-
Notifications
You must be signed in to change notification settings - Fork 7
/
CertificateList.js
64 lines (52 loc) · 2.13 KB
/
CertificateList.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
/**
* This is an example implementation of the sdk for AdonisJS (https://adonisjs.com/)
*/
"use strict";
const DomainRobot = require("@internetx/js-domainrobot-sdk").DomainRobot
const DomainRobotModels = require("@internetx/js-domainrobot-sdk").DomainRobotModels
const Logger = use("Logger")
class CertificateList {
async sdk({ request, response, params }) {
// Create a new Instance of the Domainrobot SDK
// and provide your (AutoDNS) Authentication Data
// The Option auth.context is optional for non personal
// AutoDNS Users but mandatory for personal ones
let domainRobot = new DomainRobot({
url: "https://api.demo.autodns.com/v1",
auth: {
user: "user",
password: "password",
context: "4"
}
});
// Create an Instance of the Query Object
// and define the Search Filters
// All possible Query Operators are listed at the following Page:
// https://help.internetx.com/pages/viewpage.action?pageId=14881040
let query = new DomainRobotModels.Query({
'filters': [{
"key": "name",
"value": "%domain%",
"operator": "LIKE"
}],
'view': new DomainRobotModels.QueryView({
'children': true,
'limit': '10'
})
});
// Send an Request and react to Success or Error Results
try {
// If the Request is Successful the returned Object
// will be of the Type DomainRobotResult
// Query the Certificate List
const domainRobotResult = await domainRobot.certificate().list(query)
Logger.transport("file").info("Request success", domainRobotResult)
return domainRobotResult
} catch (DomainRobotException) {
// If the Request produces an Error the returned Object
// will be of the Type DomainRobotException
Logger.transport("file").error("Request error", DomainRobotException)
}
}
}
module.exports = CertificateList