// 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 GoogleIAMV1
import GoogleCloudGax

/// Data Policy Service provides APIs for managing the BigQuery Data Policy.
///
/// @Snippet(path: "DataPolicyServiceQuickstart")
public class DataPolicyServiceClient: Clients.DataPolicyServiceProtocol {
  let inner: any Clients.DataPolicyServiceStub

  /// Creates a new `DataPolicyServiceClient` instance.
  public init(_ options: GoogleCloudGax.ClientOptions = .init()) throws {
    var inner: any Clients.DataPolicyServiceStub = try Clients.DataPolicyServiceTransport(options)
    inner = Clients.DataPolicyServiceRetry(inner, options: options)
    if let logger = options.logger {
      inner = Clients.DataPolicyServiceLogging(inner, logger: logger)
    }
    self.inner = inner
  }

  /// Creates a new data policy under a project with the given `data_policy_id`
  /// (used as the display name), and data policy type.
  ///
  /// @Snippet(path: "DataPolicyService_CreateDataPolicy")
  public func createDataPolicy(
    request: CreateDataPolicyRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleBigQueryDataPoliciesV2.DataPolicy {
    try await self.inner.createDataPolicy(request: request, options: options)
  }

  /// Adds new grantees to a data policy.
  /// The new grantees will be added to the existing grantees.
  /// If the request contains a duplicate grantee, the grantee will be ignored.
  /// If the request contains a grantee that already exists, the grantee will be
  /// ignored.
  ///
  /// @Snippet(path: "DataPolicyService_AddGrantees")
  public func addGrantees(
    request: AddGranteesRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleBigQueryDataPoliciesV2.DataPolicy {
    try await self.inner.addGrantees(request: request, options: options)
  }

  /// Removes grantees from a data policy.
  /// The grantees will be removed from the existing grantees.
  /// If the request contains a grantee that does not exist, the grantee will be
  /// ignored.
  ///
  /// @Snippet(path: "DataPolicyService_RemoveGrantees")
  public func removeGrantees(
    request: RemoveGranteesRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleBigQueryDataPoliciesV2.DataPolicy {
    try await self.inner.removeGrantees(request: request, options: options)
  }

  /// Updates the metadata for an existing data policy. The target data policy
  /// can be specified by the resource name.
  ///
  /// @Snippet(path: "DataPolicyService_UpdateDataPolicy")
  public func updateDataPolicy(
    request: UpdateDataPolicyRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleBigQueryDataPoliciesV2.DataPolicy {
    try await self.inner.updateDataPolicy(request: request, options: options)
  }

  /// Deletes the data policy specified by its resource name.
  ///
  /// @Snippet(path: "DataPolicyService_DeleteDataPolicy")
  public func deleteDataPolicy(
    request: DeleteDataPolicyRequest, options: GoogleCloudGax.RequestOptions
  ) async throws {
    try await self.inner.deleteDataPolicy(request: request, options: options)
  }

  /// Gets the data policy specified by its resource name.
  ///
  /// @Snippet(path: "DataPolicyService_GetDataPolicy")
  public func getDataPolicy(
    request: GetDataPolicyRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleBigQueryDataPoliciesV2.DataPolicy {
    try await self.inner.getDataPolicy(request: request, options: options)
  }

  /// List all of the data policies in the specified parent project.
  ///
  /// @Snippet(path: "DataPolicyService_ListDataPolicies")
  public func listDataPolicies(
    request: ListDataPoliciesRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleBigQueryDataPoliciesV2.ListDataPoliciesResponse {
    try await self.inner.listDataPolicies(request: request, options: options)
  }

  /// List all of the data policies in the specified parent project.
  ///
  /// @Snippet(path: "DataPolicyService_ListDataPolicies")
  public func listDataPolicies(
    byItem: ListDataPoliciesRequest, options: GoogleCloudGax.RequestOptions
  ) throws -> any AsyncSequence<DataPolicy, Swift.Error> {
    let listRpc = {
      (token: Swift.String) async throws -> GoogleBigQueryDataPoliciesV2.ListDataPoliciesResponse in
      var request = byItem
      request.pageToken = token
      return try await self.listDataPolicies(request: request, options: options)
    }
    return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
  }

  /// Gets the IAM policy for the specified data policy.
  ///
  /// @Snippet(path: "DataPolicyService_GetIamPolicy")
  public func getIamPolicy(
    request: GoogleIAMV1.GetIamPolicyRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleIAMV1.Policy {
    try await self.inner.getIamPolicy(request: request, options: options)
  }

  /// Sets the IAM policy for the specified data policy.
  ///
  /// @Snippet(path: "DataPolicyService_SetIamPolicy")
  public func setIamPolicy(
    request: GoogleIAMV1.SetIamPolicyRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleIAMV1.Policy {
    try await self.inner.setIamPolicy(request: request, options: options)
  }

  /// Returns the caller's permission on the specified data policy resource.
  ///
  /// @Snippet(path: "DataPolicyService_TestIamPermissions")
  public func testIamPermissions(
    request: GoogleIAMV1.TestIamPermissionsRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleIAMV1.TestIamPermissionsResponse {
    try await self.inner.testIamPermissions(request: request, options: options)
  }
}

extension Clients {
  /// A Swift protocol to mock `DataPolicyServiceClient`.
  ///
  /// To mock `DataPolicyServiceClient` change your functions to receive
  /// `some DataPolicyServiceProtocol` or `any DataPolicyServiceProtocol`
  /// and pass a mock implementation in your tests.
  public protocol DataPolicyServiceProtocol {
    /// See `DataPolicyServiceClient.createDataPolicy`.
    func createDataPolicy(request: CreateDataPolicyRequest) async throws
      -> GoogleBigQueryDataPoliciesV2.DataPolicy

    /// See `DataPolicyServiceClient.createDataPolicy`.
    func createDataPolicy(
      parent: Swift.String,
      dataPolicy: DataPolicy?,
      dataPolicyId: Swift.String,
    ) async throws -> GoogleBigQueryDataPoliciesV2.DataPolicy

    /// See `DataPolicyServiceClient.addGrantees`.
    func addGrantees(request: AddGranteesRequest) async throws
      -> GoogleBigQueryDataPoliciesV2.DataPolicy

    /// See `DataPolicyServiceClient.addGrantees`.
    func addGrantees(
      dataPolicy: Swift.String,
      grantees: [Swift.String],
    ) async throws -> GoogleBigQueryDataPoliciesV2.DataPolicy

    /// See `DataPolicyServiceClient.removeGrantees`.
    func removeGrantees(request: RemoveGranteesRequest) async throws
      -> GoogleBigQueryDataPoliciesV2.DataPolicy

    /// See `DataPolicyServiceClient.removeGrantees`.
    func removeGrantees(
      dataPolicy: Swift.String,
      grantees: [Swift.String],
    ) async throws -> GoogleBigQueryDataPoliciesV2.DataPolicy

    /// See `DataPolicyServiceClient.updateDataPolicy`.
    func updateDataPolicy(request: UpdateDataPolicyRequest) async throws
      -> GoogleBigQueryDataPoliciesV2.DataPolicy

    /// See `DataPolicyServiceClient.updateDataPolicy`.
    func updateDataPolicy(
      dataPolicy: DataPolicy?,
      updateMask: GoogleCloudWkt.FieldMask?,
    ) async throws -> GoogleBigQueryDataPoliciesV2.DataPolicy

    /// See `DataPolicyServiceClient.deleteDataPolicy`.
    func deleteDataPolicy(request: DeleteDataPolicyRequest) async throws

    /// See `DataPolicyServiceClient.deleteDataPolicy`.
    func deleteDataPolicy(
      name: Swift.String,
    ) async throws

    /// See `DataPolicyServiceClient.getDataPolicy`.
    func getDataPolicy(request: GetDataPolicyRequest) async throws
      -> GoogleBigQueryDataPoliciesV2.DataPolicy

    /// See `DataPolicyServiceClient.getDataPolicy`.
    func getDataPolicy(
      name: Swift.String,
    ) async throws -> GoogleBigQueryDataPoliciesV2.DataPolicy

    /// See `DataPolicyServiceClient.listDataPolicies`.
    func listDataPolicies(request: ListDataPoliciesRequest) async throws
      -> GoogleBigQueryDataPoliciesV2.ListDataPoliciesResponse

    /// See `DataPolicyServiceClient.listDataPolicies`.
    func listDataPolicies(
      byItem: ListDataPoliciesRequest
    ) throws -> any AsyncSequence<DataPolicy, Swift.Error>

    /// See `DataPolicyServiceClient.listDataPolicies`.
    func listDataPolicies(
      parent: Swift.String,
    ) throws -> any AsyncSequence<DataPolicy, Swift.Error>

    /// See `DataPolicyServiceClient.getIamPolicy`.
    func getIamPolicy(request: GoogleIAMV1.GetIamPolicyRequest) async throws -> GoogleIAMV1.Policy

    /// See `DataPolicyServiceClient.setIamPolicy`.
    func setIamPolicy(request: GoogleIAMV1.SetIamPolicyRequest) async throws -> GoogleIAMV1.Policy

    /// See `DataPolicyServiceClient.testIamPermissions`.
    func testIamPermissions(request: GoogleIAMV1.TestIamPermissionsRequest) async throws
      -> GoogleIAMV1.TestIamPermissionsResponse

    /// See `DataPolicyServiceClient.createDataPolicy`.
    func createDataPolicy(
      request: CreateDataPolicyRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleBigQueryDataPoliciesV2.DataPolicy

    /// See `DataPolicyServiceClient.addGrantees`.
    func addGrantees(
      request: AddGranteesRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleBigQueryDataPoliciesV2.DataPolicy

    /// See `DataPolicyServiceClient.removeGrantees`.
    func removeGrantees(
      request: RemoveGranteesRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleBigQueryDataPoliciesV2.DataPolicy

    /// See `DataPolicyServiceClient.updateDataPolicy`.
    func updateDataPolicy(
      request: UpdateDataPolicyRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleBigQueryDataPoliciesV2.DataPolicy

    /// See `DataPolicyServiceClient.deleteDataPolicy`.
    func deleteDataPolicy(
      request: DeleteDataPolicyRequest, options: GoogleCloudGax.RequestOptions
    ) async throws

    /// See `DataPolicyServiceClient.getDataPolicy`.
    func getDataPolicy(
      request: GetDataPolicyRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleBigQueryDataPoliciesV2.DataPolicy

    /// See `DataPolicyServiceClient.listDataPolicies`.
    func listDataPolicies(
      request: ListDataPoliciesRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleBigQueryDataPoliciesV2.ListDataPoliciesResponse

    /// See `DataPolicyServiceClient.listDataPolicies`.
    func listDataPolicies(
      byItem: ListDataPoliciesRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<DataPolicy, Swift.Error>

    /// See `DataPolicyServiceClient.getIamPolicy`.
    func getIamPolicy(
      request: GoogleIAMV1.GetIamPolicyRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleIAMV1.Policy

    /// See `DataPolicyServiceClient.setIamPolicy`.
    func setIamPolicy(
      request: GoogleIAMV1.SetIamPolicyRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleIAMV1.Policy

    /// See `DataPolicyServiceClient.testIamPermissions`.
    func testIamPermissions(
      request: GoogleIAMV1.TestIamPermissionsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleIAMV1.TestIamPermissionsResponse
  }
}

// Default implementations
extension Clients.DataPolicyServiceProtocol {
  public func createDataPolicy(request: CreateDataPolicyRequest) async throws
    -> GoogleBigQueryDataPoliciesV2.DataPolicy
  {
    try await self.createDataPolicy(request: request, options: .init())
  }

  public func createDataPolicy(
    request: CreateDataPolicyRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleBigQueryDataPoliciesV2.DataPolicy {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func createDataPolicy(
    parent: Swift.String,
    dataPolicy: DataPolicy?,
    dataPolicyId: Swift.String,
  ) async throws -> GoogleBigQueryDataPoliciesV2.DataPolicy {
    let request = CreateDataPolicyRequest().with {
      $0.parent = parent
      $0.dataPolicy = dataPolicy
      $0.dataPolicyId = dataPolicyId
    }
    return try await self.createDataPolicy(request: request)
  }

  public func addGrantees(request: AddGranteesRequest) async throws
    -> GoogleBigQueryDataPoliciesV2.DataPolicy
  {
    try await self.addGrantees(request: request, options: .init())
  }

  public func addGrantees(
    request: AddGranteesRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleBigQueryDataPoliciesV2.DataPolicy {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func addGrantees(
    dataPolicy: Swift.String,
    grantees: [Swift.String],
  ) async throws -> GoogleBigQueryDataPoliciesV2.DataPolicy {
    let request = AddGranteesRequest().with {
      $0.dataPolicy = dataPolicy
      $0.grantees = grantees
    }
    return try await self.addGrantees(request: request)
  }

  public func removeGrantees(request: RemoveGranteesRequest) async throws
    -> GoogleBigQueryDataPoliciesV2.DataPolicy
  {
    try await self.removeGrantees(request: request, options: .init())
  }

  public func removeGrantees(
    request: RemoveGranteesRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleBigQueryDataPoliciesV2.DataPolicy {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func removeGrantees(
    dataPolicy: Swift.String,
    grantees: [Swift.String],
  ) async throws -> GoogleBigQueryDataPoliciesV2.DataPolicy {
    let request = RemoveGranteesRequest().with {
      $0.dataPolicy = dataPolicy
      $0.grantees = grantees
    }
    return try await self.removeGrantees(request: request)
  }

  public func updateDataPolicy(request: UpdateDataPolicyRequest) async throws
    -> GoogleBigQueryDataPoliciesV2.DataPolicy
  {
    try await self.updateDataPolicy(request: request, options: .init())
  }

  public func updateDataPolicy(
    request: UpdateDataPolicyRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleBigQueryDataPoliciesV2.DataPolicy {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func updateDataPolicy(
    dataPolicy: DataPolicy?,
    updateMask: GoogleCloudWkt.FieldMask?,
  ) async throws -> GoogleBigQueryDataPoliciesV2.DataPolicy {
    let request = UpdateDataPolicyRequest().with {
      $0.dataPolicy = dataPolicy
      $0.updateMask = updateMask
    }
    return try await self.updateDataPolicy(request: request)
  }

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

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

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

  public func getDataPolicy(request: GetDataPolicyRequest) async throws
    -> GoogleBigQueryDataPoliciesV2.DataPolicy
  {
    try await self.getDataPolicy(request: request, options: .init())
  }

  public func getDataPolicy(
    request: GetDataPolicyRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleBigQueryDataPoliciesV2.DataPolicy {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func getDataPolicy(
    name: Swift.String,
  ) async throws -> GoogleBigQueryDataPoliciesV2.DataPolicy {
    let request = GetDataPolicyRequest().with {
      $0.name = name
    }
    return try await self.getDataPolicy(request: request)
  }

  public func listDataPolicies(request: ListDataPoliciesRequest) async throws
    -> GoogleBigQueryDataPoliciesV2.ListDataPoliciesResponse
  {
    try await self.listDataPolicies(request: request, options: .init())
  }

  public func listDataPolicies(
    request: ListDataPoliciesRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleBigQueryDataPoliciesV2.ListDataPoliciesResponse {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func listDataPolicies(
    byItem: ListDataPoliciesRequest
  ) throws -> any AsyncSequence<DataPolicy, Swift.Error> {
    try self.listDataPolicies(byItem: byItem, options: .init())
  }

  public func listDataPolicies(
    byItem: ListDataPoliciesRequest, options: GoogleCloudGax.RequestOptions
  ) throws -> any AsyncSequence<DataPolicy, Swift.Error> {
    let listRpc = {
      (token: Swift.String) async throws -> GoogleBigQueryDataPoliciesV2.ListDataPoliciesResponse in
      throw GoogleCloudGax.RequestError.unimplemented
    }
    return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
  }

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

  public func getIamPolicy(request: GoogleIAMV1.GetIamPolicyRequest) async throws
    -> GoogleIAMV1.Policy
  {
    try await self.getIamPolicy(request: request, options: .init())
  }

  public func getIamPolicy(
    request: GoogleIAMV1.GetIamPolicyRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleIAMV1.Policy {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func setIamPolicy(request: GoogleIAMV1.SetIamPolicyRequest) async throws
    -> GoogleIAMV1.Policy
  {
    try await self.setIamPolicy(request: request, options: .init())
  }

  public func setIamPolicy(
    request: GoogleIAMV1.SetIamPolicyRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleIAMV1.Policy {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func testIamPermissions(request: GoogleIAMV1.TestIamPermissionsRequest) async throws
    -> GoogleIAMV1.TestIamPermissionsResponse
  {
    try await self.testIamPermissions(request: request, options: .init())
  }

  public func testIamPermissions(
    request: GoogleIAMV1.TestIamPermissionsRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleIAMV1.TestIamPermissionsResponse {
    throw GoogleCloudGax.RequestError.unimplemented
  }
}
