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

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

/// Cloud Run Build Control Plane API
///
/// @Snippet(path: "BuildsQuickstart")
public class BuildsClient: Clients.BuildsProtocol {
  let inner: any Clients.BuildsStub

  /// Creates a new `BuildsClient` instance.
  public init(_ options: GoogleCloudGax.ClientOptions = .init()) throws {
    var inner: any Clients.BuildsStub = try Clients.BuildsTransport(options)
    inner = Clients.BuildsRetry(inner, options: options)
    if let logger = options.logger {
      inner = Clients.BuildsLogging(inner, logger: logger)
    }
    self.inner = inner
  }

  /// Submits a build in a given project.
  ///
  /// @Snippet(path: "Builds_SubmitBuild")
  public func submitBuild(
    request: SubmitBuildRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudRunV2.SubmitBuildResponse {
    try await self.inner.submitBuild(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: "Builds_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: "Builds_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: "Builds_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: "Builds_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: "Builds_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 `BuildsClient`.
  ///
  /// To mock `BuildsClient` change your functions to receive
  /// `some BuildsProtocol` or `any BuildsProtocol`
  /// and pass a mock implementation in your tests.
  public protocol BuildsProtocol {
    /// See `BuildsClient.submitBuild`.
    func submitBuild(request: SubmitBuildRequest) async throws
      -> GoogleCloudRunV2.SubmitBuildResponse

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

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

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

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

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

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

    /// See `BuildsClient.submitBuild`.
    func submitBuild(
      request: SubmitBuildRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudRunV2.SubmitBuildResponse

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

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

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

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

// Default implementations
extension Clients.BuildsProtocol {
  public func submitBuild(request: SubmitBuildRequest) async throws
    -> GoogleCloudRunV2.SubmitBuildResponse
  {
    try await self.submitBuild(request: request, options: .init())
  }

  public func submitBuild(
    request: SubmitBuildRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudRunV2.SubmitBuildResponse {
    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 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
  }
}
