<commit_before>/*
 * loadbalancer.js: Rackspace Cloud LoadBalancer LoadBalancer
 *
 * (C) 2013 Rackspace
 *      <NAME>
 * MIT LICENSE
 *
 */

var utile = require('utile'),
    base = require('../../core/loadbalancer/loadbalancer'),
    _ = require('underscore');

var LoadBalancer = exports.LoadBalancer = function LoadBalancer(client, details) {
  base.LoadBalancer.call(this, client, details);
};

utile.inherits(LoadBalancer, base.LoadBalancer);

LoadBalancer.prototype._setProperties = function (details) {
  var self = this;

  self.id = details.id;
  self.name = details.name;
  self.protocol = details.protocol;
  self.port = details.port;
  self.algorithm = details.algorithm;
  self.cluster = details.cluster;
  self.status = details.status;
  self.timeout = details.timeout;
  self.halfClosed = details.halfClosed;
  self.nodes = details.nodes || [];
  self.virtualIps = details.virtualIps || [];
  self.sourceAddresses = details.sourceAddresses;
  self.httpsRedirect = details.httpsRedirect;
  self.connectionLogging = details.connectionLogging;
  self.contentCaching = details.contentCaching;
  self.nodeCount = details.nodeCount || (details.nodes ? details.nodes.length : 0);
  self.created = details.created;
  self.updated = details.updated;
};

/// Nodes

LoadBalancer.prototype.getNodes = function(callback) {
  this.client.getNodes(this, callback);
};

LoadBalancer.prototype.addNode = function(node, callback) {
  this.client.addNodes(this, [ node ], callback);
};

LoadBalancer.prototype.addNodes = function(nodes, callback) {
  this.client.addNodes(this, nodes, callback);
};

LoadBalancer.prototype.updateNode = function(node, callback) {
  this.client.updateNode(this, node, callback);
};

LoadBalancer.prototype.removeNode = function (node, callback) {
  this.client.removeNode(this, node, callback);
};<commit_msg>Adding refresh method for cloud load balancer<commit_after>/*
 * loadbalancer.js: Rackspace Cloud LoadBalancer LoadBalancer
 *
 * (C) 2013 Rackspace
 *      <NAME>
 * MIT LICENSE
 *
 */

var utile = require('utile'),
    base = require('../../core/loadbalancer/loadbalancer'),
    _ = require('underscore');

var LoadBalancer = exports.LoadBalancer = function LoadBalancer(client, details) {
  base.LoadBalancer.call(this, client, details);
};

utile.inherits(LoadBalancer, base.LoadBalancer);

LoadBalancer.prototype._setProperties = function (details) {
  var self = this;

  self.id = details.id;
  self.name = details.name;
  self.protocol = details.protocol;
  self.port = details.port;
  self.algorithm = details.algorithm;
  self.cluster = details.cluster;
  self.status = details.status;
  self.timeout = details.timeout;
  self.halfClosed = details.halfClosed;
  self.nodes = details.nodes || [];
  self.virtualIps = details.virtualIps || [];
  self.sourceAddresses = details.sourceAddresses;
  self.httpsRedirect = details.httpsRedirect;
  self.connectionLogging = details.connectionLogging;
  self.contentCaching = details.contentCaching;
  self.nodeCount = details.nodeCount || (details.nodes ? details.nodes.length : 0);
  self.created = details.created;
  self.updated = details.updated;
};

/// Nodes

LoadBalancer.prototype.refresh = function(callback) {
  var self = this;
  return self.client.getLoadBalancer(this, function (err, server) {
    if (err) {
      callback(err);
      return;
    }

    self._setProperties(server);
    callback(err, self);
  });
};

LoadBalancer.prototype.getNodes = function(callback) {
  this.client.getNodes(this, callback);
};

LoadBalancer.prototype.addNode = function(node, callback) {
  this.client.addNodes(this, [ node ], callback);
};

LoadBalancer.prototype.addNodes = function(nodes, callback) {
  this.client.addNodes(this, nodes, callback);
};

LoadBalancer.prototype.updateNode = function(node, callback) {
  this.client.updateNode(this, node, callback);
};

LoadBalancer.prototype.removeNode = function (node, callback) {
  this.client.removeNode(this, node, callback);
};
{'fraction_non_alphanumeric': 0.13448969331322272, 'fraction_numerical': 0.002513826043237808, 'mean_word_length': 4.488275862068965, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '929931', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1226, 'n_words': 231}