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

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

import com.azure.core.annotation.Fluent;
import com.azure.resourcemanager.devcenter.models.EnvironmentTypeEnableStatus;
import com.azure.resourcemanager.devcenter.models.ProjectEnvironmentTypeUpdatePropertiesCreatorRoleAssignment;
import com.azure.resourcemanager.devcenter.models.UserRoleAssignmentValue;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Map;

/** Properties of a project environment type. These properties can be updated after the resource has been created. */
@Fluent
public class ProjectEnvironmentTypeUpdateProperties {
    /*
     * Id of a subscription that the environment type will be mapped to. The environment's resources will be deployed
     * into this subscription.
     */
    @JsonProperty(value = "deploymentTargetId")
    private String deploymentTargetId;

    /*
     * Defines whether this Environment Type can be used in this Project.
     */
    @JsonProperty(value = "status")
    private EnvironmentTypeEnableStatus status;

    /*
     * The role definition assigned to the environment creator on backing resources.
     */
    @JsonProperty(value = "creatorRoleAssignment")
    private ProjectEnvironmentTypeUpdatePropertiesCreatorRoleAssignment creatorRoleAssignment;

    /*
     * Role Assignments created on environment backing resources. This is a mapping from a user object ID to an object
     * of role definition IDs.
     */
    @JsonProperty(value = "userRoleAssignments")
    @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS)
    private Map<String, UserRoleAssignmentValue> userRoleAssignments;

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

    /**
     * Get the deploymentTargetId property: Id of a subscription that the environment type will be mapped to. The
     * environment's resources will be deployed into this subscription.
     *
     * @return the deploymentTargetId value.
     */
    public String deploymentTargetId() {
        return this.deploymentTargetId;
    }

    /**
     * Set the deploymentTargetId property: Id of a subscription that the environment type will be mapped to. The
     * environment's resources will be deployed into this subscription.
     *
     * @param deploymentTargetId the deploymentTargetId value to set.
     * @return the ProjectEnvironmentTypeUpdateProperties object itself.
     */
    public ProjectEnvironmentTypeUpdateProperties withDeploymentTargetId(String deploymentTargetId) {
        this.deploymentTargetId = deploymentTargetId;
        return this;
    }

    /**
     * Get the status property: Defines whether this Environment Type can be used in this Project.
     *
     * @return the status value.
     */
    public EnvironmentTypeEnableStatus status() {
        return this.status;
    }

    /**
     * Set the status property: Defines whether this Environment Type can be used in this Project.
     *
     * @param status the status value to set.
     * @return the ProjectEnvironmentTypeUpdateProperties object itself.
     */
    public ProjectEnvironmentTypeUpdateProperties withStatus(EnvironmentTypeEnableStatus status) {
        this.status = status;
        return this;
    }

    /**
     * Get the creatorRoleAssignment property: The role definition assigned to the environment creator on backing
     * resources.
     *
     * @return the creatorRoleAssignment value.
     */
    public ProjectEnvironmentTypeUpdatePropertiesCreatorRoleAssignment creatorRoleAssignment() {
        return this.creatorRoleAssignment;
    }

    /**
     * Set the creatorRoleAssignment property: The role definition assigned to the environment creator on backing
     * resources.
     *
     * @param creatorRoleAssignment the creatorRoleAssignment value to set.
     * @return the ProjectEnvironmentTypeUpdateProperties object itself.
     */
    public ProjectEnvironmentTypeUpdateProperties withCreatorRoleAssignment(
        ProjectEnvironmentTypeUpdatePropertiesCreatorRoleAssignment creatorRoleAssignment) {
        this.creatorRoleAssignment = creatorRoleAssignment;
        return this;
    }

    /**
     * Get the userRoleAssignments property: Role Assignments created on environment backing resources. This is a
     * mapping from a user object ID to an object of role definition IDs.
     *
     * @return the userRoleAssignments value.
     */
    public Map<String, UserRoleAssignmentValue> userRoleAssignments() {
        return this.userRoleAssignments;
    }

    /**
     * Set the userRoleAssignments property: Role Assignments created on environment backing resources. This is a
     * mapping from a user object ID to an object of role definition IDs.
     *
     * @param userRoleAssignments the userRoleAssignments value to set.
     * @return the ProjectEnvironmentTypeUpdateProperties object itself.
     */
    public ProjectEnvironmentTypeUpdateProperties withUserRoleAssignments(
        Map<String, UserRoleAssignmentValue> userRoleAssignments) {
        this.userRoleAssignments = userRoleAssignments;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (creatorRoleAssignment() != null) {
            creatorRoleAssignment().validate();
        }
        if (userRoleAssignments() != null) {
            userRoleAssignments()
                .values()
                .forEach(
                    e -> {
                        if (e != null) {
                            e.validate();
                        }
                    });
        }
    }
}
