-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapi-script.js
70 lines (55 loc) · 2.05 KB
/
api-script.js
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
require('dotenv').load();
var AWS = require('aws-sdk');
var apigateway = new AWS.APIGateway({apiVersion: '2015-07-09'});
var lambda = new AWS.Lambda({apiVersion: '2015-03-31'});
//get the API
var params = {
restApiId: 'dquw9oidca' /* required */
};
apigateway.getRestApi(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
//get the resource
var params = {
restApiId: 'dquw9oidca', /* required */
};
apigateway.getResources(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log("RESOUCRES: ", data.items[0].id); // successful response
});
//get method
var params = {
httpMethod: 'POST', /* required */
resourceId: 'd34ey94tal', /* required */
restApiId: 'dquw9oidca' /* required */
};
apigateway.getMethod(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log("METHOD: ", data); // successful response
});
//get integration
var params = {
httpMethod: 'POST', /* required */
resourceId: 'd34ey94tal', /* required */
restApiId: 'dquw9oidca' /* required */
};
apigateway.getIntegration(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log("INTEGRATION: ", data); // successful response
});
//get deployment
var params = {
restApiId: 'dquw9oidca', /* required */
};
apigateway.getDeployments(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log("DEPLOYMENT: ", data); // successful response
});
var params = {
FunctionName: 'arn:aws:lambda:us-east-1:519275522978:function:copyBucketFunction', /* required */
};
lambda.getFunction(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});