Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #592 from WindowsAzure/release-0.6.10

Release 0.6.10
  • Loading branch information...
commit 6f74063fa552c654acf31c70c4779190c8f95ceb 2 parents cdfe370 + 08c4f04
@andrerod andrerod authored
Showing with 10,331 additions and 1,672 deletions.
  1. +1 −0  .gitignore
  2. +5 −0 ChangeLog.txt
  3. +83 −1 README.md
  4. +1 −1  examples/geophoto/services/pushpinService.js
  5. +1 −1  examples/myevents/eventService.js
  6. +1 −1  examples/serviceexplorer/services/roleEnvironmentService.js
  7. +52 −0 lib/azure.js
  8. +6 −7 lib/serviceruntime/runtimeversionprotocolclient.js
  9. +5 −5 lib/serviceruntime/xmlgoalstatedeserializer.js
  10. +24 −43 lib/serviceruntime/xmlroleenvironmentdatadeserializer.js
  11. +38 −39 lib/services/blob/blobservice.js
  12. +9 −7 lib/services/blob/models/blobresult.js
  13. +6 −6 lib/services/blob/models/blocklistresult.js
  14. +28 −2 lib/services/blob/models/containeraclresult.js
  15. +7 −9 lib/services/blob/models/containerresult.js
  16. +26 −25 lib/services/blob/models/servicepropertiesresult.js
  17. +58 −24 lib/services/core/serviceclient.js
  18. +1 −1  lib/services/core/servicemanagementclient.js
  19. +125 −0 lib/services/core/sqlserviceclient.js
  20. +2 −2 lib/services/queue/models/queuemessageresult.js
  21. +1 −1  lib/services/queue/models/queueresult.js
  22. +24 −24 lib/services/queue/models/servicepropertiesresult.js
  23. +6 −19 lib/services/queue/queueservice.js
  24. +14 −14 lib/services/serviceBus/models/queueresult.js
  25. +22 −22 lib/services/serviceBus/models/ruleresult.js
  26. +14 −14 lib/services/serviceBus/models/subscriptionresult.js
  27. +14 −14 lib/services/serviceBus/models/topicresult.js
  28. +60 −74 lib/services/serviceBus/servicebusservice.js
  29. +56 −0 lib/services/serviceManagement/models/parseserverresponse.js
  30. +7 −6 lib/services/serviceManagement/servicemanagementservice.js
  31. +295 −0 lib/services/serviceManagement/sqlmanagementservice.js
  32. +81 −0 lib/services/sqlAzure/models/databaseresult.js
  33. +135 −0 lib/services/sqlAzure/sqlserveracs.js
  34. +193 −0 lib/services/sqlAzure/sqlservice.js
  35. +1 −1  lib/services/table/models/entityresult.js
  36. +25 −24 lib/services/table/models/servicepropertiesresult.js
  37. +2 −1  lib/services/table/models/tableresult.js
  38. +14 −20 lib/services/table/tableservice.js
  39. +19 −18 lib/util/atomhandler.js
  40. +33 −12 lib/util/constants.js
  41. +62 −0 lib/util/date.js
  42. +4 −4 package.json
  43. +0 −47 test/mockserver/index.html
  44. +0 −489 test/mockserver/mockserver.js
  45. +0 −172 test/mockserver/mockserverclient.js
  46. +1 −0  test/recordings/batchserviceclient-tests1/index.json
  47. +1 −0  test/recordings/batchserviceclient-tests1/x1.dat
  48. +16 −0 test/recordings/batchserviceclient-tests1/x2.dat
  49. +15 −0 test/recordings/batchserviceclient-tests1/x3.dat
  50. +38 −0 test/recordings/batchserviceclient-tests1/x4.dat
  51. +1 −0  test/recordings/batchserviceclient-tests2/index.json
  52. +1 −0  test/recordings/sharedkeytable-tests1/index.json
  53. +1 −0  test/recordings/sharedkeytable-tests1/x1.dat
  54. +16 −0 test/recordings/sharedkeytable-tests1/x2.dat
  55. +16 −0 test/recordings/sharedkeytable-tests1/x3.dat
  56. +1 −0  test/recordings/tableservice-batch-tests1/index.json
  57. +1 −0  test/recordings/tableservice-batch-tests1/x1.dat
  58. +16 −0 test/recordings/tableservice-batch-tests1/x2.dat
  59. +205 −0 test/recordings/tableservice-batch-tests1/x3.dat
  60. +625 −0 test/recordings/tableservice-batch-tests1/x4.dat
  61. +367 −0 test/recordings/tableservice-batch-tests1/x5.dat
  62. +22 −0 test/recordings/tableservice-batch-tests1/x6.dat
  63. +1 −0  test/recordings/tableservice-batch-tests2/index.json
  64. +1 −0  test/recordings/tableservice-batch-tests2/x1.dat
  65. +16 −0 test/recordings/tableservice-batch-tests2/x2.dat
  66. +205 −0 test/recordings/tableservice-batch-tests2/x3.dat
  67. +625 −0 test/recordings/tableservice-batch-tests2/x4.dat
  68. +19 −0 test/recordings/tableservice-batch-tests2/x5.dat
  69. +22 −0 test/recordings/tableservice-batch-tests2/x6.dat
  70. +1 −0  test/recordings/tableservice-batch-tests3/index.json
  71. +1 −0  test/recordings/tableservice-batch-tests3/x1.dat
  72. +16 −0 test/recordings/tableservice-batch-tests3/x2.dat
  73. +205 −0 test/recordings/tableservice-batch-tests3/x3.dat
  74. +625 −0 test/recordings/tableservice-batch-tests3/x4.dat
  75. +19 −0 test/recordings/tableservice-batch-tests3/x5.dat
  76. +22 −0 test/recordings/tableservice-batch-tests3/x6.dat
  77. +1 −0  test/recordings/tableservice-batch-tests4/index.json
  78. +1 −0  test/recordings/tableservice-batch-tests4/x1.dat
  79. +16 −0 test/recordings/tableservice-batch-tests4/x2.dat
  80. +205 −0 test/recordings/tableservice-batch-tests4/x3.dat
  81. +625 −0 test/recordings/tableservice-batch-tests4/x4.dat
  82. +25 −0 test/recordings/tableservice-batch-tests4/x5.dat
  83. +22 −0 test/recordings/tableservice-batch-tests4/x6.dat
  84. +1 −0  test/recordings/tableservice-batch-tests5/index.json
  85. +1 −0  test/recordings/tableservice-batch-tests5/x1.dat
  86. +16 −0 test/recordings/tableservice-batch-tests5/x2.dat
  87. +205 −0 test/recordings/tableservice-batch-tests5/x3.dat
  88. +625 −0 test/recordings/tableservice-batch-tests5/x4.dat
  89. +25 −0 test/recordings/tableservice-batch-tests5/x5.dat
  90. +22 −0 test/recordings/tableservice-batch-tests5/x6.dat
  91. +1 −0  test/recordings/tableservice-batch-tests6/index.json
  92. +1 −0  test/recordings/tableservice-batch-tests6/x1.dat
  93. +16 −0 test/recordings/tableservice-batch-tests6/x2.dat
  94. +205 −0 test/recordings/tableservice-batch-tests6/x3.dat
  95. +625 −0 test/recordings/tableservice-batch-tests6/x4.dat
  96. +79 −0 test/recordings/tableservice-batch-tests6/x5.dat
  97. +22 −0 test/recordings/tableservice-batch-tests6/x6.dat
  98. +1 −0  test/recordings/tableservice-tablequery-tests1/index.json
  99. +1 −0  test/recordings/tableservice-tablequery-tests1/x1.dat
  100. +16 −0 test/recordings/tableservice-tablequery-tests1/x2.dat
  101. +1 −0  test/recordings/tableservice-tablequery-tests1/x3.dat
  102. +20 −0 test/recordings/tableservice-tablequery-tests1/x4.dat
  103. +22 −0 test/recordings/tableservice-tablequery-tests1/x5.dat
  104. +26 −0 test/recordings/tableservice-tablequery-tests1/x6.dat
  105. +22 −0 test/recordings/tableservice-tablequery-tests1/x7.dat
  106. +1 −0  test/recordings/tableservice-tests1/index.json
  107. +1 −0  test/recordings/tableservice-tests1/x1.dat
  108. +10 −0 test/recordings/tableservice-tests1/x2.dat
  109. +1 −0  test/recordings/tableservice-tests10/index.json
  110. +1 −0  test/recordings/tableservice-tests10/x1.dat
  111. +16 −0 test/recordings/tableservice-tests10/x2.dat
  112. +1 −0  test/recordings/tableservice-tests10/x3.dat
  113. +21 −0 test/recordings/tableservice-tests10/x4.dat
  114. +7 −0 test/recordings/tableservice-tests10/x5.dat
  115. +22 −0 test/recordings/tableservice-tests10/x6.dat
  116. +1 −0  test/recordings/tableservice-tests11/index.json
  117. +1 −0  test/recordings/tableservice-tests11/x1.dat
  118. +16 −0 test/recordings/tableservice-tests11/x2.dat
  119. +1 −0  test/recordings/tableservice-tests11/x3.dat
  120. +21 −0 test/recordings/tableservice-tests11/x4.dat
  121. +1 −0  test/recordings/tableservice-tests11/x5.dat
  122. +22 −0 test/recordings/tableservice-tests11/x6.dat
  123. +1 −0  test/recordings/tableservice-tests12/index.json
  124. +1 −0  test/recordings/tableservice-tests12/x1.dat
  125. +16 −0 test/recordings/tableservice-tests12/x2.dat
  126. +1 −0  test/recordings/tableservice-tests12/x3.dat
  127. +21 −0 test/recordings/tableservice-tests12/x4.dat
  128. +1 −0  test/recordings/tableservice-tests12/x5.dat
  129. +7 −0 test/recordings/tableservice-tests12/x6.dat
  130. +22 −0 test/recordings/tableservice-tests12/x7.dat
  131. +1 −0  test/recordings/tableservice-tests13/index.json
  132. +1 −0  test/recordings/tableservice-tests13/x1.dat
  133. +16 −0 test/recordings/tableservice-tests13/x2.dat
  134. +1 −0  test/recordings/tableservice-tests13/x3.dat
  135. +21 −0 test/recordings/tableservice-tests13/x4.dat
  136. +1 −0  test/recordings/tableservice-tests13/x5.dat
  137. +22 −0 test/recordings/tableservice-tests13/x6.dat
  138. +1 −0  test/recordings/tableservice-tests14/index.json
  139. +1 −0  test/recordings/tableservice-tests14/x1.dat
  140. +16 −0 test/recordings/tableservice-tests14/x2.dat
  141. +1 −0  test/recordings/tableservice-tests14/x3.dat
  142. +21 −0 test/recordings/tableservice-tests14/x4.dat
  143. +1 −0  test/recordings/tableservice-tests14/x5.dat
  144. +7 −0 test/recordings/tableservice-tests14/x6.dat
  145. +22 −0 test/recordings/tableservice-tests14/x7.dat
  146. +1 −0  test/recordings/tableservice-tests15/index.json
  147. +1 −0  test/recordings/tableservice-tests15/x1.dat
  148. +16 −0 test/recordings/tableservice-tests15/x2.dat
  149. +1 −0  test/recordings/tableservice-tests15/x3.dat
  150. +1 −0  test/recordings/tableservice-tests15/x4.dat
  151. +20 −0 test/recordings/tableservice-tests15/x5.dat
  152. +22 −0 test/recordings/tableservice-tests15/x6.dat
  153. +1 −0  test/recordings/tableservice-tests16/index.json
  154. +1 −0  test/recordings/tableservice-tests16/x1.dat
  155. +16 −0 test/recordings/tableservice-tests16/x2.dat
  156. +1 −0  test/recordings/tableservice-tests16/x3.dat
  157. +1 −0  test/recordings/tableservice-tests16/x4.dat
  158. +21 −0 test/recordings/tableservice-tests16/x5.dat
  159. +22 −0 test/recordings/tableservice-tests16/x6.dat
  160. +1 −0  test/recordings/tableservice-tests17/index.json
  161. +1 −0  test/recordings/tableservice-tests17/x1.dat
  162. +16 −0 test/recordings/tableservice-tests17/x2.dat
  163. +1 −0  test/recordings/tableservice-tests17/x3.dat
  164. +20 −0 test/recordings/tableservice-tests17/x4.dat
  165. +22 −0 test/recordings/tableservice-tests17/x5.dat
  166. +1 −0  test/recordings/tableservice-tests18/index.json
  167. +1 −0  test/recordings/tableservice-tests18/x1.dat
  168. +16 −0 test/recordings/tableservice-tests18/x2.dat
  169. +7 −0 test/recordings/tableservice-tests18/x3.dat
  170. +25 −0 test/recordings/tableservice-tests18/x4.dat
  171. +22 −0 test/recordings/tableservice-tests18/x5.dat
  172. +1 −0  test/recordings/tableservice-tests19/index.json
  173. +1 −0  test/recordings/tableservice-tests19/x1.dat
  174. +22 −0 test/recordings/tableservice-tests19/x10.dat
  175. +16 −0 test/recordings/tableservice-tests19/x2.dat
  176. +1 −0  test/recordings/tableservice-tests19/x3.dat
  177. +19 −0 test/recordings/tableservice-tests19/x4.dat
  178. +1 −0  test/recordings/tableservice-tests19/x5.dat
  179. +19 −0 test/recordings/tableservice-tests19/x6.dat
  180. +1 −0  test/recordings/tableservice-tests19/x7.dat
  181. +19 −0 test/recordings/tableservice-tests19/x8.dat
  182. +43 −0 test/recordings/tableservice-tests19/x9.dat
  183. +1 −0  test/recordings/tableservice-tests2/index.json
  184. +1 −0  test/recordings/tableservice-tests2/x1.dat
  185. +1 −0  test/recordings/tableservice-tests2/x2.dat
  186. +1 −0  test/recordings/tableservice-tests2/x3.dat
  187. +10 −0 test/recordings/tableservice-tests2/x4.dat
  188. +1 −0  test/recordings/tableservice-tests20/index.json
  189. +10 −0 test/recordings/tableservice-tests20/x1.dat
  190. +1 −0  test/recordings/tableservice-tests21/index.json
  191. +10 −0 test/recordings/tableservice-tests21/x1.dat
  192. +1 −0  test/recordings/tableservice-tests22/index.json
  193. +1 −0  test/recordings/tableservice-tests22/x1.dat
  194. +16 −0 test/recordings/tableservice-tests22/x2.dat
  195. +22 −0 test/recordings/tableservice-tests22/x3.dat
  196. +1 −0  test/recordings/tableservice-tests23/index.json
  197. +1 −0  test/recordings/tableservice-tests23/x1.dat
  198. +16 −0 test/recordings/tableservice-tests23/x2.dat
  199. +22 −0 test/recordings/tableservice-tests23/x3.dat
  200. +1 −0  test/recordings/tableservice-tests24/index.json
  201. +1 −0  test/recordings/tableservice-tests24/x1.dat
  202. +16 −0 test/recordings/tableservice-tests24/x2.dat
  203. +22 −0 test/recordings/tableservice-tests24/x3.dat
  204. +1 −0  test/recordings/tableservice-tests25/index.json
  205. +10 −0 test/recordings/tableservice-tests25/x1.dat
  206. +1 −0  test/recordings/tableservice-tests3/index.json
  207. +1 −0  test/recordings/tableservice-tests3/x1.dat
  208. +16 −0 test/recordings/tableservice-tests3/x2.dat
  209. +16 −0 test/recordings/tableservice-tests3/x3.dat
  210. +22 −0 test/recordings/tableservice-tests3/x4.dat
  211. +1 −0  test/recordings/tableservice-tests4/index.json
  212. +1 −0  test/recordings/tableservice-tests4/x1.dat
  213. +16 −0 test/recordings/tableservice-tests4/x2.dat
  214. +1 −0  test/recordings/tableservice-tests4/x3.dat
  215. +7 −0 test/recordings/tableservice-tests4/x4.dat
  216. +22 −0 test/recordings/tableservice-tests4/x5.dat
  217. +1 −0  test/recordings/tableservice-tests5/index.json
  218. +10 −0 test/recordings/tableservice-tests5/x1.dat
  219. +1 −0  test/recordings/tableservice-tests5/x2.dat
  220. +16 −0 test/recordings/tableservice-tests5/x3.dat
  221. +1 −0  test/recordings/tableservice-tests5/x4.dat
  222. +16 −0 test/recordings/tableservice-tests5/x5.dat
  223. +37 −0 test/recordings/tableservice-tests5/x6.dat
  224. +37 −0 test/recordings/tableservice-tests5/x7.dat
  225. +1 −0  test/recordings/tableservice-tests6/index.json
  226. +1 −0  test/recordings/tableservice-tests6/x1.dat
  227. +16 −0 test/recordings/tableservice-tests6/x2.dat
  228. +10 −0 test/recordings/tableservice-tests6/x3.dat
  229. +1 −0  test/recordings/tableservice-tests7/index.json
  230. +1 −0  test/recordings/tableservice-tests7/x1.dat
  231. +16 −0 test/recordings/tableservice-tests7/x2.dat
  232. +1 −0  test/recordings/tableservice-tests7/x3.dat
  233. +21 −0 test/recordings/tableservice-tests7/x4.dat
  234. +1 −0  test/recordings/tableservice-tests7/x5.dat
  235. +22 −0 test/recordings/tableservice-tests7/x6.dat
  236. +48 −0 test/recordings/tableservice-tests7/x7.dat
  237. +21 −0 test/recordings/tableservice-tests7/x8.dat
  238. +22 −0 test/recordings/tableservice-tests7/x9.dat
  239. +1 −0  test/recordings/tableservice-tests8/index.json
  240. +1 −0  test/recordings/tableservice-tests8/x1.dat
  241. +16 −0 test/recordings/tableservice-tests8/x2.dat
  242. +1 −0  test/recordings/tableservice-tests8/x3.dat
  243. +21 −0 test/recordings/tableservice-tests8/x4.dat
  244. +21 −0 test/recordings/tableservice-tests8/x5.dat
  245. +22 −0 test/recordings/tableservice-tests8/x6.dat
  246. +1 −0  test/recordings/tableservice-tests9/index.json
  247. +1 −0  test/recordings/tableservice-tests9/x1.dat
  248. +16 −0 test/recordings/tableservice-tests9/x2.dat
  249. +1 −0  test/recordings/tableservice-tests9/x3.dat
  250. +21 −0 test/recordings/tableservice-tests9/x4.dat
  251. +22 −0 test/recordings/tableservice-tests9/x5.dat
  252. +8 −6 test/runtests.js
  253. +131 −74 test/services/blob/blobservice-tests.js
  254. +15 −8 test/services/blob/filters-tests.js
  255. +16 −20 test/services/blob/sharedkeylite-tests.js
  256. +20 −12 test/services/core/exponentialretrypolicyfilter-tests.js
  257. +20 −11 test/services/core/linearretrypolicyfilter-tests.js
  258. +6 −4 test/services/core/serviceclient-tests.js
  259. +26 −17 test/services/queue/queueservice-tests.js
  260. +0 −1  test/services/serviceBus/servicebusservice-tests.js
  261. +179 −0 test/services/serviceManagement/servicemanagementservice-tests.js
  262. +285 −0 test/services/serviceManagement/sqlmanagementservice-tests.js
  263. +190 −0 test/services/sqlAzure/sqlservice-tests.js
  264. +17 −10 test/services/table/batchserviceclient-tests.js
  265. +1 −2  test/services/table/queryentitiesresultcontinuation-tests.js
  266. +22 −15 test/services/table/sharedkeytable-tests.js
  267. +22 −14 test/services/table/tableservice-batch-tests.js
  268. +16 −9 test/services/table/tableservice-tablequery-tests.js
  269. +70 −55 test/services/table/tableservice-tests.js
  270. +4 −0 test/testlist.txt
  271. +49 −49 test/util/atomhandler-tests.js
  272. +26 −75 test/util/blob-test-utils.js
  273. +58 −0 test/util/date-tests.js
  274. +24 −64 test/util/queue-test-utils.js
  275. +2 −2 test/util/servicebus-test-utils.js
  276. +84 −0 test/util/storage-test-utils.js
  277. +22 −70 test/util/table-test-utils.js
  278. +22 −0 test/util/util.js
  279. +1 −4 test/util/wrapservice-test-utils.js
View
1  .gitignore
@@ -6,6 +6,7 @@ targets/*
*.user
# Node #
+test/recordings/
node_modules/
npm-debug.log
azure_error
View
5 ChangeLog.txt
@@ -1,3 +1,8 @@
+2012.02.11 Version 0.6.10
+* Added helper date.* functions for generating SAS expirations (secondsFromNow, minutesFromNow, hoursFromNow, daysFromNow)
+* Added SQL classes for managing SQL Servers, Databases and Firewall rules
+* Updating to use latest xml2js
+
2012.12.12 Version 0.6.9
* Exporting WebResource, Client classes from package to support CLI.
* Install message updated to remind users the CLI is now a separate package.
View
84 README.md
@@ -17,6 +17,8 @@ This project provides a Node.js package that makes it easy to access Windows Azu
* Service Bus
* Queues: create, list and delete queues; create, list, and delete subscriptions; send, receive, unlock and delete messages
* Topics: create, list, and delete topics; create, list, and delete rules
+* Azure SQL Database
+ * create, list and delete Azure SQL Database servers, databases and firewall rules
* Service Runtime
* discover addresses and ports for the endpoints of other role instances in your service
* get configuration settings and access local resources
@@ -120,6 +122,21 @@ blobService.getBlobToStream('taskcontainer', 'task1', fs.createWriteStream('task
});
```
+To create a SAS URL you can use the **generateSharedAccessSignatureUrl** method. Additionally you can use the **date** helper functions to easily create a SAS that expires at some point relative to the current time.
+
+```Javascript
+var blobService = azure.createBlobService();
+
+//create a SAS that expires in an hour
+var sharedAccessPolicy = {
+ AccessPolicy: {
+ Expiry: azure.date.minutesFromNow(60);
+ }
+};
+
+var sasUrl = blobService.generateSharedAccessSignatureUrl(containerName, blobName, sharedAccessPolicy);
+```
+
## Storage Queues
The **createQueueIfNotExists** method can be used to ensure a queue exists:
@@ -245,6 +262,71 @@ serviceBusService.createSubscription(topic, subscription, function(error1){
}
});
```
+## Azure SQL Database
+
+The Azure SQL Database functions allow you to manage Azure SQL servers, databases and firewall rules.
+
+### Servers
+You can add, delete and list SQL Server instances
+
+```Javascript
+var authentication={keyvalue:"...", certvalue:"..."};
+var sqlMgmt = new azure.createSqlManagementService(subscriptionId, authentication);
+
+//create a new server
+//admin, password, location, callback
+sqlMgmt.createServer("sqladmin", "Pa$$w0rd", "West US", function(error, serverName) {
+ console.log("created server " + serverName);
+});
+
+//list out servers
+sqlMgmt.listServers(function(error, servers) {
+ console.log("servers\n" + servers);
+});
+
+```
+
+### Firewall rules
+You can list, create and delete firewall rules
+
+```Javascript
+var authentication={keyvalue:"...", certvalue:"..."};
+var sqlMgmt = new azure.createSqlManagementService(subscriptionId, authentication);
+
+//create a new rule
+//server, rule name, start ip, end ip, callback
+sqlMgmt.createServerFirewallRule(serverName, 'myrule', '192.168.100.0', '192.168.100.255',
+ function(error, rule) {
+ console.log("Rule created:\n" + rule);
+ }
+);
+
+//list rules
+sqlMgmt.listServerFirewallRules(serverName, function(error, rules) {
+ console.log("Rules:\n:" + rules);
+});
+
+```
+
+### Databases
+You can list, create and delete databases
+
+```Javascript
+var sqlService = new azure.createSqlService(serverName, 'sqlAdmin', 'Pa$$w0rd');
+
+//create a new database
+//db name, callback
+sqlServer.createServerDatabase("mydb", function(error, db) {
+ console.log("DB Created:\n" + db);
+});
+
+//list databases
+sqlServer.listServerDatabases(function(error, dbs) {
+ console.log("Databases:\n" + dbs);
+});
+
+```
+
## Service Runtime
@@ -322,4 +404,4 @@ For documentation on how to host Node.js applications on Windows Azure, please s
For documentation on the Azure cross platform CLI tool for Mac and Linux, please see our readme [here] (http://github.com/windowsazure/azure-sdk-tools-xplat)
-Check out our new IRC channel on freenode, node-azure.
+Check out our new IRC channel on freenode, node-azure.
View
2  examples/geophoto/services/pushpinService.js
@@ -82,7 +82,7 @@ PushpinService.prototype.createPushpin = function (pushpinData, pushpinImage, ca
entity.PartitionKey = DEFAULT_PARTITION;
if (blob) {
- entity.imageUrl = self.blobClient.getBlobUrl(blob.container, blob.blob).url();
+ entity.imageUrl = self.blobClient.getBlobUrl(blob.container, blob.blob);
}
self.tableClient.insertEntity(TABLE_NAME, entity, callback);
View
2  examples/myevents/eventService.js
@@ -31,7 +31,7 @@ EventService.prototype = {
res.render('detail', {
title: eventItem.name,
eventItem: eventItem,
- imageUrl: self.blobClient.getBlobUrl('photos', eventItem.RowKey).url(),
+ imageUrl: self.blobClient.getBlobUrl('photos', eventItem.RowKey),
});
}
});
View
2  examples/serviceexplorer/services/roleEnvironmentService.js
@@ -146,7 +146,7 @@ exports.createOrEditRole = function (roleData, roleImage, callback) {
function insertOrUpdateEntity(error, role) {
if (role) {
- roleData.imageUrl = blobClient.getBlobUrl(role.container, role.blob).url();
+ roleData.imageUrl = blobClient.getBlobUrl(role.container, role.blob);
}
if (!_.isUndefined(roleData.RowKey) && !_.isUndefined(roleData.PartitionKey)) {
View
52 lib/azure.js
@@ -98,6 +98,27 @@ exports.createServiceBusService = function (namespaceOrConnectionString, accessK
};
/**
+* 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.
*/
@@ -127,6 +148,35 @@ exports.createServiceManagementService = function(subscriptionId, authentication
};
/**
+* 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);
+};
+
+/**
* Service Runtime exports.
*/
@@ -158,6 +208,8 @@ exports.ServiceBusSettings = require('./services/core/servicebussettings');
exports.ServiceManagementSettings = require('./services/core/servicemanagementsettings');
exports.Validate = require('./util/validate');
+exports.date = require('./util/date');
+
/*
* Convenience functions.
*/
View
13 lib/serviceruntime/runtimeversionprotocolclient.js
@@ -32,16 +32,15 @@ RuntimeVersionProtocolClient.prototype.getVersionMap = function (connectionPath,
} else {
var versions = {};
- if (data[ServiceRuntimeConstants.RUNTIME_SERVER_ENDPOINTS] &&
- data[ServiceRuntimeConstants.RUNTIME_SERVER_ENDPOINTS][ServiceRuntimeConstants.RUNTIME_SERVER_ENDPOINT]) {
-
- var endpoints = data[ServiceRuntimeConstants.RUNTIME_SERVER_ENDPOINTS][ServiceRuntimeConstants.RUNTIME_SERVER_ENDPOINT];
- if (!Array.isArray(endpoints)) {
- endpoints = [endpoints];
- }
+ if (data[ServiceRuntimeConstants.RUNTIME_SERVER_DISCOVERY] &&
+ data[ServiceRuntimeConstants.RUNTIME_SERVER_DISCOVERY][ServiceRuntimeConstants.RUNTIME_SERVER_ENDPOINTS] &&
+ data[ServiceRuntimeConstants.RUNTIME_SERVER_DISCOVERY][ServiceRuntimeConstants.RUNTIME_SERVER_ENDPOINTS][0] &&
+ data[ServiceRuntimeConstants.RUNTIME_SERVER_DISCOVERY][ServiceRuntimeConstants.RUNTIME_SERVER_ENDPOINTS][0][ServiceRuntimeConstants.RUNTIME_SERVER_ENDPOINT]) {
+ var endpoints = data[ServiceRuntimeConstants.RUNTIME_SERVER_DISCOVERY][ServiceRuntimeConstants.RUNTIME_SERVER_ENDPOINTS][0][[ServiceRuntimeConstants.RUNTIME_SERVER_ENDPOINT]];
for (var endpoint in endpoints) {
var currentEndpoint = endpoints[endpoint];
+
versions[currentEndpoint[Constants.XML_METADATA_MARKER].version] = currentEndpoint[Constants.XML_METADATA_MARKER].path;
}
}
View
10 lib/serviceruntime/xmlgoalstatedeserializer.js
@@ -29,11 +29,11 @@ XmlGoalStateDeserializer.prototype.deserialize = function (xml) {
var goalState = {};
- goalState.incarnation = xml[ServiceRuntimeConstants.INCARNATION];
- goalState.expectedState = xml[ServiceRuntimeConstants.EXPECTED_STATE];
- goalState.roleEnvironmentPath = xml[ServiceRuntimeConstants.ROLE_ENVIRONMENT_PATH];
- goalState.deadline = xml[ServiceRuntimeConstants.DEADLINE];
- goalState.currentStateEndpoint = xml[ServiceRuntimeConstants.CURRENT_STATE_ENDPOINT];
+ goalState.incarnation = xml[ServiceRuntimeConstants.GOAL_STATE][ServiceRuntimeConstants.INCARNATION][0];
+ goalState.expectedState = xml[ServiceRuntimeConstants.GOAL_STATE][ServiceRuntimeConstants.EXPECTED_STATE][0];
+ goalState.roleEnvironmentPath = xml[ServiceRuntimeConstants.GOAL_STATE][ServiceRuntimeConstants.ROLE_ENVIRONMENT_PATH][0];
+ goalState.deadline = xml[ServiceRuntimeConstants.GOAL_STATE][ServiceRuntimeConstants.DEADLINE][0];
+ goalState.currentStateEndpoint = xml[ServiceRuntimeConstants.GOAL_STATE][ServiceRuntimeConstants.CURRENT_STATE_ENDPOINT][0];
return goalState;
};
View
67 lib/serviceruntime/xmlroleenvironmentdatadeserializer.js
@@ -23,12 +23,12 @@ exports = module.exports = XmlRoleEnvironmentDataDeserializer;
function XmlRoleEnvironmentDataDeserializer() { }
XmlRoleEnvironmentDataDeserializer.prototype.deserialize = function (xml) {
- var configurationSettings = this._translateConfigurationSettings(xml);
- var localResources = this._translateLocalResources(xml);
- var currentInstance = this._translateCurrentInstance(xml);
- var isEmulated = xml[ServiceRuntimeConstants.DEPLOYMENT][Constants.XML_METADATA_MARKER][ServiceRuntimeConstants.EMULATED] === 'true';
- var deploymentId = xml[ServiceRuntimeConstants.DEPLOYMENT][Constants.XML_METADATA_MARKER][ServiceRuntimeConstants.DEPLOYMENT_ID];
- var roles = this._translateRoles(xml, currentInstance, currentInstance.roleName);
+ var configurationSettings = this._translateConfigurationSettings(xml[ServiceRuntimeConstants.ROLE_ENVIRONMENT]);
+ var localResources = this._translateLocalResources(xml[ServiceRuntimeConstants.ROLE_ENVIRONMENT]);
+ var currentInstance = this._translateCurrentInstance(xml[ServiceRuntimeConstants.ROLE_ENVIRONMENT]);
+ var isEmulated = xml[ServiceRuntimeConstants.ROLE_ENVIRONMENT][ServiceRuntimeConstants.DEPLOYMENT][0][Constants.XML_METADATA_MARKER][ServiceRuntimeConstants.EMULATED] === 'true';
+ var deploymentId = xml[ServiceRuntimeConstants.ROLE_ENVIRONMENT][ServiceRuntimeConstants.DEPLOYMENT][0][Constants.XML_METADATA_MARKER][ServiceRuntimeConstants.DEPLOYMENT_ID];
+ var roles = this._translateRoles(xml[ServiceRuntimeConstants.ROLE_ENVIRONMENT], currentInstance, currentInstance.roleName);
var roleEnvironmentData = {
id: deploymentId,
@@ -45,15 +45,12 @@ XmlRoleEnvironmentDataDeserializer.prototype.deserialize = function (xml) {
XmlRoleEnvironmentDataDeserializer.prototype._translateConfigurationSettings = function (xml) {
var configurationSettingsMap = {};
- if (xml[ServiceRuntimeConstants.CURRENT_INSTANCE] &&
- xml[ServiceRuntimeConstants.CURRENT_INSTANCE][ServiceRuntimeConstants.CONFIGURATION_SETTINGS] &&
- xml[ServiceRuntimeConstants.CURRENT_INSTANCE][ServiceRuntimeConstants.CONFIGURATION_SETTINGS][ServiceRuntimeConstants.CONFIGURATION_SETTING]) {
- var configurationSettings = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][ServiceRuntimeConstants.CONFIGURATION_SETTINGS][ServiceRuntimeConstants.CONFIGURATION_SETTING];
- if (!Array.isArray(configurationSettings)) {
- configurationSettings = [configurationSettings];
- }
+ if (xml[ServiceRuntimeConstants.CURRENT_INSTANCE] &&
+ xml[ServiceRuntimeConstants.CURRENT_INSTANCE][0][ServiceRuntimeConstants.CONFIGURATION_SETTINGS] &&
+ xml[ServiceRuntimeConstants.CURRENT_INSTANCE][0][ServiceRuntimeConstants.CONFIGURATION_SETTINGS][0][ServiceRuntimeConstants.CONFIGURATION_SETTING]) {
+ var configurationSettings = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][0][ServiceRuntimeConstants.CONFIGURATION_SETTINGS][0][ServiceRuntimeConstants.CONFIGURATION_SETTING];
for (var configurationSetting in configurationSettings) {
var currentConfigurationSetting = configurationSettings[configurationSetting];
configurationSettingsMap[currentConfigurationSetting[Constants.XML_METADATA_MARKER].name] = currentConfigurationSetting[Constants.XML_METADATA_MARKER].value;
@@ -67,14 +64,10 @@ XmlRoleEnvironmentDataDeserializer.prototype._translateLocalResources = function
var localResourcesMap = {};
if (xml[ServiceRuntimeConstants.CURRENT_INSTANCE] &&
- xml[ServiceRuntimeConstants.CURRENT_INSTANCE][ServiceRuntimeConstants.LOCAL_RESOURCES] &&
- xml[ServiceRuntimeConstants.CURRENT_INSTANCE][ServiceRuntimeConstants.LOCAL_RESOURCES][ServiceRuntimeConstants.LOCAL_RESOURCE]) {
-
- var localResources = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][ServiceRuntimeConstants.LOCAL_RESOURCES][ServiceRuntimeConstants.LOCAL_RESOURCE];
- if (!Array.isArray(localResources)) {
- localResources = [localResources];
- }
+ xml[ServiceRuntimeConstants.CURRENT_INSTANCE][0][ServiceRuntimeConstants.LOCAL_RESOURCES] &&
+ xml[ServiceRuntimeConstants.CURRENT_INSTANCE][0][ServiceRuntimeConstants.LOCAL_RESOURCES][0][ServiceRuntimeConstants.LOCAL_RESOURCE]) {
+ var localResources = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][0][ServiceRuntimeConstants.LOCAL_RESOURCES][0][ServiceRuntimeConstants.LOCAL_RESOURCE];
for (var localResource in localResources) {
var currentLocalResource = localResources[localResource];
var currentLocalResourceName = currentLocalResource[Constants.XML_METADATA_MARKER].name;
@@ -89,13 +82,13 @@ XmlRoleEnvironmentDataDeserializer.prototype._translateLocalResources = function
XmlRoleEnvironmentDataDeserializer.prototype._translateCurrentInstance = function (xml) {
var currentInstance = {};
- currentInstance.id = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][Constants.XML_METADATA_MARKER].id;
- currentInstance.roleName = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][Constants.XML_METADATA_MARKER].roleName;
- currentInstance.faultDomain = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][Constants.XML_METADATA_MARKER].faultDomain;
- currentInstance.updateDomain = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][Constants.XML_METADATA_MARKER].updateDomain;
+ currentInstance.id = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][0][Constants.XML_METADATA_MARKER].id;
+ currentInstance.roleName = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][0][Constants.XML_METADATA_MARKER].roleName;
+ currentInstance.faultDomain = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][0][Constants.XML_METADATA_MARKER].faultDomain;
+ currentInstance.updateDomain = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][0][Constants.XML_METADATA_MARKER].updateDomain;
- if (xml[ServiceRuntimeConstants.CURRENT_INSTANCE][ServiceRuntimeConstants.ENDPOINTS]) {
- currentInstance.endpoints = this._translateRoleInstanceEndpoints(xml[ServiceRuntimeConstants.CURRENT_INSTANCE][ServiceRuntimeConstants.ENDPOINTS]);
+ if (xml[ServiceRuntimeConstants.CURRENT_INSTANCE][0][ServiceRuntimeConstants.ENDPOINTS]) {
+ currentInstance.endpoints = this._translateRoleInstanceEndpoints(xml[ServiceRuntimeConstants.CURRENT_INSTANCE][0][ServiceRuntimeConstants.ENDPOINTS][0]);
for (var endpoint in currentInstance.endpoints) {
currentInstance.endpoints[endpoint].roleInstanceId = currentInstance.id;
@@ -112,13 +105,9 @@ XmlRoleEnvironmentDataDeserializer.prototype._translateRoles = function (xml, cu
var roleInstances;
if (xml[ServiceRuntimeConstants.ROLES] &&
- xml[ServiceRuntimeConstants.ROLES][ServiceRuntimeConstants.ROLE]) {
-
- var roles = xml[ServiceRuntimeConstants.ROLES][ServiceRuntimeConstants.ROLE];
- if (!Array.isArray(roles)) {
- roles = [roles];
- }
+ xml[ServiceRuntimeConstants.ROLES][0][ServiceRuntimeConstants.ROLE]) {
+ var roles = xml[ServiceRuntimeConstants.ROLES][0][ServiceRuntimeConstants.ROLE];
for (var role in roles) {
var currentIterationRole = roles[role];
var currentIterationRoleName = currentIterationRole[Constants.XML_METADATA_MARKER].name;
@@ -159,18 +148,14 @@ XmlRoleEnvironmentDataDeserializer.prototype._translateRoleInstances = function
var roleInstancesMap = {};
if (xml[ServiceRuntimeConstants.INSTANCES] &&
- xml[ServiceRuntimeConstants.INSTANCES][ServiceRuntimeConstants.INSTANCE]) {
-
- var instances = xml[ServiceRuntimeConstants.INSTANCES][ServiceRuntimeConstants.INSTANCE];
- if (!Array.isArray(instances)) {
- instances = [instances];
- }
+ xml[ServiceRuntimeConstants.INSTANCES][0][ServiceRuntimeConstants.INSTANCE]) {
+ var instances = xml[ServiceRuntimeConstants.INSTANCES][0][ServiceRuntimeConstants.INSTANCE];
for (var instance in instances) {
var currentIterationInstance = instances[instance];
var currentIterationInstanceId = currentIterationInstance[Constants.XML_METADATA_MARKER].id;
- var endpoints = this._translateRoleInstanceEndpoints(currentIterationInstance[ServiceRuntimeConstants.ENDPOINTS]);
+ var endpoints = this._translateRoleInstanceEndpoints(currentIterationInstance[ServiceRuntimeConstants.ENDPOINTS][0]);
for (var endpoint in endpoints) {
endpoints[endpoint].roleInstanceId = currentIterationInstanceId;
@@ -192,10 +177,6 @@ XmlRoleEnvironmentDataDeserializer.prototype._translateRoleInstanceEndpoints = f
endpointsXml[ServiceRuntimeConstants.ENDPOINT]) {
var endpoints = endpointsXml[ServiceRuntimeConstants.ENDPOINT];
- if (!Array.isArray(endpoints)) {
- endpoints = [endpoints];
- }
-
for (var endpoint in endpoints) {
var currentEndpoint = endpoints[endpoint];
var currentEndpointName = currentEndpoint[Constants.XML_METADATA_MARKER].name;
View
77 lib/services/blob/blobservice.js
@@ -126,7 +126,7 @@ BlobService.prototype.getServiceProperties = function (optionsOrCallback, callba
var processResponseCallback = function (responseObject, next) {
responseObject.servicePropertiesResult = null;
if (!responseObject.error) {
- responseObject.servicePropertiesResult = ServicePropertiesResult.parse(responseObject.response.body);
+ responseObject.servicePropertiesResult = ServicePropertiesResult.parse(responseObject.response.body.StorageServiceProperties);
}
// function to be called after all filters
@@ -224,22 +224,14 @@ BlobService.prototype.listContainers = function (optionsOrCallback, callback) {
if (!responseObject.error) {
responseObject.listContainersResult = [];
- if (responseObject.response.body.Containers && responseObject.response.body.Containers.Container) {
- var containers = [];
- if (responseObject.response.body.Containers.Container) {
- containers = responseObject.response.body.Containers.Container;
-
- if (!Array.isArray(containers)) {
- containers = [containers];
- }
- }
-
+ if (responseObject.response.body.EnumerationResults.Containers && responseObject.response.body.EnumerationResults.Containers[0].Container) {
+ var containers = responseObject.response.body.EnumerationResults.Containers[0].Container;
containers.forEach(function (currentContainer) {
var containerResult = ContainerResult.parse(currentContainer);
responseObject.listContainersResult.push(containerResult);
});
- responseObject.listContainersResultContinuation = new ListContainersResultContinuation(self, options, responseObject.response.body.NextMarker);
+ responseObject.listContainersResultContinuation = new ListContainersResultContinuation(self, options, responseObject.response.body.EnumerationResults.NextMarker[0]);
}
}
@@ -328,6 +320,8 @@ BlobService.prototype.createContainerIfNotExists = function (container, optionsO
options = optionsOrCallback;
}
+ validateCallback(callback);
+
this.createContainer(container, options, function (error, responseContainer, response) {
if (error && error.code === Constants.BlobErrorCodeStrings.CONTAINER_ALREADY_EXISTS) {
// If it was created before, there was no actual error.
@@ -510,7 +504,7 @@ BlobService.prototype.getContainerAcl = function (container, optionsOrCallback,
if (!responseObject.error) {
responseObject.containerResult = new ContainerResult(container);
responseObject.containerResult.getPropertiesFromHeaders(responseObject.response.headers);
- responseObject.containerResult.signedIdentifiers = ContainerAclResult.parse(responseObject.response.body.SignedIdentifier);
+ responseObject.containerResult.signedIdentifiers = ContainerAclResult.parse(responseObject.response.body.SignedIdentifiers.SignedIdentifier);
}
var finalCallback = function (returnObject) {
@@ -669,11 +663,9 @@ BlobService.prototype.listBlobs = function (container, optionsOrCallback, callba
if (!responseObject.error) {
responseObject.listBlobsResult = [];
var blobs = [];
- if (responseObject.response.body.Blobs.Blob) {
- blobs = responseObject.response.body.Blobs.Blob;
- if (!Array.isArray(blobs)) {
- blobs = [blobs];
- }
+
+ if (responseObject.response.body.EnumerationResults.Blobs[0].Blob) {
+ blobs = responseObject.response.body.EnumerationResults.Blobs[0].Blob;
}
blobs.forEach(function (currentBlob) {
@@ -960,6 +952,7 @@ BlobService.prototype.createBlockBlobFromText = function (container, blob, text,
var processResponseCallback = function (responseObject, next) {
responseObject.blobResult = null;
+
if (!responseObject.error) {
responseObject.blobResult = new BlobResult(container, blob);
responseObject.blobResult.getPropertiesFromHeaders(responseObject.response.headers);
@@ -1894,17 +1887,14 @@ BlobService.prototype.listBlobRegions = function (container, blob, rangeStart, r
responseObject.pageRegions = [];
var pageRanges = [];
- if (responseObject.response.body.PageRange) {
- pageRanges = responseObject.response.body.PageRange;
- if (!Array.isArray(pageRanges)) {
- pageRanges = [pageRanges];
- }
+ if (responseObject.response.body.PageList.PageRange) {
+ pageRanges = responseObject.response.body.PageList.PageRange;
}
pageRanges.forEach(function (pageRange) {
var range = {
- start: parseInt(pageRange.Start, 10),
- end: parseInt(pageRange.End, 10)
+ start: parseInt(pageRange.Start[0], 10),
+ end: parseInt(pageRange.End[0], 10)
};
responseObject.pageRegions.push(range);
@@ -2131,7 +2121,7 @@ BlobService.prototype.listBlobBlocks = function (container, blob, blocklisttype,
var processResponseCallback = function (responseObject, next) {
responseObject.blockListResult = null;
if (!responseObject.error) {
- responseObject.blockListResult = BlockListResult.parse(responseObject.response.body);
+ responseObject.blockListResult = BlockListResult.parse(responseObject.response.body.BlockList);
}
var finalCallback = function (returnObject) {
@@ -2152,7 +2142,7 @@ BlobService.prototype.listBlobBlocks = function (container, blob, blocklisttype,
* @param {string} [blob] The blob name.
* @param {object} sharedAccessPolicy The shared access policy.
* @param {string} [sharedAccessPolicy.Id] The signed identifier.
-* @param {SharedAccessPermissions} sharedAccessPolicy.AccessPolicy.Permissions The permission type.
+* @param {object} [sharedAccessPolicy.AccessPolicy.Permissions] The permission type.
* @param {date|string} [sharedAccessPolicy.AccessPolicy.Start] The time at which the Shared Access Signature becomes valid (The UTC value will be used).
* @param {date|string} sharedAccessPolicy.AccessPolicy.Expiry The time at which the Shared Access Signature becomes expired (The UTC value will be used).
* @return {object} An object with the shared access signature.
@@ -2166,6 +2156,10 @@ BlobService.prototype.generateSharedAccessSignature = function (container, blob,
resourceType = BlobConstants.ResourceTypes.BLOB;
}
+ if (azureutil.objectIsNull(sharedAccessPolicy.AccessPolicy.Permissions)) {
+ sharedAccessPolicy.AccessPolicy.Permissions = BlobConstants.SharedAccessPermissions.READ;
+ }
+
if (!azureutil.objectIsNull(sharedAccessPolicy.AccessPolicy.Start)) {
sharedAccessPolicy.AccessPolicy.Start = ISO8061Date.format(sharedAccessPolicy.AccessPolicy.Start, true);
}
@@ -2196,24 +2190,29 @@ BlobService.prototype.generateSharedAccessSignature = function (container, blob,
* @this {BlobService}
* @param {string} container The container name.
* @param {string} [blob] The blob name.
+* @param {object} [sharedAccessPolicy] The shared access policy.
+* @param {string} [sharedAccessPolicy.Id] The signed identifier.
+* @param {object} [sharedAccessPolicy.AccessPolicy.Permissions] The permission type.
+* @param {date|string} [sharedAccessPolicy.AccessPolicy.Start] The time at which the Shared Access Signature becomes valid (The UTC value will be used).
+* @param {date|string} sharedAccessPolicy.AccessPolicy.Expiry The time at which the Shared Access Signature becomes expired (The UTC value will be used).
* @return {object} An object with the blob URL.
*/
-BlobService.prototype.getBlobUrl = function (container, blob) {
+BlobService.prototype.getBlobUrl = function (container, blob, sharedAccessPolicy) {
// Validate container name. Blob name is optional.
validateContainerName(container);
- var resourceName = createResourceName(container, blob);
-
- var baseUrl = this.protocol + this.host + ':' + this.port;
- var path = this._getPath('/' + resourceName);
+ var signedQueryString = {};
+ if (sharedAccessPolicy) {
+ signedQueryString = this.generateSharedAccessSignature(container, blob, sharedAccessPolicy).queryString;
+ }
- return {
- baseUrl: baseUrl,
- path: path,
- url: function () {
- return baseUrl + path;
- }
- };
+ return url.format({
+ protocol: this._isHttps() ? 'https:' : 'http:',
+ hostname: this.host,
+ port: this.port,
+ pathname: this._getPath('/' + createResourceName(container, blob)),
+ query: signedQueryString
+ });
};
// Private methods
View
16 lib/services/blob/models/blobresult.js
@@ -32,14 +32,16 @@ function BlobResult(container, blob) {
}
}
-BlobResult.parse = function (containerXml) {
+BlobResult.parse = function (blobXml) {
var blobResult = new BlobResult();
- for (var propertyName in containerXml) {
- if (propertyName.toLowerCase() === 'lastmodified') {
- blobResult.lastModified = containerXml[propertyName];
- }
- else {
- blobResult[propertyName.toLowerCase()] = containerXml[propertyName];
+ for (var propertyName in blobXml) {
+ if (propertyName === 'Properties' || propertyName === 'Metadata') {
+ blobResult[propertyName.toLowerCase()] = { };
+ for (var subPropertyName in blobXml[propertyName][0]) {
+ blobResult[propertyName.toLowerCase()][subPropertyName.toLowerCase()] = blobXml[propertyName][0][subPropertyName][0];
+ }
+ } else {
+ blobResult[propertyName.toLowerCase()] = blobXml[propertyName][0];
}
}
View
12 lib/services/blob/models/blocklistresult.js
@@ -76,16 +76,16 @@ BlockListResult.serialize = function (blockListJs) {
BlockListResult.parse = function (blockListXml) {
var blockListResult = new BlockListResult();
- if (blockListXml.CommittedBlocks && blockListXml.CommittedBlocks.Block && blockListXml.CommittedBlocks.Block.length > 0) {
- blockListResult.CommittedBlocks = blockListXml.CommittedBlocks.Block;
+ if (blockListXml.CommittedBlocks && blockListXml.CommittedBlocks[0].Block && blockListXml.CommittedBlocks[0].Block.length > 0) {
+ blockListResult.CommittedBlocks = blockListXml.CommittedBlocks[0].Block;
}
- if (blockListXml.UncommittedBlocks && blockListXml.UncommittedBlocks.Block && blockListXml.UncommittedBlocks.Block.length > 0) {
- blockListResult.UncommittedBlocks = blockListXml.UncommittedBlocks.Block;
+ if (blockListXml.UncommittedBlocks && blockListXml.UncommittedBlocks[0].Block && blockListXml.UncommittedBlocks[0].Block.length > 0) {
+ blockListResult.UncommittedBlocks = blockListXml.UncommittedBlocks[0].Block;
}
- if (blockListXml.LatestBlocks && blockListXml.Laassert.Block && blockListXml.Laassert.Block.length > 0) {
- blockListResult.LatestBlocks = blockListXml.Laassert.Block;
+ if (blockListXml.LatestBlocks && blockListXml.LatestBlocks[0].Block && blockListXml.LatestBlocks[0].Block.length > 0) {
+ blockListResult.LatestBlocks = blockListXml.LatestBlocks[0].Block;
}
return blockListResult;
View
30 lib/services/blob/models/containeraclresult.js
@@ -89,6 +89,32 @@ ContainerAclResult.serialize = function (signedIdentifiersJs) {
return doc.doc().toString();
};
-ContainerAclResult.parse = function (containerAclXml) {
- return containerAclXml;
+ContainerAclResult.parse = function (signedIdentifiersXml) {
+ var signedIdentifiers = [];
+
+ if (signedIdentifiersXml) {
+ signedIdentifiersXml.forEach(function (signedIdentifier) {
+ var si = {};
+ si.Id = signedIdentifier.Id[0];
+ if (signedIdentifier.AccessPolicy) {
+ si.AccessPolicy = {};
+
+ if (signedIdentifier.AccessPolicy[0].Start) {
+ si.AccessPolicy.Start = signedIdentifier.AccessPolicy[0].Start[0];
+ }
+
+ if (signedIdentifier.AccessPolicy[0].Expiry) {
+ si.AccessPolicy.Expiry = signedIdentifier.AccessPolicy[0].Expiry[0];
+ }
+
+ if (signedIdentifier.AccessPolicy[0].Permission) {
+ si.AccessPolicy.Permission = signedIdentifier.AccessPolicy[0].Permission[0];
+ }
+ }
+
+ signedIdentifiers.push(si);
+ });
+ }
+
+ return signedIdentifiers;
};
View
16 lib/services/blob/models/containerresult.js
@@ -36,15 +36,13 @@ function ContainerResult(name, publicAccessLevel) {
ContainerResult.parse = function (containerXml) {
var containerResult = new ContainerResult();
for (var propertyName in containerXml) {
- switch (propertyName.toLowerCase()) {
- case 'publicaccesslevel':
- containerResult.publicAccessLevel = containerXml[propertyName];
- break;
- case 'lastmodified':
- containerResult.lastModified = containerXml[propertyName];
- break;
- default:
- containerResult[propertyName.toLowerCase()] = containerXml[propertyName];
+ if (propertyName === 'Properties' || propertyName === 'Metadata') {
+ containerResult[propertyName.toLowerCase()] = { };
+ for (var subPropertyName in containerXml[propertyName][0]) {
+ containerResult[propertyName.toLowerCase()][subPropertyName.toLowerCase()] = containerXml[propertyName][0][subPropertyName][0];
+ }
+ } else {
+ containerResult[propertyName.toLowerCase()] = containerXml[propertyName][0];
}
}
View
51 lib/services/blob/models/servicepropertiesresult.js
@@ -124,66 +124,67 @@ ServicePropertiesResult.serialize = function (servicePropertiesJs) {
ServicePropertiesResult.parse = function (servicePropertiesXml) {
var serviceProperties = {};
+
if (servicePropertiesXml.Logging) {
serviceProperties.Logging = {};
- if (servicePropertiesXml.Logging.Version) {
- serviceProperties.Logging.Version = servicePropertiesXml.Logging.Version;
+ if (servicePropertiesXml.Logging[0].Version) {
+ serviceProperties.Logging.Version = servicePropertiesXml.Logging[0].Version[0];
}
- if (servicePropertiesXml.Logging.Delete) {
- serviceProperties.Logging.Delete = servicePropertiesXml.Logging.Delete === 'true';
+ if (servicePropertiesXml.Logging[0].Delete) {
+ serviceProperties.Logging.Delete = servicePropertiesXml.Logging[0].Delete[0] === 'true';
}
- if (servicePropertiesXml.Logging.Read) {
- serviceProperties.Logging.Read = servicePropertiesXml.Logging.Read === 'true';
+ if (servicePropertiesXml.Logging[0].Read) {
+ serviceProperties.Logging.Read = servicePropertiesXml.Logging[0].Read[0] === 'true';
}
- if (servicePropertiesXml.Logging.Write) {
- serviceProperties.Logging.Write = servicePropertiesXml.Logging.Write === 'true';
+ if (servicePropertiesXml.Logging[0].Write) {
+ serviceProperties.Logging.Write = servicePropertiesXml.Logging[0].Write[0] === 'true';
}
- if (servicePropertiesXml.Logging.RetentionPolicy) {
+ if (servicePropertiesXml.Logging[0].RetentionPolicy) {
serviceProperties.Logging.RetentionPolicy = {};
- if (servicePropertiesXml.Logging.RetentionPolicy.Enabled) {
- serviceProperties.Logging.RetentionPolicy.Enabled = servicePropertiesXml.Logging.RetentionPolicy.Enabled === 'true';
+ if (servicePropertiesXml.Logging[0].RetentionPolicy[0].Enabled) {
+ serviceProperties.Logging.RetentionPolicy.Enabled = servicePropertiesXml.Logging[0].RetentionPolicy[0].Enabled[0] === 'true';
}
- if (servicePropertiesXml.Logging.RetentionPolicy.Days) {
- serviceProperties.Logging.RetentionPolicy.Days = parseInt(servicePropertiesXml.Logging.RetentionPolicy.Days, 10);
+ if (servicePropertiesXml.Logging[0].RetentionPolicy[0].Days) {
+ serviceProperties.Logging.RetentionPolicy.Days = parseInt(servicePropertiesXml.Logging[0].RetentionPolicy[0].Days[0], 10);
}
}
}
if (servicePropertiesXml.Metrics) {
serviceProperties.Metrics = {};
- if (servicePropertiesXml.Metrics.Version) {
- serviceProperties.Metrics.Version = servicePropertiesXml.Metrics.Version;
+ if (servicePropertiesXml.Metrics[0].Version) {
+ serviceProperties.Metrics.Version = servicePropertiesXml.Metrics[0].Version[0];
}
- if (servicePropertiesXml.Metrics.Enabled) {
- serviceProperties.Metrics.Enabled = servicePropertiesXml.Metrics.Enabled === 'true';
+ if (servicePropertiesXml.Metrics[0].Enabled) {
+ serviceProperties.Metrics.Enabled = servicePropertiesXml.Metrics[0].Enabled[0] === 'true';
}
- if (servicePropertiesXml.Metrics.IncludeAPIs) {
- serviceProperties.Metrics.IncludeAPIs = servicePropertiesXml.Metrics.IncludeAPIs === 'true';
+ if (servicePropertiesXml.Metrics[0].IncludeAPIs) {
+ serviceProperties.Metrics.IncludeAPIs = servicePropertiesXml.Metrics[0].IncludeAPIs[0] === 'true';
}
- if (servicePropertiesXml.Metrics.RetentionPolicy) {
+ if (servicePropertiesXml.Metrics[0].RetentionPolicy) {
serviceProperties.Metrics.RetentionPolicy = {};
- if (servicePropertiesXml.Metrics.RetentionPolicy.Enabled) {
- serviceProperties.Metrics.RetentionPolicy.Enabled = servicePropertiesXml.Metrics.RetentionPolicy.Enabled === 'true';
+ if (servicePropertiesXml.Metrics[0].RetentionPolicy[0].Enabled) {
+ serviceProperties.Metrics.RetentionPolicy.Enabled = servicePropertiesXml.Metrics[0].RetentionPolicy[0].Enabled[0] === 'true';
}
- if (servicePropertiesXml.Metrics.RetentionPolicy.Days) {
- serviceProperties.Metrics.RetentionPolicy.Days = parseInt(servicePropertiesXml.Metrics.RetentionPolicy.Days, 10);
+ if (servicePropertiesXml.Metrics[0].RetentionPolicy[0].Days) {
+ serviceProperties.Metrics.RetentionPolicy.Days = parseInt(servicePropertiesXml.Metrics[0].RetentionPolicy[0].Days[0], 10);
}
}
}
if (servicePropertiesXml.DefaultServiceVersion) {
- serviceProperties.DefaultServiceVersion = servicePropertiesXml.DefaultServiceVersion;
+ serviceProperties.DefaultServiceVersion = servicePropertiesXml.DefaultServiceVersion[0];
}
return serviceProperties;
View
82 lib/services/core/serviceclient.js
@@ -29,6 +29,9 @@ var HeaderConstants = Constants.HeaderConstants;
var HttpConstants = Constants.HttpConstants;
var Logger = require('../../diagnostics/logger');
+var moduleVersion = require('../../../package.json').version;
+var operatingSystem = process.platform;
+
// Expose 'ServiceClient'.
exports = module.exports = ServiceClient;
@@ -72,6 +75,7 @@ ServiceClient.CLOUD_TABLE_HOST = 'table.core.windows.net';
ServiceClient.CLOUD_SERVICEBUS_HOST = 'servicebus.windows.net';
ServiceClient.CLOUD_ACCESS_CONTROL_HOST = 'accesscontrol.windows.net';
ServiceClient.CLOUD_SERVICE_MANAGEMENT_HOST = 'management.core.windows.net';
+ServiceClient.CLOUD_DATABASE_HOST = 'database.windows.net';
/**
* The default service bus issuer.
@@ -106,20 +110,7 @@ function ServiceClient(host, authenticationProvider) {
this._initDefaultFilter();
if (host) {
- var parsedHost = ServiceClient._parseHost(host);
- this.host = parsedHost.hostname;
-
- if (parsedHost.port) {
- this.port = parsedHost.port;
- } else if (parsedHost.protocol === 'https:') {
- this.port = 443;
- } else {
- this.port = 80;
- }
-
- if (!this.protocol) {
- this.protocol = parsedHost.protocol + '//';
- }
+ this.setHost(host);
} else if (!this.protocol) {
this.protocol = ServiceClient.DEFAULT_PROTOCOL;
}
@@ -130,11 +121,35 @@ function ServiceClient(host, authenticationProvider) {
this.proxyProtocol = 'http:'
this.authenticationProvider = authenticationProvider;
this.logger = new Logger(Logger.LogLevels.INFO);
+
+ this.xml2jsVersion = '0.2';
}
util.inherits(ServiceClient, events.EventEmitter);
/**
+* Sets a host for the service.
+*
+* @param {string} host The host for the service.
+*/
+ServiceClient.prototype.setHost = function (host) {
+ var parsedHost = ServiceClient._parseHost(host);
+ this.host = parsedHost.hostname;
+
+ if (parsedHost.port) {
+ this.port = parsedHost.port;
+ } else if (parsedHost.protocol === 'https:') {
+ this.port = 443;
+ } else {
+ this.port = 80;
+ }
+
+ if (!this.protocol) {
+ this.protocol = parsedHost.protocol + '//';
+ }
+}
+
+/**
* Performs a REST service request through HTTP expecting an input stream.
*
* @param {WebResource} webResource The webresource on which to perform the request.
@@ -194,6 +209,8 @@ ServiceClient.prototype._performRequest = function (webResource, body, options,
finalCallback(requestOptions);
});
} else {
+ self._tagRequest(requestOptions);
+
self.logger.log(Logger.LogLevels.DEBUG, "REQUEST OPTIONS:\n" + util.inspect(requestOptions));
var operation = function (finalRequestOptions, operationCallback, next) {
@@ -272,6 +289,14 @@ ServiceClient.prototype._performRequest = function (webResource, body, options,
});
};
+ServiceClient.prototype._tagRequest = function (requestOptions) {
+ if (!this.userAgent) {
+ this.userAgent = util.format('Windows Azure SDK/%s (Node.js; %s)', moduleVersion, operatingSystem);
+ }
+
+ requestOptions.headers[HeaderConstants.USER_AGENT] = this.userAgent;
+};
+
/**
* Process the response.
*
@@ -484,7 +509,13 @@ ServiceClient.prototype._parseResponse = function (response) {
parsedBody = { parsingError: error };
}
} else {
- var parser = new xml2js.Parser({normalize: false, trim: false});
+ var settings = xml2js.defaults[this.xml2jsVersion];
+ settings.normalize = false;
+ settings.trim = false;
+ settings.attrkey = Constants.XML_METADATA_MARKER;
+ settings.charkey = Constants.XML_VALUE_MARKER;
+
+ var parser = new xml2js.Parser(settings);
var parseError = null;
parser.on('error', function (e) { parseError = e; });
parser.parseString(response.body);
@@ -506,15 +537,15 @@ ServiceClient.prototype._parseResponse = function (response) {
}
var codeMessage = response.body.substr(codeIndex + 5, endIndex - codeIndex - 1);
- resultObject['code'] = codeMessage;
+ resultObject['code'] = [ codeMessage ];
var detailIndex = response.body.indexOf('detail:');
if (detailIndex !== -1) {
var detailMessage = response.body.substr(detailIndex + 7);
- resultObject['detail'] = detailMessage;
+ resultObject['detail'] = [ detailMessage ];
}
- parsedBody = resultObject;
+ parsedBody = { Error: resultObject };
}
}
@@ -625,21 +656,24 @@ ServiceClient.isEmulated = function (host) {
ServiceClient.prototype._normalizeError = function (error) {
if (azureutil.objectIsString(error)) {
return new Error(error);
- } else {
+ } else if (error) {
var normalizedError = new Error();
- for (var property in error) {
- if (property !== '@') {
- if (error[property] && error[property]['#']) {
- normalizedError[property.toLowerCase()] = error[property]['#'];
+ var errorProperties = error.Error || error.error;
+ for (var property in errorProperties) {
+ if (property !== Constants.XML_METADATA_MARKER) {
+ if (errorProperties[property] && errorProperties[property][Constants.XML_VALUE_MARKER]) {
+ normalizedError[property.toLowerCase()] = errorProperties[property][Constants.XML_VALUE_MARKER][0];
} else {
- normalizedError[property.toLowerCase()] = error[property];
+ normalizedError[property.toLowerCase()] = errorProperties[property][0];
}
}
}
return normalizedError;
}
+
+ return null;
};
/**
View
2  lib/services/core/servicemanagementclient.js
@@ -41,7 +41,7 @@ ServiceManagementClient.DefaultAPIVersion = '2012-03-01';
ServiceManagementClient.DefaultSerializeType = 'JSON';
/**
-* Creates a new ServiceClient object.
+* Creates a new ServiceManagementClient object.
*
* @constructor
* @param {string} hostOptions The host options to override defaults.
View
125 lib/services/core/sqlserviceclient.js
@@ -0,0 +1,125 @@
+/**
+* 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.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+// Module dependencies.
+var util = require('util');
+var url = require('url');
+
+var azureutil = require('../../util/util');
+
+var ServiceClient = require('./serviceclient');
+var SqlServerAcs = require('../sqlAzure/sqlserveracs');
+var Constants = require('../../util/constants');
+var HeaderConstants = Constants.HeaderConstants;
+var QueryStringConstants = Constants.QueryStringConstants;
+var HttpConstants = Constants.HttpConstants;
+
+// Expose 'SqlServiceClient'.
+exports = module.exports = SqlServiceClient;
+
+/**
+* Creates a new SqlServiceClient object.
+*
+* @constructor
+* @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. Usually the same as the sb namespace with "-sb" suffix.
+* @param {object} [authenticationProvider] The authentication provider.
+*/
+function SqlServiceClient(serverName, administratorLogin, administratorLoginPassword, host, acsHost, authenticationProvider) {
+ SqlServiceClient.super_.call(this, host, authenticationProvider);
+
+ this.authenticationProvider = authenticationProvider;
+ if (!this.authenticationProvider) {
+ this.authenticationProvider = new SqlServerAcs(acsHost, serverName, administratorLogin, administratorLoginPassword);
+ }
+}
+
+util.inherits(SqlServiceClient, ServiceClient);
+
+/**
+* Builds the request options to be passed to the http.request method.
+*
+* @param {WebResource} webResource The webresource where to build the options from.
+* @param {object} options The request options.
+* @param {function(error, requestOptions)} callback The callback function.
+*/
+SqlServiceClient.prototype._buildRequestOptions = function (webResource, options, callback) {
+ var self = this;
+
+ if (!webResource.headers || !webResource.headers[HeaderConstants.CONTENT_TYPE]) {
+ webResource.addOptionalHeader(HeaderConstants.CONTENT_TYPE, '');
+ }
+
+ if (!webResource.headers || !webResource.headers[HeaderConstants.CONTENT_LENGTH]) {
+ webResource.addOptionalHeader(HeaderConstants.CONTENT_LENGTH, 0);
+ }
+
+ webResource.addOptionalHeader(HeaderConstants.ACCEPT_CHARSET_HEADER, 'UTF-8');
+ webResource.addOptionalHeader(HeaderConstants.HOST_HEADER, this.host + ':' + this.port);
+
+ // Sets the request url in the web resource.
+ this._setRequestUrl(webResource);
+
+ // If wrap is used, make sure proxy settings are in sync
+ if (this.useProxy &&
+ this.authenticationProvider &&
+ this.authenticationProvider.wrapTokenManager &&
+ this.authenticationProvider.wrapTokenManager.wrapService) {
+ this.authenticationProvider.wrapTokenManager.wrapService.setProxy(this.proxyUrl, this.proxyPort);
+ }
+
+ // Now that the web request is finalized, sign it
+ this.authenticationProvider.signRequest(webResource, function (error) {
+ var requestOptions = null;
+
+ if (!error) {
+ requestOptions = {
+ url: url.format({
+ protocol: self._isHttps() ? 'https:' : 'http:',
+ hostname: self.host,
+ port: self.port,
+ pathname: webResource.path + webResource.getQueryString(true)
+ }),
+ method: webResource.httpVerb,
+ headers: webResource.headers
+ };
+
+ self._setRequestOptionsProxy(requestOptions);
+ }
+
+ callback(error, requestOptions);
+ });
+};
+
+/**
+* Retrieves the normalized path to be used in a request.
+* It adds a leading "/" to the path in case
+* it's not there before.
+*
+* @param {string} path The path to be normalized.
+* @return {string} The normalized path.
+*/
+SqlServiceClient.prototype._getPath = function (path) {
+ if (path === null || path === undefined) {
+ path = '/';
+ } else if (path.indexOf('/') !== 0) {
+ path = '/' + path;
+ }
+
+ return path;
+};
View
4 lib/services/queue/models/queuemessageresult.js
@@ -66,9 +66,9 @@ QueueMessageResult.parse = function (messageXml) {
var queueMessageResult = new QueueMessageResult();
for (var property in messageXml) {
if (property === Constants.MESSAGE_TEXT_ELEMENT) {
- queueMessageResult.messagetext = new Buffer(messageXml[property], 'base64').toString();
+ queueMessageResult.messagetext = new Buffer(messageXml[property][0], 'base64').toString();
} else {
- queueMessageResult[property.toLowerCase()] = messageXml[property];
+ queueMessageResult[property.toLowerCase()] = messageXml[property][0];
}
}
View
2  lib/services/queue/models/queueresult.js
@@ -33,7 +33,7 @@ function QueueResult(name, metadata) {
QueueResult.parse = function (messageXml) {
var queueResult = new QueueResult();
for (var property in messageXml) {
- queueResult[property.toLowerCase()] = messageXml[property];
+ queueResult[property.toLowerCase()] = messageXml[property][0];
}
return queueResult;
View
48 lib/services/queue/models/servicepropertiesresult.js
@@ -120,58 +120,58 @@ ServicePropertiesResult.parse = function (servicePropertiesXml) {
var serviceProperties = {};
if (servicePropertiesXml.Logging) {
serviceProperties.Logging = {};
- if (servicePropertiesXml.Logging.Version) {
- serviceProperties.Logging.Version = servicePropertiesXml.Logging.Version;
+ if (servicePropertiesXml.Logging[0].Version) {
+ serviceProperties.Logging.Version = servicePropertiesXml.Logging[0].Version[0];
}
- if (servicePropertiesXml.Logging.Delete) {
- serviceProperties.Logging.Delete = servicePropertiesXml.Logging.Delete === 'true';
+ if (servicePropertiesXml.Logging[0].Delete) {
+ serviceProperties.Logging.Delete = servicePropertiesXml.Logging[0].Delete[0] === 'true';
}
- if (servicePropertiesXml.Logging.Read) {
- serviceProperties.Logging.Read = servicePropertiesXml.Logging.Read === 'true';
+ if (servicePropertiesXml.Logging[0].Read) {
+ serviceProperties.Logging.Read = servicePropertiesXml.Logging[0].Read[0] === 'true';
}
- if (servicePropertiesXml.Logging.Write) {
- serviceProperties.Logging.Write = servicePropertiesXml.Logging.Write === 'true';
+ if (servicePropertiesXml.Logging[0].Write) {
+ serviceProperties.Logging.Write = servicePropertiesXml.Logging[0].Write[0] === 'true';
}
- if (servicePropertiesXml.Logging.RetentionPolicy) {
+ if (servicePropertiesXml.Logging[0].RetentionPolicy) {
serviceProperties.Logging.RetentionPolicy = {};
- if (servicePropertiesXml.Logging.RetentionPolicy.Enabled) {
- serviceProperties.Logging.RetentionPolicy.Enabled = servicePropertiesXml.Logging.RetentionPolicy.Enabled === 'true';
+ if (servicePropertiesXml.Logging[0].RetentionPolicy[0].Enabled) {
+ serviceProperties.Logging.RetentionPolicy.Enabled = servicePropertiesXml.Logging[0].RetentionPolicy[0].Enabled[0] === 'true';
}
- if (servicePropertiesXml.Logging.RetentionPolicy.Days) {
- serviceProperties.Logging.RetentionPolicy.Days = parseInt(servicePropertiesXml.Logging.RetentionPolicy.Days, 10);
+ if (servicePropertiesXml.Logging[0].RetentionPolicy[0].Days) {
+ serviceProperties.Logging.RetentionPolicy.Days = parseInt(servicePropertiesXml.Logging[0].RetentionPolicy[0].Days[0], 10);
}
}
}
if (servicePropertiesXml.Metrics) {
serviceProperties.Metrics = {};
- if (servicePropertiesXml.Metrics.Version) {
- serviceProperties.Metrics.Version = servicePropertiesXml.Metrics.Version;
+ if (servicePropertiesXml.Metrics[0].Version) {
+ serviceProperties.Metrics.Version = servicePropertiesXml.Metrics[0].Version[0];
}
- if (servicePropertiesXml.Metrics.Enabled) {
- serviceProperties.Metrics.Enabled = servicePropertiesXml.Metrics.Enabled === 'true';
+ if (servicePropertiesXml.Metrics[0].Enabled) {
+ serviceProperties.Metrics.Enabled = servicePropertiesXml.Metrics[0].Enabled[0] === 'true';
}
- if (servicePropertiesXml.Metrics.IncludeAPIs) {
- serviceProperties.Metrics.IncludeAPIs = servicePropertiesXml.Metrics.IncludeAPIs === 'true';
+ if (servicePropertiesXml.Metrics[0].IncludeAPIs) {
+ serviceProperties.Metrics.IncludeAPIs = servicePropertiesXml.Metrics[0].IncludeAPIs[0] === 'true';
}
- if (servicePropertiesXml.Metrics.RetentionPolicy) {
+ if (servicePropertiesXml.Metrics[0].RetentionPolicy) {
serviceProperties.Metrics.RetentionPolicy = {};
- if (servicePropertiesXml.Metrics.RetentionPolicy.Enabled) {
- serviceProperties.Metrics.RetentionPolicy.Enabled = servicePropertiesXml.Metrics.RetentionPolicy.Enabled === 'true';
+ if (servicePropertiesXml.Metrics[0].RetentionPolicy[0].Enabled) {
+ serviceProperties.Metrics.RetentionPolicy.Enabled = servicePropertiesXml.Metrics[0].RetentionPolicy[0].Enabled[0] === 'true';
}
- if (servicePropertiesXml.Metrics.RetentionPolicy.Days) {
- serviceProperties.Metrics.RetentionPolicy.Days = parseInt(servicePropertiesXml.Metrics.RetentionPolicy.Days, 10);
+ if (servicePropertiesXml.Metrics[0].RetentionPolicy[0].Days) {
+ serviceProperties.Metrics.RetentionPolicy.Days = parseInt(servicePropertiesXml.Metrics[0].RetentionPolicy[0].Days[0], 10);
}
}
}
View
25 lib/services/queue/queueservice.js
@@ -93,7 +93,7 @@ QueueService.prototype.getServiceProperties = function (optionsOrCallback, callb
var processResponseCallback = function (responseObject, next) {
responseObject.servicePropertiesResult = null;
if (!responseObject.error) {
- responseObject.servicePropertiesResult = ServicePropertiesResult.parse(responseObject.response.body);
+ responseObject.servicePropertiesResult = ServicePropertiesResult.parse(responseObject.response.body.StorageServiceProperties);
}
var finalCallback = function (returnObject) {
@@ -186,21 +186,15 @@ QueueService.prototype.listQueues = function (optionsOrCallback, callback) {
if (!responseObject.error) {
responseObject.listQueueResult = [];
- if (responseObject.response.body.Queues.Queue) {
- var queues = [];
- if (responseObject.response.body.Queues.Queue) {
- queues = responseObject.response.body.Queues.Queue;
- if (!Array.isArray(queues)) {
- queues = [queues];
- }
- }
+ if (responseObject.response.body.EnumerationResults.Queues && responseObject.response.body.EnumerationResults.Queues[0].Queue) {
+ var queues = responseObject.response.body.EnumerationResults.Queues[0].Queue;
queues.forEach(function (currentQueue) {
var queueResult = QueueResult.parse(currentQueue);
responseObject.listQueueResult.push(queueResult);
});
- responseObject.listQueueResultContinuation = new ListQueuesResultContinuation(self, options, responseObject.response.body.NextMarker);
+ responseObject.listQueueResultContinuation = new ListQueuesResultContinuation(self, options, responseObject.response.body.EnumerationResults.NextMarker[0]);
}
}
@@ -516,15 +510,8 @@ QueueService.prototype.getMessages = function (queue, optionsOrCallback, callbac
if (!responseObject.error) {
responseObject.queueMessageResults = [];
- if (responseObject.response.body.QueueMessage) {
- var messages = [];
- if (responseObject.response.body.QueueMessage) {
- messages = responseObject.response.body.QueueMessage;
-
- if (!Array.isArray(messages)) {
- messages = [messages];
- }
- }
+ if (responseObject.response.body.QueueMessagesList && responseObject.response.body.QueueMessagesList.QueueMessage) {
+ var messages = responseObject.response.body.QueueMessagesList.QueueMessage;
messages.forEach(function (message) {
var queueMessageResult = QueueMessageResult.parse(message);
View
28 lib/services/serviceBus/models/queueresult.js
@@ -31,25 +31,12 @@ function QueueResult() { }
QueueResult.serialize = function (path, queue) {
var queueDescription = {
- '@': {
+ '$': {
'xmlns:i': 'http://www.w3.org/2001/XMLSchema-instance',
'xmlns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'
}
};
- var atomQueue = {
- 'title': '',
- 'updated': ISO8061Date.format(new Date()),
- 'author': {
- name: ''
- },
- 'id': '',
- 'content': {
- '@': { type: 'application/xml' },
- QueueDescription: queueDescription
- }
- };
-
if (queue) {
if (queue[ServiceBusConstants.LOCK_DURATION]) {
queueDescription[ServiceBusConstants.LOCK_DURATION] = queue[ServiceBusConstants.LOCK_DURATION];
@@ -96,6 +83,19 @@ QueueResult.serialize = function (path, queue) {
}
}
+ var atomQueue = {
+ 'title': '',
+ 'updated': ISO8061Date.format(new Date()),
+ 'author': {
+ name: ''
+ },
+ 'id': '',
+ 'content': {
+ '$': { type: 'application/xml' },
+ QueueDescription: queueDescription
+ }
+ };
+
var atomHandler = new AtomHandler(null, null);
var xml = atomHandler.serialize(atomQueue);
View
44 lib/services/serviceBus/models/ruleresult.js
@@ -28,32 +28,17 @@ function RuleResult() { }
RuleResult.serialize = function (name, path, rule) {
var ruleDescription = {
- '@': {
+ '$': {
'xmlns:i': 'http://www.w3.org/2001/XMLSchema-instance',
'xmlns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'
}
};
- var atomRule = {
- 'title': {
- '@': {
- 'type': 'text'
- },
- '#': name
- },
- 'updated': ISO8061Date.format(new Date()),
- 'id': '',
- 'content': {
- '@': { type: 'application/xml' },
- RuleDescription: ruleDescription
- }
- };
-
if (rule) {
var filters = [];
if (rule.sqlExpressionFilter) {
var sqlFilter = {
- '@': {
+ '$': {
'i:type': 'SqlFilter'
},
SqlExpression: rule.sqlExpressionFilter,
@@ -63,7 +48,7 @@ RuleResult.serialize = function (name, path, rule) {
filters.push(sqlFilter);
} else if (rule.correlationIdFilter) {
var correlationFilter = {
- '@': {
+ '$': {
'i:type': 'CorrelationFilter'
},
CorrelationId: rule.correlationIdFilter
@@ -72,7 +57,7 @@ RuleResult.serialize = function (name, path, rule) {
filters.push(correlationFilter);
} else if (rule.trueFilter) {
var trueFilter = {
- '@': {
+ '$': {
'i:type': 'TrueFilter'
},
SqlExpression: rule.trueFilter,
@@ -82,7 +67,7 @@ RuleResult.serialize = function (name, path, rule) {
filters.push(trueFilter);
} else if (rule.falseFilter) {
var falseFilter = {
- '@': {
+ '$': {
'i:type': 'FalseFilter'
},
SqlExpression: rule.falseFilter,
@@ -100,7 +85,7 @@ RuleResult.serialize = function (name, path, rule) {
if (rule.sqlRuleAction) {
var sqlAction = {
- '@': {
+ '$': {
'i:type': 'SqlFilterExpression'
},
SqlExpression: rule.sqlRuleAction
@@ -109,7 +94,7 @@ RuleResult.serialize = function (name, path, rule) {
actions.push(sqlAction);
} else {
var emptyRuleAction = {
- '@': {
+ '$': {
'i:type': 'EmptyRuleAction'
}
};
@@ -122,6 +107,21 @@ RuleResult.serialize = function (name, path, rule) {
}
}
+ var atomRule = {
+ 'title': {
+ '$': {
+ 'type': 'text'
+ },
+ '_': name
+ },
+ 'updated': ISO8061Date.format(new Date()),
+ 'id': '',
+ 'content': {
+ '$': { type: 'application/xml' },
+ RuleDescription: ruleDescription
+ }
+ };
+
var atomHandler = new AtomHandler(null, null);
var xml = atomHandler.serialize(atomRule);
return xml;
View
28 lib/services/serviceBus/models/subscriptionresult.js
@@ -29,25 +29,12 @@ function SubscriptionResult() { }
SubscriptionResult.serialize = function (path, subscription) {
var subscriptionDescription = {
- '@': {
+ '$': {
'xmlns:i': 'http://www.w3.org/2001/XMLSchema-instance',
'xmlns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'
}
};
- var atomQueue = {
- 'title': '',
- 'updated': ISO8061Date.format(new Date()),
- 'author': {
- name: ''
- },
- 'id': '',
- 'content': {
- '@': { type: 'application/xml' },
- SubscriptionDescription: subscriptionDescription
- }
- };
-
if (subscription) {
if (subscription[ServiceBusConstants.LOCK_DURATION]) {
subscriptionDescription[ServiceBusConstants.LOCK_DURATION] = subscription[ServiceBusConstants.LOCK_DURATION];
@@ -86,6 +73,19 @@ SubscriptionResult.serialize = function (path, subscription) {
}
}
+ var atomQueue = {
+ 'title': '',
+ 'updated': ISO8061Date.format(new Date()),
+ 'author': {
+ name: ''
+ },
+ 'id': '',
+ 'content': {
+ '$': { type: 'application/xml' },
+ SubscriptionDescription: subscriptionDescription
+ }
+ };
+
var atomHandler = new AtomHandler(null, null);
var xml = atomHandler.serialize(atomQueue);
View
28 lib/services/serviceBus/models/topicresult.js
@@ -29,25 +29,12 @@ function TopicResult() { }
TopicResult.serialize = function (path, topic) {
var topicDescription = {
- '@': {
+ '$': {
'xmlns:i': 'http://www.w3.org/2001/XMLSchema-instance',
'xmlns': 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'
}
};
- var atomQueue = {
- 'title': '',
- 'updated': ISO8061Date.format(new Date()),
- 'author': {
- name: ''
- },
- 'id': '',
- 'content': {
- '@': { type: 'application/xml' },
- TopicDescription: topicDescription
- }
- };
-
if (topic) {
if (topic[ServiceBusConstants.DEFAULT_MESSAGE_TIME_TO_LIVE]) {
topicDescription[ServiceBusConstants.DEFAULT_MESSAGE_TIME_TO_LIVE] = topic[ServiceBusConstants.DEFAULT_MESSAGE_TIME_TO_LIVE];
@@ -74,6 +61,19 @@ TopicResult.serialize = function (path, topic) {
}
}
+ var atomQueue = {
+ 'title': '',
+ 'updated': ISO8061Date.format(new Date()),
+ 'author': {
+ name: ''
+ },
+ 'id': '',
+ 'content': {
+ '$': { type: 'application/xml' },
+ TopicDescription: topicDescription
+ }
+ };
+
var atomHandler = new AtomHandler(null, null);
var xml = atomHandler.serialize(atomQueue);
return xml;
View
134 lib/services/serviceBus/servicebusservice.js
@@ -399,7 +399,7 @@ ServiceBusService.prototype.createQueue = function (queuePath, optionsOrCallback
var processResponseCallback = function (responseObject, next) {
if (!responseObject.error) {
- responseObject.queue = QueueResult.parse(responseObject.response.body);
+ responseObject.queue = QueueResult.parse(responseObject.response.body.entry);
}
var finalCallback = function (returnObject) {
@@ -448,11 +448,13 @@ ServiceBusService.prototype.createQueueIfNotExists = function (queuePath, option
var processResponseCallback = function (responseObject, next) {
// Check if queue was actually created.
- responseObject.created = (responseObject.response.statusCode === HttpConstants.HttpResponseCodes.CREATED_CODE);
+ if (!responseObject.error) {
+ responseObject.created = (responseObject.response.statusCode === HttpConstants.HttpResponseCodes.CREATED_CODE);
- if (responseObject.response.statusCode === HttpConstants.HttpResponseCodes.CREATED_CODE || responseObject.response.statusCode === HttpConstants.HttpResponseCodes.CONFLICT_CODE) {
- // If it was created before, there was no actual error.
- responseObject.error = null;
+ if (responseObject.response.statusCode === HttpConstants.HttpResponseCodes.CREATED_CODE || responseObject.response.statusCode === HttpConstants.HttpResponseCodes.CONFLICT_CODE) {
+ // If it was created before, there was no actual error.
+ responseObject.error = null;
+ }
}
var finalCallback = function (returnObject) {
@@ -505,14 +507,13 @@ ServiceBusService.prototype.getQueue = function (queuePath, callback) {
var processResponseCallback = function (responseObject, next) {
if (!responseObject.error) {
- var queue = QueueResult.parse(responseObject.response.body);
- if (queue.QueueName !== queuePath) {
+ if (!(responseObject.response.body && responseObject.response.body.entry)) {
responseObject.error = {
code: Constants.ServiceBusErrorCodeStrings.QUEUE_NOT_FOUND,