// 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 PersistentResourceService
  import Foundation
  #if canImport(FoundationNetworking)
    import FoundationNetworking
  #endif
  import GoogleCloudLocation
  import GoogleCloudWkt
  import GoogleIAMV1
  import GoogleLongRunning
  import GoogleRpc
  import GoogleCloudGax

  /// A service for managing Vertex AI's machine learning PersistentResource.
  ///
  /// @Snippet(path: "PersistentResourceServiceQuickstart")
  public class PersistentResourceServiceClient: Clients.PersistentResourceServiceProtocol {
    let inner: any Clients.PersistentResourceServiceStub
    let pollingErrorPolicy: GoogleCloudGax.PollingErrorPolicy
    let pollingBackoffPolicy: GoogleCloudGax.BackoffPolicy

    /// Creates a new `PersistentResourceServiceClient` instance.
    public init(_ options: GoogleCloudGax.ClientOptions = .init()) throws {
      var inner: any Clients.PersistentResourceServiceStub =
        try Clients.PersistentResourceServiceTransport(options)
      inner = Clients.PersistentResourceServiceRetry(inner, options: options)
      if let logger = options.logger {
        inner = Clients.PersistentResourceServiceLogging(inner, logger: logger)
      }
      self.inner = inner
      self.pollingErrorPolicy = options.pollingErrorPolicy
      self.pollingBackoffPolicy = options.pollingBackoffPolicy
    }

    /// Creates a PersistentResource.
    ///
    /// @Snippet(path: "PersistentResourceService_CreatePersistentResource")
    public func createPersistentResource(
      request: CreatePersistentResourceRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      try await self.inner.createPersistentResource(request: request, options: options)
    }

    /// Creates a PersistentResource.
    ///
    /// @Snippet(path: "PersistentResourceService_CreatePersistentResource")
    public func createPersistentResource(
      withPolling: CreatePersistentResourceRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> any GoogleCloudGax.PollableOperation<PersistentResource> {
      let extractStatus = {
        (op: GoogleLongRunning.Operation) throws
          -> GoogleCloudGax._PollableOperationImpl<PersistentResource>.State in
        guard op.done else {
          return .init(done: false, result: nil)
        }

        switch op.result {
        case .response(let anyValue):
          guard let anyValueUnwrapped = anyValue else {
            return .init(
              done: true,
              result: .failure(
                GoogleCloudGax.RequestError.binding(
                  "Operation completed but response value was missing")))
          }
          let response = try PersistentResource(fromAny: anyValueUnwrapped)
          return .init(done: true, result: .success(response))
        case .error(let status):
          guard let statusUnwrapped = status else {
            return .init(
              done: true,
              result: .failure(
                GoogleCloudGax.RequestError.binding(
                  "Operation completed but error value was missing")))
          }
          let error = GoogleCloudGax.RequestError.service(
            GoogleCloudGax.ServiceError(
              code: GoogleRpc.Code(intValue: Int(statusUnwrapped.code)),
              message: statusUnwrapped.message))
          return .init(done: true, result: .failure(error))
        case .none:
          return .init(
            done: true,
            result: .failure(
              GoogleCloudGax.RequestError.binding("Operation completed but result was missing")))
        }
      }
      let rawOp = try await self.createPersistentResource(request: withPolling, options: options)
      let initialState = try extractStatus(rawOp)
      let poll = {
        () async throws -> GoogleCloudGax._PollableOperationImpl<PersistentResource>.State in
        let op = try await self.getOperation(
          request: .init().with { $0.name = rawOp.name }, options: options)
        return try extractStatus(op)
      }
      return GoogleCloudGax._PollableOperationImpl(
        initialState: initialState,
        polling: options.pollingErrorPolicy ?? self.pollingErrorPolicy,
        backoff: options.pollingBackoffPolicy ?? self.pollingBackoffPolicy,
        poll: poll,
      )
    }

    /// Gets a PersistentResource.
    ///
    /// @Snippet(path: "PersistentResourceService_GetPersistentResource")
    public func getPersistentResource(
      request: GetPersistentResourceRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudAIPlatformV1.PersistentResource {
      try await self.inner.getPersistentResource(request: request, options: options)
    }

    /// Lists PersistentResources in a Location.
    ///
    /// @Snippet(path: "PersistentResourceService_ListPersistentResources")
    public func listPersistentResources(
      request: ListPersistentResourcesRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudAIPlatformV1.ListPersistentResourcesResponse {
      try await self.inner.listPersistentResources(request: request, options: options)
    }

    /// Lists PersistentResources in a Location.
    ///
    /// @Snippet(path: "PersistentResourceService_ListPersistentResources")
    public func listPersistentResources(
      byItem: ListPersistentResourcesRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<PersistentResource, Swift.Error> {
      let listRpc = {
        (token: Swift.String) async throws
          -> GoogleCloudAIPlatformV1.ListPersistentResourcesResponse in
        var request = byItem
        request.pageToken = token
        return try await self.listPersistentResources(request: request, options: options)
      }
      return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
    }

    /// Deletes a PersistentResource.
    ///
    /// @Snippet(path: "PersistentResourceService_DeletePersistentResource")
    public func deletePersistentResource(
      request: DeletePersistentResourceRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      try await self.inner.deletePersistentResource(request: request, options: options)
    }

    /// Deletes a PersistentResource.
    ///
    /// @Snippet(path: "PersistentResourceService_DeletePersistentResource")
    public func deletePersistentResource(
      withPolling: DeletePersistentResourceRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> any GoogleCloudGax.PollableOperation<Void> {
      let extractStatus = {
        (op: GoogleLongRunning.Operation) throws
          -> GoogleCloudGax._PollableOperationImpl<Void>.State in
        guard op.done else {
          return .init(done: false, result: nil)
        }

        switch op.result {
        case .response:
          return .init(done: true, result: .success(()))
        case .error(let status):
          guard let statusUnwrapped = status else {
            return .init(
              done: true,
              result: .failure(
                GoogleCloudGax.RequestError.binding(
                  "Operation completed but error value was missing")))
          }
          let error = GoogleCloudGax.RequestError.service(
            GoogleCloudGax.ServiceError(
              code: GoogleRpc.Code(intValue: Int(statusUnwrapped.code)),
              message: statusUnwrapped.message))
          return .init(done: true, result: .failure(error))
        case .none:
          return .init(
            done: true,
            result: .failure(
              GoogleCloudGax.RequestError.binding("Operation completed but result was missing")))
        }
      }
      let rawOp = try await self.deletePersistentResource(request: withPolling, options: options)
      let initialState = try extractStatus(rawOp)
      let poll = { () async throws -> GoogleCloudGax._PollableOperationImpl<Void>.State in
        let op = try await self.getOperation(
          request: .init().with { $0.name = rawOp.name }, options: options)
        return try extractStatus(op)
      }
      return GoogleCloudGax._PollableOperationImpl(
        initialState: initialState,
        polling: options.pollingErrorPolicy ?? self.pollingErrorPolicy,
        backoff: options.pollingBackoffPolicy ?? self.pollingBackoffPolicy,
        poll: poll,
      )
    }

    /// Updates a PersistentResource.
    ///
    /// @Snippet(path: "PersistentResourceService_UpdatePersistentResource")
    public func updatePersistentResource(
      request: UpdatePersistentResourceRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      try await self.inner.updatePersistentResource(request: request, options: options)
    }

    /// Updates a PersistentResource.
    ///
    /// @Snippet(path: "PersistentResourceService_UpdatePersistentResource")
    public func updatePersistentResource(
      withPolling: UpdatePersistentResourceRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> any GoogleCloudGax.PollableOperation<PersistentResource> {
      let extractStatus = {
        (op: GoogleLongRunning.Operation) throws
          -> GoogleCloudGax._PollableOperationImpl<PersistentResource>.State in
        guard op.done else {
          return .init(done: false, result: nil)
        }

        switch op.result {
        case .response(let anyValue):
          guard let anyValueUnwrapped = anyValue else {
            return .init(
              done: true,
              result: .failure(
                GoogleCloudGax.RequestError.binding(
                  "Operation completed but response value was missing")))
          }
          let response = try PersistentResource(fromAny: anyValueUnwrapped)
          return .init(done: true, result: .success(response))
        case .error(let status):
          guard let statusUnwrapped = status else {
            return .init(
              done: true,
              result: .failure(
                GoogleCloudGax.RequestError.binding(
                  "Operation completed but error value was missing")))
          }
          let error = GoogleCloudGax.RequestError.service(
            GoogleCloudGax.ServiceError(
              code: GoogleRpc.Code(intValue: Int(statusUnwrapped.code)),
              message: statusUnwrapped.message))
          return .init(done: true, result: .failure(error))
        case .none:
          return .init(
            done: true,
            result: .failure(
              GoogleCloudGax.RequestError.binding("Operation completed but result was missing")))
        }
      }
      let rawOp = try await self.updatePersistentResource(request: withPolling, options: options)
      let initialState = try extractStatus(rawOp)
      let poll = {
        () async throws -> GoogleCloudGax._PollableOperationImpl<PersistentResource>.State in
        let op = try await self.getOperation(
          request: .init().with { $0.name = rawOp.name }, options: options)
        return try extractStatus(op)
      }
      return GoogleCloudGax._PollableOperationImpl(
        initialState: initialState,
        polling: options.pollingErrorPolicy ?? self.pollingErrorPolicy,
        backoff: options.pollingBackoffPolicy ?? self.pollingBackoffPolicy,
        poll: poll,
      )
    }

    /// Reboots a PersistentResource.
    ///
    /// @Snippet(path: "PersistentResourceService_RebootPersistentResource")
    public func rebootPersistentResource(
      request: RebootPersistentResourceRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      try await self.inner.rebootPersistentResource(request: request, options: options)
    }

    /// Reboots a PersistentResource.
    ///
    /// @Snippet(path: "PersistentResourceService_RebootPersistentResource")
    public func rebootPersistentResource(
      withPolling: RebootPersistentResourceRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> any GoogleCloudGax.PollableOperation<PersistentResource> {
      let extractStatus = {
        (op: GoogleLongRunning.Operation) throws
          -> GoogleCloudGax._PollableOperationImpl<PersistentResource>.State in
        guard op.done else {
          return .init(done: false, result: nil)
        }

        switch op.result {
        case .response(let anyValue):
          guard let anyValueUnwrapped = anyValue else {
            return .init(
              done: true,
              result: .failure(
                GoogleCloudGax.RequestError.binding(
                  "Operation completed but response value was missing")))
          }
          let response = try PersistentResource(fromAny: anyValueUnwrapped)
          return .init(done: true, result: .success(response))
        case .error(let status):
          guard let statusUnwrapped = status else {
            return .init(
              done: true,
              result: .failure(
                GoogleCloudGax.RequestError.binding(
                  "Operation completed but error value was missing")))
          }
          let error = GoogleCloudGax.RequestError.service(
            GoogleCloudGax.ServiceError(
              code: GoogleRpc.Code(intValue: Int(statusUnwrapped.code)),
              message: statusUnwrapped.message))
          return .init(done: true, result: .failure(error))
        case .none:
          return .init(
            done: true,
            result: .failure(
              GoogleCloudGax.RequestError.binding("Operation completed but result was missing")))
        }
      }
      let rawOp = try await self.rebootPersistentResource(request: withPolling, options: options)
      let initialState = try extractStatus(rawOp)
      let poll = {
        () async throws -> GoogleCloudGax._PollableOperationImpl<PersistentResource>.State in
        let op = try await self.getOperation(
          request: .init().with { $0.name = rawOp.name }, options: options)
        return try extractStatus(op)
      }
      return GoogleCloudGax._PollableOperationImpl(
        initialState: initialState,
        polling: options.pollingErrorPolicy ?? self.pollingErrorPolicy,
        backoff: options.pollingBackoffPolicy ?? self.pollingBackoffPolicy,
        poll: poll,
      )
    }

    /// Lists information about the supported locations for this service.
    ///
    /// @Snippet(path: "PersistentResourceService_ListLocations")
    public func listLocations(
      request: GoogleCloudLocation.ListLocationsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudLocation.ListLocationsResponse {
      try await self.inner.listLocations(request: request, options: options)
    }

    /// Lists information about the supported locations for this service.
    ///
    /// @Snippet(path: "PersistentResourceService_ListLocations")
    public func listLocations(
      byItem: GoogleCloudLocation.ListLocationsRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<GoogleCloudLocation.Location, Swift.Error> {
      let listRpc = {
        (token: Swift.String) async throws -> GoogleCloudLocation.ListLocationsResponse in
        var request = byItem
        request.pageToken = token
        return try await self.listLocations(request: request, options: options)
      }
      return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
    }

    /// Gets information about a location.
    ///
    /// @Snippet(path: "PersistentResourceService_GetLocation")
    public func getLocation(
      request: GoogleCloudLocation.GetLocationRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudLocation.Location {
      try await self.inner.getLocation(request: request, options: options)
    }

    /// Sets the access control policy on the specified resource. Replaces
    /// any existing policy.
    ///
    /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
    /// errors.
    ///
    /// @Snippet(path: "PersistentResourceService_SetIamPolicy")
    public func setIamPolicy(
      request: GoogleIAMV1.SetIamPolicyRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleIAMV1.Policy {
      try await self.inner.setIamPolicy(request: request, options: options)
    }

    /// Gets the access control policy for a resource. Returns an empty policy
    /// if the resource exists and does not have a policy set.
    ///
    /// @Snippet(path: "PersistentResourceService_GetIamPolicy")
    public func getIamPolicy(
      request: GoogleIAMV1.GetIamPolicyRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleIAMV1.Policy {
      try await self.inner.getIamPolicy(request: request, options: options)
    }

    /// Returns permissions that a caller has on the specified resource. If the
    /// resource does not exist, this will return an empty set of
    /// permissions, not a `NOT_FOUND` error.
    ///
    /// Note: This operation is designed to be used for building
    /// permission-aware UIs and command-line tools, not for authorization
    /// checking. This operation may "fail open" without warning.
    ///
    /// @Snippet(path: "PersistentResourceService_TestIamPermissions")
    public func testIamPermissions(
      request: GoogleIAMV1.TestIamPermissionsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleIAMV1.TestIamPermissionsResponse {
      try await self.inner.testIamPermissions(request: request, options: options)
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: https://www.google.com/search?q=Swift+google.longrunning+Operations
    ///
    /// @Snippet(path: "PersistentResourceService_ListOperations")
    public func listOperations(
      request: GoogleLongRunning.ListOperationsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.ListOperationsResponse {
      try await self.inner.listOperations(request: request, options: options)
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: https://www.google.com/search?q=Swift+google.longrunning+Operations
    ///
    /// @Snippet(path: "PersistentResourceService_ListOperations")
    public func listOperations(
      byItem: GoogleLongRunning.ListOperationsRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<GoogleLongRunning.Operation, Swift.Error> {
      let listRpc = {
        (token: Swift.String) async throws -> GoogleLongRunning.ListOperationsResponse in
        var request = byItem
        request.pageToken = token
        return try await self.listOperations(request: request, options: options)
      }
      return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: https://www.google.com/search?q=Swift+google.longrunning+Operations
    ///
    /// @Snippet(path: "PersistentResourceService_GetOperation")
    func getOperation(
      request: GoogleLongRunning.GetOperationRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      try await self.inner.getOperation(request: request, options: options)
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: https://www.google.com/search?q=Swift+google.longrunning+Operations
    ///
    /// @Snippet(path: "PersistentResourceService_DeleteOperation")
    public func deleteOperation(
      request: GoogleLongRunning.DeleteOperationRequest, options: GoogleCloudGax.RequestOptions
    ) async throws {
      try await self.inner.deleteOperation(request: request, options: options)
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: https://www.google.com/search?q=Swift+google.longrunning+Operations
    ///
    /// @Snippet(path: "PersistentResourceService_CancelOperation")
    public func cancelOperation(
      request: GoogleLongRunning.CancelOperationRequest, options: GoogleCloudGax.RequestOptions
    ) async throws {
      try await self.inner.cancelOperation(request: request, options: options)
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: https://www.google.com/search?q=Swift+google.longrunning+Operations
    ///
    /// @Snippet(path: "PersistentResourceService_WaitOperation")
    public func waitOperation(
      request: GoogleLongRunning.WaitOperationRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      try await self.inner.waitOperation(request: request, options: options)
    }
  }

  extension Clients {
    /// A Swift protocol to mock `PersistentResourceServiceClient`.
    ///
    /// To mock `PersistentResourceServiceClient` change your functions to receive
    /// `some PersistentResourceServiceProtocol` or `any PersistentResourceServiceProtocol`
    /// and pass a mock implementation in your tests.
    public protocol PersistentResourceServiceProtocol {
      /// See `PersistentResourceServiceClient.createPersistentResource`.
      func createPersistentResource(request: CreatePersistentResourceRequest) async throws
        -> GoogleLongRunning.Operation

      /// See `PersistentResourceServiceClient.createPersistentResource`.
      func createPersistentResource(withPolling: CreatePersistentResourceRequest) async throws
        -> any GoogleCloudGax.PollableOperation<PersistentResource>

      /// See `PersistentResourceServiceClient.createPersistentResource`.
      func createPersistentResource(
        parent: Swift.String,
        persistentResource: PersistentResource?,
        persistentResourceId: Swift.String,
      ) async throws -> any GoogleCloudGax.PollableOperation<PersistentResource>

      /// See `PersistentResourceServiceClient.getPersistentResource`.
      func getPersistentResource(request: GetPersistentResourceRequest) async throws
        -> GoogleCloudAIPlatformV1.PersistentResource

      /// See `PersistentResourceServiceClient.getPersistentResource`.
      func getPersistentResource(
        name: Swift.String,
      ) async throws -> GoogleCloudAIPlatformV1.PersistentResource

      /// See `PersistentResourceServiceClient.listPersistentResources`.
      func listPersistentResources(request: ListPersistentResourcesRequest) async throws
        -> GoogleCloudAIPlatformV1.ListPersistentResourcesResponse

      /// See `PersistentResourceServiceClient.listPersistentResources`.
      func listPersistentResources(
        byItem: ListPersistentResourcesRequest
      ) throws -> any AsyncSequence<PersistentResource, Swift.Error>

      /// See `PersistentResourceServiceClient.listPersistentResources`.
      func listPersistentResources(
        parent: Swift.String,
      ) throws -> any AsyncSequence<PersistentResource, Swift.Error>

      /// See `PersistentResourceServiceClient.deletePersistentResource`.
      func deletePersistentResource(request: DeletePersistentResourceRequest) async throws
        -> GoogleLongRunning.Operation

      /// See `PersistentResourceServiceClient.deletePersistentResource`.
      func deletePersistentResource(withPolling: DeletePersistentResourceRequest) async throws
        -> any GoogleCloudGax.PollableOperation<Void>

      /// See `PersistentResourceServiceClient.deletePersistentResource`.
      func deletePersistentResource(
        name: Swift.String,
      ) async throws -> any GoogleCloudGax.PollableOperation<Void>

      /// See `PersistentResourceServiceClient.updatePersistentResource`.
      func updatePersistentResource(request: UpdatePersistentResourceRequest) async throws
        -> GoogleLongRunning.Operation

      /// See `PersistentResourceServiceClient.updatePersistentResource`.
      func updatePersistentResource(withPolling: UpdatePersistentResourceRequest) async throws
        -> any GoogleCloudGax.PollableOperation<PersistentResource>

      /// See `PersistentResourceServiceClient.updatePersistentResource`.
      func updatePersistentResource(
        persistentResource: PersistentResource?,
        updateMask: GoogleCloudWkt.FieldMask?,
      ) async throws -> any GoogleCloudGax.PollableOperation<PersistentResource>

      /// See `PersistentResourceServiceClient.rebootPersistentResource`.
      func rebootPersistentResource(request: RebootPersistentResourceRequest) async throws
        -> GoogleLongRunning.Operation

      /// See `PersistentResourceServiceClient.rebootPersistentResource`.
      func rebootPersistentResource(withPolling: RebootPersistentResourceRequest) async throws
        -> any GoogleCloudGax.PollableOperation<PersistentResource>

      /// See `PersistentResourceServiceClient.rebootPersistentResource`.
      func rebootPersistentResource(
        name: Swift.String,
      ) async throws -> any GoogleCloudGax.PollableOperation<PersistentResource>

      /// See `PersistentResourceServiceClient.listLocations`.
      func listLocations(request: GoogleCloudLocation.ListLocationsRequest) async throws
        -> GoogleCloudLocation.ListLocationsResponse

      /// See `PersistentResourceServiceClient.listLocations`.
      func listLocations(
        byItem: GoogleCloudLocation.ListLocationsRequest
      ) throws -> any AsyncSequence<GoogleCloudLocation.Location, Swift.Error>

      /// See `PersistentResourceServiceClient.getLocation`.
      func getLocation(request: GoogleCloudLocation.GetLocationRequest) async throws
        -> GoogleCloudLocation.Location

      /// See `PersistentResourceServiceClient.setIamPolicy`.
      func setIamPolicy(request: GoogleIAMV1.SetIamPolicyRequest) async throws -> GoogleIAMV1.Policy

      /// See `PersistentResourceServiceClient.getIamPolicy`.
      func getIamPolicy(request: GoogleIAMV1.GetIamPolicyRequest) async throws -> GoogleIAMV1.Policy

      /// See `PersistentResourceServiceClient.testIamPermissions`.
      func testIamPermissions(request: GoogleIAMV1.TestIamPermissionsRequest) async throws
        -> GoogleIAMV1.TestIamPermissionsResponse

      /// See `PersistentResourceServiceClient.listOperations`.
      func listOperations(request: GoogleLongRunning.ListOperationsRequest) async throws
        -> GoogleLongRunning.ListOperationsResponse

      /// See `PersistentResourceServiceClient.listOperations`.
      func listOperations(
        byItem: GoogleLongRunning.ListOperationsRequest
      ) throws -> any AsyncSequence<GoogleLongRunning.Operation, Swift.Error>

      /// See `PersistentResourceServiceClient.listOperations`.
      func listOperations(
        name: Swift.String,
        filter: Swift.String,
      ) throws -> any AsyncSequence<GoogleLongRunning.Operation, Swift.Error>

      /// See `PersistentResourceServiceClient.deleteOperation`.
      func deleteOperation(request: GoogleLongRunning.DeleteOperationRequest) async throws

      /// See `PersistentResourceServiceClient.deleteOperation`.
      func deleteOperation(
        name: Swift.String,
      ) async throws

      /// See `PersistentResourceServiceClient.cancelOperation`.
      func cancelOperation(request: GoogleLongRunning.CancelOperationRequest) async throws

      /// See `PersistentResourceServiceClient.cancelOperation`.
      func cancelOperation(
        name: Swift.String,
      ) async throws

      /// See `PersistentResourceServiceClient.waitOperation`.
      func waitOperation(request: GoogleLongRunning.WaitOperationRequest) async throws
        -> GoogleLongRunning.Operation

      /// See `PersistentResourceServiceClient.createPersistentResource`.
      func createPersistentResource(
        request: CreatePersistentResourceRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation

      /// See `PersistentResourceServiceClient.createPersistentResource`.
      func createPersistentResource(
        withPolling: CreatePersistentResourceRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> any GoogleCloudGax.PollableOperation<PersistentResource>

      /// See `PersistentResourceServiceClient.getPersistentResource`.
      func getPersistentResource(
        request: GetPersistentResourceRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudAIPlatformV1.PersistentResource

      /// See `PersistentResourceServiceClient.listPersistentResources`.
      func listPersistentResources(
        request: ListPersistentResourcesRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudAIPlatformV1.ListPersistentResourcesResponse

      /// See `PersistentResourceServiceClient.listPersistentResources`.
      func listPersistentResources(
        byItem: ListPersistentResourcesRequest, options: GoogleCloudGax.RequestOptions
      ) throws -> any AsyncSequence<PersistentResource, Swift.Error>

      /// See `PersistentResourceServiceClient.deletePersistentResource`.
      func deletePersistentResource(
        request: DeletePersistentResourceRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation

      /// See `PersistentResourceServiceClient.deletePersistentResource`.
      func deletePersistentResource(
        withPolling: DeletePersistentResourceRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> any GoogleCloudGax.PollableOperation<Void>

      /// See `PersistentResourceServiceClient.updatePersistentResource`.
      func updatePersistentResource(
        request: UpdatePersistentResourceRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation

      /// See `PersistentResourceServiceClient.updatePersistentResource`.
      func updatePersistentResource(
        withPolling: UpdatePersistentResourceRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> any GoogleCloudGax.PollableOperation<PersistentResource>

      /// See `PersistentResourceServiceClient.rebootPersistentResource`.
      func rebootPersistentResource(
        request: RebootPersistentResourceRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation

      /// See `PersistentResourceServiceClient.rebootPersistentResource`.
      func rebootPersistentResource(
        withPolling: RebootPersistentResourceRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> any GoogleCloudGax.PollableOperation<PersistentResource>

      /// See `PersistentResourceServiceClient.listLocations`.
      func listLocations(
        request: GoogleCloudLocation.ListLocationsRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudLocation.ListLocationsResponse

      /// See `PersistentResourceServiceClient.listLocations`.
      func listLocations(
        byItem: GoogleCloudLocation.ListLocationsRequest, options: GoogleCloudGax.RequestOptions
      ) throws -> any AsyncSequence<GoogleCloudLocation.Location, Swift.Error>

      /// See `PersistentResourceServiceClient.getLocation`.
      func getLocation(
        request: GoogleCloudLocation.GetLocationRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudLocation.Location

      /// See `PersistentResourceServiceClient.setIamPolicy`.
      func setIamPolicy(
        request: GoogleIAMV1.SetIamPolicyRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleIAMV1.Policy

      /// See `PersistentResourceServiceClient.getIamPolicy`.
      func getIamPolicy(
        request: GoogleIAMV1.GetIamPolicyRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleIAMV1.Policy

      /// See `PersistentResourceServiceClient.testIamPermissions`.
      func testIamPermissions(
        request: GoogleIAMV1.TestIamPermissionsRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleIAMV1.TestIamPermissionsResponse

      /// See `PersistentResourceServiceClient.listOperations`.
      func listOperations(
        request: GoogleLongRunning.ListOperationsRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.ListOperationsResponse

      /// See `PersistentResourceServiceClient.listOperations`.
      func listOperations(
        byItem: GoogleLongRunning.ListOperationsRequest, options: GoogleCloudGax.RequestOptions
      ) throws -> any AsyncSequence<GoogleLongRunning.Operation, Swift.Error>

      /// See `PersistentResourceServiceClient.deleteOperation`.
      func deleteOperation(
        request: GoogleLongRunning.DeleteOperationRequest, options: GoogleCloudGax.RequestOptions
      ) async throws

      /// See `PersistentResourceServiceClient.cancelOperation`.
      func cancelOperation(
        request: GoogleLongRunning.CancelOperationRequest, options: GoogleCloudGax.RequestOptions
      ) async throws

      /// See `PersistentResourceServiceClient.waitOperation`.
      func waitOperation(
        request: GoogleLongRunning.WaitOperationRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation
    }
  }

  // Default implementations
  extension Clients.PersistentResourceServiceProtocol {
    public func createPersistentResource(request: CreatePersistentResourceRequest) async throws
      -> GoogleLongRunning.Operation
    {
      try await self.createPersistentResource(request: request, options: .init())
    }

    public func createPersistentResource(
      request: CreatePersistentResourceRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func createPersistentResource(withPolling: CreatePersistentResourceRequest) async throws
      -> any GoogleCloudGax.PollableOperation<PersistentResource>
    {
      try await self.createPersistentResource(withPolling: withPolling, options: .init())
    }

    public func createPersistentResource(
      withPolling: CreatePersistentResourceRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> any GoogleCloudGax.PollableOperation<PersistentResource> {
      let poll = {
        () async throws -> GoogleCloudGax._PollableOperationImpl<PersistentResource>.State in
        throw GoogleCloudGax.RequestError.unimplemented
      }
      return GoogleCloudGax._PollableOperationImpl(
        initialState: .init(done: false, result: nil), poll: poll)
    }

    public func createPersistentResource(
      parent: Swift.String,
      persistentResource: PersistentResource?,
      persistentResourceId: Swift.String,
    ) async throws -> any GoogleCloudGax.PollableOperation<PersistentResource> {
      let request = CreatePersistentResourceRequest().with {
        $0.parent = parent
        $0.persistentResource = persistentResource
        $0.persistentResourceId = persistentResourceId
      }
      return try await self.createPersistentResource(withPolling: request)
    }

    public func getPersistentResource(request: GetPersistentResourceRequest) async throws
      -> GoogleCloudAIPlatformV1.PersistentResource
    {
      try await self.getPersistentResource(request: request, options: .init())
    }

    public func getPersistentResource(
      request: GetPersistentResourceRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudAIPlatformV1.PersistentResource {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func getPersistentResource(
      name: Swift.String,
    ) async throws -> GoogleCloudAIPlatformV1.PersistentResource {
      let request = GetPersistentResourceRequest().with {
        $0.name = name
      }
      return try await self.getPersistentResource(request: request)
    }

    public func listPersistentResources(request: ListPersistentResourcesRequest) async throws
      -> GoogleCloudAIPlatformV1.ListPersistentResourcesResponse
    {
      try await self.listPersistentResources(request: request, options: .init())
    }

    public func listPersistentResources(
      request: ListPersistentResourcesRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudAIPlatformV1.ListPersistentResourcesResponse {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func listPersistentResources(
      byItem: ListPersistentResourcesRequest
    ) throws -> any AsyncSequence<PersistentResource, Swift.Error> {
      try self.listPersistentResources(byItem: byItem, options: .init())
    }

    public func listPersistentResources(
      byItem: ListPersistentResourcesRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<PersistentResource, Swift.Error> {
      let listRpc = {
        (token: Swift.String) async throws
          -> GoogleCloudAIPlatformV1.ListPersistentResourcesResponse in
        throw GoogleCloudGax.RequestError.unimplemented
      }
      return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
    }

    public func listPersistentResources(
      parent: Swift.String,
    ) throws -> any AsyncSequence<PersistentResource, Swift.Error> {
      let request = ListPersistentResourcesRequest().with {
        $0.parent = parent
      }
      return try self.listPersistentResources(byItem: request)
    }

    public func deletePersistentResource(request: DeletePersistentResourceRequest) async throws
      -> GoogleLongRunning.Operation
    {
      try await self.deletePersistentResource(request: request, options: .init())
    }

    public func deletePersistentResource(
      request: DeletePersistentResourceRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func deletePersistentResource(withPolling: DeletePersistentResourceRequest) async throws
      -> any GoogleCloudGax.PollableOperation<Void>
    {
      try await self.deletePersistentResource(withPolling: withPolling, options: .init())
    }

    public func deletePersistentResource(
      withPolling: DeletePersistentResourceRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> any GoogleCloudGax.PollableOperation<Void> {
      let poll = { () async throws -> GoogleCloudGax._PollableOperationImpl<Void>.State in
        throw GoogleCloudGax.RequestError.unimplemented
      }
      return GoogleCloudGax._PollableOperationImpl(
        initialState: .init(done: false, result: nil), poll: poll)
    }

    public func deletePersistentResource(
      name: Swift.String,
    ) async throws -> any GoogleCloudGax.PollableOperation<Void> {
      let request = DeletePersistentResourceRequest().with {
        $0.name = name
      }
      return try await self.deletePersistentResource(withPolling: request)
    }

    public func updatePersistentResource(request: UpdatePersistentResourceRequest) async throws
      -> GoogleLongRunning.Operation
    {
      try await self.updatePersistentResource(request: request, options: .init())
    }

    public func updatePersistentResource(
      request: UpdatePersistentResourceRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func updatePersistentResource(withPolling: UpdatePersistentResourceRequest) async throws
      -> any GoogleCloudGax.PollableOperation<PersistentResource>
    {
      try await self.updatePersistentResource(withPolling: withPolling, options: .init())
    }

    public func updatePersistentResource(
      withPolling: UpdatePersistentResourceRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> any GoogleCloudGax.PollableOperation<PersistentResource> {
      let poll = {
        () async throws -> GoogleCloudGax._PollableOperationImpl<PersistentResource>.State in
        throw GoogleCloudGax.RequestError.unimplemented
      }
      return GoogleCloudGax._PollableOperationImpl(
        initialState: .init(done: false, result: nil), poll: poll)
    }

    public func updatePersistentResource(
      persistentResource: PersistentResource?,
      updateMask: GoogleCloudWkt.FieldMask?,
    ) async throws -> any GoogleCloudGax.PollableOperation<PersistentResource> {
      let request = UpdatePersistentResourceRequest().with {
        $0.persistentResource = persistentResource
        $0.updateMask = updateMask
      }
      return try await self.updatePersistentResource(withPolling: request)
    }

    public func rebootPersistentResource(request: RebootPersistentResourceRequest) async throws
      -> GoogleLongRunning.Operation
    {
      try await self.rebootPersistentResource(request: request, options: .init())
    }

    public func rebootPersistentResource(
      request: RebootPersistentResourceRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func rebootPersistentResource(withPolling: RebootPersistentResourceRequest) async throws
      -> any GoogleCloudGax.PollableOperation<PersistentResource>
    {
      try await self.rebootPersistentResource(withPolling: withPolling, options: .init())
    }

    public func rebootPersistentResource(
      withPolling: RebootPersistentResourceRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> any GoogleCloudGax.PollableOperation<PersistentResource> {
      let poll = {
        () async throws -> GoogleCloudGax._PollableOperationImpl<PersistentResource>.State in
        throw GoogleCloudGax.RequestError.unimplemented
      }
      return GoogleCloudGax._PollableOperationImpl(
        initialState: .init(done: false, result: nil), poll: poll)
    }

    public func rebootPersistentResource(
      name: Swift.String,
    ) async throws -> any GoogleCloudGax.PollableOperation<PersistentResource> {
      let request = RebootPersistentResourceRequest().with {
        $0.name = name
      }
      return try await self.rebootPersistentResource(withPolling: request)
    }

    public func listLocations(request: GoogleCloudLocation.ListLocationsRequest) async throws
      -> GoogleCloudLocation.ListLocationsResponse
    {
      try await self.listLocations(request: request, options: .init())
    }

    public func listLocations(
      request: GoogleCloudLocation.ListLocationsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudLocation.ListLocationsResponse {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func listLocations(
      byItem: GoogleCloudLocation.ListLocationsRequest
    ) throws -> any AsyncSequence<GoogleCloudLocation.Location, Swift.Error> {
      try self.listLocations(byItem: byItem, options: .init())
    }

    public func listLocations(
      byItem: GoogleCloudLocation.ListLocationsRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<GoogleCloudLocation.Location, Swift.Error> {
      let listRpc = {
        (token: Swift.String) async throws -> GoogleCloudLocation.ListLocationsResponse in
        throw GoogleCloudGax.RequestError.unimplemented
      }
      return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
    }

    public func getLocation(request: GoogleCloudLocation.GetLocationRequest) async throws
      -> GoogleCloudLocation.Location
    {
      try await self.getLocation(request: request, options: .init())
    }

    public func getLocation(
      request: GoogleCloudLocation.GetLocationRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudLocation.Location {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func setIamPolicy(request: GoogleIAMV1.SetIamPolicyRequest) async throws
      -> GoogleIAMV1.Policy
    {
      try await self.setIamPolicy(request: request, options: .init())
    }

    public func setIamPolicy(
      request: GoogleIAMV1.SetIamPolicyRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleIAMV1.Policy {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func getIamPolicy(request: GoogleIAMV1.GetIamPolicyRequest) async throws
      -> GoogleIAMV1.Policy
    {
      try await self.getIamPolicy(request: request, options: .init())
    }

    public func getIamPolicy(
      request: GoogleIAMV1.GetIamPolicyRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleIAMV1.Policy {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func testIamPermissions(request: GoogleIAMV1.TestIamPermissionsRequest) async throws
      -> GoogleIAMV1.TestIamPermissionsResponse
    {
      try await self.testIamPermissions(request: request, options: .init())
    }

    public func testIamPermissions(
      request: GoogleIAMV1.TestIamPermissionsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleIAMV1.TestIamPermissionsResponse {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func listOperations(request: GoogleLongRunning.ListOperationsRequest) async throws
      -> GoogleLongRunning.ListOperationsResponse
    {
      try await self.listOperations(request: request, options: .init())
    }

    public func listOperations(
      request: GoogleLongRunning.ListOperationsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.ListOperationsResponse {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func listOperations(
      byItem: GoogleLongRunning.ListOperationsRequest
    ) throws -> any AsyncSequence<GoogleLongRunning.Operation, Swift.Error> {
      try self.listOperations(byItem: byItem, options: .init())
    }

    public func listOperations(
      byItem: GoogleLongRunning.ListOperationsRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<GoogleLongRunning.Operation, Swift.Error> {
      let listRpc = {
        (token: Swift.String) async throws -> GoogleLongRunning.ListOperationsResponse in
        throw GoogleCloudGax.RequestError.unimplemented
      }
      return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
    }

    public func listOperations(
      name: Swift.String,
      filter: Swift.String,
    ) throws -> any AsyncSequence<GoogleLongRunning.Operation, Swift.Error> {
      let request = GoogleLongRunning.ListOperationsRequest().with {
        $0.name = name
        $0.filter = filter
      }
      return try self.listOperations(byItem: request)
    }

    public func getOperation(request: GoogleLongRunning.GetOperationRequest) async throws
      -> GoogleLongRunning.Operation
    {
      try await self.getOperation(request: request, options: .init())
    }

    public func getOperation(
      request: GoogleLongRunning.GetOperationRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func getOperation(
      name: Swift.String,
    ) async throws -> GoogleLongRunning.Operation {
      let request = GoogleLongRunning.GetOperationRequest().with {
        $0.name = name
      }
      return try await self.getOperation(request: request)
    }

    public func deleteOperation(request: GoogleLongRunning.DeleteOperationRequest) async throws {
      try await self.deleteOperation(request: request, options: .init())
    }

    public func deleteOperation(
      request: GoogleLongRunning.DeleteOperationRequest, options: GoogleCloudGax.RequestOptions
    ) async throws {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func deleteOperation(
      name: Swift.String,
    ) async throws {
      let request = GoogleLongRunning.DeleteOperationRequest().with {
        $0.name = name
      }
      try await self.deleteOperation(request: request)
    }

    public func cancelOperation(request: GoogleLongRunning.CancelOperationRequest) async throws {
      try await self.cancelOperation(request: request, options: .init())
    }

    public func cancelOperation(
      request: GoogleLongRunning.CancelOperationRequest, options: GoogleCloudGax.RequestOptions
    ) async throws {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func cancelOperation(
      name: Swift.String,
    ) async throws {
      let request = GoogleLongRunning.CancelOperationRequest().with {
        $0.name = name
      }
      try await self.cancelOperation(request: request)
    }

    public func waitOperation(request: GoogleLongRunning.WaitOperationRequest) async throws
      -> GoogleLongRunning.Operation
    {
      try await self.waitOperation(request: request, options: .init())
    }

    public func waitOperation(
      request: GoogleLongRunning.WaitOperationRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      throw GoogleCloudGax.RequestError.unimplemented
    }
  }
#endif
