// Code generated by sidekick. DO NOT EDIT.
//
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import Foundation
#if canImport(FoundationNetworking)
  import FoundationNetworking
#endif
import GoogleCloudWkt
import GoogleCloudGax

/// Service to handle EDW migrations.
///
/// @Snippet(path: "MigrationServiceQuickstart")
public class MigrationServiceClient: Clients.MigrationServiceProtocol {
  let inner: any Clients.MigrationServiceStub

  /// Creates a new `MigrationServiceClient` instance.
  public init(_ options: GoogleCloudGax.ClientOptions = .init()) throws {
    var inner: any Clients.MigrationServiceStub = try Clients.MigrationServiceTransport(options)
    inner = Clients.MigrationServiceRetry(inner, options: options)
    if let logger = options.logger {
      inner = Clients.MigrationServiceLogging(inner, logger: logger)
    }
    self.inner = inner
  }

  /// Creates a migration workflow.
  ///
  /// @Snippet(path: "MigrationService_CreateMigrationWorkflow")
  public func createMigrationWorkflow(
    request: CreateMigrationWorkflowRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleBigQueryMigrationV2.MigrationWorkflow {
    try await self.inner.createMigrationWorkflow(request: request, options: options)
  }

  /// Gets a previously created migration workflow.
  ///
  /// @Snippet(path: "MigrationService_GetMigrationWorkflow")
  public func getMigrationWorkflow(
    request: GetMigrationWorkflowRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleBigQueryMigrationV2.MigrationWorkflow {
    try await self.inner.getMigrationWorkflow(request: request, options: options)
  }

  /// Lists previously created migration workflow.
  ///
  /// @Snippet(path: "MigrationService_ListMigrationWorkflows")
  public func listMigrationWorkflows(
    request: ListMigrationWorkflowsRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleBigQueryMigrationV2.ListMigrationWorkflowsResponse {
    try await self.inner.listMigrationWorkflows(request: request, options: options)
  }

  /// Lists previously created migration workflow.
  ///
  /// @Snippet(path: "MigrationService_ListMigrationWorkflows")
  public func listMigrationWorkflows(
    byItem: ListMigrationWorkflowsRequest, options: GoogleCloudGax.RequestOptions
  ) throws -> any AsyncSequence<MigrationWorkflow, Swift.Error> {
    let listRpc = {
      (token: Swift.String) async throws -> GoogleBigQueryMigrationV2.ListMigrationWorkflowsResponse
      in
      var request = byItem
      request.pageToken = token
      return try await self.listMigrationWorkflows(request: request, options: options)
    }
    return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
  }

  /// Deletes a migration workflow by name.
  ///
  /// @Snippet(path: "MigrationService_DeleteMigrationWorkflow")
  public func deleteMigrationWorkflow(
    request: DeleteMigrationWorkflowRequest, options: GoogleCloudGax.RequestOptions
  ) async throws {
    try await self.inner.deleteMigrationWorkflow(request: request, options: options)
  }

  /// Starts a previously created migration workflow. I.e., the state transitions
  /// from DRAFT to RUNNING. This is a no-op if the state is already RUNNING.
  /// An error will be signaled if the state is anything other than DRAFT or
  /// RUNNING.
  ///
  /// @Snippet(path: "MigrationService_StartMigrationWorkflow")
  public func startMigrationWorkflow(
    request: StartMigrationWorkflowRequest, options: GoogleCloudGax.RequestOptions
  ) async throws {
    try await self.inner.startMigrationWorkflow(request: request, options: options)
  }

  /// Gets a previously created migration subtask.
  ///
  /// @Snippet(path: "MigrationService_GetMigrationSubtask")
  public func getMigrationSubtask(
    request: GetMigrationSubtaskRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleBigQueryMigrationV2.MigrationSubtask {
    try await self.inner.getMigrationSubtask(request: request, options: options)
  }

  /// Lists previously created migration subtasks.
  ///
  /// @Snippet(path: "MigrationService_ListMigrationSubtasks")
  public func listMigrationSubtasks(
    request: ListMigrationSubtasksRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleBigQueryMigrationV2.ListMigrationSubtasksResponse {
    try await self.inner.listMigrationSubtasks(request: request, options: options)
  }

  /// Lists previously created migration subtasks.
  ///
  /// @Snippet(path: "MigrationService_ListMigrationSubtasks")
  public func listMigrationSubtasks(
    byItem: ListMigrationSubtasksRequest, options: GoogleCloudGax.RequestOptions
  ) throws -> any AsyncSequence<MigrationSubtask, Swift.Error> {
    let listRpc = {
      (token: Swift.String) async throws -> GoogleBigQueryMigrationV2.ListMigrationSubtasksResponse
      in
      var request = byItem
      request.pageToken = token
      return try await self.listMigrationSubtasks(request: request, options: options)
    }
    return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
  }
}

extension Clients {
  /// A Swift protocol to mock `MigrationServiceClient`.
  ///
  /// To mock `MigrationServiceClient` change your functions to receive
  /// `some MigrationServiceProtocol` or `any MigrationServiceProtocol`
  /// and pass a mock implementation in your tests.
  public protocol MigrationServiceProtocol {
    /// See `MigrationServiceClient.createMigrationWorkflow`.
    func createMigrationWorkflow(request: CreateMigrationWorkflowRequest) async throws
      -> GoogleBigQueryMigrationV2.MigrationWorkflow

    /// See `MigrationServiceClient.createMigrationWorkflow`.
    func createMigrationWorkflow(
      parent: Swift.String,
      migrationWorkflow: MigrationWorkflow?,
    ) async throws -> GoogleBigQueryMigrationV2.MigrationWorkflow

    /// See `MigrationServiceClient.getMigrationWorkflow`.
    func getMigrationWorkflow(request: GetMigrationWorkflowRequest) async throws
      -> GoogleBigQueryMigrationV2.MigrationWorkflow

    /// See `MigrationServiceClient.getMigrationWorkflow`.
    func getMigrationWorkflow(
      name: Swift.String,
    ) async throws -> GoogleBigQueryMigrationV2.MigrationWorkflow

    /// See `MigrationServiceClient.listMigrationWorkflows`.
    func listMigrationWorkflows(request: ListMigrationWorkflowsRequest) async throws
      -> GoogleBigQueryMigrationV2.ListMigrationWorkflowsResponse

    /// See `MigrationServiceClient.listMigrationWorkflows`.
    func listMigrationWorkflows(
      byItem: ListMigrationWorkflowsRequest
    ) throws -> any AsyncSequence<MigrationWorkflow, Swift.Error>

    /// See `MigrationServiceClient.listMigrationWorkflows`.
    func listMigrationWorkflows(
      parent: Swift.String,
    ) throws -> any AsyncSequence<MigrationWorkflow, Swift.Error>

    /// See `MigrationServiceClient.deleteMigrationWorkflow`.
    func deleteMigrationWorkflow(request: DeleteMigrationWorkflowRequest) async throws

    /// See `MigrationServiceClient.deleteMigrationWorkflow`.
    func deleteMigrationWorkflow(
      name: Swift.String,
    ) async throws

    /// See `MigrationServiceClient.startMigrationWorkflow`.
    func startMigrationWorkflow(request: StartMigrationWorkflowRequest) async throws

    /// See `MigrationServiceClient.startMigrationWorkflow`.
    func startMigrationWorkflow(
      name: Swift.String,
    ) async throws

    /// See `MigrationServiceClient.getMigrationSubtask`.
    func getMigrationSubtask(request: GetMigrationSubtaskRequest) async throws
      -> GoogleBigQueryMigrationV2.MigrationSubtask

    /// See `MigrationServiceClient.getMigrationSubtask`.
    func getMigrationSubtask(
      name: Swift.String,
    ) async throws -> GoogleBigQueryMigrationV2.MigrationSubtask

    /// See `MigrationServiceClient.listMigrationSubtasks`.
    func listMigrationSubtasks(request: ListMigrationSubtasksRequest) async throws
      -> GoogleBigQueryMigrationV2.ListMigrationSubtasksResponse

    /// See `MigrationServiceClient.listMigrationSubtasks`.
    func listMigrationSubtasks(
      byItem: ListMigrationSubtasksRequest
    ) throws -> any AsyncSequence<MigrationSubtask, Swift.Error>

    /// See `MigrationServiceClient.listMigrationSubtasks`.
    func listMigrationSubtasks(
      parent: Swift.String,
    ) throws -> any AsyncSequence<MigrationSubtask, Swift.Error>

    /// See `MigrationServiceClient.createMigrationWorkflow`.
    func createMigrationWorkflow(
      request: CreateMigrationWorkflowRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleBigQueryMigrationV2.MigrationWorkflow

    /// See `MigrationServiceClient.getMigrationWorkflow`.
    func getMigrationWorkflow(
      request: GetMigrationWorkflowRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleBigQueryMigrationV2.MigrationWorkflow

    /// See `MigrationServiceClient.listMigrationWorkflows`.
    func listMigrationWorkflows(
      request: ListMigrationWorkflowsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleBigQueryMigrationV2.ListMigrationWorkflowsResponse

    /// See `MigrationServiceClient.listMigrationWorkflows`.
    func listMigrationWorkflows(
      byItem: ListMigrationWorkflowsRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<MigrationWorkflow, Swift.Error>

    /// See `MigrationServiceClient.deleteMigrationWorkflow`.
    func deleteMigrationWorkflow(
      request: DeleteMigrationWorkflowRequest, options: GoogleCloudGax.RequestOptions
    ) async throws

    /// See `MigrationServiceClient.startMigrationWorkflow`.
    func startMigrationWorkflow(
      request: StartMigrationWorkflowRequest, options: GoogleCloudGax.RequestOptions
    ) async throws

    /// See `MigrationServiceClient.getMigrationSubtask`.
    func getMigrationSubtask(
      request: GetMigrationSubtaskRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleBigQueryMigrationV2.MigrationSubtask

    /// See `MigrationServiceClient.listMigrationSubtasks`.
    func listMigrationSubtasks(
      request: ListMigrationSubtasksRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleBigQueryMigrationV2.ListMigrationSubtasksResponse

    /// See `MigrationServiceClient.listMigrationSubtasks`.
    func listMigrationSubtasks(
      byItem: ListMigrationSubtasksRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<MigrationSubtask, Swift.Error>
  }
}

// Default implementations
extension Clients.MigrationServiceProtocol {
  public func createMigrationWorkflow(request: CreateMigrationWorkflowRequest) async throws
    -> GoogleBigQueryMigrationV2.MigrationWorkflow
  {
    try await self.createMigrationWorkflow(request: request, options: .init())
  }

  public func createMigrationWorkflow(
    request: CreateMigrationWorkflowRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleBigQueryMigrationV2.MigrationWorkflow {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func createMigrationWorkflow(
    parent: Swift.String,
    migrationWorkflow: MigrationWorkflow?,
  ) async throws -> GoogleBigQueryMigrationV2.MigrationWorkflow {
    let request = CreateMigrationWorkflowRequest().with {
      $0.parent = parent
      $0.migrationWorkflow = migrationWorkflow
    }
    return try await self.createMigrationWorkflow(request: request)
  }

  public func getMigrationWorkflow(request: GetMigrationWorkflowRequest) async throws
    -> GoogleBigQueryMigrationV2.MigrationWorkflow
  {
    try await self.getMigrationWorkflow(request: request, options: .init())
  }

  public func getMigrationWorkflow(
    request: GetMigrationWorkflowRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleBigQueryMigrationV2.MigrationWorkflow {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func getMigrationWorkflow(
    name: Swift.String,
  ) async throws -> GoogleBigQueryMigrationV2.MigrationWorkflow {
    let request = GetMigrationWorkflowRequest().with {
      $0.name = name
    }
    return try await self.getMigrationWorkflow(request: request)
  }

  public func listMigrationWorkflows(request: ListMigrationWorkflowsRequest) async throws
    -> GoogleBigQueryMigrationV2.ListMigrationWorkflowsResponse
  {
    try await self.listMigrationWorkflows(request: request, options: .init())
  }

  public func listMigrationWorkflows(
    request: ListMigrationWorkflowsRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleBigQueryMigrationV2.ListMigrationWorkflowsResponse {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func listMigrationWorkflows(
    byItem: ListMigrationWorkflowsRequest
  ) throws -> any AsyncSequence<MigrationWorkflow, Swift.Error> {
    try self.listMigrationWorkflows(byItem: byItem, options: .init())
  }

  public func listMigrationWorkflows(
    byItem: ListMigrationWorkflowsRequest, options: GoogleCloudGax.RequestOptions
  ) throws -> any AsyncSequence<MigrationWorkflow, Swift.Error> {
    let listRpc = {
      (token: Swift.String) async throws -> GoogleBigQueryMigrationV2.ListMigrationWorkflowsResponse
      in
      throw GoogleCloudGax.RequestError.unimplemented
    }
    return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
  }

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

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

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

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

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

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

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

  public func getMigrationSubtask(request: GetMigrationSubtaskRequest) async throws
    -> GoogleBigQueryMigrationV2.MigrationSubtask
  {
    try await self.getMigrationSubtask(request: request, options: .init())
  }

  public func getMigrationSubtask(
    request: GetMigrationSubtaskRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleBigQueryMigrationV2.MigrationSubtask {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func getMigrationSubtask(
    name: Swift.String,
  ) async throws -> GoogleBigQueryMigrationV2.MigrationSubtask {
    let request = GetMigrationSubtaskRequest().with {
      $0.name = name
    }
    return try await self.getMigrationSubtask(request: request)
  }

  public func listMigrationSubtasks(request: ListMigrationSubtasksRequest) async throws
    -> GoogleBigQueryMigrationV2.ListMigrationSubtasksResponse
  {
    try await self.listMigrationSubtasks(request: request, options: .init())
  }

  public func listMigrationSubtasks(
    request: ListMigrationSubtasksRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleBigQueryMigrationV2.ListMigrationSubtasksResponse {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func listMigrationSubtasks(
    byItem: ListMigrationSubtasksRequest
  ) throws -> any AsyncSequence<MigrationSubtask, Swift.Error> {
    try self.listMigrationSubtasks(byItem: byItem, options: .init())
  }

  public func listMigrationSubtasks(
    byItem: ListMigrationSubtasksRequest, options: GoogleCloudGax.RequestOptions
  ) throws -> any AsyncSequence<MigrationSubtask, Swift.Error> {
    let listRpc = {
      (token: Swift.String) async throws -> GoogleBigQueryMigrationV2.ListMigrationSubtasksResponse
      in
      throw GoogleCloudGax.RequestError.unimplemented
    }
    return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
  }

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