This repository was archived by the owner on Feb 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.js
More file actions
69 lines (55 loc) · 1.43 KB
/
index.js
File metadata and controls
69 lines (55 loc) · 1.43 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
"use strict";
const common = require("@google-cloud/common");
const extend = require("extend");
const util = require("util");
function Builder(options) {
if (!(this instanceof Builder)) {
options = common.util.normalizeArguments(this, options);
return new Builder(options);
}
const config = {
baseUrl: "https://cloudbuild.googleapis.com/v1",
scopes: ["https://www.googleapis.com/auth/cloud-platform"],
packageJson: require("./package.json")
};
common.Service.call(this, config, options);
}
util.inherits(Builder, common.Service);
Builder.prototype.runTrigger = function(options, callback) {
const self = this;
if (!options) {
throw new Error('Missing options object');
}
if (!options.triggerId) {
throw new Error('You must contain a triggerId');
}
const body = extend({}, options.requestBody);
this.request(
{
method: "POST",
uri: `/triggers/${options.triggerId}:run`,
json: body
},
function(err, resp) {
if (err) {
callback(err, resp);
return;
}
callback(null, resp);
}
);
};
/*! Developer Documentation
*
* These methods can be auto-paginated.
*/
common.paginator.extend(Builder, "getBuilds");
/*! Developer Documentation
*
* All async methods (except for streams) will return a Promise in the event
* that a callback is omitted.
*/
common.util.promisifyAll(Builder, {
exclude: ["bucket"]
});
module.exports = Builder;