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

/// A request to start manual transfer runs.
public struct StartManualTransferRunsRequest: Codable, Equatable, GoogleCloudWkt._AnyPackable,
  Sendable
{
  /// Required. Transfer configuration name in the form:
  /// `projects/{project_id}/transferConfigs/{config_id}` or
  /// `projects/{project_id}/locations/{location_id}/transferConfigs/{config_id}`.
  public var parent: Swift.String = Swift.String()

  /// The requested time specification - this can be a time range or a specific
  /// run_time.
  public var time: OneOf_Time? = nil

  /// Initialize a new instance of `StartManualTransferRunsRequest`.
  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 = StartManualTransferRunsRequest().with { $0.parent = ... }
  /// ```
  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 parent = "parent"
    case requestedTimeRange = "requestedTimeRange"
    case requestedRunTime = "requestedRunTime"
  }

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

    var time: OneOf_Time? = nil
    let timeCheckAndSet = {
      if time != nil {
        throw DecodingError.dataCorrupted(
          DecodingError.Context(
            codingPath: decoder.codingPath, debugDescription: "Multiple values set for oneof 'time'"
          ))
      }
      time = $0
    }
    if let requestedTimeRange = try container.decodeIfPresent(
      StartManualTransferRunsRequest.TimeRange?.self, forKey: .requestedTimeRange)
    {
      try timeCheckAndSet(.requestedTimeRange(requestedTimeRange))
    }
    if let requestedRunTime = try container.decodeIfPresent(
      GoogleCloudWkt.Timestamp?.self, forKey: .requestedRunTime)
    {
      try timeCheckAndSet(.requestedRunTime(requestedRunTime))
    }
    self.time = time
  }

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

    if let choice = self.time {
      switch choice {
      case .requestedTimeRange(let value):
        try container.encode(value, forKey: .requestedTimeRange)
      case .requestedRunTime(let value):
        try container.encode(value, forKey: .requestedRunTime)
      }
    }
  }

  /// A specification for a time range, this will request transfer runs with
  /// run_time between start_time (inclusive) and end_time (exclusive).
  public struct TimeRange: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Start time of the range of transfer runs. For example,
    /// `"2017-05-25T00:00:00+00:00"`. The start_time must be strictly less than
    /// the end_time. Creates transfer runs where run_time is in the range
    /// between start_time (inclusive) and end_time (exclusive).
    public var startTime: GoogleCloudWkt.Timestamp? = nil

    /// End time of the range of transfer runs. For example,
    /// `"2017-05-30T00:00:00+00:00"`. The end_time must not be in the future.
    /// Creates transfer runs where run_time is in the range between start_time
    /// (inclusive) and end_time (exclusive).
    public var endTime: GoogleCloudWkt.Timestamp? = nil

    /// Initialize a new instance of `TimeRange`.
    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 = TimeRange().with { $0.startTime = ... }
    /// ```
    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.bigquery.datatransfer.v1.StartManualTransferRunsRequest.TimeRange"
    }
    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 requested time specification - this can be a time range or a specific
  /// run_time.
  public enum OneOf_Time: Codable, Equatable, Sendable {
    /// A time_range start and end timestamp for historical data files or reports
    /// that are scheduled to be transferred by the scheduled transfer run.
    /// requested_time_range must be a past time and cannot include future time
    /// values.
    indirect case requestedTimeRange(StartManualTransferRunsRequest.TimeRange?)
    /// A run_time timestamp for historical data files or reports
    /// that are scheduled to be transferred by the scheduled transfer run.
    /// requested_run_time must be a past time and cannot include future time
    /// values.
    indirect case requestedRunTime(GoogleCloudWkt.Timestamp?)
  }

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