// 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 WorkloadManagerLogging: WorkloadManagerStub {
    let inner: any WorkloadManagerStub
    let logger: Logger

    public init(_ inner: any WorkloadManagerStub, logger: Logger) {
      var logger = logger
      logger[metadataKey: "gcp.artifact.id"] = "google-cloud-workloadmanager-v1"
      logger[metadataKey: "gcp.client.service"] = "workloadmanager"
      logger[metadataKey: "gcp.experimental.swift.client"] = "WorkloadManager"
      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 listEvaluations(
      request: ListEvaluationsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudWorkloadManagerV1.ListEvaluationsResponse {
      try await self._intercept(
        request: request,
        options: options,
        name: "listEvaluations",
        action: {
          (r: ListEvaluationsRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudWorkloadManagerV1.ListEvaluationsResponse
          in
          return try await self.inner.listEvaluations(request: r, options: o)
        })
    }

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

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

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

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

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

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

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

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

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

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

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