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

/// Export data from Managed Lustre to a Cloud Storage bucket.
public struct ExportDataRequest: Codable, Equatable, GoogleCloudWkt._AnyPackable,
  Sendable
{
  /// Required. The name of the Managed Lustre instance in the format
  /// `projects/{project}/locations/{location}/instances/{instance}`.
  public var name: Swift.String = Swift.String()

  /// Optional. UUID to identify requests.
  public var requestId: Swift.String = Swift.String()

  /// Optional. User-specified service account used to perform the transfer.
  /// If unspecified, the Managed Lustre service agent is used.
  public var serviceAccount: Swift.String = Swift.String()

  /// The source of the data transfer.
  public var source: OneOf_Source? = nil

  /// The destination of the data transfer.
  public var destination: OneOf_Destination? = nil

  /// Initialize a new instance of `ExportDataRequest`.
  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 = ExportDataRequest().with { $0.lustrePath = ... }
  /// ```
  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 lustrePath = "lustrePath"
    case gcsPath = "gcsPath"
    case name = "name"
    case requestId = "requestId"
    case serviceAccount = "serviceAccount"
  }

  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.requestId = try container.decode(Swift.String.self, forKey: .requestId)
    self.serviceAccount = try container.decode(Swift.String.self, forKey: .serviceAccount)

    var source: OneOf_Source? = nil
    let sourceCheckAndSet = {
      if source != nil {
        throw DecodingError.dataCorrupted(
          DecodingError.Context(
            codingPath: decoder.codingPath,
            debugDescription: "Multiple values set for oneof 'source'"))
      }
      source = $0
    }
    if let lustrePath = try container.decodeIfPresent(LustrePath?.self, forKey: .lustrePath) {
      try sourceCheckAndSet(.lustrePath(lustrePath))
    }
    self.source = source

    var destination: OneOf_Destination? = nil
    let destinationCheckAndSet = {
      if destination != nil {
        throw DecodingError.dataCorrupted(
          DecodingError.Context(
            codingPath: decoder.codingPath,
            debugDescription: "Multiple values set for oneof 'destination'"))
      }
      destination = $0
    }
    if let gcsPath = try container.decodeIfPresent(GcsPath?.self, forKey: .gcsPath) {
      try destinationCheckAndSet(.gcsPath(gcsPath))
    }
    self.destination = destination
  }

  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.requestId, forKey: .requestId)
    try container.encode(self.serviceAccount, forKey: .serviceAccount)

    if let choice = self.source {
      switch choice {
      case .lustrePath(let value):
        try container.encode(value, forKey: .lustrePath)
      }
    }

    if let choice = self.destination {
      switch choice {
      case .gcsPath(let value):
        try container.encode(value, forKey: .gcsPath)
      }
    }
  }

  /// The source of the data transfer.
  public enum OneOf_Source: Codable, Equatable, Sendable {
    /// The root directory path to the Managed Lustre file system. Must start
    /// with `/`. Default is `/`.
    indirect case lustrePath(LustrePath?)
  }

  /// The destination of the data transfer.
  public enum OneOf_Destination: Codable, Equatable, Sendable {
    /// The URI to a Cloud Storage bucket, or a path within a bucket, using
    /// the format `gs://<bucket_name>/<optional_path_inside_bucket>/`. If a
    /// path inside the bucket is specified, it must end with a forward slash
    /// (`/`).
    indirect case gcsPath(GcsPath?)
  }

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