<commit_before>var request = require('request');

api = function(key){
	key = key || require('./secrets.js').doAPI;
	this.BASEURL = 'https://api.digitalocean.com/v2/';
	this.headers = {
		'Content-Type': 'application/json',
		'Authorization': 'Bearer '+key
	}
	this.calls = 0;

	this.account = function(callback){
		var options = {
			url: this.BASEURL+'account',
			headers: this.headers
		};
		this.calls++;

		return request.get(options, function(error, response, body){
			return callback(body, response, error);
		});
	};

	this.dropletsByTag = function(tag, callback){
		var options = {
			url: this.BASEURL+'droplets?tag_name='+tag,
			headers: this.headers
		};
		this.calls++;
		
		return request.get(options, function(error, response, body){
			return callback(body, response, error);
		});
	};

	this.dropletSetTag = function(tag, dropletID, callback) {
		callback = callback || function(){};
		var data = {
			resources: [
				{
					resource_id: dropletID,
					resource_type: 'droplet'
				}
			]
		};
		var options = {
			url: this.BASEURL+'tags/'+tag+'/resources',
			headers: this.headers,
			body: JSON.stringify(data)
		};
		this.calls++;

		return request.post(options, function(error, response, body){
			return callback(body, response, error);
		});
	};
	
	this.dropletCreate = function(args, callback){
		callback = callback || function(){};<commit_msg>Updating droplet tagging code to cast the droplet id to a string (digital ocean gives the droplet id as a number, but their tagging endpoint would like the resource_id to be a string).<commit_after>var request = require('request');

api = function(key){
	key = key || require('./secrets.js').doAPI;
	this.BASEURL = 'https://api.digitalocean.com/v2/';
	this.headers = {
		'Content-Type': 'application/json',
		'Authorization': 'Bearer '+key
	}
	this.calls = 0;

	this.account = function(callback){
		var options = {
			url: this.BASEURL+'account',
			headers: this.headers
		};
		this.calls++;

		return request.get(options, function(error, response, body){
			return callback(body, response, error);
		});
	};

	this.dropletsByTag = function(tag, callback){
		var options = {
			url: this.BASEURL+'droplets?tag_name='+tag,
			headers: this.headers
		};
		this.calls++;
		
		return request.get(options, function(error, response, body){
			return callback(body, response, error);
		});
	};

	this.dropletSetTag = function(tag, dropletID, callback) {
		callback = callback || function(){};
		var data = {
			resources: [
				{
					resource_id: ""+dropletID,
					resource_type: 'droplet'
				}
			]
		};
		var options = {
			url: this.BASEURL+'tags/'+tag+'/resources',
			headers: this.headers,
			body: JSON.stringify(data)
		};
		this.calls++;

		return request.post(options, function(error, response, body){
			return callback(body, response, error);
		});
	};
	
	this.dropletCreate = function(args, callback){
		callback = callback || function(){};
{'fraction_non_alphanumeric': 0.1582365003417635, 'fraction_numerical': 0.001367053998632946, 'mean_word_length': 3.846026490066225, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '5717736', 'n_tokens_mistral': 1093, 'n_tokens_neox': 947, 'n_words': 217}