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

/// Represents a Database Migration Service migration job object.
public struct MigrationJob: Codable, Equatable, GoogleCloudWkt._AnyPackable,
  Sendable
{
  /// The name (URI) of this migration job resource, in the form of:
  /// projects/{project}/locations/{location}/migrationJobs/{migrationJob}.
  public var name: Swift.String = Swift.String()

  /// Output only. The timestamp when the migration job resource was created.
  /// A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds.
  /// Example: "2014-10-02T15:01:23.045123456Z".
  public var createTime: GoogleCloudWkt.Timestamp? = nil

  /// Output only. The timestamp when the migration job resource was last
  /// updated. A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds.
  /// Example: "2014-10-02T15:01:23.045123456Z".
  public var updateTime: GoogleCloudWkt.Timestamp? = nil

  /// The resource labels for migration job 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": "1.3kg", "count": "3" }`.
  public var labels: [Swift.String: Swift.String] = [:]

  /// The migration job display name.
  public var displayName: Swift.String = Swift.String()

  /// The current migration job state.
  public var state: MigrationJob.State = MigrationJob.State()

  /// Output only. The current migration job phase.
  public var phase: MigrationJob.Phase = MigrationJob.Phase()

  /// Required. The migration job type.
  public var type: MigrationJob.Type_ = MigrationJob.Type_()

  /// The path to the dump file in Google Cloud Storage,
  /// in the format: (gs://[BUCKET_NAME]/[OBJECT_NAME]).
  /// This field and the "dump_flags" field are mutually exclusive.
  public var dumpPath: Swift.String = Swift.String()

  /// The initial dump flags.
  /// This field and the "dump_path" field are mutually exclusive.
  public var dumpFlags: MigrationJob.DumpFlags? = nil

  /// Required. The resource name (URI) of the source connection profile.
  public var source: Swift.String = Swift.String()

  /// Required. The resource name (URI) of the destination connection profile.
  public var destination: Swift.String = Swift.String()

  /// Output only. The duration of the migration job (in seconds). A duration in
  /// seconds with up to nine fractional digits, terminated by 's'. Example:
  /// "3.5s".
  public var duration: GoogleCloudWkt.Duration? = nil

  /// Output only. The error details in case of state FAILED.
  public var error: GoogleRpc.Status? = nil

  /// The database engine type and provider of the source.
  public var sourceDatabase: DatabaseType? = nil

  /// The database engine type and provider of the destination.
  public var destinationDatabase: DatabaseType? = nil

  /// Output only. If the migration job is completed, the time when it was
  /// completed.
  public var endTime: GoogleCloudWkt.Timestamp? = nil

  /// The conversion workspace used by the migration.
  public var conversionWorkspace: ConversionWorkspaceInfo? = nil

  /// This field can be used to select the entities to migrate as part of
  /// the migration job. It uses AIP-160 notation to select a subset of the
  /// entities configured on the associated conversion-workspace. This field
  /// should not be set on migration-jobs that are not associated with a
  /// conversion workspace.
  public var filter: Swift.String = Swift.String()

  /// The CMEK (customer-managed encryption key) fully qualified key name used
  /// for the migration job.
  /// This field supports all migration jobs types except for:
  /// * Mysql to Mysql (use the cmek field in the cloudsql connection profile
  /// instead).
  /// * PostrgeSQL to PostgreSQL (use the cmek field in the cloudsql
  /// connection profile instead).
  /// * PostgreSQL to AlloyDB (use the kms_key_name field in the alloydb
  /// connection profile instead).
  /// Each Cloud CMEK key has the following format:
  /// projects/[PROJECT]/locations/[REGION]/keyRings/[RING]/cryptoKeys/[KEY_NAME]
  public var cmekKeyName: Swift.String = Swift.String()

  /// Optional. Data dump parallelism settings used by the migration.
  /// Currently applicable only for MySQL to Cloud SQL for MySQL migrations only.
  public var performanceConfig: MigrationJob.PerformanceConfig? = nil

  /// The connectivity method.
  public var connectivity: OneOf_Connectivity? = nil

  /// Initialize a new instance of `MigrationJob`.
  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 = MigrationJob().with { $0.name = ... }
  /// ```
  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 name = "name"
    case createTime = "createTime"
    case updateTime = "updateTime"
    case labels = "labels"
    case displayName = "displayName"
    case state = "state"
    case phase = "phase"
    case type = "type"
    case dumpPath = "dumpPath"
    case dumpFlags = "dumpFlags"
    case source = "source"
    case destination = "destination"
    case reverseSshConnectivity = "reverseSshConnectivity"
    case vpcPeeringConnectivity = "vpcPeeringConnectivity"
    case staticIpConnectivity = "staticIpConnectivity"
    case duration = "duration"
    case error = "error"
    case sourceDatabase = "sourceDatabase"
    case destinationDatabase = "destinationDatabase"
    case endTime = "endTime"
    case conversionWorkspace = "conversionWorkspace"
    case filter = "filter"
    case cmekKeyName = "cmekKeyName"
    case performanceConfig = "performanceConfig"
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
    self.name = try container.decode(Swift.String.self, forKey: .name)
    self.createTime = try container.decodeIfPresent(
      GoogleCloudWkt.Timestamp.self, forKey: .createTime)
    self.updateTime = try container.decodeIfPresent(
      GoogleCloudWkt.Timestamp.self, forKey: .updateTime)
    self.labels = try container.decode([Swift.String: Swift.String].self, forKey: .labels)
    self.displayName = try container.decode(Swift.String.self, forKey: .displayName)
    self.state = try container.decode(MigrationJob.State.self, forKey: .state)
    self.phase = try container.decode(MigrationJob.Phase.self, forKey: .phase)
    self.type = try container.decode(MigrationJob.Type_.self, forKey: .type)
    self.dumpPath = try container.decode(Swift.String.self, forKey: .dumpPath)
    self.dumpFlags = try container.decodeIfPresent(MigrationJob.DumpFlags.self, forKey: .dumpFlags)
    self.source = try container.decode(Swift.String.self, forKey: .source)
    self.destination = try container.decode(Swift.String.self, forKey: .destination)
    self.duration = try container.decodeIfPresent(GoogleCloudWkt.Duration.self, forKey: .duration)
    self.error = try container.decodeIfPresent(GoogleRpc.Status.self, forKey: .error)
    self.sourceDatabase = try container.decodeIfPresent(DatabaseType.self, forKey: .sourceDatabase)
    self.destinationDatabase = try container.decodeIfPresent(
      DatabaseType.self, forKey: .destinationDatabase)
    self.endTime = try container.decodeIfPresent(GoogleCloudWkt.Timestamp.self, forKey: .endTime)
    self.conversionWorkspace = try container.decodeIfPresent(
      ConversionWorkspaceInfo.self, forKey: .conversionWorkspace)
    self.filter = try container.decode(Swift.String.self, forKey: .filter)
    self.cmekKeyName = try container.decode(Swift.String.self, forKey: .cmekKeyName)
    self.performanceConfig = try container.decodeIfPresent(
      MigrationJob.PerformanceConfig.self, forKey: .performanceConfig)

    var connectivity: OneOf_Connectivity? = nil
    let connectivityCheckAndSet = {
      if connectivity != nil {
        throw DecodingError.dataCorrupted(
          DecodingError.Context(
            codingPath: decoder.codingPath,
            debugDescription: "Multiple values set for oneof 'connectivity'"))
      }
      connectivity = $0
    }
    if let reverseSshConnectivity = try container.decodeIfPresent(
      ReverseSshConnectivity?.self, forKey: .reverseSshConnectivity)
    {
      try connectivityCheckAndSet(.reverseSshConnectivity(reverseSshConnectivity))
    }
    if let vpcPeeringConnectivity = try container.decodeIfPresent(
      VpcPeeringConnectivity?.self, forKey: .vpcPeeringConnectivity)
    {
      try connectivityCheckAndSet(.vpcPeeringConnectivity(vpcPeeringConnectivity))
    }
    if let staticIpConnectivity = try container.decodeIfPresent(
      StaticIpConnectivity?.self, forKey: .staticIpConnectivity)
    {
      try connectivityCheckAndSet(.staticIpConnectivity(staticIpConnectivity))
    }
    self.connectivity = connectivity
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    try container.encode(self.name, forKey: .name)
    try container.encode(self.createTime, forKey: .createTime)
    try container.encode(self.updateTime, forKey: .updateTime)
    try container.encode(self.labels, forKey: .labels)
    try container.encode(self.displayName, forKey: .displayName)
    try container.encode(self.state, forKey: .state)
    try container.encode(self.phase, forKey: .phase)
    try container.encode(self.type, forKey: .type)
    try container.encode(self.dumpPath, forKey: .dumpPath)
    try container.encode(self.dumpFlags, forKey: .dumpFlags)
    try container.encode(self.source, forKey: .source)
    try container.encode(self.destination, forKey: .destination)
    try container.encode(self.duration, forKey: .duration)
    try container.encode(self.error, forKey: .error)
    try container.encode(self.sourceDatabase, forKey: .sourceDatabase)
    try container.encode(self.destinationDatabase, forKey: .destinationDatabase)
    try container.encode(self.endTime, forKey: .endTime)
    try container.encode(self.conversionWorkspace, forKey: .conversionWorkspace)
    try container.encode(self.filter, forKey: .filter)
    try container.encode(self.cmekKeyName, forKey: .cmekKeyName)
    try container.encode(self.performanceConfig, forKey: .performanceConfig)

    if let choice = self.connectivity {
      switch choice {
      case .reverseSshConnectivity(let value):
        try container.encode(value, forKey: .reverseSshConnectivity)
      case .vpcPeeringConnectivity(let value):
        try container.encode(value, forKey: .vpcPeeringConnectivity)
      case .staticIpConnectivity(let value):
        try container.encode(value, forKey: .staticIpConnectivity)
      }
    }
  }

  /// Dump flag definition.
  public struct DumpFlag: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// The name of the flag
    public var name: Swift.String = Swift.String()

    /// The value of the flag.
    public var value: Swift.String = Swift.String()

    /// Initialize a new instance of `DumpFlag`.
    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 = DumpFlag().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.clouddms.v1.MigrationJob.DumpFlag"
    }
    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)
    }
  }

  /// Dump flags definition.
  public struct DumpFlags: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// The flags for the initial dump.
    public var dumpFlags: [MigrationJob.DumpFlag] = []

    /// Initialize a new instance of `DumpFlags`.
    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 = DumpFlags().with { $0.dumpFlags = ... }
    /// ```
    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.clouddms.v1.MigrationJob.DumpFlags"
    }
    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)
    }
  }

  /// Performance configuration definition.
  public struct PerformanceConfig: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Initial dump parallelism level.
    public var dumpParallelLevel: MigrationJob.PerformanceConfig.DumpParallelLevel = MigrationJob
      .PerformanceConfig.DumpParallelLevel()

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

    /// Describes the parallelism level during initial dump.
    public enum DumpParallelLevel: Codable, Equatable, Sendable {
      /// Unknown dump parallel level. Will be defaulted to OPTIMAL.
      case unspecified
      /// Minimal parallel level.
      case min
      /// Optimal parallel level.
      case optimal
      /// Maximum parallel level.
      case max
      /// 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 .min: return 1
        case .optimal: return 2
        case .max: 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 "DUMP_PARALLEL_LEVEL_UNSPECIFIED"
        case .min: return "MIN"
        case .optimal: return "OPTIMAL"
        case .max: return "MAX"
        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:DumpParallelLevel/unknownStringValue(_:)).
      public init(stringValue: Swift.String) {
        switch stringValue {
        case "DUMP_PARALLEL_LEVEL_UNSPECIFIED": self = .unspecified
        case "MIN": self = .min
        case "OPTIMAL": self = .optimal
        case "MAX": self = .max
        default: self = .unknownStringValue(stringValue)
        }
      }

      /// Initialize from an integer value.
      ///
      /// If the value is unknown, this initializes to [`unknownIntValue`](doc:DumpParallelLevel/unknownIntValue(_:)).
      public init(intValue: Int) {
        switch intValue {
        case 0: self = .unspecified
        case 1: self = .min
        case 2: self = .optimal
        case 3: self = .max
        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 .min: return try container.encode(1)
        case .optimal: return try container.encode(2)
        case .max: 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.MigrationJob.PerformanceConfig"
    }
    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 migration job states.
  public enum State: Codable, Equatable, Sendable {
    /// The state of the migration job is unknown.
    case unspecified
    /// The migration job is down for maintenance.
    case maintenance
    /// The migration job is in draft mode and no resources are created.
    case draft
    /// The migration job is being created.
    case creating
    /// The migration job is created and not started.
    case notStarted
    /// The migration job is running.
    case running
    /// The migration job failed.
    case failed
    /// The migration job has been completed.
    case completed
    /// The migration job is being deleted.
    case deleting
    /// The migration job is being stopped.
    case stopping
    /// The migration job is currently stopped.
    case stopped
    /// The migration job has been deleted.
    case deleted
    /// The migration job is being updated.
    case updating
    /// The migration job is starting.
    case starting
    /// The migration job is restarting.
    case restarting
    /// The migration job is resuming.
    case resuming
    /// 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 .maintenance: return 1
      case .draft: return 2
      case .creating: return 3
      case .notStarted: return 4
      case .running: return 5
      case .failed: return 6
      case .completed: return 7
      case .deleting: return 8
      case .stopping: return 9
      case .stopped: return 10
      case .deleted: return 11
      case .updating: return 12
      case .starting: return 13
      case .restarting: return 14
      case .resuming: return 15
      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 .maintenance: return "MAINTENANCE"
      case .draft: return "DRAFT"
      case .creating: return "CREATING"
      case .notStarted: return "NOT_STARTED"
      case .running: return "RUNNING"
      case .failed: return "FAILED"
      case .completed: return "COMPLETED"
      case .deleting: return "DELETING"
      case .stopping: return "STOPPING"
      case .stopped: return "STOPPED"
      case .deleted: return "DELETED"
      case .updating: return "UPDATING"
      case .starting: return "STARTING"
      case .restarting: return "RESTARTING"
      case .resuming: return "RESUMING"
      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 "MAINTENANCE": self = .maintenance
      case "DRAFT": self = .draft
      case "CREATING": self = .creating
      case "NOT_STARTED": self = .notStarted
      case "RUNNING": self = .running
      case "FAILED": self = .failed
      case "COMPLETED": self = .completed
      case "DELETING": self = .deleting
      case "STOPPING": self = .stopping
      case "STOPPED": self = .stopped
      case "DELETED": self = .deleted
      case "UPDATING": self = .updating
      case "STARTING": self = .starting
      case "RESTARTING": self = .restarting
      case "RESUMING": self = .resuming
      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 = .maintenance
      case 2: self = .draft
      case 3: self = .creating
      case 4: self = .notStarted
      case 5: self = .running
      case 6: self = .failed
      case 7: self = .completed
      case 8: self = .deleting
      case 9: self = .stopping
      case 10: self = .stopped
      case 11: self = .deleted
      case 12: self = .updating
      case 13: self = .starting
      case 14: self = .restarting
      case 15: self = .resuming
      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 .maintenance: return try container.encode(1)
      case .draft: return try container.encode(2)
      case .creating: return try container.encode(3)
      case .notStarted: return try container.encode(4)
      case .running: return try container.encode(5)
      case .failed: return try container.encode(6)
      case .completed: return try container.encode(7)
      case .deleting: return try container.encode(8)
      case .stopping: return try container.encode(9)
      case .stopped: return try container.encode(10)
      case .deleted: return try container.encode(11)
      case .updating: return try container.encode(12)
      case .starting: return try container.encode(13)
      case .restarting: return try container.encode(14)
      case .resuming: return try container.encode(15)
      case .unknownIntValue(let v): return try container.encode(v)
      case .unknownStringValue(let v): return try container.encode(v)
      }
    }
  }

  /// The current migration job phase.
  public enum Phase: Codable, Equatable, Sendable {
    /// The phase of the migration job is unknown.
    case unspecified
    /// The migration job is in the full dump phase.
    case fullDump
    /// The migration job is CDC phase.
    case cdc
    /// The migration job is running the promote phase.
    case promoteInProgress
    /// Only RDS flow - waiting for source writes to stop
    case waitingForSourceWritesToStop
    /// Only RDS flow - the sources writes stopped, waiting for dump to begin
    case preparingTheDump
    /// 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 .fullDump: return 1
      case .cdc: return 2
      case .promoteInProgress: return 3
      case .waitingForSourceWritesToStop: return 4
      case .preparingTheDump: return 5
      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 "PHASE_UNSPECIFIED"
      case .fullDump: return "FULL_DUMP"
      case .cdc: return "CDC"
      case .promoteInProgress: return "PROMOTE_IN_PROGRESS"
      case .waitingForSourceWritesToStop: return "WAITING_FOR_SOURCE_WRITES_TO_STOP"
      case .preparingTheDump: return "PREPARING_THE_DUMP"
      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:Phase/unknownStringValue(_:)).
    public init(stringValue: Swift.String) {
      switch stringValue {
      case "PHASE_UNSPECIFIED": self = .unspecified
      case "FULL_DUMP": self = .fullDump
      case "CDC": self = .cdc
      case "PROMOTE_IN_PROGRESS": self = .promoteInProgress
      case "WAITING_FOR_SOURCE_WRITES_TO_STOP": self = .waitingForSourceWritesToStop
      case "PREPARING_THE_DUMP": self = .preparingTheDump
      default: self = .unknownStringValue(stringValue)
      }
    }

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

  /// The type of migration job (one-time or continuous).
  public enum Type_: Codable, Equatable, Sendable {
    /// The type of the migration job is unknown.
    case unspecified
    /// The migration job is a one time migration.
    case oneTime
    /// The migration job is a continuous migration.
    case continuous
    /// 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 .oneTime: return 1
      case .continuous: 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 "TYPE_UNSPECIFIED"
      case .oneTime: return "ONE_TIME"
      case .continuous: return "CONTINUOUS"
      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:Type_/unknownStringValue(_:)).
    public init(stringValue: Swift.String) {
      switch stringValue {
      case "TYPE_UNSPECIFIED": self = .unspecified
      case "ONE_TIME": self = .oneTime
      case "CONTINUOUS": self = .continuous
      default: self = .unknownStringValue(stringValue)
      }
    }

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

  /// The connectivity method.
  public enum OneOf_Connectivity: Codable, Equatable, Sendable {
    /// The details needed to communicate to the source over Reverse SSH
    /// tunnel connectivity.
    indirect case reverseSshConnectivity(ReverseSshConnectivity?)
    /// The details of the VPC network that the source database is located in.
    indirect case vpcPeeringConnectivity(VpcPeeringConnectivity?)
    /// static ip connectivity data (default, no additional details needed).
    indirect case staticIpConnectivity(StaticIpConnectivity?)
  }

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