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

  /// Service for managing [Playbooks][google.cloud.dialogflow.cx.v3.Playbook].
  ///
  /// [google.cloud.dialogflow.cx.v3.Playbook]: <doc:Playbook>
  ///
  /// @Snippet(path: "PlaybooksQuickstart")
  public class PlaybooksClient: Clients.PlaybooksProtocol {
    let inner: any Clients.PlaybooksStub
    let pollingErrorPolicy: GoogleCloudGax.PollingErrorPolicy
    let pollingBackoffPolicy: GoogleCloudGax.BackoffPolicy

    /// Creates a new `PlaybooksClient` instance.
    public init(_ options: GoogleCloudGax.ClientOptions = .init()) throws {
      var inner: any Clients.PlaybooksStub = try Clients.PlaybooksTransport(options)
      inner = Clients.PlaybooksRetry(inner, options: options)
      if let logger = options.logger {
        inner = Clients.PlaybooksLogging(inner, logger: logger)
      }
      self.inner = inner
      self.pollingErrorPolicy = options.pollingErrorPolicy
      self.pollingBackoffPolicy = options.pollingBackoffPolicy
    }

    /// Creates a playbook in a specified agent.
    ///
    /// @Snippet(path: "Playbooks_CreatePlaybook")
    public func createPlaybook(
      request: CreatePlaybookRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDialogflowCXV3.Playbook {
      try await self.inner.createPlaybook(request: request, options: options)
    }

    /// Deletes a specified playbook.
    ///
    /// @Snippet(path: "Playbooks_DeletePlaybook")
    public func deletePlaybook(
      request: DeletePlaybookRequest, options: GoogleCloudGax.RequestOptions
    ) async throws {
      try await self.inner.deletePlaybook(request: request, options: options)
    }

    /// Returns a list of playbooks in the specified agent.
    ///
    /// @Snippet(path: "Playbooks_ListPlaybooks")
    public func listPlaybooks(
      request: ListPlaybooksRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDialogflowCXV3.ListPlaybooksResponse {
      try await self.inner.listPlaybooks(request: request, options: options)
    }

    /// Returns a list of playbooks in the specified agent.
    ///
    /// @Snippet(path: "Playbooks_ListPlaybooks")
    public func listPlaybooks(
      byItem: ListPlaybooksRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<Playbook, Swift.Error> {
      let listRpc = {
        (token: Swift.String) async throws -> GoogleCloudDialogflowCXV3.ListPlaybooksResponse in
        var request = byItem
        request.pageToken = token
        return try await self.listPlaybooks(request: request, options: options)
      }
      return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
    }

    /// Retrieves the specified Playbook.
    ///
    /// @Snippet(path: "Playbooks_GetPlaybook")
    public func getPlaybook(
      request: GetPlaybookRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDialogflowCXV3.Playbook {
      try await self.inner.getPlaybook(request: request, options: options)
    }

    /// Exports the specified playbook to a binary file.
    ///
    /// Note that resources (e.g. examples, tools) that the playbook
    /// references will also be exported.
    ///
    /// @Snippet(path: "Playbooks_ExportPlaybook")
    public func exportPlaybook(
      request: ExportPlaybookRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      try await self.inner.exportPlaybook(request: request, options: options)
    }

    /// Exports the specified playbook to a binary file.
    ///
    /// Note that resources (e.g. examples, tools) that the playbook
    /// references will also be exported.
    ///
    /// @Snippet(path: "Playbooks_ExportPlaybook")
    public func exportPlaybook(
      withPolling: ExportPlaybookRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> any GoogleCloudGax.PollableOperation<ExportPlaybookResponse> {
      let extractStatus = {
        (op: GoogleLongRunning.Operation) throws
          -> GoogleCloudGax._PollableOperationImpl<ExportPlaybookResponse>.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 ExportPlaybookResponse(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.exportPlaybook(request: withPolling, options: options)
      let initialState = try extractStatus(rawOp)
      let poll = {
        () async throws -> GoogleCloudGax._PollableOperationImpl<ExportPlaybookResponse>.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,
      )
    }

    /// Imports the specified playbook to the specified agent from a binary file.
    ///
    /// @Snippet(path: "Playbooks_ImportPlaybook")
    public func importPlaybook(
      request: ImportPlaybookRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      try await self.inner.importPlaybook(request: request, options: options)
    }

    /// Imports the specified playbook to the specified agent from a binary file.
    ///
    /// @Snippet(path: "Playbooks_ImportPlaybook")
    public func importPlaybook(
      withPolling: ImportPlaybookRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> any GoogleCloudGax.PollableOperation<ImportPlaybookResponse> {
      let extractStatus = {
        (op: GoogleLongRunning.Operation) throws
          -> GoogleCloudGax._PollableOperationImpl<ImportPlaybookResponse>.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 ImportPlaybookResponse(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.importPlaybook(request: withPolling, options: options)
      let initialState = try extractStatus(rawOp)
      let poll = {
        () async throws -> GoogleCloudGax._PollableOperationImpl<ImportPlaybookResponse>.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 the specified Playbook.
    ///
    /// @Snippet(path: "Playbooks_UpdatePlaybook")
    public func updatePlaybook(
      request: UpdatePlaybookRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDialogflowCXV3.Playbook {
      try await self.inner.updatePlaybook(request: request, options: options)
    }

    /// Creates a version for the specified Playbook.
    ///
    /// @Snippet(path: "Playbooks_CreatePlaybookVersion")
    public func createPlaybookVersion(
      request: CreatePlaybookVersionRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDialogflowCXV3.PlaybookVersion {
      try await self.inner.createPlaybookVersion(request: request, options: options)
    }

    /// Retrieves the specified version of the Playbook.
    ///
    /// @Snippet(path: "Playbooks_GetPlaybookVersion")
    public func getPlaybookVersion(
      request: GetPlaybookVersionRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDialogflowCXV3.PlaybookVersion {
      try await self.inner.getPlaybookVersion(request: request, options: options)
    }

    /// Retrieves the specified version of the Playbook and stores it as the
    /// current playbook draft, returning the playbook with resources updated.
    ///
    /// @Snippet(path: "Playbooks_RestorePlaybookVersion")
    public func restorePlaybookVersion(
      request: RestorePlaybookVersionRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDialogflowCXV3.RestorePlaybookVersionResponse {
      try await self.inner.restorePlaybookVersion(request: request, options: options)
    }

    /// Lists versions for the specified Playbook.
    ///
    /// @Snippet(path: "Playbooks_ListPlaybookVersions")
    public func listPlaybookVersions(
      request: ListPlaybookVersionsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDialogflowCXV3.ListPlaybookVersionsResponse {
      try await self.inner.listPlaybookVersions(request: request, options: options)
    }

    /// Lists versions for the specified Playbook.
    ///
    /// @Snippet(path: "Playbooks_ListPlaybookVersions")
    public func listPlaybookVersions(
      byItem: ListPlaybookVersionsRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<PlaybookVersion, Swift.Error> {
      let listRpc = {
        (token: Swift.String) async throws -> GoogleCloudDialogflowCXV3.ListPlaybookVersionsResponse
        in
        var request = byItem
        request.pageToken = token
        return try await self.listPlaybookVersions(request: request, options: options)
      }
      return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
    }

    /// Deletes the specified version of the Playbook.
    ///
    /// @Snippet(path: "Playbooks_DeletePlaybookVersion")
    public func deletePlaybookVersion(
      request: DeletePlaybookVersionRequest, options: GoogleCloudGax.RequestOptions
    ) async throws {
      try await self.inner.deletePlaybookVersion(request: request, options: options)
    }

    /// Lists information about the supported locations for this service.
    ///
    /// This method lists locations based on the resource scope provided in
    /// the [ListLocationsRequest.name][google.cloud.location.ListLocationsRequest.name] field: *
    /// **Global locations**: If `name` is empty, the method lists the
    /// public locations available to all projects. * **Project-specific
    /// locations**: If `name` follows the format
    /// `projects/{project}`, the method lists locations visible to that
    /// specific project. This includes public, private, or other
    /// project-specific locations enabled for the project.
    ///
    /// For gRPC and client library implementations, the resource name is
    /// passed as the `name` field. For direct service calls, the resource
    /// name is
    /// incorporated into the request path based on the specific service
    /// implementation and version.
    ///
    /// [google.cloud.location.ListLocationsRequest.name]: https://www.google.com/search?q=Swift+google.cloud.location+GoogleCloudLocation.ListLocationsRequest/name
    ///
    /// @Snippet(path: "Playbooks_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.
    ///
    /// This method lists locations based on the resource scope provided in
    /// the [ListLocationsRequest.name][google.cloud.location.ListLocationsRequest.name] field: *
    /// **Global locations**: If `name` is empty, the method lists the
    /// public locations available to all projects. * **Project-specific
    /// locations**: If `name` follows the format
    /// `projects/{project}`, the method lists locations visible to that
    /// specific project. This includes public, private, or other
    /// project-specific locations enabled for the project.
    ///
    /// For gRPC and client library implementations, the resource name is
    /// passed as the `name` field. For direct service calls, the resource
    /// name is
    /// incorporated into the request path based on the specific service
    /// implementation and version.
    ///
    /// [google.cloud.location.ListLocationsRequest.name]: https://www.google.com/search?q=Swift+google.cloud.location+GoogleCloudLocation.ListLocationsRequest/name
    ///
    /// @Snippet(path: "Playbooks_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: "Playbooks_GetLocation")
    public func getLocation(
      request: GoogleCloudLocation.GetLocationRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudLocation.Location {
      try await self.inner.getLocation(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: "Playbooks_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: "Playbooks_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: "Playbooks_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: "Playbooks_CancelOperation")
    public func cancelOperation(
      request: GoogleLongRunning.CancelOperationRequest, options: GoogleCloudGax.RequestOptions
    ) async throws {
      try await self.inner.cancelOperation(request: request, options: options)
    }
  }

  extension Clients {
    /// A Swift protocol to mock `PlaybooksClient`.
    ///
    /// To mock `PlaybooksClient` change your functions to receive
    /// `some PlaybooksProtocol` or `any PlaybooksProtocol`
    /// and pass a mock implementation in your tests.
    public protocol PlaybooksProtocol {
      /// See `PlaybooksClient.createPlaybook`.
      func createPlaybook(request: CreatePlaybookRequest) async throws
        -> GoogleCloudDialogflowCXV3.Playbook

      /// See `PlaybooksClient.createPlaybook`.
      func createPlaybook(
        parent: Swift.String,
        playbook: Playbook?,
      ) async throws -> GoogleCloudDialogflowCXV3.Playbook

      /// See `PlaybooksClient.deletePlaybook`.
      func deletePlaybook(request: DeletePlaybookRequest) async throws

      /// See `PlaybooksClient.deletePlaybook`.
      func deletePlaybook(
        name: Swift.String,
      ) async throws

      /// See `PlaybooksClient.listPlaybooks`.
      func listPlaybooks(request: ListPlaybooksRequest) async throws
        -> GoogleCloudDialogflowCXV3.ListPlaybooksResponse

      /// See `PlaybooksClient.listPlaybooks`.
      func listPlaybooks(
        byItem: ListPlaybooksRequest
      ) throws -> any AsyncSequence<Playbook, Swift.Error>

      /// See `PlaybooksClient.listPlaybooks`.
      func listPlaybooks(
        parent: Swift.String,
      ) throws -> any AsyncSequence<Playbook, Swift.Error>

      /// See `PlaybooksClient.getPlaybook`.
      func getPlaybook(request: GetPlaybookRequest) async throws
        -> GoogleCloudDialogflowCXV3.Playbook

      /// See `PlaybooksClient.getPlaybook`.
      func getPlaybook(
        name: Swift.String,
      ) async throws -> GoogleCloudDialogflowCXV3.Playbook

      /// See `PlaybooksClient.exportPlaybook`.
      func exportPlaybook(request: ExportPlaybookRequest) async throws
        -> GoogleLongRunning.Operation

      /// See `PlaybooksClient.exportPlaybook`.
      func exportPlaybook(withPolling: ExportPlaybookRequest) async throws -> any GoogleCloudGax
        .PollableOperation<ExportPlaybookResponse>

      /// See `PlaybooksClient.importPlaybook`.
      func importPlaybook(request: ImportPlaybookRequest) async throws
        -> GoogleLongRunning.Operation

      /// See `PlaybooksClient.importPlaybook`.
      func importPlaybook(withPolling: ImportPlaybookRequest) async throws -> any GoogleCloudGax
        .PollableOperation<ImportPlaybookResponse>

      /// See `PlaybooksClient.updatePlaybook`.
      func updatePlaybook(request: UpdatePlaybookRequest) async throws
        -> GoogleCloudDialogflowCXV3.Playbook

      /// See `PlaybooksClient.updatePlaybook`.
      func updatePlaybook(
        playbook: Playbook?,
        updateMask: GoogleCloudWkt.FieldMask?,
      ) async throws -> GoogleCloudDialogflowCXV3.Playbook

      /// See `PlaybooksClient.createPlaybookVersion`.
      func createPlaybookVersion(request: CreatePlaybookVersionRequest) async throws
        -> GoogleCloudDialogflowCXV3.PlaybookVersion

      /// See `PlaybooksClient.createPlaybookVersion`.
      func createPlaybookVersion(
        parent: Swift.String,
        playbookVersion: PlaybookVersion?,
      ) async throws -> GoogleCloudDialogflowCXV3.PlaybookVersion

      /// See `PlaybooksClient.getPlaybookVersion`.
      func getPlaybookVersion(request: GetPlaybookVersionRequest) async throws
        -> GoogleCloudDialogflowCXV3.PlaybookVersion

      /// See `PlaybooksClient.getPlaybookVersion`.
      func getPlaybookVersion(
        name: Swift.String,
      ) async throws -> GoogleCloudDialogflowCXV3.PlaybookVersion

      /// See `PlaybooksClient.restorePlaybookVersion`.
      func restorePlaybookVersion(request: RestorePlaybookVersionRequest) async throws
        -> GoogleCloudDialogflowCXV3.RestorePlaybookVersionResponse

      /// See `PlaybooksClient.restorePlaybookVersion`.
      func restorePlaybookVersion(
        name: Swift.String,
      ) async throws -> GoogleCloudDialogflowCXV3.RestorePlaybookVersionResponse

      /// See `PlaybooksClient.listPlaybookVersions`.
      func listPlaybookVersions(request: ListPlaybookVersionsRequest) async throws
        -> GoogleCloudDialogflowCXV3.ListPlaybookVersionsResponse

      /// See `PlaybooksClient.listPlaybookVersions`.
      func listPlaybookVersions(
        byItem: ListPlaybookVersionsRequest
      ) throws -> any AsyncSequence<PlaybookVersion, Swift.Error>

      /// See `PlaybooksClient.listPlaybookVersions`.
      func listPlaybookVersions(
        parent: Swift.String,
      ) throws -> any AsyncSequence<PlaybookVersion, Swift.Error>

      /// See `PlaybooksClient.deletePlaybookVersion`.
      func deletePlaybookVersion(request: DeletePlaybookVersionRequest) async throws

      /// See `PlaybooksClient.deletePlaybookVersion`.
      func deletePlaybookVersion(
        name: Swift.String,
      ) async throws

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

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

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

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

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

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

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

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

      /// See `PlaybooksClient.createPlaybook`.
      func createPlaybook(
        request: CreatePlaybookRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDialogflowCXV3.Playbook

      /// See `PlaybooksClient.deletePlaybook`.
      func deletePlaybook(
        request: DeletePlaybookRequest, options: GoogleCloudGax.RequestOptions
      ) async throws

      /// See `PlaybooksClient.listPlaybooks`.
      func listPlaybooks(
        request: ListPlaybooksRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDialogflowCXV3.ListPlaybooksResponse

      /// See `PlaybooksClient.listPlaybooks`.
      func listPlaybooks(
        byItem: ListPlaybooksRequest, options: GoogleCloudGax.RequestOptions
      ) throws -> any AsyncSequence<Playbook, Swift.Error>

      /// See `PlaybooksClient.getPlaybook`.
      func getPlaybook(
        request: GetPlaybookRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDialogflowCXV3.Playbook

      /// See `PlaybooksClient.exportPlaybook`.
      func exportPlaybook(
        request: ExportPlaybookRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation

      /// See `PlaybooksClient.exportPlaybook`.
      func exportPlaybook(
        withPolling: ExportPlaybookRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> any GoogleCloudGax.PollableOperation<ExportPlaybookResponse>

      /// See `PlaybooksClient.importPlaybook`.
      func importPlaybook(
        request: ImportPlaybookRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation

      /// See `PlaybooksClient.importPlaybook`.
      func importPlaybook(
        withPolling: ImportPlaybookRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> any GoogleCloudGax.PollableOperation<ImportPlaybookResponse>

      /// See `PlaybooksClient.updatePlaybook`.
      func updatePlaybook(
        request: UpdatePlaybookRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDialogflowCXV3.Playbook

      /// See `PlaybooksClient.createPlaybookVersion`.
      func createPlaybookVersion(
        request: CreatePlaybookVersionRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDialogflowCXV3.PlaybookVersion

      /// See `PlaybooksClient.getPlaybookVersion`.
      func getPlaybookVersion(
        request: GetPlaybookVersionRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDialogflowCXV3.PlaybookVersion

      /// See `PlaybooksClient.restorePlaybookVersion`.
      func restorePlaybookVersion(
        request: RestorePlaybookVersionRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDialogflowCXV3.RestorePlaybookVersionResponse

      /// See `PlaybooksClient.listPlaybookVersions`.
      func listPlaybookVersions(
        request: ListPlaybookVersionsRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDialogflowCXV3.ListPlaybookVersionsResponse

      /// See `PlaybooksClient.listPlaybookVersions`.
      func listPlaybookVersions(
        byItem: ListPlaybookVersionsRequest, options: GoogleCloudGax.RequestOptions
      ) throws -> any AsyncSequence<PlaybookVersion, Swift.Error>

      /// See `PlaybooksClient.deletePlaybookVersion`.
      func deletePlaybookVersion(
        request: DeletePlaybookVersionRequest, options: GoogleCloudGax.RequestOptions
      ) async throws

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

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

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

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

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

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

  // Default implementations
  extension Clients.PlaybooksProtocol {
    public func createPlaybook(request: CreatePlaybookRequest) async throws
      -> GoogleCloudDialogflowCXV3.Playbook
    {
      try await self.createPlaybook(request: request, options: .init())
    }

    public func createPlaybook(
      request: CreatePlaybookRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDialogflowCXV3.Playbook {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func createPlaybook(
      parent: Swift.String,
      playbook: Playbook?,
    ) async throws -> GoogleCloudDialogflowCXV3.Playbook {
      let request = CreatePlaybookRequest().with {
        $0.parent = parent
        $0.playbook = playbook
      }
      return try await self.createPlaybook(request: request)
    }

    public func deletePlaybook(request: DeletePlaybookRequest) async throws {
      try await self.deletePlaybook(request: request, options: .init())
    }

    public func deletePlaybook(
      request: DeletePlaybookRequest, options: GoogleCloudGax.RequestOptions
    ) async throws {
      throw GoogleCloudGax.RequestError.unimplemented
    }

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

    public func listPlaybooks(request: ListPlaybooksRequest) async throws
      -> GoogleCloudDialogflowCXV3.ListPlaybooksResponse
    {
      try await self.listPlaybooks(request: request, options: .init())
    }

    public func listPlaybooks(
      request: ListPlaybooksRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDialogflowCXV3.ListPlaybooksResponse {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func listPlaybooks(
      byItem: ListPlaybooksRequest
    ) throws -> any AsyncSequence<Playbook, Swift.Error> {
      try self.listPlaybooks(byItem: byItem, options: .init())
    }

    public func listPlaybooks(
      byItem: ListPlaybooksRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<Playbook, Swift.Error> {
      let listRpc = {
        (token: Swift.String) async throws -> GoogleCloudDialogflowCXV3.ListPlaybooksResponse in
        throw GoogleCloudGax.RequestError.unimplemented
      }
      return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
    }

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

    public func getPlaybook(request: GetPlaybookRequest) async throws
      -> GoogleCloudDialogflowCXV3.Playbook
    {
      try await self.getPlaybook(request: request, options: .init())
    }

    public func getPlaybook(
      request: GetPlaybookRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDialogflowCXV3.Playbook {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func getPlaybook(
      name: Swift.String,
    ) async throws -> GoogleCloudDialogflowCXV3.Playbook {
      let request = GetPlaybookRequest().with {
        $0.name = name
      }
      return try await self.getPlaybook(request: request)
    }

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

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

    public func exportPlaybook(withPolling: ExportPlaybookRequest) async throws
      -> any GoogleCloudGax.PollableOperation<ExportPlaybookResponse>
    {
      try await self.exportPlaybook(withPolling: withPolling, options: .init())
    }

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

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

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

    public func importPlaybook(withPolling: ImportPlaybookRequest) async throws
      -> any GoogleCloudGax.PollableOperation<ImportPlaybookResponse>
    {
      try await self.importPlaybook(withPolling: withPolling, options: .init())
    }

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

    public func updatePlaybook(request: UpdatePlaybookRequest) async throws
      -> GoogleCloudDialogflowCXV3.Playbook
    {
      try await self.updatePlaybook(request: request, options: .init())
    }

    public func updatePlaybook(
      request: UpdatePlaybookRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDialogflowCXV3.Playbook {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func updatePlaybook(
      playbook: Playbook?,
      updateMask: GoogleCloudWkt.FieldMask?,
    ) async throws -> GoogleCloudDialogflowCXV3.Playbook {
      let request = UpdatePlaybookRequest().with {
        $0.playbook = playbook
        $0.updateMask = updateMask
      }
      return try await self.updatePlaybook(request: request)
    }

    public func createPlaybookVersion(request: CreatePlaybookVersionRequest) async throws
      -> GoogleCloudDialogflowCXV3.PlaybookVersion
    {
      try await self.createPlaybookVersion(request: request, options: .init())
    }

    public func createPlaybookVersion(
      request: CreatePlaybookVersionRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDialogflowCXV3.PlaybookVersion {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func createPlaybookVersion(
      parent: Swift.String,
      playbookVersion: PlaybookVersion?,
    ) async throws -> GoogleCloudDialogflowCXV3.PlaybookVersion {
      let request = CreatePlaybookVersionRequest().with {
        $0.parent = parent
        $0.playbookVersion = playbookVersion
      }
      return try await self.createPlaybookVersion(request: request)
    }

    public func getPlaybookVersion(request: GetPlaybookVersionRequest) async throws
      -> GoogleCloudDialogflowCXV3.PlaybookVersion
    {
      try await self.getPlaybookVersion(request: request, options: .init())
    }

    public func getPlaybookVersion(
      request: GetPlaybookVersionRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDialogflowCXV3.PlaybookVersion {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func getPlaybookVersion(
      name: Swift.String,
    ) async throws -> GoogleCloudDialogflowCXV3.PlaybookVersion {
      let request = GetPlaybookVersionRequest().with {
        $0.name = name
      }
      return try await self.getPlaybookVersion(request: request)
    }

    public func restorePlaybookVersion(request: RestorePlaybookVersionRequest) async throws
      -> GoogleCloudDialogflowCXV3.RestorePlaybookVersionResponse
    {
      try await self.restorePlaybookVersion(request: request, options: .init())
    }

    public func restorePlaybookVersion(
      request: RestorePlaybookVersionRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDialogflowCXV3.RestorePlaybookVersionResponse {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func restorePlaybookVersion(
      name: Swift.String,
    ) async throws -> GoogleCloudDialogflowCXV3.RestorePlaybookVersionResponse {
      let request = RestorePlaybookVersionRequest().with {
        $0.name = name
      }
      return try await self.restorePlaybookVersion(request: request)
    }

    public func listPlaybookVersions(request: ListPlaybookVersionsRequest) async throws
      -> GoogleCloudDialogflowCXV3.ListPlaybookVersionsResponse
    {
      try await self.listPlaybookVersions(request: request, options: .init())
    }

    public func listPlaybookVersions(
      request: ListPlaybookVersionsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDialogflowCXV3.ListPlaybookVersionsResponse {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func listPlaybookVersions(
      byItem: ListPlaybookVersionsRequest
    ) throws -> any AsyncSequence<PlaybookVersion, Swift.Error> {
      try self.listPlaybookVersions(byItem: byItem, options: .init())
    }

    public func listPlaybookVersions(
      byItem: ListPlaybookVersionsRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<PlaybookVersion, Swift.Error> {
      let listRpc = {
        (token: Swift.String) async throws -> GoogleCloudDialogflowCXV3.ListPlaybookVersionsResponse
        in
        throw GoogleCloudGax.RequestError.unimplemented
      }
      return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
    }

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

    public func deletePlaybookVersion(request: DeletePlaybookVersionRequest) async throws {
      try await self.deletePlaybookVersion(request: request, options: .init())
    }

    public func deletePlaybookVersion(
      request: DeletePlaybookVersionRequest, options: GoogleCloudGax.RequestOptions
    ) async throws {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func deletePlaybookVersion(
      name: Swift.String,
    ) async throws {
      let request = DeletePlaybookVersionRequest().with {
        $0.name = name
      }
      try await self.deletePlaybookVersion(request: 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 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 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)
    }
  }
#endif
