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

extension Clients {
  final class RecaptchaEnterpriseServiceRetry: RecaptchaEnterpriseServiceStub {
    let inner: any RecaptchaEnterpriseServiceStub
    let options: GoogleCloudGax.ClientOptions

    public init(_ inner: any RecaptchaEnterpriseServiceStub, 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 createAssessment(
      request: CreateAssessmentRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudRecaptchaEnterpriseV1.Assessment {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: false,
        action: {
          (r: CreateAssessmentRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudRecaptchaEnterpriseV1.Assessment
          in
          return try await self.inner.createAssessment(request: r, options: o)
        })
    }

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

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

    public func listKeys(
      request: ListKeysRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudRecaptchaEnterpriseV1.ListKeysResponse {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: ListKeysRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudRecaptchaEnterpriseV1.ListKeysResponse
          in
          return try await self.inner.listKeys(request: r, options: o)
        })
    }

    public func retrieveLegacySecretKey(
      request: RetrieveLegacySecretKeyRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudRecaptchaEnterpriseV1.RetrieveLegacySecretKeyResponse {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: RetrieveLegacySecretKeyRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudRecaptchaEnterpriseV1.RetrieveLegacySecretKeyResponse
          in
          return try await self.inner.retrieveLegacySecretKey(request: r, options: o)
        })
    }

    public func getKey(
      request: GetKeyRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudRecaptchaEnterpriseV1.Key {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: GetKeyRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudRecaptchaEnterpriseV1.Key
          in
          return try await self.inner.getKey(request: r, options: o)
        })
    }

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

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

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

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

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

    public func listIpOverrides(
      request: ListIpOverridesRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudRecaptchaEnterpriseV1.ListIpOverridesResponse {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: ListIpOverridesRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudRecaptchaEnterpriseV1.ListIpOverridesResponse
          in
          return try await self.inner.listIpOverrides(request: r, options: o)
        })
    }

    public func getMetrics(
      request: GetMetricsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudRecaptchaEnterpriseV1.Metrics {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: GetMetricsRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudRecaptchaEnterpriseV1.Metrics
          in
          return try await self.inner.getMetrics(request: r, options: o)
        })
    }

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

    public func listFirewallPolicies(
      request: ListFirewallPoliciesRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudRecaptchaEnterpriseV1.ListFirewallPoliciesResponse {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: ListFirewallPoliciesRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudRecaptchaEnterpriseV1.ListFirewallPoliciesResponse
          in
          return try await self.inner.listFirewallPolicies(request: r, options: o)
        })
    }

    public func getFirewallPolicy(
      request: GetFirewallPolicyRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudRecaptchaEnterpriseV1.FirewallPolicy {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: GetFirewallPolicyRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudRecaptchaEnterpriseV1.FirewallPolicy
          in
          return try await self.inner.getFirewallPolicy(request: r, options: o)
        })
    }

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

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

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

    public func listRelatedAccountGroups(
      request: ListRelatedAccountGroupsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudRecaptchaEnterpriseV1.ListRelatedAccountGroupsResponse {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: ListRelatedAccountGroupsRequest, o: GoogleCloudGax.RequestOptions) async throws
            -> GoogleCloudRecaptchaEnterpriseV1.ListRelatedAccountGroupsResponse
          in
          return try await self.inner.listRelatedAccountGroups(request: r, options: o)
        })
    }

    public func listRelatedAccountGroupMemberships(
      request: ListRelatedAccountGroupMembershipsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudRecaptchaEnterpriseV1.ListRelatedAccountGroupMembershipsResponse {
      try await self._intercept(
        request: request,
        options: options,
        idempotent: true,
        action: {
          (r: ListRelatedAccountGroupMembershipsRequest, o: GoogleCloudGax.RequestOptions)
            async throws
            -> GoogleCloudRecaptchaEnterpriseV1.ListRelatedAccountGroupMembershipsResponse
          in
          return try await self.inner.listRelatedAccountGroupMemberships(request: r, options: o)
        })
    }

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