forked from moul/node-gitlab
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProjectVariables.js
More file actions
107 lines (94 loc) · 3.23 KB
/
Copy pathProjectVariables.js
File metadata and controls
107 lines (94 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
(function() {
var BaseModel, ProjectVariables, Utils,
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
BaseModel = require('../BaseModel');
Utils = require('../Utils');
ProjectVariables = (function(superClass) {
var list;
extend(ProjectVariables, superClass);
function ProjectVariables() {
this.create = bind(this.create, this);
this.show = bind(this.show, this);
this.all = bind(this.all, this);
return ProjectVariables.__super__.constructor.apply(this, arguments);
}
list = function(projectId, fn) {
if (fn == null) {
fn = null;
}
console.log('DEPRECATED: variables.list. Use variables.all instead');
return this.all.apply(this, arguments);
};
ProjectVariables.prototype.all = function(projectId, fn) {
var cb, data, params;
if (fn == null) {
fn = null;
}
this.debug("Projects::Variables::all()");
params = {};
if (params.page == null) {
params.page = 1;
}
if (params.per_page == null) {
params.per_page = 100;
}
data = [];
cb = (function(_this) {
return function(err, retData) {
if (err) {
if (fn) {
return fn(retData || data);
}
} else if (retData.length === params.per_page) {
_this.debug("Recurse Projects::Variables::all()");
data = data.concat(retData);
params.page++;
return _this.get("projects/" + (Utils.parseProjectId(projectId)) + "/variables", params, cb);
} else {
data = data.concat(retData);
if (fn) {
return fn(data);
}
}
};
})(this);
return this.get("projects/" + (Utils.parseProjectId(projectId)) + "/variables", params, cb);
};
ProjectVariables.prototype.show = function(projectId, variableId, fn) {
if (fn == null) {
fn = null;
}
this.debug("Projects::Variables::show()");
return this.get("projects/" + (Utils.parseProjectId(projectId)) + "/variables/" + (parseInt(variableId)), (function(_this) {
return function(data) {
if (fn) {
return fn(data);
}
};
})(this));
};
ProjectVariables.prototype.create = function(projectId, key, value, fn) {
var params;
if (fn == null) {
fn = null;
}
params = {};
params.key = key;
params.value = value;
this.debug("Projects::Variables::create()", params);
return this.post("projects/" + (Utils.parseProjectId(projectId)) + "/variables", params, (function(_this) {
return function(data) {
if (fn) {
return fn(data);
}
};
})(this));
};
return ProjectVariables;
})(BaseModel);
module.exports = function(client) {
return new ProjectVariables(client);
};
}).call(this);