Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Rodrigues committed Mar 21, 2013
1 parent 7590d98 commit 5357746
Show file tree
Hide file tree
Showing 181 changed files with 28,487 additions and 3,621 deletions.
198 changes: 168 additions & 30 deletions lib/azure.js
@@ -1,5 +1,5 @@
/**
* Copyright 2011 Microsoft Corporation
* Copyright (c) Microsoft. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -26,13 +26,13 @@ exports.TableService = TableService;
* Creates a new TableService object.
* If no storageaccount or storageaccesskey are provided, the AZURE_STORAGE_ACCOUNT and AZURE_STORAGE_ACCESS_KEY environment variables will be used.
*
* @param {string} [storageAccount] The storage account.
* @param {string} [storageAccessKey] The storage access key.
* @param {string} [host] The host address.
* @param {object} [authenticationProvider] The authentication provider.
* @param {string} [storageAccountOrConnectionString] The storage account or the connection string.
* @param {string} [storageAccessKey] The storage access key.
* @param {string} [host] The host address.
* @param {object} [authenticationProvider] The authentication provider.
*/
exports.createTableService = function (storageAccount, storageAccessKey, host, authenticationProvider) {
return new TableService(storageAccount, storageAccessKey, host, authenticationProvider);
exports.createTableService = function (storageAccountOrConnectionString, storageAccessKey, host, authenticationProvider) {
return new TableService(storageAccountOrConnectionString, storageAccessKey, host, authenticationProvider);
};

/**
Expand All @@ -46,34 +46,33 @@ exports.BlobService = BlobService;
* Creates a new BlobService object.
* If no storageaccount or storageaccesskey are provided, the AZURE_STORAGE_ACCOUNT and AZURE_STORAGE_ACCESS_KEY environment variables will be used.
*
* @param {string} [storageAccount] The storage account.
* @param {string} [storageAccessKey] The storage access key.
* @param {string} [host] The host address.
* @param {object} [authenticationProvider] The authentication provider.
* @param {string} [storageAccountOrConnectionString] The storage account or the connection string.
* @param {string} [storageAccessKey] The storage access key.
* @param {string} [host] The host address.
* @param {object} [authenticationProvider] The authentication provider.
*/
exports.createBlobService = function (storageAccount, storageAccessKey, host, authenticationProvider) {
return new BlobService(storageAccount, storageAccessKey, host, authenticationProvider);
exports.createBlobService = function (storageAccountOrConnectionString, storageAccessKey, host, authenticationProvider) {
return new BlobService(storageAccountOrConnectionString, storageAccessKey, host, authenticationProvider);
};

/**
* Queue client exports.
*/

var QueueService = require('./services/queue/queueservice');
exports.QueueService = QueueService;

/**
* Creates a new QueueService object.
* If no storageAccount or storageAccessKey are provided, the AZURE_STORAGE_ACCOUNT and AZURE_STORAGE_ACCESS_KEY
* If no storageAccount or storageAccessKey are provided, the AZURE_STORAGE_ACCOUNT and AZURE_STORAGE_ACCESS_KEY
* environment variables will be used.
*
* @param {string} [storageAccount] The storage account.
* @param {string} [storageAccessKey] The storage access key.
* @param {string} [host] The host address.
* @param {object} [authenticationProvider] The authentication provider.
* @param {string} [storageAccountOrConnectionString] The storage account or the connection string.
* @param {string} [storageAccessKey] The storage access key.
* @param {string} [host] The host address.
* @param {object} [authenticationProvider] The authentication provider.
*/
exports.createQueueService = function (storageAccount, storageAccessKey, host, authenticationProvider) {
return new QueueService(storageAccount, storageAccessKey, host, authenticationProvider);
exports.createQueueService = function (storageAccountOrConnectionString, storageAccessKey, host, authenticationProvider) {
return new QueueService(storageAccountOrConnectionString, storageAccessKey, host, authenticationProvider);
};

/**
Expand All @@ -86,15 +85,142 @@ exports.ServiceBusService = ServiceBusService;
/**
* Creates a new ServiceBusService object.
*
* @param {string} [namespace] The service bus namespace.
* @param {string} [accessKey] The password.
* @param {string} [issuer] The issuer.
* @param {string} [acsNamespace] The acs namespace. Usually the same as the sb namespace with "-sb" suffix.
* @param {string} [host] The host address.
* @param {object} [authenticationProvider] The authentication provider.
*/
exports.createServiceBusService = function (namespace, accessKey, issuer, acsNamespace, host, authenticationProvider) {
return new ServiceBusService(namespace, accessKey, issuer, acsNamespace, host, authenticationProvider);
* @param {string} [namespaceOrConnectionString] The service bus namespace.
* @param {string} [accessKey] The password.
* @param {string} [issuer] The issuer.
* @param {string} [acsNamespace] The acs namespace. Usually the same as the sb namespace with "-sb" suffix.
* @param {string} [host] The host address.
* @param {object} [authenticationProvider] The authentication provider.
*/
exports.createServiceBusService = function (namespaceOrConnectionString, accessKey, issuer, acsNamespace, host, authenticationProvider) {
return new ServiceBusService(namespaceOrConnectionString, accessKey, issuer, acsNamespace, host, authenticationProvider);
};

/**
* Notification hub client exports.
*/

var NotificationHubService = require('./services/serviceBus/notificationhubservice');
exports.NotificationHubService = NotificationHubService;

/**
* Creates a new NotificationHubService object.
*
* @param {string} hubName The notification hub name.
* @param {string} [endpointOrConnectionString] The service bus endpoint or connection string.
* @param {string} [sharedAccessKeyName] The notification hub shared access key name.
* @param {string} [sharedAccessKeyValue] The notification hub shared access key value.
*/
exports.createNotificationHubService = function (hubName, endpointOrConnectionString, sharedAccessKeyName, sharedAccessKeyValue) {
return new NotificationHubService(hubName, endpointOrConnectionString, sharedAccessKeyName, sharedAccessKeyValue);
};

/**
* SqlService client exports.
*/

var SqlService = require('./services/sqlAzure/sqlservice');
exports.SqlService = SqlService;

/**
* Creates a new SqlManagementService object.
*
* @param {string} serverName The SQL server name.
* @param {string} administratorLogin The SQL Server administrator login.
* @param {string} administratorLoginPassword The SQL Server administrator login password.
* @param {string} [host] The host for the service.
* @param {string} [acsHost] The acs host.
* @param {object} [authenticationProvider] The authentication provider.
*/
exports.createSqlService = function (serverName, administratorLogin, administratorLoginPassword, host, acsHost, authenticationProvider) {
return new SqlService(serverName, administratorLogin, administratorLoginPassword, host, acsHost, authenticationProvider);
};

/**
* ServiceManagement client exports.
*/

var ServiceManagementService = require('./services/serviceManagement/servicemanagementservice');
exports.ServiceManagementService = ServiceManagementService;

/**
* Creates a new ServiceManagementService object.
*
* @param {string} subscriptionId The subscription ID for the account.
* @param {string} authentication The authentication object for the client.
* {
* keyfile: 'path to .pem',
* certfile: 'path to .pem',
* keyvalue: privatekey value,
* certvalue: public cert value
* }
* @param {string} hostOptions The host options to override defaults.
* {
* host: 'management.core.windows.net',
* apiversion: '2012-03-01',
* serializetype: 'XML'
* }
*/
exports.createServiceManagementService = function (subscriptionId, authentication, hostOptions) {
return new ServiceManagementService(subscriptionId, authentication, hostOptions);
};

/**
* SqlManagementService client exports.
*/

var SqlManagementService = require('./services/serviceManagement/sqlmanagementservice');
exports.SqlManagementService = SqlManagementService;

/**
* Creates a new SqlManagementService object.
*
* @param {string} subscriptionId The subscription ID for the account.
* @param {string} authentication The authentication object for the client.
* {
* keyfile: 'path to .pem',
* certfile: 'path to .pem',
* keyvalue: privatekey value,
* certvalue: public cert value
* }
* @param {string} hostOptions The host options to override defaults.
* {
* host: 'management.core.windows.net',
* apiversion: '2012-03-01',
* serializetype: 'XML'
* }
*/
exports.createSqlManagementService = function (subscriptionId, authentication, hostOptions) {
return new SqlManagementService(subscriptionId, authentication, hostOptions);
};

/**
* ServiceBusManagementService client exports.
*/

var ServiceBusManagementService = require('./services/serviceManagement/servicebusmanagementservice');
exports.ServiceBusManagementService = ServiceBusManagementService;

/**
* Creates a new ServiceBusManagementService object.
*
* @param {string} subscriptionId The subscription ID for the account.
* @param {string} authentication The authentication object for the client.
* {
* keyfile: 'path to .pem',
* certfile: 'path to .pem',
* keyvalue: privatekey value,
* certvalue: public cert value
* }
* @param {string} hostOptions The host options to override defaults.
* {
* host: 'management.core.windows.net',
* apiversion: '2012-03-01',
* serializetype: 'XML'
* }
*/
exports.createServiceBusManagementService = function (subscriptionId, authentication, hostOptions) {
return new ServiceBusManagementService(subscriptionId, authentication, hostOptions);
};

/**
Expand All @@ -107,7 +233,9 @@ exports.RoleEnvironment = require('./serviceruntime/roleenvironment');
* Other exports.
*/

exports.WebResource = require('./http/webresource');
exports.ServiceClient = require('./services/core/serviceclient');
exports.ServiceManagementClient = require('./services/core/servicemanagementclient');
exports.TableQuery = require('./services/table/tablequery');
exports.BatchServiceClient = require('./services/table/batchserviceclient');
exports.Constants = require('./util/constants');
Expand All @@ -118,8 +246,18 @@ exports.SharedKey = require('./services/blob/sharedkey');
exports.SharedKeyLite = require('./services/blob/sharedkeylite');
exports.SharedKeyTable = require('./services/table/sharedkeytable');
exports.SharedKeyLiteTable = require('./services/table/sharedkeylitetable');
// deprecated
exports.ISO8061Date = require('./util/iso8061date');
exports.Logger = require('./diagnostics/logger');
exports.ConnectionStringParser = require('./services/core/connectionstringparser');
exports.ServiceSettings = require('./services/core/servicesettings');
exports.StorageServiceSettings = require('./services/core/storageservicesettings');
exports.ServiceBusSettings = require('./services/core/servicebussettings');
exports.ServiceManagementSettings = require('./services/core/servicemanagementsettings');
exports.Validate = require('./util/validate');

exports.date = require('./util/date');
exports.namespaceNameIsValid = require('./services/serviceManagement/models/namevalidation');

/*
* Convenience functions.
Expand Down
65 changes: 31 additions & 34 deletions lib/diagnostics/logger.js
@@ -1,5 +1,5 @@
/**
* Copyright 2011 Microsoft Corporation
* Copyright (c) Microsoft. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,11 +13,23 @@
* limitations under the License.
*/

// Module dependencies.
var Log = require('log');
function Logger(level, loggerFunction) {
var self = this;

// Expose 'Logger'.
exports = module.exports = Logger;
this.level = level;
this.loggerFunction = loggerFunction;

if (!this.loggerFunction) {
this.loggerFunction = function (logLevel, msg) {
var currentLevelIndex = Logger.logPriority.indexOf(self.level);
var logLeveLIndex = Logger.logPriority.indexOf(logLevel);

if (logLeveLIndex <= currentLevelIndex) {
console.log(self.level + ' : ' + msg);
}
};
}
}

Logger.LogLevels = {
/**
Expand Down Expand Up @@ -61,34 +73,19 @@ Logger.LogLevels = {
DEBUG : 'debug'
};

function Logger(level, stream) {
this.logger = new Log(level, stream);
}
Logger.logPriority = [
Logger.LogLevels.EMERGENCY,
Logger.LogLevels.ALERT,
Logger.LogLevels.CRITICAL,
Logger.LogLevels.ERROR,
Logger.LogLevels.WARNING,
Logger.LogLevels.NOTICE,
Logger.LogLevels.INFO,
Logger.LogLevels.DEBUG
];

Logger.prototype.log = function (level, msg) {
switch (level) {
case Logger.LogLevels.EMERGENCY:
this.logger.emergency(msg);
break;
case Logger.LogLevels.ALERT:
this.logger.alert(msg);
break;
case Logger.LogLevels.CRITICAL:
this.logger.critical(msg);
break;
case Logger.LogLevels.ERROR:
this.logger.error(msg);
break;
case Logger.LogLevels.WARNING:
this.logger.warning(msg);
break;
case Logger.LogLevels.NOTICE:
this.logger.notice(msg);
break;
case Logger.LogLevels.INFO:
this.logger.info(msg);
break;
case Logger.LogLevels.DEBUG:
this.logger.debug(msg);
}
};
this.loggerFunction(level, msg);
};

module.exports = Logger;

0 comments on commit 5357746

Please sign in to comment.