// 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 GoogleCloudGax
import struct Logging.Logger

extension Clients {
  final class EnterpriseKnowledgeGraphServiceLogging: EnterpriseKnowledgeGraphServiceStub {
    let inner: any EnterpriseKnowledgeGraphServiceStub
    let logger: Logger

    public init(_ inner: any EnterpriseKnowledgeGraphServiceStub, logger: Logger) {
      var logger = logger
      logger[metadataKey: "gcp.artifact.id"] = "google-cloud-enterpriseknowledgegraph-v1"
      logger[metadataKey: "gcp.client.service"] = "enterpriseknowledgegraph"
      logger[metadataKey: "gcp.experimental.swift.client"] = "EnterpriseKnowledgeGraphService"
      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 createEntityReconciliationJob(
      request: CreateEntityReconciliationJobRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudEnterpriseKnowledgeGraphV1.EntityReconciliationJob {
      try await self._intercept(
        request: request,
        options: options,
        name: "createEntityReconciliationJob",
        action: {
          (r: CreateEntityReconciliationJobRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudEnterpriseKnowledgeGraphV1.EntityReconciliationJob
          in
          return try await self.inner.createEntityReconciliationJob(request: r, options: o)
        })
    }

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

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

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

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

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

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

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

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