// 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 InstanceGroupManagers
  import Foundation
  #if canImport(FoundationNetworking)
    import FoundationNetworking
  #endif
  import GoogleCloudWkt
  import GoogleCloudGax

  extension Clients {
    final class InstanceGroupManagersRetry: InstanceGroupManagersStub {
      let inner: any InstanceGroupManagersStub
      let options: GoogleCloudGax.ClientOptions

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

      public func aggregatedList(
        request: InstanceGroupManagersClient.AggregatedListRequest,
        options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudComputeV1.InstanceGroupManagerAggregatedList {
        try await self._intercept(
          request: request,
          options: options,
          idempotent: true,
          action: {
            (r: InstanceGroupManagersClient.AggregatedListRequest, o: GoogleCloudGax.RequestOptions)
              async throws -> GoogleCloudComputeV1.InstanceGroupManagerAggregatedList
            in
            return try await self.inner.aggregatedList(request: r, options: o)
          })
      }

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

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

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

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

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

      public func `get`(
        request: InstanceGroupManagersClient.GetRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudComputeV1.InstanceGroupManager {
        try await self._intercept(
          request: request,
          options: options,
          idempotent: true,
          action: {
            (r: InstanceGroupManagersClient.GetRequest, o: GoogleCloudGax.RequestOptions)
              async throws -> GoogleCloudComputeV1.InstanceGroupManager
            in
            return try await self.inner.`get`(request: r, options: o)
          })
      }

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

      public func list(
        request: InstanceGroupManagersClient.ListRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudComputeV1.InstanceGroupManagerList {
        try await self._intercept(
          request: request,
          options: options,
          idempotent: true,
          action: {
            (r: InstanceGroupManagersClient.ListRequest, o: GoogleCloudGax.RequestOptions)
              async throws -> GoogleCloudComputeV1.InstanceGroupManagerList
            in
            return try await self.inner.list(request: r, options: o)
          })
      }

      public func listErrors(
        request: InstanceGroupManagersClient.ListErrorsRequest,
        options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudComputeV1.InstanceGroupManagersListErrorsResponse {
        try await self._intercept(
          request: request,
          options: options,
          idempotent: true,
          action: {
            (r: InstanceGroupManagersClient.ListErrorsRequest, o: GoogleCloudGax.RequestOptions)
              async throws -> GoogleCloudComputeV1.InstanceGroupManagersListErrorsResponse
            in
            return try await self.inner.listErrors(request: r, options: o)
          })
      }

      public func listManagedInstances(
        request: InstanceGroupManagersClient.ListManagedInstancesRequest,
        options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudComputeV1.InstanceGroupManagersListManagedInstancesResponse {
        try await self._intercept(
          request: request,
          options: options,
          idempotent: false,
          action: {
            (
              r: InstanceGroupManagersClient.ListManagedInstancesRequest,
              o: GoogleCloudGax.RequestOptions
            ) async throws -> GoogleCloudComputeV1.InstanceGroupManagersListManagedInstancesResponse
            in
            return try await self.inner.listManagedInstances(request: r, options: o)
          })
      }

      public func listPerInstanceConfigs(
        request: InstanceGroupManagersClient.ListPerInstanceConfigsRequest,
        options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudComputeV1.InstanceGroupManagersListPerInstanceConfigsResp {
        try await self._intercept(
          request: request,
          options: options,
          idempotent: false,
          action: {
            (
              r: InstanceGroupManagersClient.ListPerInstanceConfigsRequest,
              o: GoogleCloudGax.RequestOptions
            ) async throws -> GoogleCloudComputeV1.InstanceGroupManagersListPerInstanceConfigsResp
            in
            return try await self.inner.listPerInstanceConfigs(request: r, options: o)
          })
      }

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

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

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

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

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

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

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

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

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

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

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

      public func getOperation(
        request: ZoneOperationsClient.GetRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudComputeV1.Operation {
        try await self._intercept(
          request: request,
          options: options,
          idempotent: true,
          action: {
            (r: ZoneOperationsClient.GetRequest, o: GoogleCloudGax.RequestOptions) async throws
              -> GoogleCloudComputeV1.Operation
            in
            return try await self.inner.getOperation(request: r, options: o)
          })
      }
    }
  }
#endif
