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

  /// Connect settings retrieval response.
  public struct ConnectSettings: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// This is always `sql#connectSettings`.
    public var kind: Swift.String = Swift.String()

    /// SSL configuration.
    public var serverCaCert: SslCert? = nil

    /// The assigned IP addresses for the instance.
    public var ipAddresses: [IpMapping] = []

    /// The cloud region for the instance. For example, `us-central1`,
    /// `europe-west1`. The region cannot be changed after instance creation.
    public var region: Swift.String = Swift.String()

    /// The database engine type and version. The `databaseVersion`
    /// field cannot be changed after instance creation.
    ///   MySQL instances: `MYSQL_8_0`, `MYSQL_5_7` (default),
    /// or `MYSQL_5_6`.
    ///   PostgreSQL instances: `POSTGRES_9_6`, `POSTGRES_10`,
    /// `POSTGRES_11`, `POSTGRES_12` (default), `POSTGRES_13`, or `POSTGRES_14`.
    ///   SQL Server instances: `SQLSERVER_2017_STANDARD` (default),
    /// `SQLSERVER_2017_ENTERPRISE`, `SQLSERVER_2017_EXPRESS`,
    /// `SQLSERVER_2017_WEB`, `SQLSERVER_2019_STANDARD`,
    /// `SQLSERVER_2019_ENTERPRISE`, `SQLSERVER_2019_EXPRESS`, or
    /// `SQLSERVER_2019_WEB`.
    public var databaseVersion: SqlDatabaseVersion = SqlDatabaseVersion()

    /// `SECOND_GEN`: Cloud SQL database instance.
    /// `EXTERNAL`: A database server that is not managed by Google.
    /// This property is read-only; use the `tier` property in the `settings`
    /// object to determine the database type.
    public var backendType: SqlBackendType = SqlBackendType()

    /// Whether PSC connectivity is enabled for this instance.
    public var pscEnabled: Swift.Bool = Swift.Bool()

    /// The dns name of the instance.
    public var dnsName: Swift.String = Swift.String()

    /// Specify what type of CA is used for the server certificate.
    public var serverCaMode: ConnectSettings.CaMode = ConnectSettings.CaMode()

    /// Custom subject alternative names for the server certificate.
    public var customSubjectAlternativeNames: [Swift.String] = []

    /// Output only. The list of DNS names used by this instance.
    public var dnsNames: [DnsNameMapping] = []

    /// The number of read pool nodes in a read pool.
    public var nodeCount: Swift.Int32? = nil

    /// Output only. Entries containing information about each read pool node of
    /// the read pool.
    public var nodes: [ConnectSettings.ConnectPoolNodeConfig] = []

    /// Optional. Output only. mdx_protocol_support controls how the client uses
    /// metadata exchange when connecting to the instance. The values in the list
    /// representing parts of the MDX protocol that are supported by this instance.
    /// When the list is empty, the instance does not support MDX, so the client
    /// must not send an MDX request. The default is empty.
    public var mdxProtocolSupport: [ConnectSettings.MdxProtocolSupport] = []

    /// Optional. Output only. Connection name of the Cloud SQL instance used in
    /// connection strings, in the format project:region:instance.
    public var connectionName: Swift.String = Swift.String()

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

    /// Details of a single read pool node of a read pool.
    public struct ConnectPoolNodeConfig: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Output only. The name of the read pool node. Doesn't include the project
      /// ID.
      public var name: Swift.String? = nil

      /// Output only. Mappings containing IP addresses that can be used to connect
      /// to the read pool node.
      public var ipAddresses: [IpMapping] = []

      /// Output only. The DNS name of the read pool node.
      public var dnsName: Swift.String? = nil

      /// Output only. The list of DNS names used by this read pool node.
      public var dnsNames: [DnsNameMapping] = []

      /// Initialize a new instance of `ConnectPoolNodeConfig`.
      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 = ConnectPoolNodeConfig().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.sql.v1.ConnectSettings.ConnectPoolNodeConfig"
      }
      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)
      }
    }

    /// Various Certificate Authority (CA) modes for certificate signing.
    public enum CaMode: Codable, Equatable, Sendable {
      /// CA mode is unknown.
      case unspecified
      /// Google-managed self-signed internal CA.
      case googleManagedInternalCa
      /// Google-managed regional CA part of root CA hierarchy hosted on Google
      /// Cloud's Certificate Authority Service (CAS).
      case googleManagedCasCa
      /// Customer-managed CA hosted on Google Cloud's Certificate Authority
      /// Service (CAS).
      case customerManagedCasCa
      /// 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 .googleManagedInternalCa: return 1
        case .googleManagedCasCa: return 2
        case .customerManagedCasCa: 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 "CA_MODE_UNSPECIFIED"
        case .googleManagedInternalCa: return "GOOGLE_MANAGED_INTERNAL_CA"
        case .googleManagedCasCa: return "GOOGLE_MANAGED_CAS_CA"
        case .customerManagedCasCa: return "CUSTOMER_MANAGED_CAS_CA"
        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:CaMode/unknownStringValue(_:)).
      public init(stringValue: Swift.String) {
        switch stringValue {
        case "CA_MODE_UNSPECIFIED": self = .unspecified
        case "GOOGLE_MANAGED_INTERNAL_CA": self = .googleManagedInternalCa
        case "GOOGLE_MANAGED_CAS_CA": self = .googleManagedCasCa
        case "CUSTOMER_MANAGED_CAS_CA": self = .customerManagedCasCa
        default: self = .unknownStringValue(stringValue)
        }
      }

      /// Initialize from an integer value.
      ///
      /// If the value is unknown, this initializes to [`unknownIntValue`](doc:CaMode/unknownIntValue(_:)).
      public init(intValue: Int) {
        switch intValue {
        case 0: self = .unspecified
        case 1: self = .googleManagedInternalCa
        case 2: self = .googleManagedCasCa
        case 3: self = .customerManagedCasCa
        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 .googleManagedInternalCa: return try container.encode(1)
        case .googleManagedCasCa: return try container.encode(2)
        case .customerManagedCasCa: return try container.encode(3)
        case .unknownIntValue(let v): return try container.encode(v)
        case .unknownStringValue(let v): return try container.encode(v)
        }
      }
    }

    /// MdxProtocolSupport describes parts of the MDX protocol supported by this
    /// instance.
    public enum MdxProtocolSupport: Codable, Equatable, Sendable {
      /// Not specified.
      case unspecified
      /// Client should send the client protocol type in the MDX request.
      case clientProtocolType
      /// 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 .clientProtocolType: 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 .unspecified: return "MDX_PROTOCOL_SUPPORT_UNSPECIFIED"
        case .clientProtocolType: return "CLIENT_PROTOCOL_TYPE"
        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:MdxProtocolSupport/unknownStringValue(_:)).
      public init(stringValue: Swift.String) {
        switch stringValue {
        case "MDX_PROTOCOL_SUPPORT_UNSPECIFIED": self = .unspecified
        case "CLIENT_PROTOCOL_TYPE": self = .clientProtocolType
        default: self = .unknownStringValue(stringValue)
        }
      }

      /// Initialize from an integer value.
      ///
      /// If the value is unknown, this initializes to [`unknownIntValue`](doc:MdxProtocolSupport/unknownIntValue(_:)).
      public init(intValue: Int) {
        switch intValue {
        case 0: self = .unspecified
        case 1: self = .clientProtocolType
        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 .clientProtocolType: 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.sql.v1.ConnectSettings"
    }
    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
