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

  /// External primary instance migration setting error/warning.
  public struct SqlExternalSyncSettingError: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Can be `sql#externalSyncSettingError` or
    /// `sql#externalSyncSettingWarning`.
    public var kind: Swift.String = Swift.String()

    /// Identifies the specific error that occurred.
    public var type: SqlExternalSyncSettingError.SqlExternalSyncSettingErrorType =
      SqlExternalSyncSettingError.SqlExternalSyncSettingErrorType()

    /// Additional information about the error encountered.
    public var detail: Swift.String = Swift.String()

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

    public enum SqlExternalSyncSettingErrorType: Codable, Equatable, Sendable {
      case unspecified
      case connectionFailure
      case binlogNotEnabled
      case incompatibleDatabaseVersion
      case replicaAlreadySetup
      /// The replication user is missing privileges that are required.
      case insufficientPrivilege
      /// Unsupported migration type.
      case unsupportedMigrationType
      /// No pglogical extension installed on databases, applicable for postgres.
      case noPglogicalInstalled
      /// pglogical node already exists on databases, applicable for postgres.
      case pglogicalNodeAlreadyExists
      /// The value of parameter wal_level is not set to logical.
      case invalidWalLevel
      /// The value of parameter shared_preload_libraries does not include
      /// pglogical.
      case invalidSharedPreloadLibrary
      /// The value of parameter max_replication_slots is not sufficient.
      case insufficientMaxReplicationSlots
      /// The value of parameter max_wal_senders is not sufficient.
      case insufficientMaxWalSenders
      /// The value of parameter max_worker_processes is not sufficient.
      case insufficientMaxWorkerProcesses
      /// Extensions installed are either not supported or having unsupported
      /// versions.
      case unsupportedExtensions
      /// The value of parameter rds.logical_replication is not set to 1.
      case invalidRdsLogicalReplication
      /// The primary instance logging setup doesn't allow EM sync.
      case invalidLoggingSetup
      /// The primary instance database parameter setup doesn't allow EM sync.
      case invalidDbParam
      /// The gtid_mode is not supported, applicable for MySQL.
      case unsupportedGtidMode
      /// SQL Server Agent is not running.
      case sqlserverAgentNotRunning
      /// The table definition is not support due to missing primary key or replica
      /// identity, applicable for postgres. Note that this is a warning and won't
      /// block the migration.
      case unsupportedTableDefinition
      /// The customer has a definer that will break EM setup.
      case unsupportedDefiner
      /// SQL Server @@SERVERNAME does not match actual host name.
      case sqlserverServernameMismatch
      /// The primary instance has been setup and will fail the setup.
      case primaryAlreadySetup
      /// The primary instance has unsupported binary log format.
      case unsupportedBinlogFormat
      /// The primary instance's binary log retention setting.
      case binlogRetentionSetting
      /// The primary instance has tables with unsupported storage engine.
      case unsupportedStorageEngine
      /// Source has tables with limited support
      /// eg: PostgreSQL tables without primary keys.
      case limitedSupportTables
      /// The replica instance contains existing data.
      case existingDataInReplica
      /// The replication user is missing privileges that are optional.
      case missingOptionalPrivileges
      /// Additional BACKUP_ADMIN privilege is granted to the replication user
      /// which may lock source MySQL 8 instance for DDLs during initial sync.
      case riskyBackupAdminPrivilege
      /// The Cloud Storage bucket is missing necessary permissions.
      case insufficientGcsPermissions
      /// The Cloud Storage bucket has an error in the file or contains invalid
      /// file information.
      case invalidFileInfo
      /// The source instance has unsupported database settings for migration.
      case unsupportedDatabaseSettings
      /// The replication user is missing parallel import specific privileges.
      /// (e.g. LOCK TABLES) for MySQL.
      case mysqlParallelImportInsufficientPrivilege
      /// The global variable local_infile is off on external server replica.
      case localInfileOff
      /// This code instructs customers to turn on point-in-time recovery manually
      /// for the instance after promoting the Cloud SQL for PostgreSQL instance.
      case turnOnPitrAfterPromote
      /// The minor version of replica database is incompatible with the source.
      case incompatibleDatabaseMinorVersion
      /// This warning message indicates that Cloud SQL uses the maximum number of
      /// subscriptions to migrate data from the source to the destination.
      case sourceMaxSubscriptions
      /// Unable to verify definers on the source for MySQL.
      case unableToVerifyDefiners
      /// If a time out occurs while the subscription counts are calculated, then
      /// this value is set to 1. Otherwise, this value is set to 2.
      case subscriptionCalculationStatus
      /// Count of subscriptions needed to sync source data for PostgreSQL
      /// database.
      case pgSubscriptionCount
      /// Final parallel level that is used to do migration.
      case pgSyncParallelLevel
      /// The disk size of the replica instance is smaller than the data size of
      /// the source instance.
      case insufficientDiskSize
      /// The data size of the source instance is greater than 1 TB, the number of
      /// cores of the replica instance is less than 8, and the memory of the
      /// replica is less than 32 GB.
      case insufficientMachineTier
      /// The warning message indicates the unsupported extensions will not be
      /// migrated to the destination.
      case unsupportedExtensionsNotMigrated
      /// The warning message indicates the pg_cron extension and settings will not
      /// be migrated to the destination.
      case extensionsNotMigrated
      /// The error message indicates that pg_cron flags are enabled on the
      /// destination which is not supported during the migration.
      case pgCronFlagEnabledInReplica
      /// This error message indicates that the specified extensions are not
      /// enabled on destination instance. For example, before you can migrate
      /// data to the destination instance, you must enable the PGAudit extension
      /// on the instance.
      case extensionsNotEnabledInReplica
      /// The source database has generated columns that can't be migrated. Please
      /// change them to regular columns before migration.
      case unsupportedColumns
      /// The source database has users that aren't created in the replica.
      /// First, create all users, which are in the pg_user_mappings table
      /// of the source database, in the destination instance. Then, perform the
      /// migration.
      case usersNotCreatedInReplica
      /// The selected objects include system objects that aren't supported for
      /// migration.
      case unsupportedSystemObjects
      /// The source database has tables with the FULL or NOTHING replica identity.
      /// Before starting your migration, either remove the identity or change it
      /// to DEFAULT. Note that this is an error and will block the migration.
      case unsupportedTablesWithReplicaIdentity
      /// The selected objects don't exist on the source instance.
      case selectedObjectsNotExistOnSource
      /// PSC only destination instance does not have a network attachment URI.
      case pscOnlyInstanceWithNoNetworkAttachmentUri
      /// Selected objects reference unselected objects. Based on their object type
      /// (foreign key constraint or view), selected objects will fail during
      /// migration.
      case selectedObjectsReferenceUnselectedObjects
      /// The migration will delete existing data in the replica; set
      /// [replica_overwrite_enabled][google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest.replica_overwrite_enabled]
      /// in the request to acknowledge this. This is an error. MySQL only.
      ///
      /// [google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest.replica_overwrite_enabled]: <doc:SqlInstancesStartExternalSyncRequest/replicaOverwriteEnabled>
      case promptDeleteExisting
      /// The migration will delete existing data in the replica;
      /// [replica_overwrite_enabled][google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest.replica_overwrite_enabled]
      /// was set in the request acknowledging this. This is a warning rather than
      /// an error. MySQL only.
      ///
      /// [google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest.replica_overwrite_enabled]: <doc:SqlInstancesStartExternalSyncRequest/replicaOverwriteEnabled>
      case willDeleteExisting
      /// The replication user is missing specific privileges to setup DDL
      /// replication. (e.g. CREATE EVENT TRIGGER, CREATE SCHEMA) for PostgreSQL.
      case pgDdlReplicationInsufficientPrivilege
      /// 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 .connectionFailure: return 1
        case .binlogNotEnabled: return 2
        case .incompatibleDatabaseVersion: return 3
        case .replicaAlreadySetup: return 4
        case .insufficientPrivilege: return 5
        case .unsupportedMigrationType: return 6
        case .noPglogicalInstalled: return 7
        case .pglogicalNodeAlreadyExists: return 8
        case .invalidWalLevel: return 9
        case .invalidSharedPreloadLibrary: return 10
        case .insufficientMaxReplicationSlots: return 11
        case .insufficientMaxWalSenders: return 12
        case .insufficientMaxWorkerProcesses: return 13
        case .unsupportedExtensions: return 14
        case .invalidRdsLogicalReplication: return 15
        case .invalidLoggingSetup: return 16
        case .invalidDbParam: return 17
        case .unsupportedGtidMode: return 18
        case .sqlserverAgentNotRunning: return 19
        case .unsupportedTableDefinition: return 20
        case .unsupportedDefiner: return 21
        case .sqlserverServernameMismatch: return 22
        case .primaryAlreadySetup: return 23
        case .unsupportedBinlogFormat: return 24
        case .binlogRetentionSetting: return 25
        case .unsupportedStorageEngine: return 26
        case .limitedSupportTables: return 27
        case .existingDataInReplica: return 28
        case .missingOptionalPrivileges: return 29
        case .riskyBackupAdminPrivilege: return 30
        case .insufficientGcsPermissions: return 31
        case .invalidFileInfo: return 32
        case .unsupportedDatabaseSettings: return 33
        case .mysqlParallelImportInsufficientPrivilege: return 34
        case .localInfileOff: return 35
        case .turnOnPitrAfterPromote: return 36
        case .incompatibleDatabaseMinorVersion: return 37
        case .sourceMaxSubscriptions: return 38
        case .unableToVerifyDefiners: return 39
        case .subscriptionCalculationStatus: return 40
        case .pgSubscriptionCount: return 41
        case .pgSyncParallelLevel: return 42
        case .insufficientDiskSize: return 43
        case .insufficientMachineTier: return 44
        case .unsupportedExtensionsNotMigrated: return 45
        case .extensionsNotMigrated: return 46
        case .pgCronFlagEnabledInReplica: return 47
        case .extensionsNotEnabledInReplica: return 48
        case .unsupportedColumns: return 49
        case .usersNotCreatedInReplica: return 50
        case .unsupportedSystemObjects: return 51
        case .unsupportedTablesWithReplicaIdentity: return 52
        case .selectedObjectsNotExistOnSource: return 53
        case .pscOnlyInstanceWithNoNetworkAttachmentUri: return 54
        case .selectedObjectsReferenceUnselectedObjects: return 55
        case .promptDeleteExisting: return 56
        case .willDeleteExisting: return 57
        case .pgDdlReplicationInsufficientPrivilege: return 58
        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_EXTERNAL_SYNC_SETTING_ERROR_TYPE_UNSPECIFIED"
        case .connectionFailure: return "CONNECTION_FAILURE"
        case .binlogNotEnabled: return "BINLOG_NOT_ENABLED"
        case .incompatibleDatabaseVersion: return "INCOMPATIBLE_DATABASE_VERSION"
        case .replicaAlreadySetup: return "REPLICA_ALREADY_SETUP"
        case .insufficientPrivilege: return "INSUFFICIENT_PRIVILEGE"
        case .unsupportedMigrationType: return "UNSUPPORTED_MIGRATION_TYPE"
        case .noPglogicalInstalled: return "NO_PGLOGICAL_INSTALLED"
        case .pglogicalNodeAlreadyExists: return "PGLOGICAL_NODE_ALREADY_EXISTS"
        case .invalidWalLevel: return "INVALID_WAL_LEVEL"
        case .invalidSharedPreloadLibrary: return "INVALID_SHARED_PRELOAD_LIBRARY"
        case .insufficientMaxReplicationSlots: return "INSUFFICIENT_MAX_REPLICATION_SLOTS"
        case .insufficientMaxWalSenders: return "INSUFFICIENT_MAX_WAL_SENDERS"
        case .insufficientMaxWorkerProcesses: return "INSUFFICIENT_MAX_WORKER_PROCESSES"
        case .unsupportedExtensions: return "UNSUPPORTED_EXTENSIONS"
        case .invalidRdsLogicalReplication: return "INVALID_RDS_LOGICAL_REPLICATION"
        case .invalidLoggingSetup: return "INVALID_LOGGING_SETUP"
        case .invalidDbParam: return "INVALID_DB_PARAM"
        case .unsupportedGtidMode: return "UNSUPPORTED_GTID_MODE"
        case .sqlserverAgentNotRunning: return "SQLSERVER_AGENT_NOT_RUNNING"
        case .unsupportedTableDefinition: return "UNSUPPORTED_TABLE_DEFINITION"
        case .unsupportedDefiner: return "UNSUPPORTED_DEFINER"
        case .sqlserverServernameMismatch: return "SQLSERVER_SERVERNAME_MISMATCH"
        case .primaryAlreadySetup: return "PRIMARY_ALREADY_SETUP"
        case .unsupportedBinlogFormat: return "UNSUPPORTED_BINLOG_FORMAT"
        case .binlogRetentionSetting: return "BINLOG_RETENTION_SETTING"
        case .unsupportedStorageEngine: return "UNSUPPORTED_STORAGE_ENGINE"
        case .limitedSupportTables: return "LIMITED_SUPPORT_TABLES"
        case .existingDataInReplica: return "EXISTING_DATA_IN_REPLICA"
        case .missingOptionalPrivileges: return "MISSING_OPTIONAL_PRIVILEGES"
        case .riskyBackupAdminPrivilege: return "RISKY_BACKUP_ADMIN_PRIVILEGE"
        case .insufficientGcsPermissions: return "INSUFFICIENT_GCS_PERMISSIONS"
        case .invalidFileInfo: return "INVALID_FILE_INFO"
        case .unsupportedDatabaseSettings: return "UNSUPPORTED_DATABASE_SETTINGS"
        case .mysqlParallelImportInsufficientPrivilege:
          return "MYSQL_PARALLEL_IMPORT_INSUFFICIENT_PRIVILEGE"
        case .localInfileOff: return "LOCAL_INFILE_OFF"
        case .turnOnPitrAfterPromote: return "TURN_ON_PITR_AFTER_PROMOTE"
        case .incompatibleDatabaseMinorVersion: return "INCOMPATIBLE_DATABASE_MINOR_VERSION"
        case .sourceMaxSubscriptions: return "SOURCE_MAX_SUBSCRIPTIONS"
        case .unableToVerifyDefiners: return "UNABLE_TO_VERIFY_DEFINERS"
        case .subscriptionCalculationStatus: return "SUBSCRIPTION_CALCULATION_STATUS"
        case .pgSubscriptionCount: return "PG_SUBSCRIPTION_COUNT"
        case .pgSyncParallelLevel: return "PG_SYNC_PARALLEL_LEVEL"
        case .insufficientDiskSize: return "INSUFFICIENT_DISK_SIZE"
        case .insufficientMachineTier: return "INSUFFICIENT_MACHINE_TIER"
        case .unsupportedExtensionsNotMigrated: return "UNSUPPORTED_EXTENSIONS_NOT_MIGRATED"
        case .extensionsNotMigrated: return "EXTENSIONS_NOT_MIGRATED"
        case .pgCronFlagEnabledInReplica: return "PG_CRON_FLAG_ENABLED_IN_REPLICA"
        case .extensionsNotEnabledInReplica: return "EXTENSIONS_NOT_ENABLED_IN_REPLICA"
        case .unsupportedColumns: return "UNSUPPORTED_COLUMNS"
        case .usersNotCreatedInReplica: return "USERS_NOT_CREATED_IN_REPLICA"
        case .unsupportedSystemObjects: return "UNSUPPORTED_SYSTEM_OBJECTS"
        case .unsupportedTablesWithReplicaIdentity:
          return "UNSUPPORTED_TABLES_WITH_REPLICA_IDENTITY"
        case .selectedObjectsNotExistOnSource: return "SELECTED_OBJECTS_NOT_EXIST_ON_SOURCE"
        case .pscOnlyInstanceWithNoNetworkAttachmentUri:
          return "PSC_ONLY_INSTANCE_WITH_NO_NETWORK_ATTACHMENT_URI"
        case .selectedObjectsReferenceUnselectedObjects:
          return "SELECTED_OBJECTS_REFERENCE_UNSELECTED_OBJECTS"
        case .promptDeleteExisting: return "PROMPT_DELETE_EXISTING"
        case .willDeleteExisting: return "WILL_DELETE_EXISTING"
        case .pgDdlReplicationInsufficientPrivilege:
          return "PG_DDL_REPLICATION_INSUFFICIENT_PRIVILEGE"
        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:SqlExternalSyncSettingErrorType/unknownStringValue(_:)).
      public init(stringValue: Swift.String) {
        switch stringValue {
        case "SQL_EXTERNAL_SYNC_SETTING_ERROR_TYPE_UNSPECIFIED": self = .unspecified
        case "CONNECTION_FAILURE": self = .connectionFailure
        case "BINLOG_NOT_ENABLED": self = .binlogNotEnabled
        case "INCOMPATIBLE_DATABASE_VERSION": self = .incompatibleDatabaseVersion
        case "REPLICA_ALREADY_SETUP": self = .replicaAlreadySetup
        case "INSUFFICIENT_PRIVILEGE": self = .insufficientPrivilege
        case "UNSUPPORTED_MIGRATION_TYPE": self = .unsupportedMigrationType
        case "NO_PGLOGICAL_INSTALLED": self = .noPglogicalInstalled
        case "PGLOGICAL_NODE_ALREADY_EXISTS": self = .pglogicalNodeAlreadyExists
        case "INVALID_WAL_LEVEL": self = .invalidWalLevel
        case "INVALID_SHARED_PRELOAD_LIBRARY": self = .invalidSharedPreloadLibrary
        case "INSUFFICIENT_MAX_REPLICATION_SLOTS": self = .insufficientMaxReplicationSlots
        case "INSUFFICIENT_MAX_WAL_SENDERS": self = .insufficientMaxWalSenders
        case "INSUFFICIENT_MAX_WORKER_PROCESSES": self = .insufficientMaxWorkerProcesses
        case "UNSUPPORTED_EXTENSIONS": self = .unsupportedExtensions
        case "INVALID_RDS_LOGICAL_REPLICATION": self = .invalidRdsLogicalReplication
        case "INVALID_LOGGING_SETUP": self = .invalidLoggingSetup
        case "INVALID_DB_PARAM": self = .invalidDbParam
        case "UNSUPPORTED_GTID_MODE": self = .unsupportedGtidMode
        case "SQLSERVER_AGENT_NOT_RUNNING": self = .sqlserverAgentNotRunning
        case "UNSUPPORTED_TABLE_DEFINITION": self = .unsupportedTableDefinition
        case "UNSUPPORTED_DEFINER": self = .unsupportedDefiner
        case "SQLSERVER_SERVERNAME_MISMATCH": self = .sqlserverServernameMismatch
        case "PRIMARY_ALREADY_SETUP": self = .primaryAlreadySetup
        case "UNSUPPORTED_BINLOG_FORMAT": self = .unsupportedBinlogFormat
        case "BINLOG_RETENTION_SETTING": self = .binlogRetentionSetting
        case "UNSUPPORTED_STORAGE_ENGINE": self = .unsupportedStorageEngine
        case "LIMITED_SUPPORT_TABLES": self = .limitedSupportTables
        case "EXISTING_DATA_IN_REPLICA": self = .existingDataInReplica
        case "MISSING_OPTIONAL_PRIVILEGES": self = .missingOptionalPrivileges
        case "RISKY_BACKUP_ADMIN_PRIVILEGE": self = .riskyBackupAdminPrivilege
        case "INSUFFICIENT_GCS_PERMISSIONS": self = .insufficientGcsPermissions
        case "INVALID_FILE_INFO": self = .invalidFileInfo
        case "UNSUPPORTED_DATABASE_SETTINGS": self = .unsupportedDatabaseSettings
        case "MYSQL_PARALLEL_IMPORT_INSUFFICIENT_PRIVILEGE":
          self = .mysqlParallelImportInsufficientPrivilege
        case "LOCAL_INFILE_OFF": self = .localInfileOff
        case "TURN_ON_PITR_AFTER_PROMOTE": self = .turnOnPitrAfterPromote
        case "INCOMPATIBLE_DATABASE_MINOR_VERSION": self = .incompatibleDatabaseMinorVersion
        case "SOURCE_MAX_SUBSCRIPTIONS": self = .sourceMaxSubscriptions
        case "UNABLE_TO_VERIFY_DEFINERS": self = .unableToVerifyDefiners
        case "SUBSCRIPTION_CALCULATION_STATUS": self = .subscriptionCalculationStatus
        case "PG_SUBSCRIPTION_COUNT": self = .pgSubscriptionCount
        case "PG_SYNC_PARALLEL_LEVEL": self = .pgSyncParallelLevel
        case "INSUFFICIENT_DISK_SIZE": self = .insufficientDiskSize
        case "INSUFFICIENT_MACHINE_TIER": self = .insufficientMachineTier
        case "UNSUPPORTED_EXTENSIONS_NOT_MIGRATED": self = .unsupportedExtensionsNotMigrated
        case "EXTENSIONS_NOT_MIGRATED": self = .extensionsNotMigrated
        case "PG_CRON_FLAG_ENABLED_IN_REPLICA": self = .pgCronFlagEnabledInReplica
        case "EXTENSIONS_NOT_ENABLED_IN_REPLICA": self = .extensionsNotEnabledInReplica
        case "UNSUPPORTED_COLUMNS": self = .unsupportedColumns
        case "USERS_NOT_CREATED_IN_REPLICA": self = .usersNotCreatedInReplica
        case "UNSUPPORTED_SYSTEM_OBJECTS": self = .unsupportedSystemObjects
        case "UNSUPPORTED_TABLES_WITH_REPLICA_IDENTITY":
          self = .unsupportedTablesWithReplicaIdentity
        case "SELECTED_OBJECTS_NOT_EXIST_ON_SOURCE": self = .selectedObjectsNotExistOnSource
        case "PSC_ONLY_INSTANCE_WITH_NO_NETWORK_ATTACHMENT_URI":
          self = .pscOnlyInstanceWithNoNetworkAttachmentUri
        case "SELECTED_OBJECTS_REFERENCE_UNSELECTED_OBJECTS":
          self = .selectedObjectsReferenceUnselectedObjects
        case "PROMPT_DELETE_EXISTING": self = .promptDeleteExisting
        case "WILL_DELETE_EXISTING": self = .willDeleteExisting
        case "PG_DDL_REPLICATION_INSUFFICIENT_PRIVILEGE":
          self = .pgDdlReplicationInsufficientPrivilege
        default: self = .unknownStringValue(stringValue)
        }
      }

      /// Initialize from an integer value.
      ///
      /// If the value is unknown, this initializes to [`unknownIntValue`](doc:SqlExternalSyncSettingErrorType/unknownIntValue(_:)).
      public init(intValue: Int) {
        switch intValue {
        case 0: self = .unspecified
        case 1: self = .connectionFailure
        case 2: self = .binlogNotEnabled
        case 3: self = .incompatibleDatabaseVersion
        case 4: self = .replicaAlreadySetup
        case 5: self = .insufficientPrivilege
        case 6: self = .unsupportedMigrationType
        case 7: self = .noPglogicalInstalled
        case 8: self = .pglogicalNodeAlreadyExists
        case 9: self = .invalidWalLevel
        case 10: self = .invalidSharedPreloadLibrary
        case 11: self = .insufficientMaxReplicationSlots
        case 12: self = .insufficientMaxWalSenders
        case 13: self = .insufficientMaxWorkerProcesses
        case 14: self = .unsupportedExtensions
        case 15: self = .invalidRdsLogicalReplication
        case 16: self = .invalidLoggingSetup
        case 17: self = .invalidDbParam
        case 18: self = .unsupportedGtidMode
        case 19: self = .sqlserverAgentNotRunning
        case 20: self = .unsupportedTableDefinition
        case 21: self = .unsupportedDefiner
        case 22: self = .sqlserverServernameMismatch
        case 23: self = .primaryAlreadySetup
        case 24: self = .unsupportedBinlogFormat
        case 25: self = .binlogRetentionSetting
        case 26: self = .unsupportedStorageEngine
        case 27: self = .limitedSupportTables
        case 28: self = .existingDataInReplica
        case 29: self = .missingOptionalPrivileges
        case 30: self = .riskyBackupAdminPrivilege
        case 31: self = .insufficientGcsPermissions
        case 32: self = .invalidFileInfo
        case 33: self = .unsupportedDatabaseSettings
        case 34: self = .mysqlParallelImportInsufficientPrivilege
        case 35: self = .localInfileOff
        case 36: self = .turnOnPitrAfterPromote
        case 37: self = .incompatibleDatabaseMinorVersion
        case 38: self = .sourceMaxSubscriptions
        case 39: self = .unableToVerifyDefiners
        case 40: self = .subscriptionCalculationStatus
        case 41: self = .pgSubscriptionCount
        case 42: self = .pgSyncParallelLevel
        case 43: self = .insufficientDiskSize
        case 44: self = .insufficientMachineTier
        case 45: self = .unsupportedExtensionsNotMigrated
        case 46: self = .extensionsNotMigrated
        case 47: self = .pgCronFlagEnabledInReplica
        case 48: self = .extensionsNotEnabledInReplica
        case 49: self = .unsupportedColumns
        case 50: self = .usersNotCreatedInReplica
        case 51: self = .unsupportedSystemObjects
        case 52: self = .unsupportedTablesWithReplicaIdentity
        case 53: self = .selectedObjectsNotExistOnSource
        case 54: self = .pscOnlyInstanceWithNoNetworkAttachmentUri
        case 55: self = .selectedObjectsReferenceUnselectedObjects
        case 56: self = .promptDeleteExisting
        case 57: self = .willDeleteExisting
        case 58: self = .pgDdlReplicationInsufficientPrivilege
        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 .connectionFailure: return try container.encode(1)
        case .binlogNotEnabled: return try container.encode(2)
        case .incompatibleDatabaseVersion: return try container.encode(3)
        case .replicaAlreadySetup: return try container.encode(4)
        case .insufficientPrivilege: return try container.encode(5)
        case .unsupportedMigrationType: return try container.encode(6)
        case .noPglogicalInstalled: return try container.encode(7)
        case .pglogicalNodeAlreadyExists: return try container.encode(8)
        case .invalidWalLevel: return try container.encode(9)
        case .invalidSharedPreloadLibrary: return try container.encode(10)
        case .insufficientMaxReplicationSlots: return try container.encode(11)
        case .insufficientMaxWalSenders: return try container.encode(12)
        case .insufficientMaxWorkerProcesses: return try container.encode(13)
        case .unsupportedExtensions: return try container.encode(14)
        case .invalidRdsLogicalReplication: return try container.encode(15)
        case .invalidLoggingSetup: return try container.encode(16)
        case .invalidDbParam: return try container.encode(17)
        case .unsupportedGtidMode: return try container.encode(18)
        case .sqlserverAgentNotRunning: return try container.encode(19)
        case .unsupportedTableDefinition: return try container.encode(20)
        case .unsupportedDefiner: return try container.encode(21)
        case .sqlserverServernameMismatch: return try container.encode(22)
        case .primaryAlreadySetup: return try container.encode(23)
        case .unsupportedBinlogFormat: return try container.encode(24)
        case .binlogRetentionSetting: return try container.encode(25)
        case .unsupportedStorageEngine: return try container.encode(26)
        case .limitedSupportTables: return try container.encode(27)
        case .existingDataInReplica: return try container.encode(28)
        case .missingOptionalPrivileges: return try container.encode(29)
        case .riskyBackupAdminPrivilege: return try container.encode(30)
        case .insufficientGcsPermissions: return try container.encode(31)
        case .invalidFileInfo: return try container.encode(32)
        case .unsupportedDatabaseSettings: return try container.encode(33)
        case .mysqlParallelImportInsufficientPrivilege: return try container.encode(34)
        case .localInfileOff: return try container.encode(35)
        case .turnOnPitrAfterPromote: return try container.encode(36)
        case .incompatibleDatabaseMinorVersion: return try container.encode(37)
        case .sourceMaxSubscriptions: return try container.encode(38)
        case .unableToVerifyDefiners: return try container.encode(39)
        case .subscriptionCalculationStatus: return try container.encode(40)
        case .pgSubscriptionCount: return try container.encode(41)
        case .pgSyncParallelLevel: return try container.encode(42)
        case .insufficientDiskSize: return try container.encode(43)
        case .insufficientMachineTier: return try container.encode(44)
        case .unsupportedExtensionsNotMigrated: return try container.encode(45)
        case .extensionsNotMigrated: return try container.encode(46)
        case .pgCronFlagEnabledInReplica: return try container.encode(47)
        case .extensionsNotEnabledInReplica: return try container.encode(48)
        case .unsupportedColumns: return try container.encode(49)
        case .usersNotCreatedInReplica: return try container.encode(50)
        case .unsupportedSystemObjects: return try container.encode(51)
        case .unsupportedTablesWithReplicaIdentity: return try container.encode(52)
        case .selectedObjectsNotExistOnSource: return try container.encode(53)
        case .pscOnlyInstanceWithNoNetworkAttachmentUri: return try container.encode(54)
        case .selectedObjectsReferenceUnselectedObjects: return try container.encode(55)
        case .promptDeleteExisting: return try container.encode(56)
        case .willDeleteExisting: return try container.encode(57)
        case .pgDdlReplicationInsufficientPrivilege: return try container.encode(58)
        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.SqlExternalSyncSettingError"
    }
    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
