// 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 Zones
  import Foundation
  #if canImport(FoundationNetworking)
    import FoundationNetworking
  #endif
  import GoogleCloudWkt
  import GoogleCloudGax

  /// Service for the `zones` resource.
  ///
  /// @Snippet(path: "zonesQuickstart")
  public class ZonesClient: Clients.ZonesProtocol {
    let inner: any Clients.ZonesStub

    /// Creates a new `ZonesClient` instance.
    public init(_ options: GoogleCloudGax.ClientOptions = .init()) throws {
      var inner: any Clients.ZonesStub = try Clients.ZonesTransport(options)
      inner = Clients.ZonesRetry(inner, options: options)
      if let logger = options.logger {
        inner = Clients.ZonesLogging(inner, logger: logger)
      }
      self.inner = inner
    }

    /// Returns the specified Zone resource.
    ///
    /// @Snippet(path: "zones_get")
    public func `get`(
      request: ZonesClient.GetRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudComputeV1.Zone {
      try await self.inner.`get`(request: request, options: options)
    }

    /// Retrieves the list of Zone resources available to the specified project.
    ///
    /// @Snippet(path: "zones_list")
    public func list(
      request: ZonesClient.ListRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudComputeV1.ZoneList {
      try await self.inner.list(request: request, options: options)
    }

    /// Retrieves the list of Zone resources available to the specified project.
    ///
    /// @Snippet(path: "zones_list")
    public func list(
      byItem: ZonesClient.ListRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<Zone, Swift.Error> {
      let listRpc = { (token: Swift.String) async throws -> GoogleCloudComputeV1.ZoneList in
        var request = byItem
        request.pageToken = token
        return try await self.list(request: request, options: options)
      }
      return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
    }
  }

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

      /// See `ZonesClient.`get``.
      func `get`(
        project: Swift.String,
        zone: Swift.String,
      ) async throws -> GoogleCloudComputeV1.Zone

      /// See `ZonesClient.list`.
      func list(request: ZonesClient.ListRequest) async throws -> GoogleCloudComputeV1.ZoneList

      /// See `ZonesClient.list`.
      func list(
        byItem: ZonesClient.ListRequest
      ) throws -> any AsyncSequence<Zone, Swift.Error>

      /// See `ZonesClient.list`.
      func list(
        project: Swift.String,
      ) throws -> any AsyncSequence<Zone, Swift.Error>

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

      /// See `ZonesClient.list`.
      func list(
        request: ZonesClient.ListRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudComputeV1.ZoneList

      /// See `ZonesClient.list`.
      func list(
        byItem: ZonesClient.ListRequest, options: GoogleCloudGax.RequestOptions
      ) throws -> any AsyncSequence<Zone, Swift.Error>
    }
  }

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

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

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

    public func list(request: ZonesClient.ListRequest) async throws -> GoogleCloudComputeV1.ZoneList
    {
      try await self.list(request: request, options: .init())
    }

    public func list(
      request: ZonesClient.ListRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudComputeV1.ZoneList {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func list(
      byItem: ZonesClient.ListRequest
    ) throws -> any AsyncSequence<Zone, Swift.Error> {
      try self.list(byItem: byItem, options: .init())
    }

    public func list(
      byItem: ZonesClient.ListRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<Zone, Swift.Error> {
      let listRpc = { (token: Swift.String) async throws -> GoogleCloudComputeV1.ZoneList in
        throw GoogleCloudGax.RequestError.unimplemented
      }
      return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
    }

    public func list(
      project: Swift.String,
    ) throws -> any AsyncSequence<Zone, Swift.Error> {
      let request = ZonesClient.ListRequest().with {
        $0.project = project
      }
      return try self.list(byItem: request)
    }
  }
#endif
