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

package com.azure.resourcemanager.security.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.OffsetDateTime;
import java.util.List;

/** The JitNetworkAccessRequestPort model. */
@Fluent
public final class JitNetworkAccessRequestPort {
    /*
     * The number property.
     */
    @JsonProperty(value = "number", required = true)
    private int number;

    /*
     * Mutually exclusive with the "allowedSourceAddressPrefixes" parameter. Should be an IP address or CIDR, for
     * example "192.168.0.3" or "192.168.0.0/16".
     */
    @JsonProperty(value = "allowedSourceAddressPrefix")
    private String allowedSourceAddressPrefix;

    /*
     * Mutually exclusive with the "allowedSourceAddressPrefix" parameter.
     */
    @JsonProperty(value = "allowedSourceAddressPrefixes")
    private List<String> allowedSourceAddressPrefixes;

    /*
     * The date & time at which the request ends in UTC
     */
    @JsonProperty(value = "endTimeUtc", required = true)
    private OffsetDateTime endTimeUtc;

    /*
     * The status of the port
     */
    @JsonProperty(value = "status", required = true)
    private Status status;

    /*
     * A description of why the `status` has its value
     */
    @JsonProperty(value = "statusReason", required = true)
    private StatusReason statusReason;

    /*
     * The port which is mapped to this port's `number` in the Azure Firewall, if applicable
     */
    @JsonProperty(value = "mappedPort")
    private Integer mappedPort;

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

    /**
     * Get the number property: The number property.
     *
     * @return the number value.
     */
    public int number() {
        return this.number;
    }

    /**
     * Set the number property: The number property.
     *
     * @param number the number value to set.
     * @return the JitNetworkAccessRequestPort object itself.
     */
    public JitNetworkAccessRequestPort withNumber(int number) {
        this.number = number;
        return this;
    }

    /**
     * Get the allowedSourceAddressPrefix property: Mutually exclusive with the "allowedSourceAddressPrefixes"
     * parameter. Should be an IP address or CIDR, for example "192.168.0.3" or "192.168.0.0/16".
     *
     * @return the allowedSourceAddressPrefix value.
     */
    public String allowedSourceAddressPrefix() {
        return this.allowedSourceAddressPrefix;
    }

    /**
     * Set the allowedSourceAddressPrefix property: Mutually exclusive with the "allowedSourceAddressPrefixes"
     * parameter. Should be an IP address or CIDR, for example "192.168.0.3" or "192.168.0.0/16".
     *
     * @param allowedSourceAddressPrefix the allowedSourceAddressPrefix value to set.
     * @return the JitNetworkAccessRequestPort object itself.
     */
    public JitNetworkAccessRequestPort withAllowedSourceAddressPrefix(String allowedSourceAddressPrefix) {
        this.allowedSourceAddressPrefix = allowedSourceAddressPrefix;
        return this;
    }

    /**
     * Get the allowedSourceAddressPrefixes property: Mutually exclusive with the "allowedSourceAddressPrefix"
     * parameter.
     *
     * @return the allowedSourceAddressPrefixes value.
     */
    public List<String> allowedSourceAddressPrefixes() {
        return this.allowedSourceAddressPrefixes;
    }

    /**
     * Set the allowedSourceAddressPrefixes property: Mutually exclusive with the "allowedSourceAddressPrefix"
     * parameter.
     *
     * @param allowedSourceAddressPrefixes the allowedSourceAddressPrefixes value to set.
     * @return the JitNetworkAccessRequestPort object itself.
     */
    public JitNetworkAccessRequestPort withAllowedSourceAddressPrefixes(List<String> allowedSourceAddressPrefixes) {
        this.allowedSourceAddressPrefixes = allowedSourceAddressPrefixes;
        return this;
    }

    /**
     * Get the endTimeUtc property: The date &amp; time at which the request ends in UTC.
     *
     * @return the endTimeUtc value.
     */
    public OffsetDateTime endTimeUtc() {
        return this.endTimeUtc;
    }

    /**
     * Set the endTimeUtc property: The date &amp; time at which the request ends in UTC.
     *
     * @param endTimeUtc the endTimeUtc value to set.
     * @return the JitNetworkAccessRequestPort object itself.
     */
    public JitNetworkAccessRequestPort withEndTimeUtc(OffsetDateTime endTimeUtc) {
        this.endTimeUtc = endTimeUtc;
        return this;
    }

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

    /**
     * Set the status property: The status of the port.
     *
     * @param status the status value to set.
     * @return the JitNetworkAccessRequestPort object itself.
     */
    public JitNetworkAccessRequestPort withStatus(Status status) {
        this.status = status;
        return this;
    }

    /**
     * Get the statusReason property: A description of why the `status` has its value.
     *
     * @return the statusReason value.
     */
    public StatusReason statusReason() {
        return this.statusReason;
    }

    /**
     * Set the statusReason property: A description of why the `status` has its value.
     *
     * @param statusReason the statusReason value to set.
     * @return the JitNetworkAccessRequestPort object itself.
     */
    public JitNetworkAccessRequestPort withStatusReason(StatusReason statusReason) {
        this.statusReason = statusReason;
        return this;
    }

    /**
     * Get the mappedPort property: The port which is mapped to this port's `number` in the Azure Firewall, if
     * applicable.
     *
     * @return the mappedPort value.
     */
    public Integer mappedPort() {
        return this.mappedPort;
    }

    /**
     * Set the mappedPort property: The port which is mapped to this port's `number` in the Azure Firewall, if
     * applicable.
     *
     * @param mappedPort the mappedPort value to set.
     * @return the JitNetworkAccessRequestPort object itself.
     */
    public JitNetworkAccessRequestPort withMappedPort(Integer mappedPort) {
        this.mappedPort = mappedPort;
        return this;
    }

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

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