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

#if PipelineService || ScheduleService
  import Foundation
  import GoogleCloudWkt
  import GoogleRpc

  /// The runtime detail of a task execution.
  public struct PipelineTaskDetail: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Output only. The system generated ID of the task.
    public var taskId: Swift.Int64 = Swift.Int64()

    /// Output only. The id of the parent task if the task is within a component
    /// scope. Empty if the task is at the root level.
    public var parentTaskId: Swift.Int64 = Swift.Int64()

    /// Output only. The user specified name of the task that is defined in
    /// [pipeline_spec][google.cloud.aiplatform.v1.PipelineJob.pipeline_spec].
    ///
    /// [google.cloud.aiplatform.v1.PipelineJob.pipeline_spec]: <doc:PipelineJob/pipelineSpec>
    public var taskName: Swift.String = Swift.String()

    /// Output only. Task create time.
    public var createTime: GoogleCloudWkt.Timestamp? = nil

    /// Output only. Task start time.
    public var startTime: GoogleCloudWkt.Timestamp? = nil

    /// Output only. Task end time.
    public var endTime: GoogleCloudWkt.Timestamp? = nil

    /// Output only. The detailed execution info.
    public var executorDetail: PipelineTaskExecutorDetail? = nil

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

    /// Output only. The execution metadata of the task.
    public var execution: Execution? = nil

    /// Output only. The error that occurred during task execution.
    /// Only populated when the task's state is FAILED or CANCELLED.
    public var error: GoogleRpc.Status? = nil

    /// Output only. A list of task status. This field keeps a record of task
    /// status evolving over time.
    public var pipelineTaskStatus: [PipelineTaskDetail.PipelineTaskStatus] = []

    /// Output only. The runtime input artifacts of the task.
    public var inputs: [Swift.String: PipelineTaskDetail.ArtifactList] = [:]

    /// Output only. The runtime output artifacts of the task.
    public var outputs: [Swift.String: PipelineTaskDetail.ArtifactList] = [:]

    /// Output only. The unique name of a task.
    /// This field is used by rerun pipeline job.
    /// Console UI and Vertex AI SDK will support triggering pipeline job reruns.
    /// The name is constructed by concatenating all the parent tasks name with
    /// the task name. For example, if a task named "child_task" has a parent task
    /// named "parent_task_1" and parent task 1 has a parent task named
    /// "parent_task_2", the task unique name will be
    /// "parent_task_2.parent_task_1.child_task".
    public var taskUniqueName: Swift.String = Swift.String()

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

    /// A single record of the task status.
    public struct PipelineTaskStatus: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Output only. Update time of this status.
      public var updateTime: GoogleCloudWkt.Timestamp? = nil

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

      /// Output only. The error that occurred during the state. May be set when
      /// the state is any of the non-final state (PENDING/RUNNING/CANCELLING) or
      /// FAILED state. If the state is FAILED, the error here is final and not
      /// going to be retried. If the state is a non-final state, the error
      /// indicates a system-error being retried.
      public var error: GoogleRpc.Status? = nil

      /// Initialize a new instance of `PipelineTaskStatus`.
      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 = PipelineTaskStatus().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.aiplatform.v1.PipelineTaskDetail.PipelineTaskStatus"
      }
      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)
      }
    }

    /// A list of artifact metadata.
    public struct ArtifactList: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Output only. A list of artifact metadata.
      public var artifacts: [Artifact] = []

      /// Initialize a new instance of `ArtifactList`.
      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 = ArtifactList().with { $0.artifacts = ... }
      /// ```
      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.aiplatform.v1.PipelineTaskDetail.ArtifactList"
      }
      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)
      }
    }

    /// Specifies state of TaskExecution
    public enum State: Codable, Equatable, Sendable {
      /// Unspecified.
      case unspecified
      /// Specifies pending state for the task.
      case pending
      /// Specifies task is being executed.
      case running
      /// Specifies task completed successfully.
      case succeeded
      /// Specifies Task cancel is in pending state.
      case cancelPending
      /// Specifies task is being cancelled.
      case cancelling
      /// Specifies task was cancelled.
      case cancelled
      /// Specifies task failed.
      case failed
      /// Specifies task was skipped due to cache hit.
      case skipped
      /// Specifies that the task was not triggered because the task's trigger
      /// policy is not satisfied. The trigger policy is specified in the
      /// `condition` field of
      /// [PipelineJob.pipeline_spec][google.cloud.aiplatform.v1.PipelineJob.pipeline_spec].
      ///
      /// [google.cloud.aiplatform.v1.PipelineJob.pipeline_spec]: <doc:PipelineJob/pipelineSpec>
      case notTriggered
      /// 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 .pending: return 1
        case .running: return 2
        case .succeeded: return 3
        case .cancelPending: return 4
        case .cancelling: return 5
        case .cancelled: return 6
        case .failed: return 7
        case .skipped: return 8
        case .notTriggered: return 9
        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 .pending: return "PENDING"
        case .running: return "RUNNING"
        case .succeeded: return "SUCCEEDED"
        case .cancelPending: return "CANCEL_PENDING"
        case .cancelling: return "CANCELLING"
        case .cancelled: return "CANCELLED"
        case .failed: return "FAILED"
        case .skipped: return "SKIPPED"
        case .notTriggered: return "NOT_TRIGGERED"
        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 "PENDING": self = .pending
        case "RUNNING": self = .running
        case "SUCCEEDED": self = .succeeded
        case "CANCEL_PENDING": self = .cancelPending
        case "CANCELLING": self = .cancelling
        case "CANCELLED": self = .cancelled
        case "FAILED": self = .failed
        case "SKIPPED": self = .skipped
        case "NOT_TRIGGERED": self = .notTriggered
        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 = .pending
        case 2: self = .running
        case 3: self = .succeeded
        case 4: self = .cancelPending
        case 5: self = .cancelling
        case 6: self = .cancelled
        case 7: self = .failed
        case 8: self = .skipped
        case 9: self = .notTriggered
        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 .pending: return try container.encode(1)
        case .running: return try container.encode(2)
        case .succeeded: return try container.encode(3)
        case .cancelPending: return try container.encode(4)
        case .cancelling: return try container.encode(5)
        case .cancelled: return try container.encode(6)
        case .failed: return try container.encode(7)
        case .skipped: return try container.encode(8)
        case .notTriggered: return try container.encode(9)
        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.aiplatform.v1.PipelineTaskDetail"
    }
    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)
    }
  }
#endif
