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

/// Service describing handlers for resources
///
/// @Snippet(path: "CloudControlsPartnerMonitoringQuickstart")
public class CloudControlsPartnerMonitoringClient: Clients.CloudControlsPartnerMonitoringProtocol {
  let inner: any Clients.CloudControlsPartnerMonitoringStub

  /// Creates a new `CloudControlsPartnerMonitoringClient` instance.
  public init(_ options: GoogleCloudGax.ClientOptions = .init()) throws {
    var inner: any Clients.CloudControlsPartnerMonitoringStub =
      try Clients.CloudControlsPartnerMonitoringTransport(options)
    inner = Clients.CloudControlsPartnerMonitoringRetry(inner, options: options)
    if let logger = options.logger {
      inner = Clients.CloudControlsPartnerMonitoringLogging(inner, logger: logger)
    }
    self.inner = inner
  }

  /// Lists Violations for a workload
  /// Callers may also choose to read across multiple Customers or for a single
  /// customer as per
  /// [AIP-159](https://google.aip.dev/159) by using '-' (the hyphen or dash
  /// character) as a wildcard character instead of {customer} & {workload}.
  /// Format:
  /// `organizations/{organization}/locations/{location}/customers/{customer}/workloads/{workload}`
  ///
  /// @Snippet(path: "CloudControlsPartnerMonitoring_ListViolations")
  public func listViolations(
    request: ListViolationsRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudControlsPartnerV1.ListViolationsResponse {
    try await self.inner.listViolations(request: request, options: options)
  }

  /// Lists Violations for a workload
  /// Callers may also choose to read across multiple Customers or for a single
  /// customer as per
  /// [AIP-159](https://google.aip.dev/159) by using '-' (the hyphen or dash
  /// character) as a wildcard character instead of {customer} & {workload}.
  /// Format:
  /// `organizations/{organization}/locations/{location}/customers/{customer}/workloads/{workload}`
  ///
  /// @Snippet(path: "CloudControlsPartnerMonitoring_ListViolations")
  public func listViolations(
    byItem: ListViolationsRequest, options: GoogleCloudGax.RequestOptions
  ) throws -> any AsyncSequence<Violation, Swift.Error> {
    let listRpc = {
      (token: Swift.String) async throws -> GoogleCloudControlsPartnerV1.ListViolationsResponse in
      var request = byItem
      request.pageToken = token
      return try await self.listViolations(request: request, options: options)
    }
    return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
  }

  /// Gets details of a single Violation.
  ///
  /// @Snippet(path: "CloudControlsPartnerMonitoring_GetViolation")
  public func getViolation(
    request: GetViolationRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudControlsPartnerV1.Violation {
    try await self.inner.getViolation(request: request, options: options)
  }
}

extension Clients {
  /// A Swift protocol to mock `CloudControlsPartnerMonitoringClient`.
  ///
  /// To mock `CloudControlsPartnerMonitoringClient` change your functions to receive
  /// `some CloudControlsPartnerMonitoringProtocol` or `any CloudControlsPartnerMonitoringProtocol`
  /// and pass a mock implementation in your tests.
  public protocol CloudControlsPartnerMonitoringProtocol {
    /// See `CloudControlsPartnerMonitoringClient.listViolations`.
    func listViolations(request: ListViolationsRequest) async throws
      -> GoogleCloudControlsPartnerV1.ListViolationsResponse

    /// See `CloudControlsPartnerMonitoringClient.listViolations`.
    func listViolations(
      byItem: ListViolationsRequest
    ) throws -> any AsyncSequence<Violation, Swift.Error>

    /// See `CloudControlsPartnerMonitoringClient.listViolations`.
    func listViolations(
      parent: Swift.String,
    ) throws -> any AsyncSequence<Violation, Swift.Error>

    /// See `CloudControlsPartnerMonitoringClient.getViolation`.
    func getViolation(request: GetViolationRequest) async throws
      -> GoogleCloudControlsPartnerV1.Violation

    /// See `CloudControlsPartnerMonitoringClient.getViolation`.
    func getViolation(
      name: Swift.String,
    ) async throws -> GoogleCloudControlsPartnerV1.Violation

    /// See `CloudControlsPartnerMonitoringClient.listViolations`.
    func listViolations(
      request: ListViolationsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudControlsPartnerV1.ListViolationsResponse

    /// See `CloudControlsPartnerMonitoringClient.listViolations`.
    func listViolations(
      byItem: ListViolationsRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<Violation, Swift.Error>

    /// See `CloudControlsPartnerMonitoringClient.getViolation`.
    func getViolation(
      request: GetViolationRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudControlsPartnerV1.Violation
  }
}

// Default implementations
extension Clients.CloudControlsPartnerMonitoringProtocol {
  public func listViolations(request: ListViolationsRequest) async throws
    -> GoogleCloudControlsPartnerV1.ListViolationsResponse
  {
    try await self.listViolations(request: request, options: .init())
  }

  public func listViolations(
    request: ListViolationsRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudControlsPartnerV1.ListViolationsResponse {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func listViolations(
    byItem: ListViolationsRequest
  ) throws -> any AsyncSequence<Violation, Swift.Error> {
    try self.listViolations(byItem: byItem, options: .init())
  }

  public func listViolations(
    byItem: ListViolationsRequest, options: GoogleCloudGax.RequestOptions
  ) throws -> any AsyncSequence<Violation, Swift.Error> {
    let listRpc = {
      (token: Swift.String) async throws -> GoogleCloudControlsPartnerV1.ListViolationsResponse in
      throw GoogleCloudGax.RequestError.unimplemented
    }
    return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
  }

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

  public func getViolation(request: GetViolationRequest) async throws
    -> GoogleCloudControlsPartnerV1.Violation
  {
    try await self.getViolation(request: request, options: .init())
  }

  public func getViolation(
    request: GetViolationRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudControlsPartnerV1.Violation {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func getViolation(
    name: Swift.String,
  ) async throws -> GoogleCloudControlsPartnerV1.Violation {
    let request = GetViolationRequest().with {
      $0.name = name
    }
    return try await self.getViolation(request: request)
  }
}
