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

  /// Request message for
  /// [SiteSearchEngineService.FetchSitemaps][google.cloud.discoveryengine.v1.SiteSearchEngineService.FetchSitemaps]
  /// method.
  ///
  /// [google.cloud.discoveryengine.v1.SiteSearchEngineService.FetchSitemaps]: <doc:SiteSearchEngineService/fetchSitemaps(request:)>
  public struct FetchSitemapsRequest: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Required. Parent resource name of the
    /// [SiteSearchEngine][google.cloud.discoveryengine.v1.SiteSearchEngine], such
    /// as `projects/*/locations/*/collections/*/dataStores/*/siteSearchEngine`.
    ///
    /// [google.cloud.discoveryengine.v1.SiteSearchEngine]: <doc:SiteSearchEngine>
    public var parent: Swift.String = Swift.String()

    /// Optional. If specified, fetches the matching
    /// [Sitemap][google.cloud.discoveryengine.v1.Sitemap]s. If not specified,
    /// fetches all [Sitemap][google.cloud.discoveryengine.v1.Sitemap]s in the
    /// [DataStore][google.cloud.discoveryengine.v1.DataStore].
    ///
    /// [google.cloud.discoveryengine.v1.DataStore]: <doc:DataStore>
    /// [google.cloud.discoveryengine.v1.Sitemap]: <doc:Sitemap>
    public var matcher: FetchSitemapsRequest.Matcher? = nil

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

    /// Matcher for the [Sitemap][google.cloud.discoveryengine.v1.Sitemap]s by
    /// their uris.
    ///
    /// [google.cloud.discoveryengine.v1.Sitemap]: <doc:Sitemap>
    public struct UrisMatcher: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// The [Sitemap][google.cloud.discoveryengine.v1.Sitemap] uris.
      ///
      /// [google.cloud.discoveryengine.v1.Sitemap]: <doc:Sitemap>
      public var uris: [Swift.String] = []

      /// Initialize a new instance of `UrisMatcher`.
      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 = UrisMatcher().with { $0.uris = ... }
      /// ```
      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.discoveryengine.v1.FetchSitemapsRequest.UrisMatcher"
      }
      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)
      }
    }

    /// Matcher for the [Sitemap][google.cloud.discoveryengine.v1.Sitemap]s.
    /// Currently only supports uris matcher.
    ///
    /// [google.cloud.discoveryengine.v1.Sitemap]: <doc:Sitemap>
    public struct Matcher: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Matcher for the [Sitemap][google.cloud.discoveryengine.v1.Sitemap]s.
      ///
      /// [google.cloud.discoveryengine.v1.Sitemap]: <doc:Sitemap>
      public var matcher: OneOf_Matcher? = nil

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

      public init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)

        var matcher: OneOf_Matcher? = nil
        let matcherCheckAndSet = {
          if matcher != nil {
            throw DecodingError.dataCorrupted(
              DecodingError.Context(
                codingPath: decoder.codingPath,
                debugDescription: "Multiple values set for oneof 'matcher'"))
          }
          matcher = $0
        }
        if let urisMatcher = try container.decodeIfPresent(
          FetchSitemapsRequest.UrisMatcher?.self, forKey: .urisMatcher)
        {
          try matcherCheckAndSet(.urisMatcher(urisMatcher))
        }
        self.matcher = matcher
      }

      public func encode(to encoder: Encoder) throws {
        var container = encoder.container(keyedBy: CodingKeys.self)

        if let choice = self.matcher {
          switch choice {
          case .urisMatcher(let value):
            try container.encode(value, forKey: .urisMatcher)
          }
        }
      }

      /// Matcher for the [Sitemap][google.cloud.discoveryengine.v1.Sitemap]s.
      ///
      /// [google.cloud.discoveryengine.v1.Sitemap]: <doc:Sitemap>
      public enum OneOf_Matcher: Codable, Equatable, Sendable {
        /// Matcher by sitemap URIs.
        indirect case urisMatcher(FetchSitemapsRequest.UrisMatcher?)
      }

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