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

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

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.customerinsights.models.AssignmentPrincipal;
import com.azure.resourcemanager.customerinsights.models.ProvisioningStates;
import com.azure.resourcemanager.customerinsights.models.ResourceSetDescription;
import com.azure.resourcemanager.customerinsights.models.RoleTypes;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import java.util.Map;

/** The Role Assignment definition. */
@Fluent
public final class RoleAssignment {
    /*
     * The hub name.
     */
    @JsonProperty(value = "tenantId", access = JsonProperty.Access.WRITE_ONLY)
    private String tenantId;

    /*
     * The name of the metadata object.
     */
    @JsonProperty(value = "assignmentName", access = JsonProperty.Access.WRITE_ONLY)
    private String assignmentName;

    /*
     * Localized display names for the metadata.
     */
    @JsonProperty(value = "displayName")
    @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS)
    private Map<String, String> displayName;

    /*
     * Localized description for the metadata.
     */
    @JsonProperty(value = "description")
    @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS)
    private Map<String, String> description;

    /*
     * Provisioning state.
     */
    @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY)
    private ProvisioningStates provisioningState;

    /*
     * Type of roles.
     */
    @JsonProperty(value = "role", required = true)
    private RoleTypes role;

    /*
     * The principals being assigned to.
     */
    @JsonProperty(value = "principals", required = true)
    private List<AssignmentPrincipal> principals;

    /*
     * Profiles set for the assignment.
     */
    @JsonProperty(value = "profiles")
    private ResourceSetDescription profiles;

    /*
     * Interactions set for the assignment.
     */
    @JsonProperty(value = "interactions")
    private ResourceSetDescription interactions;

    /*
     * Links set for the assignment.
     */
    @JsonProperty(value = "links")
    private ResourceSetDescription links;

    /*
     * Kpis set for the assignment.
     */
    @JsonProperty(value = "kpis")
    private ResourceSetDescription kpis;

    /*
     * Sas Policies set for the assignment.
     */
    @JsonProperty(value = "sasPolicies")
    private ResourceSetDescription sasPolicies;

    /*
     * Connectors set for the assignment.
     */
    @JsonProperty(value = "connectors")
    private ResourceSetDescription connectors;

    /*
     * Views set for the assignment.
     */
    @JsonProperty(value = "views")
    private ResourceSetDescription views;

    /*
     * The Role assignments set for the relationship links.
     */
    @JsonProperty(value = "relationshipLinks")
    private ResourceSetDescription relationshipLinks;

    /*
     * The Role assignments set for the relationships.
     */
    @JsonProperty(value = "relationships")
    private ResourceSetDescription relationships;

    /*
     * Widget types set for the assignment.
     */
    @JsonProperty(value = "widgetTypes")
    private ResourceSetDescription widgetTypes;

    /*
     * The Role assignments set for the assignment.
     */
    @JsonProperty(value = "roleAssignments")
    private ResourceSetDescription roleAssignments;

    /*
     * Widget types set for the assignment.
     */
    @JsonProperty(value = "conflationPolicies")
    private ResourceSetDescription conflationPolicies;

    /*
     * The Role assignments set for the assignment.
     */
    @JsonProperty(value = "segments")
    private ResourceSetDescription segments;

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

    /**
     * Get the tenantId property: The hub name.
     *
     * @return the tenantId value.
     */
    public String tenantId() {
        return this.tenantId;
    }

    /**
     * Get the assignmentName property: The name of the metadata object.
     *
     * @return the assignmentName value.
     */
    public String assignmentName() {
        return this.assignmentName;
    }

    /**
     * Get the displayName property: Localized display names for the metadata.
     *
     * @return the displayName value.
     */
    public Map<String, String> displayName() {
        return this.displayName;
    }

    /**
     * Set the displayName property: Localized display names for the metadata.
     *
     * @param displayName the displayName value to set.
     * @return the RoleAssignment object itself.
     */
    public RoleAssignment withDisplayName(Map<String, String> displayName) {
        this.displayName = displayName;
        return this;
    }

    /**
     * Get the description property: Localized description for the metadata.
     *
     * @return the description value.
     */
    public Map<String, String> description() {
        return this.description;
    }

    /**
     * Set the description property: Localized description for the metadata.
     *
     * @param description the description value to set.
     * @return the RoleAssignment object itself.
     */
    public RoleAssignment withDescription(Map<String, String> description) {
        this.description = description;
        return this;
    }

    /**
     * Get the provisioningState property: Provisioning state.
     *
     * @return the provisioningState value.
     */
    public ProvisioningStates provisioningState() {
        return this.provisioningState;
    }

    /**
     * Get the role property: Type of roles.
     *
     * @return the role value.
     */
    public RoleTypes role() {
        return this.role;
    }

    /**
     * Set the role property: Type of roles.
     *
     * @param role the role value to set.
     * @return the RoleAssignment object itself.
     */
    public RoleAssignment withRole(RoleTypes role) {
        this.role = role;
        return this;
    }

    /**
     * Get the principals property: The principals being assigned to.
     *
     * @return the principals value.
     */
    public List<AssignmentPrincipal> principals() {
        return this.principals;
    }

    /**
     * Set the principals property: The principals being assigned to.
     *
     * @param principals the principals value to set.
     * @return the RoleAssignment object itself.
     */
    public RoleAssignment withPrincipals(List<AssignmentPrincipal> principals) {
        this.principals = principals;
        return this;
    }

    /**
     * Get the profiles property: Profiles set for the assignment.
     *
     * @return the profiles value.
     */
    public ResourceSetDescription profiles() {
        return this.profiles;
    }

    /**
     * Set the profiles property: Profiles set for the assignment.
     *
     * @param profiles the profiles value to set.
     * @return the RoleAssignment object itself.
     */
    public RoleAssignment withProfiles(ResourceSetDescription profiles) {
        this.profiles = profiles;
        return this;
    }

    /**
     * Get the interactions property: Interactions set for the assignment.
     *
     * @return the interactions value.
     */
    public ResourceSetDescription interactions() {
        return this.interactions;
    }

    /**
     * Set the interactions property: Interactions set for the assignment.
     *
     * @param interactions the interactions value to set.
     * @return the RoleAssignment object itself.
     */
    public RoleAssignment withInteractions(ResourceSetDescription interactions) {
        this.interactions = interactions;
        return this;
    }

    /**
     * Get the links property: Links set for the assignment.
     *
     * @return the links value.
     */
    public ResourceSetDescription links() {
        return this.links;
    }

    /**
     * Set the links property: Links set for the assignment.
     *
     * @param links the links value to set.
     * @return the RoleAssignment object itself.
     */
    public RoleAssignment withLinks(ResourceSetDescription links) {
        this.links = links;
        return this;
    }

    /**
     * Get the kpis property: Kpis set for the assignment.
     *
     * @return the kpis value.
     */
    public ResourceSetDescription kpis() {
        return this.kpis;
    }

    /**
     * Set the kpis property: Kpis set for the assignment.
     *
     * @param kpis the kpis value to set.
     * @return the RoleAssignment object itself.
     */
    public RoleAssignment withKpis(ResourceSetDescription kpis) {
        this.kpis = kpis;
        return this;
    }

    /**
     * Get the sasPolicies property: Sas Policies set for the assignment.
     *
     * @return the sasPolicies value.
     */
    public ResourceSetDescription sasPolicies() {
        return this.sasPolicies;
    }

    /**
     * Set the sasPolicies property: Sas Policies set for the assignment.
     *
     * @param sasPolicies the sasPolicies value to set.
     * @return the RoleAssignment object itself.
     */
    public RoleAssignment withSasPolicies(ResourceSetDescription sasPolicies) {
        this.sasPolicies = sasPolicies;
        return this;
    }

    /**
     * Get the connectors property: Connectors set for the assignment.
     *
     * @return the connectors value.
     */
    public ResourceSetDescription connectors() {
        return this.connectors;
    }

    /**
     * Set the connectors property: Connectors set for the assignment.
     *
     * @param connectors the connectors value to set.
     * @return the RoleAssignment object itself.
     */
    public RoleAssignment withConnectors(ResourceSetDescription connectors) {
        this.connectors = connectors;
        return this;
    }

    /**
     * Get the views property: Views set for the assignment.
     *
     * @return the views value.
     */
    public ResourceSetDescription views() {
        return this.views;
    }

    /**
     * Set the views property: Views set for the assignment.
     *
     * @param views the views value to set.
     * @return the RoleAssignment object itself.
     */
    public RoleAssignment withViews(ResourceSetDescription views) {
        this.views = views;
        return this;
    }

    /**
     * Get the relationshipLinks property: The Role assignments set for the relationship links.
     *
     * @return the relationshipLinks value.
     */
    public ResourceSetDescription relationshipLinks() {
        return this.relationshipLinks;
    }

    /**
     * Set the relationshipLinks property: The Role assignments set for the relationship links.
     *
     * @param relationshipLinks the relationshipLinks value to set.
     * @return the RoleAssignment object itself.
     */
    public RoleAssignment withRelationshipLinks(ResourceSetDescription relationshipLinks) {
        this.relationshipLinks = relationshipLinks;
        return this;
    }

    /**
     * Get the relationships property: The Role assignments set for the relationships.
     *
     * @return the relationships value.
     */
    public ResourceSetDescription relationships() {
        return this.relationships;
    }

    /**
     * Set the relationships property: The Role assignments set for the relationships.
     *
     * @param relationships the relationships value to set.
     * @return the RoleAssignment object itself.
     */
    public RoleAssignment withRelationships(ResourceSetDescription relationships) {
        this.relationships = relationships;
        return this;
    }

    /**
     * Get the widgetTypes property: Widget types set for the assignment.
     *
     * @return the widgetTypes value.
     */
    public ResourceSetDescription widgetTypes() {
        return this.widgetTypes;
    }

    /**
     * Set the widgetTypes property: Widget types set for the assignment.
     *
     * @param widgetTypes the widgetTypes value to set.
     * @return the RoleAssignment object itself.
     */
    public RoleAssignment withWidgetTypes(ResourceSetDescription widgetTypes) {
        this.widgetTypes = widgetTypes;
        return this;
    }

    /**
     * Get the roleAssignments property: The Role assignments set for the assignment.
     *
     * @return the roleAssignments value.
     */
    public ResourceSetDescription roleAssignments() {
        return this.roleAssignments;
    }

    /**
     * Set the roleAssignments property: The Role assignments set for the assignment.
     *
     * @param roleAssignments the roleAssignments value to set.
     * @return the RoleAssignment object itself.
     */
    public RoleAssignment withRoleAssignments(ResourceSetDescription roleAssignments) {
        this.roleAssignments = roleAssignments;
        return this;
    }

    /**
     * Get the conflationPolicies property: Widget types set for the assignment.
     *
     * @return the conflationPolicies value.
     */
    public ResourceSetDescription conflationPolicies() {
        return this.conflationPolicies;
    }

    /**
     * Set the conflationPolicies property: Widget types set for the assignment.
     *
     * @param conflationPolicies the conflationPolicies value to set.
     * @return the RoleAssignment object itself.
     */
    public RoleAssignment withConflationPolicies(ResourceSetDescription conflationPolicies) {
        this.conflationPolicies = conflationPolicies;
        return this;
    }

    /**
     * Get the segments property: The Role assignments set for the assignment.
     *
     * @return the segments value.
     */
    public ResourceSetDescription segments() {
        return this.segments;
    }

    /**
     * Set the segments property: The Role assignments set for the assignment.
     *
     * @param segments the segments value to set.
     * @return the RoleAssignment object itself.
     */
    public RoleAssignment withSegments(ResourceSetDescription segments) {
        this.segments = segments;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (role() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property role in model RoleAssignment"));
        }
        if (principals() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property principals in model RoleAssignment"));
        } else {
            principals().forEach(e -> e.validate());
        }
        if (profiles() != null) {
            profiles().validate();
        }
        if (interactions() != null) {
            interactions().validate();
        }
        if (links() != null) {
            links().validate();
        }
        if (kpis() != null) {
            kpis().validate();
        }
        if (sasPolicies() != null) {
            sasPolicies().validate();
        }
        if (connectors() != null) {
            connectors().validate();
        }
        if (views() != null) {
            views().validate();
        }
        if (relationshipLinks() != null) {
            relationshipLinks().validate();
        }
        if (relationships() != null) {
            relationships().validate();
        }
        if (widgetTypes() != null) {
            widgetTypes().validate();
        }
        if (roleAssignments() != null) {
            roleAssignments().validate();
        }
        if (conflationPolicies() != null) {
            conflationPolicies().validate();
        }
        if (segments() != null) {
            segments().validate();
        }
    }

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