// 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.

import Foundation
import GoogleCloudWkt

/// A VPN connection .
public struct VpnConnection: Codable, Equatable, GoogleCloudWkt._AnyPackable,
  Sendable
{
  /// Required. The resource name of VPN connection
  public var name: Swift.String = Swift.String()

  /// Output only. The time when the VPN connection was created.
  public var createTime: GoogleCloudWkt.Timestamp? = nil

  /// Output only. The time when the VPN connection was last updated.
  public var updateTime: GoogleCloudWkt.Timestamp? = nil

  /// Labels associated with this resource.
  public var labels: [Swift.String: Swift.String] = [:]

  /// NAT gateway IP, or WAN IP address. If a customer has multiple NAT IPs, the
  /// customer needs to configure NAT such that only one external IP maps to the
  /// GMEC Anthos cluster. This is empty if NAT is not used.
  public var natGatewayIp: Swift.String = Swift.String()

  /// Dynamic routing mode of the VPC network, `regional` or `global`.
  @available(*, deprecated)
  public var bgpRoutingMode: VpnConnection.BgpRoutingMode = VpnConnection.BgpRoutingMode()

  /// The canonical Cluster name to connect to. It is in the form of
  /// projects/{project}/locations/{location}/clusters/{cluster}.
  public var cluster: Swift.String = Swift.String()

  /// The network ID of VPC to connect to.
  public var vpc: Swift.String = Swift.String()

  /// Optional. Project detail of the VPC network. Required if VPC is in a
  /// different project than the cluster project.
  public var vpcProject: VpnConnection.VpcProject? = nil

  /// Whether this VPN connection has HA enabled on cluster side. If enabled,
  /// when creating VPN connection we will attempt to use 2 ANG floating IPs.
  public var enableHighAvailability: Swift.Bool = Swift.Bool()

  /// Optional. The VPN connection Cloud Router name.
  public var router: Swift.String = Swift.String()

  /// Output only. The created connection details.
  public var details: VpnConnection.Details? = nil

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

  /// Project detail of the VPC network.
  public struct VpcProject: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// The project of the VPC to connect to. If not specified, it is the same as
    /// the cluster project.
    public var projectId: Swift.String = Swift.String()

    /// Optional. Deprecated: do not use.
    @available(*, deprecated)
    public var serviceAccount: Swift.String = Swift.String()

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

    public static var _anyTypeUrl: Swift.String {
      return "type.googleapis.com/google.cloud.edgecontainer.v1.VpnConnection.VpcProject"
    }
    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)
    }
  }

  /// The created connection details.
  public struct Details: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// The state of this connection.
    public var state: VpnConnection.Details.State = VpnConnection.Details.State()

    /// The error message. This is only populated when state=ERROR.
    public var error: Swift.String = Swift.String()

    /// The Cloud Router info.
    public var cloudRouter: VpnConnection.Details.CloudRouter? = nil

    /// Each connection has multiple Cloud VPN gateways.
    public var cloudVpns: [VpnConnection.Details.CloudVpn] = []

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

    /// The Cloud Router info.
    public struct CloudRouter: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// The associated Cloud Router name.
      public var name: Swift.String = Swift.String()

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

      public static var _anyTypeUrl: Swift.String {
        return "type.googleapis.com/google.cloud.edgecontainer.v1.VpnConnection.Details.CloudRouter"
      }
      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)
      }
    }

    /// The Cloud VPN info.
    public struct CloudVpn: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// The created Cloud VPN gateway name.
      public var gateway: Swift.String = Swift.String()

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

      public static var _anyTypeUrl: Swift.String {
        return "type.googleapis.com/google.cloud.edgecontainer.v1.VpnConnection.Details.CloudVpn"
      }
      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)
      }
    }

    /// The current connection state.
    public enum State: Codable, Equatable, Sendable {
      /// Unknown.
      case unspecified
      /// Connected.
      case connected
      /// Still connecting.
      case connecting
      /// Error occurred.
      case error
      /// 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 = .unspecified
      }

      /// 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 .unspecified: return 0
        case .connected: return 1
        case .connecting: return 2
        case .error: return 3
        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 .unspecified: return "STATE_UNSPECIFIED"
        case .connected: return "STATE_CONNECTED"
        case .connecting: return "STATE_CONNECTING"
        case .error: return "STATE_ERROR"
        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 "STATE_UNSPECIFIED": self = .unspecified
        case "STATE_CONNECTED": self = .connected
        case "STATE_CONNECTING": self = .connecting
        case "STATE_ERROR": self = .error
        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 = .unspecified
        case 1: self = .connected
        case 2: self = .connecting
        case 3: self = .error
        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 .unspecified: return try container.encode(0)
        case .connected: return try container.encode(1)
        case .connecting: return try container.encode(2)
        case .error: return try container.encode(3)
        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.edgecontainer.v1.VpnConnection.Details"
    }
    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)
    }
  }

  /// Routing mode.
  public enum BgpRoutingMode: Codable, Equatable, Sendable {
    /// Unknown.
    case unspecified
    /// Regional mode.
    case regional
    /// Global mode.
    case global
    /// 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 = .unspecified
    }

    /// 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 .unspecified: return 0
      case .regional: return 1
      case .global: 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 .unspecified: return "BGP_ROUTING_MODE_UNSPECIFIED"
      case .regional: return "REGIONAL"
      case .global: return "GLOBAL"
      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:BgpRoutingMode/unknownStringValue(_:)).
    public init(stringValue: Swift.String) {
      switch stringValue {
      case "BGP_ROUTING_MODE_UNSPECIFIED": self = .unspecified
      case "REGIONAL": self = .regional
      case "GLOBAL": self = .global
      default: self = .unknownStringValue(stringValue)
      }
    }

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