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

/// The possible dialect options for translation.
public struct Dialect: Codable, Equatable, GoogleCloudWkt._AnyPackable,
  Sendable
{
  /// The possible dialect options that this message represents.
  public var dialectValue: OneOf_DialectValue? = nil

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

  private enum CodingKeys: Swift.String, CodingKey {
    case bigqueryDialect = "bigqueryDialect"
    case hiveqlDialect = "hiveqlDialect"
    case redshiftDialect = "redshiftDialect"
    case teradataDialect = "teradataDialect"
    case oracleDialect = "oracleDialect"
    case sparksqlDialect = "sparksqlDialect"
    case snowflakeDialect = "snowflakeDialect"
    case netezzaDialect = "netezzaDialect"
    case azureSynapseDialect = "azureSynapseDialect"
    case verticaDialect = "verticaDialect"
    case sqlServerDialect = "sqlServerDialect"
    case postgresqlDialect = "postgresqlDialect"
    case prestoDialect = "prestoDialect"
    case mysqlDialect = "mysqlDialect"
    case db2Dialect = "db2Dialect"
    case sqliteDialect = "sqliteDialect"
    case greenplumDialect = "greenplumDialect"
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)

    var dialectValue: OneOf_DialectValue? = nil
    let dialectValueCheckAndSet = {
      if dialectValue != nil {
        throw DecodingError.dataCorrupted(
          DecodingError.Context(
            codingPath: decoder.codingPath,
            debugDescription: "Multiple values set for oneof 'dialectValue'"))
      }
      dialectValue = $0
    }
    if let bigqueryDialect = try container.decodeIfPresent(
      BigQueryDialect?.self, forKey: .bigqueryDialect)
    {
      try dialectValueCheckAndSet(.bigqueryDialect(bigqueryDialect))
    }
    if let hiveqlDialect = try container.decodeIfPresent(
      HiveQLDialect?.self, forKey: .hiveqlDialect)
    {
      try dialectValueCheckAndSet(.hiveqlDialect(hiveqlDialect))
    }
    if let redshiftDialect = try container.decodeIfPresent(
      RedshiftDialect?.self, forKey: .redshiftDialect)
    {
      try dialectValueCheckAndSet(.redshiftDialect(redshiftDialect))
    }
    if let teradataDialect = try container.decodeIfPresent(
      TeradataDialect?.self, forKey: .teradataDialect)
    {
      try dialectValueCheckAndSet(.teradataDialect(teradataDialect))
    }
    if let oracleDialect = try container.decodeIfPresent(
      OracleDialect?.self, forKey: .oracleDialect)
    {
      try dialectValueCheckAndSet(.oracleDialect(oracleDialect))
    }
    if let sparksqlDialect = try container.decodeIfPresent(
      SparkSQLDialect?.self, forKey: .sparksqlDialect)
    {
      try dialectValueCheckAndSet(.sparksqlDialect(sparksqlDialect))
    }
    if let snowflakeDialect = try container.decodeIfPresent(
      SnowflakeDialect?.self, forKey: .snowflakeDialect)
    {
      try dialectValueCheckAndSet(.snowflakeDialect(snowflakeDialect))
    }
    if let netezzaDialect = try container.decodeIfPresent(
      NetezzaDialect?.self, forKey: .netezzaDialect)
    {
      try dialectValueCheckAndSet(.netezzaDialect(netezzaDialect))
    }
    if let azureSynapseDialect = try container.decodeIfPresent(
      AzureSynapseDialect?.self, forKey: .azureSynapseDialect)
    {
      try dialectValueCheckAndSet(.azureSynapseDialect(azureSynapseDialect))
    }
    if let verticaDialect = try container.decodeIfPresent(
      VerticaDialect?.self, forKey: .verticaDialect)
    {
      try dialectValueCheckAndSet(.verticaDialect(verticaDialect))
    }
    if let sqlServerDialect = try container.decodeIfPresent(
      SQLServerDialect?.self, forKey: .sqlServerDialect)
    {
      try dialectValueCheckAndSet(.sqlServerDialect(sqlServerDialect))
    }
    if let postgresqlDialect = try container.decodeIfPresent(
      PostgresqlDialect?.self, forKey: .postgresqlDialect)
    {
      try dialectValueCheckAndSet(.postgresqlDialect(postgresqlDialect))
    }
    if let prestoDialect = try container.decodeIfPresent(
      PrestoDialect?.self, forKey: .prestoDialect)
    {
      try dialectValueCheckAndSet(.prestoDialect(prestoDialect))
    }
    if let mysqlDialect = try container.decodeIfPresent(MySQLDialect?.self, forKey: .mysqlDialect) {
      try dialectValueCheckAndSet(.mysqlDialect(mysqlDialect))
    }
    if let db2Dialect = try container.decodeIfPresent(DB2Dialect?.self, forKey: .db2Dialect) {
      try dialectValueCheckAndSet(.db2Dialect(db2Dialect))
    }
    if let sqliteDialect = try container.decodeIfPresent(
      SQLiteDialect?.self, forKey: .sqliteDialect)
    {
      try dialectValueCheckAndSet(.sqliteDialect(sqliteDialect))
    }
    if let greenplumDialect = try container.decodeIfPresent(
      GreenplumDialect?.self, forKey: .greenplumDialect)
    {
      try dialectValueCheckAndSet(.greenplumDialect(greenplumDialect))
    }
    self.dialectValue = dialectValue
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)

    if let choice = self.dialectValue {
      switch choice {
      case .bigqueryDialect(let value):
        try container.encode(value, forKey: .bigqueryDialect)
      case .hiveqlDialect(let value):
        try container.encode(value, forKey: .hiveqlDialect)
      case .redshiftDialect(let value):
        try container.encode(value, forKey: .redshiftDialect)
      case .teradataDialect(let value):
        try container.encode(value, forKey: .teradataDialect)
      case .oracleDialect(let value):
        try container.encode(value, forKey: .oracleDialect)
      case .sparksqlDialect(let value):
        try container.encode(value, forKey: .sparksqlDialect)
      case .snowflakeDialect(let value):
        try container.encode(value, forKey: .snowflakeDialect)
      case .netezzaDialect(let value):
        try container.encode(value, forKey: .netezzaDialect)
      case .azureSynapseDialect(let value):
        try container.encode(value, forKey: .azureSynapseDialect)
      case .verticaDialect(let value):
        try container.encode(value, forKey: .verticaDialect)
      case .sqlServerDialect(let value):
        try container.encode(value, forKey: .sqlServerDialect)
      case .postgresqlDialect(let value):
        try container.encode(value, forKey: .postgresqlDialect)
      case .prestoDialect(let value):
        try container.encode(value, forKey: .prestoDialect)
      case .mysqlDialect(let value):
        try container.encode(value, forKey: .mysqlDialect)
      case .db2Dialect(let value):
        try container.encode(value, forKey: .db2Dialect)
      case .sqliteDialect(let value):
        try container.encode(value, forKey: .sqliteDialect)
      case .greenplumDialect(let value):
        try container.encode(value, forKey: .greenplumDialect)
      }
    }
  }

  /// The possible dialect options that this message represents.
  public enum OneOf_DialectValue: Codable, Equatable, Sendable {
    /// The BigQuery dialect
    indirect case bigqueryDialect(BigQueryDialect?)
    /// The HiveQL dialect
    indirect case hiveqlDialect(HiveQLDialect?)
    /// The Redshift dialect
    indirect case redshiftDialect(RedshiftDialect?)
    /// The Teradata dialect
    indirect case teradataDialect(TeradataDialect?)
    /// The Oracle dialect
    indirect case oracleDialect(OracleDialect?)
    /// The SparkSQL dialect
    indirect case sparksqlDialect(SparkSQLDialect?)
    /// The Snowflake dialect
    indirect case snowflakeDialect(SnowflakeDialect?)
    /// The Netezza dialect
    indirect case netezzaDialect(NetezzaDialect?)
    /// The Azure Synapse dialect
    indirect case azureSynapseDialect(AzureSynapseDialect?)
    /// The Vertica dialect
    indirect case verticaDialect(VerticaDialect?)
    /// The SQL Server dialect
    indirect case sqlServerDialect(SQLServerDialect?)
    /// The Postgresql dialect
    indirect case postgresqlDialect(PostgresqlDialect?)
    /// The Presto dialect
    indirect case prestoDialect(PrestoDialect?)
    /// The MySQL dialect
    indirect case mysqlDialect(MySQLDialect?)
    /// DB2 dialect
    indirect case db2Dialect(DB2Dialect?)
    /// SQLite dialect
    indirect case sqliteDialect(SQLiteDialect?)
    /// Greenplum dialect
    indirect case greenplumDialect(GreenplumDialect?)
  }

  public static var _anyTypeUrl: Swift.String {
    return "type.googleapis.com/google.cloud.bigquery.migration.v2.Dialect"
  }
  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)
  }
}
