//
// DO NOT EDIT.
//
// Generated by the protocol buffer compiler.
// Source: lum/beam/query.proto
//

//
// Copyright 2018, gRPC Authors All rights reserved.
//
// 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
//
//     http://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 GRPC
import NIO
import SwiftProtobuf


/// Query defines the gRPC querier service.
///
/// Usage: instantiate `Lum_Network_Beam_QueryClient`, then call methods of this protocol to make API calls.
internal protocol Lum_Network_Beam_QueryClientProtocol: GRPCClient {
  var serviceName: String { get }
  var interceptors: Lum_Network_Beam_QueryClientInterceptorFactoryProtocol? { get }

  func beam(
    _ request: Lum_Network_Beam_QueryGetBeamRequest,
    callOptions: CallOptions?
  ) -> UnaryCall<Lum_Network_Beam_QueryGetBeamRequest, Lum_Network_Beam_QueryGetBeamResponse>

  func beams(
    _ request: Lum_Network_Beam_QueryFetchBeamsRequest,
    callOptions: CallOptions?
  ) -> UnaryCall<Lum_Network_Beam_QueryFetchBeamsRequest, Lum_Network_Beam_QueryFetchBeamsResponse>
}

extension Lum_Network_Beam_QueryClientProtocol {
  internal var serviceName: String {
    return "lum.network.beam.Query"
  }

  /// Unary call to Beam
  ///
  /// - Parameters:
  ///   - request: Request to send to Beam.
  ///   - callOptions: Call options.
  /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  internal func beam(
    _ request: Lum_Network_Beam_QueryGetBeamRequest,
    callOptions: CallOptions? = nil
  ) -> UnaryCall<Lum_Network_Beam_QueryGetBeamRequest, Lum_Network_Beam_QueryGetBeamResponse> {
    return self.makeUnaryCall(
      path: "/lum.network.beam.Query/Beam",
      request: request,
      callOptions: callOptions ?? self.defaultCallOptions,
      interceptors: self.interceptors?.makeBeamInterceptors() ?? []
    )
  }

  /// Unary call to Beams
  ///
  /// - Parameters:
  ///   - request: Request to send to Beams.
  ///   - callOptions: Call options.
  /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  internal func beams(
    _ request: Lum_Network_Beam_QueryFetchBeamsRequest,
    callOptions: CallOptions? = nil
  ) -> UnaryCall<Lum_Network_Beam_QueryFetchBeamsRequest, Lum_Network_Beam_QueryFetchBeamsResponse> {
    return self.makeUnaryCall(
      path: "/lum.network.beam.Query/Beams",
      request: request,
      callOptions: callOptions ?? self.defaultCallOptions,
      interceptors: self.interceptors?.makeBeamsInterceptors() ?? []
    )
  }
}

internal protocol Lum_Network_Beam_QueryClientInterceptorFactoryProtocol {

  /// - Returns: Interceptors to use when invoking 'beam'.
  func makeBeamInterceptors() -> [ClientInterceptor<Lum_Network_Beam_QueryGetBeamRequest, Lum_Network_Beam_QueryGetBeamResponse>]

  /// - Returns: Interceptors to use when invoking 'beams'.
  func makeBeamsInterceptors() -> [ClientInterceptor<Lum_Network_Beam_QueryFetchBeamsRequest, Lum_Network_Beam_QueryFetchBeamsResponse>]
}

internal final class Lum_Network_Beam_QueryClient: Lum_Network_Beam_QueryClientProtocol {
  internal let channel: GRPCChannel
  internal var defaultCallOptions: CallOptions
  internal var interceptors: Lum_Network_Beam_QueryClientInterceptorFactoryProtocol?

  /// Creates a client for the lum.network.beam.Query service.
  ///
  /// - Parameters:
  ///   - channel: `GRPCChannel` to the service host.
  ///   - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
  ///   - interceptors: A factory providing interceptors for each RPC.
  internal init(
    channel: GRPCChannel,
    defaultCallOptions: CallOptions = CallOptions(),
    interceptors: Lum_Network_Beam_QueryClientInterceptorFactoryProtocol? = nil
  ) {
    self.channel = channel
    self.defaultCallOptions = defaultCallOptions
    self.interceptors = interceptors
  }
}

/// Query defines the gRPC querier service.
///
/// To build a server, implement a class that conforms to this protocol.
internal protocol Lum_Network_Beam_QueryProvider: CallHandlerProvider {
  var interceptors: Lum_Network_Beam_QueryServerInterceptorFactoryProtocol? { get }

  func beam(request: Lum_Network_Beam_QueryGetBeamRequest, context: StatusOnlyCallContext) -> EventLoopFuture<Lum_Network_Beam_QueryGetBeamResponse>

  func beams(request: Lum_Network_Beam_QueryFetchBeamsRequest, context: StatusOnlyCallContext) -> EventLoopFuture<Lum_Network_Beam_QueryFetchBeamsResponse>
}

extension Lum_Network_Beam_QueryProvider {
  internal var serviceName: Substring { return "lum.network.beam.Query" }

  /// Determines, calls and returns the appropriate request handler, depending on the request's method.
  /// Returns nil for methods not handled by this service.
  internal func handle(
    method name: Substring,
    context: CallHandlerContext
  ) -> GRPCServerHandlerProtocol? {
    switch name {
    case "Beam":
      return UnaryServerHandler(
        context: context,
        requestDeserializer: ProtobufDeserializer<Lum_Network_Beam_QueryGetBeamRequest>(),
        responseSerializer: ProtobufSerializer<Lum_Network_Beam_QueryGetBeamResponse>(),
        interceptors: self.interceptors?.makeBeamInterceptors() ?? [],
        userFunction: self.beam(request:context:)
      )

    case "Beams":
      return UnaryServerHandler(
        context: context,
        requestDeserializer: ProtobufDeserializer<Lum_Network_Beam_QueryFetchBeamsRequest>(),
        responseSerializer: ProtobufSerializer<Lum_Network_Beam_QueryFetchBeamsResponse>(),
        interceptors: self.interceptors?.makeBeamsInterceptors() ?? [],
        userFunction: self.beams(request:context:)
      )

    default:
      return nil
    }
  }
}

internal protocol Lum_Network_Beam_QueryServerInterceptorFactoryProtocol {

  /// - Returns: Interceptors to use when handling 'beam'.
  ///   Defaults to calling `self.makeInterceptors()`.
  func makeBeamInterceptors() -> [ServerInterceptor<Lum_Network_Beam_QueryGetBeamRequest, Lum_Network_Beam_QueryGetBeamResponse>]

  /// - Returns: Interceptors to use when handling 'beams'.
  ///   Defaults to calling `self.makeInterceptors()`.
  func makeBeamsInterceptors() -> [ServerInterceptor<Lum_Network_Beam_QueryFetchBeamsRequest, Lum_Network_Beam_QueryFetchBeamsResponse>]
}
