// 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 GoogleIAMV1
import GoogleLongRunning
import GoogleRpc
import GoogleCloudGax

extension Clients {
  final class DataplexServiceRetry: DataplexServiceStub {
    let inner: any DataplexServiceStub
    let options: GoogleCloudGax.ClientOptions

    public init(_ inner: any DataplexServiceStub, options: GoogleCloudGax.ClientOptions) {
      self.inner = inner
      self.options = options
    }

    func _intercept<Input, Output>(
      request: Input,
      options: GoogleCloudGax.RequestOptions,
      idempotent: Swift.Bool,
      action: (Input, GoogleCloudGax.RequestOptions) async throws -> Output,
    ) async throws -> Output {
      let loop = GoogleCloudGax._RetryLoop(
        options: options, withDefault: self.options, idempotent: idempotent,
      )
      let attempt = { (attemptTimeout: Swift.Duration?) async throws -> Output in
        var attemptOptions = options
        attemptOptions.attemptTimeout = attemptTimeout
        return try await action(request, attemptOptions)
      }
      return try await loop.run(attempt: attempt)
    }

    public func createLake(
      request: CreateLakeRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: false,
        action: {
          (r: CreateLakeRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleLongRunning.Operation
          in
          return try await self.inner.createLake(request: r, options: o)
        })
    }

    public func updateLake(
      request: UpdateLakeRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: false,
        action: {
          (r: UpdateLakeRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleLongRunning.Operation
          in
          return try await self.inner.updateLake(request: r, options: o)
        })
    }

    public func deleteLake(
      request: DeleteLakeRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: false,
        action: {
          (r: DeleteLakeRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleLongRunning.Operation
          in
          return try await self.inner.deleteLake(request: r, options: o)
        })
    }

    public func listLakes(
      request: ListLakesRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDataplexV1.ListLakesResponse {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: ListLakesRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudDataplexV1.ListLakesResponse
          in
          return try await self.inner.listLakes(request: r, options: o)
        })
    }

    public func getLake(
      request: GetLakeRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDataplexV1.Lake {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: GetLakeRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudDataplexV1.Lake
          in
          return try await self.inner.getLake(request: r, options: o)
        })
    }

    public func listLakeActions(
      request: ListLakeActionsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDataplexV1.ListActionsResponse {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: ListLakeActionsRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudDataplexV1.ListActionsResponse
          in
          return try await self.inner.listLakeActions(request: r, options: o)
        })
    }

    public func createZone(
      request: CreateZoneRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: false,
        action: {
          (r: CreateZoneRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleLongRunning.Operation
          in
          return try await self.inner.createZone(request: r, options: o)
        })
    }

    public func updateZone(
      request: UpdateZoneRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: false,
        action: {
          (r: UpdateZoneRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleLongRunning.Operation
          in
          return try await self.inner.updateZone(request: r, options: o)
        })
    }

    public func deleteZone(
      request: DeleteZoneRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: false,
        action: {
          (r: DeleteZoneRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleLongRunning.Operation
          in
          return try await self.inner.deleteZone(request: r, options: o)
        })
    }

    public func listZones(
      request: ListZonesRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDataplexV1.ListZonesResponse {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: ListZonesRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudDataplexV1.ListZonesResponse
          in
          return try await self.inner.listZones(request: r, options: o)
        })
    }

    public func getZone(
      request: GetZoneRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDataplexV1.Zone {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: GetZoneRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudDataplexV1.Zone
          in
          return try await self.inner.getZone(request: r, options: o)
        })
    }

    public func listZoneActions(
      request: ListZoneActionsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDataplexV1.ListActionsResponse {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: ListZoneActionsRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudDataplexV1.ListActionsResponse
          in
          return try await self.inner.listZoneActions(request: r, options: o)
        })
    }

    public func createAsset(
      request: CreateAssetRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: false,
        action: {
          (r: CreateAssetRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleLongRunning.Operation
          in
          return try await self.inner.createAsset(request: r, options: o)
        })
    }

    public func updateAsset(
      request: UpdateAssetRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: false,
        action: {
          (r: UpdateAssetRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleLongRunning.Operation
          in
          return try await self.inner.updateAsset(request: r, options: o)
        })
    }

    public func deleteAsset(
      request: DeleteAssetRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: false,
        action: {
          (r: DeleteAssetRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleLongRunning.Operation
          in
          return try await self.inner.deleteAsset(request: r, options: o)
        })
    }

    public func listAssets(
      request: ListAssetsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDataplexV1.ListAssetsResponse {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: ListAssetsRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudDataplexV1.ListAssetsResponse
          in
          return try await self.inner.listAssets(request: r, options: o)
        })
    }

    public func getAsset(
      request: GetAssetRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDataplexV1.Asset {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: GetAssetRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudDataplexV1.Asset
          in
          return try await self.inner.getAsset(request: r, options: o)
        })
    }

    public func listAssetActions(
      request: ListAssetActionsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDataplexV1.ListActionsResponse {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: ListAssetActionsRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudDataplexV1.ListActionsResponse
          in
          return try await self.inner.listAssetActions(request: r, options: o)
        })
    }

    public func createTask(
      request: CreateTaskRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: false,
        action: {
          (r: CreateTaskRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleLongRunning.Operation
          in
          return try await self.inner.createTask(request: r, options: o)
        })
    }

    public func updateTask(
      request: UpdateTaskRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: false,
        action: {
          (r: UpdateTaskRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleLongRunning.Operation
          in
          return try await self.inner.updateTask(request: r, options: o)
        })
    }

    public func deleteTask(
      request: DeleteTaskRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: false,
        action: {
          (r: DeleteTaskRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleLongRunning.Operation
          in
          return try await self.inner.deleteTask(request: r, options: o)
        })
    }

    public func listTasks(
      request: ListTasksRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDataplexV1.ListTasksResponse {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: ListTasksRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudDataplexV1.ListTasksResponse
          in
          return try await self.inner.listTasks(request: r, options: o)
        })
    }

    public func getTask(
      request: GetTaskRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDataplexV1.Task {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: GetTaskRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudDataplexV1.Task
          in
          return try await self.inner.getTask(request: r, options: o)
        })
    }

    public func listJobs(
      request: ListJobsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDataplexV1.ListJobsResponse {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: ListJobsRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudDataplexV1.ListJobsResponse
          in
          return try await self.inner.listJobs(request: r, options: o)
        })
    }

    public func runTask(
      request: RunTaskRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDataplexV1.RunTaskResponse {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: false,
        action: {
          (r: RunTaskRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudDataplexV1.RunTaskResponse
          in
          return try await self.inner.runTask(request: r, options: o)
        })
    }

    public func getJob(
      request: GetJobRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDataplexV1.Job {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: GetJobRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudDataplexV1.Job
          in
          return try await self.inner.getJob(request: r, options: o)
        })
    }

    public func cancelJob(
      request: CancelJobRequest, options: GoogleCloudGax.RequestOptions
    ) async throws {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: false,
        action: { (r: CancelJobRequest, o: GoogleCloudGax.RequestOptions) async throws -> Void in
          return try await self.inner.cancelJob(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,
        idempotent: true,
        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,
        idempotent: true,
        action: {
          (r: GoogleCloudLocation.GetLocationRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudLocation.Location
          in
          return try await self.inner.getLocation(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,
        idempotent: false,
        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,
        idempotent: true,
        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,
        idempotent: false,
        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,
        idempotent: true,
        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,
        idempotent: true,
        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,
        idempotent: false,
        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,
        idempotent: false,
        action: {
          (r: GoogleLongRunning.CancelOperationRequest, o: GoogleCloudGax.RequestOptions)
            async throws -> Void in
          return try await self.inner.cancelOperation(request: r, options: o)
        })
    }
  }
}
