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

  /// Debug information related to Knowledge Assist feature.
  public struct KnowledgeAssistDebugInfo: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Reason for query generation.
    public var queryGenerationFailureReason: KnowledgeAssistDebugInfo.QueryGenerationFailureReason =
      KnowledgeAssistDebugInfo.QueryGenerationFailureReason()

    /// Reason for query categorization.
    public var queryCategorizationFailureReason:
      KnowledgeAssistDebugInfo.QueryCategorizationFailureReason =
        KnowledgeAssistDebugInfo.QueryCategorizationFailureReason()

    /// Response reason from datastore which indicates data serving status or
    /// answer quality degradation.
    public var datastoreResponseReason: DatastoreResponseReason = DatastoreResponseReason()

    /// Configured behaviors for Knowedge Assist.
    public var knowledgeAssistBehavior: KnowledgeAssistDebugInfo.KnowledgeAssistBehavior? = nil

    /// Information about parameters ingested for search knowledge.
    public var ingestedContextReferenceDebugInfo: IngestedContextReferenceDebugInfo? = nil

    /// The latency of the service.
    public var serviceLatency: ServiceLatency? = nil

    /// Token usage metadata for query generation.
    public var queryGenerationDebugInfo: KnowledgeAssistDebugInfo.QueryGenerationDebugInfo? = nil

    /// Debug information from CES runtime API.
    public var cesDebugInfo: GoogleCloudWkt.Struct? = nil

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

    /// Configured behaviors for Knowedge Assist.
    public struct KnowledgeAssistBehavior: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Whether data store agent rewriter was turned off for the request.
      public var answerGenerationRewriterOn: Swift.Bool = Swift.Bool()

      /// Whether end_user_metadata is included in the data store agent call.
      public var endUserMetadataIncluded: Swift.Bool = Swift.Bool()

      /// Whether customers configured to return query only in the
      /// conversation profile.
      public var returnQueryOnly: Swift.Bool = Swift.Bool()

      /// Whether customers configured to use pubsub to deliver.
      public var usePubsubDelivery: Swift.Bool = Swift.Bool()

      /// Whether customers configured to disable the synchronous delivery of
      /// Knowedge Assist response.
      public var disableSyncDelivery: Swift.Bool = Swift.Bool()

      /// Whether previously suggested queries are included in the query generation
      /// process.
      public var previousQueriesIncluded: Swift.Bool = Swift.Bool()

      /// Translated message is included in query generation process.
      public var useTranslatedMessage: Swift.Bool = Swift.Bool()

      /// Safety filter is adjusted by user.
      public var useCustomSafetyFilterLevel: Swift.Bool = Swift.Bool()

      /// Conversation transcript has mixed languages.
      public var conversationTranscriptHasMixedLanguages: Swift.Bool = Swift.Bool()

      /// Whether the agent language from the translation generator mismatches the
      /// end-user language.
      public var queryGenerationAgentLanguageMismatch: Swift.Bool = Swift.Bool()

      /// Whether the end-user language from the translation generator mismatches
      /// the end-user language.
      public var queryGenerationEndUserLanguageMismatch: Swift.Bool = Swift.Bool()

      /// This field indicates whether third party connectors are enabled for the
      /// project
      public var thirdPartyConnectorAllowed: Swift.Bool = Swift.Bool()

      /// Indicates that the query generation model generated multiple queries.
      public var multipleQueriesGenerated: Swift.Bool = Swift.Bool()

      /// Indicates that the generated query contains search context.
      public var queryContainedSearchContext: Swift.Bool = Swift.Bool()

      /// Indicates that invalid items were skipped when parsing the LLM response.
      public var invalidItemsQuerySuggestionSkipped: Swift.Bool = Swift.Bool()

      /// True if the primary suggested query was redacted and replaced by an
      /// additional query.
      public var primaryQueryRedactedAndReplaced: Swift.Bool = Swift.Bool()

      /// The number of search contexts appended to the query.
      public var appendedSearchContextCount: Swift.Int32 = Swift.Int32()

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

    /// Token usage metadata for query generation.
    public struct QueryGenerationDebugInfo: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// The total number of tokens in the prompt.
      public var promptTokenCount: Swift.Int32 = Swift.Int32()

      /// The total number of tokens in the generated candidates.
      public var candidatesTokenCount: Swift.Int32 = Swift.Int32()

      /// The total number of tokens for the entire request.
      public var totalTokenCount: Swift.Int32 = Swift.Int32()

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

    /// Reason for query generation failure.
    public enum QueryGenerationFailureReason: Codable, Equatable, Sendable {
      /// Default value.
      case unspecified
      /// Query generation is blocked due to out of quota.
      case queryGenerationOutOfQuota
      /// Call to Knowedge Assist query generation model fails.
      case queryGenerationFailed
      /// Query generation model decides that there is no new topic change or
      /// there has been similar queries generated in the previous turns.
      case queryGenerationNoQueryGenerated
      /// Knowedge Assist generated query is blocked by RAI (Responsible AI).
      case queryGenerationRaiFailed
      /// Query generation is blocked by Knowledge Assist conversation profile
      /// level / agent id level filtering.
      case notInAllowlist
      /// The generated query is blocked due to redaction.
      case queryGenerationQueryRedacted
      /// Query generation failed due to LLM response parse failure.
      case queryGenerationLlmResponseParseFailed
      /// The conversation has no messages.
      case queryGenerationEmptyConversation
      /// The last message in the conversation is empty.
      case queryGenerationEmptyLastMessage
      /// The trigger event condition is not met.
      /// This occurs in the following scenarios:
      /// 1. The trigger_event is CUSTOMER_MESSAGE or UNSPECIFIED, but the last
      ///    message is not from the customer.
      /// 2. The trigger_event is AGENT_MESSAGE, but the last message is not from
      ///    the agent.
      case queryGenerationTriggeringEventConditionNotMet
      /// 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 .queryGenerationOutOfQuota: return 1
        case .queryGenerationFailed: return 2
        case .queryGenerationNoQueryGenerated: return 3
        case .queryGenerationRaiFailed: return 4
        case .notInAllowlist: return 5
        case .queryGenerationQueryRedacted: return 6
        case .queryGenerationLlmResponseParseFailed: return 10
        case .queryGenerationEmptyConversation: return 11
        case .queryGenerationEmptyLastMessage: return 12
        case .queryGenerationTriggeringEventConditionNotMet: return 13
        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 "QUERY_GENERATION_FAILURE_REASON_UNSPECIFIED"
        case .queryGenerationOutOfQuota: return "QUERY_GENERATION_OUT_OF_QUOTA"
        case .queryGenerationFailed: return "QUERY_GENERATION_FAILED"
        case .queryGenerationNoQueryGenerated: return "QUERY_GENERATION_NO_QUERY_GENERATED"
        case .queryGenerationRaiFailed: return "QUERY_GENERATION_RAI_FAILED"
        case .notInAllowlist: return "NOT_IN_ALLOWLIST"
        case .queryGenerationQueryRedacted: return "QUERY_GENERATION_QUERY_REDACTED"
        case .queryGenerationLlmResponseParseFailed:
          return "QUERY_GENERATION_LLM_RESPONSE_PARSE_FAILED"
        case .queryGenerationEmptyConversation: return "QUERY_GENERATION_EMPTY_CONVERSATION"
        case .queryGenerationEmptyLastMessage: return "QUERY_GENERATION_EMPTY_LAST_MESSAGE"
        case .queryGenerationTriggeringEventConditionNotMet:
          return "QUERY_GENERATION_TRIGGERING_EVENT_CONDITION_NOT_MET"
        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:QueryGenerationFailureReason/unknownStringValue(_:)).
      public init(stringValue: Swift.String) {
        switch stringValue {
        case "QUERY_GENERATION_FAILURE_REASON_UNSPECIFIED": self = .unspecified
        case "QUERY_GENERATION_OUT_OF_QUOTA": self = .queryGenerationOutOfQuota
        case "QUERY_GENERATION_FAILED": self = .queryGenerationFailed
        case "QUERY_GENERATION_NO_QUERY_GENERATED": self = .queryGenerationNoQueryGenerated
        case "QUERY_GENERATION_RAI_FAILED": self = .queryGenerationRaiFailed
        case "NOT_IN_ALLOWLIST": self = .notInAllowlist
        case "QUERY_GENERATION_QUERY_REDACTED": self = .queryGenerationQueryRedacted
        case "QUERY_GENERATION_LLM_RESPONSE_PARSE_FAILED":
          self = .queryGenerationLlmResponseParseFailed
        case "QUERY_GENERATION_EMPTY_CONVERSATION": self = .queryGenerationEmptyConversation
        case "QUERY_GENERATION_EMPTY_LAST_MESSAGE": self = .queryGenerationEmptyLastMessage
        case "QUERY_GENERATION_TRIGGERING_EVENT_CONDITION_NOT_MET":
          self = .queryGenerationTriggeringEventConditionNotMet
        default: self = .unknownStringValue(stringValue)
        }
      }

      /// Initialize from an integer value.
      ///
      /// If the value is unknown, this initializes to [`unknownIntValue`](doc:QueryGenerationFailureReason/unknownIntValue(_:)).
      public init(intValue: Int) {
        switch intValue {
        case 0: self = .unspecified
        case 1: self = .queryGenerationOutOfQuota
        case 2: self = .queryGenerationFailed
        case 3: self = .queryGenerationNoQueryGenerated
        case 4: self = .queryGenerationRaiFailed
        case 5: self = .notInAllowlist
        case 6: self = .queryGenerationQueryRedacted
        case 10: self = .queryGenerationLlmResponseParseFailed
        case 11: self = .queryGenerationEmptyConversation
        case 12: self = .queryGenerationEmptyLastMessage
        case 13: self = .queryGenerationTriggeringEventConditionNotMet
        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 .queryGenerationOutOfQuota: return try container.encode(1)
        case .queryGenerationFailed: return try container.encode(2)
        case .queryGenerationNoQueryGenerated: return try container.encode(3)
        case .queryGenerationRaiFailed: return try container.encode(4)
        case .notInAllowlist: return try container.encode(5)
        case .queryGenerationQueryRedacted: return try container.encode(6)
        case .queryGenerationLlmResponseParseFailed: return try container.encode(10)
        case .queryGenerationEmptyConversation: return try container.encode(11)
        case .queryGenerationEmptyLastMessage: return try container.encode(12)
        case .queryGenerationTriggeringEventConditionNotMet: return try container.encode(13)
        case .unknownIntValue(let v): return try container.encode(v)
        case .unknownStringValue(let v): return try container.encode(v)
        }
      }
    }

    /// Reason for query categorization failure.
    public enum QueryCategorizationFailureReason: Codable, Equatable, Sendable {
      /// Default value.
      case unspecified
      /// Vertex AI Search config supplied for query categorization is invalid.
      case queryCategorizationInvalidConfig
      /// Vertex AI Search result does not contain a query categorization result.
      case queryCategorizationResultNotFound
      /// Vertex AI Search call fails.
      case queryCategorizationFailed
      /// 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 .queryCategorizationInvalidConfig: return 1
        case .queryCategorizationResultNotFound: return 2
        case .queryCategorizationFailed: return 3
        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 "QUERY_CATEGORIZATION_FAILURE_REASON_UNSPECIFIED"
        case .queryCategorizationInvalidConfig: return "QUERY_CATEGORIZATION_INVALID_CONFIG"
        case .queryCategorizationResultNotFound: return "QUERY_CATEGORIZATION_RESULT_NOT_FOUND"
        case .queryCategorizationFailed: return "QUERY_CATEGORIZATION_FAILED"
        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:QueryCategorizationFailureReason/unknownStringValue(_:)).
      public init(stringValue: Swift.String) {
        switch stringValue {
        case "QUERY_CATEGORIZATION_FAILURE_REASON_UNSPECIFIED": self = .unspecified
        case "QUERY_CATEGORIZATION_INVALID_CONFIG": self = .queryCategorizationInvalidConfig
        case "QUERY_CATEGORIZATION_RESULT_NOT_FOUND": self = .queryCategorizationResultNotFound
        case "QUERY_CATEGORIZATION_FAILED": self = .queryCategorizationFailed
        default: self = .unknownStringValue(stringValue)
        }
      }

      /// Initialize from an integer value.
      ///
      /// If the value is unknown, this initializes to [`unknownIntValue`](doc:QueryCategorizationFailureReason/unknownIntValue(_:)).
      public init(intValue: Int) {
        switch intValue {
        case 0: self = .unspecified
        case 1: self = .queryCategorizationInvalidConfig
        case 2: self = .queryCategorizationResultNotFound
        case 3: self = .queryCategorizationFailed
        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 .queryCategorizationInvalidConfig: return try container.encode(1)
        case .queryCategorizationResultNotFound: return try container.encode(2)
        case .queryCategorizationFailed: return try container.encode(3)
        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.dialogflow.v2.KnowledgeAssistDebugInfo"
    }
    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
