Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
*/
'use strict';
var common = require('azure-common');
var ApiAppManagementClient = require('./apiAppManagementClient');
var getDeploymentTemplate = require('./getDeploymentTemplate');
exports.ApiAppManagementClient = ApiAppManagementClient.ApiAppManagementClient;
//
// New up a dummy client so we can get at the TemplateOperations
// prototype and attach our custom method to it.
//
var dummyClient = new exports.ApiAppManagementClient(
new common.TokenCloudCredentials({subscriptionId: '0', token: '0'}),
'https://dummy.example');
getDeploymentTemplate.attachGetDeploymentTemplate(dummyClient);
/**
* Create a new {@link ApiAppManagementClient} object.
*
* @param {object} credentials The credentials object (typically, a TokenCloudCredentials instance).
* @param {string} [baseUri] Optional base uri, defaults to production Azure
* @param {array} [filters] Optional array of service filters
* @return {ApiAppManagementClient} A new ApiAppManagementClient object.
*/
exports.createApiAppManagementClient = function (credentials, baseUri, filters)
{
return new exports.ApiAppManagementClient(credentials, baseUri, filters);
};
var getCloudCredential = function(subscription){
var cred;
if(subscription.credential.type === 'cert'){
cred = computeMgmt.createCertificateCloudCredentials({
subscriptionId:subscription.id ,
cert:subscription.managementCertificate.cert,
key:subscription.managementCertificate.key,
});
}else{//if(subscription.credential.type === 'token'){
cred = new common.TokenCloudCredentials({
subscriptionId : subscription.id,
token : subscription.credential.token
});
}
return cred;
}
var getCloudCredential = function(subscription){
var cred;
if(subscription.credential.type === 'cert'){
cred = computeMgmt.createCertificateCloudCredentials({
subscriptionId:subscription.id ,
cert:subscription.managementCertificate.cert,
key:subscription.managementCertificate.key,
});
}else{//if(subscription.credential.type === 'token'){
cred = new common.TokenCloudCredentials({
subscriptionId : subscription.id,
token : subscription.credential.token
});
}
return cred;
}
function (err, result) {
if (err) throw err;
obj.credentials = new azureCommon.TokenCloudCredentials({
subscriptionId: obj.subscriptionId,
authorizationScheme: result.tokenType,
token: result.accessToken
});
next();
});
}