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

extension Clients {
  final class ApiHubLogging: ApiHubStub {
    let inner: any ApiHubStub
    let logger: Logger

    public init(_ inner: any ApiHubStub, logger: Logger) {
      var logger = logger
      logger[metadataKey: "gcp.artifact.id"] = "google-cloud-apihub-v1"
      logger[metadataKey: "gcp.client.service"] = "apihub"
      logger[metadataKey: "gcp.experimental.swift.client"] = "ApiHub"
      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 createApi(
      request: CreateApiRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudApiHubV1.Api {
      try await self._intercept(
        request: request,
        options: options,
        name: "createApi",
        action: {
          (r: CreateApiRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudApiHubV1.Api
          in
          return try await self.inner.createApi(request: r, options: o)
        })
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    public func listOperations(
      request: GoogleLongRunning.ListOperationsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.ListOperationsResponse {
      try await self._intercept(
        request: request,
        options: options,
        name: "listOperations",
        action: {
          (r: GoogleLongRunning.ListOperationsRequest, o: GoogleCloudGax.RequestOptions)
            async throws -> GoogleLongRunning.ListOperationsResponse
          in
          return try await self.inner.listOperations(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)
        })
    }

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

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