// 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 service to manage Google Cloud support cases.
///
/// @Snippet(path: "CaseServiceQuickstart")
public class CaseServiceClient: Clients.CaseServiceProtocol {
  let inner: any Clients.CaseServiceStub

  /// Creates a new `CaseServiceClient` instance.
  public init(_ options: GoogleCloudGax.ClientOptions = .init()) throws {
    var inner: any Clients.CaseServiceStub = try Clients.CaseServiceTransport(options)
    inner = Clients.CaseServiceRetry(inner, options: options)
    if let logger = options.logger {
      inner = Clients.CaseServiceLogging(inner, logger: logger)
    }
    self.inner = inner
  }

  /// Retrieve a case.
  ///
  /// @Snippet(path: "CaseService_GetCase")
  public func getCase(
    request: GetCaseRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudSupportV2.Case {
    try await self.inner.getCase(request: request, options: options)
  }

  /// Retrieve all cases under a parent, but not its children.
  ///
  /// For example, listing cases under an organization only returns the cases
  /// that are directly parented by that organization. To retrieve cases
  /// under an organization and its projects, use `cases.search`.
  ///
  /// @Snippet(path: "CaseService_ListCases")
  public func listCases(
    request: ListCasesRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudSupportV2.ListCasesResponse {
    try await self.inner.listCases(request: request, options: options)
  }

  /// Retrieve all cases under a parent, but not its children.
  ///
  /// For example, listing cases under an organization only returns the cases
  /// that are directly parented by that organization. To retrieve cases
  /// under an organization and its projects, use `cases.search`.
  ///
  /// @Snippet(path: "CaseService_ListCases")
  public func listCases(
    byItem: ListCasesRequest, options: GoogleCloudGax.RequestOptions
  ) throws -> any AsyncSequence<Case, Swift.Error> {
    let listRpc = { (token: Swift.String) async throws -> GoogleCloudSupportV2.ListCasesResponse in
      var request = byItem
      request.pageToken = token
      return try await self.listCases(request: request, options: options)
    }
    return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
  }

  /// Search for cases using a query.
  ///
  /// @Snippet(path: "CaseService_SearchCases")
  public func searchCases(
    request: SearchCasesRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudSupportV2.SearchCasesResponse {
    try await self.inner.searchCases(request: request, options: options)
  }

  /// Search for cases using a query.
  ///
  /// @Snippet(path: "CaseService_SearchCases")
  public func searchCases(
    byItem: SearchCasesRequest, options: GoogleCloudGax.RequestOptions
  ) throws -> any AsyncSequence<Case, Swift.Error> {
    let listRpc = {
      (token: Swift.String) async throws -> GoogleCloudSupportV2.SearchCasesResponse in
      var request = byItem
      request.pageToken = token
      return try await self.searchCases(request: request, options: options)
    }
    return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
  }

  /// Create a new case and associate it with a parent.
  ///
  /// It must have the following fields set: `display_name`, `description`,
  /// `classification`, and `priority`. If you're just testing the API and don't
  /// want to route your case to an agent, set `testCase=true`.
  ///
  /// @Snippet(path: "CaseService_CreateCase")
  public func createCase(
    request: CreateCaseRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudSupportV2.Case {
    try await self.inner.createCase(request: request, options: options)
  }

  /// Update a case. Only some fields can be updated.
  ///
  /// @Snippet(path: "CaseService_UpdateCase")
  public func updateCase(
    request: UpdateCaseRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudSupportV2.Case {
    try await self.inner.updateCase(request: request, options: options)
  }

  /// Escalate a case, starting the Google Cloud Support escalation management
  /// process.
  ///
  /// This operation is only available for some support services. Go to
  /// https://cloud.google.com/support and look for 'Technical support
  /// escalations' in the feature list to find out which ones let you
  /// do that.
  ///
  /// @Snippet(path: "CaseService_EscalateCase")
  public func escalateCase(
    request: EscalateCaseRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudSupportV2.Case {
    try await self.inner.escalateCase(request: request, options: options)
  }

  /// Close a case.
  ///
  /// @Snippet(path: "CaseService_CloseCase")
  public func closeCase(
    request: CloseCaseRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudSupportV2.Case {
    try await self.inner.closeCase(request: request, options: options)
  }

  /// Retrieve valid classifications to use when creating a support case.
  ///
  /// Classifications are hierarchical. Each classification is a string
  /// containing all levels of the hierarchy separated by `" > "`. For example,
  /// `"Technical Issue > Compute > Compute Engine"`.
  ///
  /// Classification IDs returned by this endpoint are valid for at least six
  /// months. When a classification is deactivated, this endpoint immediately
  /// stops returning it. After six months, `case.create` requests using the
  /// classification will fail.
  ///
  /// @Snippet(path: "CaseService_SearchCaseClassifications")
  public func searchCaseClassifications(
    request: SearchCaseClassificationsRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudSupportV2.SearchCaseClassificationsResponse {
    try await self.inner.searchCaseClassifications(request: request, options: options)
  }

  /// Retrieve valid classifications to use when creating a support case.
  ///
  /// Classifications are hierarchical. Each classification is a string
  /// containing all levels of the hierarchy separated by `" > "`. For example,
  /// `"Technical Issue > Compute > Compute Engine"`.
  ///
  /// Classification IDs returned by this endpoint are valid for at least six
  /// months. When a classification is deactivated, this endpoint immediately
  /// stops returning it. After six months, `case.create` requests using the
  /// classification will fail.
  ///
  /// @Snippet(path: "CaseService_SearchCaseClassifications")
  public func searchCaseClassifications(
    byItem: SearchCaseClassificationsRequest, options: GoogleCloudGax.RequestOptions
  ) throws -> any AsyncSequence<CaseClassification, Swift.Error> {
    let listRpc = {
      (token: Swift.String) async throws -> GoogleCloudSupportV2.SearchCaseClassificationsResponse
      in
      var request = byItem
      request.pageToken = token
      return try await self.searchCaseClassifications(request: request, options: options)
    }
    return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
  }
}

extension Clients {
  /// A Swift protocol to mock `CaseServiceClient`.
  ///
  /// To mock `CaseServiceClient` change your functions to receive
  /// `some CaseServiceProtocol` or `any CaseServiceProtocol`
  /// and pass a mock implementation in your tests.
  public protocol CaseServiceProtocol {
    /// See `CaseServiceClient.getCase`.
    func getCase(request: GetCaseRequest) async throws -> GoogleCloudSupportV2.Case

    /// See `CaseServiceClient.getCase`.
    func getCase(
      name: Swift.String,
    ) async throws -> GoogleCloudSupportV2.Case

    /// See `CaseServiceClient.listCases`.
    func listCases(request: ListCasesRequest) async throws -> GoogleCloudSupportV2.ListCasesResponse

    /// See `CaseServiceClient.listCases`.
    func listCases(
      byItem: ListCasesRequest
    ) throws -> any AsyncSequence<Case, Swift.Error>

    /// See `CaseServiceClient.listCases`.
    func listCases(
      parent: Swift.String,
    ) throws -> any AsyncSequence<Case, Swift.Error>

    /// See `CaseServiceClient.searchCases`.
    func searchCases(request: SearchCasesRequest) async throws
      -> GoogleCloudSupportV2.SearchCasesResponse

    /// See `CaseServiceClient.searchCases`.
    func searchCases(
      byItem: SearchCasesRequest
    ) throws -> any AsyncSequence<Case, Swift.Error>

    /// See `CaseServiceClient.createCase`.
    func createCase(request: CreateCaseRequest) async throws -> GoogleCloudSupportV2.Case

    /// See `CaseServiceClient.createCase`.
    func createCase(
      parent: Swift.String,
      `case`: Case?,
    ) async throws -> GoogleCloudSupportV2.Case

    /// See `CaseServiceClient.updateCase`.
    func updateCase(request: UpdateCaseRequest) async throws -> GoogleCloudSupportV2.Case

    /// See `CaseServiceClient.updateCase`.
    func updateCase(
      `case`: Case?,
      updateMask: GoogleCloudWkt.FieldMask?,
    ) async throws -> GoogleCloudSupportV2.Case

    /// See `CaseServiceClient.escalateCase`.
    func escalateCase(request: EscalateCaseRequest) async throws -> GoogleCloudSupportV2.Case

    /// See `CaseServiceClient.closeCase`.
    func closeCase(request: CloseCaseRequest) async throws -> GoogleCloudSupportV2.Case

    /// See `CaseServiceClient.searchCaseClassifications`.
    func searchCaseClassifications(request: SearchCaseClassificationsRequest) async throws
      -> GoogleCloudSupportV2.SearchCaseClassificationsResponse

    /// See `CaseServiceClient.searchCaseClassifications`.
    func searchCaseClassifications(
      byItem: SearchCaseClassificationsRequest
    ) throws -> any AsyncSequence<CaseClassification, Swift.Error>

    /// See `CaseServiceClient.getCase`.
    func getCase(
      request: GetCaseRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudSupportV2.Case

    /// See `CaseServiceClient.listCases`.
    func listCases(
      request: ListCasesRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudSupportV2.ListCasesResponse

    /// See `CaseServiceClient.listCases`.
    func listCases(
      byItem: ListCasesRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<Case, Swift.Error>

    /// See `CaseServiceClient.searchCases`.
    func searchCases(
      request: SearchCasesRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudSupportV2.SearchCasesResponse

    /// See `CaseServiceClient.searchCases`.
    func searchCases(
      byItem: SearchCasesRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<Case, Swift.Error>

    /// See `CaseServiceClient.createCase`.
    func createCase(
      request: CreateCaseRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudSupportV2.Case

    /// See `CaseServiceClient.updateCase`.
    func updateCase(
      request: UpdateCaseRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudSupportV2.Case

    /// See `CaseServiceClient.escalateCase`.
    func escalateCase(
      request: EscalateCaseRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudSupportV2.Case

    /// See `CaseServiceClient.closeCase`.
    func closeCase(
      request: CloseCaseRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudSupportV2.Case

    /// See `CaseServiceClient.searchCaseClassifications`.
    func searchCaseClassifications(
      request: SearchCaseClassificationsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudSupportV2.SearchCaseClassificationsResponse

    /// See `CaseServiceClient.searchCaseClassifications`.
    func searchCaseClassifications(
      byItem: SearchCaseClassificationsRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<CaseClassification, Swift.Error>
  }
}

// Default implementations
extension Clients.CaseServiceProtocol {
  public func getCase(request: GetCaseRequest) async throws -> GoogleCloudSupportV2.Case {
    try await self.getCase(request: request, options: .init())
  }

  public func getCase(
    request: GetCaseRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudSupportV2.Case {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func getCase(
    name: Swift.String,
  ) async throws -> GoogleCloudSupportV2.Case {
    let request = GetCaseRequest().with {
      $0.name = name
    }
    return try await self.getCase(request: request)
  }

  public func listCases(request: ListCasesRequest) async throws
    -> GoogleCloudSupportV2.ListCasesResponse
  {
    try await self.listCases(request: request, options: .init())
  }

  public func listCases(
    request: ListCasesRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudSupportV2.ListCasesResponse {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func listCases(
    byItem: ListCasesRequest
  ) throws -> any AsyncSequence<Case, Swift.Error> {
    try self.listCases(byItem: byItem, options: .init())
  }

  public func listCases(
    byItem: ListCasesRequest, options: GoogleCloudGax.RequestOptions
  ) throws -> any AsyncSequence<Case, Swift.Error> {
    let listRpc = { (token: Swift.String) async throws -> GoogleCloudSupportV2.ListCasesResponse in
      throw GoogleCloudGax.RequestError.unimplemented
    }
    return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
  }

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

  public func searchCases(request: SearchCasesRequest) async throws
    -> GoogleCloudSupportV2.SearchCasesResponse
  {
    try await self.searchCases(request: request, options: .init())
  }

  public func searchCases(
    request: SearchCasesRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudSupportV2.SearchCasesResponse {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func searchCases(
    byItem: SearchCasesRequest
  ) throws -> any AsyncSequence<Case, Swift.Error> {
    try self.searchCases(byItem: byItem, options: .init())
  }

  public func searchCases(
    byItem: SearchCasesRequest, options: GoogleCloudGax.RequestOptions
  ) throws -> any AsyncSequence<Case, Swift.Error> {
    let listRpc = {
      (token: Swift.String) async throws -> GoogleCloudSupportV2.SearchCasesResponse in
      throw GoogleCloudGax.RequestError.unimplemented
    }
    return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
  }

  public func createCase(request: CreateCaseRequest) async throws -> GoogleCloudSupportV2.Case {
    try await self.createCase(request: request, options: .init())
  }

  public func createCase(
    request: CreateCaseRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudSupportV2.Case {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func createCase(
    parent: Swift.String,
    `case`: Case?,
  ) async throws -> GoogleCloudSupportV2.Case {
    let request = CreateCaseRequest().with {
      $0.parent = parent
      $0.`case` = `case`
    }
    return try await self.createCase(request: request)
  }

  public func updateCase(request: UpdateCaseRequest) async throws -> GoogleCloudSupportV2.Case {
    try await self.updateCase(request: request, options: .init())
  }

  public func updateCase(
    request: UpdateCaseRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudSupportV2.Case {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func updateCase(
    `case`: Case?,
    updateMask: GoogleCloudWkt.FieldMask?,
  ) async throws -> GoogleCloudSupportV2.Case {
    let request = UpdateCaseRequest().with {
      $0.`case` = `case`
      $0.updateMask = updateMask
    }
    return try await self.updateCase(request: request)
  }

  public func escalateCase(request: EscalateCaseRequest) async throws -> GoogleCloudSupportV2.Case {
    try await self.escalateCase(request: request, options: .init())
  }

  public func escalateCase(
    request: EscalateCaseRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudSupportV2.Case {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func closeCase(request: CloseCaseRequest) async throws -> GoogleCloudSupportV2.Case {
    try await self.closeCase(request: request, options: .init())
  }

  public func closeCase(
    request: CloseCaseRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudSupportV2.Case {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func searchCaseClassifications(request: SearchCaseClassificationsRequest) async throws
    -> GoogleCloudSupportV2.SearchCaseClassificationsResponse
  {
    try await self.searchCaseClassifications(request: request, options: .init())
  }

  public func searchCaseClassifications(
    request: SearchCaseClassificationsRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudSupportV2.SearchCaseClassificationsResponse {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func searchCaseClassifications(
    byItem: SearchCaseClassificationsRequest
  ) throws -> any AsyncSequence<CaseClassification, Swift.Error> {
    try self.searchCaseClassifications(byItem: byItem, options: .init())
  }

  public func searchCaseClassifications(
    byItem: SearchCaseClassificationsRequest, options: GoogleCloudGax.RequestOptions
  ) throws -> any AsyncSequence<CaseClassification, Swift.Error> {
    let listRpc = {
      (token: Swift.String) async throws -> GoogleCloudSupportV2.SearchCaseClassificationsResponse
      in
      throw GoogleCloudGax.RequestError.unimplemented
    }
    return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
  }
}
