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

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

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.authorization.models.ExpandedProperties;
import com.azure.resourcemanager.authorization.models.PrincipalType;
import com.azure.resourcemanager.authorization.models.RequestType;
import com.azure.resourcemanager.authorization.models.RoleEligibilityScheduleRequestPropertiesScheduleInfo;
import com.azure.resourcemanager.authorization.models.RoleEligibilityScheduleRequestPropertiesTicketInfo;
import com.azure.resourcemanager.authorization.models.Status;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.OffsetDateTime;

/** Role eligibility schedule request properties with scope. */
@Fluent
public final class RoleEligibilityScheduleRequestProperties {
    /*
     * The role eligibility schedule request scope.
     */
    @JsonProperty(value = "scope", access = JsonProperty.Access.WRITE_ONLY)
    private String scope;

    /*
     * The role definition ID.
     */
    @JsonProperty(value = "roleDefinitionId", required = true)
    private String roleDefinitionId;

    /*
     * The principal ID.
     */
    @JsonProperty(value = "principalId", required = true)
    private String principalId;

    /*
     * The principal type of the assigned principal ID.
     */
    @JsonProperty(value = "principalType", access = JsonProperty.Access.WRITE_ONLY)
    private PrincipalType principalType;

    /*
     * The type of the role assignment schedule request. Eg: SelfActivate, AdminAssign etc
     */
    @JsonProperty(value = "requestType", required = true)
    private RequestType requestType;

    /*
     * The status of the role eligibility schedule request.
     */
    @JsonProperty(value = "status", access = JsonProperty.Access.WRITE_ONLY)
    private Status status;

    /*
     * The approvalId of the role eligibility schedule request.
     */
    @JsonProperty(value = "approvalId", access = JsonProperty.Access.WRITE_ONLY)
    private String approvalId;

    /*
     * Schedule info of the role eligibility schedule
     */
    @JsonProperty(value = "scheduleInfo")
    private RoleEligibilityScheduleRequestPropertiesScheduleInfo scheduleInfo;

    /*
     * The resultant role eligibility schedule id or the role eligibility schedule id being updated
     */
    @JsonProperty(value = "targetRoleEligibilityScheduleId")
    private String targetRoleEligibilityScheduleId;

    /*
     * The role eligibility schedule instance id being updated
     */
    @JsonProperty(value = "targetRoleEligibilityScheduleInstanceId")
    private String targetRoleEligibilityScheduleInstanceId;

    /*
     * Justification for the role eligibility
     */
    @JsonProperty(value = "justification")
    private String justification;

    /*
     * Ticket Info of the role eligibility
     */
    @JsonProperty(value = "ticketInfo")
    private RoleEligibilityScheduleRequestPropertiesTicketInfo ticketInfo;

    /*
     * The conditions on the role assignment. This limits the resources it can be assigned to. e.g.:
     * @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase
     * 'foo_storage_container'
     */
    @JsonProperty(value = "condition")
    private String condition;

    /*
     * Version of the condition. Currently accepted value is '2.0'
     */
    @JsonProperty(value = "conditionVersion")
    private String conditionVersion;

    /*
     * DateTime when role eligibility schedule request was created
     */
    @JsonProperty(value = "createdOn", access = JsonProperty.Access.WRITE_ONLY)
    private OffsetDateTime createdOn;

    /*
     * Id of the user who created this request
     */
    @JsonProperty(value = "requestorId", access = JsonProperty.Access.WRITE_ONLY)
    private String requestorId;

    /*
     * Additional properties of principal, scope and role definition
     */
    @JsonProperty(value = "expandedProperties", access = JsonProperty.Access.WRITE_ONLY)
    private ExpandedProperties expandedProperties;

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

    /**
     * Get the scope property: The role eligibility schedule request scope.
     *
     * @return the scope value.
     */
    public String scope() {
        return this.scope;
    }

    /**
     * Get the roleDefinitionId property: The role definition ID.
     *
     * @return the roleDefinitionId value.
     */
    public String roleDefinitionId() {
        return this.roleDefinitionId;
    }

    /**
     * Set the roleDefinitionId property: The role definition ID.
     *
     * @param roleDefinitionId the roleDefinitionId value to set.
     * @return the RoleEligibilityScheduleRequestProperties object itself.
     */
    public RoleEligibilityScheduleRequestProperties withRoleDefinitionId(String roleDefinitionId) {
        this.roleDefinitionId = roleDefinitionId;
        return this;
    }

    /**
     * Get the principalId property: The principal ID.
     *
     * @return the principalId value.
     */
    public String principalId() {
        return this.principalId;
    }

    /**
     * Set the principalId property: The principal ID.
     *
     * @param principalId the principalId value to set.
     * @return the RoleEligibilityScheduleRequestProperties object itself.
     */
    public RoleEligibilityScheduleRequestProperties withPrincipalId(String principalId) {
        this.principalId = principalId;
        return this;
    }

    /**
     * Get the principalType property: The principal type of the assigned principal ID.
     *
     * @return the principalType value.
     */
    public PrincipalType principalType() {
        return this.principalType;
    }

    /**
     * Get the requestType property: The type of the role assignment schedule request. Eg: SelfActivate, AdminAssign
     * etc.
     *
     * @return the requestType value.
     */
    public RequestType requestType() {
        return this.requestType;
    }

    /**
     * Set the requestType property: The type of the role assignment schedule request. Eg: SelfActivate, AdminAssign
     * etc.
     *
     * @param requestType the requestType value to set.
     * @return the RoleEligibilityScheduleRequestProperties object itself.
     */
    public RoleEligibilityScheduleRequestProperties withRequestType(RequestType requestType) {
        this.requestType = requestType;
        return this;
    }

    /**
     * Get the status property: The status of the role eligibility schedule request.
     *
     * @return the status value.
     */
    public Status status() {
        return this.status;
    }

    /**
     * Get the approvalId property: The approvalId of the role eligibility schedule request.
     *
     * @return the approvalId value.
     */
    public String approvalId() {
        return this.approvalId;
    }

    /**
     * Get the scheduleInfo property: Schedule info of the role eligibility schedule.
     *
     * @return the scheduleInfo value.
     */
    public RoleEligibilityScheduleRequestPropertiesScheduleInfo scheduleInfo() {
        return this.scheduleInfo;
    }

    /**
     * Set the scheduleInfo property: Schedule info of the role eligibility schedule.
     *
     * @param scheduleInfo the scheduleInfo value to set.
     * @return the RoleEligibilityScheduleRequestProperties object itself.
     */
    public RoleEligibilityScheduleRequestProperties withScheduleInfo(
        RoleEligibilityScheduleRequestPropertiesScheduleInfo scheduleInfo) {
        this.scheduleInfo = scheduleInfo;
        return this;
    }

    /**
     * Get the targetRoleEligibilityScheduleId property: The resultant role eligibility schedule id or the role
     * eligibility schedule id being updated.
     *
     * @return the targetRoleEligibilityScheduleId value.
     */
    public String targetRoleEligibilityScheduleId() {
        return this.targetRoleEligibilityScheduleId;
    }

    /**
     * Set the targetRoleEligibilityScheduleId property: The resultant role eligibility schedule id or the role
     * eligibility schedule id being updated.
     *
     * @param targetRoleEligibilityScheduleId the targetRoleEligibilityScheduleId value to set.
     * @return the RoleEligibilityScheduleRequestProperties object itself.
     */
    public RoleEligibilityScheduleRequestProperties withTargetRoleEligibilityScheduleId(
        String targetRoleEligibilityScheduleId) {
        this.targetRoleEligibilityScheduleId = targetRoleEligibilityScheduleId;
        return this;
    }

    /**
     * Get the targetRoleEligibilityScheduleInstanceId property: The role eligibility schedule instance id being
     * updated.
     *
     * @return the targetRoleEligibilityScheduleInstanceId value.
     */
    public String targetRoleEligibilityScheduleInstanceId() {
        return this.targetRoleEligibilityScheduleInstanceId;
    }

    /**
     * Set the targetRoleEligibilityScheduleInstanceId property: The role eligibility schedule instance id being
     * updated.
     *
     * @param targetRoleEligibilityScheduleInstanceId the targetRoleEligibilityScheduleInstanceId value to set.
     * @return the RoleEligibilityScheduleRequestProperties object itself.
     */
    public RoleEligibilityScheduleRequestProperties withTargetRoleEligibilityScheduleInstanceId(
        String targetRoleEligibilityScheduleInstanceId) {
        this.targetRoleEligibilityScheduleInstanceId = targetRoleEligibilityScheduleInstanceId;
        return this;
    }

    /**
     * Get the justification property: Justification for the role eligibility.
     *
     * @return the justification value.
     */
    public String justification() {
        return this.justification;
    }

    /**
     * Set the justification property: Justification for the role eligibility.
     *
     * @param justification the justification value to set.
     * @return the RoleEligibilityScheduleRequestProperties object itself.
     */
    public RoleEligibilityScheduleRequestProperties withJustification(String justification) {
        this.justification = justification;
        return this;
    }

    /**
     * Get the ticketInfo property: Ticket Info of the role eligibility.
     *
     * @return the ticketInfo value.
     */
    public RoleEligibilityScheduleRequestPropertiesTicketInfo ticketInfo() {
        return this.ticketInfo;
    }

    /**
     * Set the ticketInfo property: Ticket Info of the role eligibility.
     *
     * @param ticketInfo the ticketInfo value to set.
     * @return the RoleEligibilityScheduleRequestProperties object itself.
     */
    public RoleEligibilityScheduleRequestProperties withTicketInfo(
        RoleEligibilityScheduleRequestPropertiesTicketInfo ticketInfo) {
        this.ticketInfo = ticketInfo;
        return this;
    }

    /**
     * Get the condition property: The conditions on the role assignment. This limits the resources it can be assigned
     * to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName]
     * StringEqualsIgnoreCase 'foo_storage_container'.
     *
     * @return the condition value.
     */
    public String condition() {
        return this.condition;
    }

    /**
     * Set the condition property: The conditions on the role assignment. This limits the resources it can be assigned
     * to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName]
     * StringEqualsIgnoreCase 'foo_storage_container'.
     *
     * @param condition the condition value to set.
     * @return the RoleEligibilityScheduleRequestProperties object itself.
     */
    public RoleEligibilityScheduleRequestProperties withCondition(String condition) {
        this.condition = condition;
        return this;
    }

    /**
     * Get the conditionVersion property: Version of the condition. Currently accepted value is '2.0'.
     *
     * @return the conditionVersion value.
     */
    public String conditionVersion() {
        return this.conditionVersion;
    }

    /**
     * Set the conditionVersion property: Version of the condition. Currently accepted value is '2.0'.
     *
     * @param conditionVersion the conditionVersion value to set.
     * @return the RoleEligibilityScheduleRequestProperties object itself.
     */
    public RoleEligibilityScheduleRequestProperties withConditionVersion(String conditionVersion) {
        this.conditionVersion = conditionVersion;
        return this;
    }

    /**
     * Get the createdOn property: DateTime when role eligibility schedule request was created.
     *
     * @return the createdOn value.
     */
    public OffsetDateTime createdOn() {
        return this.createdOn;
    }

    /**
     * Get the requestorId property: Id of the user who created this request.
     *
     * @return the requestorId value.
     */
    public String requestorId() {
        return this.requestorId;
    }

    /**
     * Get the expandedProperties property: Additional properties of principal, scope and role definition.
     *
     * @return the expandedProperties value.
     */
    public ExpandedProperties expandedProperties() {
        return this.expandedProperties;
    }

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

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