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

package com.azure.resourcemanager.managednetworkfabric.models;

import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** BGP configuration properties. */
@Fluent
public final class BgpConfiguration extends AnnotationResource {
    /*
     * BFD configuration properties
     */
    @JsonProperty(value = "bfdConfiguration")
    private BfdConfiguration bfdConfiguration;

    /*
     * Originate a defaultRoute. Ex: "True" | "False".
     */
    @JsonProperty(value = "defaultRouteOriginate")
    private BooleanEnumProperty defaultRouteOriginate;

    /*
     * Allows for routes to be received and processed even if the router detects its own ASN in the AS-Path. 0 is
     * disable, Possible values are 1-10, default is 2.
     */
    @JsonProperty(value = "allowAS")
    private Integer allowAS;

    /*
     * Enable Or Disable state.
     */
    @JsonProperty(value = "allowASOverride")
    private AllowASOverride allowASOverride;

    /*
     * ASN of Network Fabric. Example: 65048.
     */
    @JsonProperty(value = "fabricASN", access = JsonProperty.Access.WRITE_ONLY)
    private Integer fabricAsn;

    /*
     * Peer ASN. Example: 65047.
     */
    @JsonProperty(value = "peerASN", required = true)
    private int peerAsn;

    /*
     * BGP Ipv4 ListenRange.
     */
    @JsonProperty(value = "ipv4ListenRangePrefixes")
    private List<String> ipv4ListenRangePrefixes;

    /*
     * BGP Ipv6 ListenRange.
     */
    @JsonProperty(value = "ipv6ListenRangePrefixes")
    private List<String> ipv6ListenRangePrefixes;

    /*
     * List with stringified ipv4NeighborAddresses.
     */
    @JsonProperty(value = "ipv4NeighborAddress")
    private List<NeighborAddress> ipv4NeighborAddress;

    /*
     * List with stringified IPv6 Neighbor Address.
     */
    @JsonProperty(value = "ipv6NeighborAddress")
    private List<NeighborAddress> ipv6NeighborAddress;

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

    /**
     * Get the bfdConfiguration property: BFD configuration properties.
     *
     * @return the bfdConfiguration value.
     */
    public BfdConfiguration bfdConfiguration() {
        return this.bfdConfiguration;
    }

    /**
     * Set the bfdConfiguration property: BFD configuration properties.
     *
     * @param bfdConfiguration the bfdConfiguration value to set.
     * @return the BgpConfiguration object itself.
     */
    public BgpConfiguration withBfdConfiguration(BfdConfiguration bfdConfiguration) {
        this.bfdConfiguration = bfdConfiguration;
        return this;
    }

    /**
     * Get the defaultRouteOriginate property: Originate a defaultRoute. Ex: "True" | "False".
     *
     * @return the defaultRouteOriginate value.
     */
    public BooleanEnumProperty defaultRouteOriginate() {
        return this.defaultRouteOriginate;
    }

    /**
     * Set the defaultRouteOriginate property: Originate a defaultRoute. Ex: "True" | "False".
     *
     * @param defaultRouteOriginate the defaultRouteOriginate value to set.
     * @return the BgpConfiguration object itself.
     */
    public BgpConfiguration withDefaultRouteOriginate(BooleanEnumProperty defaultRouteOriginate) {
        this.defaultRouteOriginate = defaultRouteOriginate;
        return this;
    }

    /**
     * Get the allowAS property: Allows for routes to be received and processed even if the router detects its own ASN
     * in the AS-Path. 0 is disable, Possible values are 1-10, default is 2.
     *
     * @return the allowAS value.
     */
    public Integer allowAS() {
        return this.allowAS;
    }

    /**
     * Set the allowAS property: Allows for routes to be received and processed even if the router detects its own ASN
     * in the AS-Path. 0 is disable, Possible values are 1-10, default is 2.
     *
     * @param allowAS the allowAS value to set.
     * @return the BgpConfiguration object itself.
     */
    public BgpConfiguration withAllowAS(Integer allowAS) {
        this.allowAS = allowAS;
        return this;
    }

    /**
     * Get the allowASOverride property: Enable Or Disable state.
     *
     * @return the allowASOverride value.
     */
    public AllowASOverride allowASOverride() {
        return this.allowASOverride;
    }

    /**
     * Set the allowASOverride property: Enable Or Disable state.
     *
     * @param allowASOverride the allowASOverride value to set.
     * @return the BgpConfiguration object itself.
     */
    public BgpConfiguration withAllowASOverride(AllowASOverride allowASOverride) {
        this.allowASOverride = allowASOverride;
        return this;
    }

    /**
     * Get the fabricAsn property: ASN of Network Fabric. Example: 65048.
     *
     * @return the fabricAsn value.
     */
    public Integer fabricAsn() {
        return this.fabricAsn;
    }

    /**
     * Get the peerAsn property: Peer ASN. Example: 65047.
     *
     * @return the peerAsn value.
     */
    public int peerAsn() {
        return this.peerAsn;
    }

    /**
     * Set the peerAsn property: Peer ASN. Example: 65047.
     *
     * @param peerAsn the peerAsn value to set.
     * @return the BgpConfiguration object itself.
     */
    public BgpConfiguration withPeerAsn(int peerAsn) {
        this.peerAsn = peerAsn;
        return this;
    }

    /**
     * Get the ipv4ListenRangePrefixes property: BGP Ipv4 ListenRange.
     *
     * @return the ipv4ListenRangePrefixes value.
     */
    public List<String> ipv4ListenRangePrefixes() {
        return this.ipv4ListenRangePrefixes;
    }

    /**
     * Set the ipv4ListenRangePrefixes property: BGP Ipv4 ListenRange.
     *
     * @param ipv4ListenRangePrefixes the ipv4ListenRangePrefixes value to set.
     * @return the BgpConfiguration object itself.
     */
    public BgpConfiguration withIpv4ListenRangePrefixes(List<String> ipv4ListenRangePrefixes) {
        this.ipv4ListenRangePrefixes = ipv4ListenRangePrefixes;
        return this;
    }

    /**
     * Get the ipv6ListenRangePrefixes property: BGP Ipv6 ListenRange.
     *
     * @return the ipv6ListenRangePrefixes value.
     */
    public List<String> ipv6ListenRangePrefixes() {
        return this.ipv6ListenRangePrefixes;
    }

    /**
     * Set the ipv6ListenRangePrefixes property: BGP Ipv6 ListenRange.
     *
     * @param ipv6ListenRangePrefixes the ipv6ListenRangePrefixes value to set.
     * @return the BgpConfiguration object itself.
     */
    public BgpConfiguration withIpv6ListenRangePrefixes(List<String> ipv6ListenRangePrefixes) {
        this.ipv6ListenRangePrefixes = ipv6ListenRangePrefixes;
        return this;
    }

    /**
     * Get the ipv4NeighborAddress property: List with stringified ipv4NeighborAddresses.
     *
     * @return the ipv4NeighborAddress value.
     */
    public List<NeighborAddress> ipv4NeighborAddress() {
        return this.ipv4NeighborAddress;
    }

    /**
     * Set the ipv4NeighborAddress property: List with stringified ipv4NeighborAddresses.
     *
     * @param ipv4NeighborAddress the ipv4NeighborAddress value to set.
     * @return the BgpConfiguration object itself.
     */
    public BgpConfiguration withIpv4NeighborAddress(List<NeighborAddress> ipv4NeighborAddress) {
        this.ipv4NeighborAddress = ipv4NeighborAddress;
        return this;
    }

    /**
     * Get the ipv6NeighborAddress property: List with stringified IPv6 Neighbor Address.
     *
     * @return the ipv6NeighborAddress value.
     */
    public List<NeighborAddress> ipv6NeighborAddress() {
        return this.ipv6NeighborAddress;
    }

    /**
     * Set the ipv6NeighborAddress property: List with stringified IPv6 Neighbor Address.
     *
     * @param ipv6NeighborAddress the ipv6NeighborAddress value to set.
     * @return the BgpConfiguration object itself.
     */
    public BgpConfiguration withIpv6NeighborAddress(List<NeighborAddress> ipv6NeighborAddress) {
        this.ipv6NeighborAddress = ipv6NeighborAddress;
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public BgpConfiguration withAnnotation(String annotation) {
        super.withAnnotation(annotation);
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
        super.validate();
        if (bfdConfiguration() != null) {
            bfdConfiguration().validate();
        }
        if (ipv4NeighborAddress() != null) {
            ipv4NeighborAddress().forEach(e -> e.validate());
        }
        if (ipv6NeighborAddress() != null) {
            ipv6NeighborAddress().forEach(e -> e.validate());
        }
    }
}
