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

/// Service for modifying ServingConfig.
///
/// @Snippet(path: "ServingConfigServiceQuickstart")
public class ServingConfigServiceClient: Clients.ServingConfigServiceProtocol {
  let inner: any Clients.ServingConfigServiceStub

  /// Creates a new `ServingConfigServiceClient` instance.
  public init(_ options: GoogleCloudGax.ClientOptions = .init()) throws {
    var inner: any Clients.ServingConfigServiceStub = try Clients.ServingConfigServiceTransport(
      options)
    inner = Clients.ServingConfigServiceRetry(inner, options: options)
    if let logger = options.logger {
      inner = Clients.ServingConfigServiceLogging(inner, logger: logger)
    }
    self.inner = inner
  }

  /// Creates a ServingConfig.
  ///
  /// A maximum of 100 [ServingConfig][google.cloud.retail.v2.ServingConfig]s are
  /// allowed in a [Catalog][google.cloud.retail.v2.Catalog], otherwise a
  /// FAILED_PRECONDITION error is returned.
  ///
  /// [google.cloud.retail.v2.Catalog]: <doc:Catalog>
  /// [google.cloud.retail.v2.ServingConfig]: <doc:ServingConfig>
  ///
  /// @Snippet(path: "ServingConfigService_CreateServingConfig")
  public func createServingConfig(
    request: CreateServingConfigRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudRetailV2.ServingConfig {
    try await self.inner.createServingConfig(request: request, options: options)
  }

  /// Deletes a ServingConfig.
  ///
  /// Returns a NotFound error if the ServingConfig does not exist.
  ///
  /// @Snippet(path: "ServingConfigService_DeleteServingConfig")
  public func deleteServingConfig(
    request: DeleteServingConfigRequest, options: GoogleCloudGax.RequestOptions
  ) async throws {
    try await self.inner.deleteServingConfig(request: request, options: options)
  }

  /// Updates a ServingConfig.
  ///
  /// @Snippet(path: "ServingConfigService_UpdateServingConfig")
  public func updateServingConfig(
    request: UpdateServingConfigRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudRetailV2.ServingConfig {
    try await self.inner.updateServingConfig(request: request, options: options)
  }

  /// Gets a ServingConfig.
  ///
  /// Returns a NotFound error if the ServingConfig does not exist.
  ///
  /// @Snippet(path: "ServingConfigService_GetServingConfig")
  public func getServingConfig(
    request: GetServingConfigRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudRetailV2.ServingConfig {
    try await self.inner.getServingConfig(request: request, options: options)
  }

  /// Lists all ServingConfigs linked to this catalog.
  ///
  /// @Snippet(path: "ServingConfigService_ListServingConfigs")
  public func listServingConfigs(
    request: ListServingConfigsRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudRetailV2.ListServingConfigsResponse {
    try await self.inner.listServingConfigs(request: request, options: options)
  }

  /// Lists all ServingConfigs linked to this catalog.
  ///
  /// @Snippet(path: "ServingConfigService_ListServingConfigs")
  public func listServingConfigs(
    byItem: ListServingConfigsRequest, options: GoogleCloudGax.RequestOptions
  ) throws -> any AsyncSequence<ServingConfig, Swift.Error> {
    let listRpc = {
      (token: Swift.String) async throws -> GoogleCloudRetailV2.ListServingConfigsResponse in
      var request = byItem
      request.pageToken = token
      return try await self.listServingConfigs(request: request, options: options)
    }
    return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
  }

  /// Enables a Control on the specified ServingConfig.
  /// The control is added in the last position of the list of controls
  /// it belongs to (e.g. if it's a facet spec control it will be applied
  /// in the last position of servingConfig.facetSpecIds)
  /// Returns a ALREADY_EXISTS error if the control has already been applied.
  /// Returns a FAILED_PRECONDITION error if the addition could exceed maximum
  /// number of control allowed for that type of control.
  ///
  /// @Snippet(path: "ServingConfigService_AddControl")
  public func addControl(
    request: AddControlRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudRetailV2.ServingConfig {
    try await self.inner.addControl(request: request, options: options)
  }

  /// Disables a Control on the specified ServingConfig.
  /// The control is removed from the ServingConfig.
  /// Returns a NOT_FOUND error if the Control is not enabled for the
  /// ServingConfig.
  ///
  /// @Snippet(path: "ServingConfigService_RemoveControl")
  public func removeControl(
    request: RemoveControlRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudRetailV2.ServingConfig {
    try await self.inner.removeControl(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: "ServingConfigService_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: "ServingConfigService_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: "ServingConfigService_GetOperation")
  func getOperation(
    request: GoogleLongRunning.GetOperationRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleLongRunning.Operation {
    try await self.inner.getOperation(request: request, options: options)
  }
}

extension Clients {
  /// A Swift protocol to mock `ServingConfigServiceClient`.
  ///
  /// To mock `ServingConfigServiceClient` change your functions to receive
  /// `some ServingConfigServiceProtocol` or `any ServingConfigServiceProtocol`
  /// and pass a mock implementation in your tests.
  public protocol ServingConfigServiceProtocol {
    /// See `ServingConfigServiceClient.createServingConfig`.
    func createServingConfig(request: CreateServingConfigRequest) async throws
      -> GoogleCloudRetailV2.ServingConfig

    /// See `ServingConfigServiceClient.createServingConfig`.
    func createServingConfig(
      parent: Swift.String,
      servingConfig: ServingConfig?,
      servingConfigId: Swift.String,
    ) async throws -> GoogleCloudRetailV2.ServingConfig

    /// See `ServingConfigServiceClient.deleteServingConfig`.
    func deleteServingConfig(request: DeleteServingConfigRequest) async throws

    /// See `ServingConfigServiceClient.deleteServingConfig`.
    func deleteServingConfig(
      name: Swift.String,
    ) async throws

    /// See `ServingConfigServiceClient.updateServingConfig`.
    func updateServingConfig(request: UpdateServingConfigRequest) async throws
      -> GoogleCloudRetailV2.ServingConfig

    /// See `ServingConfigServiceClient.updateServingConfig`.
    func updateServingConfig(
      servingConfig: ServingConfig?,
      updateMask: GoogleCloudWkt.FieldMask?,
    ) async throws -> GoogleCloudRetailV2.ServingConfig

    /// See `ServingConfigServiceClient.getServingConfig`.
    func getServingConfig(request: GetServingConfigRequest) async throws
      -> GoogleCloudRetailV2.ServingConfig

    /// See `ServingConfigServiceClient.getServingConfig`.
    func getServingConfig(
      name: Swift.String,
    ) async throws -> GoogleCloudRetailV2.ServingConfig

    /// See `ServingConfigServiceClient.listServingConfigs`.
    func listServingConfigs(request: ListServingConfigsRequest) async throws
      -> GoogleCloudRetailV2.ListServingConfigsResponse

    /// See `ServingConfigServiceClient.listServingConfigs`.
    func listServingConfigs(
      byItem: ListServingConfigsRequest
    ) throws -> any AsyncSequence<ServingConfig, Swift.Error>

    /// See `ServingConfigServiceClient.listServingConfigs`.
    func listServingConfigs(
      parent: Swift.String,
    ) throws -> any AsyncSequence<ServingConfig, Swift.Error>

    /// See `ServingConfigServiceClient.addControl`.
    func addControl(request: AddControlRequest) async throws -> GoogleCloudRetailV2.ServingConfig

    /// See `ServingConfigServiceClient.addControl`.
    func addControl(
      servingConfig: Swift.String,
    ) async throws -> GoogleCloudRetailV2.ServingConfig

    /// See `ServingConfigServiceClient.removeControl`.
    func removeControl(request: RemoveControlRequest) async throws
      -> GoogleCloudRetailV2.ServingConfig

    /// See `ServingConfigServiceClient.removeControl`.
    func removeControl(
      servingConfig: Swift.String,
    ) async throws -> GoogleCloudRetailV2.ServingConfig

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

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

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

    /// See `ServingConfigServiceClient.createServingConfig`.
    func createServingConfig(
      request: CreateServingConfigRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudRetailV2.ServingConfig

    /// See `ServingConfigServiceClient.deleteServingConfig`.
    func deleteServingConfig(
      request: DeleteServingConfigRequest, options: GoogleCloudGax.RequestOptions
    ) async throws

    /// See `ServingConfigServiceClient.updateServingConfig`.
    func updateServingConfig(
      request: UpdateServingConfigRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudRetailV2.ServingConfig

    /// See `ServingConfigServiceClient.getServingConfig`.
    func getServingConfig(
      request: GetServingConfigRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudRetailV2.ServingConfig

    /// See `ServingConfigServiceClient.listServingConfigs`.
    func listServingConfigs(
      request: ListServingConfigsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudRetailV2.ListServingConfigsResponse

    /// See `ServingConfigServiceClient.listServingConfigs`.
    func listServingConfigs(
      byItem: ListServingConfigsRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<ServingConfig, Swift.Error>

    /// See `ServingConfigServiceClient.addControl`.
    func addControl(
      request: AddControlRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudRetailV2.ServingConfig

    /// See `ServingConfigServiceClient.removeControl`.
    func removeControl(
      request: RemoveControlRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudRetailV2.ServingConfig

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

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

// Default implementations
extension Clients.ServingConfigServiceProtocol {
  public func createServingConfig(request: CreateServingConfigRequest) async throws
    -> GoogleCloudRetailV2.ServingConfig
  {
    try await self.createServingConfig(request: request, options: .init())
  }

  public func createServingConfig(
    request: CreateServingConfigRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudRetailV2.ServingConfig {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func createServingConfig(
    parent: Swift.String,
    servingConfig: ServingConfig?,
    servingConfigId: Swift.String,
  ) async throws -> GoogleCloudRetailV2.ServingConfig {
    let request = CreateServingConfigRequest().with {
      $0.parent = parent
      $0.servingConfig = servingConfig
      $0.servingConfigId = servingConfigId
    }
    return try await self.createServingConfig(request: request)
  }

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

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

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

  public func updateServingConfig(request: UpdateServingConfigRequest) async throws
    -> GoogleCloudRetailV2.ServingConfig
  {
    try await self.updateServingConfig(request: request, options: .init())
  }

  public func updateServingConfig(
    request: UpdateServingConfigRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudRetailV2.ServingConfig {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func updateServingConfig(
    servingConfig: ServingConfig?,
    updateMask: GoogleCloudWkt.FieldMask?,
  ) async throws -> GoogleCloudRetailV2.ServingConfig {
    let request = UpdateServingConfigRequest().with {
      $0.servingConfig = servingConfig
      $0.updateMask = updateMask
    }
    return try await self.updateServingConfig(request: request)
  }

  public func getServingConfig(request: GetServingConfigRequest) async throws
    -> GoogleCloudRetailV2.ServingConfig
  {
    try await self.getServingConfig(request: request, options: .init())
  }

  public func getServingConfig(
    request: GetServingConfigRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudRetailV2.ServingConfig {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func getServingConfig(
    name: Swift.String,
  ) async throws -> GoogleCloudRetailV2.ServingConfig {
    let request = GetServingConfigRequest().with {
      $0.name = name
    }
    return try await self.getServingConfig(request: request)
  }

  public func listServingConfigs(request: ListServingConfigsRequest) async throws
    -> GoogleCloudRetailV2.ListServingConfigsResponse
  {
    try await self.listServingConfigs(request: request, options: .init())
  }

  public func listServingConfigs(
    request: ListServingConfigsRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudRetailV2.ListServingConfigsResponse {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func listServingConfigs(
    byItem: ListServingConfigsRequest
  ) throws -> any AsyncSequence<ServingConfig, Swift.Error> {
    try self.listServingConfigs(byItem: byItem, options: .init())
  }

  public func listServingConfigs(
    byItem: ListServingConfigsRequest, options: GoogleCloudGax.RequestOptions
  ) throws -> any AsyncSequence<ServingConfig, Swift.Error> {
    let listRpc = {
      (token: Swift.String) async throws -> GoogleCloudRetailV2.ListServingConfigsResponse in
      throw GoogleCloudGax.RequestError.unimplemented
    }
    return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
  }

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

  public func addControl(request: AddControlRequest) async throws
    -> GoogleCloudRetailV2.ServingConfig
  {
    try await self.addControl(request: request, options: .init())
  }

  public func addControl(
    request: AddControlRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudRetailV2.ServingConfig {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func addControl(
    servingConfig: Swift.String,
  ) async throws -> GoogleCloudRetailV2.ServingConfig {
    let request = AddControlRequest().with {
      $0.servingConfig = servingConfig
    }
    return try await self.addControl(request: request)
  }

  public func removeControl(request: RemoveControlRequest) async throws
    -> GoogleCloudRetailV2.ServingConfig
  {
    try await self.removeControl(request: request, options: .init())
  }

  public func removeControl(
    request: RemoveControlRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudRetailV2.ServingConfig {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func removeControl(
    servingConfig: Swift.String,
  ) async throws -> GoogleCloudRetailV2.ServingConfig {
    let request = RemoveControlRequest().with {
      $0.servingConfig = servingConfig
    }
    return try await self.removeControl(request: request)
  }

  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)
  }
}
