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

    public init(_ inner: any RepositoryManagerStub, logger: Logger) {
      var logger = logger
      logger[metadataKey: "gcp.artifact.id"] = "google-devtools-cloudbuild-v2"
      logger[metadataKey: "gcp.client.service"] = "cloudbuild"
      logger[metadataKey: "gcp.experimental.swift.client"] = "RepositoryManager"
      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 createConnection(
      request: CreateConnectionRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      try await self._intercept(
        request: request,
        options: options,
        name: "createConnection",
        action: {
          (r: CreateConnectionRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleLongRunning.Operation
          in
          return try await self.inner.createConnection(request: r, options: o)
        })
    }

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

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

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

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

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

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

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

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

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

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

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

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

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