// 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 GenAiCacheService || LlmUtilityService || PredictionService || VertexRagService
  import Foundation
  import GoogleCloudWkt

  /// Tool details that the model may use to generate response.
  ///
  /// A `Tool` is a piece of code that enables the system to interact with
  /// external systems to perform an action, or set of actions, outside of
  /// knowledge and scope of the model. A Tool object should contain exactly
  /// one type of Tool (e.g FunctionDeclaration, Retrieval or
  /// GoogleSearchRetrieval).
  public struct Tool: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Optional. Function tool type.
    /// One or more function declarations to be passed to the model along with the
    /// current user query. Model may decide to call a subset of these functions
    /// by populating [FunctionCall][google.cloud.aiplatform.v1.Part.function_call]
    /// in the response. User should provide a
    /// [FunctionResponse][google.cloud.aiplatform.v1.Part.function_response] for
    /// each function call in the next turn. Based on the function responses, Model
    /// will generate the final response back to the user. Maximum 128 function
    /// declarations can be provided.
    ///
    /// [google.cloud.aiplatform.v1.Part.function_call]: <doc:Part/functionCall>
    /// [google.cloud.aiplatform.v1.Part.function_response]: <doc:Part/functionResponse>
    public var functionDeclarations: [FunctionDeclaration] = []

    /// Optional. Retrieval tool type.
    /// System will always execute the provided retrieval tool(s) to get external
    /// knowledge to answer the prompt. Retrieval results are presented to the
    /// model for generation.
    public var retrieval: Retrieval? = nil

    /// Optional. GoogleSearch tool type.
    /// Tool to support Google Search in Model. Powered by Google.
    public var googleSearch: Tool.GoogleSearch? = nil

    /// Optional. GoogleSearchRetrieval tool type.
    /// Specialized retrieval tool that is powered by Google search.
    public var googleSearchRetrieval: GoogleSearchRetrieval? = nil

    /// Optional. GoogleMaps tool type.
    /// Tool to support Google Maps in Model.
    public var googleMaps: GoogleMaps? = nil

    /// Optional. Tool to support searching public web data, powered by Vertex AI
    /// Search and Sec4 compliance.
    public var enterpriseWebSearch: EnterpriseWebSearch? = nil

    /// Optional. If specified, Vertex AI will use Parallel.ai to search for
    /// information to answer user queries. The search results will be grounded on
    /// Parallel.ai and presented to the model for response generation
    public var parallelAiSearch: Tool.ParallelAiSearch? = nil

    /// Optional. Uses Exa.ai to search for information to
    /// answer user queries. The search results will be grounded on Exa.ai
    /// and presented to the model for response generation
    public var exaAiSearch: Tool.ExaAiSearch? = nil

    /// Optional. CodeExecution tool type.
    /// Enables the model to execute code as part of generation.
    public var codeExecution: Tool.CodeExecution? = nil

    /// Optional. Tool to support URL context retrieval.
    public var urlContext: UrlContext? = nil

    /// Optional. Tool to support the model interacting directly with the computer.
    /// If enabled, it automatically populates computer-use specific Function
    /// Declarations.
    public var computerUse: Tool.ComputerUse? = nil

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

    /// GoogleSearch tool type.
    /// Tool to support Google Search in Model. Powered by Google.
    public struct GoogleSearch: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Optional. List of domains to be excluded from the search results.
      /// The default limit is 2000 domains.
      /// Example: ["amazon.com", "facebook.com"].
      public var excludeDomains: [Swift.String] = []

      /// Optional. Sites with confidence level chosen & above this value will be
      /// blocked from the search results.
      public var blockingConfidence: Tool.PhishBlockThreshold? = nil

      /// Initialize a new instance of `GoogleSearch`.
      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 = GoogleSearch().with { $0.excludeDomains = ... }
      /// ```
      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.aiplatform.v1.Tool.GoogleSearch"
      }
      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)
      }
    }

    /// ParallelAiSearch tool type.
    /// A tool that uses the Parallel.ai search engine for grounding.
    public struct ParallelAiSearch: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Optional. The API key for ParallelAiSearch.
      /// If an API key is not provided, the system will attempt to verify access
      /// by checking for an active Parallel.ai subscription through the Google
      /// Cloud Marketplace.
      /// See https://docs.parallel.ai/search/search-quickstart for more details.
      public var apiKey: Swift.String = Swift.String()

      /// Optional. Custom configs for ParallelAiSearch.
      /// This field can be used to pass any parameter from the Parallel.ai
      /// Search API.
      /// See the Parallel.ai documentation for the full list of available
      /// parameters and their usage:
      /// https://docs.parallel.ai/api-reference/search-beta/search
      /// Currently only `source_policy`, `excerpts`, `max_results`, `mode`,
      /// `fetch_policy` can be set via this field. For example:
      /// {
      ///   "source_policy": {
      ///     "include_domains": ["google.com", "wikipedia.org"],
      ///     "exclude_domains": ["example.com"]
      ///   },
      ///   "fetch_policy": {
      ///     "max_age_seconds": 3600
      ///   }
      /// }
      public var customConfigs: GoogleCloudWkt.Struct? = nil

      /// Initialize a new instance of `ParallelAiSearch`.
      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 = ParallelAiSearch().with { $0.apiKey = ... }
      /// ```
      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.aiplatform.v1.Tool.ParallelAiSearch"
      }
      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)
      }
    }

    /// ExaAiSearch tool type.
    /// A tool that uses the Exa.ai search engine for grounding.
    public struct ExaAiSearch: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Required. The API key for ExaAiSearch.
      public var apiKey: Swift.String = Swift.String()

      /// Optional. This field can be used to pass any parameter from the Exa.ai
      /// Search API.
      public var customConfigs: GoogleCloudWkt.Struct? = nil

      /// Initialize a new instance of `ExaAiSearch`.
      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 = ExaAiSearch().with { $0.apiKey = ... }
      /// ```
      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.aiplatform.v1.Tool.ExaAiSearch"
      }
      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)
      }
    }

    /// Tool that executes code generated by the model, and automatically returns
    /// the result to the model.
    ///
    /// See also [ExecutableCode]and [CodeExecutionResult] which are input and
    /// output to this tool.
    public struct CodeExecution: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Initialize a new instance of `CodeExecution`.
      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 = CodeExecution().with { $0.<placeholder> = ... }
      /// ```
      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.aiplatform.v1.Tool.CodeExecution"
      }
      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)
      }
    }

    /// Tool to support computer use.
    public struct ComputerUse: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Required. The environment being operated.
      public var environment: Tool.ComputerUse.Environment = Tool.ComputerUse.Environment()

      /// Optional. By default, [predefined
      /// functions](https://cloud.google.com/vertex-ai/generative-ai/docs/computer-use#supported-actions)
      /// are included in the final model call. Some of them can be explicitly
      /// excluded from being automatically included. This can serve two purposes:
      /// 1. Using a more restricted / different action space.
      /// 2. Improving the definitions / instructions of predefined functions.
      public var excludedPredefinedFunctions: [Swift.String] = []

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

      /// Represents the environment being operated, such as a web browser.
      public enum Environment: Codable, Equatable, Sendable {
        /// Defaults to browser.
        case unspecified
        /// Operates in a web browser.
        case browser
        /// 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 .browser: 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 "ENVIRONMENT_UNSPECIFIED"
          case .browser: return "ENVIRONMENT_BROWSER"
          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:Environment/unknownStringValue(_:)).
        public init(stringValue: Swift.String) {
          switch stringValue {
          case "ENVIRONMENT_UNSPECIFIED": self = .unspecified
          case "ENVIRONMENT_BROWSER": self = .browser
          default: self = .unknownStringValue(stringValue)
          }
        }

        /// Initialize from an integer value.
        ///
        /// If the value is unknown, this initializes to [`unknownIntValue`](doc:Environment/unknownIntValue(_:)).
        public init(intValue: Int) {
          switch intValue {
          case 0: self = .unspecified
          case 1: self = .browser
          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 .browser: 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.aiplatform.v1.Tool.ComputerUse"
      }
      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)
      }
    }

    /// These are available confidence level user can set to block malicious urls
    /// with chosen confidence and above. For understanding different confidence of
    /// webrisk, please refer to
    /// https://cloud.google.com/web-risk/docs/reference/rpc/google.cloud.webrisk.v1eap1#confidencelevel
    public enum PhishBlockThreshold: Codable, Equatable, Sendable {
      /// Defaults to unspecified.
      case unspecified
      /// Blocks Low and above confidence URL that is risky.
      case blockLowAndAbove
      /// Blocks Medium and above confidence URL that is risky.
      case blockMediumAndAbove
      /// Blocks High and above confidence URL that is risky.
      case blockHighAndAbove
      /// Blocks Higher and above confidence URL that is risky.
      case blockHigherAndAbove
      /// Blocks Very high and above confidence URL that is risky.
      case blockVeryHighAndAbove
      /// Blocks Extremely high confidence URL that is risky.
      case blockOnlyExtremelyHigh
      /// 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 .blockLowAndAbove: return 30
        case .blockMediumAndAbove: return 40
        case .blockHighAndAbove: return 50
        case .blockHigherAndAbove: return 55
        case .blockVeryHighAndAbove: return 60
        case .blockOnlyExtremelyHigh: return 100
        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 "PHISH_BLOCK_THRESHOLD_UNSPECIFIED"
        case .blockLowAndAbove: return "BLOCK_LOW_AND_ABOVE"
        case .blockMediumAndAbove: return "BLOCK_MEDIUM_AND_ABOVE"
        case .blockHighAndAbove: return "BLOCK_HIGH_AND_ABOVE"
        case .blockHigherAndAbove: return "BLOCK_HIGHER_AND_ABOVE"
        case .blockVeryHighAndAbove: return "BLOCK_VERY_HIGH_AND_ABOVE"
        case .blockOnlyExtremelyHigh: return "BLOCK_ONLY_EXTREMELY_HIGH"
        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:PhishBlockThreshold/unknownStringValue(_:)).
      public init(stringValue: Swift.String) {
        switch stringValue {
        case "PHISH_BLOCK_THRESHOLD_UNSPECIFIED": self = .unspecified
        case "BLOCK_LOW_AND_ABOVE": self = .blockLowAndAbove
        case "BLOCK_MEDIUM_AND_ABOVE": self = .blockMediumAndAbove
        case "BLOCK_HIGH_AND_ABOVE": self = .blockHighAndAbove
        case "BLOCK_HIGHER_AND_ABOVE": self = .blockHigherAndAbove
        case "BLOCK_VERY_HIGH_AND_ABOVE": self = .blockVeryHighAndAbove
        case "BLOCK_ONLY_EXTREMELY_HIGH": self = .blockOnlyExtremelyHigh
        default: self = .unknownStringValue(stringValue)
        }
      }

      /// Initialize from an integer value.
      ///
      /// If the value is unknown, this initializes to [`unknownIntValue`](doc:PhishBlockThreshold/unknownIntValue(_:)).
      public init(intValue: Int) {
        switch intValue {
        case 0: self = .unspecified
        case 30: self = .blockLowAndAbove
        case 40: self = .blockMediumAndAbove
        case 50: self = .blockHighAndAbove
        case 55: self = .blockHigherAndAbove
        case 60: self = .blockVeryHighAndAbove
        case 100: self = .blockOnlyExtremelyHigh
        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 .blockLowAndAbove: return try container.encode(30)
        case .blockMediumAndAbove: return try container.encode(40)
        case .blockHighAndAbove: return try container.encode(50)
        case .blockHigherAndAbove: return try container.encode(55)
        case .blockVeryHighAndAbove: return try container.encode(60)
        case .blockOnlyExtremelyHigh: return try container.encode(100)
        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.aiplatform.v1.Tool"
    }
    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
