<commit_before>var request = require('request');
var helper = require('./helper-functions.js');

exports.npmInstallRevision = function (apigee_profiles, revision, callback, includeCurl) {
	var apigeel = apigee_profiles[apigee_profiles.env];

	var options = {
		method: 'POST',
		uri: apigeel.url_mgmt + '/v1/o/' + apigeel.org + '/apis/' + apigeel.apiproxy + '/revisions/' + revision + '/npm',
		auth: {
			user: apigeel.username,
			password: <PASSWORD>
		},
		headers : {
			'Content-Type' : 'application/x-www-form-urlencoded',
		},
		body:'command=install'
	};
	if(includeCurl)
		helper.generatecURL(options);

	request(options, callback);
};
<commit_msg>Adding support for shared flows fixes #5<commit_after>var request = require('request');
var helper = require('./helper-functions.js');

exports.npmInstallRevision = function (apigee_profiles, revision, callback, includeCurl) {
	var apigeel = apigee_profiles[apigee_profiles.env];

	var options = {
		method: 'POST',
		uri: apigeel.url_mgmt + '/v1/o/' + apigeel.org + '/apis/' + apigeel.apiproxy + '/revisions/' + revision + '/npm',
		auth: {
			user: apigeel.username,
			password: <PASSWORD>
		},
		headers : {
			'Content-Type' : 'application/x-www-form-urlencoded',
		},
		body:'command=install'
	};
	if(includeCurl)
		helper.generatecURL(options);

	request(options, callback);
};

exports.getDeployedSharedFlowRevisions = function (apigee_profiles, callback, includeCurl) {
	var apigeel = apigee_profiles[apigee_profiles.env];
	//echo curl -H "Authorization:Basic $credentials" "$url/v1/organizations/$org/apis/$application/revisions/$RevToUndeploy/deployments" -X GET
	var options = {
		method: 'GET',
		uri: apigeel.url_mgmt + '/v1/o/' + apigeel.org + '/environments/' + apigeel.env + '/sharedflows/' + apigeel.apiproxy + '/deployments',
		auth: {
			user: apigeel.username,
			password: <PASSWORD>
		}
	};
	if(includeCurl)
		helper.generatecURL(options);
	request(options, callback);
};

exports.getSharedFlows = function(apigee_profiles, callback, includeCurl){
	var apigeel = apigee_profiles[apigee_profiles.env];
	var options = {
      uri : apigeel.url_mgmt + '/v1/organizations/' + apigeel.org + "/sharedflows",
      method : 'GET',
      auth : {user : apigeel.username, password: <PASSWORD>}
    };
	if(includeCurl)
		helper.generatecURL(options);
    request(options, callback);
}

exports.deploySharedFlow = function(apigee_profiles, revision, callback, includeCurl){
	var apigeel = apigee_profiles[apigee_profiles.env];
	var options = {
		method: 'POST',
		uri: apigeel.url_mgmt + '/v1/organizations/' + apigeel.org + '/environments/' + apigeel.env + '/sharedflows/' + apigeel.apiproxy + '/revisions/' + revision + '/deployments' + (apigeel.override ? '?override=true' : '') + ((apigeel.override && apigeel.delay != 0) ? '&delay=' + apigeel.delay : ''),
		auth: {
			user: apigeel.username,
			password: <PASSWORD>
		},
		headers : {
			'Content-Type' : 'application/x-www-form-urlencoded',
		},
	};
	if(includeCurl)
		helper.generatecURL(options);
    request(options, callback);
}

exports.importSharedFlowBundle = function(apigee_profiles, callback, includeCurl){
		var apigeel = apigee_profiles[apigee_profiles.env];
		var fs = require('fs');
		var rs = fs.createReadStream('target/' + apigeel.apiproxy + '.zip');
		var options = {
			method: 'POST',
			uri: apigeel.url_mgmt + '/v1/organizations/' + apigeel.org + '/sharedflows?action=import&name=' + apigeel.apiproxy,
			auth: {
				user: apigeel.username,
				password: <PASSWORD>
			},
			headers : {
				'Content-Type' : 'application/octet-stream',
			},
			strictSSL: false
		};
		//if(includeCurl)
			helper.generatecURL(options);
		rs.pipe(request(options, callback));
}

{'fraction_non_alphanumeric': 0.15956873315363881, 'fraction_numerical': 0.002425876010781671, 'mean_word_length': 4.331896551724138, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 3, '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': '5364963', 'n_tokens_mistral': 1432, 'n_tokens_neox': 1322, 'n_words': 232}