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

  /// Service for the `globalOperations` resource.
  ///
  /// @Snippet(path: "globalOperationsQuickstart")
  public class GlobalOperationsClient: Clients.GlobalOperationsProtocol {
    let inner: any Clients.GlobalOperationsStub

    /// Creates a new `GlobalOperationsClient` instance.
    public init(_ options: GoogleCloudGax.ClientOptions = .init()) throws {
      var inner: any Clients.GlobalOperationsStub = try Clients.GlobalOperationsTransport(options)
      inner = Clients.GlobalOperationsRetry(inner, options: options)
      if let logger = options.logger {
        inner = Clients.GlobalOperationsLogging(inner, logger: logger)
      }
      self.inner = inner
    }

    /// Retrieves an aggregated list of all operations.
    ///
    /// To prevent failure, Google recommends that you set the
    /// `returnPartialSuccess` parameter to `true`.
    ///
    /// @Snippet(path: "globalOperations_aggregatedList")
    public func aggregatedList(
      request: GlobalOperationsClient.AggregatedListRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudComputeV1.OperationAggregatedList {
      try await self.inner.aggregatedList(request: request, options: options)
    }

    /// Retrieves an aggregated list of all operations.
    ///
    /// To prevent failure, Google recommends that you set the
    /// `returnPartialSuccess` parameter to `true`.
    ///
    /// @Snippet(path: "globalOperations_aggregatedList")
    public func aggregatedList(
      byItem: GlobalOperationsClient.AggregatedListRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<(Swift.String, OperationsScopedList), Swift.Error> {
      let listRpc = {
        (token: Swift.String) async throws -> GoogleCloudComputeV1.OperationAggregatedList in
        var request = byItem
        request.pageToken = token
        return try await self.aggregatedList(request: request, options: options)
      }
      return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
    }

    /// Deletes the specified Operations resource.
    ///
    /// @Snippet(path: "globalOperations_delete")
    public func delete(
      request: GlobalOperationsClient.DeleteRequest, options: GoogleCloudGax.RequestOptions
    ) async throws {
      try await self.inner.delete(request: request, options: options)
    }

    /// Retrieves the specified Operations resource.
    ///
    /// @Snippet(path: "globalOperations_get")
    public func `get`(
      request: GlobalOperationsClient.GetRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudComputeV1.Operation {
      try await self.inner.`get`(request: request, options: options)
    }

    /// Retrieves a list of Operation resources contained within the specified
    /// project.
    ///
    /// @Snippet(path: "globalOperations_list")
    public func list(
      request: GlobalOperationsClient.ListRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudComputeV1.OperationList {
      try await self.inner.list(request: request, options: options)
    }

    /// Retrieves a list of Operation resources contained within the specified
    /// project.
    ///
    /// @Snippet(path: "globalOperations_list")
    public func list(
      byItem: GlobalOperationsClient.ListRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<Operation, Swift.Error> {
      let listRpc = { (token: Swift.String) async throws -> GoogleCloudComputeV1.OperationList in
        var request = byItem
        request.pageToken = token
        return try await self.list(request: request, options: options)
      }
      return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
    }

    /// Waits for the specified Operation resource to return as `DONE`
    /// or for the request to approach the 2 minute deadline, and retrieves the
    /// specified Operation resource. This method differs from the
    /// `GET` method in that it waits for no more than the default
    /// deadline (2 minutes) and then returns the current state of the operation,
    /// which might be `DONE` or still in progress.
    ///
    /// This method is called on a best-effort basis. Specifically:
    ///
    ///
    ///     - In uncommon cases, when the server is overloaded, the request might
    ///     return before the default deadline is reached, or might return after zero
    ///     seconds.
    ///    - If the default deadline is reached, there is no guarantee that the
    ///     operation is actually done when the method returns. Be prepared to retry
    ///     if the operation is not `DONE`.
    ///
    /// @Snippet(path: "globalOperations_wait")
    public func wait(
      request: GlobalOperationsClient.WaitRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudComputeV1.Operation {
      try await self.inner.wait(request: request, options: options)
    }
  }

  extension Clients {
    /// A Swift protocol to mock `GlobalOperationsClient`.
    ///
    /// To mock `GlobalOperationsClient` change your functions to receive
    /// `some GlobalOperationsProtocol` or `any GlobalOperationsProtocol`
    /// and pass a mock implementation in your tests.
    public protocol GlobalOperationsProtocol {
      /// See `GlobalOperationsClient.aggregatedList`.
      func aggregatedList(request: GlobalOperationsClient.AggregatedListRequest) async throws
        -> GoogleCloudComputeV1.OperationAggregatedList

      /// See `GlobalOperationsClient.aggregatedList`.
      func aggregatedList(
        byItem: GlobalOperationsClient.AggregatedListRequest
      ) throws -> any AsyncSequence<(Swift.String, OperationsScopedList), Swift.Error>

      /// See `GlobalOperationsClient.aggregatedList`.
      func aggregatedList(
        project: Swift.String,
      ) throws -> any AsyncSequence<(Swift.String, OperationsScopedList), Swift.Error>

      /// See `GlobalOperationsClient.delete`.
      func delete(request: GlobalOperationsClient.DeleteRequest) async throws

      /// See `GlobalOperationsClient.delete`.
      func delete(
        project: Swift.String,
        operation: Swift.String,
      ) async throws

      /// See `GlobalOperationsClient.`get``.
      func `get`(request: GlobalOperationsClient.GetRequest) async throws
        -> GoogleCloudComputeV1.Operation

      /// See `GlobalOperationsClient.`get``.
      func `get`(
        project: Swift.String,
        operation: Swift.String,
      ) async throws -> GoogleCloudComputeV1.Operation

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

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

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

      /// See `GlobalOperationsClient.wait`.
      func wait(request: GlobalOperationsClient.WaitRequest) async throws
        -> GoogleCloudComputeV1.Operation

      /// See `GlobalOperationsClient.wait`.
      func wait(
        project: Swift.String,
        operation: Swift.String,
      ) async throws -> GoogleCloudComputeV1.Operation

      /// See `GlobalOperationsClient.aggregatedList`.
      func aggregatedList(
        request: GlobalOperationsClient.AggregatedListRequest,
        options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudComputeV1.OperationAggregatedList

      /// See `GlobalOperationsClient.aggregatedList`.
      func aggregatedList(
        byItem: GlobalOperationsClient.AggregatedListRequest, options: GoogleCloudGax.RequestOptions
      ) throws -> any AsyncSequence<(Swift.String, OperationsScopedList), Swift.Error>

      /// See `GlobalOperationsClient.delete`.
      func delete(
        request: GlobalOperationsClient.DeleteRequest, options: GoogleCloudGax.RequestOptions
      ) async throws

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

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

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

      /// See `GlobalOperationsClient.wait`.
      func wait(
        request: GlobalOperationsClient.WaitRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudComputeV1.Operation
    }
  }

  // Default implementations
  extension Clients.GlobalOperationsProtocol {
    public func aggregatedList(request: GlobalOperationsClient.AggregatedListRequest) async throws
      -> GoogleCloudComputeV1.OperationAggregatedList
    {
      try await self.aggregatedList(request: request, options: .init())
    }

    public func aggregatedList(
      request: GlobalOperationsClient.AggregatedListRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudComputeV1.OperationAggregatedList {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func aggregatedList(
      byItem: GlobalOperationsClient.AggregatedListRequest
    ) throws -> any AsyncSequence<(Swift.String, OperationsScopedList), Swift.Error> {
      try self.aggregatedList(byItem: byItem, options: .init())
    }

    public func aggregatedList(
      byItem: GlobalOperationsClient.AggregatedListRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<(Swift.String, OperationsScopedList), Swift.Error> {
      let listRpc = {
        (token: Swift.String) async throws -> GoogleCloudComputeV1.OperationAggregatedList in
        throw GoogleCloudGax.RequestError.unimplemented
      }
      return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
    }

    public func aggregatedList(
      project: Swift.String,
    ) throws -> any AsyncSequence<(Swift.String, OperationsScopedList), Swift.Error> {
      let request = GlobalOperationsClient.AggregatedListRequest().with {
        $0.project = project
      }
      return try self.aggregatedList(byItem: request)
    }

    public func delete(request: GlobalOperationsClient.DeleteRequest) async throws {
      try await self.delete(request: request, options: .init())
    }

    public func delete(
      request: GlobalOperationsClient.DeleteRequest, options: GoogleCloudGax.RequestOptions
    ) async throws {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func delete(
      project: Swift.String,
      operation: Swift.String,
    ) async throws {
      let request = GlobalOperationsClient.DeleteRequest().with {
        $0.project = project
        $0.operation = operation
      }
      try await self.delete(request: request)
    }

    public func `get`(request: GlobalOperationsClient.GetRequest) async throws
      -> GoogleCloudComputeV1.Operation
    {
      try await self.`get`(request: request, options: .init())
    }

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

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

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

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

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

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

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

    public func wait(request: GlobalOperationsClient.WaitRequest) async throws
      -> GoogleCloudComputeV1.Operation
    {
      try await self.wait(request: request, options: .init())
    }

    public func wait(
      request: GlobalOperationsClient.WaitRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudComputeV1.Operation {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func wait(
      project: Swift.String,
      operation: Swift.String,
    ) async throws -> GoogleCloudComputeV1.Operation {
      let request = GlobalOperationsClient.WaitRequest().with {
        $0.project = project
        $0.operation = operation
      }
      return try await self.wait(request: request)
    }
  }
#endif
