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

extension Clients {
  final class DomainsLogging: DomainsStub {
    let inner: any DomainsStub
    let logger: Logger

    public init(_ inner: any DomainsStub, logger: Logger) {
      var logger = logger
      logger[metadataKey: "gcp.artifact.id"] = "google-cloud-domains-v1"
      logger[metadataKey: "gcp.client.service"] = "domains"
      logger[metadataKey: "gcp.experimental.swift.client"] = "Domains"
      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 searchDomains(
      request: SearchDomainsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDomainsV1.SearchDomainsResponse {
      try await self._intercept(
        request: request,
        options: options,
        name: "searchDomains",
        action: {
          (r: SearchDomainsRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudDomainsV1.SearchDomainsResponse
          in
          return try await self.inner.searchDomains(request: r, options: o)
        })
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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