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

package com.azure.resourcemanager.paloaltonetworks.ngfw.models;

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

/** Frontend setting for Firewall. */
@Fluent
public final class FrontendSetting {
    /*
     * Settings name
     */
    @JsonProperty(value = "name", required = true)
    private String name;

    /*
     * Protocol Type
     */
    @JsonProperty(value = "protocol", required = true)
    private ProtocolType protocol;

    /*
     * Frontend configurations
     */
    @JsonProperty(value = "frontendConfiguration", required = true)
    private EndpointConfiguration frontendConfiguration;

    /*
     * Backend configurations
     */
    @JsonProperty(value = "backendConfiguration", required = true)
    private EndpointConfiguration backendConfiguration;

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

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

    /**
     * Set the name property: Settings name.
     *
     * @param name the name value to set.
     * @return the FrontendSetting object itself.
     */
    public FrontendSetting withName(String name) {
        this.name = name;
        return this;
    }

    /**
     * Get the protocol property: Protocol Type.
     *
     * @return the protocol value.
     */
    public ProtocolType protocol() {
        return this.protocol;
    }

    /**
     * Set the protocol property: Protocol Type.
     *
     * @param protocol the protocol value to set.
     * @return the FrontendSetting object itself.
     */
    public FrontendSetting withProtocol(ProtocolType protocol) {
        this.protocol = protocol;
        return this;
    }

    /**
     * Get the frontendConfiguration property: Frontend configurations.
     *
     * @return the frontendConfiguration value.
     */
    public EndpointConfiguration frontendConfiguration() {
        return this.frontendConfiguration;
    }

    /**
     * Set the frontendConfiguration property: Frontend configurations.
     *
     * @param frontendConfiguration the frontendConfiguration value to set.
     * @return the FrontendSetting object itself.
     */
    public FrontendSetting withFrontendConfiguration(EndpointConfiguration frontendConfiguration) {
        this.frontendConfiguration = frontendConfiguration;
        return this;
    }

    /**
     * Get the backendConfiguration property: Backend configurations.
     *
     * @return the backendConfiguration value.
     */
    public EndpointConfiguration backendConfiguration() {
        return this.backendConfiguration;
    }

    /**
     * Set the backendConfiguration property: Backend configurations.
     *
     * @param backendConfiguration the backendConfiguration value to set.
     * @return the FrontendSetting object itself.
     */
    public FrontendSetting withBackendConfiguration(EndpointConfiguration backendConfiguration) {
        this.backendConfiguration = backendConfiguration;
        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 FrontendSetting"));
        }
        if (protocol() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property protocol in model FrontendSetting"));
        }
        if (frontendConfiguration() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property frontendConfiguration in model FrontendSetting"));
        } else {
            frontendConfiguration().validate();
        }
        if (backendConfiguration() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property backendConfiguration in model FrontendSetting"));
        } else {
            backendConfiguration().validate();
        }
    }

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