more dns stuff
This commit is contained in:
parent
bbd75d63eb
commit
b2a992d2d5
48
dns.examples.js
Normal file
48
dns.examples.js
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
oauth3.api('devices.list').then(function (result) {
|
||||||
|
console.log(result);
|
||||||
|
});
|
||||||
|
|
||||||
|
oauth3.api(
|
||||||
|
'devices.set'
|
||||||
|
, { data: {
|
||||||
|
name: 'tester.local'
|
||||||
|
, uid: 'test-01-uid'
|
||||||
|
, addresses: [
|
||||||
|
{
|
||||||
|
type: 'A'
|
||||||
|
, address: '192.168.1.104'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
} }
|
||||||
|
).then(function (result) {
|
||||||
|
console.log('devices.set');
|
||||||
|
console.log(result);
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO don't allow attaching if the device is not set
|
||||||
|
// TODO update API as well
|
||||||
|
oauth3.api(
|
||||||
|
'devices.attach'
|
||||||
|
, { data: {
|
||||||
|
sub: 'test-01'
|
||||||
|
, sld: 'aj'
|
||||||
|
, tld: 'daplie.me'
|
||||||
|
, uid: 'test-01-uid'
|
||||||
|
} }
|
||||||
|
).then(function (result) {
|
||||||
|
console.log('devices.attach');
|
||||||
|
console.log(result);
|
||||||
|
});
|
||||||
|
|
||||||
|
oauth3.api(
|
||||||
|
'devices.detach'
|
||||||
|
, { data: {
|
||||||
|
sub: 'test-01'
|
||||||
|
, sld: 'aj'
|
||||||
|
, tld: 'daplie.me'
|
||||||
|
, uid: 'test-01-uid'
|
||||||
|
} }
|
||||||
|
).then(function (result) {
|
||||||
|
console.log('devices.detach');
|
||||||
|
console.log(result);
|
||||||
|
});
|
@ -29,6 +29,38 @@ OAUTH3.api['devices.list'] = function (providerUri, opts) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
OAUTH3.api['devices.attach'] = function (providerUri, opts) {
|
||||||
|
var session = opts.session;
|
||||||
|
|
||||||
|
return OAUTH3.request({
|
||||||
|
url: OAUTH3.url.normalize(providerUri)
|
||||||
|
+ '/api/com.daplie.domains/accounts/' + session.token.sub
|
||||||
|
//+ '/devices/' + device + '/'
|
||||||
|
+ '/devices/' + (opts.data.uid || '_') + '/' + opts.data.device
|
||||||
|
+ '/' + opts.data.tld + '/' + opts.data.sld + '/' + (opts.data.sub || '')
|
||||||
|
, method: 'POST'
|
||||||
|
, session: session
|
||||||
|
}, {}).then(function (res) {
|
||||||
|
return res.data.devices || res.data;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
OAUTH3.api['devices.detach'] = function (providerUri, opts) {
|
||||||
|
var session = opts.session;
|
||||||
|
|
||||||
|
return OAUTH3.request({
|
||||||
|
url: OAUTH3.url.normalize(providerUri)
|
||||||
|
+ '/api/com.daplie.domains/accounts/' + session.token.sub
|
||||||
|
//+ '/devices/' + device + '/'
|
||||||
|
+ '/devices/' + (opts.data.uid || '_') + '/' + opts.data.device
|
||||||
|
+ '/' + opts.data.tld + '/' + opts.data.sld + '/' + (opts.data.sub || '')
|
||||||
|
, method: 'DELETE'
|
||||||
|
, session: session
|
||||||
|
}, {}).then(function (res) {
|
||||||
|
return res.data.devices || res.data;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
OAUTH3.api['devices.detach'] = function (providerUri, opts) {
|
OAUTH3.api['devices.detach'] = function (providerUri, opts) {
|
||||||
var session = opts.session;
|
var session = opts.session;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user