// 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.

#if ModelService
  import Foundation
  #if canImport(FoundationNetworking)
    import FoundationNetworking
  #endif
  import GoogleCloudLocation
  import GoogleCloudWkt
  import GoogleIAMV1
  import GoogleLongRunning
  import GoogleRpc
  import GoogleCloudGax

  extension Clients {
    final class ModelServiceRetry: ModelServiceStub {
      let inner: any ModelServiceStub
      let options: GoogleCloudGax.ClientOptions

      public init(_ inner: any ModelServiceStub, 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 uploadModel(
        request: UploadModelRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation {
        try await self._intercept(
          request: request,
          options: options,
          idempotent: false,
          action: {
            (r: UploadModelRequest, o: GoogleCloudGax.RequestOptions) async throws
              -> GoogleLongRunning.Operation
            in
            return try await self.inner.uploadModel(request: r, options: o)
          })
      }

      public func getModel(
        request: GetModelRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudAIPlatformV1.Model {
        try await self._intercept(
          request: request,
          options: options,
          idempotent: true,
          action: {
            (r: GetModelRequest, o: GoogleCloudGax.RequestOptions) async throws
              -> GoogleCloudAIPlatformV1.Model
            in
            return try await self.inner.getModel(request: r, options: o)
          })
      }

      public func listModels(
        request: ListModelsRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudAIPlatformV1.ListModelsResponse {
        try await self._intercept(
          request: request,
          options: options,
          idempotent: true,
          action: {
            (r: ListModelsRequest, o: GoogleCloudGax.RequestOptions) async throws
              -> GoogleCloudAIPlatformV1.ListModelsResponse
            in
            return try await self.inner.listModels(request: r, options: o)
          })
      }

      public func listModelVersions(
        request: ListModelVersionsRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudAIPlatformV1.ListModelVersionsResponse {
        try await self._intercept(
          request: request,
          options: options,
          idempotent: true,
          action: {
            (r: ListModelVersionsRequest, o: GoogleCloudGax.RequestOptions) async throws
              -> GoogleCloudAIPlatformV1.ListModelVersionsResponse
            in
            return try await self.inner.listModelVersions(request: r, options: o)
          })
      }

      public func listModelVersionCheckpoints(
        request: ListModelVersionCheckpointsRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudAIPlatformV1.ListModelVersionCheckpointsResponse {
        try await self._intercept(
          request: request,
          options: options,
          idempotent: true,
          action: {
            (r: ListModelVersionCheckpointsRequest, o: GoogleCloudGax.RequestOptions) async throws
              -> GoogleCloudAIPlatformV1.ListModelVersionCheckpointsResponse
            in
            return try await self.inner.listModelVersionCheckpoints(request: r, options: o)
          })
      }

      public func updateModel(
        request: UpdateModelRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudAIPlatformV1.Model {
        try await self._intercept(
          request: request,
          options: options,
          idempotent: false,
          action: {
            (r: UpdateModelRequest, o: GoogleCloudGax.RequestOptions) async throws
              -> GoogleCloudAIPlatformV1.Model
            in
            return try await self.inner.updateModel(request: r, options: o)
          })
      }

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

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

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

      public func mergeVersionAliases(
        request: MergeVersionAliasesRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudAIPlatformV1.Model {
        try await self._intercept(
          request: request,
          options: options,
          idempotent: false,
          action: {
            (r: MergeVersionAliasesRequest, o: GoogleCloudGax.RequestOptions) async throws
              -> GoogleCloudAIPlatformV1.Model
            in
            return try await self.inner.mergeVersionAliases(request: r, options: o)
          })
      }

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

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

      public func importModelEvaluation(
        request: ImportModelEvaluationRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudAIPlatformV1.ModelEvaluation {
        try await self._intercept(
          request: request,
          options: options,
          idempotent: false,
          action: {
            (r: ImportModelEvaluationRequest, o: GoogleCloudGax.RequestOptions) async throws
              -> GoogleCloudAIPlatformV1.ModelEvaluation
            in
            return try await self.inner.importModelEvaluation(request: r, options: o)
          })
      }

      public func batchImportModelEvaluationSlices(
        request: BatchImportModelEvaluationSlicesRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudAIPlatformV1.BatchImportModelEvaluationSlicesResponse {
        try await self._intercept(
          request: request,
          options: options,
          idempotent: false,
          action: {
            (r: BatchImportModelEvaluationSlicesRequest, o: GoogleCloudGax.RequestOptions)
              async throws -> GoogleCloudAIPlatformV1.BatchImportModelEvaluationSlicesResponse
            in
            return try await self.inner.batchImportModelEvaluationSlices(request: r, options: o)
          })
      }

      public func batchImportEvaluatedAnnotations(
        request: BatchImportEvaluatedAnnotationsRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudAIPlatformV1.BatchImportEvaluatedAnnotationsResponse {
        try await self._intercept(
          request: request,
          options: options,
          idempotent: false,
          action: {
            (r: BatchImportEvaluatedAnnotationsRequest, o: GoogleCloudGax.RequestOptions)
              async throws -> GoogleCloudAIPlatformV1.BatchImportEvaluatedAnnotationsResponse
            in
            return try await self.inner.batchImportEvaluatedAnnotations(request: r, options: o)
          })
      }

      public func getModelEvaluation(
        request: GetModelEvaluationRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudAIPlatformV1.ModelEvaluation {
        try await self._intercept(
          request: request,
          options: options,
          idempotent: true,
          action: {
            (r: GetModelEvaluationRequest, o: GoogleCloudGax.RequestOptions) async throws
              -> GoogleCloudAIPlatformV1.ModelEvaluation
            in
            return try await self.inner.getModelEvaluation(request: r, options: o)
          })
      }

      public func listModelEvaluations(
        request: ListModelEvaluationsRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudAIPlatformV1.ListModelEvaluationsResponse {
        try await self._intercept(
          request: request,
          options: options,
          idempotent: true,
          action: {
            (r: ListModelEvaluationsRequest, o: GoogleCloudGax.RequestOptions) async throws
              -> GoogleCloudAIPlatformV1.ListModelEvaluationsResponse
            in
            return try await self.inner.listModelEvaluations(request: r, options: o)
          })
      }

      public func getModelEvaluationSlice(
        request: GetModelEvaluationSliceRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudAIPlatformV1.ModelEvaluationSlice {
        try await self._intercept(
          request: request,
          options: options,
          idempotent: true,
          action: {
            (r: GetModelEvaluationSliceRequest, o: GoogleCloudGax.RequestOptions) async throws
              -> GoogleCloudAIPlatformV1.ModelEvaluationSlice
            in
            return try await self.inner.getModelEvaluationSlice(request: r, options: o)
          })
      }

      public func listModelEvaluationSlices(
        request: ListModelEvaluationSlicesRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudAIPlatformV1.ListModelEvaluationSlicesResponse {
        try await self._intercept(
          request: request,
          options: options,
          idempotent: true,
          action: {
            (r: ListModelEvaluationSlicesRequest, o: GoogleCloudGax.RequestOptions) async throws
              -> GoogleCloudAIPlatformV1.ListModelEvaluationSlicesResponse
            in
            return try await self.inner.listModelEvaluationSlices(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: false,
          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)
          })
      }

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