text: module.exports = function (RED) {
    function DockerStartStop (config) {
      const node = this;
      const docker = RED.nodes.getNode(config.docker);
      const operation = config.operation;
  
      RED.nodes.createNode(this, config);
  
      node.on('input', function (msg, send, done) {
        const path = `/containers/${msg.payload.container}/${operation}`;
        
        const request = require(docker.protocol).request({
          hostname: docker.hostname,
          port: docker.port,
          path: path,
          method: 'POST'
        }, function (response) {
          response.setEncoding('utf8');
  
          response.on('error', node.error);
  
          response.on('data',  function noop () {});
  
          response.on('end', function () {
            const success = response.complete && (response.statusCode === 204);
            
            if (success) {
              const payload = msg.payload = msg.payload || {};
              payload.time = new Date();
  
              send(msg);
              done();
            } else {
              node.error(`${path} [${response.statusCode}]`);
            }
          });
        });
  
        request.end();
      });
    }
    
    RED.nodes.registerType('start-stop-container', DockerStartStop);
  }