barracuda app status
This commit is contained in:
@@ -56,5 +56,20 @@ async function deleteApp(provision) {
|
||||
|
||||
}
|
||||
|
||||
async function getApp(provision) {
|
||||
|
||||
if ( !provision || !provision.barracudaAppId ) {
|
||||
console.log(`Barracuda# Provision does not exist or does not have a barracudaAppId value. Do nothing.`);
|
||||
return;
|
||||
}
|
||||
const client = new BarracudaAPI.QlikSenseNPrintingApp();
|
||||
var details = await client.get(provision.barracudaAppId);
|
||||
var status = await client.isProvisioned(provision.barracudaAppId);
|
||||
|
||||
return {"app": details, "status": status};
|
||||
|
||||
}
|
||||
|
||||
module.exports.getApp = getApp;
|
||||
module.exports.createAppQS = createAppQS;
|
||||
module.exports.deleteApp = deleteApp;
|
||||
4
qmi-cloud-common/package-lock.json
generated
4
qmi-cloud-common/package-lock.json
generated
@@ -249,8 +249,8 @@
|
||||
}
|
||||
},
|
||||
"barracuda-api": {
|
||||
"version": "git+https://gitlab.com/qlik_gear/barracuda-api-node.git#a4a15a6766f3c66196ed1854cc301575c218323f",
|
||||
"from": "git+https://gitlab.com/qlik_gear/barracuda-api-node.git#0.0.3",
|
||||
"version": "git+https://gitlab.com/qlik_gear/barracuda-api-node.git#2609dd6a55a11108e6fcb246cbf27450ce5608a6",
|
||||
"from": "git+https://gitlab.com/qlik_gear/barracuda-api-node.git#0.0.4",
|
||||
"requires": {
|
||||
"axios": "^0.21.1"
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"@azure/ms-rest-nodeauth": "^3.0.7",
|
||||
"@hapi/boom": "^9.1.0",
|
||||
"axios": "^0.21.1",
|
||||
"barracuda-api": "https://gitlab.com/qlik_gear/barracuda-api-node.git#0.0.3",
|
||||
"barracuda-api": "https://gitlab.com/qlik_gear/barracuda-api-node.git#0.0.4",
|
||||
"bull": "^3.11.0",
|
||||
"mongoose": "^5.7.4",
|
||||
"nodemailer": "^6.4.2"
|
||||
|
||||
@@ -198,9 +198,9 @@ axios@^0.21.1:
|
||||
dependencies:
|
||||
follow-redirects "^1.10.0"
|
||||
|
||||
"barracuda-api@https://gitlab.com/qlik_gear/barracuda-api-node.git#0.0.3":
|
||||
version "0.0.3"
|
||||
resolved "https://gitlab.com/qlik_gear/barracuda-api-node.git#a4a15a6766f3c66196ed1854cc301575c218323f"
|
||||
"barracuda-api@https://gitlab.com/qlik_gear/barracuda-api-node.git#0.0.4":
|
||||
version "0.0.4"
|
||||
resolved "https://gitlab.com/qlik_gear/barracuda-api-node.git#2609dd6a55a11108e6fcb246cbf27450ce5608a6"
|
||||
dependencies:
|
||||
axios "^0.21.1"
|
||||
|
||||
|
||||
@@ -228,6 +228,38 @@ router.post('/:userId/provisions', passport.ensureAuthenticatedAndIsMe, async (r
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /users/{userId}/provisions/{id}:
|
||||
* get:
|
||||
* description: Get provision details
|
||||
* summary: Get provision details
|
||||
* parameters:
|
||||
* - name: userId
|
||||
* in: path
|
||||
* type: string
|
||||
* required: true
|
||||
* - name: id
|
||||
* in: path
|
||||
* type: string
|
||||
* required: true
|
||||
* produces:
|
||||
* - application/json
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Provision
|
||||
*/
|
||||
router.get('/:userId/provisions/:id', passport.ensureAuthenticatedAndIsMe, async (req, res, next) => {
|
||||
|
||||
try {
|
||||
let provision = await db.provision.getById(req.params.id);
|
||||
return res.json(provision);
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /users/{userId}/provisions/{id}:
|
||||
@@ -353,6 +385,50 @@ router.delete('/:userId/provisions/:id', passport.ensureAuthenticatedAndIsMe, as
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /users/{userId}/provisions/{id}/barracuda:
|
||||
* get:
|
||||
* description: Barracuda - get details and provision status
|
||||
* summary: Barracuda - get details and provision status
|
||||
* produces:
|
||||
* - application/json
|
||||
* parameters:
|
||||
* - name: userId
|
||||
* in: path
|
||||
* type: string
|
||||
* required: true
|
||||
* - name: id
|
||||
* in: path
|
||||
* type: string
|
||||
* required: true
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Provision
|
||||
* 404:
|
||||
* description: Not found
|
||||
*
|
||||
*/
|
||||
router.get('/:userId/provisions/:id/barracuda', passport.ensureAuthenticatedAndIsMe, async (req, res, next) => {
|
||||
try {
|
||||
|
||||
let provision = await db.provision.getById(req.params.id);
|
||||
if (!provision){
|
||||
return res.status(404).json({"msg": "Not found provision with id "+req.params.id});
|
||||
}
|
||||
|
||||
if ( !provision.barracudaAppId ) {
|
||||
console.log(`APIUser# Provision (${req.params.id}) does not have a barracudaAppId value!`);
|
||||
return res.status(404).json({"msg": "Not found Barracuda App for this provision"});
|
||||
}
|
||||
|
||||
var app = await barracuda.getApp(provision);
|
||||
return res.json(app);
|
||||
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
|
||||
Reference in New Issue
Block a user