// 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 Networks
  import Foundation
  import GoogleCloudWkt

  /// A network peering attached to a network resource. The message includes the
  /// peering name, peer network, peering state, and a flag indicating whether
  /// Google Compute Engine should automatically create routes for the peering.
  public struct NetworkPeering: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// This field will be deprecated soon. Use theexchange_subnet_routes field instead.
    /// Indicates whether full mesh connectivity is created and managed
    /// automatically between peered networks. Currently this field should always
    /// be true since Google Compute Engine will automatically create and manage
    /// subnetwork routes between two networks when peering state isACTIVE.
    public var autoCreateRoutes: Swift.Bool? = nil

    /// Output only. [Output Only] The effective state of the peering connection
    /// as a whole.
    public var connectionStatus: NetworkPeeringConnectionStatus? = nil

    /// Indicates whether full mesh connectivity is created and managed
    /// automatically between peered networks. Currently this field should always
    /// be true since Google Compute Engine will automatically create and manage
    /// subnetwork routes between two networks when peering state isACTIVE.
    public var exchangeSubnetRoutes: Swift.Bool? = nil

    /// Whether to export the custom routes to peer network. The default value is
    /// false.
    public var exportCustomRoutes: Swift.Bool? = nil

    /// Whether subnet routes with public IP range are exported. The default value
    /// is true, all subnet routes are exported.IPv4
    /// special-use ranges are always
    /// exported to peers and are not controlled by this field.
    public var exportSubnetRoutesWithPublicIp: Swift.Bool? = nil

    /// Whether to import the custom routes from peer network. The default value is
    /// false.
    public var importCustomRoutes: Swift.Bool? = nil

    /// Whether subnet routes with public IP range are imported. The default value
    /// is false.IPv4
    /// special-use ranges are always
    /// imported from peers and are not controlled by this field.
    public var importSubnetRoutesWithPublicIp: Swift.Bool? = nil

    /// Name of this peering. Provided by the client when the peering is created.
    /// The name must comply withRFC1035.
    /// Specifically, the name must be 1-63 characters long and match regular
    /// expression `[a-z]([-a-z0-9]*[a-z0-9])?`. The first character must be a
    /// lowercase letter, and all the 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

    /// The URL of the peer network. It can be either full URL or partial URL. The
    /// peer network may belong to a different project. If the partial URL does not
    /// contain project, it is assumed that the peer network is in the same project
    /// as the current network.
    public var network: Swift.String? = nil

    /// Output only. [Output Only] Maximum Transmission Unit in bytes of the peer network.
    public var peerMtu: Swift.Int32? = nil

    /// Which IP version(s) of traffic and routes are allowed to be imported or
    /// exported between peer networks. The default value is IPV4_ONLY.
    public var stackType: NetworkPeering.StackType? = nil

    /// Output only. [Output Only] State for the peering.
    public var state: NetworkPeering.State? = nil

    /// Output only. [Output Only] Details about the current state of the peering.
    public var stateDetails: Swift.String? = nil

    /// The update strategy determines the semantics for updates and deletes to the
    /// peering connection configuration.
    public var updateStrategy: NetworkPeering.UpdateStrategy? = nil

    /// Initialize a new instance of `NetworkPeering`.
    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 = NetworkPeering().with { $0.autoCreateRoutes = ... }
    /// ```
    public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
      var copy = self
      try config(&copy)
      return copy
    }

    /// The enumerated type for the [stackType][google.cloud.compute.v1.NetworkPeering.stackType] field.
    ///
    /// [google.cloud.compute.v1.NetworkPeering.stackType]: <doc:NetworkPeering/StackType>
    public enum StackType: Codable, Equatable, Sendable {
      /// This Peering will allow IPv4 traffic and routes to be
      /// exchanged. Additionally if the matching peering is
      /// IPV4_IPV6, IPv6 traffic and routes will be exchanged as
      /// well.
      case ipv4Ipv6
      /// This Peering will only allow IPv4 traffic and routes to be
      /// exchanged, even if the matching peering is IPV4_IPV6.
      case ipv4Only
      /// 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 = .ipv4Ipv6
      }

      /// 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 .ipv4Ipv6: return 0
        case .ipv4Only: 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 .ipv4Ipv6: return "IPV4_IPV6"
        case .ipv4Only: return "IPV4_ONLY"
        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:StackType/unknownStringValue(_:)).
      public init(stringValue: Swift.String) {
        switch stringValue {
        case "IPV4_IPV6": self = .ipv4Ipv6
        case "IPV4_ONLY": self = .ipv4Only
        default: self = .unknownStringValue(stringValue)
        }
      }

      /// Initialize from an integer value.
      ///
      /// If the value is unknown, this initializes to [`unknownIntValue`](doc:StackType/unknownIntValue(_:)).
      public init(intValue: Int) {
        switch intValue {
        case 0: self = .ipv4Ipv6
        case 1: self = .ipv4Only
        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 .ipv4Ipv6: return try container.encode(0)
        case .ipv4Only: 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 [state][google.cloud.compute.v1.NetworkPeering.state] field.
    ///
    /// [google.cloud.compute.v1.NetworkPeering.state]: <doc:NetworkPeering/State>
    public enum State: Codable, Equatable, Sendable {
      /// Matching configuration exists on the peer.
      case active
      /// There is no matching configuration on the peer, including the case when
      /// peer does not exist.
      case inactive
      /// 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 = .active
      }

      /// 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 .active: return 0
        case .inactive: 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 .active: return "ACTIVE"
        case .inactive: return "INACTIVE"
        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:State/unknownStringValue(_:)).
      public init(stringValue: Swift.String) {
        switch stringValue {
        case "ACTIVE": self = .active
        case "INACTIVE": self = .inactive
        default: self = .unknownStringValue(stringValue)
        }
      }

      /// Initialize from an integer value.
      ///
      /// If the value is unknown, this initializes to [`unknownIntValue`](doc:State/unknownIntValue(_:)).
      public init(intValue: Int) {
        switch intValue {
        case 0: self = .active
        case 1: self = .inactive
        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 .active: return try container.encode(0)
        case .inactive: 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 [updateStrategy][google.cloud.compute.v1.NetworkPeering.updateStrategy] field.
    ///
    /// [google.cloud.compute.v1.NetworkPeering.updateStrategy]: <doc:NetworkPeering/UpdateStrategy>
    public enum UpdateStrategy: Codable, Equatable, Sendable {
      /// Updates are reflected in the local peering but aren't applied to the
      /// peering connection until a complementary change is made to the
      /// matching peering.
      /// To delete a peering with the consensus update strategy, both the peerings
      /// must request the deletion of the peering before the peering can be
      /// deleted.
      case consensus
      /// In this mode, changes to the peering configuration can
      /// be unilaterally altered by changing either side of the peering.
      /// This is the default value if the field is unspecified.
      case independent
      /// Peerings with update strategy UNSPECIFIED are created with
      /// update strategy INDEPENDENT.
      case unspecified
      /// 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 = .consensus
      }

      /// 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 .consensus: return 0
        case .independent: return 1
        case .unspecified: return 2
        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 .consensus: return "CONSENSUS"
        case .independent: return "INDEPENDENT"
        case .unspecified: return "UNSPECIFIED"
        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:UpdateStrategy/unknownStringValue(_:)).
      public init(stringValue: Swift.String) {
        switch stringValue {
        case "CONSENSUS": self = .consensus
        case "INDEPENDENT": self = .independent
        case "UNSPECIFIED": self = .unspecified
        default: self = .unknownStringValue(stringValue)
        }
      }

      /// Initialize from an integer value.
      ///
      /// If the value is unknown, this initializes to [`unknownIntValue`](doc:UpdateStrategy/unknownIntValue(_:)).
      public init(intValue: Int) {
        switch intValue {
        case 0: self = .consensus
        case 1: self = .independent
        case 2: self = .unspecified
        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 .consensus: return try container.encode(0)
        case .independent: return try container.encode(1)
        case .unspecified: return try container.encode(2)
        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.NetworkPeering"
    }
    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
