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

  /// The runtime detail of a pipeline executor.
  public struct PipelineTaskExecutorDetail: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    public var details: OneOf_Details? = nil

    /// Initialize a new instance of `PipelineTaskExecutorDetail`.
    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 = PipelineTaskExecutorDetail().with { $0.containerDetail = ... }
    /// ```
    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 containerDetail = "containerDetail"
      case customJobDetail = "customJobDetail"
    }

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

      var details: OneOf_Details? = nil
      let detailsCheckAndSet = {
        if details != nil {
          throw DecodingError.dataCorrupted(
            DecodingError.Context(
              codingPath: decoder.codingPath,
              debugDescription: "Multiple values set for oneof 'details'"))
        }
        details = $0
      }
      if let containerDetail = try container.decodeIfPresent(
        PipelineTaskExecutorDetail.ContainerDetail?.self, forKey: .containerDetail)
      {
        try detailsCheckAndSet(.containerDetail(containerDetail))
      }
      if let customJobDetail = try container.decodeIfPresent(
        PipelineTaskExecutorDetail.CustomJobDetail?.self, forKey: .customJobDetail)
      {
        try detailsCheckAndSet(.customJobDetail(customJobDetail))
      }
      self.details = details
    }

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

      if let choice = self.details {
        switch choice {
        case .containerDetail(let value):
          try container.encode(value, forKey: .containerDetail)
        case .customJobDetail(let value):
          try container.encode(value, forKey: .customJobDetail)
        }
      }
    }

    /// The detail of a container execution. It contains the job names of the
    /// lifecycle of a container execution.
    public struct ContainerDetail: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Output only. The name of the
      /// [CustomJob][google.cloud.aiplatform.v1.CustomJob] for the main container
      /// execution.
      ///
      /// [google.cloud.aiplatform.v1.CustomJob]: <doc:CustomJob>
      public var mainJob: Swift.String = Swift.String()

      /// Output only. The name of the
      /// [CustomJob][google.cloud.aiplatform.v1.CustomJob] for the
      /// pre-caching-check container execution. This job will be available if the
      /// [PipelineJob.pipeline_spec][google.cloud.aiplatform.v1.PipelineJob.pipeline_spec]
      /// specifies the `pre_caching_check` hook in the lifecycle events.
      ///
      /// [google.cloud.aiplatform.v1.CustomJob]: <doc:CustomJob>
      /// [google.cloud.aiplatform.v1.PipelineJob.pipeline_spec]: <doc:PipelineJob/pipelineSpec>
      public var preCachingCheckJob: Swift.String = Swift.String()

      /// Output only. The names of the previously failed
      /// [CustomJob][google.cloud.aiplatform.v1.CustomJob] for the main container
      /// executions. The list includes the all attempts in chronological order.
      ///
      /// [google.cloud.aiplatform.v1.CustomJob]: <doc:CustomJob>
      public var failedMainJobs: [Swift.String] = []

      /// Output only. The names of the previously failed
      /// [CustomJob][google.cloud.aiplatform.v1.CustomJob] for the
      /// pre-caching-check container executions. This job will be available if the
      /// [PipelineJob.pipeline_spec][google.cloud.aiplatform.v1.PipelineJob.pipeline_spec]
      /// specifies the `pre_caching_check` hook in the lifecycle events. The list
      /// includes the all attempts in chronological order.
      ///
      /// [google.cloud.aiplatform.v1.CustomJob]: <doc:CustomJob>
      /// [google.cloud.aiplatform.v1.PipelineJob.pipeline_spec]: <doc:PipelineJob/pipelineSpec>
      public var failedPreCachingCheckJobs: [Swift.String] = []

      /// Initialize a new instance of `ContainerDetail`.
      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 = ContainerDetail().with { $0.mainJob = ... }
      /// ```
      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.PipelineTaskExecutorDetail.ContainerDetail"
      }
      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 detailed info for a custom job executor.
    public struct CustomJobDetail: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Output only. The name of the
      /// [CustomJob][google.cloud.aiplatform.v1.CustomJob].
      ///
      /// [google.cloud.aiplatform.v1.CustomJob]: <doc:CustomJob>
      public var job: Swift.String = Swift.String()

      /// Output only. The names of the previously failed
      /// [CustomJob][google.cloud.aiplatform.v1.CustomJob]. The list includes the
      /// all attempts in chronological order.
      ///
      /// [google.cloud.aiplatform.v1.CustomJob]: <doc:CustomJob>
      public var failedJobs: [Swift.String] = []

      /// Initialize a new instance of `CustomJobDetail`.
      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 = CustomJobDetail().with { $0.job = ... }
      /// ```
      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.PipelineTaskExecutorDetail.CustomJobDetail"
      }
      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)
      }
    }

    public enum OneOf_Details: Codable, Equatable, Sendable {
      /// Output only. The detailed info for a container executor.
      indirect case containerDetail(PipelineTaskExecutorDetail.ContainerDetail?)
      /// Output only. The detailed info for a custom job executor.
      indirect case customJobDetail(PipelineTaskExecutorDetail.CustomJobDetail?)
    }

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