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

  /// Represents a conversation.
  /// A conversation is an interaction between an agent, including live agents
  /// and Dialogflow agents, and a support customer. Conversations can
  /// include phone calls and text-based chat sessions.
  public struct Conversation: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Output only. Identifier. The unique identifier of this conversation.
    /// Format: `projects/<Project ID>/locations/<Location
    /// ID>/conversations/<Conversation ID>`.
    public var name: Swift.String = Swift.String()

    /// Output only. The current state of the Conversation.
    public var lifecycleState: Conversation.LifecycleState = Conversation.LifecycleState()

    /// Required. The Conversation Profile to be used to configure this
    /// Conversation. This field cannot be updated.
    /// Format: `projects/<Project ID>/locations/<Location
    /// ID>/conversationProfiles/<Conversation Profile ID>`.
    public var conversationProfile: Swift.String = Swift.String()

    /// Output only. It will not be empty if the conversation is to be connected
    /// over telephony.
    public var phoneNumber: ConversationPhoneNumber? = nil

    /// Output only. The time the conversation was started.
    public var startTime: GoogleCloudWkt.Timestamp? = nil

    /// Output only. The time the conversation was finished.
    public var endTime: GoogleCloudWkt.Timestamp? = nil

    /// Optional. The stage of a conversation. It indicates whether the virtual
    /// agent or a human agent is handling the conversation.
    ///
    /// If the conversation is created with the conversation profile that has
    /// Dialogflow config set, defaults to
    /// [ConversationStage.VIRTUAL_AGENT_STAGE][google.cloud.dialogflow.v2.Conversation.ConversationStage.VIRTUAL_AGENT_STAGE];
    /// Otherwise, defaults to
    /// [ConversationStage.HUMAN_ASSIST_STAGE][google.cloud.dialogflow.v2.Conversation.ConversationStage.HUMAN_ASSIST_STAGE].
    ///
    /// If the conversation is created with the conversation profile that has
    /// Dialogflow config set but explicitly sets conversation_stage to
    /// [ConversationStage.HUMAN_ASSIST_STAGE][google.cloud.dialogflow.v2.Conversation.ConversationStage.HUMAN_ASSIST_STAGE],
    /// it skips
    /// [ConversationStage.VIRTUAL_AGENT_STAGE][google.cloud.dialogflow.v2.Conversation.ConversationStage.VIRTUAL_AGENT_STAGE]
    /// stage and directly goes to
    /// [ConversationStage.HUMAN_ASSIST_STAGE][google.cloud.dialogflow.v2.Conversation.ConversationStage.HUMAN_ASSIST_STAGE].
    ///
    /// [google.cloud.dialogflow.v2.Conversation.ConversationStage.HUMAN_ASSIST_STAGE]: <doc:Conversation/ConversationStage/humanAssistStage>
    /// [google.cloud.dialogflow.v2.Conversation.ConversationStage.VIRTUAL_AGENT_STAGE]: <doc:Conversation/ConversationStage/virtualAgentStage>
    public var conversationStage: Conversation.ConversationStage = Conversation.ConversationStage()

    /// Output only. The telephony connection information.
    public var telephonyConnectionInfo: Conversation.TelephonyConnectionInfo? = nil

    /// Optional. Output only. The initial conversation profile to be used to
    /// configure this conversation, which is a copy of the conversation profile
    /// config read at conversation creation time.
    public var initialConversationProfile: ConversationProfile? = nil

    /// Output only. The context reference updates provided by external systems.
    public var ingestedContextReferences: [Swift.String: Conversation.ContextReference] = [:]

    /// Output only. A map with generator name as key and generator context as
    /// value.
    public var initialGeneratorContexts: [Swift.String: Conversation.GeneratorContext] = [:]

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

    /// The information about phone calls connected via phone gateway to the
    /// conversation.
    public struct TelephonyConnectionInfo: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Output only. The number dialed to connect this call in E.164 format.
      public var dialedNumber: Swift.String = Swift.String()

      /// Optional. SDP of the call. It's initially the SDP answer to the incoming
      /// call, but maybe later updated for the purpose of making the link active,
      /// etc.
      public var sdp: Swift.String = Swift.String()

      /// Output only. The SIP headers from the initial SIP INVITE.
      public var sipHeaders: [Conversation.TelephonyConnectionInfo.SipHeader] = []

      /// Output only. The mime content from the initial SIP INVITE.
      public var extraMimeContents: [Conversation.TelephonyConnectionInfo.MimeContent] = []

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

      /// The SIP headers from the initial SIP INVITE.
      public struct SipHeader: Codable, Equatable, GoogleCloudWkt._AnyPackable,
        Sendable
      {
        /// Optional. The name of the header.
        public var name: Swift.String = Swift.String()

        /// Optional. The value of the header.
        public var value: Swift.String = Swift.String()

        /// Initialize a new instance of `SipHeader`.
        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 = SipHeader().with { $0.name = ... }
        /// ```
        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.Conversation.TelephonyConnectionInfo.SipHeader"
        }
        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 mime content from the initial SIP INVITE.
      public struct MimeContent: Codable, Equatable, GoogleCloudWkt._AnyPackable,
        Sendable
      {
        /// Optional. The mime type of the content.
        public var mimeType: Swift.String = Swift.String()

        /// Optional. The content payload.
        public var content: Foundation.Data = Foundation.Data()

        /// Initialize a new instance of `MimeContent`.
        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 = MimeContent().with { $0.mimeType = ... }
        /// ```
        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.Conversation.TelephonyConnectionInfo.MimeContent"
        }
        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 static var _anyTypeUrl: Swift.String {
        return "type.googleapis.com/google.cloud.dialogflow.v2.Conversation.TelephonyConnectionInfo"
      }
      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)
      }
    }

    /// Represents a section of ingested context information.
    public struct ContextReference: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Required. The list of content updates for a context reference.
      public var contextContents: [Conversation.ContextReference.ContextContent] = []

      /// Required. The mode in which context reference contents are updated.
      public var updateMode: Conversation.ContextReference.UpdateMode = Conversation
        .ContextReference.UpdateMode()

      /// Optional. The language of the information ingested, defaults to "en-US"
      /// if not set.
      public var languageCode: Swift.String = Swift.String()

      /// Output only. The time the context reference was first created.
      public var createTime: GoogleCloudWkt.Timestamp? = nil

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

      /// Contents ingested.
      public struct ContextContent: Codable, Equatable, GoogleCloudWkt._AnyPackable,
        Sendable
      {
        /// Required. The information ingested in a single request.
        public var content: Swift.String = Swift.String()

        /// Required. The format of the ingested string.
        public var contentFormat: Conversation.ContextReference.ContextContent.ContentFormat =
          Conversation.ContextReference.ContextContent.ContentFormat()

        /// Output only. The time when this information was incorporated into the
        /// relevant context reference.
        public var ingestionTime: GoogleCloudWkt.Timestamp? = nil

        /// If the context content was generated from a tool call, specify the
        /// answer record associated with the tool call.
        /// Format: `projects/<Project ID>/locations/<Location
        /// ID>/answerRecords/<Answer Record ID>`.
        public var answerRecord: Swift.String = Swift.String()

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

        /// Represents the format of the ingested string.
        public enum ContentFormat: Codable, Equatable, Sendable {
          /// Unspecified content format.
          case unspecified
          /// Content was provided in JSON format.
          case json
          /// Content was provided as plain text.
          case plainText
          /// 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 .json: return 1
            case .plainText: return 2
            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 "CONTENT_FORMAT_UNSPECIFIED"
            case .json: return "JSON"
            case .plainText: return "PLAIN_TEXT"
            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:ContentFormat/unknownStringValue(_:)).
          public init(stringValue: Swift.String) {
            switch stringValue {
            case "CONTENT_FORMAT_UNSPECIFIED": self = .unspecified
            case "JSON": self = .json
            case "PLAIN_TEXT": self = .plainText
            default: self = .unknownStringValue(stringValue)
            }
          }

          /// Initialize from an integer value.
          ///
          /// If the value is unknown, this initializes to [`unknownIntValue`](doc:ContentFormat/unknownIntValue(_:)).
          public init(intValue: Int) {
            switch intValue {
            case 0: self = .unspecified
            case 1: self = .json
            case 2: self = .plainText
            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 .json: return try container.encode(1)
            case .plainText: return try container.encode(2)
            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.Conversation.ContextReference.ContextContent"
        }
        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)
        }
      }

      /// Represents the mode in which context reference contents are updated.
      public enum UpdateMode: Codable, Equatable, Sendable {
        /// Unspecified update mode.
        case unspecified
        /// Context content updates are applied in append mode.
        case append
        /// Context content updates are applied in overwrite mode.
        case overwrite
        /// 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 .append: return 1
          case .overwrite: return 2
          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 "UPDATE_MODE_UNSPECIFIED"
          case .append: return "APPEND"
          case .overwrite: return "OVERWRITE"
          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:UpdateMode/unknownStringValue(_:)).
        public init(stringValue: Swift.String) {
          switch stringValue {
          case "UPDATE_MODE_UNSPECIFIED": self = .unspecified
          case "APPEND": self = .append
          case "OVERWRITE": self = .overwrite
          default: self = .unknownStringValue(stringValue)
          }
        }

        /// Initialize from an integer value.
        ///
        /// If the value is unknown, this initializes to [`unknownIntValue`](doc:UpdateMode/unknownIntValue(_:)).
        public init(intValue: Int) {
          switch intValue {
          case 0: self = .unspecified
          case 1: self = .append
          case 2: self = .overwrite
          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 .append: return try container.encode(1)
          case .overwrite: return try container.encode(2)
          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.Conversation.ContextReference"
      }
      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)
      }
    }

    /// Represents the context of a generator.
    public struct GeneratorContext: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Output only. The type of the generator.
      public var generatorType: Conversation.GeneratorContext.GeneratorType = Conversation
        .GeneratorContext.GeneratorType()

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

      /// The available generator types.
      public enum GeneratorType: Codable, Equatable, Sendable {
        /// Unspecified generator type.
        case unspecified
        /// Free form generator type.
        case freeForm
        /// Agent coaching generator type.
        case agentCoaching
        /// Summarization generator type.
        case summarization
        /// Translation generator type.
        case translation
        /// Agent feedback generator type.
        case agentFeedback
        /// Customer message generation generator type.
        case customerMessageGeneration
        /// 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 .freeForm: return 1
          case .agentCoaching: return 2
          case .summarization: return 3
          case .translation: return 4
          case .agentFeedback: return 5
          case .customerMessageGeneration: return 6
          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 "GENERATOR_TYPE_UNSPECIFIED"
          case .freeForm: return "FREE_FORM"
          case .agentCoaching: return "AGENT_COACHING"
          case .summarization: return "SUMMARIZATION"
          case .translation: return "TRANSLATION"
          case .agentFeedback: return "AGENT_FEEDBACK"
          case .customerMessageGeneration: return "CUSTOMER_MESSAGE_GENERATION"
          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:GeneratorType/unknownStringValue(_:)).
        public init(stringValue: Swift.String) {
          switch stringValue {
          case "GENERATOR_TYPE_UNSPECIFIED": self = .unspecified
          case "FREE_FORM": self = .freeForm
          case "AGENT_COACHING": self = .agentCoaching
          case "SUMMARIZATION": self = .summarization
          case "TRANSLATION": self = .translation
          case "AGENT_FEEDBACK": self = .agentFeedback
          case "CUSTOMER_MESSAGE_GENERATION": self = .customerMessageGeneration
          default: self = .unknownStringValue(stringValue)
          }
        }

        /// Initialize from an integer value.
        ///
        /// If the value is unknown, this initializes to [`unknownIntValue`](doc:GeneratorType/unknownIntValue(_:)).
        public init(intValue: Int) {
          switch intValue {
          case 0: self = .unspecified
          case 1: self = .freeForm
          case 2: self = .agentCoaching
          case 3: self = .summarization
          case 4: self = .translation
          case 5: self = .agentFeedback
          case 6: self = .customerMessageGeneration
          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 .freeForm: return try container.encode(1)
          case .agentCoaching: return try container.encode(2)
          case .summarization: return try container.encode(3)
          case .translation: return try container.encode(4)
          case .agentFeedback: return try container.encode(5)
          case .customerMessageGeneration: return try container.encode(6)
          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.Conversation.GeneratorContext"
      }
      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)
      }
    }

    /// Enumeration of the completion status of the conversation.
    public enum LifecycleState: Codable, Equatable, Sendable {
      /// Unknown.
      case unspecified
      /// Conversation is currently open for media analysis.
      case inProgress
      /// Conversation has been completed.
      case completed
      /// 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 .inProgress: return 1
        case .completed: return 2
        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 "LIFECYCLE_STATE_UNSPECIFIED"
        case .inProgress: return "IN_PROGRESS"
        case .completed: return "COMPLETED"
        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:LifecycleState/unknownStringValue(_:)).
      public init(stringValue: Swift.String) {
        switch stringValue {
        case "LIFECYCLE_STATE_UNSPECIFIED": self = .unspecified
        case "IN_PROGRESS": self = .inProgress
        case "COMPLETED": self = .completed
        default: self = .unknownStringValue(stringValue)
        }
      }

      /// Initialize from an integer value.
      ///
      /// If the value is unknown, this initializes to [`unknownIntValue`](doc:LifecycleState/unknownIntValue(_:)).
      public init(intValue: Int) {
        switch intValue {
        case 0: self = .unspecified
        case 1: self = .inProgress
        case 2: self = .completed
        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 .inProgress: return try container.encode(1)
        case .completed: return try container.encode(2)
        case .unknownIntValue(let v): return try container.encode(v)
        case .unknownStringValue(let v): return try container.encode(v)
        }
      }
    }

    /// Enumeration of the different conversation stages a conversation can be in.
    /// Reference:
    /// https://cloud.google.com/agent-assist/docs/basics#conversation_stages
    public enum ConversationStage: Codable, Equatable, Sendable {
      /// Unknown. Should never be used after a conversation is successfully
      /// created.
      case unspecified
      /// The conversation should return virtual agent responses into the
      /// conversation.
      case virtualAgentStage
      /// The conversation should not provide responses, just listen and provide
      /// suggestions.
      case humanAssistStage
      /// 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 .virtualAgentStage: return 1
        case .humanAssistStage: return 2
        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 "CONVERSATION_STAGE_UNSPECIFIED"
        case .virtualAgentStage: return "VIRTUAL_AGENT_STAGE"
        case .humanAssistStage: return "HUMAN_ASSIST_STAGE"
        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:ConversationStage/unknownStringValue(_:)).
      public init(stringValue: Swift.String) {
        switch stringValue {
        case "CONVERSATION_STAGE_UNSPECIFIED": self = .unspecified
        case "VIRTUAL_AGENT_STAGE": self = .virtualAgentStage
        case "HUMAN_ASSIST_STAGE": self = .humanAssistStage
        default: self = .unknownStringValue(stringValue)
        }
      }

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