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

#if LicenseCodes
  import Foundation
  #if canImport(FoundationNetworking)
    import FoundationNetworking
  #endif
  import GoogleCloudWkt
  import GoogleCloudGax

  /// Service for the `licenseCodes` resource.
  ///
  /// @Snippet(path: "licenseCodesQuickstart")
  public class LicenseCodesClient: Clients.LicenseCodesProtocol {
    let inner: any Clients.LicenseCodesStub

    /// Creates a new `LicenseCodesClient` instance.
    public init(_ options: GoogleCloudGax.ClientOptions = .init()) throws {
      var inner: any Clients.LicenseCodesStub = try Clients.LicenseCodesTransport(options)
      inner = Clients.LicenseCodesRetry(inner, options: options)
      if let logger = options.logger {
        inner = Clients.LicenseCodesLogging(inner, logger: logger)
      }
      self.inner = inner
    }

    /// Return a specified license code. License codes are mirrored across
    /// all projects that have permissions to read the License Code.
    ///  *Caution* This resource is intended
    /// for use only by third-party partners who are creatingCloud Marketplace
    /// images.
    ///
    /// @Snippet(path: "licenseCodes_get")
    public func `get`(
      request: LicenseCodesClient.GetRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudComputeV1.LicenseCode {
      try await self.inner.`get`(request: request, options: options)
    }

    /// Gets the access control policy for a resource. May be empty if no such
    /// policy or resource exists.
    ///  *Caution* This resource is intended
    /// for use only by third-party partners who are creatingCloud Marketplace
    /// images.
    ///
    /// @Snippet(path: "licenseCodes_getIamPolicy")
    public func getIamPolicy(
      request: LicenseCodesClient.GetIamPolicyRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudComputeV1.Policy {
      try await self.inner.getIamPolicy(request: request, options: options)
    }

    /// Sets the access control policy on the specified resource.
    /// Replaces any existing policy.
    ///  *Caution* This resource is intended
    /// for use only by third-party partners who are creatingCloud Marketplace
    /// images.
    ///
    /// @Snippet(path: "licenseCodes_setIamPolicy")
    public func setIamPolicy(
      request: LicenseCodesClient.SetIamPolicyRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudComputeV1.Policy {
      try await self.inner.setIamPolicy(request: request, options: options)
    }

    /// Returns permissions that a caller has on the specified resource.
    ///  *Caution* This resource is intended
    /// for use only by third-party partners who are creatingCloud Marketplace
    /// images.
    ///
    /// @Snippet(path: "licenseCodes_testIamPermissions")
    public func testIamPermissions(
      request: LicenseCodesClient.TestIamPermissionsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudComputeV1.TestPermissionsResponse {
      try await self.inner.testIamPermissions(request: request, options: options)
    }
  }

  extension Clients {
    /// A Swift protocol to mock `LicenseCodesClient`.
    ///
    /// To mock `LicenseCodesClient` change your functions to receive
    /// `some LicenseCodesProtocol` or `any LicenseCodesProtocol`
    /// and pass a mock implementation in your tests.
    public protocol LicenseCodesProtocol {
      /// See `LicenseCodesClient.`get``.
      func `get`(request: LicenseCodesClient.GetRequest) async throws
        -> GoogleCloudComputeV1.LicenseCode

      /// See `LicenseCodesClient.`get``.
      func `get`(
        project: Swift.String,
        licenseCode: Swift.String,
      ) async throws -> GoogleCloudComputeV1.LicenseCode

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

      /// See `LicenseCodesClient.getIamPolicy`.
      func getIamPolicy(
        project: Swift.String,
        resource: Swift.String,
      ) async throws -> GoogleCloudComputeV1.Policy

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

      /// See `LicenseCodesClient.setIamPolicy`.
      func setIamPolicy(
        project: Swift.String,
        resource: Swift.String,
        body: GlobalSetPolicyRequest?,
      ) async throws -> GoogleCloudComputeV1.Policy

      /// See `LicenseCodesClient.testIamPermissions`.
      func testIamPermissions(request: LicenseCodesClient.TestIamPermissionsRequest) async throws
        -> GoogleCloudComputeV1.TestPermissionsResponse

      /// See `LicenseCodesClient.testIamPermissions`.
      func testIamPermissions(
        project: Swift.String,
        resource: Swift.String,
        body: TestPermissionsRequest?,
      ) async throws -> GoogleCloudComputeV1.TestPermissionsResponse

      /// See `LicenseCodesClient.`get``.
      func `get`(
        request: LicenseCodesClient.GetRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudComputeV1.LicenseCode

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

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

      /// See `LicenseCodesClient.testIamPermissions`.
      func testIamPermissions(
        request: LicenseCodesClient.TestIamPermissionsRequest,
        options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudComputeV1.TestPermissionsResponse
    }
  }

  // Default implementations
  extension Clients.LicenseCodesProtocol {
    public func `get`(request: LicenseCodesClient.GetRequest) async throws
      -> GoogleCloudComputeV1.LicenseCode
    {
      try await self.`get`(request: request, options: .init())
    }

    public func `get`(
      request: LicenseCodesClient.GetRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudComputeV1.LicenseCode {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func `get`(
      project: Swift.String,
      licenseCode: Swift.String,
    ) async throws -> GoogleCloudComputeV1.LicenseCode {
      let request = LicenseCodesClient.GetRequest().with {
        $0.project = project
        $0.licenseCode = licenseCode
      }
      return try await self.`get`(request: request)
    }

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

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

    public func getIamPolicy(
      project: Swift.String,
      resource: Swift.String,
    ) async throws -> GoogleCloudComputeV1.Policy {
      let request = LicenseCodesClient.GetIamPolicyRequest().with {
        $0.project = project
        $0.resource = resource
      }
      return try await self.getIamPolicy(request: request)
    }

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

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

    public func setIamPolicy(
      project: Swift.String,
      resource: Swift.String,
      body: GlobalSetPolicyRequest?,
    ) async throws -> GoogleCloudComputeV1.Policy {
      let request = LicenseCodesClient.SetIamPolicyRequest().with {
        $0.project = project
        $0.resource = resource
        $0.body = body
      }
      return try await self.setIamPolicy(request: request)
    }

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

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

    public func testIamPermissions(
      project: Swift.String,
      resource: Swift.String,
      body: TestPermissionsRequest?,
    ) async throws -> GoogleCloudComputeV1.TestPermissionsResponse {
      let request = LicenseCodesClient.TestIamPermissionsRequest().with {
        $0.project = project
        $0.resource = resource
        $0.body = body
      }
      return try await self.testIamPermissions(request: request)
    }
  }
#endif
