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

extension Clients {
  final class WorkstationsLogging: WorkstationsStub {
    let inner: any WorkstationsStub
    let logger: Logger

    public init(_ inner: any WorkstationsStub, logger: Logger) {
      var logger = logger
      logger[metadataKey: "gcp.artifact.id"] = "google-cloud-workstations-v1"
      logger[metadataKey: "gcp.client.service"] = "workstations"
      logger[metadataKey: "gcp.experimental.swift.client"] = "Workstations"
      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 getWorkstationCluster(
      request: GetWorkstationClusterRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudWorkstationsV1.WorkstationCluster {
      try await self._intercept(
        request: request,
        options: options,
        name: "getWorkstationCluster",
        action: {
          (r: GetWorkstationClusterRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudWorkstationsV1.WorkstationCluster
          in
          return try await self.inner.getWorkstationCluster(request: r, options: o)
        })
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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