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

/// A service that handles company management, including CRUD and enumeration.
///
/// @Snippet(path: "CompanyServiceQuickstart")
public class CompanyServiceClient: Clients.CompanyServiceProtocol {
  let inner: any Clients.CompanyServiceStub

  /// Creates a new `CompanyServiceClient` instance.
  public init(_ options: GoogleCloudGax.ClientOptions = .init()) throws {
    var inner: any Clients.CompanyServiceStub = try Clients.CompanyServiceTransport(options)
    inner = Clients.CompanyServiceRetry(inner, options: options)
    if let logger = options.logger {
      inner = Clients.CompanyServiceLogging(inner, logger: logger)
    }
    self.inner = inner
  }

  /// Creates a new company entity.
  ///
  /// @Snippet(path: "CompanyService_CreateCompany")
  public func createCompany(
    request: CreateCompanyRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudTalentV4.Company {
    try await self.inner.createCompany(request: request, options: options)
  }

  /// Retrieves specified company.
  ///
  /// @Snippet(path: "CompanyService_GetCompany")
  public func getCompany(
    request: GetCompanyRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudTalentV4.Company {
    try await self.inner.getCompany(request: request, options: options)
  }

  /// Updates specified company.
  ///
  /// @Snippet(path: "CompanyService_UpdateCompany")
  public func updateCompany(
    request: UpdateCompanyRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudTalentV4.Company {
    try await self.inner.updateCompany(request: request, options: options)
  }

  /// Deletes specified company.
  /// Prerequisite: The company has no jobs associated with it.
  ///
  /// @Snippet(path: "CompanyService_DeleteCompany")
  public func deleteCompany(
    request: DeleteCompanyRequest, options: GoogleCloudGax.RequestOptions
  ) async throws {
    try await self.inner.deleteCompany(request: request, options: options)
  }

  /// Lists all companies associated with the project.
  ///
  /// @Snippet(path: "CompanyService_ListCompanies")
  public func listCompanies(
    request: ListCompaniesRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudTalentV4.ListCompaniesResponse {
    try await self.inner.listCompanies(request: request, options: options)
  }

  /// Lists all companies associated with the project.
  ///
  /// @Snippet(path: "CompanyService_ListCompanies")
  public func listCompanies(
    byItem: ListCompaniesRequest, options: GoogleCloudGax.RequestOptions
  ) throws -> any AsyncSequence<Company, Swift.Error> {
    let listRpc = {
      (token: Swift.String) async throws -> GoogleCloudTalentV4.ListCompaniesResponse in
      var request = byItem
      request.pageToken = token
      return try await self.listCompanies(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: "CompanyService_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 `CompanyServiceClient`.
  ///
  /// To mock `CompanyServiceClient` change your functions to receive
  /// `some CompanyServiceProtocol` or `any CompanyServiceProtocol`
  /// and pass a mock implementation in your tests.
  public protocol CompanyServiceProtocol {
    /// See `CompanyServiceClient.createCompany`.
    func createCompany(request: CreateCompanyRequest) async throws -> GoogleCloudTalentV4.Company

    /// See `CompanyServiceClient.createCompany`.
    func createCompany(
      parent: Swift.String,
      company: Company?,
    ) async throws -> GoogleCloudTalentV4.Company

    /// See `CompanyServiceClient.getCompany`.
    func getCompany(request: GetCompanyRequest) async throws -> GoogleCloudTalentV4.Company

    /// See `CompanyServiceClient.getCompany`.
    func getCompany(
      name: Swift.String,
    ) async throws -> GoogleCloudTalentV4.Company

    /// See `CompanyServiceClient.updateCompany`.
    func updateCompany(request: UpdateCompanyRequest) async throws -> GoogleCloudTalentV4.Company

    /// See `CompanyServiceClient.updateCompany`.
    func updateCompany(
      company: Company?,
      updateMask: GoogleCloudWkt.FieldMask?,
    ) async throws -> GoogleCloudTalentV4.Company

    /// See `CompanyServiceClient.deleteCompany`.
    func deleteCompany(request: DeleteCompanyRequest) async throws

    /// See `CompanyServiceClient.deleteCompany`.
    func deleteCompany(
      name: Swift.String,
    ) async throws

    /// See `CompanyServiceClient.listCompanies`.
    func listCompanies(request: ListCompaniesRequest) async throws
      -> GoogleCloudTalentV4.ListCompaniesResponse

    /// See `CompanyServiceClient.listCompanies`.
    func listCompanies(
      byItem: ListCompaniesRequest
    ) throws -> any AsyncSequence<Company, Swift.Error>

    /// See `CompanyServiceClient.listCompanies`.
    func listCompanies(
      parent: Swift.String,
    ) throws -> any AsyncSequence<Company, Swift.Error>

    /// See `CompanyServiceClient.createCompany`.
    func createCompany(
      request: CreateCompanyRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudTalentV4.Company

    /// See `CompanyServiceClient.getCompany`.
    func getCompany(
      request: GetCompanyRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudTalentV4.Company

    /// See `CompanyServiceClient.updateCompany`.
    func updateCompany(
      request: UpdateCompanyRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudTalentV4.Company

    /// See `CompanyServiceClient.deleteCompany`.
    func deleteCompany(
      request: DeleteCompanyRequest, options: GoogleCloudGax.RequestOptions
    ) async throws

    /// See `CompanyServiceClient.listCompanies`.
    func listCompanies(
      request: ListCompaniesRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudTalentV4.ListCompaniesResponse

    /// See `CompanyServiceClient.listCompanies`.
    func listCompanies(
      byItem: ListCompaniesRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<Company, Swift.Error>
  }
}

// Default implementations
extension Clients.CompanyServiceProtocol {
  public func createCompany(request: CreateCompanyRequest) async throws
    -> GoogleCloudTalentV4.Company
  {
    try await self.createCompany(request: request, options: .init())
  }

  public func createCompany(
    request: CreateCompanyRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudTalentV4.Company {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func createCompany(
    parent: Swift.String,
    company: Company?,
  ) async throws -> GoogleCloudTalentV4.Company {
    let request = CreateCompanyRequest().with {
      $0.parent = parent
      $0.company = company
    }
    return try await self.createCompany(request: request)
  }

  public func getCompany(request: GetCompanyRequest) async throws -> GoogleCloudTalentV4.Company {
    try await self.getCompany(request: request, options: .init())
  }

  public func getCompany(
    request: GetCompanyRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudTalentV4.Company {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func getCompany(
    name: Swift.String,
  ) async throws -> GoogleCloudTalentV4.Company {
    let request = GetCompanyRequest().with {
      $0.name = name
    }
    return try await self.getCompany(request: request)
  }

  public func updateCompany(request: UpdateCompanyRequest) async throws
    -> GoogleCloudTalentV4.Company
  {
    try await self.updateCompany(request: request, options: .init())
  }

  public func updateCompany(
    request: UpdateCompanyRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudTalentV4.Company {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func updateCompany(
    company: Company?,
    updateMask: GoogleCloudWkt.FieldMask?,
  ) async throws -> GoogleCloudTalentV4.Company {
    let request = UpdateCompanyRequest().with {
      $0.company = company
      $0.updateMask = updateMask
    }
    return try await self.updateCompany(request: request)
  }

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

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

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

  public func listCompanies(request: ListCompaniesRequest) async throws
    -> GoogleCloudTalentV4.ListCompaniesResponse
  {
    try await self.listCompanies(request: request, options: .init())
  }

  public func listCompanies(
    request: ListCompaniesRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudTalentV4.ListCompaniesResponse {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func listCompanies(
    byItem: ListCompaniesRequest
  ) throws -> any AsyncSequence<Company, Swift.Error> {
    try self.listCompanies(byItem: byItem, options: .init())
  }

  public func listCompanies(
    byItem: ListCompaniesRequest, options: GoogleCloudGax.RequestOptions
  ) throws -> any AsyncSequence<Company, Swift.Error> {
    let listRpc = {
      (token: Swift.String) async throws -> GoogleCloudTalentV4.ListCompaniesResponse in
      throw GoogleCloudGax.RequestError.unimplemented
    }
    return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
  }

  public func listCompanies(
    parent: Swift.String,
  ) throws -> any AsyncSequence<Company, Swift.Error> {
    let request = ListCompaniesRequest().with {
      $0.parent = parent
    }
    return try self.listCompanies(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)
  }
}
