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

extension Clients {
  final class NativeDashboardServiceRetry: NativeDashboardServiceStub {
    let inner: any NativeDashboardServiceStub
    let options: GoogleCloudGax.ClientOptions

    public init(_ inner: any NativeDashboardServiceStub, 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 createNativeDashboard(
      request: CreateNativeDashboardRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudChronicleV1.NativeDashboard {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: false,
        action: {
          (r: CreateNativeDashboardRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudChronicleV1.NativeDashboard
          in
          return try await self.inner.createNativeDashboard(request: r, options: o)
        })
    }

    public func getNativeDashboard(
      request: GetNativeDashboardRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudChronicleV1.NativeDashboard {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: GetNativeDashboardRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudChronicleV1.NativeDashboard
          in
          return try await self.inner.getNativeDashboard(request: r, options: o)
        })
    }

    public func listNativeDashboards(
      request: ListNativeDashboardsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudChronicleV1.ListNativeDashboardsResponse {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: ListNativeDashboardsRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudChronicleV1.ListNativeDashboardsResponse
          in
          return try await self.inner.listNativeDashboards(request: r, options: o)
        })
    }

    public func updateNativeDashboard(
      request: UpdateNativeDashboardRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudChronicleV1.NativeDashboard {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: false,
        action: {
          (r: UpdateNativeDashboardRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudChronicleV1.NativeDashboard
          in
          return try await self.inner.updateNativeDashboard(request: r, options: o)
        })
    }

    public func duplicateNativeDashboard(
      request: DuplicateNativeDashboardRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudChronicleV1.NativeDashboard {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: false,
        action: {
          (r: DuplicateNativeDashboardRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudChronicleV1.NativeDashboard
          in
          return try await self.inner.duplicateNativeDashboard(request: r, options: o)
        })
    }

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

    public func addChart(
      request: AddChartRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudChronicleV1.AddChartResponse {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: false,
        action: {
          (r: AddChartRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudChronicleV1.AddChartResponse
          in
          return try await self.inner.addChart(request: r, options: o)
        })
    }

    public func removeChart(
      request: RemoveChartRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudChronicleV1.NativeDashboard {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: false,
        action: {
          (r: RemoveChartRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudChronicleV1.NativeDashboard
          in
          return try await self.inner.removeChart(request: r, options: o)
        })
    }

    public func editChart(
      request: EditChartRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudChronicleV1.EditChartResponse {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: false,
        action: {
          (r: EditChartRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudChronicleV1.EditChartResponse
          in
          return try await self.inner.editChart(request: r, options: o)
        })
    }

    public func duplicateChart(
      request: DuplicateChartRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudChronicleV1.DuplicateChartResponse {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: false,
        action: {
          (r: DuplicateChartRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudChronicleV1.DuplicateChartResponse
          in
          return try await self.inner.duplicateChart(request: r, options: o)
        })
    }

    public func exportNativeDashboards(
      request: ExportNativeDashboardsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudChronicleV1.ExportNativeDashboardsResponse {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: false,
        action: {
          (r: ExportNativeDashboardsRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudChronicleV1.ExportNativeDashboardsResponse
          in
          return try await self.inner.exportNativeDashboards(request: r, options: o)
        })
    }

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