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

package com.azure.resourcemanager.logic.models;

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

/** The AS2 agreement protocol settings. */
@Fluent
public final class AS2ProtocolSettings {
    /*
     * The message connection settings.
     */
    @JsonProperty(value = "messageConnectionSettings", required = true)
    private AS2MessageConnectionSettings messageConnectionSettings;

    /*
     * The acknowledgement connection settings.
     */
    @JsonProperty(value = "acknowledgementConnectionSettings", required = true)
    private AS2AcknowledgementConnectionSettings acknowledgementConnectionSettings;

    /*
     * The MDN settings.
     */
    @JsonProperty(value = "mdnSettings", required = true)
    private AS2MdnSettings mdnSettings;

    /*
     * The security settings.
     */
    @JsonProperty(value = "securitySettings", required = true)
    private AS2SecuritySettings securitySettings;

    /*
     * The validation settings.
     */
    @JsonProperty(value = "validationSettings", required = true)
    private AS2ValidationSettings validationSettings;

    /*
     * The envelope settings.
     */
    @JsonProperty(value = "envelopeSettings", required = true)
    private AS2EnvelopeSettings envelopeSettings;

    /*
     * The error settings.
     */
    @JsonProperty(value = "errorSettings", required = true)
    private AS2ErrorSettings errorSettings;

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

    /**
     * Get the messageConnectionSettings property: The message connection settings.
     *
     * @return the messageConnectionSettings value.
     */
    public AS2MessageConnectionSettings messageConnectionSettings() {
        return this.messageConnectionSettings;
    }

    /**
     * Set the messageConnectionSettings property: The message connection settings.
     *
     * @param messageConnectionSettings the messageConnectionSettings value to set.
     * @return the AS2ProtocolSettings object itself.
     */
    public AS2ProtocolSettings withMessageConnectionSettings(AS2MessageConnectionSettings messageConnectionSettings) {
        this.messageConnectionSettings = messageConnectionSettings;
        return this;
    }

    /**
     * Get the acknowledgementConnectionSettings property: The acknowledgement connection settings.
     *
     * @return the acknowledgementConnectionSettings value.
     */
    public AS2AcknowledgementConnectionSettings acknowledgementConnectionSettings() {
        return this.acknowledgementConnectionSettings;
    }

    /**
     * Set the acknowledgementConnectionSettings property: The acknowledgement connection settings.
     *
     * @param acknowledgementConnectionSettings the acknowledgementConnectionSettings value to set.
     * @return the AS2ProtocolSettings object itself.
     */
    public AS2ProtocolSettings withAcknowledgementConnectionSettings(
        AS2AcknowledgementConnectionSettings acknowledgementConnectionSettings) {
        this.acknowledgementConnectionSettings = acknowledgementConnectionSettings;
        return this;
    }

    /**
     * Get the mdnSettings property: The MDN settings.
     *
     * @return the mdnSettings value.
     */
    public AS2MdnSettings mdnSettings() {
        return this.mdnSettings;
    }

    /**
     * Set the mdnSettings property: The MDN settings.
     *
     * @param mdnSettings the mdnSettings value to set.
     * @return the AS2ProtocolSettings object itself.
     */
    public AS2ProtocolSettings withMdnSettings(AS2MdnSettings mdnSettings) {
        this.mdnSettings = mdnSettings;
        return this;
    }

    /**
     * Get the securitySettings property: The security settings.
     *
     * @return the securitySettings value.
     */
    public AS2SecuritySettings securitySettings() {
        return this.securitySettings;
    }

    /**
     * Set the securitySettings property: The security settings.
     *
     * @param securitySettings the securitySettings value to set.
     * @return the AS2ProtocolSettings object itself.
     */
    public AS2ProtocolSettings withSecuritySettings(AS2SecuritySettings securitySettings) {
        this.securitySettings = securitySettings;
        return this;
    }

    /**
     * Get the validationSettings property: The validation settings.
     *
     * @return the validationSettings value.
     */
    public AS2ValidationSettings validationSettings() {
        return this.validationSettings;
    }

    /**
     * Set the validationSettings property: The validation settings.
     *
     * @param validationSettings the validationSettings value to set.
     * @return the AS2ProtocolSettings object itself.
     */
    public AS2ProtocolSettings withValidationSettings(AS2ValidationSettings validationSettings) {
        this.validationSettings = validationSettings;
        return this;
    }

    /**
     * Get the envelopeSettings property: The envelope settings.
     *
     * @return the envelopeSettings value.
     */
    public AS2EnvelopeSettings envelopeSettings() {
        return this.envelopeSettings;
    }

    /**
     * Set the envelopeSettings property: The envelope settings.
     *
     * @param envelopeSettings the envelopeSettings value to set.
     * @return the AS2ProtocolSettings object itself.
     */
    public AS2ProtocolSettings withEnvelopeSettings(AS2EnvelopeSettings envelopeSettings) {
        this.envelopeSettings = envelopeSettings;
        return this;
    }

    /**
     * Get the errorSettings property: The error settings.
     *
     * @return the errorSettings value.
     */
    public AS2ErrorSettings errorSettings() {
        return this.errorSettings;
    }

    /**
     * Set the errorSettings property: The error settings.
     *
     * @param errorSettings the errorSettings value to set.
     * @return the AS2ProtocolSettings object itself.
     */
    public AS2ProtocolSettings withErrorSettings(AS2ErrorSettings errorSettings) {
        this.errorSettings = errorSettings;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (messageConnectionSettings() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property messageConnectionSettings in model AS2ProtocolSettings"));
        } else {
            messageConnectionSettings().validate();
        }
        if (acknowledgementConnectionSettings() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property acknowledgementConnectionSettings in model AS2ProtocolSettings"));
        } else {
            acknowledgementConnectionSettings().validate();
        }
        if (mdnSettings() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property mdnSettings in model AS2ProtocolSettings"));
        } else {
            mdnSettings().validate();
        }
        if (securitySettings() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property securitySettings in model AS2ProtocolSettings"));
        } else {
            securitySettings().validate();
        }
        if (validationSettings() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property validationSettings in model AS2ProtocolSettings"));
        } else {
            validationSettings().validate();
        }
        if (envelopeSettings() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property envelopeSettings in model AS2ProtocolSettings"));
        } else {
            envelopeSettings().validate();
        }
        if (errorSettings() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property errorSettings in model AS2ProtocolSettings"));
        } else {
            errorSettings().validate();
        }
    }

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