// package: nde.filesystem
// file: fm.proto

import * as fm_pb from "./fm_pb";
import {grpc} from "@improbable-eng/grpc-web";

type FsManagerGetTree = {
  readonly methodName: string;
  readonly service: typeof FsManager;
  readonly requestStream: false;
  readonly responseStream: true;
  readonly requestType: typeof fm_pb.GetTreeRequest;
  readonly responseType: typeof fm_pb.GetTreeResponse;
};

type FsManagerMkdir = {
  readonly methodName: string;
  readonly service: typeof FsManager;
  readonly requestStream: false;
  readonly responseStream: false;
  readonly requestType: typeof fm_pb.MkdirRequest;
  readonly responseType: typeof fm_pb.MkdirResponse;
};

type FsManagerRemoveFile = {
  readonly methodName: string;
  readonly service: typeof FsManager;
  readonly requestStream: false;
  readonly responseStream: false;
  readonly requestType: typeof fm_pb.RemoveRequest;
  readonly responseType: typeof fm_pb.RemoveResponse;
};

type FsManagerPasteFile = {
  readonly methodName: string;
  readonly service: typeof FsManager;
  readonly requestStream: true;
  readonly responseStream: true;
  readonly requestType: typeof fm_pb.PasteRequest;
  readonly responseType: typeof fm_pb.PasteResponse;
};

type FsManagerRename = {
  readonly methodName: string;
  readonly service: typeof FsManager;
  readonly requestStream: false;
  readonly responseStream: false;
  readonly requestType: typeof fm_pb.RenameRequest;
  readonly responseType: typeof fm_pb.RenameResponse;
};

type FsManagerGetFile = {
  readonly methodName: string;
  readonly service: typeof FsManager;
  readonly requestStream: false;
  readonly responseStream: true;
  readonly requestType: typeof fm_pb.FileName;
  readonly responseType: typeof fm_pb.FileData;
};

type FsManagerSaveFile = {
  readonly methodName: string;
  readonly service: typeof FsManager;
  readonly requestStream: false;
  readonly responseStream: false;
  readonly requestType: typeof fm_pb.SaveFileRequest;
  readonly responseType: typeof fm_pb.SaveFileResponse;
};

export class FsManager {
  static readonly serviceName: string;
  static readonly GetTree: FsManagerGetTree;
  static readonly Mkdir: FsManagerMkdir;
  static readonly RemoveFile: FsManagerRemoveFile;
  static readonly PasteFile: FsManagerPasteFile;
  static readonly Rename: FsManagerRename;
  static readonly GetFile: FsManagerGetFile;
  static readonly SaveFile: FsManagerSaveFile;
}

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 FsManagerClient {
  readonly serviceHost: string;

  constructor(serviceHost: string, options?: grpc.RpcOptions);
  getTree(requestMessage: fm_pb.GetTreeRequest, metadata?: grpc.Metadata): ResponseStream<fm_pb.GetTreeResponse>;
  mkdir(
    requestMessage: fm_pb.MkdirRequest,
    metadata: grpc.Metadata,
    callback: (error: ServiceError|null, responseMessage: fm_pb.MkdirResponse|null) => void
  ): UnaryResponse;
  mkdir(
    requestMessage: fm_pb.MkdirRequest,
    callback: (error: ServiceError|null, responseMessage: fm_pb.MkdirResponse|null) => void
  ): UnaryResponse;
  removeFile(
    requestMessage: fm_pb.RemoveRequest,
    metadata: grpc.Metadata,
    callback: (error: ServiceError|null, responseMessage: fm_pb.RemoveResponse|null) => void
  ): UnaryResponse;
  removeFile(
    requestMessage: fm_pb.RemoveRequest,
    callback: (error: ServiceError|null, responseMessage: fm_pb.RemoveResponse|null) => void
  ): UnaryResponse;
  pasteFile(metadata?: grpc.Metadata): BidirectionalStream<fm_pb.PasteRequest, fm_pb.PasteResponse>;
  rename(
    requestMessage: fm_pb.RenameRequest,
    metadata: grpc.Metadata,
    callback: (error: ServiceError|null, responseMessage: fm_pb.RenameResponse|null) => void
  ): UnaryResponse;
  rename(
    requestMessage: fm_pb.RenameRequest,
    callback: (error: ServiceError|null, responseMessage: fm_pb.RenameResponse|null) => void
  ): UnaryResponse;
  getFile(requestMessage: fm_pb.FileName, metadata?: grpc.Metadata): ResponseStream<fm_pb.FileData>;
  saveFile(
    requestMessage: fm_pb.SaveFileRequest,
    metadata: grpc.Metadata,
    callback: (error: ServiceError|null, responseMessage: fm_pb.SaveFileResponse|null) => void
  ): UnaryResponse;
  saveFile(
    requestMessage: fm_pb.SaveFileRequest,
    callback: (error: ServiceError|null, responseMessage: fm_pb.SaveFileResponse|null) => void
  ): UnaryResponse;
}

