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

/// A catalog of Google Cloud Platform services and SKUs.
/// Provides pricing information and metadata on Google Cloud Platform services
/// and SKUs.
///
/// @Snippet(path: "CloudCatalogQuickstart")
public class CloudCatalogClient: Clients.CloudCatalogProtocol {
  let inner: any Clients.CloudCatalogStub

  /// Creates a new `CloudCatalogClient` instance.
  public init(_ options: GoogleCloudGax.ClientOptions = .init()) throws {
    var inner: any Clients.CloudCatalogStub = try Clients.CloudCatalogTransport(options)
    inner = Clients.CloudCatalogRetry(inner, options: options)
    if let logger = options.logger {
      inner = Clients.CloudCatalogLogging(inner, logger: logger)
    }
    self.inner = inner
  }

  /// Lists all public cloud services.
  ///
  /// @Snippet(path: "CloudCatalog_ListServices")
  public func listServices(
    request: ListServicesRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudBillingV1.ListServicesResponse {
    try await self.inner.listServices(request: request, options: options)
  }

  /// Lists all public cloud services.
  ///
  /// @Snippet(path: "CloudCatalog_ListServices")
  public func listServices(
    byItem: ListServicesRequest, options: GoogleCloudGax.RequestOptions
  ) throws -> any AsyncSequence<Service, Swift.Error> {
    let listRpc = {
      (token: Swift.String) async throws -> GoogleCloudBillingV1.ListServicesResponse in
      var request = byItem
      request.pageToken = token
      return try await self.listServices(request: request, options: options)
    }
    return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
  }

  /// Lists all publicly available SKUs for a given cloud service.
  ///
  /// @Snippet(path: "CloudCatalog_ListSkus")
  public func listSkus(
    request: ListSkusRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudBillingV1.ListSkusResponse {
    try await self.inner.listSkus(request: request, options: options)
  }

  /// Lists all publicly available SKUs for a given cloud service.
  ///
  /// @Snippet(path: "CloudCatalog_ListSkus")
  public func listSkus(
    byItem: ListSkusRequest, options: GoogleCloudGax.RequestOptions
  ) throws -> any AsyncSequence<Sku, Swift.Error> {
    let listRpc = { (token: Swift.String) async throws -> GoogleCloudBillingV1.ListSkusResponse in
      var request = byItem
      request.pageToken = token
      return try await self.listSkus(request: request, options: options)
    }
    return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
  }
}

extension Clients {
  /// A Swift protocol to mock `CloudCatalogClient`.
  ///
  /// To mock `CloudCatalogClient` change your functions to receive
  /// `some CloudCatalogProtocol` or `any CloudCatalogProtocol`
  /// and pass a mock implementation in your tests.
  public protocol CloudCatalogProtocol {
    /// See `CloudCatalogClient.listServices`.
    func listServices(request: ListServicesRequest) async throws
      -> GoogleCloudBillingV1.ListServicesResponse

    /// See `CloudCatalogClient.listServices`.
    func listServices(
      byItem: ListServicesRequest
    ) throws -> any AsyncSequence<Service, Swift.Error>

    /// See `CloudCatalogClient.listSkus`.
    func listSkus(request: ListSkusRequest) async throws -> GoogleCloudBillingV1.ListSkusResponse

    /// See `CloudCatalogClient.listSkus`.
    func listSkus(
      byItem: ListSkusRequest
    ) throws -> any AsyncSequence<Sku, Swift.Error>

    /// See `CloudCatalogClient.listSkus`.
    func listSkus(
      parent: Swift.String,
    ) throws -> any AsyncSequence<Sku, Swift.Error>

    /// See `CloudCatalogClient.listServices`.
    func listServices(
      request: ListServicesRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudBillingV1.ListServicesResponse

    /// See `CloudCatalogClient.listServices`.
    func listServices(
      byItem: ListServicesRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<Service, Swift.Error>

    /// See `CloudCatalogClient.listSkus`.
    func listSkus(
      request: ListSkusRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudBillingV1.ListSkusResponse

    /// See `CloudCatalogClient.listSkus`.
    func listSkus(
      byItem: ListSkusRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<Sku, Swift.Error>
  }
}

// Default implementations
extension Clients.CloudCatalogProtocol {
  public func listServices(request: ListServicesRequest) async throws
    -> GoogleCloudBillingV1.ListServicesResponse
  {
    try await self.listServices(request: request, options: .init())
  }

  public func listServices(
    request: ListServicesRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudBillingV1.ListServicesResponse {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func listServices(
    byItem: ListServicesRequest
  ) throws -> any AsyncSequence<Service, Swift.Error> {
    try self.listServices(byItem: byItem, options: .init())
  }

  public func listServices(
    byItem: ListServicesRequest, options: GoogleCloudGax.RequestOptions
  ) throws -> any AsyncSequence<Service, Swift.Error> {
    let listRpc = {
      (token: Swift.String) async throws -> GoogleCloudBillingV1.ListServicesResponse in
      throw GoogleCloudGax.RequestError.unimplemented
    }
    return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
  }

  public func listSkus(request: ListSkusRequest) async throws
    -> GoogleCloudBillingV1.ListSkusResponse
  {
    try await self.listSkus(request: request, options: .init())
  }

  public func listSkus(
    request: ListSkusRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudBillingV1.ListSkusResponse {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func listSkus(
    byItem: ListSkusRequest
  ) throws -> any AsyncSequence<Sku, Swift.Error> {
    try self.listSkus(byItem: byItem, options: .init())
  }

  public func listSkus(
    byItem: ListSkusRequest, options: GoogleCloudGax.RequestOptions
  ) throws -> any AsyncSequence<Sku, Swift.Error> {
    let listRpc = { (token: Swift.String) async throws -> GoogleCloudBillingV1.ListSkusResponse in
      throw GoogleCloudGax.RequestError.unimplemented
    }
    return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
  }

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