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

import Foundation
import GoogleCloudWkt

/// Tool to retrieve from Vertex AI Search datastore or engine for grounding.
/// Accepts either a datastore or an engine, but not both.
/// See Vertex AI Search:
/// https://cloud.google.com/generative-ai-app-builder/docs/enterprise-search-introduction.
public struct DataStoreTool: Codable, Equatable, GoogleCloudWkt._AnyPackable,
  Sendable
{
  /// Required. The data store tool name.
  public var name: Swift.String = Swift.String()

  /// Optional. The tool description.
  public var description: Swift.String = Swift.String()

  /// Optional. Boost specification to boost certain documents.
  public var boostSpecs: [DataStoreTool.BoostSpecs] = []

  /// Optional. The modality configs for the data store.
  public var modalityConfigs: [DataStoreTool.ModalityConfig] = []

  /// Optional. The filter parameter behavior.
  public var filterParameterBehavior: DataStoreTool.FilterParameterBehavior =
    DataStoreTool.FilterParameterBehavior()

  /// Defines the search source, either a single DataStore or an Engine.
  public var searchSource: OneOf_SearchSource? = nil

  /// Initialize a new instance of `DataStoreTool`.
  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 = DataStoreTool().with { $0.dataStoreSource = ... }
  /// ```
  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 dataStoreSource = "dataStoreSource"
    case engineSource = "engineSource"
    case name = "name"
    case description = "description"
    case boostSpecs = "boostSpecs"
    case modalityConfigs = "modalityConfigs"
    case filterParameterBehavior = "filterParameterBehavior"
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
    self.name = try container.decode(Swift.String.self, forKey: .name)
    self.description = try container.decode(Swift.String.self, forKey: .description)
    self.boostSpecs = try container.decode([DataStoreTool.BoostSpecs].self, forKey: .boostSpecs)
    self.modalityConfigs = try container.decode(
      [DataStoreTool.ModalityConfig].self, forKey: .modalityConfigs)
    self.filterParameterBehavior = try container.decode(
      DataStoreTool.FilterParameterBehavior.self, forKey: .filterParameterBehavior)

    var searchSource: OneOf_SearchSource? = nil
    let searchSourceCheckAndSet = {
      if searchSource != nil {
        throw DecodingError.dataCorrupted(
          DecodingError.Context(
            codingPath: decoder.codingPath,
            debugDescription: "Multiple values set for oneof 'searchSource'"))
      }
      searchSource = $0
    }
    if let dataStoreSource = try container.decodeIfPresent(
      DataStoreTool.DataStoreSource?.self, forKey: .dataStoreSource)
    {
      try searchSourceCheckAndSet(.dataStoreSource(dataStoreSource))
    }
    if let engineSource = try container.decodeIfPresent(
      DataStoreTool.EngineSource?.self, forKey: .engineSource)
    {
      try searchSourceCheckAndSet(.engineSource(engineSource))
    }
    self.searchSource = searchSource
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    try container.encode(self.name, forKey: .name)
    try container.encode(self.description, forKey: .description)
    try container.encode(self.boostSpecs, forKey: .boostSpecs)
    try container.encode(self.modalityConfigs, forKey: .modalityConfigs)
    try container.encode(self.filterParameterBehavior, forKey: .filterParameterBehavior)

    if let choice = self.searchSource {
      switch choice {
      case .dataStoreSource(let value):
        try container.encode(value, forKey: .dataStoreSource)
      case .engineSource(let value):
        try container.encode(value, forKey: .engineSource)
      }
    }
  }

  /// Rewriter configuration.
  public struct RewriterConfig: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Required. Configurations for the LLM model.
    public var modelSettings: ModelSettings? = nil

    /// Optional. The prompt definition. If not set, default prompt will be used.
    public var prompt: Swift.String = Swift.String()

    /// Optional. Whether the rewriter is disabled.
    public var disabled: Swift.Bool = Swift.Bool()

    /// Initialize a new instance of `RewriterConfig`.
    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 = RewriterConfig().with { $0.modelSettings = ... }
    /// ```
    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.ces.v1.DataStoreTool.RewriterConfig"
    }
    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)
    }
  }

  /// Summarization configuration.
  public struct SummarizationConfig: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Optional. Configurations for the LLM model.
    public var modelSettings: ModelSettings? = nil

    /// Optional. The prompt definition. If not set, default prompt will be used.
    public var prompt: Swift.String = Swift.String()

    /// Optional. Whether summarization is disabled.
    public var disabled: Swift.Bool = Swift.Bool()

    /// Initialize a new instance of `SummarizationConfig`.
    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 = SummarizationConfig().with { $0.modelSettings = ... }
    /// ```
    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.ces.v1.DataStoreTool.SummarizationConfig"
    }
    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)
    }
  }

  /// Grounding configuration.
  public struct GroundingConfig: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Optional. The groundedness threshold of the answer based on the retrieved
    /// sources. The value has a configurable range of [1, 5]. The level is used
    /// to threshold the groundedness of the answer, meaning that all responses
    /// with a groundedness score below the threshold will fall back to returning
    /// relevant snippets only.
    ///
    /// For example, a level of 3 means that the groundedness score must be
    /// 3 or higher for the response to be returned.
    public var groundingLevel: Swift.Float = Swift.Float()

    /// Optional. Whether grounding is disabled.
    public var disabled: Swift.Bool = Swift.Bool()

    /// Initialize a new instance of `GroundingConfig`.
    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 = GroundingConfig().with { $0.groundingLevel = ... }
    /// ```
    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.ces.v1.DataStoreTool.GroundingConfig"
    }
    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)
    }
  }

  /// Configuration for searching within a specific DataStore.
  public struct DataStoreSource: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Optional. Filter specification for the DataStore.
    /// See:
    /// https://cloud.google.com/generative-ai-app-builder/docs/filter-search-metadata
    public var filter: Swift.String = Swift.String()

    /// Optional. The data store.
    public var dataStore: DataStore? = nil

    /// Initialize a new instance of `DataStoreSource`.
    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 = DataStoreSource().with { $0.filter = ... }
    /// ```
    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.ces.v1.DataStoreTool.DataStoreSource"
    }
    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)
    }
  }

  /// Configuration for searching within an Engine, potentially targeting
  /// specific DataStores.
  public struct EngineSource: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Required. Full resource name of the Engine.
    /// Format:
    /// `projects/{project}/locations/{location}/collections/{collection}/engines/{engine}`
    public var engine: Swift.String = Swift.String()

    /// Optional. Use to target specific DataStores within the Engine.
    /// If empty, the search applies to all DataStores associated with the
    /// Engine.
    public var dataStoreSources: [DataStoreTool.DataStoreSource] = []

    /// Optional. A filter applied to the search across the Engine. Not relevant
    /// and not used if 'data_store_sources' is provided. See:
    /// https://cloud.google.com/generative-ai-app-builder/docs/filter-search-metadata
    public var filter: Swift.String = Swift.String()

    /// Initialize a new instance of `EngineSource`.
    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 = EngineSource().with { $0.engine = ... }
    /// ```
    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.ces.v1.DataStoreTool.EngineSource"
    }
    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)
    }
  }

  /// Boost specifications to boost certain documents.
  /// For more information, please refer to
  /// https://cloud.google.com/generative-ai-app-builder/docs/boosting.
  public struct BoostSpecs: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Required. The Data Store where the boosting configuration is applied.
    /// Full resource name of DataStore, such as
    /// projects/{project}/locations/{location}/collections/{collection}/dataStores/{dataStore}.
    public var dataStores: [Swift.String] = []

    /// Required. A list of boosting specifications.
    public var spec: [DataStoreTool.BoostSpec] = []

    /// Initialize a new instance of `BoostSpecs`.
    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 = BoostSpecs().with { $0.dataStores = ... }
    /// ```
    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.ces.v1.DataStoreTool.BoostSpecs"
    }
    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)
    }
  }

  /// Boost specification to boost certain documents.
  public struct BoostSpec: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Required. A list of boosting specifications.
    public var conditionBoostSpecs: [DataStoreTool.BoostSpec.ConditionBoostSpec] = []

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

    /// Boost specification for a condition.
    public struct ConditionBoostSpec: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Required. An expression which specifies a boost condition. The syntax
      /// is the same as filter expression syntax. Currently, the only supported
      /// condition is a list of BCP-47 lang codes. Example: To boost suggestions
      /// in languages en or fr: (lang_code: ANY("en", "fr"))
      public var condition: Swift.String = Swift.String()

      /// Optional. Strength of the boost, which should be in [-1, 1]. Negative
      /// boost means demotion. Default is 0.0.
      ///
      /// Setting to 1.0 gives the suggestions a big promotion. However, it does
      /// not necessarily mean that the top result will be a boosted suggestion.
      ///
      /// Setting to -1.0 gives the suggestions a big demotion. However, other
      /// suggestions that are relevant might still be shown.
      ///
      /// Setting to 0.0 means no boost applied. The boosting condition is
      /// ignored.
      public var boost: Swift.Float = Swift.Float()

      /// Optional. Complex specification for custom ranking based on customer
      /// defined attribute value.
      public var boostControlSpec: DataStoreTool.BoostSpec.ConditionBoostSpec.BoostControlSpec? =
        nil

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

      /// Specification for custom ranking based on customer specified attribute
      /// value. It provides more controls for customized ranking than the simple
      /// (condition, boost) combination above.
      public struct BoostControlSpec: Codable, Equatable, GoogleCloudWkt._AnyPackable,
        Sendable
      {
        /// Optional. The name of the field whose value will be used to determine
        /// the boost amount.
        public var fieldName: Swift.String = Swift.String()

        /// Optional. The attribute type to be used to determine the boost
        /// amount. The attribute value can be derived from the field value of
        /// the specified field_name. In the case of numerical it is
        /// straightforward i.e. attribute_value = numerical_field_value. In the
        /// case of freshness however, attribute_value = (time.now() -
        /// datetime_field_value).
        public var attributeType:
          DataStoreTool.BoostSpec.ConditionBoostSpec.BoostControlSpec.AttributeType = DataStoreTool
            .BoostSpec.ConditionBoostSpec.BoostControlSpec.AttributeType()

        /// Optional. The interpolation type to be applied to connect the control
        /// points listed below.
        public var interpolationType:
          DataStoreTool.BoostSpec.ConditionBoostSpec.BoostControlSpec.InterpolationType =
            DataStoreTool.BoostSpec.ConditionBoostSpec.BoostControlSpec.InterpolationType()

        /// Optional. The control points used to define the curve. The monotonic
        /// function (defined through the interpolation_type above) passes
        /// through the control points listed here.
        public var controlPoints:
          [DataStoreTool.BoostSpec.ConditionBoostSpec.BoostControlSpec.ControlPoint] = []

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

        /// The control points used to define the curve. The curve defined
        /// through these control points can only be monotonically increasing
        /// or decreasing(constant values are acceptable).
        public struct ControlPoint: Codable, Equatable, GoogleCloudWkt._AnyPackable,
          Sendable
        {
          /// Optional. Can be one of:
          /// 1. The numerical field value.
          /// 2. The duration spec for freshness:
          /// The value must be formatted as an XSD `dayTimeDuration` value (a
          /// restricted subset of an ISO 8601 duration value). The pattern for
          /// this is: `[nD][T[nH][nM][nS]]`.
          public var attributeValue: Swift.String = Swift.String()

          /// Optional. The value between -1 to 1 by which to boost the score if
          /// the attribute_value evaluates to the value specified above.
          public var boostAmount: Swift.Float = Swift.Float()

          /// Initialize a new instance of `ControlPoint`.
          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 = ControlPoint().with { $0.attributeValue = ... }
          /// ```
          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.ces.v1.DataStoreTool.BoostSpec.ConditionBoostSpec.BoostControlSpec.ControlPoint"
          }
          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 attribute(or function) for which the custom ranking is to be
        /// applied.
        public enum AttributeType: Codable, Equatable, Sendable {
          /// Unspecified AttributeType.
          case unspecified
          /// The value of the numerical field will be used to dynamically update
          /// the boost amount. In this case, the attribute_value (the x value)
          /// of the control point will be the actual value of the numerical
          /// field for which the boost_amount is specified.
          case numerical
          /// For the freshness use case the attribute value will be the duration
          /// between the current time and the date in the datetime field
          /// specified. The value must be formatted as an XSD `dayTimeDuration`
          /// value (a restricted subset of an ISO 8601 duration value). The
          /// pattern for this is: `[nD][T[nH][nM][nS]]`.
          /// E.g. `5D`, `3DT12H30M`, `T24H`.
          case freshness
          /// 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 .numerical: return 1
            case .freshness: 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 "ATTRIBUTE_TYPE_UNSPECIFIED"
            case .numerical: return "NUMERICAL"
            case .freshness: return "FRESHNESS"
            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:AttributeType/unknownStringValue(_:)).
          public init(stringValue: Swift.String) {
            switch stringValue {
            case "ATTRIBUTE_TYPE_UNSPECIFIED": self = .unspecified
            case "NUMERICAL": self = .numerical
            case "FRESHNESS": self = .freshness
            default: self = .unknownStringValue(stringValue)
            }
          }

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

        /// The interpolation type to be applied. Default will be linear
        /// (Piecewise Linear).
        public enum InterpolationType: Codable, Equatable, Sendable {
          /// Interpolation type is unspecified. In this case, it defaults to
          /// Linear.
          case unspecified
          /// Piecewise linear interpolation will be applied.
          case linear
          /// 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 .linear: return 1
            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 "INTERPOLATION_TYPE_UNSPECIFIED"
            case .linear: return "LINEAR"
            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:InterpolationType/unknownStringValue(_:)).
          public init(stringValue: Swift.String) {
            switch stringValue {
            case "INTERPOLATION_TYPE_UNSPECIFIED": self = .unspecified
            case "LINEAR": self = .linear
            default: self = .unknownStringValue(stringValue)
            }
          }

          /// Initialize from an integer value.
          ///
          /// If the value is unknown, this initializes to [`unknownIntValue`](doc:InterpolationType/unknownIntValue(_:)).
          public init(intValue: Int) {
            switch intValue {
            case 0: self = .unspecified
            case 1: self = .linear
            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 .linear: return try container.encode(1)
            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.ces.v1.DataStoreTool.BoostSpec.ConditionBoostSpec.BoostControlSpec"
        }
        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.ces.v1.DataStoreTool.BoostSpec.ConditionBoostSpec"
      }
      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.ces.v1.DataStoreTool.BoostSpec"
    }
    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)
    }
  }

  /// If specified, will apply the given configuration for the specified
  /// modality.
  public struct ModalityConfig: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Required. The modality type.
    public var modalityType: DataStoreTool.ModalityConfig.ModalityType = DataStoreTool
      .ModalityConfig.ModalityType()

    /// Optional. The rewriter config.
    public var rewriterConfig: DataStoreTool.RewriterConfig? = nil

    /// Optional. The summarization config.
    public var summarizationConfig: DataStoreTool.SummarizationConfig? = nil

    /// Optional. The grounding configuration.
    public var groundingConfig: DataStoreTool.GroundingConfig? = nil

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

    /// The modality type.
    public enum ModalityType: Codable, Equatable, Sendable {
      /// Unspecified modality type.
      case unspecified
      /// Text modality.
      case text
      /// Audio modality.
      case audio
      /// 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 .text: return 1
        case .audio: 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 "MODALITY_TYPE_UNSPECIFIED"
        case .text: return "TEXT"
        case .audio: return "AUDIO"
        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:ModalityType/unknownStringValue(_:)).
      public init(stringValue: Swift.String) {
        switch stringValue {
        case "MODALITY_TYPE_UNSPECIFIED": self = .unspecified
        case "TEXT": self = .text
        case "AUDIO": self = .audio
        default: self = .unknownStringValue(stringValue)
        }
      }

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

  /// Filter parameter behavior.
  public enum FilterParameterBehavior: Codable, Equatable, Sendable {
    /// Default filter behavior.
    /// Include filter parameter for connector datastores.
    /// For the rest of the datastore types, the filter input parameter is
    /// omitted.
    case unspecified
    /// Always include filter parameter for all datastore types.
    case alwaysInclude
    /// The filter parameter is never included in the list of tool parameters,
    /// regardless of the datastore type.
    case neverInclude
    /// 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 .alwaysInclude: return 2
      case .neverInclude: 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 "FILTER_PARAMETER_BEHAVIOR_UNSPECIFIED"
      case .alwaysInclude: return "ALWAYS_INCLUDE"
      case .neverInclude: return "NEVER_INCLUDE"
      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:FilterParameterBehavior/unknownStringValue(_:)).
    public init(stringValue: Swift.String) {
      switch stringValue {
      case "FILTER_PARAMETER_BEHAVIOR_UNSPECIFIED": self = .unspecified
      case "ALWAYS_INCLUDE": self = .alwaysInclude
      case "NEVER_INCLUDE": self = .neverInclude
      default: self = .unknownStringValue(stringValue)
      }
    }

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

  /// Defines the search source, either a single DataStore or an Engine.
  public enum OneOf_SearchSource: Codable, Equatable, Sendable {
    /// Optional. Search within a single specific DataStore.
    indirect case dataStoreSource(DataStoreTool.DataStoreSource?)
    /// Optional. Search within an Engine (potentially across multiple
    /// DataStores).
    indirect case engineSource(DataStoreTool.EngineSource?)
  }

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