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

extension Clients {
  final class ConfigDeliveryLogging: ConfigDeliveryStub {
    let inner: any ConfigDeliveryStub
    let logger: Logger

    public init(_ inner: any ConfigDeliveryStub, logger: Logger) {
      var logger = logger
      logger[metadataKey: "gcp.artifact.id"] = "google-cloud-configdelivery-v1"
      logger[metadataKey: "gcp.client.service"] = "configdelivery"
      logger[metadataKey: "gcp.experimental.swift.client"] = "ConfigDelivery"
      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 listResourceBundles(
      request: ListResourceBundlesRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudConfigDeliveryV1.ListResourceBundlesResponse {
      try await self._intercept(
        request: request,
        options: options,
        name: "listResourceBundles",
        action: {
          (r: ListResourceBundlesRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudConfigDeliveryV1.ListResourceBundlesResponse
          in
          return try await self.inner.listResourceBundles(request: r, options: o)
        })
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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