Files
cloudron-box/src/dns/interface.js
T

87 lines
2.8 KiB
JavaScript
Raw Normal View History

2016-09-15 12:17:17 +02:00
'use strict';
// -------------------------------------------
// This file just describes the interface
//
// New backends can start from here
// -------------------------------------------
exports = module.exports = {
removePrivateFields: removePrivateFields,
injectPrivateFields: injectPrivateFields,
2016-09-15 12:17:17 +02:00
upsert: upsert,
get: get,
del: del,
2019-01-04 18:44:54 -08:00
wait: wait,
verifyDnsConfig: verifyDnsConfig
2016-09-15 12:17:17 +02:00
};
var assert = require('assert'),
2019-12-04 10:21:42 -08:00
BoxError = require('../boxerror.js'),
2016-09-15 12:17:17 +02:00
util = require('util');
function removePrivateFields(domainObject) {
2020-05-14 23:01:44 +02:00
// in-place removal of tokens and api keys with constants.SECRET_PLACEHOLDER
return domainObject;
}
2019-12-04 10:21:42 -08:00
// eslint-disable-next-line no-unused-vars
function injectPrivateFields(newConfig, currentConfig) {
2020-05-14 23:01:44 +02:00
// in-place injection of tokens and api keys which came in with constants.SECRET_PLACEHOLDER
}
2019-01-04 18:44:54 -08:00
function upsert(domainObject, location, type, values, callback) {
assert.strictEqual(typeof domainObject, 'object');
assert.strictEqual(typeof location, 'string');
2016-09-15 12:17:17 +02:00
assert.strictEqual(typeof type, 'string');
assert(util.isArray(values));
assert.strictEqual(typeof callback, 'function');
2018-06-29 22:25:34 +02:00
// Result: none
2016-09-15 12:17:17 +02:00
2019-12-04 10:29:06 -08:00
callback(new BoxError(BoxError.NOT_IMPLEMENTED, 'upsert is not implemented'));
2016-09-15 12:17:17 +02:00
}
2019-01-04 18:44:54 -08:00
function get(domainObject, location, type, callback) {
assert.strictEqual(typeof domainObject, 'object');
assert.strictEqual(typeof location, 'string');
2016-09-15 12:17:17 +02:00
assert.strictEqual(typeof type, 'string');
assert.strictEqual(typeof callback, 'function');
// Result: Array of matching DNS records in string format
2019-12-04 10:29:06 -08:00
callback(new BoxError(BoxError.NOT_IMPLEMENTED, 'get is not implemented'));
2016-09-15 12:17:17 +02:00
}
2019-01-04 18:44:54 -08:00
function del(domainObject, location, type, values, callback) {
assert.strictEqual(typeof domainObject, 'object');
assert.strictEqual(typeof location, 'string');
2016-09-15 12:17:17 +02:00
assert.strictEqual(typeof type, 'string');
assert(util.isArray(values));
assert.strictEqual(typeof callback, 'function');
// Result: none
2019-12-04 10:29:06 -08:00
callback(new BoxError(BoxError.NOT_IMPLEMENTED, 'del is not implemented'));
2016-09-15 12:17:17 +02:00
}
2019-01-04 18:44:54 -08:00
function wait(domainObject, location, type, value, options, callback) {
assert.strictEqual(typeof domainObject, 'object');
assert.strictEqual(typeof location, 'string');
assert.strictEqual(typeof type, 'string');
assert.strictEqual(typeof value, 'string');
assert(options && typeof options === 'object'); // { interval: 5000, times: 50000 }
assert.strictEqual(typeof callback, 'function');
callback();
}
function verifyDnsConfig(domainObject, callback) {
assert.strictEqual(typeof domainObject, 'object');
assert.strictEqual(typeof callback, 'function');
// Result: dnsConfig object
2019-12-04 10:21:42 -08:00
callback(new BoxError(BoxError.NOT_IMPLEMENTED, 'verifyDnsConfig is not implemented'));
}