// 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
  #if canImport(FoundationNetworking)
    import FoundationNetworking
  #endif
  import GoogleCloudWkt
  import GoogleLongRunning
  import GoogleRpc
  import GoogleCloudGax

  extension Clients {
    protocol SiteSearchEngineServiceStub {
      func getSiteSearchEngine(
        request: GetSiteSearchEngineRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDiscoveryEngineV1.SiteSearchEngine

      func createTargetSite(
        request: CreateTargetSiteRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation

      func batchCreateTargetSites(
        request: BatchCreateTargetSitesRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation

      func getTargetSite(
        request: GetTargetSiteRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDiscoveryEngineV1.TargetSite

      func updateTargetSite(
        request: UpdateTargetSiteRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation

      func deleteTargetSite(
        request: DeleteTargetSiteRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation

      func listTargetSites(
        request: ListTargetSitesRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDiscoveryEngineV1.ListTargetSitesResponse

      func createSitemap(
        request: CreateSitemapRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation

      func deleteSitemap(
        request: DeleteSitemapRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation

      func fetchSitemaps(
        request: FetchSitemapsRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDiscoveryEngineV1.FetchSitemapsResponse

      func enableAdvancedSiteSearch(
        request: EnableAdvancedSiteSearchRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation

      func disableAdvancedSiteSearch(
        request: DisableAdvancedSiteSearchRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation

      func recrawlUris(
        request: RecrawlUrisRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation

      func batchVerifyTargetSites(
        request: BatchVerifyTargetSitesRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation

      func fetchDomainVerificationStatus(
        request: FetchDomainVerificationStatusRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDiscoveryEngineV1.FetchDomainVerificationStatusResponse

      func listOperations(
        request: GoogleLongRunning.ListOperationsRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.ListOperationsResponse

      func getOperation(
        request: GoogleLongRunning.GetOperationRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation

      func cancelOperation(
        request: GoogleLongRunning.CancelOperationRequest, options: GoogleCloudGax.RequestOptions
      ) async throws
    }

    class SiteSearchEngineServiceTransport: SiteSearchEngineServiceStub {
      let inner: GoogleCloudGax.HTTPClient

      public init(_ options: GoogleCloudGax.ClientOptions = .init()) throws {
        self.inner = try GoogleCloudGax.HTTPClient(
          from: options, withDefaultEndpoint: "https://discoveryengine.googleapis.com")
      }

      public func getSiteSearchEngine(
        request: GetSiteSearchEngineRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDiscoveryEngineV1.SiteSearchEngine {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.name as Swift.String?, !pathVariable0.isEmpty else {
            throw GoogleCloudGax.RequestError.binding("'request.name' is not set or is empty")
          }
          return "/v1/\(pathVariable0)"
        }()
        let query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "GET"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleCloudDiscoveryEngineV1.SiteSearchEngine.self, from: data)
      }

      public func createTargetSite(
        request: CreateTargetSiteRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.parent as Swift.String?, !pathVariable0.isEmpty else {
            throw GoogleCloudGax.RequestError.binding("'request.parent' is not set or is empty")
          }
          return "/v1/\(pathVariable0)/targetSites"
        }()
        let query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "POST"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        if let body = request.targetSite {
          req.setValue("application/json", forHTTPHeaderField: "Content-Type")
          req.httpBody = try JSONEncoder().encode(body)
        }
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleLongRunning.Operation.self, from: data)
      }

      public func batchCreateTargetSites(
        request: BatchCreateTargetSitesRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.parent as Swift.String?, !pathVariable0.isEmpty else {
            throw GoogleCloudGax.RequestError.binding("'request.parent' is not set or is empty")
          }
          return "/v1/\(pathVariable0)/targetSites:batchCreate"
        }()
        let query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "POST"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        req.setValue("application/json", forHTTPHeaderField: "Content-Type")
        req.httpBody = try JSONEncoder().encode(request)
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleLongRunning.Operation.self, from: data)
      }

      public func getTargetSite(
        request: GetTargetSiteRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDiscoveryEngineV1.TargetSite {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.name as Swift.String?, !pathVariable0.isEmpty else {
            throw GoogleCloudGax.RequestError.binding("'request.name' is not set or is empty")
          }
          return "/v1/\(pathVariable0)"
        }()
        let query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "GET"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleCloudDiscoveryEngineV1.TargetSite.self, from: data)
      }

      public func updateTargetSite(
        request: UpdateTargetSiteRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.targetSite.map({ $0.name }), !pathVariable0.isEmpty
          else {
            throw GoogleCloudGax.RequestError.binding(
              "'request.target_site.name' is not set or is empty")
          }
          return "/v1/\(pathVariable0)"
        }()
        let query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "PATCH"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        if let body = request.targetSite {
          req.setValue("application/json", forHTTPHeaderField: "Content-Type")
          req.httpBody = try JSONEncoder().encode(body)
        }
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleLongRunning.Operation.self, from: data)
      }

      public func deleteTargetSite(
        request: DeleteTargetSiteRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.name as Swift.String?, !pathVariable0.isEmpty else {
            throw GoogleCloudGax.RequestError.binding("'request.name' is not set or is empty")
          }
          return "/v1/\(pathVariable0)"
        }()
        let query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "DELETE"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleLongRunning.Operation.self, from: data)
      }

      public func listTargetSites(
        request: ListTargetSitesRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDiscoveryEngineV1.ListTargetSitesResponse {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.parent as Swift.String?, !pathVariable0.isEmpty else {
            throw GoogleCloudGax.RequestError.binding("'request.parent' is not set or is empty")
          }
          return "/v1/\(pathVariable0)/targetSites"
        }()
        var query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        let encoder = GoogleCloudGax.QueryParameterEncoder()
        query.append(contentsOf: try encoder.encode(request.pageSize, prefix: "pageSize"))
        query.append(contentsOf: try encoder.encode(request.pageToken, prefix: "pageToken"))
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "GET"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleCloudDiscoveryEngineV1.ListTargetSitesResponse.self, from: data)
      }

      public func createSitemap(
        request: CreateSitemapRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.parent as Swift.String?, !pathVariable0.isEmpty else {
            throw GoogleCloudGax.RequestError.binding("'request.parent' is not set or is empty")
          }
          return "/v1/\(pathVariable0)/sitemaps"
        }()
        let query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "POST"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        if let body = request.sitemap {
          req.setValue("application/json", forHTTPHeaderField: "Content-Type")
          req.httpBody = try JSONEncoder().encode(body)
        }
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleLongRunning.Operation.self, from: data)
      }

      public func deleteSitemap(
        request: DeleteSitemapRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.name as Swift.String?, !pathVariable0.isEmpty else {
            throw GoogleCloudGax.RequestError.binding("'request.name' is not set or is empty")
          }
          return "/v1/\(pathVariable0)"
        }()
        let query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "DELETE"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleLongRunning.Operation.self, from: data)
      }

      public func fetchSitemaps(
        request: FetchSitemapsRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDiscoveryEngineV1.FetchSitemapsResponse {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.parent as Swift.String?, !pathVariable0.isEmpty else {
            throw GoogleCloudGax.RequestError.binding("'request.parent' is not set or is empty")
          }
          return "/v1/\(pathVariable0)/sitemaps:fetch"
        }()
        var query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        let encoder = GoogleCloudGax.QueryParameterEncoder()
        query.append(contentsOf: try encoder.encode(request.matcher, prefix: "matcher"))
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "GET"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleCloudDiscoveryEngineV1.FetchSitemapsResponse.self, from: data)
      }

      public func enableAdvancedSiteSearch(
        request: EnableAdvancedSiteSearchRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.siteSearchEngine as Swift.String?,
            !pathVariable0.isEmpty
          else {
            throw GoogleCloudGax.RequestError.binding(
              "'request.site_search_engine' is not set or is empty")
          }
          return "/v1/\(pathVariable0):enableAdvancedSiteSearch"
        }()
        let query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "POST"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        req.setValue("application/json", forHTTPHeaderField: "Content-Type")
        req.httpBody = try JSONEncoder().encode(request)
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleLongRunning.Operation.self, from: data)
      }

      public func disableAdvancedSiteSearch(
        request: DisableAdvancedSiteSearchRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.siteSearchEngine as Swift.String?,
            !pathVariable0.isEmpty
          else {
            throw GoogleCloudGax.RequestError.binding(
              "'request.site_search_engine' is not set or is empty")
          }
          return "/v1/\(pathVariable0):disableAdvancedSiteSearch"
        }()
        let query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "POST"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        req.setValue("application/json", forHTTPHeaderField: "Content-Type")
        req.httpBody = try JSONEncoder().encode(request)
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleLongRunning.Operation.self, from: data)
      }

      public func recrawlUris(
        request: RecrawlUrisRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.siteSearchEngine as Swift.String?,
            !pathVariable0.isEmpty
          else {
            throw GoogleCloudGax.RequestError.binding(
              "'request.site_search_engine' is not set or is empty")
          }
          return "/v1/\(pathVariable0):recrawlUris"
        }()
        let query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "POST"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        req.setValue("application/json", forHTTPHeaderField: "Content-Type")
        req.httpBody = try JSONEncoder().encode(request)
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleLongRunning.Operation.self, from: data)
      }

      public func batchVerifyTargetSites(
        request: BatchVerifyTargetSitesRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.parent as Swift.String?, !pathVariable0.isEmpty else {
            throw GoogleCloudGax.RequestError.binding("'request.parent' is not set or is empty")
          }
          return "/v1/\(pathVariable0):batchVerifyTargetSites"
        }()
        let query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "POST"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        req.setValue("application/json", forHTTPHeaderField: "Content-Type")
        req.httpBody = try JSONEncoder().encode(request)
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleLongRunning.Operation.self, from: data)
      }

      public func fetchDomainVerificationStatus(
        request: FetchDomainVerificationStatusRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDiscoveryEngineV1.FetchDomainVerificationStatusResponse {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.siteSearchEngine as Swift.String?,
            !pathVariable0.isEmpty
          else {
            throw GoogleCloudGax.RequestError.binding(
              "'request.site_search_engine' is not set or is empty")
          }
          return "/v1/\(pathVariable0):fetchDomainVerificationStatus"
        }()
        var query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        let encoder = GoogleCloudGax.QueryParameterEncoder()
        query.append(contentsOf: try encoder.encode(request.pageSize, prefix: "pageSize"))
        query.append(contentsOf: try encoder.encode(request.pageToken, prefix: "pageToken"))
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "GET"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleCloudDiscoveryEngineV1.FetchDomainVerificationStatusResponse.self, from: data)
      }

      public func listOperations(
        request: GoogleLongRunning.ListOperationsRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.ListOperationsResponse {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.name as Swift.String?, !pathVariable0.isEmpty else {
            throw GoogleCloudGax.RequestError.binding("'request.name' is not set or is empty")
          }
          return "/v1/\(pathVariable0)/operations"
        }()
        var query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        let encoder = GoogleCloudGax.QueryParameterEncoder()
        query.append(contentsOf: try encoder.encode(request.filter, prefix: "filter"))
        query.append(contentsOf: try encoder.encode(request.pageSize, prefix: "pageSize"))
        query.append(contentsOf: try encoder.encode(request.pageToken, prefix: "pageToken"))
        query.append(
          contentsOf: try encoder.encode(
            request.returnPartialSuccess, prefix: "returnPartialSuccess"))
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "GET"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleLongRunning.ListOperationsResponse.self, from: data)
      }

      public func getOperation(
        request: GoogleLongRunning.GetOperationRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.name as Swift.String?, !pathVariable0.isEmpty else {
            throw GoogleCloudGax.RequestError.binding("'request.name' is not set or is empty")
          }
          return "/v1/\(pathVariable0)"
        }()
        let query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "GET"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleLongRunning.Operation.self, from: data)
      }

      public func cancelOperation(
        request: GoogleLongRunning.CancelOperationRequest, options: GoogleCloudGax.RequestOptions
      ) async throws {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.name as Swift.String?, !pathVariable0.isEmpty else {
            throw GoogleCloudGax.RequestError.binding("'request.name' is not set or is empty")
          }
          return "/v1/\(pathVariable0):cancel"
        }()
        let query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "POST"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        req.setValue("application/json", forHTTPHeaderField: "Content-Type")
        req.httpBody = try JSONEncoder().encode(request)
        _ = try await self.inner.rpc(for: req).get()
      }
    }
  }
#endif
