// 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 AnswerRecords || Conversations || GeneratorEvaluations || Generators || Participants
  import Foundation
  import GoogleCloudWkt

  /// Suggestion generated using a Generator.
  public struct GeneratorSuggestion: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Optional. List of request and response for tool calls executed.
    public var toolCallInfo: [GeneratorSuggestion.ToolCallInfo] = []

    /// The suggestion could be one of the many types
    public var suggestion: OneOf_Suggestion? = nil

    /// Initialize a new instance of `GeneratorSuggestion`.
    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 = GeneratorSuggestion().with { $0.freeFormSuggestion = ... }
    /// ```
    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 freeFormSuggestion = "freeFormSuggestion"
      case summarySuggestion = "summarySuggestion"
      case agentCoachingSuggestion = "agentCoachingSuggestion"
      case toolCallInfo = "toolCallInfo"
    }

    public init(from decoder: Decoder) throws {
      let container = try decoder.container(keyedBy: CodingKeys.self)
      self.toolCallInfo = try container.decode(
        [GeneratorSuggestion.ToolCallInfo].self, forKey: .toolCallInfo)

      var suggestion: OneOf_Suggestion? = nil
      let suggestionCheckAndSet = {
        if suggestion != nil {
          throw DecodingError.dataCorrupted(
            DecodingError.Context(
              codingPath: decoder.codingPath,
              debugDescription: "Multiple values set for oneof 'suggestion'"))
        }
        suggestion = $0
      }
      if let freeFormSuggestion = try container.decodeIfPresent(
        FreeFormSuggestion?.self, forKey: .freeFormSuggestion)
      {
        try suggestionCheckAndSet(.freeFormSuggestion(freeFormSuggestion))
      }
      if let summarySuggestion = try container.decodeIfPresent(
        SummarySuggestion?.self, forKey: .summarySuggestion)
      {
        try suggestionCheckAndSet(.summarySuggestion(summarySuggestion))
      }
      if let agentCoachingSuggestion = try container.decodeIfPresent(
        AgentCoachingSuggestion?.self, forKey: .agentCoachingSuggestion)
      {
        try suggestionCheckAndSet(.agentCoachingSuggestion(agentCoachingSuggestion))
      }
      self.suggestion = suggestion
    }

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

      if let choice = self.suggestion {
        switch choice {
        case .freeFormSuggestion(let value):
          try container.encode(value, forKey: .freeFormSuggestion)
        case .summarySuggestion(let value):
          try container.encode(value, forKey: .summarySuggestion)
        case .agentCoachingSuggestion(let value):
          try container.encode(value, forKey: .agentCoachingSuggestion)
        }
      }
    }

    /// Request and response for a tool call.
    public struct ToolCallInfo: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Required. Request for a tool call.
      public var toolCall: ToolCall? = nil

      /// Required. Response for a tool call.
      public var toolCallResult: ToolCallResult? = nil

      /// Initialize a new instance of `ToolCallInfo`.
      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 = ToolCallInfo().with { $0.toolCall = ... }
      /// ```
      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.dialogflow.v2.GeneratorSuggestion.ToolCallInfo"
      }
      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 suggestion could be one of the many types
    public enum OneOf_Suggestion: Codable, Equatable, Sendable {
      /// Optional. Free form suggestion.
      indirect case freeFormSuggestion(FreeFormSuggestion?)
      /// Optional. Suggested summary.
      indirect case summarySuggestion(SummarySuggestion?)
      /// Optional. Suggestion to coach the agent.
      indirect case agentCoachingSuggestion(AgentCoachingSuggestion?)
    }

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