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

/// Provides interfaces for managing [Cloud KMS
/// Autokey](https://cloud.google.com/kms/help/autokey) folder-level or
/// project-level configurations. A configuration is inherited by all descendent
/// folders and projects. A configuration at a folder or project overrides any
/// other configurations in its ancestry. Setting a configuration on a folder is
/// a prerequisite for Cloud KMS Autokey, so that users working in a descendant
/// project can request provisioned [CryptoKeys][google.cloud.kms.v1.CryptoKey],
/// ready for Customer Managed Encryption Key (CMEK) use, on-demand when using
/// the dedicated key project mode. This is not required when using the delegated
/// key management mode for same-project keys.
///
/// [google.cloud.kms.v1.CryptoKey]: <doc:CryptoKey>
///
/// @Snippet(path: "AutokeyAdminQuickstart")
public class AutokeyAdminClient: Clients.AutokeyAdminProtocol {
  let inner: any Clients.AutokeyAdminStub

  /// Creates a new `AutokeyAdminClient` instance.
  public init(_ options: GoogleCloudGax.ClientOptions = .init()) throws {
    var inner: any Clients.AutokeyAdminStub = try Clients.AutokeyAdminTransport(options)
    inner = Clients.AutokeyAdminRetry(inner, options: options)
    if let logger = options.logger {
      inner = Clients.AutokeyAdminLogging(inner, logger: logger)
    }
    self.inner = inner
  }

  /// Updates the [AutokeyConfig][google.cloud.kms.v1.AutokeyConfig] for a folder
  /// or a project. The caller must have both `cloudkms.autokeyConfigs.update`
  /// permission on the parent folder and `cloudkms.cryptoKeys.setIamPolicy`
  /// permission on the provided key project. A
  /// [KeyHandle][google.cloud.kms.v1.KeyHandle] creation in the folder's
  /// descendant projects will use this configuration to determine where to
  /// create the resulting [CryptoKey][google.cloud.kms.v1.CryptoKey].
  ///
  /// [google.cloud.kms.v1.AutokeyConfig]: <doc:AutokeyConfig>
  /// [google.cloud.kms.v1.CryptoKey]: <doc:CryptoKey>
  /// [google.cloud.kms.v1.KeyHandle]: <doc:KeyHandle>
  ///
  /// @Snippet(path: "AutokeyAdmin_UpdateAutokeyConfig")
  public func updateAutokeyConfig(
    request: UpdateAutokeyConfigRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudKMSV1.AutokeyConfig {
    try await self.inner.updateAutokeyConfig(request: request, options: options)
  }

  /// Returns the [AutokeyConfig][google.cloud.kms.v1.AutokeyConfig] for a folder
  /// or project.
  ///
  /// [google.cloud.kms.v1.AutokeyConfig]: <doc:AutokeyConfig>
  ///
  /// @Snippet(path: "AutokeyAdmin_GetAutokeyConfig")
  public func getAutokeyConfig(
    request: GetAutokeyConfigRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudKMSV1.AutokeyConfig {
    try await self.inner.getAutokeyConfig(request: request, options: options)
  }

  /// Returns the effective Cloud KMS Autokey configuration for a given project.
  ///
  /// @Snippet(path: "AutokeyAdmin_ShowEffectiveAutokeyConfig")
  public func showEffectiveAutokeyConfig(
    request: ShowEffectiveAutokeyConfigRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudKMSV1.ShowEffectiveAutokeyConfigResponse {
    try await self.inner.showEffectiveAutokeyConfig(request: request, options: options)
  }

  /// Lists information about the supported locations for this service.
  ///
  /// This method lists locations based on the resource scope provided in
  /// the [ListLocationsRequest.name][google.cloud.location.ListLocationsRequest.name] field: *
  /// **Global locations**: If `name` is empty, the method lists the
  /// public locations available to all projects. * **Project-specific
  /// locations**: If `name` follows the format
  /// `projects/{project}`, the method lists locations visible to that
  /// specific project. This includes public, private, or other
  /// project-specific locations enabled for the project.
  ///
  /// For gRPC and client library implementations, the resource name is
  /// passed as the `name` field. For direct service calls, the resource
  /// name is
  /// incorporated into the request path based on the specific service
  /// implementation and version.
  ///
  /// [google.cloud.location.ListLocationsRequest.name]: https://www.google.com/search?q=Swift+google.cloud.location+GoogleCloudLocation.ListLocationsRequest/name
  ///
  /// @Snippet(path: "AutokeyAdmin_ListLocations")
  public func listLocations(
    request: GoogleCloudLocation.ListLocationsRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudLocation.ListLocationsResponse {
    try await self.inner.listLocations(request: request, options: options)
  }

  /// Lists information about the supported locations for this service.
  ///
  /// This method lists locations based on the resource scope provided in
  /// the [ListLocationsRequest.name][google.cloud.location.ListLocationsRequest.name] field: *
  /// **Global locations**: If `name` is empty, the method lists the
  /// public locations available to all projects. * **Project-specific
  /// locations**: If `name` follows the format
  /// `projects/{project}`, the method lists locations visible to that
  /// specific project. This includes public, private, or other
  /// project-specific locations enabled for the project.
  ///
  /// For gRPC and client library implementations, the resource name is
  /// passed as the `name` field. For direct service calls, the resource
  /// name is
  /// incorporated into the request path based on the specific service
  /// implementation and version.
  ///
  /// [google.cloud.location.ListLocationsRequest.name]: https://www.google.com/search?q=Swift+google.cloud.location+GoogleCloudLocation.ListLocationsRequest/name
  ///
  /// @Snippet(path: "AutokeyAdmin_ListLocations")
  public func listLocations(
    byItem: GoogleCloudLocation.ListLocationsRequest, options: GoogleCloudGax.RequestOptions
  ) throws -> any AsyncSequence<GoogleCloudLocation.Location, Swift.Error> {
    let listRpc = {
      (token: Swift.String) async throws -> GoogleCloudLocation.ListLocationsResponse in
      var request = byItem
      request.pageToken = token
      return try await self.listLocations(request: request, options: options)
    }
    return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
  }

  /// Gets information about a location.
  ///
  /// @Snippet(path: "AutokeyAdmin_GetLocation")
  public func getLocation(
    request: GoogleCloudLocation.GetLocationRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudLocation.Location {
    try await self.inner.getLocation(request: request, options: options)
  }

  /// Sets the access control policy on the specified resource. Replaces
  /// any existing policy.
  ///
  /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
  /// errors.
  ///
  /// @Snippet(path: "AutokeyAdmin_SetIamPolicy")
  public func setIamPolicy(
    request: GoogleIAMV1.SetIamPolicyRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleIAMV1.Policy {
    try await self.inner.setIamPolicy(request: request, options: options)
  }

  /// Gets the access control policy for a resource. Returns an empty policy
  /// if the resource exists and does not have a policy set.
  ///
  /// @Snippet(path: "AutokeyAdmin_GetIamPolicy")
  public func getIamPolicy(
    request: GoogleIAMV1.GetIamPolicyRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleIAMV1.Policy {
    try await self.inner.getIamPolicy(request: request, options: options)
  }

  /// Returns permissions that a caller has on the specified resource. If the
  /// resource does not exist, this will return an empty set of
  /// permissions, not a `NOT_FOUND` error.
  ///
  /// Note: This operation is designed to be used for building
  /// permission-aware UIs and command-line tools, not for authorization
  /// checking. This operation may "fail open" without warning.
  ///
  /// @Snippet(path: "AutokeyAdmin_TestIamPermissions")
  public func testIamPermissions(
    request: GoogleIAMV1.TestIamPermissionsRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleIAMV1.TestIamPermissionsResponse {
    try await self.inner.testIamPermissions(request: request, options: options)
  }

  /// 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: "AutokeyAdmin_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 `AutokeyAdminClient`.
  ///
  /// To mock `AutokeyAdminClient` change your functions to receive
  /// `some AutokeyAdminProtocol` or `any AutokeyAdminProtocol`
  /// and pass a mock implementation in your tests.
  public protocol AutokeyAdminProtocol {
    /// See `AutokeyAdminClient.updateAutokeyConfig`.
    func updateAutokeyConfig(request: UpdateAutokeyConfigRequest) async throws
      -> GoogleCloudKMSV1.AutokeyConfig

    /// See `AutokeyAdminClient.updateAutokeyConfig`.
    func updateAutokeyConfig(
      autokeyConfig: AutokeyConfig?,
      updateMask: GoogleCloudWkt.FieldMask?,
    ) async throws -> GoogleCloudKMSV1.AutokeyConfig

    /// See `AutokeyAdminClient.getAutokeyConfig`.
    func getAutokeyConfig(request: GetAutokeyConfigRequest) async throws
      -> GoogleCloudKMSV1.AutokeyConfig

    /// See `AutokeyAdminClient.getAutokeyConfig`.
    func getAutokeyConfig(
      name: Swift.String,
    ) async throws -> GoogleCloudKMSV1.AutokeyConfig

    /// See `AutokeyAdminClient.showEffectiveAutokeyConfig`.
    func showEffectiveAutokeyConfig(request: ShowEffectiveAutokeyConfigRequest) async throws
      -> GoogleCloudKMSV1.ShowEffectiveAutokeyConfigResponse

    /// See `AutokeyAdminClient.showEffectiveAutokeyConfig`.
    func showEffectiveAutokeyConfig(
      parent: Swift.String,
    ) async throws -> GoogleCloudKMSV1.ShowEffectiveAutokeyConfigResponse

    /// See `AutokeyAdminClient.listLocations`.
    func listLocations(request: GoogleCloudLocation.ListLocationsRequest) async throws
      -> GoogleCloudLocation.ListLocationsResponse

    /// See `AutokeyAdminClient.listLocations`.
    func listLocations(
      byItem: GoogleCloudLocation.ListLocationsRequest
    ) throws -> any AsyncSequence<GoogleCloudLocation.Location, Swift.Error>

    /// See `AutokeyAdminClient.getLocation`.
    func getLocation(request: GoogleCloudLocation.GetLocationRequest) async throws
      -> GoogleCloudLocation.Location

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

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

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

    /// See `AutokeyAdminClient.updateAutokeyConfig`.
    func updateAutokeyConfig(
      request: UpdateAutokeyConfigRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudKMSV1.AutokeyConfig

    /// See `AutokeyAdminClient.getAutokeyConfig`.
    func getAutokeyConfig(
      request: GetAutokeyConfigRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudKMSV1.AutokeyConfig

    /// See `AutokeyAdminClient.showEffectiveAutokeyConfig`.
    func showEffectiveAutokeyConfig(
      request: ShowEffectiveAutokeyConfigRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudKMSV1.ShowEffectiveAutokeyConfigResponse

    /// See `AutokeyAdminClient.listLocations`.
    func listLocations(
      request: GoogleCloudLocation.ListLocationsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudLocation.ListLocationsResponse

    /// See `AutokeyAdminClient.listLocations`.
    func listLocations(
      byItem: GoogleCloudLocation.ListLocationsRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<GoogleCloudLocation.Location, Swift.Error>

    /// See `AutokeyAdminClient.getLocation`.
    func getLocation(
      request: GoogleCloudLocation.GetLocationRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudLocation.Location

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

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

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

// Default implementations
extension Clients.AutokeyAdminProtocol {
  public func updateAutokeyConfig(request: UpdateAutokeyConfigRequest) async throws
    -> GoogleCloudKMSV1.AutokeyConfig
  {
    try await self.updateAutokeyConfig(request: request, options: .init())
  }

  public func updateAutokeyConfig(
    request: UpdateAutokeyConfigRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudKMSV1.AutokeyConfig {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func updateAutokeyConfig(
    autokeyConfig: AutokeyConfig?,
    updateMask: GoogleCloudWkt.FieldMask?,
  ) async throws -> GoogleCloudKMSV1.AutokeyConfig {
    let request = UpdateAutokeyConfigRequest().with {
      $0.autokeyConfig = autokeyConfig
      $0.updateMask = updateMask
    }
    return try await self.updateAutokeyConfig(request: request)
  }

  public func getAutokeyConfig(request: GetAutokeyConfigRequest) async throws
    -> GoogleCloudKMSV1.AutokeyConfig
  {
    try await self.getAutokeyConfig(request: request, options: .init())
  }

  public func getAutokeyConfig(
    request: GetAutokeyConfigRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudKMSV1.AutokeyConfig {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func getAutokeyConfig(
    name: Swift.String,
  ) async throws -> GoogleCloudKMSV1.AutokeyConfig {
    let request = GetAutokeyConfigRequest().with {
      $0.name = name
    }
    return try await self.getAutokeyConfig(request: request)
  }

  public func showEffectiveAutokeyConfig(request: ShowEffectiveAutokeyConfigRequest) async throws
    -> GoogleCloudKMSV1.ShowEffectiveAutokeyConfigResponse
  {
    try await self.showEffectiveAutokeyConfig(request: request, options: .init())
  }

  public func showEffectiveAutokeyConfig(
    request: ShowEffectiveAutokeyConfigRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudKMSV1.ShowEffectiveAutokeyConfigResponse {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func showEffectiveAutokeyConfig(
    parent: Swift.String,
  ) async throws -> GoogleCloudKMSV1.ShowEffectiveAutokeyConfigResponse {
    let request = ShowEffectiveAutokeyConfigRequest().with {
      $0.parent = parent
    }
    return try await self.showEffectiveAutokeyConfig(request: request)
  }

  public func listLocations(request: GoogleCloudLocation.ListLocationsRequest) async throws
    -> GoogleCloudLocation.ListLocationsResponse
  {
    try await self.listLocations(request: request, options: .init())
  }

  public func listLocations(
    request: GoogleCloudLocation.ListLocationsRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudLocation.ListLocationsResponse {
    throw GoogleCloudGax.RequestError.unimplemented
  }

  public func listLocations(
    byItem: GoogleCloudLocation.ListLocationsRequest
  ) throws -> any AsyncSequence<GoogleCloudLocation.Location, Swift.Error> {
    try self.listLocations(byItem: byItem, options: .init())
  }

  public func listLocations(
    byItem: GoogleCloudLocation.ListLocationsRequest, options: GoogleCloudGax.RequestOptions
  ) throws -> any AsyncSequence<GoogleCloudLocation.Location, Swift.Error> {
    let listRpc = {
      (token: Swift.String) async throws -> GoogleCloudLocation.ListLocationsResponse in
      throw GoogleCloudGax.RequestError.unimplemented
    }
    return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
  }

  public func getLocation(request: GoogleCloudLocation.GetLocationRequest) async throws
    -> GoogleCloudLocation.Location
  {
    try await self.getLocation(request: request, options: .init())
  }

  public func getLocation(
    request: GoogleCloudLocation.GetLocationRequest, options: GoogleCloudGax.RequestOptions
  ) async throws -> GoogleCloudLocation.Location {
    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 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 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
  }

  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)
  }
}
