// 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 comments on cases.
///
/// @Snippet(path: "CommentServiceQuickstart")
public class CommentServiceClient: Clients.CommentServiceProtocol {
  let inner: any Clients.CommentServiceStub

  /// Creates a new `CommentServiceClient` instance.
  public init(_ options: GoogleCloudGax.ClientOptions = .init()) throws {
    var inner: any Clients.CommentServiceStub = try Clients.CommentServiceTransport(options)
    inner = Clients.CommentServiceRetry(inner, options: options)
    if let logger = options.logger {
      inner = Clients.CommentServiceLogging(inner, logger: logger)
    }
    self.inner = inner
  }

  /// List all the comments associated with a case.
  ///
  /// @Snippet(path: "CommentService_ListComments")
  public func listComments(
    request: ListCommentsRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudSupportV2.ListCommentsResponse {
    try await self.inner.listComments(request: request, options: options)
  }

  /// List all the comments associated with a case.
  ///
  /// @Snippet(path: "CommentService_ListComments")
  public func listComments(
    byItem: ListCommentsRequest, options: GoogleCloudGax.RequestOptions
  ) throws -> any AsyncSequence<Comment, Swift.Error> {
    let listRpc = {
      (token: Swift.String) async throws -> GoogleCloudSupportV2.ListCommentsResponse in
      var request = byItem
      request.pageToken = token
      return try await self.listComments(request: request, options: options)
    }
    return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
  }

  /// Add a new comment to a case.
  ///
  /// The comment must have the following fields set: `body`.
  ///
  /// @Snippet(path: "CommentService_CreateComment")
  public func createComment(
    request: CreateCommentRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudSupportV2.Comment {
    try await self.inner.createComment(request: request, options: options)
  }

  /// Retrieve a comment.
  ///
  /// EXAMPLES:
  ///
  /// cURL:
  ///
  /// ```shell
  /// comment="projects/some-project/cases/43595344/comments/234567890"
  /// curl \
  ///   --header "Authorization: Bearer $(gcloud auth print-access-token)" \
  ///   "https://cloudsupport.googleapis.com/v2/$comment"
  /// ```
  ///
  /// Python:
  ///
  /// ```python
  /// import googleapiclient.discovery
  ///
  /// api_version = "v2"
  /// supportApiService = googleapiclient.discovery.build(
  ///     serviceName="cloudsupport",
  ///     version=api_version,
  ///     discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}",
  /// )
  ///
  /// request = supportApiService.cases().comments().get(
  ///     name="projects/some-project/cases/43595344/comments/234567890",
  /// )
  /// print(request.execute())
  /// ```
  ///
  /// @Snippet(path: "CommentService_GetComment")
  public func getComment(
    request: GetCommentRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudSupportV2.Comment {
    try await self.inner.getComment(request: request, options: options)
  }
}

extension Clients {
  /// A Swift protocol to mock `CommentServiceClient`.
  ///
  /// To mock `CommentServiceClient` change your functions to receive
  /// `some CommentServiceProtocol` or `any CommentServiceProtocol`
  /// and pass a mock implementation in your tests.
  public protocol CommentServiceProtocol {
    /// See `CommentServiceClient.listComments`.
    func listComments(request: ListCommentsRequest) async throws
      -> GoogleCloudSupportV2.ListCommentsResponse

    /// See `CommentServiceClient.listComments`.
    func listComments(
      byItem: ListCommentsRequest
    ) throws -> any AsyncSequence<Comment, Swift.Error>

    /// See `CommentServiceClient.listComments`.
    func listComments(
      parent: Swift.String,
    ) throws -> any AsyncSequence<Comment, Swift.Error>

    /// See `CommentServiceClient.createComment`.
    func createComment(request: CreateCommentRequest) async throws -> GoogleCloudSupportV2.Comment

    /// See `CommentServiceClient.createComment`.
    func createComment(
      parent: Swift.String,
      comment: Comment?,
    ) async throws -> GoogleCloudSupportV2.Comment

    /// See `CommentServiceClient.getComment`.
    func getComment(request: GetCommentRequest) async throws -> GoogleCloudSupportV2.Comment

    /// See `CommentServiceClient.getComment`.
    func getComment(
      name: Swift.String,
    ) async throws -> GoogleCloudSupportV2.Comment

    /// See `CommentServiceClient.listComments`.
    func listComments(
      request: ListCommentsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudSupportV2.ListCommentsResponse

    /// See `CommentServiceClient.listComments`.
    func listComments(
      byItem: ListCommentsRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<Comment, Swift.Error>

    /// See `CommentServiceClient.createComment`.
    func createComment(
      request: CreateCommentRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudSupportV2.Comment

    /// See `CommentServiceClient.getComment`.
    func getComment(
      request: GetCommentRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudSupportV2.Comment
  }
}

// Default implementations
extension Clients.CommentServiceProtocol {
  public func listComments(request: ListCommentsRequest) async throws
    -> GoogleCloudSupportV2.ListCommentsResponse
  {
    try await self.listComments(request: request, options: .init())
  }

  public func listComments(
    request: ListCommentsRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudSupportV2.ListCommentsResponse {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func listComments(
    byItem: ListCommentsRequest
  ) throws -> any AsyncSequence<Comment, Swift.Error> {
    try self.listComments(byItem: byItem, options: .init())
  }

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

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

  public func createComment(request: CreateCommentRequest) async throws
    -> GoogleCloudSupportV2.Comment
  {
    try await self.createComment(request: request, options: .init())
  }

  public func createComment(
    request: CreateCommentRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudSupportV2.Comment {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func createComment(
    parent: Swift.String,
    comment: Comment?,
  ) async throws -> GoogleCloudSupportV2.Comment {
    let request = CreateCommentRequest().with {
      $0.parent = parent
      $0.comment = comment
    }
    return try await self.createComment(request: request)
  }

  public func getComment(request: GetCommentRequest) async throws -> GoogleCloudSupportV2.Comment {
    try await self.getComment(request: request, options: .init())
  }

  public func getComment(
    request: GetCommentRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudSupportV2.Comment {
    throw GoogleCloudGax.RequestError.unimplemented
  }

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