@autorest/powershell 3.0.504 → 4.0.0-dev.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (306) hide show
  1. package/.rush/temp/package-deps_build.json +95 -61
  2. package/.rush/temp/shrinkwrap-deps.json +249 -193
  3. package/autorest-configuration-for-sdk.md +122 -0
  4. package/autorest-configuration.md +2 -1
  5. package/dist/cmdlets/class.d.ts +1 -0
  6. package/dist/cmdlets/class.d.ts.map +1 -1
  7. package/dist/cmdlets/class.js +220 -90
  8. package/dist/cmdlets/class.js.map +1 -1
  9. package/dist/cmdlets/namespace.d.ts.map +1 -1
  10. package/dist/cmdlets/namespace.js +3 -1
  11. package/dist/cmdlets/namespace.js.map +1 -1
  12. package/dist/cmdlets/parameter.js +1 -0
  13. package/dist/cmdlets/parameter.js.map +1 -1
  14. package/dist/enums/namespace.js +2 -1
  15. package/dist/enums/namespace.js.map +1 -1
  16. package/dist/file-formats/md-file.js +1 -0
  17. package/dist/file-formats/md-file.js.map +1 -1
  18. package/dist/file-formats/psd-file.js +1 -0
  19. package/dist/file-formats/psd-file.js.map +1 -1
  20. package/dist/file-formats/psscript-file.js +1 -0
  21. package/dist/file-formats/psscript-file.js.map +1 -1
  22. package/dist/generators/csproj.js +1 -0
  23. package/dist/generators/csproj.js.map +1 -1
  24. package/dist/generators/gitattributes.js +1 -0
  25. package/dist/generators/gitattributes.js.map +1 -1
  26. package/dist/generators/gitignore.js +1 -0
  27. package/dist/generators/gitignore.js.map +1 -1
  28. package/dist/generators/inputhandler.custom.d.ts +3 -0
  29. package/dist/generators/inputhandler.custom.d.ts.map +1 -0
  30. package/dist/generators/inputhandler.custom.js +33 -0
  31. package/dist/generators/inputhandler.custom.js.map +1 -0
  32. package/dist/generators/nuspec.js +1 -0
  33. package/dist/generators/nuspec.js.map +1 -1
  34. package/dist/generators/psm1.custom.js +1 -0
  35. package/dist/generators/psm1.custom.js.map +1 -1
  36. package/dist/generators/psm1.internal.js +1 -0
  37. package/dist/generators/psm1.internal.js.map +1 -1
  38. package/dist/generators/psm1.js +2 -1
  39. package/dist/generators/psm1.js.map +1 -1
  40. package/dist/generators/readme.js +1 -0
  41. package/dist/generators/readme.js.map +1 -1
  42. package/dist/generators/script-cmdlet.js +3 -2
  43. package/dist/generators/script-cmdlet.js.map +1 -1
  44. package/dist/internal/name-inferrer.js +1 -0
  45. package/dist/internal/name-inferrer.js.map +1 -1
  46. package/dist/internal/powershell-declarations.d.ts +3 -0
  47. package/dist/internal/powershell-declarations.d.ts.map +1 -1
  48. package/dist/internal/powershell-declarations.js +3 -0
  49. package/dist/internal/powershell-declarations.js.map +1 -1
  50. package/dist/internal/project.d.ts +11 -9
  51. package/dist/internal/project.d.ts.map +1 -1
  52. package/dist/internal/project.js +30 -12
  53. package/dist/internal/project.js.map +1 -1
  54. package/dist/internal/state.js +1 -0
  55. package/dist/internal/state.js.map +1 -1
  56. package/dist/internal/verbs.js +1 -0
  57. package/dist/internal/verbs.js.map +1 -1
  58. package/dist/llcsharp/clientruntime.d.ts +7 -1
  59. package/dist/llcsharp/clientruntime.d.ts.map +1 -1
  60. package/dist/llcsharp/clientruntime.js +8 -1
  61. package/dist/llcsharp/clientruntime.js.map +1 -1
  62. package/dist/llcsharp/code-model.d.ts +1 -0
  63. package/dist/llcsharp/code-model.d.ts.map +1 -1
  64. package/dist/llcsharp/csharp-declarations.js +1 -0
  65. package/dist/llcsharp/csharp-declarations.js.map +1 -1
  66. package/dist/llcsharp/enums/enum.js +2 -1
  67. package/dist/llcsharp/enums/enum.js.map +1 -1
  68. package/dist/llcsharp/enums/namespace.js +1 -0
  69. package/dist/llcsharp/enums/namespace.js.map +1 -1
  70. package/dist/llcsharp/exports.js +23 -13
  71. package/dist/llcsharp/exports.js.map +1 -1
  72. package/dist/llcsharp/generator.js +1 -0
  73. package/dist/llcsharp/generator.js.map +1 -1
  74. package/dist/llcsharp/messages.js +1 -0
  75. package/dist/llcsharp/messages.js.map +1 -1
  76. package/dist/llcsharp/model/idictionary.js +1 -0
  77. package/dist/llcsharp/model/idictionary.js.map +1 -1
  78. package/dist/llcsharp/model/interface.d.ts +3 -2
  79. package/dist/llcsharp/model/interface.d.ts.map +1 -1
  80. package/dist/llcsharp/model/interface.js +14 -8
  81. package/dist/llcsharp/model/interface.js.map +1 -1
  82. package/dist/llcsharp/model/model-class-dictionary.js +1 -0
  83. package/dist/llcsharp/model/model-class-dictionary.js.map +1 -1
  84. package/dist/llcsharp/model/model-class-json.d.ts.map +1 -1
  85. package/dist/llcsharp/model/model-class-json.js +25 -3
  86. package/dist/llcsharp/model/model-class-json.js.map +1 -1
  87. package/dist/llcsharp/model/model-class-serializer.js +1 -0
  88. package/dist/llcsharp/model/model-class-serializer.js.map +1 -1
  89. package/dist/llcsharp/model/model-class.js +10 -9
  90. package/dist/llcsharp/model/model-class.js.map +1 -1
  91. package/dist/llcsharp/model/namespace.js +1 -0
  92. package/dist/llcsharp/model/namespace.js.map +1 -1
  93. package/dist/llcsharp/model/property.js +1 -0
  94. package/dist/llcsharp/model/property.js.map +1 -1
  95. package/dist/llcsharp/operation/api-class.js +1 -0
  96. package/dist/llcsharp/operation/api-class.js.map +1 -1
  97. package/dist/llcsharp/operation/method.d.ts +3 -1
  98. package/dist/llcsharp/operation/method.d.ts.map +1 -1
  99. package/dist/llcsharp/operation/method.js +30 -28
  100. package/dist/llcsharp/operation/method.js.map +1 -1
  101. package/dist/llcsharp/operation/namespace.js +1 -0
  102. package/dist/llcsharp/operation/namespace.js.map +1 -1
  103. package/dist/llcsharp/operation/parameter.js +1 -0
  104. package/dist/llcsharp/operation/parameter.js.map +1 -1
  105. package/dist/llcsharp/project.d.ts.map +1 -1
  106. package/dist/llcsharp/project.js +3 -1
  107. package/dist/llcsharp/project.js.map +1 -1
  108. package/dist/llcsharp/schema/Uuid.js +1 -0
  109. package/dist/llcsharp/schema/Uuid.js.map +1 -1
  110. package/dist/llcsharp/schema/array.js +1 -0
  111. package/dist/llcsharp/schema/array.js.map +1 -1
  112. package/dist/llcsharp/schema/binary.js +1 -0
  113. package/dist/llcsharp/schema/binary.js.map +1 -1
  114. package/dist/llcsharp/schema/boolean.js +1 -0
  115. package/dist/llcsharp/schema/boolean.js.map +1 -1
  116. package/dist/llcsharp/schema/byte-array.js +1 -0
  117. package/dist/llcsharp/schema/byte-array.js.map +1 -1
  118. package/dist/llcsharp/schema/char.js +1 -0
  119. package/dist/llcsharp/schema/char.js.map +1 -1
  120. package/dist/llcsharp/schema/date-time.d.ts.map +1 -1
  121. package/dist/llcsharp/schema/date-time.js +1 -0
  122. package/dist/llcsharp/schema/date-time.js.map +1 -1
  123. package/dist/llcsharp/schema/date.js +1 -0
  124. package/dist/llcsharp/schema/date.js.map +1 -1
  125. package/dist/llcsharp/schema/duration.js +1 -0
  126. package/dist/llcsharp/schema/duration.js.map +1 -1
  127. package/dist/llcsharp/schema/enum.d.ts +1 -5
  128. package/dist/llcsharp/schema/enum.d.ts.map +1 -1
  129. package/dist/llcsharp/schema/enum.js +1 -9
  130. package/dist/llcsharp/schema/enum.js.map +1 -1
  131. package/dist/llcsharp/schema/integer.js +1 -0
  132. package/dist/llcsharp/schema/integer.js.map +1 -1
  133. package/dist/llcsharp/schema/object.js +2 -1
  134. package/dist/llcsharp/schema/object.js.map +1 -1
  135. package/dist/llcsharp/schema/password.js +2 -1
  136. package/dist/llcsharp/schema/password.js.map +1 -1
  137. package/dist/llcsharp/schema/primitive.js +1 -0
  138. package/dist/llcsharp/schema/primitive.js.map +1 -1
  139. package/dist/llcsharp/schema/schema-resolver.d.ts +2 -3
  140. package/dist/llcsharp/schema/schema-resolver.d.ts.map +1 -1
  141. package/dist/llcsharp/schema/schema-resolver.js +4 -0
  142. package/dist/llcsharp/schema/schema-resolver.js.map +1 -1
  143. package/dist/llcsharp/schema/string.d.ts.map +1 -1
  144. package/dist/llcsharp/schema/string.js +1 -0
  145. package/dist/llcsharp/schema/string.js.map +1 -1
  146. package/dist/llcsharp/schema/uri.d.ts +10 -0
  147. package/dist/llcsharp/schema/uri.d.ts.map +1 -0
  148. package/dist/llcsharp/schema/uri.js +25 -0
  149. package/dist/llcsharp/schema/uri.js.map +1 -0
  150. package/dist/llcsharp/validations.js +1 -0
  151. package/dist/llcsharp/validations.js.map +1 -1
  152. package/dist/main.d.ts.map +1 -1
  153. package/dist/main.js +11 -0
  154. package/dist/main.js.map +1 -1
  155. package/dist/models/model-extensions.js +7 -6
  156. package/dist/models/model-extensions.js.map +1 -1
  157. package/dist/module/module-class.js +2 -1
  158. package/dist/module/module-class.js.map +1 -1
  159. package/dist/module/module-namespace.js +1 -0
  160. package/dist/module/module-namespace.js.map +1 -1
  161. package/dist/plugins/add-azure-completers-v2.js +1 -0
  162. package/dist/plugins/add-azure-completers-v2.js.map +1 -1
  163. package/dist/plugins/create-commands-v2.d.ts.map +1 -1
  164. package/dist/plugins/create-commands-v2.js +18 -21
  165. package/dist/plugins/create-commands-v2.js.map +1 -1
  166. package/dist/plugins/cs-namer-v2.d.ts.map +1 -1
  167. package/dist/plugins/cs-namer-v2.js +9 -3
  168. package/dist/plugins/cs-namer-v2.js.map +1 -1
  169. package/dist/plugins/llcsharp-v2.js +1 -0
  170. package/dist/plugins/llcsharp-v2.js.map +1 -1
  171. package/dist/plugins/modifiers-v2.d.ts +4 -0
  172. package/dist/plugins/modifiers-v2.d.ts.map +1 -1
  173. package/dist/plugins/modifiers-v2.js +69 -13
  174. package/dist/plugins/modifiers-v2.js.map +1 -1
  175. package/dist/plugins/plugin-create-inline-properties.d.ts.map +1 -1
  176. package/dist/plugins/plugin-create-inline-properties.js +51 -4
  177. package/dist/plugins/plugin-create-inline-properties.js.map +1 -1
  178. package/dist/plugins/plugin-tweak-m4-model.js +4 -3
  179. package/dist/plugins/plugin-tweak-m4-model.js.map +1 -1
  180. package/dist/plugins/plugin-tweak-model-azure-v2.js +4 -3
  181. package/dist/plugins/plugin-tweak-model-azure-v2.js.map +1 -1
  182. package/dist/plugins/plugin-tweak-model.js +15 -14
  183. package/dist/plugins/plugin-tweak-model.js.map +1 -1
  184. package/dist/plugins/powershell-v2.d.ts.map +1 -1
  185. package/dist/plugins/powershell-v2.js +7 -2
  186. package/dist/plugins/powershell-v2.js.map +1 -1
  187. package/dist/plugins/ps-namer-v2.js +1 -0
  188. package/dist/plugins/ps-namer-v2.js.map +1 -1
  189. package/dist/plugins/sdk-create-inline-properties.d.ts +4 -0
  190. package/dist/plugins/sdk-create-inline-properties.d.ts.map +1 -0
  191. package/dist/plugins/sdk-create-inline-properties.js +552 -0
  192. package/dist/plugins/sdk-create-inline-properties.js.map +1 -0
  193. package/dist/plugins/sdk-cs-namer.d.ts +3 -0
  194. package/dist/plugins/sdk-cs-namer.d.ts.map +1 -0
  195. package/dist/plugins/sdk-cs-namer.js +385 -0
  196. package/dist/plugins/sdk-cs-namer.js.map +1 -0
  197. package/dist/plugins/sdk-cs-simplifier.d.ts +3 -0
  198. package/dist/plugins/sdk-cs-simplifier.d.ts.map +1 -0
  199. package/dist/plugins/sdk-cs-simplifier.js +154 -0
  200. package/dist/plugins/sdk-cs-simplifier.js.map +1 -0
  201. package/dist/plugins/sdk-generate.d.ts +3 -0
  202. package/dist/plugins/sdk-generate.d.ts.map +1 -0
  203. package/dist/plugins/sdk-generate.js +106 -0
  204. package/dist/plugins/sdk-generate.js.map +1 -0
  205. package/dist/plugins/sdk-tweak-model.d.ts +3 -0
  206. package/dist/plugins/sdk-tweak-model.d.ts.map +1 -0
  207. package/dist/plugins/sdk-tweak-model.js +357 -0
  208. package/dist/plugins/sdk-tweak-model.js.map +1 -0
  209. package/dist/sdk/project.d.ts +45 -0
  210. package/dist/sdk/project.d.ts.map +1 -0
  211. package/dist/sdk/project.js +56 -0
  212. package/dist/sdk/project.js.map +1 -0
  213. package/dist/sdk/state.d.ts +23 -0
  214. package/dist/sdk/state.d.ts.map +1 -0
  215. package/dist/sdk/state.js +28 -0
  216. package/dist/sdk/state.js.map +1 -0
  217. package/dist/sdk/utility.d.ts +32 -0
  218. package/dist/sdk/utility.d.ts.map +1 -0
  219. package/dist/sdk/utility.js +414 -0
  220. package/dist/sdk/utility.js.map +1 -0
  221. package/dist/utils/PwshModel.js +1 -0
  222. package/dist/utils/PwshModel.js.map +1 -1
  223. package/dist/utils/SdkModel.d.ts +7 -0
  224. package/dist/utils/SdkModel.d.ts.map +1 -0
  225. package/dist/utils/SdkModel.js +17 -0
  226. package/dist/utils/SdkModel.js.map +1 -0
  227. package/dist/utils/TrieNode.d.ts +10 -0
  228. package/dist/utils/TrieNode.d.ts.map +1 -0
  229. package/dist/utils/TrieNode.js +45 -0
  230. package/dist/utils/TrieNode.js.map +1 -0
  231. package/dist/utils/WrapComments.d.ts +2 -0
  232. package/dist/utils/WrapComments.d.ts.map +1 -0
  233. package/dist/utils/WrapComments.js +46 -0
  234. package/dist/utils/WrapComments.js.map +1 -0
  235. package/dist/utils/code-namer.d.ts +3 -0
  236. package/dist/utils/code-namer.d.ts.map +1 -0
  237. package/dist/utils/code-namer.js +38 -0
  238. package/dist/utils/code-namer.js.map +1 -0
  239. package/dist/utils/command-operation.d.ts +7 -0
  240. package/dist/utils/command-operation.d.ts.map +1 -1
  241. package/dist/utils/command-operation.js +8 -2
  242. package/dist/utils/command-operation.js.map +1 -1
  243. package/dist/utils/components.d.ts +2 -0
  244. package/dist/utils/components.d.ts.map +1 -1
  245. package/dist/utils/components.js +1 -0
  246. package/dist/utils/components.js.map +1 -1
  247. package/dist/utils/extensions.js +1 -0
  248. package/dist/utils/extensions.js.map +1 -1
  249. package/dist/utils/http-definitions.js +1 -0
  250. package/dist/utils/http-definitions.js.map +1 -1
  251. package/dist/utils/http-operation.js +1 -0
  252. package/dist/utils/http-operation.js.map +1 -1
  253. package/dist/utils/info.js +1 -0
  254. package/dist/utils/info.js.map +1 -1
  255. package/dist/utils/model-state.js +1 -0
  256. package/dist/utils/model-state.js.map +1 -1
  257. package/dist/utils/powershell-comment.js +11 -10
  258. package/dist/utils/powershell-comment.js.map +1 -1
  259. package/dist/utils/programatic-operation.js +2 -2
  260. package/dist/utils/programatic-operation.js.map +1 -1
  261. package/dist/utils/resolve-conflicts.js +1 -0
  262. package/dist/utils/resolve-conflicts.js.map +1 -1
  263. package/dist/utils/schema.d.ts +13 -0
  264. package/dist/utils/schema.d.ts.map +1 -1
  265. package/dist/utils/schema.js +39 -0
  266. package/dist/utils/schema.js.map +1 -1
  267. package/dist/utils/security-scheme.js +1 -0
  268. package/dist/utils/security-scheme.js.map +1 -1
  269. package/dist/utils/uid.js +1 -0
  270. package/dist/utils/uid.js.map +1 -1
  271. package/package.json +8 -7
  272. package/readme.md +5 -1
  273. package/resources/assets/build-module.ps1 +9 -5
  274. package/resources/assets/create-model-cmdlets.ps1 +14 -2
  275. package/resources/assets/generate-portal-ux.ps1 +379 -0
  276. package/resources/assets/tools/Resources/custom/New-AzDeployment.ps1 +2 -2
  277. package/resources/psruntime/Attributes/ExternalDocsAttribute.cs +30 -0
  278. package/resources/psruntime/BuildTime/Cmdlets/ExportPsd1.cs +1 -1
  279. package/resources/psruntime/BuildTime/Models/PsMarkdownTypes.cs +39 -4
  280. package/resources/psruntime/BuildTime/Models/PsProxyOutputs.cs +10 -4
  281. package/resources/psruntime/BuildTime/Models/PsProxyTypes.cs +6 -0
  282. package/resources/psruntime/BuildTime/PsAttributes.cs +7 -0
  283. package/resources/psruntime/BuildTime/PsHelpers.cs +1 -2
  284. package/resources/psruntime/MessageAttributeHelper.cs +1 -5
  285. package/resources/runtime/csharp/client/Context.cs +33 -0
  286. package/resources/runtime/csharp/client/InfoAttribute.cs +4 -0
  287. package/resources/runtime/csharp/client/InputHandler.cs +22 -0
  288. package/resources/runtime/csharp/client/SerializationMode.cs +5 -3
  289. package/resources/runtime/csharp/pipeline/Events.cs +2 -2
  290. package/resources/runtime/csharp/pipeline/PipelineMocking.cs +1 -1
  291. package/resources/runtime/csharp/xml/IXmlSerializable.cs +2 -2
  292. package/resources/templates/azureMethod.ejs +5 -0
  293. package/resources/templates/azureMethodGroup.ejs +46 -0
  294. package/resources/templates/azureServiceClient.ejs +80 -0
  295. package/resources/templates/enum.ejs +73 -0
  296. package/resources/templates/exception.ejs +52 -0
  297. package/resources/templates/extensionMethod.ejs +68 -0
  298. package/resources/templates/extensions.ejs +19 -0
  299. package/resources/templates/longRunningOperationMethod.ejs +43 -0
  300. package/resources/templates/method.ejs +65 -0
  301. package/resources/templates/methodBodyRestCall.ejs +317 -0
  302. package/resources/templates/methodGroupInterface.ejs +77 -0
  303. package/resources/templates/model.ejs +184 -0
  304. package/resources/templates/page.ejs +40 -0
  305. package/resources/templates/serviceClientBody.ejs +303 -0
  306. package/resources/templates/serviceClientInterface.ejs +55 -0
@@ -0,0 +1,68 @@
1
+ <% var key = methodGroup.$key == 'Operations' ? '' : methodGroup.$key-%>
2
+ <%# ToDo: currently assume the SyncMethodsGenerationMode is Essential type, and need to add support for other types -%>
3
+ /// <summary>
4
+ /// <%=method.language.default.description%>
5
+ <%# ToDo: add support for externaldocsurl -%>
6
+ /// </summary>
7
+ <%# ToDo: add <remarks> if there are both description and summary -%>
8
+ /// <param name='operations'>
9
+ /// The operations group for this extension method.
10
+ /// </param>
11
+ <% if(method.parameters && !method.language.default.pageable?.nextPageOperation) { method.parameters.filter(p => p.implementation != 'Client' && !project.helper.IsConstantParameter(p)).forEach(function (parameter) {-%>
12
+ /// <param name='<%-parameter.language.default.name%>'>
13
+ /// <%=parameter.language.default.description%>
14
+ /// </param>
15
+ <% });}-%>
16
+ <% if(method.language.default.pageable?.nextPageOperation) {-%>
17
+ /// <param name='nextPageLink'>
18
+ /// The NextLink from the previous successful call to List operation.
19
+ /// </param>
20
+ <% } -%>
21
+ <%# ToDo: add support for GetObsoleteAttribute-%>
22
+ <%# ToDo: add support for AccessModifier, assume public for the time being-%>
23
+ public static <%-method.language.default.returnType%> <%-method.language.default.name%>(this I<%-project.helper.PascalCase(key)%>Operations operations<%- method.language.default.syncMethodParameterDeclaration ? ', ' + method.language.default.syncMethodParameterDeclaration: '' %>)
24
+ {
25
+ <%# ToDo: need to handle different return type, body, header and the others including no return type-%>
26
+ <% if(method.language.default.returnType != 'void') {-%>
27
+ return ((I<%-project.helper.PascalCase(key)%>Operations)operations).<%-method.language.default.name%>Async(<%-method.language.default.syncMethodInvocationArgs%>).GetAwaiter().GetResult();
28
+ <% } else { -%>
29
+ ((I<%-project.helper.PascalCase(key)%>Operations)operations).<%-method.language.default.name%>Async(<%-method.language.default.syncMethodInvocationArgs%>).GetAwaiter().GetResult();
30
+ <% } -%>
31
+ }
32
+
33
+ /// <summary>
34
+ /// <%=method.language.default.description%>
35
+ <%# ToDo: add support for externaldocsurl -%>
36
+ /// </summary>
37
+ <%# ToDo: add <remarks> if there are both description and summary -%>
38
+ /// <param name='operations'>
39
+ /// The operations group for this extension method.
40
+ /// </param>
41
+ <% if(method.parameters && !method.language.default.pageable?.nextPageOperation) { method.parameters.filter(p => p.implementation != 'Client' && !project.helper.IsConstantParameter(p)).forEach(function (parameter) {-%>
42
+ /// <param name='<%-parameter.language.default.name%>'>
43
+ /// <%=parameter.language.default.description%>
44
+ /// </param>
45
+ <% });}-%>
46
+ <% if(method.language.default.pageable?.nextPageOperation) {-%>
47
+ /// <param name='nextPageLink'>
48
+ /// The NextLink from the previous successful call to List operation.
49
+ /// </param>
50
+ <% } -%>
51
+ /// <param name='cancellationToken'>
52
+ /// The cancellation token.
53
+ /// </param>
54
+ <%# ToDo: add support for GetObsoleteAttribute-%>
55
+ <%# ToDo: add support for AccessModifier, assume public for the time being-%>
56
+ public static async System.Threading.Tasks.Task<%- method.language.default.returnType != 'void' ? '<' + method.language.default.returnType + '>' : ''%> <%-method.language.default.name%>Async(this I<%-project.helper.PascalCase(key)%>Operations operations<%- method.language.default.asyncMethodParameterDeclaration ? ', ' + method.language.default.asyncMethodParameterDeclaration: '' %>)
57
+ {
58
+ <%# ToDo: need to handle different return type, body, header and the others including no return type-%>
59
+ <% if(method.language.default.returnType != 'void') {-%>
60
+ <%# ToDo: add support for primitive return-%>
61
+ using (var _result = await operations.<%-method.language.default.name%>WithHttpMessagesAsync(<%-method.language.default.asyncMethodInvocationArgs%>).ConfigureAwait(false))
62
+ {
63
+ return <%- method.language.default.responseType.startsWith('Microsoft.Rest.Azure.AzureOperationResponse') ? '_result.Body' : '_result.Headers'%>;
64
+ }
65
+ <% } else { -%>
66
+ (await operations.<%-method.language.default.name%>WithHttpMessagesAsync(<%-method.language.default.asyncMethodInvocationArgs%>).ConfigureAwait(false)).Dispose();
67
+ <% }-%>
68
+ }
@@ -0,0 +1,19 @@
1
+ <%- project.commentHeader %>
2
+ <% var key = methodGroup.$key == 'Operations' ? '' : methodGroup.$key-%>
3
+ namespace <%- project.namespace %>
4
+ {
5
+ <% project.model.usings.forEach(function(using){ -%>
6
+ using <%- using %>;
7
+ <% }); -%>
8
+
9
+ /// <summary>
10
+ /// Extension methods for <%- project.helper.PascalCase(key) %>Operations
11
+ /// </summary>
12
+ public static partial class <%- project.helper.PascalCase(key) %>OperationsExtensions
13
+ {
14
+ <% methodGroup.operations.forEach(function(method){ -%>
15
+ <%# ToDo: add support for ExcludeFromInterface-%>
16
+ <%- include('extensionMethod', {method: method, group: methodGroup, project: project}) %>
17
+ <% }); -%>
18
+ }
19
+ }
@@ -0,0 +1,43 @@
1
+ <% if (method.language.default.description) {-%>
2
+ /// <summary>
3
+ /// <%= method.language.default.description%>
4
+ <%# ToDo: add externaldocsurl -%>
5
+ /// </summary>
6
+ <% };-%>
7
+ <%# ToDo: add remark if both description and summary is provided, question here is in m4, there is no summary provided-%>
8
+ <% if(method.parameters&&!method.language.default.pageable?.nextPageOperation) { method.parameters.filter(p => p.implementation != 'Client' && !project.helper.IsConstantParameter(p)).forEach(function (parameter) {-%>
9
+ <%# ToDo: should use camel name instead of pascal name here -%>
10
+ /// <param name='<%-parameter.language.default.name%>'>
11
+ /// <%=parameter.language.default.description%>
12
+ /// </param>
13
+ <% });}-%>
14
+ <% (method.requests[0].parameters || []).filter(p=>p.protocol.http.in == 'body' && !project.helper.IsConstantParameter(p)).forEach(function(parameter){-%>
15
+ <%if(parameter.extensions && parameter.extensions['x-ms-client-flatten'] ) {-%>
16
+ <%project.helper.GetAllPublicVirtualProperties(parameter.schema.language.default.virtualProperties).filter(p => !project.helper.IsConstantProperty(p)).forEach(function(vp) {-%>
17
+ /// <param name='<%-vp.property.language.default.name%>'>
18
+ /// <%= vp.property.language.default.description%>
19
+ /// </param>
20
+ <%});-%>
21
+ <%} else {-%>
22
+ /// <param name='<%-parameter.language.default.name%>'>
23
+ /// <%= parameter.language.default.description%>
24
+ /// </param>
25
+ <%}-%>
26
+ <% });-%>
27
+ <% if(method.language.default.pageable?.nextPageOperation) {-%>
28
+ /// <param name='nextPageLink'>
29
+ /// The NextLink from the previous successful call to List operation.
30
+ /// </param>
31
+ <% } -%>
32
+ /// <param name='customHeaders'>
33
+ /// Headers that will be added to request.
34
+ /// </param>
35
+ /// <param name='cancellationToken'>
36
+ /// The cancellation token.
37
+ /// </param>
38
+ public async System.Threading.Tasks.Task<<%-method.language.default.responseType%>> <%-method.language.default.name%>WithHttpMessagesAsync(<%-method.language.default.asyncMethodParameterDeclarationWithCustomHeader%>)
39
+ {
40
+ // Send Request
41
+ <%-method.language.default.responseType%> _response = await Begin<%-method.language.default.name%>WithHttpMessagesAsync(<%-method.language.default.asyncMethodInvocationArgsWithCustomerHeaders%>).ConfigureAwait(false);
42
+ return await this.Client.<%-(method.requests[0].protocol.http.method == 'put' || method.requests[0].protocol.http.method == 'patch')?'GetPutOrPatch':(method.requests[0].protocol.http.method == 'post' || method.requests[0].protocol.http.method == 'delete')?'GetPostOrDelete':''%>OperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false);
43
+ }
@@ -0,0 +1,65 @@
1
+ <% if (method.language.default.description) {-%>
2
+ /// <summary>
3
+ /// <%= method.language.default.description%>
4
+ <%# ToDo: add externaldocsurl -%>
5
+ /// </summary>
6
+ <% };-%>
7
+ <%# ToDo: add remark if both description and summary is provided, question here is in m4, there is no summary provided-%>
8
+ <% if(method.parameters&&!method.language.default.pageable?.nextPageOperation) { method.parameters.filter(p => p.implementation != 'Client' && !project.helper.IsConstantParameter(p)).forEach(function (parameter) {-%>
9
+ <%# ToDo: should use camel name instead of pascal name here -%>
10
+ /// <param name='<%-parameter.language.default.name%>'>
11
+ /// <%=parameter.language.default.description%>
12
+ /// </param>
13
+ <% });}-%>
14
+ <% (method.requests[0].parameters || []).filter(p=>p.protocol.http.in == 'body' && !project.helper.IsConstantParameter(p)).forEach(function(parameter){-%>
15
+ <%if(parameter.extensions && parameter.extensions['x-ms-client-flatten'] ) {-%>
16
+ <%project.helper.GetAllPublicVirtualProperties(parameter.schema.language.default.virtualProperties).filter(p => !project.helper.IsConstantProperty(p)).forEach(function(vp) {-%>
17
+ /// <param name='<%-vp.property.language.default.name%>'>
18
+ /// <%= vp.property.language.default.description%>
19
+ /// </param>
20
+ <%});-%>
21
+ <%} else {-%>
22
+ /// <param name='<%-parameter.language.default.name%>'>
23
+ /// <%= parameter.language.default.description%>
24
+ /// </param>
25
+ <%}-%>
26
+ <% });-%>
27
+ <% if(method.language.default.pageable?.nextPageOperation) {-%>
28
+ /// <param name='nextPageLink'>
29
+ /// The NextLink from the previous successful call to List operation.
30
+ /// </param>
31
+ <% } -%>
32
+ /// <param name='customHeaders'>
33
+ /// Headers that will be added to request.
34
+ /// </param>
35
+ /// <param name='cancellationToken'>
36
+ /// The cancellation token.
37
+ /// </param>
38
+ /// <exception cref="Microsoft.Rest.Azure.CloudException">
39
+ /// Thrown when the operation returned an invalid status code
40
+ /// </exception>
41
+ <% if ((method.responses || []).filter(p => p.schema).length > 0) {-%>
42
+ /// <exception cref="Microsoft.Rest.SerializationException">
43
+ /// Thrown when unable to deserialize the response
44
+ /// </exception>
45
+ <% };-%>
46
+ <%# ToDo: add isnullable check -%>
47
+ <% if (method.parameters.filter(p => p.schema.type != 'constant' && p.required)) {-%>
48
+ /// <exception cref="Microsoft.Rest.ValidationException">
49
+ /// Thrown when a required parameter is null
50
+ /// </exception>
51
+ /// <exception cref="System.ArgumentNullException">
52
+ /// Thrown when a required parameter is null
53
+ /// </exception>
54
+ <% };-%>
55
+ /// <return>
56
+ /// A response object containing the response body and response headers.
57
+ /// </return>
58
+ <%# ToDo: add GetObsoleteAttribute -%>
59
+ <%# ToDo: need to check in which case the method is not public(AccessModifier), currently set it to public -%>
60
+ public async System.Threading.Tasks.Task<<%-method.language.default.responseType%>> <%-method.language.default.name%>WithHttpMessagesAsync(<%-method.language.default.asyncMethodParameterDeclarationWithCustomHeader%>)
61
+ {
62
+ <%# ToDo: add support for method.Flavor, currently assume it is RestCall -%>
63
+
64
+ <%- include('methodBodyRestCall', {method: method}) -%>
65
+ }
@@ -0,0 +1,317 @@
1
+ <%- project.helper.HandleConstParameters(method)%>
2
+ <%# handle x-ms-client-request-id -%>
3
+ <% var clientRequestId = 'x-ms-client-request-id';
4
+ var requestId = 'x-ms-request-id';
5
+ (method.parameters||[]).filter(p => p.protocol.http.in == 'header').forEach(function (parameter) {
6
+ if (parameter.extensions && parameter.extensions['x-ms-client-request-id']) {
7
+ clientRequestId = parameter.language.default.serializedName;
8
+ }
9
+ });
10
+ if (method.extensions && method.extensions['x-ms-request-id']) {
11
+ requestId = method.extensions['x-ms-request-id'];
12
+ }
13
+ -%>
14
+ <%# end of handling x-ms-client-request-id -%>
15
+ <% if(method.language.default.pageable?.nextPageOperation) {-%>
16
+ if (nextPageLink == null)
17
+ {
18
+ throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "nextPageLink");
19
+ }
20
+ <% }else{-%>
21
+ <% (method.requests[0].parameters || []).filter(p=>p.protocol.http.in == 'body').forEach(function(parameter){-%>
22
+ <%if(!(parameter.extensions && parameter.extensions['x-ms-client-flatten'])) {-%>
23
+ <% if (!project.helper.IsValueType(parameter.schema.type) && parameter.required && !project.helper.IsConstantParameter(parameter)) { -%>
24
+ if (<%-parameter.language.default.name%> == null)
25
+ {
26
+ throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "<%-parameter.language.default.name%>");
27
+ }
28
+ <% } -%>
29
+ <%if(method.requests[0].protocol.http.method != 'patch') {-%>
30
+ <%-project.helper.ValidateType(parameter.schema, method, parameter.language.default.name, parameter.nullable)%>
31
+ <%}-%>
32
+ <%}-%>
33
+ <% });-%>
34
+ <% if(method.parameters) { method.parameters.filter(p => (p.schema.type != 'constant' && p.language.default.name != '$host') || p.language.default.name == 'ApiVersion').forEach(function (parameter) {-%>
35
+ <%# ToDo: add check IsNullable with required -%>
36
+ <% var prefix = parameter.implementation == 'Client' ? 'this.Client.' : ''-%>
37
+ <% if ( !(parameter.extensions && parameter.extensions['x-ms-parameter-grouping']) && parameter.required && !project.helper.IsValueType(parameter.schema.type) && !project.helper.IsConstantParameter(parameter)) {-%>
38
+ if (<%-prefix%><%-parameter.language.default.name%> == null)
39
+ {
40
+ throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "<%-prefix%><%-parameter.language.default.name%>");
41
+ }
42
+ <% } -%>
43
+ <%-project.helper.ValidateType(parameter.schema, method, prefix + parameter.language.default.name, parameter.nullable)%>
44
+ <%});}-%>
45
+ <%(method.parameters || []).filter(p => p.protocol.http.in == 'complex').forEach(function(parameter) {-%>
46
+ <%-project.helper.PopulateGroupParameters(parameter)%>
47
+ <%});-%>
48
+ <%# support for p => p.IsConstant && !p.IsClientProperty -%>
49
+ <%(method.parameters || []).filter(p => p.implementation !== 'Client' && p.schema.type === 'constant' && p.required).forEach(function(parameter) {-%>
50
+ <%-project.helper.GetCsharpType(parameter.schema.valueType)%> <%-parameter.language.default.name%> = <%-parameter.schema.valueType.type === 'string' ? '"' + parameter.schema.value.value + '"' : parameter.schema.value.value%>;
51
+ <%});-%>
52
+ <%# ToDo: add support for BuildInputMappings -%>
53
+ <% (method.requests[0].parameters || []).filter(p=>p.protocol.http.in == 'body').forEach(function(parameter){-%>
54
+ <%if(parameter.extensions && parameter.extensions['x-ms-client-flatten']) {-%>
55
+ <%-parameter.schema.language.default.name%> <%-parameter.language.default.name%> = new <%-parameter.schema.language.default.name%>();
56
+ <% var vps = project.helper.GetAllPublicVirtualProperties(parameter.schema.language.default.virtualProperties)-%>
57
+ if(<%-vps.map(vp=>`${vp.property.language.default.name} != null`).join('||')%>)
58
+ {
59
+ <%vps.forEach(function(vp) {-%>
60
+ <%-parameter.language.default.name%>.<%-vp.property.language.csharp.name%> = <%-vp.property.language.default.name%>;
61
+ <%});-%>
62
+ }
63
+ <%}-%>
64
+ <% });-%>
65
+ <%}-%>
66
+ // Tracing
67
+ bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
68
+ string _invocationId = null;
69
+ if (_shouldTrace)
70
+ {
71
+ _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString();
72
+ System.Collections.Generic.Dictionary<string, object> tracingParameters = new System.Collections.Generic.Dictionary<string, object>();
73
+ <% if(method.language.default.pageable?.nextPageOperation) {-%>
74
+ tracingParameters.Add("nextPageLink", nextPageLink);
75
+ <% }else{-%>
76
+ <%# ToDo: add support for Model.LogicalParameters.Where(p => !p.IsClientProperty)-%>
77
+ <%method.parameters.filter(p => p.implementation != 'Client' && p.protocol.http.in != 'complex').forEach(function(p) {-%>
78
+ tracingParameters.Add("<%-p.language.default.name%>", <%-p.language.default.name%>);
79
+ <%});-%>
80
+ <%# ToDo: currently we just add the unexpanded body parameter, and need to be fixed in the future %>
81
+ <% (method.requests[0].parameters || []).filter(p =>p.protocol.http.in == 'body').forEach(function (parameter) {-%>
82
+ tracingParameters.Add("<%-parameter.language.default.name%>", <%-parameter.language.default.name%>);
83
+ <% });-%>
84
+ <% }%>
85
+ tracingParameters.Add("cancellationToken", cancellationToken);
86
+ Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "<%-method.language.default.name%>", tracingParameters);
87
+ }
88
+ // Construct URL
89
+ <% if(method.language.default.pageable?.nextPageOperation) {-%>
90
+ string _url = "{nextLink}";
91
+ _url = _url.Replace("{nextLink}", nextPageLink);
92
+ <% }else{%>
93
+ <%# ToDo: may need to support AbsoluteUrl -%>
94
+ var _baseUrl = this.Client.BaseUri.AbsoluteUri;
95
+ <%# ToDo: buildurl, currently only added simple cases, besides we need to handle skip url encoding -%>
96
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "<%-method.requests[0].protocol.http.path.substring(1)%>").ToString();
97
+ <%if (method.parameters) { method.parameters.filter(p => p.protocol.http.in == 'path').forEach(function (pathParameter) {
98
+ var prefix = pathParameter.implementation == 'Client' ? 'this.Client.' : '';
99
+ -%>
100
+ _url = _url.Replace("{<%-pathParameter.language.default.serializedName%>}", <%-project.helper.PathParameterString(pathParameter)%>);
101
+ <% });}-%>
102
+ <% }%>
103
+ System.Collections.Generic.List<string> _queryParameters = new System.Collections.Generic.List<string>();
104
+ <%if (method.parameters && !method.language.default.pageable?.nextPageOperation) { method.parameters.filter(p => p.protocol.http.in == 'query').forEach(function (queryParameter) { -%>
105
+ <% var prefix = queryParameter.implementation == 'Client' ? 'this.Client.' : ''-%>
106
+ <% if (queryParameter.extensions && queryParameter.extensions['x-ms-odata']) {-%>
107
+ if (<%-queryParameter.language.default.name%> != null)
108
+ {
109
+ var _<%-project.helper.CamelCase(queryParameter.schema.language.default.name)%> = <%-queryParameter.language.default.name%>.ToString();
110
+ if (!string.IsNullOrEmpty(_<%-project.helper.CamelCase(queryParameter.schema.language.default.name)%>))
111
+ {
112
+ _queryParameters.Add(_<%-project.helper.CamelCase(queryParameter.schema.language.default.name)%>);
113
+ }
114
+ }
115
+ <% } else {-%>
116
+ if (<%-prefix%><%-queryParameter.language.default.name%> != null)
117
+ {
118
+ _queryParameters.Add(string.Format("<%-queryParameter.language.default.serializedName%>={0}", <%-project.helper.PathParameterString(queryParameter)%>));
119
+ }
120
+ <% }-%>
121
+ <% });}-%>
122
+ if (_queryParameters.Count > 0)
123
+ {
124
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
125
+ }
126
+ // Create HTTP transport objects
127
+ var _httpRequest = new System.Net.Http.HttpRequestMessage();
128
+ System.Net.Http.HttpResponseMessage _httpResponse = null;
129
+ _httpRequest.Method = new System.Net.Http.HttpMethod("<%-method.requests[0].protocol.http.method.toUpperCase()%>");
130
+ _httpRequest.RequestUri = new System.Uri(_url);
131
+ // Set Headers
132
+ <%# ToDo: Add headers except for following default ones -%>
133
+ if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value)
134
+ {
135
+ _httpRequest.Headers.TryAddWithoutValidation("<%-clientRequestId%>", System.Guid.NewGuid().ToString());
136
+ }
137
+ if (this.Client.AcceptLanguage != null)
138
+ {
139
+ if (_httpRequest.Headers.Contains("accept-language"))
140
+ {
141
+ _httpRequest.Headers.Remove("accept-language");
142
+ }
143
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage);
144
+ }
145
+ <% (method.parameters || []).filter(p => p.protocol.http.in == 'header').forEach(function(parameter) {
146
+ var prefix = parameter.implementation == 'Client' ? 'this.Client.' : ''-%>
147
+ if (<%-prefix%><%-parameter.language.default.name%> != null)
148
+ {
149
+ if (_httpRequest.Headers.Contains("<%-parameter.language.default.serializedName%>"))
150
+ {
151
+ _httpRequest.Headers.Remove("<%-parameter.language.default.serializedName%>");
152
+ }
153
+ _httpRequest.Headers.TryAddWithoutValidation("<%-parameter.language.default.serializedName%>", <%-prefix%><%-parameter.language.default.name%>);
154
+ }
155
+ <% });-%>
156
+
157
+ if (customHeaders != null)
158
+ {
159
+ foreach(var _header in customHeaders)
160
+ {
161
+ if (_httpRequest.Headers.Contains(_header.Key))
162
+ {
163
+ _httpRequest.Headers.Remove(_header.Key);
164
+ }
165
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
166
+ }
167
+ }
168
+ // Serialize Request
169
+ string _requestContent = null;
170
+ <%# ToDo: add RequestBody, formdata support-%>
171
+ <% (method.requests[0].parameters || []).filter(p =>p.protocol.http.in == 'body').forEach(function (parameter) {-%>
172
+ <%# ToDo: currently only support for an unexpanded nullable body, need other support in the future -%>
173
+ <% if (!project.helper.IsValueType(parameter.schema.type) && !project.helper.IsConstantParameter(parameter)) {-%>
174
+ if(<%-parameter.language.default.name%> != null)
175
+ {
176
+ _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(<%-parameter.language.default.name%>, <%-project.helper.GetSerializationSettings(parameter.schema, 'this.Client')%>);
177
+ _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8);
178
+ _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
179
+ }
180
+ <% } else { -%>
181
+ _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(<%-parameter.language.default.name%>, <%-project.helper.GetSerializationSettings(parameter.schema, 'this.Client')%>);
182
+ _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8);
183
+ _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
184
+ <% } -%>
185
+ <% });-%>
186
+ <%# ToDo: Need to confirm in which case Settings.AddCredentials is false -%>
187
+ // Set Credentials
188
+ if (this.Client.Credentials != null)
189
+ {
190
+ cancellationToken.ThrowIfCancellationRequested();
191
+ await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
192
+ }
193
+ // Send Request
194
+ if (_shouldTrace)
195
+ {
196
+ Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
197
+ }
198
+ cancellationToken.ThrowIfCancellationRequested();
199
+ <%# ToDo: Add support for primary type return -%>
200
+ <% var responseHeadersRead = method.requests[0].protocol.http.method === 'head' ? 'System.Net.Http.HttpCompletionOption.ResponseHeadersRead, ': '' -%>
201
+ _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, <%-responseHeadersRead%>cancellationToken).ConfigureAwait(false);
202
+ if (_shouldTrace)
203
+ {
204
+ Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
205
+ }
206
+
207
+ System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode;
208
+ cancellationToken.ThrowIfCancellationRequested();
209
+ string _responseContent = null;
210
+
211
+ if (<%-method.language.default.failureStatusCodePredicate%>)
212
+ {
213
+ var ex = new <%-project.helper.IsCloudErrorException(method) ? 'Microsoft.Rest.Azure.CloudException' : `${method.exceptions[0].schema.language.default.name}Exception`%>(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
214
+ <%# ToDo: not sure whether there is the case that there is no default response(error). If so, we will need to add support for it -%>
215
+ try
216
+ {
217
+ <%# ToDo: Need to add support for primary type -%>
218
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
219
+ <%var errorClass = !project.helper.IsCloudErrorException(method) ? method.exceptions[0].schema.language.default.name : 'CloudError'-%>
220
+ <%-errorClass%> _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject<<%-errorClass%>>(_responseContent, this.Client.DeserializationSettings);
221
+ if (_errorBody != null)
222
+ {
223
+ <% if(project.helper.IsCloudErrorException(method)) { -%>
224
+ ex = new Microsoft.Rest.Azure.CloudException(_errorBody.Message);
225
+ <% } -%>
226
+ ex.Body = _errorBody;
227
+ }
228
+ }
229
+ catch (Newtonsoft.Json.JsonException)
230
+ {
231
+ // Ignore the exception
232
+ }
233
+ ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent);
234
+ ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent);
235
+ <% if (project.helper.IsCloudErrorException(method)) {-%>
236
+ if (_httpResponse.Headers.Contains("<%-(method.extensions && method.extensions[requestId]) ?? requestId%>"))
237
+ {
238
+ ex.RequestId = _httpResponse.Headers.GetValues("<%-(method.extensions && method.extensions[requestId]) ?? requestId%>").FirstOrDefault();
239
+ }
240
+ <% } -%>
241
+ if (_shouldTrace)
242
+ {
243
+ Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex);
244
+ }
245
+ _httpRequest.Dispose();
246
+ if (_httpResponse != null)
247
+ {
248
+ _httpResponse.Dispose();
249
+ }
250
+ throw ex;
251
+ }
252
+ // Create Result
253
+ var _result = new <%-method.language.default.responseType%>();
254
+ _result.Request = _httpRequest;
255
+ _result.Response = _httpResponse;
256
+ <%- method.language.default.initializeResponseBody %>
257
+ if (_httpResponse.Headers.Contains("<%-requestId%>"))
258
+ {
259
+ _result.RequestId = _httpResponse.Headers.GetValues("<%-requestId%>").FirstOrDefault();
260
+ }
261
+ <%(method.responses || []).filter(r => r.schema).forEach(function(resp) {-%>
262
+ // Deserialize Response
263
+ if ((int)_statusCode == <%-resp.protocol.http.statusCodes[0]%>)
264
+ {
265
+ <%# ToDo: Need to add support for primary type -%>
266
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
267
+ <%# ToDo: support for XmlSerialization, guess we do not need it actually -%>
268
+ try
269
+ {
270
+ <%# ToDo: we assume the return is object, need to add support for other types including support nullable -%>
271
+ <% var respSchema = resp.schema;
272
+ if(resp.schema.type === 'choice' || (resp.schema.type === 'sealed-choice' && (respSchema.schema.choiceType.type != 'string' || (resp.schema.extensions && resp.schema.extensions['x-ms-model-as-string'])))){
273
+ respSchema = resp.schema.choiceType;
274
+ }
275
+ var deserializeType = method.language.default.deserializeType ? method.language.default.deserializeType : respSchema.language.csharp.fullname;
276
+ const postfix = (project.helper.IsValueType(respSchema.type) || project.helper.IsEnum(resp.schema)) ? '?' : '';
277
+ -%>
278
+ _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject<<%-deserializeType + postfix%>>(_responseContent, <%-project.helper.GetDeserializationSettings(respSchema, 'this.Client')%>);
279
+ }
280
+ catch (Newtonsoft.Json.JsonException ex)
281
+ {
282
+ _httpRequest.Dispose();
283
+ if (_httpResponse != null)
284
+ {
285
+ _httpResponse.Dispose();
286
+ }
287
+ throw new Microsoft.Rest.SerializationException("Unable to deserialize the response.", _responseContent, ex);
288
+ }
289
+ }
290
+ <% });-%>
291
+ <%# ToDo: add support for case Model.ReturnType.Body != null && Model.DefaultResponse.Body != null && !Model.Responses.Any()-%>
292
+ <%# ToDo: add support for case there are return in headers-%>
293
+ <% if (method.language.default.returnTypeHeader.name !== '') { -%>
294
+ try
295
+ {
296
+ _result.Headers = _httpResponse.GetHeadersAsJson().ToObject<<%-method.language.default.returnTypeHeader.name%>>(Newtonsoft.Json.JsonSerializer.Create(this.Client.DeserializationSettings));
297
+ }
298
+ catch (Newtonsoft.Json.JsonException ex)
299
+ {
300
+ _httpRequest.Dispose();
301
+ if (_httpResponse != null)
302
+ {
303
+ _httpResponse.Dispose();
304
+ }
305
+ throw new Microsoft.Rest.SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
306
+ }
307
+ <% } -%>
308
+ if (_shouldTrace)
309
+ {
310
+ Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result);
311
+ }
312
+ return _result;
313
+
314
+
315
+
316
+
317
+
@@ -0,0 +1,77 @@
1
+ <%- project.commentHeader %>
2
+ <% var key = methodGroup.$key == 'Operations' ? '' : methodGroup.$key-%>
3
+
4
+ namespace <%- project.namespace %>
5
+ {
6
+ <% project.model.usings.forEach(function(using){ -%>
7
+ using <%- using %>;
8
+ <% }); -%>
9
+
10
+ <% var typeName = project.helper.PascalCase(key) + 'Operations' -%>
11
+ /// <summary>
12
+ /// <%- typeName %> operations.
13
+ /// </summary>
14
+ public partial interface I<%- typeName%>
15
+ {
16
+ <% methodGroup.operations.forEach(function(method){ -%>
17
+ <%# ToDo: support for ExcludeFromInterface -%>
18
+ <% if(method.language.default.description) {-%>
19
+ /// <summary>
20
+ /// <%= method.language.default.description%>
21
+ <%# ToDo: support for ExternalDocsUrl -%>
22
+ /// </summary>
23
+ /// <remarks>
24
+ /// <%= method.language.default.description%>
25
+ /// </remarks>
26
+ <% };-%>
27
+ <% if(!method.language.default.pageable?.nextPageOperation) {-%>
28
+ <% method.parameters.filter(p=>p.implementation != 'Client' && !project.helper.IsConstantParameter(p)).forEach(function(parameter){-%>
29
+ /// <param name='<%-parameter.language.default.name%>'>
30
+ /// <%= parameter.language.default.description%>
31
+ /// </param>
32
+ <% }); -%>
33
+ <% (method.requests[0].parameters || []).filter(p=>p.protocol.http.in == 'body' && !project.helper.IsConstantParameter(p)).forEach(function(parameter){-%>
34
+ <%if(parameter.extensions && parameter.extensions['x-ms-client-flatten'] ) {-%>
35
+ <%project.helper.GetAllPublicVirtualProperties(parameter.schema.language.default.virtualProperties).filter(p => !project.helper.IsConstantProperty(p)).forEach(function(vp) {-%>
36
+ /// <param name='<%-vp.property.language.default.name%>'>
37
+ /// <%= vp.property.language.default.description%>
38
+ /// </param>
39
+ <%});-%>
40
+ <%} else {-%>
41
+ /// <param name='<%-parameter.language.default.name%>'>
42
+ /// <%= parameter.language.default.description%>
43
+ /// </param>
44
+ <%}-%>
45
+ <% });-%>
46
+ <% };-%>
47
+ <% if(method.language.default.pageable?.nextPageOperation) {-%>
48
+ /// <param name='nextPageLink'>
49
+ /// The NextLink from the previous successful call to List operation.
50
+ /// </param>
51
+ <% } -%>
52
+ /// <param name='customHeaders'>
53
+ /// The headers that will be added to request.
54
+ /// </param>
55
+ /// <param name='cancellationToken'>
56
+ /// The cancellation token.
57
+ /// </param>
58
+ <%# ToDo: Need to figure out whether we could hand code the exception here -%>
59
+ /// <exception cref="Microsoft.Rest.Azure.CloudException">
60
+ /// Thrown when the operation returned an invalid status code
61
+ /// </exception>
62
+ <% if ((method.responses || []).filter(r => r.schema).length > 0) {-%>
63
+ /// <exception cref="Microsoft.Rest.SerializationException">
64
+ /// Thrown when unable to deserialize the response
65
+ /// </exception>
66
+ <% }; -%>
67
+ <% if (method.parameters.filter(p => p.required && p.nullable).length > 0 || (method.requests[0].parameters || []).filter(p => p.required && p.nullable).length > 0) {-%>
68
+ /// <exception cref="Microsoft.Rest.ValidationException">
69
+ /// Thrown when a required parameter is null
70
+ /// </exception>
71
+ <% }; -%>
72
+ <%# ToDo: support GetObsoleteAttribute, deprecated message?-%>
73
+ System.Threading.Tasks.Task<<%-method.language.default.responseType %>> <%- method.language.default.name%>WithHttpMessagesAsync(<%-method.language.default.asyncMethodParameterDeclarationWithCustomHeader%>);
74
+
75
+ <% }); -%>
76
+ }
77
+ }