// Code generated by sidekick. DO NOT EDIT.
//
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#if Routers
  import Foundation
  import GoogleCloudWkt

  public struct RouterBgpPeer: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// User-specified flag to indicate which mode to use for advertisement.
    public var advertiseMode: RouterBgpPeer.AdvertiseMode? = nil

    /// User-specified list of prefix groups to advertise in custom mode,
    /// which currently supports the following option:
    ///
    ///    - ALL_SUBNETS: Advertises all of the router's own VPC subnets. This
    ///    excludes any routes learned for subnets that use
    ///    VPC Network Peering.
    ///
    ///
    /// Note that this field can only be populated if advertise_mode is CUSTOM
    /// and overrides the list defined for the router (in the "bgp" message).
    /// These groups are advertised in addition to any specified prefixes.
    /// Leave this field blank to advertise no custom groups.
    public var advertisedGroups: [RouterBgpPeer.AdvertisedGroups] = []

    /// User-specified list of individual IP ranges to advertise in custom mode.
    /// This field can only be populated if advertise_mode is CUSTOM and
    /// overrides the list defined for the router (in the "bgp" message).
    /// These IP ranges are advertised in addition to any specified groups.
    /// Leave this field blank to advertise no custom IP ranges.
    public var advertisedIpRanges: [RouterAdvertisedIpRange] = []

    /// The priority of routes advertised to this BGP peer. Where there is more
    /// than one matching route of maximum length, the routes with the lowest
    /// priority value win.
    public var advertisedRoutePriority: Swift.UInt32? = nil

    /// BFD configuration for the BGP peering.
    public var bfd: RouterBgpPeerBfd? = nil

    /// A list of user-defined custom learned route IP address ranges for a BGP
    /// session.
    public var customLearnedIpRanges: [RouterBgpPeerCustomLearnedIpRange] = []

    /// The user-defined custom learned route priority for a BGP session. This
    /// value is applied to all custom learned route ranges for the session.
    /// You can choose a value from `0` to `65335`. If you don't provide a
    /// value, Google Cloud assigns a priority of `100` to the ranges.
    public var customLearnedRoutePriority: Swift.Int32? = nil

    /// The status of the BGP peer connection.
    ///
    ///
    /// If set to FALSE, any active session with the peer is terminated and
    /// all associated routing information is removed. If set to TRUE, the
    /// peer connection can be established with routing information. The default
    /// is TRUE.
    public var enable: RouterBgpPeer.Enable? = nil

    /// Enable IPv4 traffic over BGP Peer. It is enabled by default if
    /// the peerIpAddress is version 4.
    public var enableIpv4: Swift.Bool? = nil

    /// Enable IPv6 traffic over BGP Peer. It is enabled by default if the
    /// peerIpAddress is version 6.
    public var enableIpv6: Swift.Bool? = nil

    /// List of export policies applied to this peer, in the order they must be
    /// evaluated. The name must correspond to an existing policy that has
    /// ROUTE_POLICY_TYPE_EXPORT type.
    public var exportPolicies: [Swift.String] = []

    /// List of import policies applied to this peer, in the order they must be
    /// evaluated. The name must correspond to an existing policy that has
    /// ROUTE_POLICY_TYPE_IMPORT type.
    public var importPolicies: [Swift.String] = []

    /// Name of the interface the BGP peer is associated with.
    public var interfaceName: Swift.String? = nil

    /// IP address of the interface inside Google Cloud Platform.
    public var ipAddress: Swift.String? = nil

    /// IPv4 address of the interface inside Google Cloud Platform.
    public var ipv4NexthopAddress: Swift.String? = nil

    /// IPv6 address of the interface inside Google Cloud Platform.
    public var ipv6NexthopAddress: Swift.String? = nil

    /// Output only. [Output Only] The resource that configures and manages this BGP peer.
    ///
    ///    -  MANAGED_BY_USER is the default value and can be managed by you
    ///    or other users
    ///    - MANAGED_BY_ATTACHMENT is a BGP peer that is configured and managed
    ///    by Cloud Interconnect, specifically by an InterconnectAttachment of type
    ///    PARTNER. Google automatically creates, updates, and deletes this type of
    ///    BGP peer when the PARTNER InterconnectAttachment is created, updated,
    ///    or deleted.
    public var managementType: RouterBgpPeer.ManagementType? = nil

    /// Present if MD5 authentication is enabled for the peering. Must be the
    /// name of one of the entries in the Router.md5_authentication_keys. The
    /// field must comply with RFC1035.
    public var md5AuthenticationKeyName: Swift.String? = nil

    /// Name of this BGP peer.
    /// The name must be 1-63 characters long, and comply withRFC1035. Specifically, the name must be 1-63
    /// characters long and match the regular expression
    /// `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a
    /// lowercase letter, and all following characters must be a dash, lowercase
    /// letter, or digit, except the last character, which cannot be a dash.
    public var name: Swift.String? = nil

    /// Peer BGP Autonomous System Number (ASN). Each BGP interface may use
    /// a different value.
    public var peerAsn: Swift.UInt32? = nil

    /// IP address of the BGP interface outside Google Cloud Platform.
    public var peerIpAddress: Swift.String? = nil

    /// IPv4 address of the BGP interface outside Google Cloud Platform.
    public var peerIpv4NexthopAddress: Swift.String? = nil

    /// IPv6 address of the BGP interface outside Google Cloud Platform.
    public var peerIpv6NexthopAddress: Swift.String? = nil

    /// URI of the VM instance that is used as third-party router
    /// appliances such as Next Gen Firewalls, Virtual Routers, or Router
    /// Appliances. The VM instance must be located in zones contained in the
    /// same region as this Cloud Router.
    /// The VM instance is the peer side of the BGP session.
    public var routerApplianceInstance: Swift.String? = nil

    /// Initialize a new instance of `RouterBgpPeer`.
    public init() {}

    /// Use `config` to return a new instance of this object, with some fields updated.
    ///
    /// Commonly used to initialize the value, for example:
    ///
    /// ```
    /// let value = RouterBgpPeer().with { $0.advertiseMode = ... }
    /// ```
    public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
      var copy = self
      try config(&copy)
      return copy
    }

    /// The enumerated type for the [advertiseMode][google.cloud.compute.v1.RouterBgpPeer.advertiseMode] field.
    ///
    /// [google.cloud.compute.v1.RouterBgpPeer.advertiseMode]: <doc:RouterBgpPeer/AdvertiseMode>
    public enum AdvertiseMode: Codable, Equatable, Sendable {
      case custom
      case `default`
      /// Encodes an unknown integer value.
      ///
      /// The most common cause for an unknown values is for the service to send
      /// a value unknown to the library. We recommend you update your library to
      /// the latest version.
      case unknownIntValue(Int)
      /// Encodes an unknown string value.
      ///
      /// The most common cause for an unknown values is for the service to send
      /// a value unknown to the library. We recommend you update your library to
      /// the latest version.
      case unknownStringValue(String)

      public init() {
        self = .custom
      }

      /// Returns the integer value associated with the enumeration.
      ///
      /// If the enumeration was initialized with an unknown string value, this returns `nil`.
      public var intValue: Int? {
        switch self {
        case .custom: return 0
        case .`default`: return 1
        case .unknownIntValue(let v): return v
        case .unknownStringValue: return nil
        }
      }

      /// Returns the string value (or name) associated with the enumeration.
      ///
      /// If the enumeration was initialized with an unknown integer value, this returns `nil`.
      public var stringValue: Swift.String? {
        switch self {
        case .custom: return "CUSTOM"
        case .`default`: return "DEFAULT"
        case .unknownIntValue: return nil
        case .unknownStringValue(let v): return v
        }
      }

      /// Initialize from a string value.
      ///
      /// If the value is unknown, this initializes to [`unknownStringValue`](doc:AdvertiseMode/unknownStringValue(_:)).
      public init(stringValue: Swift.String) {
        switch stringValue {
        case "CUSTOM": self = .custom
        case "DEFAULT": self = .`default`
        default: self = .unknownStringValue(stringValue)
        }
      }

      /// Initialize from an integer value.
      ///
      /// If the value is unknown, this initializes to [`unknownIntValue`](doc:AdvertiseMode/unknownIntValue(_:)).
      public init(intValue: Int) {
        switch intValue {
        case 0: self = .custom
        case 1: self = .`default`
        default: self = .unknownIntValue(intValue)
        }
      }

      public init(from decoder: Decoder) throws {
        let container = try decoder.singleValueContainer()
        if let v = try? container.decode(Int.self) {
          self.init(intValue: v)
          return
        }
        if let s = try? container.decode(String.self) {
          if let v = Int(s) {
            self.init(intValue: v)
          } else {
            self.init(stringValue: s)
          }
          return
        }
        throw DecodingError.dataCorruptedError(
          in: container, debugDescription: "Expected enum value, must be integer or string.")
      }

      public func encode(to encoder: Encoder) throws {
        var container = encoder.singleValueContainer()
        switch self {
        case .custom: return try container.encode(0)
        case .`default`: return try container.encode(1)
        case .unknownIntValue(let v): return try container.encode(v)
        case .unknownStringValue(let v): return try container.encode(v)
        }
      }
    }

    /// The enumerated type for the [advertisedGroups][google.cloud.compute.v1.RouterBgpPeer.advertisedGroups] field.
    ///
    /// [google.cloud.compute.v1.RouterBgpPeer.advertisedGroups]: <doc:RouterBgpPeer/AdvertisedGroups>
    public enum AdvertisedGroups: Codable, Equatable, Sendable {
      /// Advertise all available subnets (including peer VPC subnets).
      case allSubnets
      /// Encodes an unknown integer value.
      ///
      /// The most common cause for an unknown values is for the service to send
      /// a value unknown to the library. We recommend you update your library to
      /// the latest version.
      case unknownIntValue(Int)
      /// Encodes an unknown string value.
      ///
      /// The most common cause for an unknown values is for the service to send
      /// a value unknown to the library. We recommend you update your library to
      /// the latest version.
      case unknownStringValue(String)

      public init() {
        self = .allSubnets
      }

      /// Returns the integer value associated with the enumeration.
      ///
      /// If the enumeration was initialized with an unknown string value, this returns `nil`.
      public var intValue: Int? {
        switch self {
        case .allSubnets: return 0
        case .unknownIntValue(let v): return v
        case .unknownStringValue: return nil
        }
      }

      /// Returns the string value (or name) associated with the enumeration.
      ///
      /// If the enumeration was initialized with an unknown integer value, this returns `nil`.
      public var stringValue: Swift.String? {
        switch self {
        case .allSubnets: return "ALL_SUBNETS"
        case .unknownIntValue: return nil
        case .unknownStringValue(let v): return v
        }
      }

      /// Initialize from a string value.
      ///
      /// If the value is unknown, this initializes to [`unknownStringValue`](doc:AdvertisedGroups/unknownStringValue(_:)).
      public init(stringValue: Swift.String) {
        switch stringValue {
        case "ALL_SUBNETS": self = .allSubnets
        default: self = .unknownStringValue(stringValue)
        }
      }

      /// Initialize from an integer value.
      ///
      /// If the value is unknown, this initializes to [`unknownIntValue`](doc:AdvertisedGroups/unknownIntValue(_:)).
      public init(intValue: Int) {
        switch intValue {
        case 0: self = .allSubnets
        default: self = .unknownIntValue(intValue)
        }
      }

      public init(from decoder: Decoder) throws {
        let container = try decoder.singleValueContainer()
        if let v = try? container.decode(Int.self) {
          self.init(intValue: v)
          return
        }
        if let s = try? container.decode(String.self) {
          if let v = Int(s) {
            self.init(intValue: v)
          } else {
            self.init(stringValue: s)
          }
          return
        }
        throw DecodingError.dataCorruptedError(
          in: container, debugDescription: "Expected enum value, must be integer or string.")
      }

      public func encode(to encoder: Encoder) throws {
        var container = encoder.singleValueContainer()
        switch self {
        case .allSubnets: return try container.encode(0)
        case .unknownIntValue(let v): return try container.encode(v)
        case .unknownStringValue(let v): return try container.encode(v)
        }
      }
    }

    /// The enumerated type for the [enable][google.cloud.compute.v1.RouterBgpPeer.enable] field.
    ///
    /// [google.cloud.compute.v1.RouterBgpPeer.enable]: <doc:RouterBgpPeer/Enable>
    public enum Enable: Codable, Equatable, Sendable {
      case `false`
      case `true`
      /// Encodes an unknown integer value.
      ///
      /// The most common cause for an unknown values is for the service to send
      /// a value unknown to the library. We recommend you update your library to
      /// the latest version.
      case unknownIntValue(Int)
      /// Encodes an unknown string value.
      ///
      /// The most common cause for an unknown values is for the service to send
      /// a value unknown to the library. We recommend you update your library to
      /// the latest version.
      case unknownStringValue(String)

      public init() {
        self = .`false`
      }

      /// Returns the integer value associated with the enumeration.
      ///
      /// If the enumeration was initialized with an unknown string value, this returns `nil`.
      public var intValue: Int? {
        switch self {
        case .`false`: return 0
        case .`true`: return 1
        case .unknownIntValue(let v): return v
        case .unknownStringValue: return nil
        }
      }

      /// Returns the string value (or name) associated with the enumeration.
      ///
      /// If the enumeration was initialized with an unknown integer value, this returns `nil`.
      public var stringValue: Swift.String? {
        switch self {
        case .`false`: return "FALSE"
        case .`true`: return "TRUE"
        case .unknownIntValue: return nil
        case .unknownStringValue(let v): return v
        }
      }

      /// Initialize from a string value.
      ///
      /// If the value is unknown, this initializes to [`unknownStringValue`](doc:Enable/unknownStringValue(_:)).
      public init(stringValue: Swift.String) {
        switch stringValue {
        case "FALSE": self = .`false`
        case "TRUE": self = .`true`
        default: self = .unknownStringValue(stringValue)
        }
      }

      /// Initialize from an integer value.
      ///
      /// If the value is unknown, this initializes to [`unknownIntValue`](doc:Enable/unknownIntValue(_:)).
      public init(intValue: Int) {
        switch intValue {
        case 0: self = .`false`
        case 1: self = .`true`
        default: self = .unknownIntValue(intValue)
        }
      }

      public init(from decoder: Decoder) throws {
        let container = try decoder.singleValueContainer()
        if let v = try? container.decode(Int.self) {
          self.init(intValue: v)
          return
        }
        if let s = try? container.decode(String.self) {
          if let v = Int(s) {
            self.init(intValue: v)
          } else {
            self.init(stringValue: s)
          }
          return
        }
        throw DecodingError.dataCorruptedError(
          in: container, debugDescription: "Expected enum value, must be integer or string.")
      }

      public func encode(to encoder: Encoder) throws {
        var container = encoder.singleValueContainer()
        switch self {
        case .`false`: return try container.encode(0)
        case .`true`: return try container.encode(1)
        case .unknownIntValue(let v): return try container.encode(v)
        case .unknownStringValue(let v): return try container.encode(v)
        }
      }
    }

    /// The enumerated type for the [managementType][google.cloud.compute.v1.RouterBgpPeer.managementType] field.
    ///
    /// [google.cloud.compute.v1.RouterBgpPeer.managementType]: <doc:RouterBgpPeer/ManagementType>
    public enum ManagementType: Codable, Equatable, Sendable {
      /// The BGP peer is automatically created for PARTNER type
      /// InterconnectAttachment; Google will automatically create/delete
      /// this BGP peer when the PARTNER InterconnectAttachment is
      /// created/deleted, and Google will update the ipAddress and
      /// peerIpAddress when the PARTNER InterconnectAttachment is provisioned.
      /// This type of BGP peer cannot be created or deleted, but can be
      /// modified for all fields except for name, ipAddress and peerIpAddress.
      case managedByAttachment
      /// Default value, the BGP peer is manually created and managed by user.
      case managedByUser
      /// Encodes an unknown integer value.
      ///
      /// The most common cause for an unknown values is for the service to send
      /// a value unknown to the library. We recommend you update your library to
      /// the latest version.
      case unknownIntValue(Int)
      /// Encodes an unknown string value.
      ///
      /// The most common cause for an unknown values is for the service to send
      /// a value unknown to the library. We recommend you update your library to
      /// the latest version.
      case unknownStringValue(String)

      public init() {
        self = .managedByAttachment
      }

      /// Returns the integer value associated with the enumeration.
      ///
      /// If the enumeration was initialized with an unknown string value, this returns `nil`.
      public var intValue: Int? {
        switch self {
        case .managedByAttachment: return 0
        case .managedByUser: return 1
        case .unknownIntValue(let v): return v
        case .unknownStringValue: return nil
        }
      }

      /// Returns the string value (or name) associated with the enumeration.
      ///
      /// If the enumeration was initialized with an unknown integer value, this returns `nil`.
      public var stringValue: Swift.String? {
        switch self {
        case .managedByAttachment: return "MANAGED_BY_ATTACHMENT"
        case .managedByUser: return "MANAGED_BY_USER"
        case .unknownIntValue: return nil
        case .unknownStringValue(let v): return v
        }
      }

      /// Initialize from a string value.
      ///
      /// If the value is unknown, this initializes to [`unknownStringValue`](doc:ManagementType/unknownStringValue(_:)).
      public init(stringValue: Swift.String) {
        switch stringValue {
        case "MANAGED_BY_ATTACHMENT": self = .managedByAttachment
        case "MANAGED_BY_USER": self = .managedByUser
        default: self = .unknownStringValue(stringValue)
        }
      }

      /// Initialize from an integer value.
      ///
      /// If the value is unknown, this initializes to [`unknownIntValue`](doc:ManagementType/unknownIntValue(_:)).
      public init(intValue: Int) {
        switch intValue {
        case 0: self = .managedByAttachment
        case 1: self = .managedByUser
        default: self = .unknownIntValue(intValue)
        }
      }

      public init(from decoder: Decoder) throws {
        let container = try decoder.singleValueContainer()
        if let v = try? container.decode(Int.self) {
          self.init(intValue: v)
          return
        }
        if let s = try? container.decode(String.self) {
          if let v = Int(s) {
            self.init(intValue: v)
          } else {
            self.init(stringValue: s)
          }
          return
        }
        throw DecodingError.dataCorruptedError(
          in: container, debugDescription: "Expected enum value, must be integer or string.")
      }

      public func encode(to encoder: Encoder) throws {
        var container = encoder.singleValueContainer()
        switch self {
        case .managedByAttachment: return try container.encode(0)
        case .managedByUser: return try container.encode(1)
        case .unknownIntValue(let v): return try container.encode(v)
        case .unknownStringValue(let v): return try container.encode(v)
        }
      }
    }

    public static var _anyTypeUrl: Swift.String {
      return "type.googleapis.com/google.cloud.compute.v1.RouterBgpPeer"
    }
    public init(fromAny any: GoogleCloudWkt.`Any`) throws {
      self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
    }
    public func _pack() throws -> GoogleCloudWkt.Struct {
      return try GoogleCloudWkt._slowAnySerialize(message: self)
    }
  }
#endif
