// package: lnks.nstd
// file: subprocess.proto

import * as subprocess_pb from "./subprocess_pb";
import * as google_protobuf_empty_pb from "google-protobuf/google/protobuf/empty_pb";
import {grpc} from "@improbable-eng/grpc-web";

type SubprocessSpawn = {
  readonly methodName: string;
  readonly service: typeof Subprocess;
  readonly requestStream: false;
  readonly responseStream: false;
  readonly requestType: typeof subprocess_pb.SpawnInfo;
  readonly responseType: typeof subprocess_pb.ProcessID;
};

type SubprocessStart = {
  readonly methodName: string;
  readonly service: typeof Subprocess;
  readonly requestStream: false;
  readonly responseStream: false;
  readonly requestType: typeof subprocess_pb.ProcessID;
  readonly responseType: typeof google_protobuf_empty_pb.Empty;
};

type SubprocessWait = {
  readonly methodName: string;
  readonly service: typeof Subprocess;
  readonly requestStream: false;
  readonly responseStream: false;
  readonly requestType: typeof subprocess_pb.ProcessID;
  readonly responseType: typeof google_protobuf_empty_pb.Empty;
};

type Subprocesskill = {
  readonly methodName: string;
  readonly service: typeof Subprocess;
  readonly requestStream: false;
  readonly responseStream: false;
  readonly requestType: typeof subprocess_pb.ProcessID;
  readonly responseType: typeof google_protobuf_empty_pb.Empty;
};

type SubprocessClosePipe = {
  readonly methodName: string;
  readonly service: typeof Subprocess;
  readonly requestStream: false;
  readonly responseStream: false;
  readonly requestType: typeof subprocess_pb.PipeID;
  readonly responseType: typeof google_protobuf_empty_pb.Empty;
};

type SubprocessReadPipe = {
  readonly methodName: string;
  readonly service: typeof Subprocess;
  readonly requestStream: false;
  readonly responseStream: false;
  readonly requestType: typeof subprocess_pb.ReadPipeRequest;
  readonly responseType: typeof subprocess_pb.Chunk;
};

type SubprocessWritePipe = {
  readonly methodName: string;
  readonly service: typeof Subprocess;
  readonly requestStream: false;
  readonly responseStream: false;
  readonly requestType: typeof subprocess_pb.WritePipeRequest;
  readonly responseType: typeof google_protobuf_empty_pb.Empty;
};

export class Subprocess {
  static readonly serviceName: string;
  static readonly Spawn: SubprocessSpawn;
  static readonly Start: SubprocessStart;
  static readonly Wait: SubprocessWait;
  static readonly kill: Subprocesskill;
  static readonly ClosePipe: SubprocessClosePipe;
  static readonly ReadPipe: SubprocessReadPipe;
  static readonly WritePipe: SubprocessWritePipe;
}

export type ServiceError = { message: string, code: number; metadata: grpc.Metadata }
export type Status = { details: string, code: number; metadata: grpc.Metadata }

interface UnaryResponse {
  cancel(): void;
}
interface ResponseStream<T> {
  cancel(): void;
  on(type: 'data', handler: (message: T) => void): ResponseStream<T>;
  on(type: 'end', handler: (status?: Status) => void): ResponseStream<T>;
  on(type: 'status', handler: (status: Status) => void): ResponseStream<T>;
}
interface RequestStream<T> {
  write(message: T): RequestStream<T>;
  end(): void;
  cancel(): void;
  on(type: 'end', handler: (status?: Status) => void): RequestStream<T>;
  on(type: 'status', handler: (status: Status) => void): RequestStream<T>;
}
interface BidirectionalStream<ReqT, ResT> {
  write(message: ReqT): BidirectionalStream<ReqT, ResT>;
  end(): void;
  cancel(): void;
  on(type: 'data', handler: (message: ResT) => void): BidirectionalStream<ReqT, ResT>;
  on(type: 'end', handler: (status?: Status) => void): BidirectionalStream<ReqT, ResT>;
  on(type: 'status', handler: (status: Status) => void): BidirectionalStream<ReqT, ResT>;
}

export class SubprocessClient {
  readonly serviceHost: string;

  constructor(serviceHost: string, options?: grpc.RpcOptions);
  spawn(
    requestMessage: subprocess_pb.SpawnInfo,
    metadata: grpc.Metadata,
    callback: (error: ServiceError|null, responseMessage: subprocess_pb.ProcessID|null) => void
  ): UnaryResponse;
  spawn(
    requestMessage: subprocess_pb.SpawnInfo,
    callback: (error: ServiceError|null, responseMessage: subprocess_pb.ProcessID|null) => void
  ): UnaryResponse;
  start(
    requestMessage: subprocess_pb.ProcessID,
    metadata: grpc.Metadata,
    callback: (error: ServiceError|null, responseMessage: google_protobuf_empty_pb.Empty|null) => void
  ): UnaryResponse;
  start(
    requestMessage: subprocess_pb.ProcessID,
    callback: (error: ServiceError|null, responseMessage: google_protobuf_empty_pb.Empty|null) => void
  ): UnaryResponse;
  wait(
    requestMessage: subprocess_pb.ProcessID,
    metadata: grpc.Metadata,
    callback: (error: ServiceError|null, responseMessage: google_protobuf_empty_pb.Empty|null) => void
  ): UnaryResponse;
  wait(
    requestMessage: subprocess_pb.ProcessID,
    callback: (error: ServiceError|null, responseMessage: google_protobuf_empty_pb.Empty|null) => void
  ): UnaryResponse;
  kill(
    requestMessage: subprocess_pb.ProcessID,
    metadata: grpc.Metadata,
    callback: (error: ServiceError|null, responseMessage: google_protobuf_empty_pb.Empty|null) => void
  ): UnaryResponse;
  kill(
    requestMessage: subprocess_pb.ProcessID,
    callback: (error: ServiceError|null, responseMessage: google_protobuf_empty_pb.Empty|null) => void
  ): UnaryResponse;
  closePipe(
    requestMessage: subprocess_pb.PipeID,
    metadata: grpc.Metadata,
    callback: (error: ServiceError|null, responseMessage: google_protobuf_empty_pb.Empty|null) => void
  ): UnaryResponse;
  closePipe(
    requestMessage: subprocess_pb.PipeID,
    callback: (error: ServiceError|null, responseMessage: google_protobuf_empty_pb.Empty|null) => void
  ): UnaryResponse;
  readPipe(
    requestMessage: subprocess_pb.ReadPipeRequest,
    metadata: grpc.Metadata,
    callback: (error: ServiceError|null, responseMessage: subprocess_pb.Chunk|null) => void
  ): UnaryResponse;
  readPipe(
    requestMessage: subprocess_pb.ReadPipeRequest,
    callback: (error: ServiceError|null, responseMessage: subprocess_pb.Chunk|null) => void
  ): UnaryResponse;
  writePipe(
    requestMessage: subprocess_pb.WritePipeRequest,
    metadata: grpc.Metadata,
    callback: (error: ServiceError|null, responseMessage: google_protobuf_empty_pb.Empty|null) => void
  ): UnaryResponse;
  writePipe(
    requestMessage: subprocess_pb.WritePipeRequest,
    callback: (error: ServiceError|null, responseMessage: google_protobuf_empty_pb.Empty|null) => void
  ): UnaryResponse;
}

