feat(api): rename <namespace> param to id
(#305)
This commit is contained in:
parent
f570492a11
commit
8c0ae892f5
14
src/api.js
14
src/api.js
@ -272,6 +272,20 @@ export default class Api {
|
||||
|
||||
try {
|
||||
await checkPermission.call(context, method)
|
||||
|
||||
// API methods are in a namespace.
|
||||
// Some methods use the namespace or an id parameter like:
|
||||
//
|
||||
// vm.detachPci vm=<string>
|
||||
// vm.ejectCd id=<string>
|
||||
//
|
||||
// The goal here is to standardize the calls by always providing
|
||||
// an id parameter when possible to simplify calls to the API.
|
||||
if (params && params.id === undefined) {
|
||||
const namespace = name.slice(0, name.indexOf('.'))
|
||||
params.id = params[namespace]
|
||||
}
|
||||
|
||||
checkParams(method, params)
|
||||
|
||||
const resolvedParams = await resolveParams.call(context, method, params)
|
||||
|
@ -688,14 +688,14 @@ rollingDeltaBackup = $coroutine ({vm, remote, tag, depth}) ->
|
||||
})
|
||||
|
||||
rollingDeltaBackup.params = {
|
||||
vm: { type: 'string' }
|
||||
id: { type: 'string' }
|
||||
remote: { type: 'string' }
|
||||
tag: { type: 'string'}
|
||||
depth: { type: ['string', 'number'] }
|
||||
}
|
||||
|
||||
rollingDeltaBackup.resolve = {
|
||||
vm: ['vm', ['VM', 'VM-snapshot'], 'administrate']
|
||||
vm: ['id', ['VM', 'VM-snapshot'], 'administrate']
|
||||
}
|
||||
|
||||
rollingDeltaBackup.permission = 'admin'
|
||||
@ -726,12 +726,12 @@ exports.importDeltaBackup = importDeltaBackup
|
||||
deltaCopy = ({ vm, sr }) -> @deltaCopyVm(vm, sr)
|
||||
|
||||
deltaCopy.params = {
|
||||
vm: { type: 'string' },
|
||||
id: { type: 'string' },
|
||||
sr: { type: 'string' }
|
||||
}
|
||||
|
||||
deltaCopy.resolve = {
|
||||
vm: [ 'vm', 'VM', 'operate'],
|
||||
vm: [ 'id', 'VM', 'operate'],
|
||||
sr: [ 'sr', 'SR', 'operate']
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user