UNPKG

digitalocean

Version:
223 lines (184 loc) 8.92 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Source: digitalocean/load_balancer.js</title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <div id="main"> <h1 class="page-title">Source: digitalocean/load_balancer.js</h1> <section> <article> <pre class="prettyprint source linenums"><code>(function() { var slice = [].slice, util = require('./util'); /** * LoadBalancer resource * @class LoadBalancer */ var LoadBalancer = (function() { function LoadBalancer(client) { this.client = client; } /** * List load balancer objects. * * @param {(number|object)} [page or queryObject] - page number to retrieve or key value pairs of query parameters * @param {number} [perPage] - number of result per page to retrieve * @param {listRequestCallback} [callback] - callback that handles the response * @memberof LoadBalancer */ LoadBalancer.prototype.list = function() { var args = util.extractListArguments(arguments, 0); return this.client.get.apply(this.client, ['/load_balancers', {}].concat(slice.call(args.params), [200, 'load_balancers', args.callback])); }; /** * Create a load balancer object. * * @param {object} attributes - The attributes with which to create the load balancer. See the {@link https://developers.digitalocean.com/documentation/v2/#load_balancers|official docs} for valid attributes. * @param {requestCallback} [callback] - callback that handles the response * @memberof LoadBalancer */ LoadBalancer.prototype.create = function(attributes, callback) { return this.client.post('/load_balancers', attributes, 202, 'load_balancer', callback); }; /** * Update a load balancer object. * * @param {string} id - The id of the load balancer to retrieve * @param {object} attributes - The attributes with which to update the load balancer. See the {@link https://developers.digitalocean.com/documentation/v2/#load_balancers|official docs} for valid attributes. * @param {requestCallback} [callback] - callback that handles the response * @memberof LoadBalancer */ LoadBalancer.prototype.update = function(id, attributes, callback) { var url = util.safeUrl('load_balancers', id); return this.client.put(url, attributes, 200, 'load_balancer', callback); }; /** * Get the identified load balancer object. * * @param {string} id - The id of the load balancer to retrieve * @param {requestCallback} [callback] - callback that handles the response * @memberof LoadBalancer */ LoadBalancer.prototype.get = function(id, callback) { var url = util.safeUrl('load_balancers', id); return this.client.get(url, {}, 200, 'load_balancer', callback); }; /** * Delete the identified load balancer object. * * @param {string} id - The id of the load balancer to delete * @param {requestCallback} [callback] - callback that handles the response * @memberof LoadBalancer */ LoadBalancer.prototype.delete = function(id, callback) { var url = util.safeUrl('load_balancers', id); return this.client.delete(url, {}, 204, [], callback); }; /** * Create a forwarding rule object in a load balancer. * * @param {string} loadBalancerId - The id of the load balancer for which to add a resource * @param {array|object} parametersOrIds - Array of ids of objects to add to the load balancer. Otherwise, an object with required key of `droplet_ids`. See the {@link https://developers.digitalocean.com/documentation/v2/#|official docs} for valid attributes. * @param {requestCallback} [callback] - callback that handles the response * @memberof LoadBalancer */ LoadBalancer.prototype.add = function(loadBalancerId, parametersOrIds, callback) { var parameters; if(parametersOrIds.length) { parameters = { droplet_ids: parametersOrIds }; } else { parameters = parametersOrIds; } var url = util.safeUrl('load_balancers', loadBalancerId, 'droplets'); return this.client.post(url, parameters, 204, [], callback); }; /** * Remove the specified IDs from the load balancer. * * @param {string} loadBalancerId - The name of the load balancer for which to remove a resource * @param {array|object} parametersOrIds - Array of ids of objects to add to the load balancer. Otherwise, an object with required key of `droplet_ids`. See the {@link https://developers.digitalocean.com/documentation/v2/#|official docs} for valid attributes. * @param {requestCallback} [callback] - callback that handles the response * @memberof LoadBalancer */ LoadBalancer.prototype.remove = function(loadBalancerId, parametersOrIds, callback) { var parameters; if(parametersOrIds.length) { parameters = { droplet_ids: parametersOrIds }; } else { parameters = parametersOrIds; } var url = util.safeUrl('load_balancers', loadBalancerId, 'droplets'); return this.client.delete(url, parameters, 204, [], callback); }; /** * Create a forwarding rule object in a load balancer. * * @param {string} loadBalancerId - The name of the load balancer for which to create a record * @param {array|object} parametersOrRules - Array of rules to create on the load balancer. Otherwise, an object with required key of `forwarding_rules`. See the https://developers.digitalocean.com/documentation/v2/#load-balancers|official docs} for valid attributes. * @param {requestCallback} [callback] - callback that handles the response * @memberof LoadBalancer */ LoadBalancer.prototype.createForwardingRules = function(loadBalancerId, parametersOrRules, callback) { var parameters; if(parametersOrRules.length) { parameters = { forwarding_rules: parametersOrRules }; } else { parameters = parametersOrRules; } var url = util.safeUrl('load_balancers', loadBalancerId, 'forwarding_rules'); return this.client.post(url, parameters, 204, [], callback); }; /** * Delete the identified load balancer forwarding rule object. * * @param {string} loadBalancerId - The name of the load balancer for which to delete a record * @param {array|object} parametersOrRules - Array of rules on the load balancer to delete. Otherwise, an object with required key of `forwarding_rules`. See the https://developers.digitalocean.com/documentation/v2/#load-balancers|official docs} for valid attributes. * @param {requestCallback} [callback] - callback that handles the response * @memberof LoadBalancer */ LoadBalancer.prototype.deleteForwardingRules = function(loadBalancerId, parametersOrRules, callback) { var parameters; if(parametersOrRules.length) { parameters = { forwarding_rules: parametersOrRules }; } else { parameters = parametersOrRules; } var url = util.safeUrl('load_balancers', loadBalancerId, 'forwarding_rules'); return this.client.delete(url, parameters, 204, [], callback); }; return LoadBalancer; })(); module.exports = LoadBalancer; }).call(this); </code></pre> </article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Account.html">Account</a></li><li><a href="Action.html">Action</a></li><li><a href="Certificate.html">Certificate</a></li><li><a href="Client.html">Client</a></li><li><a href="Domain.html">Domain</a></li><li><a href="Droplet.html">Droplet</a></li><li><a href="Firewall.html">Firewall</a></li><li><a href="FloatingIp.html">FloatingIp</a></li><li><a href="Image.html">Image</a></li><li><a href="ListResponse.html">ListResponse</a></li><li><a href="LoadBalancer.html">LoadBalancer</a></li><li><a href="Region.html">Region</a></li><li><a href="Size.html">Size</a></li><li><a href="Snapshot.html">Snapshot</a></li><li><a href="Tag.html">Tag</a></li><li><a href="Volume.html">Volume</a></li></ul><h3><a href="global.html">Global</a></h3> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>