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

extension Clients {
  final class ProductSearchLogging: ProductSearchStub {
    let inner: any ProductSearchStub
    let logger: Logger

    public init(_ inner: any ProductSearchStub, logger: Logger) {
      var logger = logger
      logger[metadataKey: "gcp.artifact.id"] = "google-cloud-vision-v1"
      logger[metadataKey: "gcp.client.service"] = "vision"
      logger[metadataKey: "gcp.experimental.swift.client"] = "ProductSearch"
      self.inner = inner
      self.logger = logger
    }

    func _intercept<Input, Output>(
      request: Input,
      options: GoogleCloudGax.RequestOptions,
      name: Swift.String,
      action: (Input, GoogleCloudGax.RequestOptions) async throws -> Output,
    ) async throws -> Output {
      var logger = logger
      logger[metadataKey: "gcp.experimental.swift.request.id"] = "\(UUID())"
      logger[metadataKey: "gcp.experimental.swift.method"] = .string(name)
      logger.debug("enter  : \(request) \(options)")
      do {
        let output = try await action(request, options)
        logger.debug("success: \(request) \(options) \(output)")
        return output
      } catch let error {
        logger.debug("error  : \(request) \(options) \(error)")
        throw error
      }
    }

    public func createProductSet(
      request: CreateProductSetRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudVisionV1.ProductSet {
      try await self._intercept(
        request: request,
        options: options,
        name: "createProductSet",
        action: {
          (r: CreateProductSetRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudVisionV1.ProductSet
          in
          return try await self.inner.createProductSet(request: r, options: o)
        })
    }

    public func listProductSets(
      request: ListProductSetsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudVisionV1.ListProductSetsResponse {
      try await self._intercept(
        request: request,
        options: options,
        name: "listProductSets",
        action: {
          (r: ListProductSetsRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudVisionV1.ListProductSetsResponse
          in
          return try await self.inner.listProductSets(request: r, options: o)
        })
    }

    public func getProductSet(
      request: GetProductSetRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudVisionV1.ProductSet {
      try await self._intercept(
        request: request,
        options: options,
        name: "getProductSet",
        action: {
          (r: GetProductSetRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudVisionV1.ProductSet
          in
          return try await self.inner.getProductSet(request: r, options: o)
        })
    }

    public func updateProductSet(
      request: UpdateProductSetRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudVisionV1.ProductSet {
      try await self._intercept(
        request: request,
        options: options,
        name: "updateProductSet",
        action: {
          (r: UpdateProductSetRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudVisionV1.ProductSet
          in
          return try await self.inner.updateProductSet(request: r, options: o)
        })
    }

    public func deleteProductSet(
      request: DeleteProductSetRequest, options: GoogleCloudGax.RequestOptions
    ) async throws {
      try await self._intercept(
        request: request,
        options: options,
        name: "deleteProductSet",
        action: {
          (r: DeleteProductSetRequest, o: GoogleCloudGax.RequestOptions) async throws -> Void in
          return try await self.inner.deleteProductSet(request: r, options: o)
        })
    }

    public func createProduct(
      request: CreateProductRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudVisionV1.Product {
      try await self._intercept(
        request: request,
        options: options,
        name: "createProduct",
        action: {
          (r: CreateProductRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudVisionV1.Product
          in
          return try await self.inner.createProduct(request: r, options: o)
        })
    }

    public func listProducts(
      request: ListProductsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudVisionV1.ListProductsResponse {
      try await self._intercept(
        request: request,
        options: options,
        name: "listProducts",
        action: {
          (r: ListProductsRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudVisionV1.ListProductsResponse
          in
          return try await self.inner.listProducts(request: r, options: o)
        })
    }

    public func getProduct(
      request: GetProductRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudVisionV1.Product {
      try await self._intercept(
        request: request,
        options: options,
        name: "getProduct",
        action: {
          (r: GetProductRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudVisionV1.Product
          in
          return try await self.inner.getProduct(request: r, options: o)
        })
    }

    public func updateProduct(
      request: UpdateProductRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudVisionV1.Product {
      try await self._intercept(
        request: request,
        options: options,
        name: "updateProduct",
        action: {
          (r: UpdateProductRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudVisionV1.Product
          in
          return try await self.inner.updateProduct(request: r, options: o)
        })
    }

    public func deleteProduct(
      request: DeleteProductRequest, options: GoogleCloudGax.RequestOptions
    ) async throws {
      try await self._intercept(
        request: request,
        options: options,
        name: "deleteProduct",
        action: {
          (r: DeleteProductRequest, o: GoogleCloudGax.RequestOptions) async throws -> Void in
          return try await self.inner.deleteProduct(request: r, options: o)
        })
    }

    public func createReferenceImage(
      request: CreateReferenceImageRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudVisionV1.ReferenceImage {
      try await self._intercept(
        request: request,
        options: options,
        name: "createReferenceImage",
        action: {
          (r: CreateReferenceImageRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudVisionV1.ReferenceImage
          in
          return try await self.inner.createReferenceImage(request: r, options: o)
        })
    }

    public func deleteReferenceImage(
      request: DeleteReferenceImageRequest, options: GoogleCloudGax.RequestOptions
    ) async throws {
      try await self._intercept(
        request: request,
        options: options,
        name: "deleteReferenceImage",
        action: {
          (r: DeleteReferenceImageRequest, o: GoogleCloudGax.RequestOptions) async throws -> Void in
          return try await self.inner.deleteReferenceImage(request: r, options: o)
        })
    }

    public func listReferenceImages(
      request: ListReferenceImagesRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudVisionV1.ListReferenceImagesResponse {
      try await self._intercept(
        request: request,
        options: options,
        name: "listReferenceImages",
        action: {
          (r: ListReferenceImagesRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudVisionV1.ListReferenceImagesResponse
          in
          return try await self.inner.listReferenceImages(request: r, options: o)
        })
    }

    public func getReferenceImage(
      request: GetReferenceImageRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudVisionV1.ReferenceImage {
      try await self._intercept(
        request: request,
        options: options,
        name: "getReferenceImage",
        action: {
          (r: GetReferenceImageRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudVisionV1.ReferenceImage
          in
          return try await self.inner.getReferenceImage(request: r, options: o)
        })
    }

    public func addProductToProductSet(
      request: AddProductToProductSetRequest, options: GoogleCloudGax.RequestOptions
    ) async throws {
      try await self._intercept(
        request: request,
        options: options,
        name: "addProductToProductSet",
        action: {
          (r: AddProductToProductSetRequest, o: GoogleCloudGax.RequestOptions) async throws -> Void
          in
          return try await self.inner.addProductToProductSet(request: r, options: o)
        })
    }

    public func removeProductFromProductSet(
      request: RemoveProductFromProductSetRequest, options: GoogleCloudGax.RequestOptions
    ) async throws {
      try await self._intercept(
        request: request,
        options: options,
        name: "removeProductFromProductSet",
        action: {
          (r: RemoveProductFromProductSetRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> Void in
          return try await self.inner.removeProductFromProductSet(request: r, options: o)
        })
    }

    public func listProductsInProductSet(
      request: ListProductsInProductSetRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudVisionV1.ListProductsInProductSetResponse {
      try await self._intercept(
        request: request,
        options: options,
        name: "listProductsInProductSet",
        action: {
          (r: ListProductsInProductSetRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudVisionV1.ListProductsInProductSetResponse
          in
          return try await self.inner.listProductsInProductSet(request: r, options: o)
        })
    }

    public func importProductSets(
      request: ImportProductSetsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      try await self._intercept(
        request: request,
        options: options,
        name: "importProductSets",
        action: {
          (r: ImportProductSetsRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleLongRunning.Operation
          in
          return try await self.inner.importProductSets(request: r, options: o)
        })
    }

    public func purgeProducts(
      request: PurgeProductsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      try await self._intercept(
        request: request,
        options: options,
        name: "purgeProducts",
        action: {
          (r: PurgeProductsRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleLongRunning.Operation
          in
          return try await self.inner.purgeProducts(request: r, options: o)
        })
    }

    public func getOperation(
      request: GoogleLongRunning.GetOperationRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      try await self._intercept(
        request: request,
        options: options,
        name: "getOperation",
        action: {
          (r: GoogleLongRunning.GetOperationRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleLongRunning.Operation
          in
          return try await self.inner.getOperation(request: r, options: o)
        })
    }
  }
}
