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

extension Clients {
  final class EdgeNetworkRetry: EdgeNetworkStub {
    let inner: any EdgeNetworkStub
    let options: GoogleCloudGax.ClientOptions

    public init(_ inner: any EdgeNetworkStub, 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 initializeZone(
      request: InitializeZoneRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudEdgeNetworkV1.InitializeZoneResponse {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: false,
        action: {
          (r: InitializeZoneRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudEdgeNetworkV1.InitializeZoneResponse
          in
          return try await self.inner.initializeZone(request: r, options: o)
        })
    }

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

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

    public func listNetworks(
      request: ListNetworksRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudEdgeNetworkV1.ListNetworksResponse {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: ListNetworksRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudEdgeNetworkV1.ListNetworksResponse
          in
          return try await self.inner.listNetworks(request: r, options: o)
        })
    }

    public func getNetwork(
      request: GetNetworkRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudEdgeNetworkV1.Network {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: GetNetworkRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudEdgeNetworkV1.Network
          in
          return try await self.inner.getNetwork(request: r, options: o)
        })
    }

    public func diagnoseNetwork(
      request: DiagnoseNetworkRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudEdgeNetworkV1.DiagnoseNetworkResponse {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: DiagnoseNetworkRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudEdgeNetworkV1.DiagnoseNetworkResponse
          in
          return try await self.inner.diagnoseNetwork(request: r, options: o)
        })
    }

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

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

    public func listSubnets(
      request: ListSubnetsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudEdgeNetworkV1.ListSubnetsResponse {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: ListSubnetsRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudEdgeNetworkV1.ListSubnetsResponse
          in
          return try await self.inner.listSubnets(request: r, options: o)
        })
    }

    public func getSubnet(
      request: GetSubnetRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudEdgeNetworkV1.Subnet {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: GetSubnetRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudEdgeNetworkV1.Subnet
          in
          return try await self.inner.getSubnet(request: r, options: o)
        })
    }

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

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

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

    public func listInterconnects(
      request: ListInterconnectsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudEdgeNetworkV1.ListInterconnectsResponse {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: ListInterconnectsRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudEdgeNetworkV1.ListInterconnectsResponse
          in
          return try await self.inner.listInterconnects(request: r, options: o)
        })
    }

    public func getInterconnect(
      request: GetInterconnectRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudEdgeNetworkV1.Interconnect {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: GetInterconnectRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudEdgeNetworkV1.Interconnect
          in
          return try await self.inner.getInterconnect(request: r, options: o)
        })
    }

    public func diagnoseInterconnect(
      request: DiagnoseInterconnectRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudEdgeNetworkV1.DiagnoseInterconnectResponse {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: DiagnoseInterconnectRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudEdgeNetworkV1.DiagnoseInterconnectResponse
          in
          return try await self.inner.diagnoseInterconnect(request: r, options: o)
        })
    }

    public func listInterconnectAttachments(
      request: ListInterconnectAttachmentsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudEdgeNetworkV1.ListInterconnectAttachmentsResponse {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: ListInterconnectAttachmentsRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudEdgeNetworkV1.ListInterconnectAttachmentsResponse
          in
          return try await self.inner.listInterconnectAttachments(request: r, options: o)
        })
    }

    public func getInterconnectAttachment(
      request: GetInterconnectAttachmentRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudEdgeNetworkV1.InterconnectAttachment {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: GetInterconnectAttachmentRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudEdgeNetworkV1.InterconnectAttachment
          in
          return try await self.inner.getInterconnectAttachment(request: r, options: o)
        })
    }

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

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

    public func listRouters(
      request: ListRoutersRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudEdgeNetworkV1.ListRoutersResponse {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: ListRoutersRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudEdgeNetworkV1.ListRoutersResponse
          in
          return try await self.inner.listRouters(request: r, options: o)
        })
    }

    public func getRouter(
      request: GetRouterRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudEdgeNetworkV1.Router {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: GetRouterRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudEdgeNetworkV1.Router
          in
          return try await self.inner.getRouter(request: r, options: o)
        })
    }

    public func diagnoseRouter(
      request: DiagnoseRouterRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudEdgeNetworkV1.DiagnoseRouterResponse {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: DiagnoseRouterRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudEdgeNetworkV1.DiagnoseRouterResponse
          in
          return try await self.inner.diagnoseRouter(request: r, options: o)
        })
    }

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

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

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