async deploy({
    functionId,
    serviceName,
    functionName,
    handler,
    runtime,
    timeout,
    memory,
    codeDir,
    codeChecksum = undefined,
    accountId = undefined,
    region = undefined,
    pinned = false,
    envVars = undefined,
    debugPort = undefined
  }) {
    if (!functionId && (!serviceName || !functionName)) {
      throw new Error(`Neither Function id nor serviceName/functionName is provided.`);
    }
    const content = {
      DeployParams: {
        functions: [{
          debugPort,
          runEnv: debugPort ? 'develop' : 'release',
          codePath: codeDir,
          config: {
            handler,
            timeout,
            functionId,
            accountId,
            serviceName,
            functionName,
            codeChecksum,
            memorySize: memory * 1000 * 1000,
            regionId: region,
            fcRuntime: runtime,
            runMode: pinned ? 'LongLived' : 'OnDemand'
          }
        }]
      }
    };
    if (envVars) {
      content.DeployParams.functions[0].config.environment = {
        variables: Object.assign({}, envVars)
      };
    }
    const params = JSON.stringify(this._buildParams(content));
    const cookie = await this._login();
    const options = {
      method: 'POST',
      host: 'localhost',
      port: '9999',
      path: '/function_compute/deploy',
      headers: {
        cookie
      },
      agent: this._agent,
      rejectUnauthorized: false
    };

    debug(`Deploying: ${params}.`);

    return new Promise((resolve, reject) => {
      const req = https.request(options, (res) => {
        let raw = '';
        res.on('data', (chunk) => {
          raw += chunk;
        });
        res.on('end', () => {
          debug(`Deploy back: ${raw}.`);
          try {
            let parsed = JSON.parse(raw);
            if (parsed.code === 200) {
              resolve();
            } else {
              reject(new Error(`${parsed.message}`));
            }
          } catch (err) {
            reject(new Error('Server Internal Error'));
          }
        });
      });
      req.on('error', (e) => {
        console.error(`Request to deploy error: ${e}`);
        reject(e);
      });
      req.write(params);
      req.end();
    });
  }
Deploy a function.

@param functionId the id of the function.
@param serviceName the name of the service.
@param functionName the name of the function.
@param handler the event handler.
@param runtime the runtime for the function. May be nodejs8, python3, c etc.
@param timeout the maximum execution time of event handler.
@param memory the maximum memory size in megabyte that the function can used.
@param codeDir the path where the code is at.
@param codeChecksum the crc64-ecma182 checksum of the code archive.
@param accountId the id of the account, to which this function belongs.
@param region the region of the function.
@param pinned whether the function is pinned or not. A pinned function is so-called
              'long-lived' function.
@param envVars the environment variables.
@param debugPort the port for debugger to listen.
@returns {Promise}