// THIS FILE IS AUTO GENERATED, DON"T EDIT IT DIRECTLY.
import {
  async_once,

  PrepareCall,
  NanoEventHelper,
  JSON2GrpcMessage,
  DefaultDialHelper
} from '@nanoapp/proxy'

let permissions = [
];

import { grpc } from "@improbable-eng/grpc-web";

import { progInfos as proxyApps } from '@nanoapp/proxy/dist/proginfo.js';

import linux_amd64_9a287731682cc49f1905b4dd0059fd71 from 'file-loader?name=[md5:hash:hex]&&outputPath=nanoapps/linux/amd64/NAPIs/!../../napi.bin/linux/amd64.nanoapp';

import linux_arm64_a6f596039944b780a529260dc69cf112 from 'file-loader?name=[md5:hash:hex]&&outputPath=nanoapps/linux/arm64/NAPIs/!../../napi.bin/linux/arm64.nanoapp';

let __nprogs__ = {

    "linux/amd64": {
      path: linux_amd64_9a287731682cc49f1905b4dd0059fd71,
      hash: "9a287731682cc49f1905b4dd0059fd71",
      size: "3702120",
    },

    "linux/arm64": {
      path: linux_arm64_a6f596039944b780a529260dc69cf112,
      hash: "a6f596039944b780a529260dc69cf112",
      size: "9568256",
    },

}

import { OSClient as _OSClient } from "./os_pb_service.js";

export class OS {
  constructor(dialHelper=DefaultDialHelper) {
    this.__dial_helper = dialHelper
    if (typeof this.__dial_helper.set_nproxy_programs === "function") {
       this.__dial_helper.set_nproxy_programs(proxyApps)
    }
    
    
    
  }
  async __dial__() {
    return await this.__dial_helper.dial({
      name: "nanoapp.nstd",
      type: "",


      programs: __nprogs__,

      appclient: _OSClient,
      permissions,
    });
  }
  async Homedir(req, scontrol) {
    
    let prepare = new PrepareCall(scontrol);
    let thisApp = await this.__dial__();
    if (prepare.shouldReturn()) {
      return
    }
    return new Promise(function(resolve, reject) {
      let ret = thisApp.homedir(req, thisApp.options.metadata, (err, msg) => {
        if (err) { reject(err) } else { resolve(msg) }
      })
      prepare.switchToApp(ret)
    })
  }
  async Hostname(req, scontrol) {
    
    let prepare = new PrepareCall(scontrol);
    let thisApp = await this.__dial__();
    if (prepare.shouldReturn()) {
      return
    }
    return new Promise(function(resolve, reject) {
      let ret = thisApp.hostname(req, thisApp.options.metadata, (err, msg) => {
        if (err) { reject(err) } else { resolve(msg) }
      })
      prepare.switchToApp(ret)
    })
  }
  async Environ(req, scontrol) {
    
    let prepare = new PrepareCall(scontrol);
    let thisApp = await this.__dial__();
    if (prepare.shouldReturn()) {
      return
    }
    return new Promise(function(resolve, reject) {
      let ret = thisApp.environ(req, thisApp.options.metadata, (err, msg) => {
        if (err) { reject(err) } else { resolve(msg) }
      })
      prepare.switchToApp(ret)
    })
  }
}

// 导入所有的Message Type
import { String, StringArray } from "./os_pb.js";
export { String, StringArray }
