// 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 task represents a user-visible job.
public struct Task: Codable, Equatable, GoogleCloudWkt._AnyPackable,
  Sendable
{
  /// Output only. The relative resource name of the task, of the form:
  /// projects/{project_number}/locations/{location_id}/lakes/{lake_id}/
  /// tasks/{task_id}.
  public var name: Swift.String = Swift.String()

  /// Output only. System generated globally unique ID for the task. This ID will
  /// be different if the task is deleted and re-created with the same name.
  public var uid: Swift.String = Swift.String()

  /// Output only. The time when the task was created.
  public var createTime: GoogleCloudWkt.Timestamp? = nil

  /// Output only. The time when the task was last updated.
  public var updateTime: GoogleCloudWkt.Timestamp? = nil

  /// Optional. Description of the task.
  public var description: Swift.String = Swift.String()

  /// Optional. User friendly display name.
  public var displayName: Swift.String = Swift.String()

  /// Output only. Current state of the task.
  public var state: State = State()

  /// Optional. User-defined labels for the task.
  public var labels: [Swift.String: Swift.String] = [:]

  /// Required. Spec related to how often and when a task should be triggered.
  public var triggerSpec: Task.TriggerSpec? = nil

  /// Required. Spec related to how a task is executed.
  public var executionSpec: Task.ExecutionSpec? = nil

  /// Output only. Status of the latest task executions.
  public var executionStatus: Task.ExecutionStatus? = nil

  /// Task template specific user-specified config.
  public var config: OneOf_Config? = nil

  /// Initialize a new instance of `Task`.
  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 = Task().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 uid = "uid"
    case createTime = "createTime"
    case updateTime = "updateTime"
    case description = "description"
    case displayName = "displayName"
    case state = "state"
    case labels = "labels"
    case triggerSpec = "triggerSpec"
    case executionSpec = "executionSpec"
    case executionStatus = "executionStatus"
    case spark = "spark"
    case notebook = "notebook"
  }

  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.uid = try container.decode(Swift.String.self, forKey: .uid)
    self.createTime = try container.decodeIfPresent(
      GoogleCloudWkt.Timestamp.self, forKey: .createTime)
    self.updateTime = try container.decodeIfPresent(
      GoogleCloudWkt.Timestamp.self, forKey: .updateTime)
    self.description = try container.decode(Swift.String.self, forKey: .description)
    self.displayName = try container.decode(Swift.String.self, forKey: .displayName)
    self.state = try container.decode(State.self, forKey: .state)
    self.labels = try container.decode([Swift.String: Swift.String].self, forKey: .labels)
    self.triggerSpec = try container.decodeIfPresent(Task.TriggerSpec.self, forKey: .triggerSpec)
    self.executionSpec = try container.decodeIfPresent(
      Task.ExecutionSpec.self, forKey: .executionSpec)
    self.executionStatus = try container.decodeIfPresent(
      Task.ExecutionStatus.self, forKey: .executionStatus)

    var config: OneOf_Config? = nil
    let configCheckAndSet = {
      if config != nil {
        throw DecodingError.dataCorrupted(
          DecodingError.Context(
            codingPath: decoder.codingPath,
            debugDescription: "Multiple values set for oneof 'config'"))
      }
      config = $0
    }
    if let spark = try container.decodeIfPresent(Task.SparkTaskConfig?.self, forKey: .spark) {
      try configCheckAndSet(.spark(spark))
    }
    if let notebook = try container.decodeIfPresent(
      Task.NotebookTaskConfig?.self, forKey: .notebook)
    {
      try configCheckAndSet(.notebook(notebook))
    }
    self.config = config
  }

  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.uid, forKey: .uid)
    try container.encode(self.createTime, forKey: .createTime)
    try container.encode(self.updateTime, forKey: .updateTime)
    try container.encode(self.description, forKey: .description)
    try container.encode(self.displayName, forKey: .displayName)
    try container.encode(self.state, forKey: .state)
    try container.encode(self.labels, forKey: .labels)
    try container.encode(self.triggerSpec, forKey: .triggerSpec)
    try container.encode(self.executionSpec, forKey: .executionSpec)
    try container.encode(self.executionStatus, forKey: .executionStatus)

    if let choice = self.config {
      switch choice {
      case .spark(let value):
        try container.encode(value, forKey: .spark)
      case .notebook(let value):
        try container.encode(value, forKey: .notebook)
      }
    }
  }

  /// Configuration for the underlying infrastructure used to run workloads.
  public struct InfrastructureSpec: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Hardware config.
    public var resources: OneOf_Resources? = nil

    /// Software config.
    public var runtime: OneOf_Runtime? = nil

    /// Networking config.
    public var network: OneOf_Network? = nil

    /// Initialize a new instance of `InfrastructureSpec`.
    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 = InfrastructureSpec().with { $0.batch = ... }
    /// ```
    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 batch = "batch"
      case containerImage = "containerImage"
      case vpcNetwork = "vpcNetwork"
    }

    public init(from decoder: Decoder) throws {
      let container = try decoder.container(keyedBy: CodingKeys.self)

      var resources: OneOf_Resources? = nil
      let resourcesCheckAndSet = {
        if resources != nil {
          throw DecodingError.dataCorrupted(
            DecodingError.Context(
              codingPath: decoder.codingPath,
              debugDescription: "Multiple values set for oneof 'resources'"))
        }
        resources = $0
      }
      if let batch = try container.decodeIfPresent(
        Task.InfrastructureSpec.BatchComputeResources?.self, forKey: .batch)
      {
        try resourcesCheckAndSet(.batch(batch))
      }
      self.resources = resources

      var runtime: OneOf_Runtime? = nil
      let runtimeCheckAndSet = {
        if runtime != nil {
          throw DecodingError.dataCorrupted(
            DecodingError.Context(
              codingPath: decoder.codingPath,
              debugDescription: "Multiple values set for oneof 'runtime'"))
        }
        runtime = $0
      }
      if let containerImage = try container.decodeIfPresent(
        Task.InfrastructureSpec.ContainerImageRuntime?.self, forKey: .containerImage)
      {
        try runtimeCheckAndSet(.containerImage(containerImage))
      }
      self.runtime = runtime

      var network: OneOf_Network? = nil
      let networkCheckAndSet = {
        if network != nil {
          throw DecodingError.dataCorrupted(
            DecodingError.Context(
              codingPath: decoder.codingPath,
              debugDescription: "Multiple values set for oneof 'network'"))
        }
        network = $0
      }
      if let vpcNetwork = try container.decodeIfPresent(
        Task.InfrastructureSpec.VpcNetwork?.self, forKey: .vpcNetwork)
      {
        try networkCheckAndSet(.vpcNetwork(vpcNetwork))
      }
      self.network = network
    }

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

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

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

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

    /// Batch compute resources associated with the task.
    public struct BatchComputeResources: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Optional. Total number of job executors.
      /// Executor Count should be between 2 and 100. [Default=2]
      public var executorsCount: Swift.Int32 = Swift.Int32()

      /// Optional. Max configurable executors.
      /// If max_executors_count > executors_count, then auto-scaling is enabled.
      /// Max Executor Count should be between 2 and 1000. [Default=1000]
      public var maxExecutorsCount: Swift.Int32 = Swift.Int32()

      /// Initialize a new instance of `BatchComputeResources`.
      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 = BatchComputeResources().with { $0.executorsCount = ... }
      /// ```
      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.dataplex.v1.Task.InfrastructureSpec.BatchComputeResources"
      }
      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)
      }
    }

    /// Container Image Runtime Configuration used with Batch execution.
    public struct ContainerImageRuntime: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Optional. Container image to use.
      public var image: Swift.String = Swift.String()

      /// Optional. A list of Java JARS to add to the classpath.
      /// Valid input includes Cloud Storage URIs to Jar binaries.
      /// For example, gs://bucket-name/my/path/to/file.jar
      public var javaJars: [Swift.String] = []

      /// Optional. A list of python packages to be installed.
      /// Valid formats include Cloud Storage URI to a PIP installable library.
      /// For example, gs://bucket-name/my/path/to/lib.tar.gz
      public var pythonPackages: [Swift.String] = []

      /// Optional. Override to common configuration of open source components
      /// installed on the Dataproc cluster. The properties to set on daemon
      /// config files. Property keys are specified in `prefix:property` format,
      /// for example `core:hadoop.tmp.dir`. For more information, see [Cluster
      /// properties](https://cloud.google.com/dataproc/docs/concepts/cluster-properties).
      public var properties: [Swift.String: Swift.String] = [:]

      /// Initialize a new instance of `ContainerImageRuntime`.
      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 = ContainerImageRuntime().with { $0.image = ... }
      /// ```
      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.dataplex.v1.Task.InfrastructureSpec.ContainerImageRuntime"
      }
      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)
      }
    }

    /// Cloud VPC Network used to run the infrastructure.
    public struct VpcNetwork: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Optional. List of network tags to apply to the job.
      public var networkTags: [Swift.String] = []

      /// The Cloud VPC network identifier.
      public var networkName: OneOf_NetworkName? = nil

      /// Initialize a new instance of `VpcNetwork`.
      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 = VpcNetwork().with { $0.network = ... }
      /// ```
      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 network = "network"
        case subNetwork = "subNetwork"
        case networkTags = "networkTags"
      }

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

        var networkName: OneOf_NetworkName? = nil
        let networkNameCheckAndSet = {
          if networkName != nil {
            throw DecodingError.dataCorrupted(
              DecodingError.Context(
                codingPath: decoder.codingPath,
                debugDescription: "Multiple values set for oneof 'networkName'"))
          }
          networkName = $0
        }
        if let network = try container.decodeIfPresent(Swift.String.self, forKey: .network) {
          try networkNameCheckAndSet(.network(network))
        }
        if let subNetwork = try container.decodeIfPresent(Swift.String.self, forKey: .subNetwork) {
          try networkNameCheckAndSet(.subNetwork(subNetwork))
        }
        self.networkName = networkName
      }

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

        if let choice = self.networkName {
          switch choice {
          case .network(let value):
            try container.encode(value, forKey: .network)
          case .subNetwork(let value):
            try container.encode(value, forKey: .subNetwork)
          }
        }
      }

      /// The Cloud VPC network identifier.
      public enum OneOf_NetworkName: Codable, Equatable, Sendable {
        /// Optional. The Cloud VPC network in which the job is run. By default,
        /// the Cloud VPC network named Default within the project is used.
        case network(Swift.String)
        /// Optional. The Cloud VPC sub-network in which the job is run.
        case subNetwork(Swift.String)
      }

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

    /// Hardware config.
    public enum OneOf_Resources: Codable, Equatable, Sendable {
      /// Compute resources needed for a Task when using Dataproc Serverless.
      indirect case batch(Task.InfrastructureSpec.BatchComputeResources?)
    }

    /// Software config.
    public enum OneOf_Runtime: Codable, Equatable, Sendable {
      /// Container Image Runtime Configuration.
      indirect case containerImage(Task.InfrastructureSpec.ContainerImageRuntime?)
    }

    /// Networking config.
    public enum OneOf_Network: Codable, Equatable, Sendable {
      /// Vpc network.
      indirect case vpcNetwork(Task.InfrastructureSpec.VpcNetwork?)
    }

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

  /// Task scheduling and trigger settings.
  public struct TriggerSpec: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Required. Immutable. Trigger type of the user-specified Task.
    public var type: Task.TriggerSpec.Type_ = Task.TriggerSpec.Type_()

    /// Optional. The first run of the task will be after this time.
    /// If not specified, the task will run shortly after being submitted if
    /// ON_DEMAND and based on the schedule if RECURRING.
    public var startTime: GoogleCloudWkt.Timestamp? = nil

    /// Optional. Prevent the task from executing.
    /// This does not cancel already running tasks. It is intended to temporarily
    /// disable RECURRING tasks.
    public var disabled: Swift.Bool = Swift.Bool()

    /// Optional. Number of retry attempts before aborting.
    /// Set to zero to never attempt to retry a failed task.
    public var maxRetries: Swift.Int32 = Swift.Int32()

    /// Trigger only applies for RECURRING tasks.
    public var trigger: OneOf_Trigger? = nil

    /// Initialize a new instance of `TriggerSpec`.
    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 = TriggerSpec().with { $0.type = ... }
    /// ```
    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 type = "type"
      case startTime = "startTime"
      case disabled = "disabled"
      case maxRetries = "maxRetries"
      case schedule = "schedule"
    }

    public init(from decoder: Decoder) throws {
      let container = try decoder.container(keyedBy: CodingKeys.self)
      self.type = try container.decode(Task.TriggerSpec.Type_.self, forKey: .type)
      self.startTime = try container.decodeIfPresent(
        GoogleCloudWkt.Timestamp.self, forKey: .startTime)
      self.disabled = try container.decode(Swift.Bool.self, forKey: .disabled)
      self.maxRetries = try container.decode(Swift.Int32.self, forKey: .maxRetries)

      var trigger: OneOf_Trigger? = nil
      let triggerCheckAndSet = {
        if trigger != nil {
          throw DecodingError.dataCorrupted(
            DecodingError.Context(
              codingPath: decoder.codingPath,
              debugDescription: "Multiple values set for oneof 'trigger'"))
        }
        trigger = $0
      }
      if let schedule = try container.decodeIfPresent(Swift.String.self, forKey: .schedule) {
        try triggerCheckAndSet(.schedule(schedule))
      }
      self.trigger = trigger
    }

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

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

    /// Determines how often and when the job will run.
    public enum Type_: Codable, Equatable, Sendable {
      /// Unspecified trigger type.
      case unspecified
      /// The task runs one-time shortly after Task Creation.
      case onDemand
      /// The task is scheduled to run periodically.
      case recurring
      /// 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 .onDemand: return 1
        case .recurring: 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 .onDemand: return "ON_DEMAND"
        case .recurring: return "RECURRING"
        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 "ON_DEMAND": self = .onDemand
        case "RECURRING": self = .recurring
        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 = .onDemand
        case 2: self = .recurring
        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 .onDemand: return try container.encode(1)
        case .recurring: return try container.encode(2)
        case .unknownIntValue(let v): return try container.encode(v)
        case .unknownStringValue(let v): return try container.encode(v)
        }
      }
    }

    /// Trigger only applies for RECURRING tasks.
    public enum OneOf_Trigger: Codable, Equatable, Sendable {
      /// Optional. Cron schedule (https://en.wikipedia.org/wiki/Cron) for
      /// running tasks periodically. To explicitly set a timezone to the cron
      /// tab, apply a prefix in the cron tab: "CRON_TZ=${IANA_TIME_ZONE}" or
      /// "TZ=${IANA_TIME_ZONE}". The ${IANA_TIME_ZONE} may only be a valid
      /// string from IANA time zone database. For example,
      /// `CRON_TZ=America/New_York 1 * * * *`, or `TZ=America/New_York 1 * * *
      /// *`. This field is required for RECURRING tasks.
      case schedule(Swift.String)
    }

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

  /// Execution related settings, like retry and service_account.
  public struct ExecutionSpec: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Optional. The arguments to pass to the task.
    /// The args can use placeholders of the format ${placeholder} as
    /// part of key/value string. These will be interpolated before passing the
    /// args to the driver. Currently supported placeholders:
    /// - ${task_id}
    /// - ${job_time}
    /// To pass positional args, set the key as TASK_ARGS. The value should be a
    /// comma-separated string of all the positional arguments. To use a
    /// delimiter other than comma, refer to
    /// https://cloud.google.com/sdk/gcloud/reference/topic/escaping. In case of
    /// other keys being present in the args, then TASK_ARGS will be passed as
    /// the last argument.
    public var args: [Swift.String: Swift.String] = [:]

    /// Required. Service account to use to execute a task.
    /// If not provided, the default Compute service account for the project is
    /// used.
    public var serviceAccount: Swift.String = Swift.String()

    /// Optional. The project in which jobs are run. By default, the project
    /// containing the Lake is used. If a project is provided, the
    /// [ExecutionSpec.service_account][google.cloud.dataplex.v1.Task.ExecutionSpec.service_account]
    /// must belong to this project.
    ///
    /// [google.cloud.dataplex.v1.Task.ExecutionSpec.service_account]: <doc:Task/ExecutionSpec/serviceAccount>
    public var project: Swift.String = Swift.String()

    /// Optional. The maximum duration after which the job execution is expired.
    public var maxJobExecutionLifetime: GoogleCloudWkt.Duration? = nil

    /// Optional. The Cloud KMS key to use for encryption, of the form:
    /// `projects/{project_number}/locations/{location_id}/keyRings/{key-ring-name}/cryptoKeys/{key-name}`.
    public var kmsKey: Swift.String = Swift.String()

    /// Initialize a new instance of `ExecutionSpec`.
    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 = ExecutionSpec().with { $0.args = ... }
    /// ```
    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.dataplex.v1.Task.ExecutionSpec"
    }
    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)
    }
  }

  /// User-specified config for running a Spark task.
  public struct SparkTaskConfig: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Optional. Cloud Storage URIs of files to be placed in the working
    /// directory of each executor.
    public var fileUris: [Swift.String] = []

    /// Optional. Cloud Storage URIs of archives to be extracted into the working
    /// directory of each executor. Supported file types: .jar, .tar, .tar.gz,
    /// .tgz, and .zip.
    public var archiveUris: [Swift.String] = []

    /// Optional. Infrastructure specification for the execution.
    public var infrastructureSpec: Task.InfrastructureSpec? = nil

    /// Required. The specification of the main method to call to drive the
    /// job. Specify either the jar file that contains the main class or the
    /// main class name.
    public var driver: OneOf_Driver? = nil

    /// Initialize a new instance of `SparkTaskConfig`.
    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 = SparkTaskConfig().with { $0.mainJarFileUri = ... }
    /// ```
    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 mainJarFileUri = "mainJarFileUri"
      case mainClass = "mainClass"
      case pythonScriptFile = "pythonScriptFile"
      case sqlScriptFile = "sqlScriptFile"
      case sqlScript = "sqlScript"
      case fileUris = "fileUris"
      case archiveUris = "archiveUris"
      case infrastructureSpec = "infrastructureSpec"
    }

    public init(from decoder: Decoder) throws {
      let container = try decoder.container(keyedBy: CodingKeys.self)
      self.fileUris = try container.decode([Swift.String].self, forKey: .fileUris)
      self.archiveUris = try container.decode([Swift.String].self, forKey: .archiveUris)
      self.infrastructureSpec = try container.decodeIfPresent(
        Task.InfrastructureSpec.self, forKey: .infrastructureSpec)

      var driver: OneOf_Driver? = nil
      let driverCheckAndSet = {
        if driver != nil {
          throw DecodingError.dataCorrupted(
            DecodingError.Context(
              codingPath: decoder.codingPath,
              debugDescription: "Multiple values set for oneof 'driver'"))
        }
        driver = $0
      }
      if let mainJarFileUri = try container.decodeIfPresent(
        Swift.String.self, forKey: .mainJarFileUri)
      {
        try driverCheckAndSet(.mainJarFileUri(mainJarFileUri))
      }
      if let mainClass = try container.decodeIfPresent(Swift.String.self, forKey: .mainClass) {
        try driverCheckAndSet(.mainClass(mainClass))
      }
      if let pythonScriptFile = try container.decodeIfPresent(
        Swift.String.self, forKey: .pythonScriptFile)
      {
        try driverCheckAndSet(.pythonScriptFile(pythonScriptFile))
      }
      if let sqlScriptFile = try container.decodeIfPresent(
        Swift.String.self, forKey: .sqlScriptFile)
      {
        try driverCheckAndSet(.sqlScriptFile(sqlScriptFile))
      }
      if let sqlScript = try container.decodeIfPresent(Swift.String.self, forKey: .sqlScript) {
        try driverCheckAndSet(.sqlScript(sqlScript))
      }
      self.driver = driver
    }

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

      if let choice = self.driver {
        switch choice {
        case .mainJarFileUri(let value):
          try container.encode(value, forKey: .mainJarFileUri)
        case .mainClass(let value):
          try container.encode(value, forKey: .mainClass)
        case .pythonScriptFile(let value):
          try container.encode(value, forKey: .pythonScriptFile)
        case .sqlScriptFile(let value):
          try container.encode(value, forKey: .sqlScriptFile)
        case .sqlScript(let value):
          try container.encode(value, forKey: .sqlScript)
        }
      }
    }

    /// Required. The specification of the main method to call to drive the
    /// job. Specify either the jar file that contains the main class or the
    /// main class name.
    public enum OneOf_Driver: Codable, Equatable, Sendable {
      /// The Cloud Storage URI of the jar file that contains the main class.
      /// The execution args are passed in as a sequence of named process
      /// arguments (`--key=value`).
      case mainJarFileUri(Swift.String)
      /// The name of the driver's main class. The jar file that contains the
      /// class must be in the default CLASSPATH or specified in
      /// `jar_file_uris`.
      /// The execution args are passed in as a sequence of named process
      /// arguments (`--key=value`).
      case mainClass(Swift.String)
      /// The Gcloud Storage URI of the main Python file to use as the driver.
      /// Must be a .py file. The execution args are passed in as a sequence of
      /// named process arguments (`--key=value`).
      case pythonScriptFile(Swift.String)
      /// A reference to a query file. This should be the Cloud Storage URI of
      /// the query file. The execution args are used to declare a set of script
      /// variables (`set key="value";`).
      case sqlScriptFile(Swift.String)
      /// The query text.
      /// The execution args are used to declare a set of script variables
      /// (`set key="value";`).
      case sqlScript(Swift.String)
    }

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

  /// Config for running scheduled notebooks.
  public struct NotebookTaskConfig: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Required. Path to input notebook. This can be the Cloud Storage URI of
    /// the notebook file or the path to a Notebook Content. The execution args
    /// are accessible as environment variables
    /// (`TASK_key=value`).
    public var notebook: Swift.String = Swift.String()

    /// Optional. Infrastructure specification for the execution.
    public var infrastructureSpec: Task.InfrastructureSpec? = nil

    /// Optional. Cloud Storage URIs of files to be placed in the working
    /// directory of each executor.
    public var fileUris: [Swift.String] = []

    /// Optional. Cloud Storage URIs of archives to be extracted into the working
    /// directory of each executor. Supported file types: .jar, .tar, .tar.gz,
    /// .tgz, and .zip.
    public var archiveUris: [Swift.String] = []

    /// Initialize a new instance of `NotebookTaskConfig`.
    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 = NotebookTaskConfig().with { $0.notebook = ... }
    /// ```
    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.dataplex.v1.Task.NotebookTaskConfig"
    }
    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)
    }
  }

  /// Status of the task execution (e.g. Jobs).
  public struct ExecutionStatus: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Output only. Last update time of the status.
    public var updateTime: GoogleCloudWkt.Timestamp? = nil

    /// Output only. latest job execution
    public var latestJob: Job? = nil

    /// Initialize a new instance of `ExecutionStatus`.
    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 = ExecutionStatus().with { $0.updateTime = ... }
    /// ```
    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.dataplex.v1.Task.ExecutionStatus"
    }
    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)
    }
  }

  /// Task template specific user-specified config.
  public enum OneOf_Config: Codable, Equatable, Sendable {
    /// Config related to running custom Spark tasks.
    indirect case spark(Task.SparkTaskConfig?)
    /// Config related to running scheduled Notebooks.
    indirect case notebook(Task.NotebookTaskConfig?)
  }

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