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

/// Request message for 'GenerateSshScript' request.
public struct GenerateSshScriptRequest: Codable, Equatable, GoogleCloudWkt._AnyPackable,
  Sendable
{
  /// Name of the migration job resource to generate the SSH script.
  public var migrationJob: Swift.String = Swift.String()

  /// Required. Bastion VM Instance name to use or to create.
  public var vm: Swift.String = Swift.String()

  /// The port that will be open on the bastion host.
  public var vmPort: Swift.Int32 = Swift.Int32()

  /// The VM configuration
  public var vmConfig: OneOf_VmConfig? = nil

  /// Initialize a new instance of `GenerateSshScriptRequest`.
  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 = GenerateSshScriptRequest().with { $0.migrationJob = ... }
  /// ```
  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 migrationJob = "migrationJob"
    case vm = "vm"
    case vmCreationConfig = "vmCreationConfig"
    case vmSelectionConfig = "vmSelectionConfig"
    case vmPort = "vmPort"
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
    self.migrationJob = try container.decode(Swift.String.self, forKey: .migrationJob)
    self.vm = try container.decode(Swift.String.self, forKey: .vm)
    self.vmPort = try container.decode(Swift.Int32.self, forKey: .vmPort)

    var vmConfig: OneOf_VmConfig? = nil
    let vmConfigCheckAndSet = {
      if vmConfig != nil {
        throw DecodingError.dataCorrupted(
          DecodingError.Context(
            codingPath: decoder.codingPath,
            debugDescription: "Multiple values set for oneof 'vmConfig'"))
      }
      vmConfig = $0
    }
    if let vmCreationConfig = try container.decodeIfPresent(
      VmCreationConfig?.self, forKey: .vmCreationConfig)
    {
      try vmConfigCheckAndSet(.vmCreationConfig(vmCreationConfig))
    }
    if let vmSelectionConfig = try container.decodeIfPresent(
      VmSelectionConfig?.self, forKey: .vmSelectionConfig)
    {
      try vmConfigCheckAndSet(.vmSelectionConfig(vmSelectionConfig))
    }
    self.vmConfig = vmConfig
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    try container.encode(self.migrationJob, forKey: .migrationJob)
    try container.encode(self.vm, forKey: .vm)
    try container.encode(self.vmPort, forKey: .vmPort)

    if let choice = self.vmConfig {
      switch choice {
      case .vmCreationConfig(let value):
        try container.encode(value, forKey: .vmCreationConfig)
      case .vmSelectionConfig(let value):
        try container.encode(value, forKey: .vmSelectionConfig)
      }
    }
  }

  /// The VM configuration
  public enum OneOf_VmConfig: Codable, Equatable, Sendable {
    /// The VM creation configuration
    indirect case vmCreationConfig(VmCreationConfig?)
    /// The VM selection configuration
    indirect case vmSelectionConfig(VmSelectionConfig?)
  }

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