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

  /// Metadata returned to client when grounding is enabled.
  public struct GroundingMetadata: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Optional. Web search queries for the following-up web search.
    public var webSearchQueries: [Swift.String] = []

    /// Optional. Google search entry for the following-up web searches.
    public var searchEntryPoint: SearchEntryPoint? = nil

    /// Optional. The queries that were executed by the retrieval tools.
    /// This field is populated only when the grounding source is a retrieval tool,
    /// such as Vertex AI Search.
    public var retrievalQueries: [Swift.String] = []

    /// List of supporting references retrieved from specified grounding source.
    public var groundingChunks: [GroundingChunk] = []

    /// Optional. List of grounding support.
    public var groundingSupports: [GroundingSupport] = []

    /// Optional. Output only. Retrieval metadata.
    public var retrievalMetadata: RetrievalMetadata? = nil

    /// Optional. Output only. Resource name of the Google Maps widget context
    /// token to be used with the PlacesContextElement widget to render contextual
    /// data. This is populated only for Google Maps grounding.
    public var googleMapsWidgetContextToken: Swift.String? = nil

    /// List of source flagging uris. This is currently populated only for Google
    /// Maps grounding.
    public var sourceFlaggingUris: [GroundingMetadata.SourceFlaggingUri] = []

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

    /// Source content flagging uri for a place or review. This is currently
    /// populated only for Google Maps grounding.
    public struct SourceFlaggingUri: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Id of the place or review.
      public var sourceId: Swift.String = Swift.String()

      /// A link where users can flag a problem with the source (place or review).
      /// (-- The link is generated by Google and it does not contain
      /// information from the user query. It may contain information of the
      /// content it is flagging, which can be used to identify places. --)
      public var flagContentUri: Swift.String = Swift.String()

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