// 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 Participants
  import Foundation
  import GoogleCloudWkt
  import GoogleRpc

  /// One response of different type of suggestion response which is used in
  /// the response of
  /// [Participants.AnalyzeContent][google.cloud.dialogflow.v2.Participants.AnalyzeContent]
  /// and
  /// [Participants.AnalyzeContent][google.cloud.dialogflow.v2.Participants.AnalyzeContent],
  /// as well as
  /// [HumanAgentAssistantEvent][google.cloud.dialogflow.v2.HumanAgentAssistantEvent].
  ///
  /// [google.cloud.dialogflow.v2.HumanAgentAssistantEvent]: <doc:HumanAgentAssistantEvent>
  /// [google.cloud.dialogflow.v2.Participants.AnalyzeContent]: <doc:Participants/analyzeContent(request:)>
  public struct SuggestionResult: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Different type of suggestion response.
    public var suggestionResponse: OneOf_SuggestionResponse? = nil

    /// Initialize a new instance of `SuggestionResult`.
    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 = SuggestionResult().with { $0.error = ... }
    /// ```
    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 error = "error"
      case suggestArticlesResponse = "suggestArticlesResponse"
      case suggestKnowledgeAssistResponse = "suggestKnowledgeAssistResponse"
      case suggestFaqAnswersResponse = "suggestFaqAnswersResponse"
      case suggestSmartRepliesResponse = "suggestSmartRepliesResponse"
      case generateSuggestionsResponse = "generateSuggestionsResponse"
    }

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

      var suggestionResponse: OneOf_SuggestionResponse? = nil
      let suggestionResponseCheckAndSet = {
        if suggestionResponse != nil {
          throw DecodingError.dataCorrupted(
            DecodingError.Context(
              codingPath: decoder.codingPath,
              debugDescription: "Multiple values set for oneof 'suggestionResponse'"))
        }
        suggestionResponse = $0
      }
      if let error = try container.decodeIfPresent(GoogleRpc.Status?.self, forKey: .error) {
        try suggestionResponseCheckAndSet(.error(error))
      }
      if let suggestArticlesResponse = try container.decodeIfPresent(
        SuggestArticlesResponse?.self, forKey: .suggestArticlesResponse)
      {
        try suggestionResponseCheckAndSet(.suggestArticlesResponse(suggestArticlesResponse))
      }
      if let suggestKnowledgeAssistResponse = try container.decodeIfPresent(
        SuggestKnowledgeAssistResponse?.self, forKey: .suggestKnowledgeAssistResponse)
      {
        try suggestionResponseCheckAndSet(
          .suggestKnowledgeAssistResponse(suggestKnowledgeAssistResponse))
      }
      if let suggestFaqAnswersResponse = try container.decodeIfPresent(
        SuggestFaqAnswersResponse?.self, forKey: .suggestFaqAnswersResponse)
      {
        try suggestionResponseCheckAndSet(.suggestFaqAnswersResponse(suggestFaqAnswersResponse))
      }
      if let suggestSmartRepliesResponse = try container.decodeIfPresent(
        SuggestSmartRepliesResponse?.self, forKey: .suggestSmartRepliesResponse)
      {
        try suggestionResponseCheckAndSet(.suggestSmartRepliesResponse(suggestSmartRepliesResponse))
      }
      if let generateSuggestionsResponse = try container.decodeIfPresent(
        GenerateSuggestionsResponse?.self, forKey: .generateSuggestionsResponse)
      {
        try suggestionResponseCheckAndSet(.generateSuggestionsResponse(generateSuggestionsResponse))
      }
      self.suggestionResponse = suggestionResponse
    }

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

      if let choice = self.suggestionResponse {
        switch choice {
        case .error(let value):
          try container.encode(value, forKey: .error)
        case .suggestArticlesResponse(let value):
          try container.encode(value, forKey: .suggestArticlesResponse)
        case .suggestKnowledgeAssistResponse(let value):
          try container.encode(value, forKey: .suggestKnowledgeAssistResponse)
        case .suggestFaqAnswersResponse(let value):
          try container.encode(value, forKey: .suggestFaqAnswersResponse)
        case .suggestSmartRepliesResponse(let value):
          try container.encode(value, forKey: .suggestSmartRepliesResponse)
        case .generateSuggestionsResponse(let value):
          try container.encode(value, forKey: .generateSuggestionsResponse)
        }
      }
    }

    /// Different type of suggestion response.
    public enum OneOf_SuggestionResponse: Codable, Equatable, Sendable {
      /// Error status if the request failed.
      indirect case error(GoogleRpc.Status?)
      /// SuggestArticlesResponse if request is for ARTICLE_SUGGESTION.
      indirect case suggestArticlesResponse(SuggestArticlesResponse?)
      /// SuggestKnowledgeAssistResponse if request is for KNOWLEDGE_ASSIST.
      indirect case suggestKnowledgeAssistResponse(SuggestKnowledgeAssistResponse?)
      /// SuggestFaqAnswersResponse if request is for FAQ_ANSWER.
      indirect case suggestFaqAnswersResponse(SuggestFaqAnswersResponse?)
      /// SuggestSmartRepliesResponse if request is for SMART_REPLY.
      indirect case suggestSmartRepliesResponse(SuggestSmartRepliesResponse?)
      /// Suggestions generated using generators triggered by customer or agent
      /// messages.
      indirect case generateSuggestionsResponse(GenerateSuggestionsResponse?)
    }

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