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

/// Settings for creating a Cloud SQL database instance.
public struct CloudSqlSettings: Codable, Equatable, GoogleCloudWkt._AnyPackable,
  Sendable
{
  /// The database engine type and version.
  public var databaseVersion: CloudSqlSettings.SqlDatabaseVersion =
    CloudSqlSettings.SqlDatabaseVersion()

  /// The resource labels for a Cloud SQL instance to use to annotate any related
  /// underlying resources such as Compute Engine VMs.
  /// An object containing a list of "key": "value" pairs.
  ///
  /// Example: `{ "name": "wrench", "mass": "18kg", "count": "3" }`.
  public var userLabels: [Swift.String: Swift.String] = [:]

  /// The tier (or machine type) for this instance, for example:
  /// `db-n1-standard-1` (MySQL instances) or
  /// `db-custom-1-3840` (PostgreSQL instances).
  /// For more information, see
  /// [Cloud SQL Instance
  /// Settings](https://cloud.google.com/sql/docs/mysql/instance-settings).
  public var tier: Swift.String = Swift.String()

  /// The maximum size to which storage capacity can be automatically increased.
  /// The default value is 0, which specifies that there is no limit.
  public var storageAutoResizeLimit: GoogleCloudWkt.Int64Value? = nil

  /// The activation policy specifies when the instance is activated; it is
  /// applicable only when the instance state is 'RUNNABLE'. Valid values:
  ///
  /// 'ALWAYS': The instance is on, and remains so even in
  /// the absence of connection requests.
  ///
  /// `NEVER`: The instance is off; it is not activated, even if a
  /// connection request arrives.
  public var activationPolicy: CloudSqlSettings.SqlActivationPolicy =
    CloudSqlSettings.SqlActivationPolicy()

  /// The settings for IP Management. This allows to enable or disable the
  /// instance IP and manage which external networks can connect to the instance.
  /// The IPv4 address cannot be disabled.
  public var ipConfig: SqlIpConfig? = nil

  /// [default: ON] If you enable this setting, Cloud SQL checks your available
  /// storage every 30 seconds. If the available storage falls below a threshold
  /// size, Cloud SQL automatically adds additional storage capacity. If the
  /// available storage repeatedly falls below the threshold size, Cloud SQL
  /// continues to add storage until it reaches the maximum of 30 TB.
  public var autoStorageIncrease: GoogleCloudWkt.BoolValue? = nil

  /// The database flags passed to the Cloud SQL instance at startup.
  /// An object containing a list of "key": value pairs.
  /// Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.
  public var databaseFlags: [Swift.String: Swift.String] = [:]

  /// The type of storage: `PD_SSD` (default) or `PD_HDD`.
  public var dataDiskType: CloudSqlSettings.SqlDataDiskType = CloudSqlSettings.SqlDataDiskType()

  /// The storage capacity available to the database, in GB.
  /// The minimum (and default) size is 10GB.
  public var dataDiskSizeGb: GoogleCloudWkt.Int64Value? = nil

  /// The Google Cloud Platform zone where your Cloud SQL database instance is
  /// located.
  public var zone: Swift.String = Swift.String()

  /// Optional. The Google Cloud Platform zone where the failover Cloud SQL
  /// database instance is located. Used when the Cloud SQL database availability
  /// type is REGIONAL (i.e. multiple zones / highly available).
  public var secondaryZone: Swift.String = Swift.String()

  /// The Database Migration Service source connection profile ID,
  /// in the format:
  /// `projects/my_project_name/locations/us-central1/connectionProfiles/connection_profile_ID`
  public var sourceId: Swift.String = Swift.String()

  /// Input only. Initial root password.
  public var rootPassword: Swift.String = Swift.String()

  /// Output only. Indicates If this connection profile root password is stored.
  public var rootPasswordSet: Swift.Bool = Swift.Bool()

  /// The Cloud SQL default instance level collation.
  public var collation: Swift.String = Swift.String()

  /// The KMS key name used for the csql instance.
  public var cmekKeyName: Swift.String = Swift.String()

  /// Optional. Availability type. Potential values:
  /// *  `ZONAL`: The instance serves data from only one zone. Outages in that
  /// zone affect data availability.
  /// *  `REGIONAL`: The instance can serve data from more than one zone in a
  /// region (it is highly available).
  public var availabilityType: CloudSqlSettings.SqlAvailabilityType =
    CloudSqlSettings.SqlAvailabilityType()

  /// Optional. The edition of the given Cloud SQL instance.
  public var edition: CloudSqlSettings.Edition = CloudSqlSettings.Edition()

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

  /// Specifies when the instance should be activated.
  public enum SqlActivationPolicy: Codable, Equatable, Sendable {
    /// unspecified policy.
    case unspecified
    /// The instance is always up and running.
    case always
    /// The instance should never spin up.
    case never
    /// 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 .always: return 1
      case .never: 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 "SQL_ACTIVATION_POLICY_UNSPECIFIED"
      case .always: return "ALWAYS"
      case .never: return "NEVER"
      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:SqlActivationPolicy/unknownStringValue(_:)).
    public init(stringValue: Swift.String) {
      switch stringValue {
      case "SQL_ACTIVATION_POLICY_UNSPECIFIED": self = .unspecified
      case "ALWAYS": self = .always
      case "NEVER": self = .never
      default: self = .unknownStringValue(stringValue)
      }
    }

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

  /// The storage options for Cloud SQL databases.
  public enum SqlDataDiskType: Codable, Equatable, Sendable {
    /// Unspecified.
    case unspecified
    /// SSD disk.
    case pdSsd
    /// HDD disk.
    case pdHdd
    /// 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 .pdSsd: return 1
      case .pdHdd: 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 "SQL_DATA_DISK_TYPE_UNSPECIFIED"
      case .pdSsd: return "PD_SSD"
      case .pdHdd: return "PD_HDD"
      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:SqlDataDiskType/unknownStringValue(_:)).
    public init(stringValue: Swift.String) {
      switch stringValue {
      case "SQL_DATA_DISK_TYPE_UNSPECIFIED": self = .unspecified
      case "PD_SSD": self = .pdSsd
      case "PD_HDD": self = .pdHdd
      default: self = .unknownStringValue(stringValue)
      }
    }

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

  /// The database engine type and version.
  public enum SqlDatabaseVersion: Codable, Equatable, Sendable {
    /// Unspecified version.
    case unspecified
    /// MySQL 5.6.
    case mysql56
    /// MySQL 5.7.
    case mysql57
    /// PostgreSQL 9.6.
    case postgres96
    /// PostgreSQL 11.
    case postgres11
    /// PostgreSQL 10.
    case postgres10
    /// MySQL 8.0.
    case mysql80
    /// PostgreSQL 12.
    case postgres12
    /// PostgreSQL 13.
    case postgres13
    /// PostgreSQL 14.
    case postgres14
    /// PostgreSQL 15.
    case postgres15
    /// 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 .mysql56: return 1
      case .mysql57: return 2
      case .postgres96: return 3
      case .postgres11: return 4
      case .postgres10: return 5
      case .mysql80: return 6
      case .postgres12: return 7
      case .postgres13: return 8
      case .postgres14: return 17
      case .postgres15: return 18
      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 "SQL_DATABASE_VERSION_UNSPECIFIED"
      case .mysql56: return "MYSQL_5_6"
      case .mysql57: return "MYSQL_5_7"
      case .postgres96: return "POSTGRES_9_6"
      case .postgres11: return "POSTGRES_11"
      case .postgres10: return "POSTGRES_10"
      case .mysql80: return "MYSQL_8_0"
      case .postgres12: return "POSTGRES_12"
      case .postgres13: return "POSTGRES_13"
      case .postgres14: return "POSTGRES_14"
      case .postgres15: return "POSTGRES_15"
      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:SqlDatabaseVersion/unknownStringValue(_:)).
    public init(stringValue: Swift.String) {
      switch stringValue {
      case "SQL_DATABASE_VERSION_UNSPECIFIED": self = .unspecified
      case "MYSQL_5_6": self = .mysql56
      case "MYSQL_5_7": self = .mysql57
      case "POSTGRES_9_6": self = .postgres96
      case "POSTGRES_11": self = .postgres11
      case "POSTGRES_10": self = .postgres10
      case "MYSQL_8_0": self = .mysql80
      case "POSTGRES_12": self = .postgres12
      case "POSTGRES_13": self = .postgres13
      case "POSTGRES_14": self = .postgres14
      case "POSTGRES_15": self = .postgres15
      default: self = .unknownStringValue(stringValue)
      }
    }

    /// Initialize from an integer value.
    ///
    /// If the value is unknown, this initializes to [`unknownIntValue`](doc:SqlDatabaseVersion/unknownIntValue(_:)).
    public init(intValue: Int) {
      switch intValue {
      case 0: self = .unspecified
      case 1: self = .mysql56
      case 2: self = .mysql57
      case 3: self = .postgres96
      case 4: self = .postgres11
      case 5: self = .postgres10
      case 6: self = .mysql80
      case 7: self = .postgres12
      case 8: self = .postgres13
      case 17: self = .postgres14
      case 18: self = .postgres15
      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 .mysql56: return try container.encode(1)
      case .mysql57: return try container.encode(2)
      case .postgres96: return try container.encode(3)
      case .postgres11: return try container.encode(4)
      case .postgres10: return try container.encode(5)
      case .mysql80: return try container.encode(6)
      case .postgres12: return try container.encode(7)
      case .postgres13: return try container.encode(8)
      case .postgres14: return try container.encode(17)
      case .postgres15: return try container.encode(18)
      case .unknownIntValue(let v): return try container.encode(v)
      case .unknownStringValue(let v): return try container.encode(v)
      }
    }
  }

  /// The availability type of the given Cloud SQL instance.
  public enum SqlAvailabilityType: Codable, Equatable, Sendable {
    /// This is an unknown Availability type.
    case unspecified
    /// Zonal availablility instance.
    case zonal
    /// Regional availability instance.
    case regional
    /// 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 .zonal: return 1
      case .regional: 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 "SQL_AVAILABILITY_TYPE_UNSPECIFIED"
      case .zonal: return "ZONAL"
      case .regional: return "REGIONAL"
      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:SqlAvailabilityType/unknownStringValue(_:)).
    public init(stringValue: Swift.String) {
      switch stringValue {
      case "SQL_AVAILABILITY_TYPE_UNSPECIFIED": self = .unspecified
      case "ZONAL": self = .zonal
      case "REGIONAL": self = .regional
      default: self = .unknownStringValue(stringValue)
      }
    }

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

  /// The edition of the given Cloud SQL instance.
  /// Can be ENTERPRISE or ENTERPRISE_PLUS.
  public enum Edition: Codable, Equatable, Sendable {
    /// The instance did not specify the edition.
    case unspecified
    /// The instance is an enterprise edition.
    case enterprise
    /// The instance is an enterprise plus edition.
    case enterprisePlus
    /// 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 .enterprise: return 2
      case .enterprisePlus: 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 "EDITION_UNSPECIFIED"
      case .enterprise: return "ENTERPRISE"
      case .enterprisePlus: return "ENTERPRISE_PLUS"
      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:Edition/unknownStringValue(_:)).
    public init(stringValue: Swift.String) {
      switch stringValue {
      case "EDITION_UNSPECIFIED": self = .unspecified
      case "ENTERPRISE": self = .enterprise
      case "ENTERPRISE_PLUS": self = .enterprisePlus
      default: self = .unknownStringValue(stringValue)
      }
    }

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