@autorest/powershell 4.0.0-dev.9 → 4.0.0

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 (483) hide show
  1. package/.rush/temp/package-deps_build.json +208 -203
  2. package/.rush/temp/shrinkwrap-deps.json +253 -280
  3. package/autorest-configuration-for-sdk.md +9 -3
  4. package/autorest-configuration.md +1 -1
  5. package/dist/cmdlets/class.d.ts +24 -3
  6. package/dist/cmdlets/class.d.ts.map +1 -1
  7. package/dist/cmdlets/class.js +888 -603
  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 +39 -5
  11. package/dist/cmdlets/namespace.js.map +1 -1
  12. package/dist/enums/namespace.js +5 -5
  13. package/dist/enums/namespace.js.map +1 -1
  14. package/dist/exports.d.ts +3 -0
  15. package/dist/exports.d.ts.map +1 -0
  16. package/dist/exports.js +19 -0
  17. package/dist/exports.js.map +1 -0
  18. package/dist/generators/gitignore.d.ts.map +1 -1
  19. package/dist/generators/gitignore.js +2 -0
  20. package/dist/generators/gitignore.js.map +1 -1
  21. package/dist/generators/psm1.custom.js +2 -2
  22. package/dist/generators/psm1.custom.js.map +1 -1
  23. package/dist/generators/psm1.d.ts.map +1 -1
  24. package/dist/generators/psm1.internal.js +2 -2
  25. package/dist/generators/psm1.internal.js.map +1 -1
  26. package/dist/generators/psm1.js +17 -11
  27. package/dist/generators/psm1.js.map +1 -1
  28. package/dist/generators/readme.d.ts.map +1 -1
  29. package/dist/generators/readme.js +0 -3
  30. package/dist/generators/readme.js.map +1 -1
  31. package/dist/generators/script-cmdlet.js +18 -18
  32. package/dist/generators/script-cmdlet.js.map +1 -1
  33. package/dist/internal/name-inferrer.d.ts +1 -1
  34. package/dist/internal/name-inferrer.d.ts.map +1 -1
  35. package/dist/internal/name-inferrer.js +12 -12
  36. package/dist/internal/name-inferrer.js.map +1 -1
  37. package/dist/internal/powershell-declarations.d.ts +2 -0
  38. package/dist/internal/powershell-declarations.d.ts.map +1 -1
  39. package/dist/internal/powershell-declarations.js +4 -2
  40. package/dist/internal/powershell-declarations.js.map +1 -1
  41. package/dist/internal/project.d.ts +14 -6
  42. package/dist/internal/project.d.ts.map +1 -1
  43. package/dist/internal/project.js +24 -13
  44. package/dist/internal/project.js.map +1 -1
  45. package/dist/internal/state.d.ts +3 -2
  46. package/dist/internal/state.d.ts.map +1 -1
  47. package/dist/internal/state.js.map +1 -1
  48. package/dist/llcsharp/clientruntime.d.ts +1 -0
  49. package/dist/llcsharp/clientruntime.d.ts.map +1 -1
  50. package/dist/llcsharp/clientruntime.js +12 -11
  51. package/dist/llcsharp/clientruntime.js.map +1 -1
  52. package/dist/llcsharp/code-model.d.ts +7 -7
  53. package/dist/llcsharp/code-model.d.ts.map +1 -1
  54. package/dist/llcsharp/enums/enum.d.ts +1 -1
  55. package/dist/llcsharp/enums/enum.d.ts.map +1 -1
  56. package/dist/llcsharp/enums/enum.js +42 -42
  57. package/dist/llcsharp/enums/enum.js.map +1 -1
  58. package/dist/llcsharp/exports.js +5 -1
  59. package/dist/llcsharp/exports.js.map +1 -1
  60. package/dist/llcsharp/generator.d.ts +3 -2
  61. package/dist/llcsharp/generator.d.ts.map +1 -1
  62. package/dist/llcsharp/generator.js.map +1 -1
  63. package/dist/llcsharp/model/idictionary.js +16 -16
  64. package/dist/llcsharp/model/idictionary.js.map +1 -1
  65. package/dist/llcsharp/model/interface.d.ts +1 -1
  66. package/dist/llcsharp/model/interface.d.ts.map +1 -1
  67. package/dist/llcsharp/model/interface.js +19 -19
  68. package/dist/llcsharp/model/interface.js.map +1 -1
  69. package/dist/llcsharp/model/model-class-dictionary.js +18 -18
  70. package/dist/llcsharp/model/model-class-dictionary.js.map +1 -1
  71. package/dist/llcsharp/model/model-class-json.js +20 -20
  72. package/dist/llcsharp/model/model-class-json.js.map +1 -1
  73. package/dist/llcsharp/model/model-class-serializer.d.ts +1 -1
  74. package/dist/llcsharp/model/model-class-serializer.d.ts.map +1 -1
  75. package/dist/llcsharp/model/model-class-serializer.js +6 -6
  76. package/dist/llcsharp/model/model-class-serializer.js.map +1 -1
  77. package/dist/llcsharp/model/model-class.d.ts +1 -1
  78. package/dist/llcsharp/model/model-class.d.ts.map +1 -1
  79. package/dist/llcsharp/model/model-class.js +108 -97
  80. package/dist/llcsharp/model/model-class.js.map +1 -1
  81. package/dist/llcsharp/model/namespace.d.ts +1 -1
  82. package/dist/llcsharp/model/namespace.d.ts.map +1 -1
  83. package/dist/llcsharp/model/namespace.js +2 -2
  84. package/dist/llcsharp/model/namespace.js.map +1 -1
  85. package/dist/llcsharp/model/property.d.ts +1 -1
  86. package/dist/llcsharp/model/property.d.ts.map +1 -1
  87. package/dist/llcsharp/model/property.js +20 -20
  88. package/dist/llcsharp/model/property.js.map +1 -1
  89. package/dist/llcsharp/operation/api-class.d.ts.map +1 -1
  90. package/dist/llcsharp/operation/api-class.js +26 -1
  91. package/dist/llcsharp/operation/api-class.js.map +1 -1
  92. package/dist/llcsharp/operation/method.d.ts +10 -5
  93. package/dist/llcsharp/operation/method.d.ts.map +1 -1
  94. package/dist/llcsharp/operation/method.js +287 -134
  95. package/dist/llcsharp/operation/method.js.map +1 -1
  96. package/dist/llcsharp/operation/parameter.d.ts +1 -1
  97. package/dist/llcsharp/operation/parameter.d.ts.map +1 -1
  98. package/dist/llcsharp/operation/parameter.js +10 -10
  99. package/dist/llcsharp/operation/parameter.js.map +1 -1
  100. package/dist/llcsharp/project.d.ts +8 -4
  101. package/dist/llcsharp/project.d.ts.map +1 -1
  102. package/dist/llcsharp/project.js +10 -1
  103. package/dist/llcsharp/project.js.map +1 -1
  104. package/dist/llcsharp/schema/Uuid.d.ts +1 -1
  105. package/dist/llcsharp/schema/Uuid.d.ts.map +1 -1
  106. package/dist/llcsharp/schema/Uuid.js +2 -2
  107. package/dist/llcsharp/schema/Uuid.js.map +1 -1
  108. package/dist/llcsharp/schema/array.d.ts +1 -1
  109. package/dist/llcsharp/schema/array.d.ts.map +1 -1
  110. package/dist/llcsharp/schema/array.js +45 -43
  111. package/dist/llcsharp/schema/array.js.map +1 -1
  112. package/dist/llcsharp/schema/binary.d.ts +1 -1
  113. package/dist/llcsharp/schema/binary.d.ts.map +1 -1
  114. package/dist/llcsharp/schema/binary.js +9 -9
  115. package/dist/llcsharp/schema/binary.js.map +1 -1
  116. package/dist/llcsharp/schema/boolean.d.ts +1 -1
  117. package/dist/llcsharp/schema/boolean.d.ts.map +1 -1
  118. package/dist/llcsharp/schema/byte-array.d.ts +1 -1
  119. package/dist/llcsharp/schema/byte-array.d.ts.map +1 -1
  120. package/dist/llcsharp/schema/byte-array.js +24 -24
  121. package/dist/llcsharp/schema/byte-array.js.map +1 -1
  122. package/dist/llcsharp/schema/char.d.ts +1 -1
  123. package/dist/llcsharp/schema/char.d.ts.map +1 -1
  124. package/dist/llcsharp/schema/char.js +1 -1
  125. package/dist/llcsharp/schema/char.js.map +1 -1
  126. package/dist/llcsharp/schema/date-time.d.ts +1 -1
  127. package/dist/llcsharp/schema/date-time.d.ts.map +1 -1
  128. package/dist/llcsharp/schema/date-time.js +45 -41
  129. package/dist/llcsharp/schema/date-time.js.map +1 -1
  130. package/dist/llcsharp/schema/date.d.ts +1 -1
  131. package/dist/llcsharp/schema/date.d.ts.map +1 -1
  132. package/dist/llcsharp/schema/duration.d.ts +1 -1
  133. package/dist/llcsharp/schema/duration.d.ts.map +1 -1
  134. package/dist/llcsharp/schema/duration.js +9 -7
  135. package/dist/llcsharp/schema/duration.js.map +1 -1
  136. package/dist/llcsharp/schema/enum.d.ts +6 -2
  137. package/dist/llcsharp/schema/enum.d.ts.map +1 -1
  138. package/dist/llcsharp/schema/enum.js +13 -4
  139. package/dist/llcsharp/schema/enum.js.map +1 -1
  140. package/dist/llcsharp/schema/extended-type-declaration.d.ts +1 -1
  141. package/dist/llcsharp/schema/extended-type-declaration.d.ts.map +1 -1
  142. package/dist/llcsharp/schema/fixed-array.d.ts +1 -1
  143. package/dist/llcsharp/schema/fixed-array.d.ts.map +1 -1
  144. package/dist/llcsharp/schema/fixed-array.js +44 -42
  145. package/dist/llcsharp/schema/fixed-array.js.map +1 -1
  146. package/dist/llcsharp/schema/integer.d.ts +1 -1
  147. package/dist/llcsharp/schema/integer.d.ts.map +1 -1
  148. package/dist/llcsharp/schema/integer.js +5 -5
  149. package/dist/llcsharp/schema/integer.js.map +1 -1
  150. package/dist/llcsharp/schema/object.d.ts +1 -1
  151. package/dist/llcsharp/schema/object.d.ts.map +1 -1
  152. package/dist/llcsharp/schema/object.js +28 -28
  153. package/dist/llcsharp/schema/object.js.map +1 -1
  154. package/dist/llcsharp/schema/password.d.ts +1 -1
  155. package/dist/llcsharp/schema/password.d.ts.map +1 -1
  156. package/dist/llcsharp/schema/password.js +13 -13
  157. package/dist/llcsharp/schema/password.js.map +1 -1
  158. package/dist/llcsharp/schema/primitive.d.ts +1 -1
  159. package/dist/llcsharp/schema/primitive.d.ts.map +1 -1
  160. package/dist/llcsharp/schema/primitive.js +40 -37
  161. package/dist/llcsharp/schema/primitive.js.map +1 -1
  162. package/dist/llcsharp/schema/schema-resolver.d.ts +1 -1
  163. package/dist/llcsharp/schema/schema-resolver.d.ts.map +1 -1
  164. package/dist/llcsharp/schema/schema-resolver.js +2 -1
  165. package/dist/llcsharp/schema/schema-resolver.js.map +1 -1
  166. package/dist/llcsharp/schema/string.d.ts +1 -1
  167. package/dist/llcsharp/schema/string.d.ts.map +1 -1
  168. package/dist/llcsharp/schema/string.js +48 -44
  169. package/dist/llcsharp/schema/string.js.map +1 -1
  170. package/dist/llcsharp/schema/uri.d.ts +1 -1
  171. package/dist/llcsharp/schema/uri.d.ts.map +1 -1
  172. package/dist/llcsharp/schema/uri.js +2 -2
  173. package/dist/llcsharp/schema/uri.js.map +1 -1
  174. package/dist/llcsharp/validations.js +2 -2
  175. package/dist/llcsharp/validations.js.map +1 -1
  176. package/dist/main.d.ts.map +1 -1
  177. package/dist/main.js +5 -2
  178. package/dist/main.js.map +1 -1
  179. package/dist/models/model-extensions.d.ts +1 -1
  180. package/dist/models/model-extensions.d.ts.map +1 -1
  181. package/dist/models/model-extensions.js +39 -39
  182. package/dist/models/model-extensions.js.map +1 -1
  183. package/dist/module/module-class.d.ts.map +1 -1
  184. package/dist/module/module-class.js +45 -15
  185. package/dist/module/module-class.js.map +1 -1
  186. package/dist/module/module-namespace.js +3 -3
  187. package/dist/module/module-namespace.js.map +1 -1
  188. package/dist/plugins/add-azure-completers-v2.d.ts +6 -1
  189. package/dist/plugins/add-azure-completers-v2.d.ts.map +1 -1
  190. package/dist/plugins/add-azure-completers-v2.js +5 -4
  191. package/dist/plugins/add-azure-completers-v2.js.map +1 -1
  192. package/dist/plugins/create-commands-v2.d.ts +16 -7
  193. package/dist/plugins/create-commands-v2.d.ts.map +1 -1
  194. package/dist/plugins/create-commands-v2.js +269 -66
  195. package/dist/plugins/create-commands-v2.js.map +1 -1
  196. package/dist/plugins/cs-namer-v2.d.ts +6 -1
  197. package/dist/plugins/cs-namer-v2.d.ts.map +1 -1
  198. package/dist/plugins/cs-namer-v2.js +42 -41
  199. package/dist/plugins/cs-namer-v2.js.map +1 -1
  200. package/dist/plugins/llcsharp-v2.d.ts +5 -2
  201. package/dist/plugins/llcsharp-v2.d.ts.map +1 -1
  202. package/dist/plugins/llcsharp-v2.js +11 -9
  203. package/dist/plugins/llcsharp-v2.js.map +1 -1
  204. package/dist/plugins/modifiers-v2.d.ts +6 -1
  205. package/dist/plugins/modifiers-v2.d.ts.map +1 -1
  206. package/dist/plugins/modifiers-v2.js +120 -92
  207. package/dist/plugins/modifiers-v2.js.map +1 -1
  208. package/dist/plugins/plugin-create-inline-properties.d.ts +6 -1
  209. package/dist/plugins/plugin-create-inline-properties.d.ts.map +1 -1
  210. package/dist/plugins/plugin-create-inline-properties.js +44 -32
  211. package/dist/plugins/plugin-create-inline-properties.js.map +1 -1
  212. package/dist/plugins/plugin-tweak-m4-model.d.ts +7 -1
  213. package/dist/plugins/plugin-tweak-m4-model.d.ts.map +1 -1
  214. package/dist/plugins/plugin-tweak-m4-model.js +28 -11
  215. package/dist/plugins/plugin-tweak-m4-model.js.map +1 -1
  216. package/dist/plugins/plugin-tweak-model-azure-v2.d.ts +6 -1
  217. package/dist/plugins/plugin-tweak-model-azure-v2.d.ts.map +1 -1
  218. package/dist/plugins/plugin-tweak-model-azure-v2.js +32 -22
  219. package/dist/plugins/plugin-tweak-model-azure-v2.js.map +1 -1
  220. package/dist/plugins/plugin-tweak-model.d.ts +6 -1
  221. package/dist/plugins/plugin-tweak-model.d.ts.map +1 -1
  222. package/dist/plugins/plugin-tweak-model.js +33 -32
  223. package/dist/plugins/plugin-tweak-model.js.map +1 -1
  224. package/dist/plugins/powershell-v2.d.ts +5 -2
  225. package/dist/plugins/powershell-v2.d.ts.map +1 -1
  226. package/dist/plugins/powershell-v2.js +32 -28
  227. package/dist/plugins/powershell-v2.js.map +1 -1
  228. package/dist/plugins/ps-namer-v2.d.ts +6 -1
  229. package/dist/plugins/ps-namer-v2.d.ts.map +1 -1
  230. package/dist/plugins/ps-namer-v2.js +33 -32
  231. package/dist/plugins/ps-namer-v2.js.map +1 -1
  232. package/dist/plugins/sdk-create-inline-properties.d.ts +1 -1
  233. package/dist/plugins/sdk-create-inline-properties.d.ts.map +1 -1
  234. package/dist/plugins/sdk-create-inline-properties.js +129 -39
  235. package/dist/plugins/sdk-create-inline-properties.js.map +1 -1
  236. package/dist/plugins/sdk-cs-namer.d.ts +1 -1
  237. package/dist/plugins/sdk-cs-namer.d.ts.map +1 -1
  238. package/dist/plugins/sdk-cs-namer.js +59 -34
  239. package/dist/plugins/sdk-cs-namer.js.map +1 -1
  240. package/dist/plugins/sdk-cs-simplifier.d.ts +1 -1
  241. package/dist/plugins/sdk-cs-simplifier.d.ts.map +1 -1
  242. package/dist/plugins/sdk-cs-simplifier.js +3 -3
  243. package/dist/plugins/sdk-cs-simplifier.js.map +1 -1
  244. package/dist/plugins/sdk-generate.d.ts +1 -1
  245. package/dist/plugins/sdk-generate.d.ts.map +1 -1
  246. package/dist/plugins/sdk-generate.js +23 -18
  247. package/dist/plugins/sdk-generate.js.map +1 -1
  248. package/dist/plugins/sdk-modifiers.d.ts +4 -0
  249. package/dist/plugins/sdk-modifiers.d.ts.map +1 -0
  250. package/dist/plugins/sdk-modifiers.js +175 -0
  251. package/dist/plugins/sdk-modifiers.js.map +1 -0
  252. package/dist/plugins/sdk-tweak-model.d.ts +1 -1
  253. package/dist/plugins/sdk-tweak-model.d.ts.map +1 -1
  254. package/dist/plugins/sdk-tweak-model.js +140 -44
  255. package/dist/plugins/sdk-tweak-model.js.map +1 -1
  256. package/dist/sdk/project.d.ts +2 -2
  257. package/dist/sdk/project.d.ts.map +1 -1
  258. package/dist/sdk/project.js +10 -9
  259. package/dist/sdk/project.js.map +1 -1
  260. package/dist/sdk/state.d.ts +2 -2
  261. package/dist/sdk/state.d.ts.map +1 -1
  262. package/dist/sdk/utility.d.ts +12 -3
  263. package/dist/sdk/utility.d.ts.map +1 -1
  264. package/dist/sdk/utility.js +122 -30
  265. package/dist/sdk/utility.js.map +1 -1
  266. package/dist/utils/PwshModel.d.ts +1 -1
  267. package/dist/utils/PwshModel.d.ts.map +1 -1
  268. package/dist/utils/PwshModel.js +1 -1
  269. package/dist/utils/PwshModel.js.map +1 -1
  270. package/dist/utils/SdkModel.d.ts +1 -1
  271. package/dist/utils/SdkModel.d.ts.map +1 -1
  272. package/dist/utils/SdkModel.js +1 -1
  273. package/dist/utils/SdkModel.js.map +1 -1
  274. package/dist/utils/command-operation.d.ts +11 -3
  275. package/dist/utils/command-operation.d.ts.map +1 -1
  276. package/dist/utils/command-operation.js +26 -4
  277. package/dist/utils/command-operation.js.map +1 -1
  278. package/dist/utils/components.d.ts +1 -1
  279. package/dist/utils/components.d.ts.map +1 -1
  280. package/dist/utils/components.js +2 -2
  281. package/dist/utils/components.js.map +1 -1
  282. package/dist/utils/http-operation.d.ts +2 -0
  283. package/dist/utils/http-operation.d.ts.map +1 -1
  284. package/dist/utils/http-operation.js +16 -12
  285. package/dist/utils/http-operation.js.map +1 -1
  286. package/dist/utils/model-state.d.ts +7 -5
  287. package/dist/utils/model-state.d.ts.map +1 -1
  288. package/dist/utils/model-state.js +28 -20
  289. package/dist/utils/model-state.js.map +1 -1
  290. package/dist/utils/programatic-operation.d.ts +1 -1
  291. package/dist/utils/programatic-operation.d.ts.map +1 -1
  292. package/dist/utils/programatic-operation.js +1 -1
  293. package/dist/utils/programatic-operation.js.map +1 -1
  294. package/dist/utils/resolve-conflicts.js +8 -8
  295. package/dist/utils/resolve-conflicts.js.map +1 -1
  296. package/dist/utils/schema.d.ts +1 -1
  297. package/dist/utils/schema.d.ts.map +1 -1
  298. package/dist/utils/schema.js +11 -11
  299. package/dist/utils/schema.js.map +1 -1
  300. package/dist/utils/security-scheme.d.ts +2 -2
  301. package/dist/utils/security-scheme.d.ts.map +1 -1
  302. package/dist/utils/security-scheme.js +2 -2
  303. package/dist/utils/security-scheme.js.map +1 -1
  304. package/dist/utils/sort-parameters.d.ts +1 -1
  305. package/dist/utils/sort-parameters.d.ts.map +1 -1
  306. package/dist/utils/tsp-generator.d.ts +3 -0
  307. package/dist/utils/tsp-generator.d.ts.map +1 -0
  308. package/dist/utils/tsp-generator.js +65 -0
  309. package/dist/utils/tsp-generator.js.map +1 -0
  310. package/dist/utils/tsp-host.d.ts +42 -0
  311. package/dist/utils/tsp-host.d.ts.map +1 -0
  312. package/dist/utils/tsp-host.js +56 -0
  313. package/dist/utils/tsp-host.js.map +1 -0
  314. package/generators/readme.ts +0 -3
  315. package/package.json +11 -10
  316. package/resources/assets/build-module.ps1 +29 -2
  317. package/resources/assets/create-model-cmdlets.ps1 +1 -0
  318. package/resources/assets/generate-help.ps1 +2 -2
  319. package/resources/assets/generate-portal-ux.ps1 +6 -22
  320. package/resources/assets/test/loadEnv.ps1 +1 -1
  321. package/resources/assets/test-module.ps1 +9 -5
  322. package/resources/assets/tools/Resources/README.md +0 -3
  323. package/resources/assets/tools/Resources/custom/New-AzDeployment.ps1 +2 -2
  324. package/resources/assets/tools/Resources/how-to.md +2 -0
  325. package/resources/built-time-cmdlets.csproj +1 -0
  326. package/resources/modules/Az.Accounts/2.13.1/Accounts.format.ps1xml +554 -0
  327. package/resources/modules/Az.Accounts/2.13.1/Accounts.generated.format.ps1xml +471 -0
  328. package/resources/modules/Az.Accounts/2.13.1/Accounts.types.ps1xml +306 -0
  329. package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Az.Accounts.nuspec +4 -5
  330. package/resources/modules/Az.Accounts/2.13.1/Az.Accounts.psd1 +389 -0
  331. package/resources/modules/Az.Accounts/2.13.1/Az.Accounts.psm1 +365 -0
  332. package/resources/modules/Az.Accounts/2.13.1/FuzzySharp.dll +0 -0
  333. package/resources/modules/Az.Accounts/2.13.1/Microsoft.ApplicationInsights.dll +0 -0
  334. package/resources/modules/Az.Accounts/2.13.1/Microsoft.Azure.PowerShell.AssemblyLoading.dll +0 -0
  335. package/resources/modules/Az.Accounts/2.13.1/Microsoft.Azure.PowerShell.Authentication.Abstractions.dll +0 -0
  336. package/resources/modules/Az.Accounts/2.13.1/Microsoft.Azure.PowerShell.Authentication.ResourceManager.dll +0 -0
  337. package/resources/modules/Az.Accounts/2.13.1/Microsoft.Azure.PowerShell.Authentication.dll +0 -0
  338. package/resources/modules/Az.Accounts/2.13.1/Microsoft.Azure.PowerShell.AuthenticationAssemblyLoadContext.dll +0 -0
  339. package/resources/modules/Az.Accounts/2.13.1/Microsoft.Azure.PowerShell.Authenticators.dll +0 -0
  340. package/resources/modules/Az.Accounts/2.13.1/Microsoft.Azure.PowerShell.Clients.Aks.dll +0 -0
  341. package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Microsoft.Azure.PowerShell.Clients.Authorization.dll +0 -0
  342. package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Microsoft.Azure.PowerShell.Clients.Compute.dll +0 -0
  343. package/resources/modules/Az.Accounts/2.13.1/Microsoft.Azure.PowerShell.Clients.Graph.Rbac.dll +0 -0
  344. package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Microsoft.Azure.PowerShell.Clients.KeyVault.dll +0 -0
  345. package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Microsoft.Azure.PowerShell.Clients.Monitor.dll +0 -0
  346. package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Microsoft.Azure.PowerShell.Clients.Network.dll +0 -0
  347. package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Microsoft.Azure.PowerShell.Clients.PolicyInsights.dll +0 -0
  348. package/resources/modules/Az.Accounts/2.13.1/Microsoft.Azure.PowerShell.Clients.ResourceManager.dll +0 -0
  349. package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Microsoft.Azure.PowerShell.Clients.Storage.Management.dll +0 -0
  350. package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Microsoft.Azure.PowerShell.Clients.Websites.dll +0 -0
  351. package/resources/modules/Az.Accounts/2.13.1/Microsoft.Azure.PowerShell.Cmdlets.Accounts.dll +0 -0
  352. package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Microsoft.Azure.PowerShell.Cmdlets.Accounts.dll-Help.xml +2510 -779
  353. package/resources/modules/Az.Accounts/2.13.1/Microsoft.Azure.PowerShell.Common.Share.dll +0 -0
  354. package/resources/modules/Az.Accounts/2.13.1/Microsoft.Azure.PowerShell.Common.dll +0 -0
  355. package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Microsoft.Azure.PowerShell.Storage.dll +0 -0
  356. package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Microsoft.Azure.PowerShell.Strategies.dll +0 -0
  357. package/resources/modules/Az.Accounts/2.13.1/Microsoft.Rest.ClientRuntime.dll +0 -0
  358. package/resources/modules/Az.Accounts/2.13.1/PostImportScripts/LoadAuthenticators.ps1 +222 -0
  359. package/resources/modules/Az.Accounts/2.13.1/StartupScripts/AzError.ps1 +281 -0
  360. package/resources/modules/Az.Accounts/2.13.1/StartupScripts/InitializeAssemblyResolver.ps1 +242 -0
  361. package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/[Content_Types].xml +2 -3
  362. package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/_rels/.rels +2 -2
  363. package/resources/modules/Az.Accounts/2.13.1/lib/netcoreapp2.1/Azure.Core.dll +0 -0
  364. package/resources/modules/Az.Accounts/2.13.1/lib/netcoreapp2.1/Microsoft.Identity.Client.dll +0 -0
  365. package/resources/modules/Az.Accounts/2.13.1/lib/netcoreapp3.1/Microsoft.Identity.Client.Extensions.Msal.dll +0 -0
  366. package/resources/modules/Az.Accounts/2.13.1/lib/netfx/Azure.Core.dll +0 -0
  367. package/resources/modules/Az.Accounts/2.13.1/lib/netfx/Microsoft.Identity.Client.Extensions.Msal.dll +0 -0
  368. package/resources/modules/Az.Accounts/2.13.1/lib/netfx/Microsoft.Identity.Client.dll +0 -0
  369. package/resources/modules/Az.Accounts/2.13.1/lib/netfx/Newtonsoft.Json.dll +0 -0
  370. package/resources/modules/Az.Accounts/2.13.1/lib/netfx/System.Diagnostics.DiagnosticSource.dll +0 -0
  371. package/resources/modules/Az.Accounts/2.13.1/lib/netfx/System.Reflection.DispatchProxy.dll +0 -0
  372. package/resources/modules/Az.Accounts/2.13.1/lib/netfx/System.Runtime.CompilerServices.Unsafe.dll +0 -0
  373. package/resources/modules/Az.Accounts/2.13.1/lib/netstandard2.0/Azure.Identity.BrokeredAuthentication.dll +0 -0
  374. package/resources/modules/Az.Accounts/2.13.1/lib/netstandard2.0/Azure.Identity.dll +0 -0
  375. package/resources/modules/Az.Accounts/2.13.1/lib/netstandard2.0/Microsoft.Identity.Client.Broker.dll +0 -0
  376. package/resources/modules/Az.Accounts/2.13.1/lib/netstandard2.0/Microsoft.Identity.Client.NativeInterop.dll +0 -0
  377. package/resources/modules/Az.Accounts/2.13.1/lib/netstandard2.0/Microsoft.IdentityModel.Abstractions.dll +0 -0
  378. package/resources/modules/Az.Accounts/2.13.1/lib/netstandard2.0/System.Security.AccessControl.dll +0 -0
  379. package/resources/modules/Az.Accounts/2.13.1/lib/netstandard2.0/System.Security.Permissions.dll +0 -0
  380. package/resources/modules/Az.Accounts/2.13.1/lib/netstandard2.0/System.Security.Principal.Windows.dll +0 -0
  381. package/resources/modules/Az.Accounts/2.13.1/lib/netstandard2.0/msalruntime.dll +0 -0
  382. package/resources/modules/Az.Accounts/2.13.1/lib/netstandard2.0/msalruntime_arm64.dll +0 -0
  383. package/resources/modules/Az.Accounts/2.13.1/lib/netstandard2.0/msalruntime_x86.dll +0 -0
  384. package/resources/modules/Az.Accounts/2.13.1/package/services/metadata/core-properties/f9ac9c2e40914e78a646a7b0b997403b.psmdcp +11 -0
  385. package/resources/psruntime/BuildTime/Cmdlets/ExportHelpMarkdown.cs +4 -1
  386. package/resources/psruntime/BuildTime/Cmdlets/ExportProxyCmdlet.cs +6 -3
  387. package/resources/psruntime/BuildTime/Cmdlets/ExportPsd1.cs +7 -4
  388. package/resources/psruntime/BuildTime/Cmdlets/ExportTestStub.cs +130 -81
  389. package/resources/psruntime/BuildTime/Cmdlets/NewAssemblyInfo.cs +64 -0
  390. package/resources/psruntime/BuildTime/MarkdownRenderer.cs +17 -9
  391. package/resources/psruntime/BuildTime/Models/PsProxyOutputs.cs +36 -8
  392. package/resources/psruntime/BuildTime/Models/PsProxyTypes.cs +21 -10
  393. package/resources/psruntime/BuildTime/PsAttributes.cs +5 -0
  394. package/resources/psruntime/BuildTime/PsHelpers.cs +4 -3
  395. package/resources/psruntime/MessageAttribute.cs +45 -55
  396. package/resources/psruntime/MessageAttributeHelper.cs +30 -7
  397. package/resources/psruntime/Properties/Resources.Designer.cs +25 -3
  398. package/resources/psruntime/Properties/Resources.resx +8 -2
  399. package/resources/runtime/csharp/pipeline/PipelineMocking.cs +1 -1
  400. package/resources/templates/azureMethod.ejs +2 -2
  401. package/resources/templates/azureMethodGroup.ejs +2 -2
  402. package/resources/templates/azureServiceClient.ejs +11 -4
  403. package/resources/templates/enum.ejs +3 -3
  404. package/resources/templates/extensionMethod.ejs +18 -12
  405. package/resources/templates/extensions.ejs +9 -2
  406. package/resources/templates/longRunningOperationMethod.ejs +10 -8
  407. package/resources/templates/method.ejs +10 -8
  408. package/resources/templates/methodBodyRestCall.ejs +77 -32
  409. package/resources/templates/methodGroupInterface.ejs +2 -61
  410. package/resources/templates/methodGroupInterfaceBody.ejs +60 -0
  411. package/resources/templates/model.ejs +15 -15
  412. package/resources/templates/serviceClientBody.ejs +8 -8
  413. package/resources/templates/serviceClientInterface.ejs +10 -4
  414. package/resources/utils/Get-SubscriptionIdTestSafe.ps1 +7 -0
  415. package/dist/utils/WrapComments.d.ts +0 -2
  416. package/dist/utils/WrapComments.d.ts.map +0 -1
  417. package/dist/utils/WrapComments.js +0 -46
  418. package/dist/utils/WrapComments.js.map +0 -1
  419. package/resources/modules/Az.Accounts/2.7.5/Accounts.format.ps1xml +0 -496
  420. package/resources/modules/Az.Accounts/2.7.5/Accounts.generated.format.ps1xml +0 -468
  421. package/resources/modules/Az.Accounts/2.7.5/Accounts.types.ps1xml +0 -303
  422. package/resources/modules/Az.Accounts/2.7.5/Az.Accounts.psd1 +0 -387
  423. package/resources/modules/Az.Accounts/2.7.5/Az.Accounts.psm1 +0 -375
  424. package/resources/modules/Az.Accounts/2.7.5/AzSharedAlcAssemblies/Azure.Core.dll +0 -0
  425. package/resources/modules/Az.Accounts/2.7.5/AzSharedAlcAssemblies/Azure.Identity.dll +0 -0
  426. package/resources/modules/Az.Accounts/2.7.5/AzSharedAlcAssemblies/Microsoft.Identity.Client.Extensions.Msal.dll +0 -0
  427. package/resources/modules/Az.Accounts/2.7.5/AzSharedAlcAssemblies/Microsoft.Identity.Client.dll +0 -0
  428. package/resources/modules/Az.Accounts/2.7.5/Microsoft.ApplicationInsights.dll +0 -0
  429. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.Authentication.Abstractions.dll +0 -0
  430. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.Authentication.ResourceManager.deps.json +0 -2309
  431. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.Authentication.ResourceManager.dll +0 -0
  432. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.Authentication.deps.json +0 -2273
  433. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.Authentication.dll +0 -0
  434. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.AuthenticationAssemblyLoadContext.deps.json +0 -1316
  435. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.AuthenticationAssemblyLoadContext.dll +0 -0
  436. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.Authenticators.dll +0 -0
  437. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.Clients.Aks.dll +0 -0
  438. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.Clients.Graph.Rbac.dll +0 -0
  439. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.Clients.ResourceManager.dll +0 -0
  440. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.Cmdlets.Accounts.deps.json +0 -2413
  441. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.Cmdlets.Accounts.dll +0 -0
  442. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.Common.Share.dll +0 -0
  443. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.Common.dll +0 -0
  444. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Rest.ClientRuntime.dll +0 -0
  445. package/resources/modules/Az.Accounts/2.7.5/PostImportScripts/LoadAuthenticators.ps1 +0 -219
  446. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/Azure.Core.dll +0 -0
  447. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/Azure.Identity.dll +0 -0
  448. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/Microsoft.Azure.PowerShell.Authenticators.dll +0 -0
  449. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/Microsoft.Bcl.AsyncInterfaces.dll +0 -0
  450. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/Microsoft.Identity.Client.Extensions.Msal.dll +0 -0
  451. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/Microsoft.Identity.Client.dll +0 -0
  452. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/Newtonsoft.Json.12.0.3.dll +0 -0
  453. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/Newtonsoft.Json.dll +0 -0
  454. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/System.Diagnostics.DiagnosticSource.dll +0 -0
  455. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/System.Memory.Data.dll +0 -0
  456. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/System.Reflection.DispatchProxy.dll +0 -0
  457. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/System.Runtime.CompilerServices.Unsafe.dll +0 -0
  458. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/System.Security.AccessControl.dll +0 -0
  459. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/System.Security.Permissions.dll +0 -0
  460. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/System.Security.Principal.Windows.dll +0 -0
  461. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/System.Text.Json.dll +0 -0
  462. package/resources/modules/Az.Accounts/2.7.5/StartupScripts/AzError.ps1 +0 -278
  463. package/resources/modules/Az.Accounts/2.7.5/StartupScripts/InitializeAssemblyResolver.ps1 +0 -234
  464. package/resources/modules/Az.Accounts/2.7.5/package/services/metadata/core-properties/1aa0749a068a4238881858013f1a5b7f.psmdcp +0 -11
  465. /package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Hyak.Common.dll +0 -0
  466. /package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Microsoft.Azure.Common.dll +0 -0
  467. /package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Microsoft.Rest.ClientRuntime.Azure.dll +0 -0
  468. /package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Microsoft.WindowsAzure.Storage.DataMovement.dll +0 -0
  469. /package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Microsoft.WindowsAzure.Storage.dll +0 -0
  470. /package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/en-US/about_az.help.txt +0 -0
  471. /package/resources/modules/Az.Accounts/{2.7.5/PreloadAssemblies → 2.13.1/lib/netfx}/System.Numerics.Vectors.dll +0 -0
  472. /package/resources/modules/Az.Accounts/{2.7.5/PreloadAssemblies → 2.13.1/lib/netfx}/System.Security.Cryptography.Cng.dll +0 -0
  473. /package/resources/modules/Az.Accounts/{2.7.5/PreloadAssemblies → 2.13.1/lib/netfx}/System.Text.Encodings.Web.dll +0 -0
  474. /package/resources/modules/Az.Accounts/{2.7.5/PreloadAssemblies → 2.13.1/lib/netfx}/System.Xml.ReaderWriter.dll +0 -0
  475. /package/resources/modules/Az.Accounts/{2.7.5/AzSharedAlcAssemblies → 2.13.1/lib/netstandard2.0}/Microsoft.Bcl.AsyncInterfaces.dll +0 -0
  476. /package/resources/modules/Az.Accounts/{2.7.5/PreloadAssemblies → 2.13.1/lib/netstandard2.0}/System.Buffers.dll +0 -0
  477. /package/resources/modules/Az.Accounts/{2.7.5/AzSharedAlcAssemblies → 2.13.1/lib/netstandard2.0}/System.Memory.Data.dll +0 -0
  478. /package/resources/modules/Az.Accounts/{2.7.5/PreloadAssemblies → 2.13.1/lib/netstandard2.0}/System.Memory.dll +0 -0
  479. /package/resources/modules/Az.Accounts/{2.7.5/PreloadAssemblies → 2.13.1/lib/netstandard2.0}/System.Net.Http.WinHttpHandler.dll +0 -0
  480. /package/resources/modules/Az.Accounts/{2.7.5/PreloadAssemblies → 2.13.1/lib/netstandard2.0}/System.Private.ServiceModel.dll +0 -0
  481. /package/resources/modules/Az.Accounts/{2.7.5/PreloadAssemblies → 2.13.1/lib/netstandard2.0}/System.ServiceModel.Primitives.dll +0 -0
  482. /package/resources/modules/Az.Accounts/{2.7.5/AzSharedAlcAssemblies → 2.13.1/lib/netstandard2.0}/System.Text.Json.dll +0 -0
  483. /package/resources/modules/Az.Accounts/{2.7.5/PreloadAssemblies → 2.13.1/lib/netstandard2.0}/System.Threading.Tasks.Extensions.dll +0 -0
@@ -4,9 +4,9 @@
4
4
  * Licensed under the MIT License. See License.txt in the project root for license information.
5
5
  *--------------------------------------------------------------------------------------------*/
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.CmdletClass = exports.NewAddInfoAttribute = exports.addInfoAttribute = exports.addDefaultInfo = exports.addPreviewMessage = exports.addParameterBreakingChange = exports.addPSArgumentCompleterAttribute = exports.isEnumImplementation = exports.NewAddCompleterInfo = exports.addCompleterInfo = exports.createStepper = void 0;
7
+ exports.CmdletClass = exports.NewAddInfoAttribute = exports.addInfoAttribute = exports.addDefaultInfo = exports.addParameterPreviewMessage = exports.addParameterBreakingChange = exports.addPSArgumentCompleterAttribute = exports.isEnumImplementation = exports.NewAddCompleterInfo = exports.addCompleterInfo = exports.createStepper = void 0;
8
8
  const ejs = require('ejs');
9
- const codemodel_1 = require("@azure-tools/codemodel");
9
+ const codemodel_1 = require("@autorest/codemodel");
10
10
  const codemodel_v3_1 = require("@azure-tools/codemodel-v3");
11
11
  const command_operation_1 = require("../utils/command-operation");
12
12
  const schema_1 = require("../utils/schema");
@@ -15,7 +15,7 @@ const linq_1 = require("@azure-tools/linq");
15
15
  const codegen_csharp_1 = require("@azure-tools/codegen-csharp");
16
16
  const exports_1 = require("../llcsharp/exports");
17
17
  const powershell_declarations_1 = require("../internal/powershell-declarations");
18
- const autorest_extension_base_1 = require("@azure-tools/autorest-extension-base");
18
+ const extension_base_1 = require("@autorest/extension-base");
19
19
  const codegen_csharp_2 = require("@azure-tools/codegen-csharp");
20
20
  const model_class_1 = require("../llcsharp/model/model-class");
21
21
  const resourceName_1 = require("../utils/resourceName");
@@ -130,7 +130,7 @@ const category = {
130
130
  'Use': Verbs.Other,
131
131
  };
132
132
  function createStepper(p) {
133
- return codegen_csharp_1.toExpression(`${codegen_csharp_1.System.Linq.Enumerable.declaration}.Select<${exports_1.ClientRuntime.SendAsyncStep.declaration},${exports_1.ClientRuntime.SendAsyncStep.declaration}>(${p.value}, step =>
133
+ return (0, codegen_csharp_1.toExpression)(`${codegen_csharp_1.System.Linq.Enumerable.declaration}.Select<${exports_1.ClientRuntime.SendAsyncStep.declaration},${exports_1.ClientRuntime.SendAsyncStep.declaration}>(${p.value}, step =>
134
134
  (r, c, n) => {
135
135
  ${powershell_declarations_1.DefaultRunspace.value} = ${powershell_declarations_1.DefaultRunspace.value} ?? ${powershell_declarations_1.RunspaceFactory.declaration}.CreateRunspace();
136
136
  return step(r, c, n);
@@ -167,7 +167,7 @@ function isEnumImplementation(schema) {
167
167
  }
168
168
  exports.isEnumImplementation = isEnumImplementation;
169
169
  function addPSArgumentCompleterAttribute(targetProperty, parameterSchema) {
170
- const enumValues = linq_1.values(parameterSchema.language.csharp.enum.values).select(v => `"${v.value}"`).toArray().join(", ");
170
+ const enumValues = (0, linq_1.values)(parameterSchema.language.csharp.enum.values).select(v => `"${v.value}"`).toArray().join(', ');
171
171
  targetProperty.add(new codegen_csharp_1.Attribute(powershell_declarations_1.PSArgumentCompleterAttribute, { parameters: [`${enumValues}`] }));
172
172
  }
173
173
  exports.addPSArgumentCompleterAttribute = addPSArgumentCompleterAttribute;
@@ -175,11 +175,13 @@ function addParameterBreakingChange(targetProperty, parameter) {
175
175
  if (parameter.breakingChange) {
176
176
  const parameters = [];
177
177
  parameters.push(`"${parameter.breakingChange.parameterName}"`);
178
- if (parameter.breakingChange.deprecateByVersion) {
179
- parameters.push(`"${parameter.breakingChange.deprecateByVersion}"`);
180
- if (parameter.breakingChange.changeInEfectByDate)
181
- parameters.push(`"${parameter.breakingChange.changeInEfectByDate}"`);
178
+ if (!parameter.breakingChange.deprecateByVersion || !parameter.breakingChange.deprecateByAzVersion) {
179
+ throw new Error(`breakingChange.deprecateByVersion and breakingChange.deprecateByAzVersion must be set for ${parameter.name}`);
182
180
  }
181
+ parameters.push(`"${parameter.breakingChange.deprecateByAzVersion}"`);
182
+ parameters.push(`"${parameter.breakingChange.deprecateByVersion}"`);
183
+ if (parameter.breakingChange.changeInEfectByDate)
184
+ parameters.push(`"${parameter.breakingChange.changeInEfectByDate}"`);
183
185
  if (parameter.breakingChange.replacement)
184
186
  parameters.push(`ReplaceMentCmdletParameterName="${parameter.breakingChange.replacement}"`);
185
187
  if (parameter.breakingChange.isBecomingMandatory)
@@ -203,12 +205,16 @@ function addParameterBreakingChange(targetProperty, parameter) {
203
205
  }
204
206
  }
205
207
  exports.addParameterBreakingChange = addParameterBreakingChange;
206
- function addPreviewMessage(targetProperty, parameter) {
207
- if (parameter.previewMessage) {
208
- targetProperty.add(new codegen_csharp_1.Attribute(exports_1.ClientRuntime.PreviewMessageAttribute, { parameters: [`"${parameter.previewMessage}"`] }));
208
+ function addParameterPreviewMessage(targetProperty, parameter) {
209
+ if (parameter.previewAnnouncement) {
210
+ const parameters = [];
211
+ parameters.push(`"${parameter.previewAnnouncement.previewMessage}"`);
212
+ if (parameter.previewAnnouncement.estimatedGaDate)
213
+ parameters.push(`"${parameter.previewAnnouncement.estimatedGaDate}"`);
214
+ targetProperty.add(new codegen_csharp_1.Attribute(exports_1.ClientRuntime.PreviewMessageAttribute, { parameters: parameters }));
209
215
  }
210
216
  }
211
- exports.addPreviewMessage = addPreviewMessage;
217
+ exports.addParameterPreviewMessage = addParameterPreviewMessage;
212
218
  function addDefaultInfo(targetProperty, parameter) {
213
219
  if (parameter.defaultInfo && parameter.defaultInfo.script) {
214
220
  targetProperty.add(new codegen_csharp_1.Attribute(exports_1.ClientRuntime.DefaultInfoAttribute, {
@@ -331,6 +337,11 @@ class CmdletClass extends codegen_csharp_1.Class {
331
337
  this.dropBodyParameter = operation.details.csharp.dropBodyParameter ? true : false;
332
338
  this.apply(objectInitializer);
333
339
  this.operation = operation;
340
+ this.apiCall = this.operation.callGraph[this.operation.callGraph.length - 1];
341
+ // create the response handlers
342
+ this.responses = [...(0, linq_1.values)(this.apiCall.responses), ...(0, linq_1.values)(this.apiCall.exceptions)];
343
+ this.callbackMethods = (0, linq_1.values)(this.responses).toArray().map(each => { var _a; return new codegen_csharp_1.LiteralExpression(((_a = each.language.csharp) === null || _a === void 0 ? void 0 : _a.name) || ''); });
344
+ this.operationParameters = [];
334
345
  this.state = state;
335
346
  this.thingsToSerialize = [];
336
347
  this.variantName = variantName;
@@ -339,14 +350,16 @@ class CmdletClass extends codegen_csharp_1.Class {
339
350
  this.interfaces.push(exports_1.ClientRuntime.IContext);
340
351
  this.eventListener = new exports_1.EventListener(new codegen_csharp_1.LiteralExpression(`((${exports_1.ClientRuntime.IEventListener})this)`), true);
341
352
  this.isViaIdentity = variantName.indexOf('ViaIdentity') > 0;
342
- this.clientsidePagination = !!operation.details.csharp.clientsidePagination && !!((_a = operation.callGraph[0].language.csharp) === null || _a === void 0 ? void 0 : _a.pageable);
353
+ this.clientsidePagination = !!operation.details.csharp.clientsidePagination && !!((_a = this.apiCall.language.csharp) === null || _a === void 0 ? void 0 : _a.pageable);
343
354
  this.inputObjectParameterName = 'InputObject';
344
355
  }
345
356
  async init() {
346
357
  // basic stuff
347
358
  this.addCommonStuff();
348
- this.description = codegen_1.escapeString(this.operation.details.csharp.description);
359
+ this.description = (0, codegen_1.escapeString)(this.operation.details.csharp.description);
349
360
  const $this = this;
361
+ this.disableTransformIdentityType = await $this.state.getValue('disable-transform-identity-type', false);
362
+ this.flattenUserAssignedIdentity = await $this.state.getValue('flatten-userassignedidentity', true);
350
363
  this.add(new codegen_csharp_1.Method('BeginProcessing', codegen_csharp_1.dotnet.Void, {
351
364
  override: codegen_csharp_1.Modifier.Override,
352
365
  access: codegen_csharp_1.Access.Protected,
@@ -354,10 +367,10 @@ class CmdletClass extends codegen_csharp_1.Class {
354
367
  *body() {
355
368
  if ($this.state.project.azure) {
356
369
  yield `var telemetryId = ${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.GetTelemetryId.Invoke();`;
357
- yield codegen_csharp_1.If('telemetryId != "" && telemetryId != "internal"', '__correlationId = telemetryId;');
370
+ yield (0, codegen_csharp_1.If)('telemetryId != "" && telemetryId != "internal"', '__correlationId = telemetryId;');
358
371
  }
359
372
  yield 'Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials);';
360
- yield codegen_csharp_1.If($this.$('Break'), `${exports_1.ClientRuntime.AttachDebugger}.Break();`);
373
+ yield (0, codegen_csharp_1.If)($this.$('Break'), `${exports_1.ClientRuntime.AttachDebugger}.Break();`);
361
374
  yield $this.eventListener.syncSignal(powershell_declarations_1.Events.CmdletBeginProcessing);
362
375
  }
363
376
  }));
@@ -376,9 +389,48 @@ class CmdletClass extends codegen_csharp_1.Class {
376
389
  this.implementIContext();
377
390
  // add constructors
378
391
  this.implementConstructors();
392
+ // add callback methods
393
+ this.NewImplementResponseMethod();
379
394
  // processRecord
380
- this.NewImplementProcessRecord(this.operation);
381
- this.NewImplementProcessRecordAsync(this.operation);
395
+ this.NewImplementProcessRecord();
396
+ // find each parameter to the method, and find out where the value is going to come from.
397
+ this.operationParameters =
398
+ (0, linq_1.values)(this.apiCall.parameters).
399
+ // filter out constants and path parameters when using piping for identity
400
+ where(each => { var _a, _b; return !((_a = each.language.csharp) === null || _a === void 0 ? void 0 : _a.constantValue) && ((_b = each.language.default) === null || _b === void 0 ? void 0 : _b.name) !== '$host'; } /* && (!$this.isViaIdentity || each.in !== ParameterLocation.Path) */).
401
+ select(p => {
402
+ var _a, _b, _c;
403
+ return {
404
+ name: (_a = p.language.csharp) === null || _a === void 0 ? void 0 : _a.name,
405
+ param: (0, linq_1.values)(this.properties).
406
+ where(each => each.metadata.parameterDefinition).
407
+ first(each => { var _a, _b; return ((_a = each.metadata.parameterDefinition.language.csharp) === null || _a === void 0 ? void 0 : _a.serializedName) === ((_b = p.language.csharp) === null || _b === void 0 ? void 0 : _b.serializedName); }),
408
+ parameterLocation: (_c = (_b = p.protocol) === null || _b === void 0 ? void 0 : _b.http) === null || _c === void 0 ? void 0 : _c.in
409
+ };
410
+ }).
411
+ select(each => {
412
+ if (each.param) {
413
+ const httpParam = (each.param.metadata.parameterDefinition);
414
+ if (httpParam.required) {
415
+ return {
416
+ name: each.param,
417
+ expression: each.param,
418
+ parameterLocation: each.parameterLocation
419
+ };
420
+ }
421
+ const httpParamTD = this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(httpParam.schema, httpParam.required, this.state);
422
+ return {
423
+ name: each.param,
424
+ expression: (0, codegen_csharp_1.toExpression)(`this.InvocationInformation.BoundParameters.ContainsKey("${each.param.value}") ? ${each.param.value} : ${httpParamTD.defaultOfType}`),
425
+ parameterLocation: each.parameterLocation
426
+ };
427
+ }
428
+ return { name: each.name, expression: codegen_csharp_1.dotnet.Null, parameterLocation: each.parameterLocation };
429
+ }).toArray();
430
+ this.NewImplementProcessRecordAsync();
431
+ if (this.state.project.azure) {
432
+ this.NewImplementWriteObject();
433
+ }
382
434
  this.debugMode = await this.state.getValue('debug', false);
383
435
  // json serialization
384
436
  this.NewImplementSerialization(this.operation);
@@ -393,7 +445,7 @@ class CmdletClass extends codegen_csharp_1.Class {
393
445
  var _a, _b, _c, _d, _e;
394
446
  const header = super.headerComment;
395
447
  let ops = '';
396
- for (const httpOperation of linq_1.values(this.operation.callGraph)) {
448
+ for (const httpOperation of (0, linq_1.values)(this.operation.callGraph)) {
397
449
  const request = (_a = httpOperation.requests) === null || _a === void 0 ? void 0 : _a[0];
398
450
  if (!request) {
399
451
  continue;
@@ -414,7 +466,7 @@ class CmdletClass extends codegen_csharp_1.Class {
414
466
  ops = `${ops}\n variant: ${this.operation.details.csharp.name}`;
415
467
  }
416
468
  }
417
- return ops ? `${header}\n${codegen_1.docComment(codegen_csharp_1.xmlize('remarks', ops))}` : header;
469
+ return ops ? `${header}\n${(0, codegen_1.docComment)((0, codegen_csharp_1.xmlize)('remarks', ops))}` : header;
418
470
  }
419
471
  AddSwitchViewProperty(responseType = codegen_csharp_1.dotnet.Object) {
420
472
  const fieldNames = this.fields.map(f => f.name);
@@ -432,7 +484,7 @@ class CmdletClass extends codegen_csharp_1.Class {
432
484
  FlushResponse(singleFlush = true) {
433
485
  const fieldNames = this.fields.map(f => f.name);
434
486
  return fieldNames.includes('_responseSize') ?
435
- codegen_csharp_1.If('1 ==_responseSize', function* () {
487
+ (0, codegen_csharp_1.If)('1 ==_responseSize', function* () {
436
488
  yield '// Flush buffer';
437
489
  if (singleFlush) {
438
490
  yield 'WriteObject(_firstResponse);';
@@ -447,16 +499,15 @@ class CmdletClass extends codegen_csharp_1.Class {
447
499
  if ($this.state.project.autoSwitchView) {
448
500
  if (isEnumerable) {
449
501
  return function* () {
450
- yield `var outputObjects = ${valueName};`;
451
- yield codegen_csharp_1.If('null != outputObjects', function* () {
452
- yield codegen_csharp_1.If('0 == _responseSize && 1 == outputObjects.Count', function* () {
453
- yield '_firstResponse = outputObjects[0];';
502
+ yield (0, codegen_csharp_1.If)(`null != ${valueName}`, function* () {
503
+ yield (0, codegen_csharp_1.If)(`0 == _responseSize && 1 == ${valueName}.Count`, function* () {
504
+ yield `_firstResponse = ${valueName}[0];`;
454
505
  yield '_responseSize = 1;';
455
506
  });
456
- yield codegen_csharp_1.Else(function* () {
507
+ yield (0, codegen_csharp_1.Else)(function* () {
457
508
  yield $this.FlushResponse(false);
458
509
  yield 'var values = new System.Collections.Generic.List<System.Management.Automation.PSObject>();';
459
- yield codegen_csharp_1.ForEach('value', 'outputObjects', function* () {
510
+ yield (0, codegen_csharp_1.ForEach)('value', valueName, function* () {
460
511
  yield 'values.Add(value.AddMultipleTypeNameIntoPSObject());';
461
512
  });
462
513
  yield 'WriteObject(values, true); ';
@@ -467,15 +518,14 @@ class CmdletClass extends codegen_csharp_1.Class {
467
518
  }
468
519
  else {
469
520
  return function* () {
470
- yield `var outputObject = ${valueName};`;
471
- yield codegen_csharp_1.If('null != outputObject', function* () {
472
- yield codegen_csharp_1.If('0 == _responseSize', function* () {
473
- yield '_firstResponse = outputObject;';
521
+ yield (0, codegen_csharp_1.If)(`null != ${valueName}`, function* () {
522
+ yield (0, codegen_csharp_1.If)('0 == _responseSize', function* () {
523
+ yield `_firstResponse = ${valueName};`;
474
524
  yield '_responseSize = 1;';
475
525
  });
476
- yield codegen_csharp_1.Else(function* () {
526
+ yield (0, codegen_csharp_1.Else)(function* () {
477
527
  yield $this.FlushResponse(false);
478
- yield 'WriteObject(outputObject.AddMultipleTypeNameIntoPSObject());';
528
+ yield `WriteObject(${valueName}.AddMultipleTypeNameIntoPSObject());`;
479
529
  yield '_responseSize = 2;';
480
530
  });
481
531
  });
@@ -483,7 +533,7 @@ class CmdletClass extends codegen_csharp_1.Class {
483
533
  }
484
534
  }
485
535
  else {
486
- return `WriteObject(${valueName}, ${isEnumerable})`;
536
+ return `WriteObject(${valueName}, ${isEnumerable});`;
487
537
  }
488
538
  }
489
539
  addCommonStuff() {
@@ -491,7 +541,7 @@ class CmdletClass extends codegen_csharp_1.Class {
491
541
  // add a private copy of invocation information for our own uses.
492
542
  const privateInvocationInfo = this.add(new codegen_csharp_1.Field('__invocationInfo', powershell_declarations_1.InvocationInfo, { description: 'A copy of the Invocation Info (necessary to allow asJob to clone this cmdlet)', access: codegen_csharp_1.Access.Private }));
493
543
  this.invocationInfo = new codegen_csharp_1.Property('InvocationInformation', powershell_declarations_1.InvocationInfo, { description: 'Accessor for our copy of the InvocationInfo.' });
494
- this.invocationInfo.get = codegen_csharp_1.toExpression(`${privateInvocationInfo.value} = ${privateInvocationInfo.value} ?? this.MyInvocation `);
544
+ this.invocationInfo.get = (0, codegen_csharp_1.toExpression)(`${privateInvocationInfo.value} = ${privateInvocationInfo.value} ?? this.MyInvocation `);
495
545
  this.invocationInfo.set = new codegen_csharp_1.Statements(privateInvocationInfo.assign('value'));
496
546
  this.add(this.invocationInfo);
497
547
  if (this.state.project.azure) {
@@ -517,6 +567,21 @@ class CmdletClass extends codegen_csharp_1.Class {
517
567
  if ($this.state.project.autoSwitchView) {
518
568
  yield $this.FlushResponse();
519
569
  }
570
+ if (!$this.state.project.azure) {
571
+ yield $this.eventListener.syncSignal(powershell_declarations_1.Events.CmdletEndProcessing);
572
+ }
573
+ else {
574
+ yield `var telemetryInfo = ${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.GetTelemetryInfo?.Invoke(__correlationId);`;
575
+ yield (0, codegen_csharp_1.If)('telemetryInfo != null', function* () {
576
+ yield 'telemetryInfo.TryGetValue("ShowSecretsWarning", out var showSecretsWarning);';
577
+ yield 'telemetryInfo.TryGetValue("SanitizedProperties", out var sanitizedProperties);';
578
+ yield 'telemetryInfo.TryGetValue("InvocationName", out var invocationName);';
579
+ yield (0, codegen_csharp_1.If)('showSecretsWarning == "true"', function* () {
580
+ yield (0, codegen_csharp_1.If)('string.IsNullOrEmpty(sanitizedProperties)', 'WriteWarning($"The output of cmdlet {invocationName} may compromise security by showing secrets. Learn more at https://go.microsoft.com/fwlink/?linkid=2258844");');
581
+ yield (0, codegen_csharp_1.Else)('WriteWarning($"The output of cmdlet {invocationName} may compromise security by showing the following secrets: {sanitizedProperties}. Learn more at https://go.microsoft.com/fwlink/?linkid=2258844");');
582
+ });
583
+ });
584
+ }
520
585
  });
521
586
  // debugging
522
587
  const brk = this.add(new codegen_csharp_1.Property('Break', powershell_declarations_1.SwitchParameter, { attributes: [], description: 'Wait for .NET debugger to attach' }));
@@ -542,40 +607,27 @@ class CmdletClass extends codegen_csharp_1.Class {
542
607
  proxyUri.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ParameterAttribute, { parameters: ['Mandatory = false', 'DontShow = true', 'HelpMessage = "The URI for the proxy server to use"'] }));
543
608
  proxyUri.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CategoryAttribute, { parameters: [`${powershell_declarations_1.ParameterCategory}.Runtime`] }));
544
609
  if (this.state.project.azure) {
545
- this.defaultProfile = this.add(new codegen_csharp_1.Property('DefaultProfile', powershell_declarations_1.PSObject, { description: 'The credentials, account, tenant, and subscription used for communication with Azure' }));
546
- this.defaultProfile.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ParameterAttribute, { parameters: ['Mandatory = false', 'HelpMessage = "The credentials, account, tenant, and subscription used for communication with Azure."'] }));
610
+ this.defaultProfile = this.add(new codegen_csharp_1.Property('DefaultProfile', powershell_declarations_1.PSObject, { description: 'The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription' }));
611
+ this.defaultProfile.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ParameterAttribute, { parameters: ['Mandatory = false', 'HelpMessage = "The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription."'] }));
547
612
  this.defaultProfile.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ValidateNotNull));
548
613
  this.defaultProfile.add(new codegen_csharp_1.Attribute(powershell_declarations_1.Alias, { parameters: ['"AzureRMContext"', '"AzureCredential"'] }));
549
614
  this.defaultProfile.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CategoryAttribute, { parameters: [`${powershell_declarations_1.ParameterCategory}.Azure`] }));
550
615
  }
551
616
  }
552
- NewIsWritableCmdlet(operation) {
553
- var _a, _b;
554
- if (operation.callGraph[0].requests) {
555
- switch ((_b = (_a = operation.callGraph[0].requests[0]) === null || _a === void 0 ? void 0 : _a.protocol.http) === null || _b === void 0 ? void 0 : _b.method.toLowerCase()) {
556
- case 'put':
557
- case 'post':
558
- case 'delete':
559
- case 'patch':
560
- return true;
561
- }
562
- }
563
- return false;
564
- }
565
- NewImplementProcessRecord(operation) {
617
+ NewImplementProcessRecord() {
566
618
  const $this = this;
567
- const writable = this.NewIsWritableCmdlet(operation);
619
+ const operation = $this.operation;
568
620
  this.add(new codegen_csharp_1.Method('ProcessRecord', undefined, { access: codegen_csharp_1.Access.Protected, override: codegen_csharp_1.Modifier.Override, description: 'Performs execution of the command.' })).add(function* () {
569
621
  yield $this.eventListener.syncSignal(powershell_declarations_1.Events.CmdletProcessRecordStart);
570
622
  if ($this.state.project.azure) {
571
623
  yield $this.processRecordId.assign('System.Guid.NewGuid().ToString()');
572
624
  }
573
- yield codegen_csharp_1.Try(function* () {
625
+ yield (0, codegen_csharp_1.Try)(function* () {
574
626
  var _a;
575
627
  yield '// work';
576
628
  const normal = new codegen_csharp_1.Statements(function* () {
577
629
  const acr = new codegen_csharp_1.LocalVariable('asyncCommandRuntime', codegen_csharp_1.dotnet.Var, { initializer: powershell_declarations_1.AsyncCommandRuntime.new(codegen_csharp_1.dotnet.This, $this.cancellationToken) });
578
- yield codegen_csharp_1.Using(acr.declarationExpression, function* () {
630
+ yield (0, codegen_csharp_1.Using)(acr.declarationExpression, function* () {
579
631
  yield `${acr}.Wait( ProcessRecordAsync(),${$this.cancellationToken});`;
580
632
  });
581
633
  });
@@ -588,7 +640,7 @@ class CmdletClass extends codegen_csharp_1.Class {
588
640
  nowait.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CategoryAttribute, { parameters: [`${powershell_declarations_1.ParameterCategory}.Runtime`] }));
589
641
  }
590
642
  const work = operation.asjob ? function* () {
591
- yield codegen_csharp_1.If('true == MyInvocation?.BoundParameters?.ContainsKey("AsJob")', function* () {
643
+ yield (0, codegen_csharp_1.If)('true == MyInvocation?.BoundParameters?.ContainsKey("AsJob")', function* () {
592
644
  // clone the cmdlet instance, since the instance can be reused and overwrite data.
593
645
  const instance = new codegen_csharp_1.LocalVariable('instance', codegen_csharp_1.dotnet.Var, { initializer: 'this.Clone()' });
594
646
  yield instance.declarationStatement;
@@ -605,46 +657,51 @@ class CmdletClass extends codegen_csharp_1.Class {
605
657
  // return the job to the user now.
606
658
  yield `WriteObject(${job});`;
607
659
  });
608
- yield codegen_csharp_1.Else(normal);
660
+ yield (0, codegen_csharp_1.Else)(normal);
609
661
  } : normal;
610
- if (writable) {
611
- yield codegen_csharp_1.If(`ShouldProcess($"Call remote '${(_a = operation.callGraph[0].language.csharp) === null || _a === void 0 ? void 0 : _a.name}' operation")`, work);
662
+ if ((0, command_operation_1.isWritableCmdlet)(operation) && !operation.details.csharp.supportShouldProcess) {
663
+ yield (0, codegen_csharp_1.If)(`ShouldProcess($"Call remote '${(_a = $this.apiCall.language.csharp) === null || _a === void 0 ? void 0 : _a.name}' operation")`, work);
612
664
  }
613
665
  else {
614
666
  yield work;
615
667
  }
616
668
  });
617
669
  const aggregateException = new codegen_csharp_1.Parameter('aggregateException', codegen_csharp_1.System.AggregateException);
618
- yield codegen_csharp_1.Catch(aggregateException, function* () {
670
+ yield (0, codegen_csharp_1.Catch)(aggregateException, function* () {
619
671
  yield '// unroll the inner exceptions to get the root cause';
620
- yield codegen_csharp_1.ForEach('innerException', new codegen_csharp_1.LiteralExpression(`${aggregateException.use}.Flatten().InnerExceptions`), function* () {
672
+ yield (0, codegen_csharp_1.ForEach)('innerException', new codegen_csharp_1.LiteralExpression(`${aggregateException.use}.Flatten().InnerExceptions`), function* () {
621
673
  yield $this.eventListener.syncSignal(powershell_declarations_1.Events.CmdletException, new codegen_csharp_1.LiteralExpression('$"{innerException.GetType().Name} - {innerException.Message} : {innerException.StackTrace}"'));
622
674
  yield '// Write exception out to error channel.';
623
- yield `WriteError( new ${powershell_declarations_1.ErrorRecord}(innerException,string.Empty, ${powershell_declarations_1.ErrorCategory('NotSpecified')}, null) );`;
675
+ yield `WriteError( new ${powershell_declarations_1.ErrorRecord}(innerException,string.Empty, ${(0, powershell_declarations_1.ErrorCategory)('NotSpecified')}, null) );`;
624
676
  });
625
677
  });
626
678
  const exception = new codegen_csharp_1.Parameter('exception', codegen_csharp_1.System.Exception);
627
- yield codegen_csharp_1.Catch(exception, function* () {
679
+ yield (0, codegen_csharp_1.Catch)(exception, function* () {
628
680
  yield $this.eventListener.syncSignal(powershell_declarations_1.Events.CmdletException, new codegen_csharp_1.LiteralExpression(`$"{${exception.use}.GetType().Name} - {${exception.use}.Message} : {${exception.use}.StackTrace}"`));
629
681
  yield '// Write exception out to error channel.';
630
- yield `WriteError( new ${powershell_declarations_1.ErrorRecord}(${exception.use},string.Empty, ${powershell_declarations_1.ErrorCategory('NotSpecified')}, null) );`;
682
+ yield `WriteError( new ${powershell_declarations_1.ErrorRecord}(${exception.use},string.Empty, ${(0, powershell_declarations_1.ErrorCategory)('NotSpecified')}, null) );`;
631
683
  }, { when: new codegen_csharp_1.LiteralExpression('(exception as System.Management.Automation.PipelineStoppedException)== null || (exception as System.Management.Automation.PipelineStoppedException).InnerException != null') });
632
- yield codegen_csharp_1.Finally(function* () {
684
+ yield (0, codegen_csharp_1.Finally)(function* () {
633
685
  yield $this.eventListener.syncSignalNoCheck(powershell_declarations_1.Events.CmdletProcessRecordEnd);
634
686
  });
635
687
  });
636
688
  }
637
- NewImplementProcessRecordAsync(operation) {
689
+ NewImplementProcessRecordAsync() {
638
690
  const $this = this;
639
- const PAR = this.add(new codegen_csharp_1.Method('ProcessRecordAsync', codegen_csharp_1.System.Threading.Tasks.Task(), {
691
+ const operationParameters = $this.operationParameters;
692
+ const pipeline = $this.$('Pipeline');
693
+ this.serializationMode = this.bodyParameter ? (this.operation.operationType === command_operation_1.OperationType.Create ? exports_1.ClientRuntime.SerializationMode.IncludeCreate : (this.operation.operationType === command_operation_1.OperationType.Update ? exports_1.ClientRuntime.SerializationMode.IncludeUpdate : undefined)) : undefined;
694
+ if (this.operation.commandType === command_operation_1.CommandType.GetPut || this.operation.commandType === command_operation_1.CommandType.ManagedIdentityUpdate) {
695
+ this.serializationMode = exports_1.ClientRuntime.SerializationMode.IncludeCreateOrUpdate;
696
+ }
697
+ const PRA = this.add(new codegen_csharp_1.Method('ProcessRecordAsync', codegen_csharp_1.System.Threading.Tasks.Task(), {
640
698
  access: codegen_csharp_1.Access.Protected, async: codegen_csharp_1.Modifier.Async,
641
699
  description: 'Performs execution of the command, working asynchronously if required.',
642
700
  returnsDescription: `A <see cref="${codegen_csharp_1.System.Threading.Tasks.Task()}" /> that will be complete when handling of the method is completed.`
643
701
  }));
644
702
  // we don't want to use SynchContext here.
645
- PAR.push(codegen_csharp_1.Using('NoSynchronizationContext', ''));
646
- PAR.add(function* () {
647
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
703
+ PRA.push((0, codegen_csharp_1.Using)('NoSynchronizationContext', ''));
704
+ PRA.add(function* () {
648
705
  if ($this.apProp && $this.bodyParameter && $this.bodyParameterInfo) {
649
706
  // yield `${ClientRuntime}.DictionaryExtensions.HashTableToDictionary<${$this.bodyParameterInfo.type.declaration},${$this.bodyParameterInfo.valueType.declaration}>(${$this.apProp.value},${$this.bodyParameter.Cast($this.bodyParameterInfo.type)});`;
650
707
  let vt = $this.bodyParameterInfo.valueType.declaration;
@@ -654,16 +711,18 @@ class CmdletClass extends codegen_csharp_1.Class {
654
711
  yield `${exports_1.ClientRuntime}.DictionaryExtensions.HashTableToDictionary<${vt}>(${$this.apProp.value},${$this.bodyParameter}.AdditionalProperties);`;
655
712
  }
656
713
  // construct the call to the operation
714
+ if (!$this.state.project.azure) {
715
+ yield $this.eventListener.signal(powershell_declarations_1.Events.CmdletProcessRecordAsyncStart);
716
+ }
657
717
  yield $this.eventListener.signal(powershell_declarations_1.Events.CmdletGetPipeline);
658
- const pipeline = $this.$('Pipeline');
659
718
  if ($this.state.project.azure) {
660
719
  yield pipeline.assign(new codegen_csharp_1.LiteralExpression(`${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.CreatePipeline(${$this.invocationInfo}, ${$this.correlationId}, ${$this.processRecordId}, this.ParameterSetName, this.ExtensibleParameters)`));
661
720
  }
662
721
  else {
663
722
  yield pipeline.assign(new codegen_csharp_1.LiteralExpression(`${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.CreatePipeline(${$this.invocationInfo}, this.ParameterSetName, this.ExtensibleParameters)`));
664
723
  }
665
- yield codegen_csharp_1.If(codegen_csharp_1.IsNotNull($this.$('HttpPipelinePrepend')), pipeline.invokeMethod('Prepend', codegen_csharp_1.toExpression(`(this.CommandRuntime as Microsoft.Rest.ClientRuntime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(${$this.$('HttpPipelinePrepend')}) ?? ${$this.$('HttpPipelinePrepend')}`)));
666
- yield codegen_csharp_1.If(codegen_csharp_1.IsNotNull($this.$('HttpPipelineAppend')), pipeline.invokeMethod('Append', codegen_csharp_1.toExpression(`(this.CommandRuntime as Microsoft.Rest.ClientRuntime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(${$this.$('HttpPipelineAppend')}) ?? ${$this.$('HttpPipelineAppend')}`)));
724
+ yield (0, codegen_csharp_1.If)((0, codegen_csharp_1.IsNotNull)($this.$('HttpPipelinePrepend')), pipeline.invokeMethod('Prepend', (0, codegen_csharp_1.toExpression)(`(this.CommandRuntime as Microsoft.Rest.ClientRuntime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(${$this.$('HttpPipelinePrepend')}) ?? ${$this.$('HttpPipelinePrepend')}`)));
725
+ yield (0, codegen_csharp_1.If)((0, codegen_csharp_1.IsNotNull)($this.$('HttpPipelineAppend')), pipeline.invokeMethod('Append', (0, codegen_csharp_1.toExpression)(`(this.CommandRuntime as Microsoft.Rest.ClientRuntime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(${$this.$('HttpPipelineAppend')}) ?? ${$this.$('HttpPipelineAppend')}`)));
667
726
  yield '// get the client instance';
668
727
  // Add input pipeline if it is configured by developers.
669
728
  if ($this.operation.extensions.inputPipe) {
@@ -685,471 +744,664 @@ class CmdletClass extends codegen_csharp_1.Class {
685
744
  for (const vParam of [...vps.body, ...vps.operation]) {
686
745
  if (vParam.hidden) {
687
746
  const td = $this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(vParam.schema, true, $this.state, true);
688
- yield codegen_csharp_1.If(`true == this.MyInvocation?.BoundParameters?.ContainsKey("${vParam.name}")`, `${vParam.name} = (${td.declaration})this.MyInvocation.BoundParameters["${vParam.name}"];`);
747
+ yield (0, codegen_csharp_1.If)(`true == this.MyInvocation?.BoundParameters?.ContainsKey("${vParam.name}")`, `${vParam.name} = (${td.declaration})this.MyInvocation.BoundParameters["${vParam.name}"];`);
689
748
  }
690
749
  }
691
- const apiCall = operation.callGraph[0];
692
- // find each parameter to the method, and find out where the value is going to come from.
693
- const operationParameters = linq_1.values(apiCall.parameters).
694
- // filter out constants and path parameters when using piping for identity
695
- where(each => { var _a, _b; return !((_a = each.language.csharp) === null || _a === void 0 ? void 0 : _a.constantValue) && ((_b = each.language.default) === null || _b === void 0 ? void 0 : _b.name) !== '$host'; } /* && (!$this.isViaIdentity || each.in !== ParameterLocation.Path) */).
696
- select(p => {
697
- var _a, _b;
698
- return {
699
- name: (_a = p.language.csharp) === null || _a === void 0 ? void 0 : _a.name,
700
- param: linq_1.values($this.properties).
701
- where(each => each.metadata.parameterDefinition).
702
- first(each => { var _a, _b; return ((_a = each.metadata.parameterDefinition.language.csharp) === null || _a === void 0 ? void 0 : _a.serializedName) === ((_b = p.language.csharp) === null || _b === void 0 ? void 0 : _b.serializedName); }),
703
- isPathParam: $this.isViaIdentity && ((_b = p.protocol.http) === null || _b === void 0 ? void 0 : _b.in) === codemodel_v3_1.ParameterLocation.Path
750
+ // is there a body parameter we should include?
751
+ // if ($this.bodyParameter) {
752
+ // operationParameters.push({ name: 'body', expression: $this.bodyParameter, isPathParam: false });
753
+ // }
754
+ yield (0, codegen_csharp_1.Try)(function* () {
755
+ // make the call.
756
+ let preProcess;
757
+ switch ($this.operation.commandType) {
758
+ case command_operation_1.CommandType.ManagedIdentityUpdate:
759
+ preProcess = !$this.disableTransformIdentityType && $this.ContainsIdentityTypeParameter() ? $this.ManagedIdentityUpdateCmdletPreProcess : undefined;
760
+ break;
761
+ case command_operation_1.CommandType.GetPut:
762
+ preProcess = $this.GetPutPreProcess;
763
+ break;
764
+ case command_operation_1.CommandType.ManagedIdentityNew:
765
+ preProcess = !$this.disableTransformIdentityType && $this.ContainsIdentityTypeParameter() && $this.ContainsUserAssignedIdentityParameter() ? $this.ManagedIdentityPreProcessForNewVerbCmdlet : undefined;
766
+ break;
767
+ case command_operation_1.CommandType.Atomic:
768
+ default:
769
+ preProcess = $this.ContainsUserAssignedIdentityParameter() ? $this.ManagedUserAssignedIdentityPreProcess : undefined;
770
+ break;
771
+ }
772
+ const actualCall = function* () {
773
+ yield $this.eventListener.signal(powershell_declarations_1.Events.CmdletBeforeAPICall);
774
+ yield $this.ImplementCall(preProcess);
775
+ yield $this.eventListener.signal(powershell_declarations_1.Events.CmdletAfterAPICall);
704
776
  };
705
- }).
706
- select(each => {
707
- if (each.param) {
708
- const httpParam = (each.param.metadata.parameterDefinition);
709
- if (httpParam.required) {
710
- return {
711
- name: each.param,
712
- expression: each.param,
713
- isPathParam: each.isPathParam
777
+ if ($this.state.project.azure && operationParameters.find(each => each.expression && each.expression.value === 'SubscriptionId') && $this.operation.details.csharp.verb.toLowerCase() === 'get') {
778
+ yield 'foreach( var SubscriptionId in this.SubscriptionId )';
779
+ yield (0, codegen_csharp_1.BlockStatement)(actualCall);
780
+ }
781
+ else {
782
+ yield actualCall;
783
+ }
784
+ });
785
+ const ure = new codegen_csharp_1.Parameter('urexception', { declaration: `${exports_1.ClientRuntime.fullName}.UndeclaredResponseException` });
786
+ yield (0, codegen_csharp_1.Catch)(ure, function* () {
787
+ yield `WriteError(new global::System.Management.Automation.ErrorRecord(${ure.value}, ${ure.value}.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { ${operationParameters.filter(e => (0, codegen_csharp_1.valueOf)(e.expression) !== 'null').map(each => `${each.name}=${each.expression}`).join(',')}})
788
+ {
789
+ ErrorDetails = new global::System.Management.Automation.ErrorDetails(${ure.value}.Message) { RecommendedAction = ${ure.value}.Action }
790
+ });`;
791
+ });
792
+ yield (0, codegen_csharp_1.Finally)(function* () {
793
+ yield $this.eventListener.signalNoCheck(powershell_declarations_1.Events.CmdletProcessRecordAsyncEnd);
794
+ });
795
+ });
796
+ }
797
+ NewImplementWriteObject() {
798
+ const $this = this;
799
+ const sendToPipeline = new codegen_csharp_1.Parameter('sendToPipeline', codegen_csharp_1.dotnet.Object);
800
+ const enumerateCollection = new codegen_csharp_1.Parameter('enumerateCollection', codegen_csharp_1.dotnet.Bool);
801
+ const snglWriteObject = new codegen_csharp_1.Method('WriteObject', codegen_csharp_1.dotnet.Void, {
802
+ access: codegen_csharp_1.Access.Protected,
803
+ new: codegen_csharp_1.Modifier.New,
804
+ parameters: [sendToPipeline]
805
+ });
806
+ snglWriteObject.add(function* () {
807
+ yield `${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);`;
808
+ yield 'base.WriteObject(sendToPipeline);';
809
+ });
810
+ const collWriteObject = new codegen_csharp_1.Method('WriteObject', codegen_csharp_1.dotnet.Void, {
811
+ access: codegen_csharp_1.Access.Protected,
812
+ new: codegen_csharp_1.Modifier.New,
813
+ parameters: [sendToPipeline, enumerateCollection]
814
+ });
815
+ collWriteObject.add(function* () {
816
+ yield `${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.SanitizeOutput?.Invoke(sendToPipeline, __correlationId);`;
817
+ yield 'base.WriteObject(sendToPipeline, enumerateCollection);';
818
+ });
819
+ $this.add(snglWriteObject);
820
+ $this.add(collWriteObject);
821
+ }
822
+ *ImplementCall(preProcess) {
823
+ var _a, _b;
824
+ const $this = this;
825
+ const operation = $this.operation;
826
+ const apiCall = $this.apiCall;
827
+ const operationParameters = $this.operationParameters;
828
+ const callbackMethods = $this.callbackMethods;
829
+ const pipeline = $this.$('Pipeline');
830
+ const serializationMode = $this.serializationMode;
831
+ const bodyParameter = this.bodyParameter ? { name: 'body', value: (0, codegen_csharp_1.valueOf)(this.bodyParameter) } : undefined;
832
+ const pathParamsNotInIdentity = [];
833
+ const pathParamsInIdentity = [];
834
+ const pathParamsInIdentitySerializedName = [];
835
+ const headerParams = [];
836
+ const queryParams = [];
837
+ const otherParams = [];
838
+ const idschema = (0, linq_1.values)($this.state.project.model.schemas.objects).first(each => each.language.default.uid === 'universal-parameter-type');
839
+ let httpOperationName = `${(_a = apiCall.language.csharp) === null || _a === void 0 ? void 0 : _a.name}`;
840
+ if (idschema) {
841
+ const allVPs = (0, schema_1.getAllPublicVirtualProperties)((_b = idschema.language.csharp) === null || _b === void 0 ? void 0 : _b.virtualProperties);
842
+ const props = [...(0, linq_1.values)(idschema.properties)];
843
+ operationParameters.forEach(each => {
844
+ var _a, _b, _c, _d, _e, _f;
845
+ const pascalName = (0, codegen_1.pascalCase)(`${each.name}`);
846
+ //push parameters that is not path parameters into allParams and idOpParamsNotFromIdentity
847
+ if (each.parameterLocation !== codemodel_v3_1.ParameterLocation.Path) {
848
+ const param = {
849
+ name: undefined,
850
+ value: (0, codegen_csharp_1.valueOf)(each.expression)
851
+ };
852
+ switch (each.parameterLocation) {
853
+ case codemodel_v3_1.ParameterLocation.Header:
854
+ headerParams.push(param);
855
+ break;
856
+ case codemodel_v3_1.ParameterLocation.Query:
857
+ queryParams.push(param);
858
+ break;
859
+ default:
860
+ otherParams.push(param);
861
+ break;
862
+ }
863
+ return;
864
+ }
865
+ else {
866
+ const match = props.find(p => (0, codegen_1.pascalCase)(p.serializedName) === pascalName);
867
+ if (match) {
868
+ const defaultOfType = $this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(match.schema, true, $this.state).defaultOfType;
869
+ // match up vp name
870
+ const vp = allVPs.find(pp => (0, codegen_1.pascalCase)(pp.property.serializedName) === pascalName);
871
+ //push path parameters that form current identity into allParams, idOpParamsFromIdentity and idOpParamsFromIdentityserializedName
872
+ if (vp && each.expression === codegen_csharp_1.dotnet.Null) {
873
+ const param = {
874
+ name: `${$this.inputObjectParameterName}.${vp.name}`,
875
+ value: `${$this.inputObjectParameterName}.${vp.name} ?? ${defaultOfType}`
876
+ };
877
+ pathParamsInIdentity.push(param);
878
+ pathParamsInIdentitySerializedName.push(match.serializedName);
879
+ return;
880
+ }
881
+ // fall back!
882
+ this.state.debug(`Unable to match identity parameter '${each.name}' member to appropriate virtual parameter. (Guessing '${(0, codegen_1.pascalCase)((_b = (_a = match.language.csharp) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '')}').`, {});
883
+ //push path parameters that current identity does not contain into allParams and idOpParamsNotFromIdentity
884
+ const param = {
885
+ name: `${(0, codegen_1.pascalCase)((_d = (_c = match.language.csharp) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : '')}`,
886
+ value: `${(0, codegen_1.pascalCase)((_f = (_e = match.language.csharp) === null || _e === void 0 ? void 0 : _e.name) !== null && _f !== void 0 ? _f : '')}`
714
887
  };
888
+ pathParamsNotInIdentity.push(param);
889
+ }
890
+ else {
891
+ this.state.debug(`Unable to match identity parameter '${each.name}' member to appropriate virtual parameter. (Guessing '${pascalName}')`, {});
892
+ /*
893
+ push path parameters do not match the name in identity schema into allParams and idOpParamsNotFromIdentity
894
+ for example, module 'Service' has only one GET API:
895
+ /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Service/resource1/{resource1Name}/resource2/{resource2Name}/resource3/{resource3Name}
896
+ the identity schema 'ServiceIdentity.cs' will have properties: {subscriptionId, resourceGroupName, resource1Name, resource2Name, resource3Name}
897
+ for variant which has (identity of resource2 + resource3Name) combined as parameters, the parameter name for 'resource3Name' is called 'Name' which do not match 'resource3Name' in 'ServiceIdentity.cs'
898
+ */
899
+ const param = {
900
+ name: `${pascalName}`,
901
+ value: `${pascalName}`
902
+ };
903
+ pathParamsNotInIdentity.push(param);
715
904
  }
716
- const httpParamTD = $this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(httpParam.schema, httpParam.required, $this.state);
717
- return {
718
- name: each.param,
719
- expression: codegen_csharp_1.toExpression(`this.InvocationInformation.BoundParameters.ContainsKey("${each.param.value}") ? ${each.param.value} : ${httpParamTD.defaultOfType}`),
720
- isPathParam: each.isPathParam
721
- };
722
905
  }
723
- return { name: each.name, expression: codegen_csharp_1.dotnet.Null, isPathParam: each.isPathParam };
724
- }).toArray();
725
- // is there a body parameter we should include?
726
- if ($this.bodyParameter) {
727
- operationParameters.push({ name: 'body', expression: $this.bodyParameter, isPathParam: false });
728
- }
729
- // create the response handlers
730
- const responses = [...linq_1.values(apiCall.responses), ...linq_1.values(apiCall.exceptions)];
731
- const callbackMethods = linq_1.values(responses).toArray().map(each => { var _a; return new codegen_csharp_1.LiteralExpression(((_a = each.language.csharp) === null || _a === void 0 ? void 0 : _a.name) || ''); });
732
- // make callback methods
733
- for (const each of linq_1.values(responses)) {
734
- const isBinary = each.binary;
735
- const parameters = new Array();
736
- parameters.push(new codegen_csharp_1.Parameter('responseMessage', codegen_csharp_1.System.Net.Http.HttpResponseMessage, { description: `the raw response message as an ${codegen_csharp_1.System.Net.Http.HttpResponseMessage}.` }));
737
- if ((_a = each.language.csharp) === null || _a === void 0 ? void 0 : _a.responseType) {
738
- parameters.push(new codegen_csharp_1.Parameter('response', codegen_csharp_1.System.Threading.Tasks.Task({ declaration: (_b = each.language.csharp) === null || _b === void 0 ? void 0 : _b.responseType }), {
739
- description: `the body result as a <see cref="${(_c = each.language.csharp) === null || _c === void 0 ? void 0 : _c.responseType.replace(/\[|\]|\?/g, '')}">${(_d = each.language.csharp) === null || _d === void 0 ? void 0 : _d.responseType}</see> from the remote call`
740
- }));
906
+ });
907
+ }
908
+ if ($this.isViaIdentity) {
909
+ //when identity does not contain property: 'Id'
910
+ const identityFromPathParams = function* () {
911
+ yield '// try to call with PATH parameters from Input Object';
912
+ if (idschema) {
913
+ for (const opParam of pathParamsInIdentity) {
914
+ if (opParam && opParam.name) {
915
+ yield (0, codegen_csharp_1.If)((0, codegen_csharp_1.IsNull)(opParam.name), `ThrowTerminatingError( new ${powershell_declarations_1.ErrorRecord}(new global::System.Exception("${$this.inputObjectParameterName} has null value for ${opParam.name}"),string.Empty, ${(0, powershell_declarations_1.ErrorCategory)('InvalidArgument')}, ${$this.inputObjectParameterName}) );`);
916
+ }
917
+ }
918
+ const pathParameters = [...pathParamsInIdentity.map(each => (0, codegen_csharp_1.toExpression)(each.value)), ...pathParamsNotInIdentity.map(each => (0, codegen_csharp_1.toExpression)(each.value))];
919
+ const nonPathParameters = [...headerParams.map(each => (0, codegen_csharp_1.toExpression)(each.value)), ...queryParams.map(each => (0, codegen_csharp_1.toExpression)(each.value)), ...otherParams.map(each => (0, codegen_csharp_1.toExpression)(each.value))];
920
+ const parameters = bodyParameter ? [...pathParameters, ...nonPathParameters, (0, codegen_csharp_1.toExpression)(bodyParameter.value), ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline] : [...pathParameters, ...nonPathParameters, ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline];
921
+ if (serializationMode) {
922
+ parameters.push(serializationMode);
923
+ }
924
+ if (preProcess) {
925
+ yield preProcess($this, pathParameters, [...otherParams.map(each => (0, codegen_csharp_1.toExpression)(each.value)), codegen_csharp_1.dotnet.This, pipeline], false);
926
+ }
927
+ yield `await this.${$this.$('Client').invokeMethod(httpOperationName, ...parameters).implementation}`;
928
+ }
929
+ };
930
+ //when identity does contain property: 'Id'
931
+ const identityParams = function* () {
932
+ var _a, _b, _c, _d;
933
+ const path = (_b = (_a = apiCall.requests) === null || _a === void 0 ? void 0 : _a[0].protocol.http) === null || _b === void 0 ? void 0 : _b.path;
934
+ let pathParams = '';
935
+ //append path parameters which are not part of current identity
936
+ pathParamsNotInIdentity.forEach(each => {
937
+ var _a;
938
+ const serializedName = (_a = (0, linq_1.values)($this.properties)
939
+ .where(p => p.metadata.parameterDefinition)
940
+ .first(p => p.name === each.name)) === null || _a === void 0 ? void 0 : _a.metadata.parameterDefinition.language.csharp.serializedName;
941
+ if (each.name && serializedName) {
942
+ if (!pathParams) {
943
+ pathParams += '$"';
944
+ }
945
+ const resourceName = (0, resourceName_1.getResourceNameFromPath)(path, serializedName);
946
+ if (resourceName) {
947
+ pathParams += `/${resourceName}/{(global::System.Uri.EscapeDataString(this.${each.name}.ToString()))}`;
948
+ }
949
+ }
950
+ });
951
+ //add child resource to path for list operation
952
+ if ($this.operation.variant.startsWith('List') && ((_d = (_c = $this.operation.callGraph[0].requests) === null || _c === void 0 ? void 0 : _c[0].protocol.http) === null || _d === void 0 ? void 0 : _d.method.toLowerCase()) !== 'post' && (pathParamsInIdentitySerializedName === null || pathParamsInIdentitySerializedName === void 0 ? void 0 : pathParamsInIdentitySerializedName[pathParamsInIdentitySerializedName.length - 1])) {
953
+ const childResourceName = (0, resourceName_1.getChildResourceNameFromPath)(path, pathParamsInIdentitySerializedName === null || pathParamsInIdentitySerializedName === void 0 ? void 0 : pathParamsInIdentitySerializedName[pathParamsInIdentitySerializedName.length - 1]);
954
+ if (pathParams && pathParams.length > 0) {
955
+ pathParams += `/${childResourceName}`;
956
+ }
957
+ else {
958
+ pathParams += `"/${childResourceName}`;
959
+ }
741
960
  }
742
- if ((_e = each.language.csharp) === null || _e === void 0 ? void 0 : _e.headerType) {
743
- parameters.push(new codegen_csharp_1.Parameter('headers', codegen_csharp_1.System.Threading.Tasks.Task({ declaration: each.language.csharp.headerType }), { description: `the header result as a <see cref="${each.language.csharp.headerType}" /> from the remote call` }));
961
+ if (pathParams && pathParams.length > 0) {
962
+ pathParams += '";';
963
+ yield `this.${$this.inputObjectParameterName}.Id += ${pathParams}`;
744
964
  }
745
- if (isBinary) {
746
- parameters.push(new codegen_csharp_1.Parameter('response', codegen_csharp_1.System.Threading.Tasks.Task({ declaration: 'global::System.IO.Stream' }), { description: 'the body result as a <see cref="global::System.IO.Stream" /> from the remote call' }));
965
+ const pathParameters = [(0, codegen_csharp_1.toExpression)(`${$this.inputObjectParameterName}.Id`)];
966
+ const nonPathParameters = [...headerParams.map(each => (0, codegen_csharp_1.toExpression)(each.value)), ...queryParams.map(each => (0, codegen_csharp_1.toExpression)(each.value)), ...otherParams.map(each => (0, codegen_csharp_1.toExpression)(each.value))];
967
+ const parameters = bodyParameter ? [...pathParameters, ...nonPathParameters, (0, codegen_csharp_1.toExpression)(bodyParameter.value), ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline] : [...pathParameters, ...nonPathParameters, ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline];
968
+ if (serializationMode) {
969
+ parameters.push(serializationMode);
747
970
  }
748
- const override = `override${codegen_1.pascalCase(((_f = each.language.csharp) === null || _f === void 0 ? void 0 : _f.name) || '')}`;
749
- const returnNow = new codegen_csharp_1.Parameter('returnNow', codegen_csharp_1.System.Threading.Tasks.Task(codegen_csharp_1.dotnet.Bool), { modifier: codegen_csharp_2.ParameterModifier.Ref, description: `/// Determines if the rest of the ${(_g = each.language.csharp) === null || _g === void 0 ? void 0 : _g.name} method should be processed, or if the method should return immediately (set to true to skip further processing )` });
750
- const overrideResponseMethod = new codegen_csharp_1.PartialMethod(override, codegen_csharp_1.dotnet.Void, {
751
- parameters: [...parameters, returnNow],
752
- description: `<c>${override}</c> will be called before the regular ${(_h = each.language.csharp) === null || _h === void 0 ? void 0 : _h.name} has been processed, allowing customization of what happens on that response. Implement this method in a partial class to enable this behavior`,
753
- returnsDescription: `A <see cref="${codegen_csharp_1.System.Threading.Tasks.Task()}" /> that will be complete when handling of the method is completed.`
971
+ if (preProcess) {
972
+ yield preProcess($this, pathParameters, [...otherParams.map(each => (0, codegen_csharp_1.toExpression)(each.value)), codegen_csharp_1.dotnet.This, pipeline], true);
973
+ }
974
+ yield `await this.${$this.$('Client').invokeMethod(`${httpOperationName}ViaIdentity`, ...parameters).implementation}`;
975
+ };
976
+ if (idschema && (0, linq_1.values)(idschema.properties).first(each => { var _a; return ((_a = each.language.csharp) === null || _a === void 0 ? void 0 : _a.uid) === 'universal-parameter:resource identity'; })) {
977
+ yield (0, codegen_csharp_1.If)(`${$this.inputObjectParameterName}?.Id != null`, identityParams);
978
+ yield (0, codegen_csharp_1.Else)(identityFromPathParams);
979
+ }
980
+ else {
981
+ yield identityFromPathParams;
982
+ }
983
+ }
984
+ else {
985
+ const pathParameters = [...pathParamsInIdentity.map(each => (0, codegen_csharp_1.toExpression)(each.value)), ...pathParamsNotInIdentity.map(each => (0, codegen_csharp_1.toExpression)(each.value))];
986
+ const nonPathParameters = [...headerParams.map(each => (0, codegen_csharp_1.toExpression)(each.value)), ...queryParams.map(each => (0, codegen_csharp_1.toExpression)(each.value)), ...otherParams.map(each => (0, codegen_csharp_1.toExpression)(each.value))];
987
+ let parameters = bodyParameter ? [...pathParameters, ...nonPathParameters, (0, codegen_csharp_1.toExpression)(bodyParameter.value), ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline] : [...pathParameters, ...nonPathParameters, ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline];
988
+ if (serializationMode) {
989
+ parameters.push(serializationMode);
990
+ }
991
+ if (operation.variant.includes('ViaJsonString') || operation.variant.includes('ViaJsonFilePath')) {
992
+ httpOperationName = `${httpOperationName}ViaJsonString`;
993
+ const jsonParameter = new codegen_csharp_1.Field('_jsonString', codegen_csharp_1.System.String);
994
+ parameters = [...pathParameters, ...nonPathParameters, jsonParameter, ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline];
995
+ }
996
+ if (preProcess) {
997
+ yield preProcess($this, pathParameters, [...otherParams.map(each => (0, codegen_csharp_1.toExpression)(each.value)), codegen_csharp_1.dotnet.This, pipeline], false);
998
+ }
999
+ yield `await this.${$this.$('Client').invokeMethod(httpOperationName, ...parameters).implementation}`;
1000
+ }
1001
+ }
1002
+ ContainsSpecifiedParameter(parameterName) {
1003
+ var _a, _b, _c, _d;
1004
+ return (_d = (_c = (_b = (_a = this.operation.details.csharp.virtualParameters) === null || _a === void 0 ? void 0 : _a.body) === null || _b === void 0 ? void 0 : _b.map(p => p.name)) === null || _c === void 0 ? void 0 : _c.includes(parameterName)) !== null && _d !== void 0 ? _d : false;
1005
+ }
1006
+ ContainsIdentityTypeParameter() {
1007
+ return this.ContainsSpecifiedParameter('IdentityType');
1008
+ }
1009
+ ContainsUserAssignedIdentityParameter() {
1010
+ return this.ContainsSpecifiedParameter('IdentityUserAssignedIdentity') || this.ContainsSpecifiedParameter('UserAssignedIdentity');
1011
+ }
1012
+ GetUserAssignedIdentityParameterTypeDefinition() {
1013
+ var _a, _b, _c, _d, _e;
1014
+ return (_e = (_d = (_c = (_b = (_a = this.operation.details.csharp.virtualParameters) === null || _a === void 0 ? void 0 : _a.body) === null || _b === void 0 ? void 0 : _b.filter(p => p.name === 'UserAssignedIdentity' || p.name === 'IdentityUserAssignedIdentity')) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.schema) === null || _e === void 0 ? void 0 : _e.type;
1015
+ }
1016
+ GetUserAssignedIdentityParameterElementType() {
1017
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1018
+ return (_h = (_g = (_f = (_e = (_d = (_c = (_b = (_a = this.operation.details.csharp.virtualParameters) === null || _a === void 0 ? void 0 : _a.body) === null || _b === void 0 ? void 0 : _b.filter(p => p.name === 'UserAssignedIdentity' || p.name === 'IdentityUserAssignedIdentity')) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.schema) === null || _e === void 0 ? void 0 : _e.elementType) === null || _f === void 0 ? void 0 : _f.language) === null || _g === void 0 ? void 0 : _g.csharp) === null || _h === void 0 ? void 0 : _h.fullname;
1019
+ }
1020
+ GetUserAssignedIdentityPropertyTypeDeclaration() {
1021
+ var _a, _b, _c;
1022
+ const userAssignedIdentityParameter = this.properties.filter(p => p.name === 'UserAssignedIdentity' || p.name === 'IdentityUserAssignedIdentity');
1023
+ return (_c = (_b = (_a = userAssignedIdentityParameter === null || userAssignedIdentityParameter === void 0 ? void 0 : userAssignedIdentityParameter[0]) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.declaration) !== null && _c !== void 0 ? _c : undefined;
1024
+ }
1025
+ GetUserAssignedIdentityPropertyName() {
1026
+ var _a, _b, _c, _d;
1027
+ const response = (_a = this.responses.filter(re => { var _a, _b; return (_b = (_a = re === null || re === void 0 ? void 0 : re.schema) === null || _a === void 0 ? void 0 : _a.extensions) === null || _b === void 0 ? void 0 : _b['is-return-object']; })) === null || _a === void 0 ? void 0 : _a[0];
1028
+ const props = (0, schema_1.getAllPublicVirtualProperties)((_b = response.schema.language.csharp) === null || _b === void 0 ? void 0 : _b.virtualProperties);
1029
+ const userAssignedIdentityParameter = props === null || props === void 0 ? void 0 : props.filter(p => p.name === 'UserAssignedIdentity' || p.name === 'IdentityUserAssignedIdentity');
1030
+ return (_d = (_c = userAssignedIdentityParameter === null || userAssignedIdentityParameter === void 0 ? void 0 : userAssignedIdentityParameter[0]) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : undefined;
1031
+ }
1032
+ ManagedUserAssignedIdentityPreProcess(cmdlet, pathParams = [], nonPathParams = [], viaIdentity = false) {
1033
+ const $this = cmdlet;
1034
+ if ($this.ContainsUserAssignedIdentityParameter() && $this.flattenUserAssignedIdentity && $this.GetUserAssignedIdentityParameterTypeDefinition() === 'dictionary') {
1035
+ return (0, codegen_csharp_1.If)('this.UserAssignedIdentity?.Length > 0', function* () {
1036
+ var _a, _b;
1037
+ yield '// calculate UserAssignedIdentity';
1038
+ const userAssignedIdentityPropertyName = $this.GetUserAssignedIdentityPropertyName();
1039
+ yield `${(_a = $this.bodyParameter) === null || _a === void 0 ? void 0 : _a.value}.${userAssignedIdentityPropertyName}.Clear();`;
1040
+ yield (0, codegen_csharp_1.ForEach)('id', 'this.UserAssignedIdentity', `${(_b = $this.bodyParameter) === null || _b === void 0 ? void 0 : _b.value}.${userAssignedIdentityPropertyName}.Add(id, new ${$this.GetUserAssignedIdentityParameterElementType()}());`);
1041
+ yield '';
1042
+ });
1043
+ }
1044
+ return new codegen_csharp_1.Statements();
1045
+ }
1046
+ ManagedIdentityPreProcessForNewVerbCmdlet(cmdlet, pathParams, nonPathParams, viaIdentity) {
1047
+ const $this = cmdlet;
1048
+ const preProcessManagedIdentityParametersMethod = new codegen_csharp_1.Method('PreProcessManagedIdentityParameters', codegen_csharp_1.dotnet.Void, {
1049
+ access: codegen_csharp_1.Access.Private
1050
+ });
1051
+ const preProcessManagedIdentityParameters = function* () {
1052
+ var _a, _b, _c, _d, _e;
1053
+ yield $this.ManagedUserAssignedIdentityPreProcess($this);
1054
+ yield '// calculate IdentityType';
1055
+ if ((_c = (_b = (_a = $this.operation.details.csharp.virtualParameters) === null || _a === void 0 ? void 0 : _a.body) === null || _b === void 0 ? void 0 : _b.filter(p => p.name === 'IdentityType')[0]) === null || _c === void 0 ? void 0 : _c.required) {
1056
+ yield (0, codegen_csharp_1.If)(`null == ${(_d = $this.bodyParameter) === null || _d === void 0 ? void 0 : _d.value}.IdentityType`, `${(_e = $this.bodyParameter) === null || _e === void 0 ? void 0 : _e.value}.IdentityType = "None";`);
1057
+ }
1058
+ // if UserAssignedIdentity is a string array or string, use Length. Otherwise, use Count
1059
+ yield (0, codegen_csharp_1.If)(`this.UserAssignedIdentity?.${!$this.flattenUserAssignedIdentity && $this.GetUserAssignedIdentityParameterTypeDefinition() === 'dictionary' ? 'Count' : 'Length'} > 0`, function* () {
1060
+ var _a, _b, _c;
1061
+ yield (0, codegen_csharp_1.If)(`"SystemAssigned".Equals(${(_a = $this.bodyParameter) === null || _a === void 0 ? void 0 : _a.value}.IdentityType, StringComparison.InvariantCultureIgnoreCase)`, `${(_b = $this.bodyParameter) === null || _b === void 0 ? void 0 : _b.value}.IdentityType = "SystemAssigned,UserAssigned";`);
1062
+ yield (0, codegen_csharp_1.Else)(`${(_c = $this.bodyParameter) === null || _c === void 0 ? void 0 : _c.value}.IdentityType = "UserAssigned";`);
1063
+ });
1064
+ };
1065
+ if (!$this.hasMethodWithSameDeclaration(preProcessManagedIdentityParametersMethod)) {
1066
+ preProcessManagedIdentityParametersMethod.add(preProcessManagedIdentityParameters);
1067
+ $this.add(preProcessManagedIdentityParametersMethod);
1068
+ }
1069
+ return new codegen_csharp_1.Statements(function* () {
1070
+ yield `this.${preProcessManagedIdentityParametersMethod.name}();`;
1071
+ });
1072
+ }
1073
+ ProcessGetResponseForManagedIdentityUpdateCmdlet(cmdlet) {
1074
+ const $this = cmdlet;
1075
+ const containsUserAssignedIdentity = $this.ContainsUserAssignedIdentityParameter();
1076
+ const preProcessManagedIdentity = function* () {
1077
+ var _a, _b, _c, _d, _e, _f;
1078
+ yield new codegen_csharp_1.LocalVariable('supportsSystemAssignedIdentity', codegen_csharp_1.dotnet.Bool, { initializer: (0, codegen_csharp_1.Or)('true == this.EnableSystemAssignedIdentity', `null == this.EnableSystemAssignedIdentity && true == ${(_a = $this.bodyParameter) === null || _a === void 0 ? void 0 : _a.value}?.IdentityType?.Contains("SystemAssigned")`) });
1079
+ yield new codegen_csharp_1.LocalVariable('supportsUserAssignedIdentity', codegen_csharp_1.dotnet.Bool, { initializer: `${codegen_csharp_1.dotnet.False}` });
1080
+ if (containsUserAssignedIdentity) {
1081
+ yield $this.ManagedUserAssignedIdentityPreProcess($this);
1082
+ yield `supportsUserAssignedIdentity = true == this.MyInvocation?.BoundParameters?.ContainsKey("UserAssignedIdentity") && ${!$this.flattenUserAssignedIdentity && $this.GetUserAssignedIdentityParameterTypeDefinition() === 'dictionary' ? `((${$this.GetUserAssignedIdentityPropertyTypeDeclaration()})this.MyInvocation?.BoundParameters["UserAssignedIdentity"])?.Count` : 'this.UserAssignedIdentity?.Length'} > 0 ||
1083
+ true != this.MyInvocation?.BoundParameters?.ContainsKey("UserAssignedIdentity") && true == ${(_b = $this.bodyParameter) === null || _b === void 0 ? void 0 : _b.value}.IdentityType?.Contains("UserAssigned");`;
1084
+ yield (0, codegen_csharp_1.If)('!supportsUserAssignedIdentity', function* () {
1085
+ var _a;
1086
+ yield `${(_a = $this.bodyParameter) === null || _a === void 0 ? void 0 : _a.value}.${$this.GetUserAssignedIdentityPropertyName()} = null;`;
754
1087
  });
755
- $this.add(overrideResponseMethod);
756
- const responseMethod = new codegen_csharp_1.Method(`${(_j = each.language.csharp) === null || _j === void 0 ? void 0 : _j.name}`, codegen_csharp_1.System.Threading.Tasks.Task(), {
757
- access: codegen_csharp_1.Access.Private,
758
- parameters,
759
- async: codegen_csharp_1.Modifier.Async,
760
- description: (_k = each.language.csharp) === null || _k === void 0 ? void 0 : _k.description,
761
- returnsDescription: `A <see cref="${codegen_csharp_1.System.Threading.Tasks.Task()}" /> that will be complete when handling of the method is completed.`
1088
+ yield '';
1089
+ }
1090
+ yield '// calculate IdentityType';
1091
+ yield (0, codegen_csharp_1.If)((0, codegen_csharp_1.And)('supportsUserAssignedIdentity', 'supportsSystemAssignedIdentity'), `${(_c = $this.bodyParameter) === null || _c === void 0 ? void 0 : _c.value}.IdentityType = "SystemAssigned,UserAssigned";`);
1092
+ yield (0, codegen_csharp_1.ElseIf)((0, codegen_csharp_1.And)('supportsUserAssignedIdentity', '!supportsSystemAssignedIdentity'), `${(_d = $this.bodyParameter) === null || _d === void 0 ? void 0 : _d.value}.IdentityType = "UserAssigned";`);
1093
+ yield (0, codegen_csharp_1.ElseIf)((0, codegen_csharp_1.And)('!supportsUserAssignedIdentity', 'supportsSystemAssignedIdentity'), `${(_e = $this.bodyParameter) === null || _e === void 0 ? void 0 : _e.value}.IdentityType = "SystemAssigned";`);
1094
+ yield (0, codegen_csharp_1.Else)(`${(_f = $this.bodyParameter) === null || _f === void 0 ? void 0 : _f.value}.IdentityType = "None";`);
1095
+ };
1096
+ const preProcessManagedIdentityMethod = new codegen_csharp_1.Method('PreProcessManagedIdentityParametersWithGetResult', codegen_csharp_1.dotnet.Void, {
1097
+ access: codegen_csharp_1.Access.Private
1098
+ });
1099
+ if (!$this.hasMethodWithSameDeclaration(preProcessManagedIdentityMethod)) {
1100
+ preProcessManagedIdentityMethod.add(preProcessManagedIdentity);
1101
+ $this.add(preProcessManagedIdentityMethod);
1102
+ }
1103
+ return new codegen_csharp_1.Statements(function* () {
1104
+ yield `this.${preProcessManagedIdentityMethod.name}();`;
1105
+ });
1106
+ }
1107
+ ManagedIdentityUpdateCmdletPreProcess(cmdlet, pathParams, nonPathParams, viaIdentity) {
1108
+ return cmdlet.GetPutPreProcess(cmdlet, pathParams, nonPathParams, viaIdentity, cmdlet.ProcessGetResponseForManagedIdentityUpdateCmdlet);
1109
+ }
1110
+ GetPutPreProcess(cmdlet, pathParams, nonPathParams, viaIdentity, processGetResponse = undefined) {
1111
+ var _a, _b;
1112
+ const $this = cmdlet;
1113
+ const updateBodyMethod = new codegen_csharp_1.Method(`Update${(_a = $this.bodyParameter) === null || _a === void 0 ? void 0 : _a.value}`, codegen_csharp_1.dotnet.Void, {
1114
+ access: codegen_csharp_1.Access.Private
1115
+ });
1116
+ const httpOperationName = `${(_b = $this.operation.callGraph[0].language.csharp) === null || _b === void 0 ? void 0 : _b.name}${viaIdentity ? 'ViaIdentity' : ''}WithResult`;
1117
+ if (!$this.hasMethodWithSameDeclaration(updateBodyMethod)) {
1118
+ updateBodyMethod.add(function* () {
1119
+ const bodyParameters = $this.properties.filter(each => {
1120
+ for (const attribute of each.attributes) {
1121
+ for (const parameter of attribute.parameters) {
1122
+ if ('global::Microsoft.Rest.ParameterCategory.Body' === (0, codegen_csharp_1.valueOf)(parameter)) {
1123
+ return true;
1124
+ }
1125
+ }
1126
+ }
1127
+ return false;
762
1128
  });
763
- responseMethod.push(codegen_csharp_1.Using('NoSynchronizationContext', ''));
764
- responseMethod.add(function* () {
765
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
766
- const skip = codegen_csharp_2.Local('_returnNow', `${codegen_csharp_1.System.Threading.Tasks.Task(codegen_csharp_1.dotnet.Bool).declaration}.FromResult(${codegen_csharp_1.dotnet.False})`);
767
- yield skip.declarationStatement;
768
- yield `${overrideResponseMethod.invoke(...parameters, `ref ${skip.value}`)};`;
769
- yield `// if ${override} has returned true, then return right away.`;
770
- yield codegen_csharp_1.If(codegen_csharp_1.And(codegen_csharp_1.IsNotNull(skip), `await ${skip}`), codegen_csharp_1.Return());
771
- if ((_a = each.language.csharp) === null || _a === void 0 ? void 0 : _a.isErrorResponse) {
772
- // this should write an error to the error channel.
773
- yield `// Error Response : ${(_b = each.protocol.http) === null || _b === void 0 ? void 0 : _b.statusCodes[0]}`;
774
- const unexpected = function* () {
775
- var _a;
776
- yield '// Unrecognized Response. Create an error record based on what we have.';
777
- const ex = ((_a = each.language.csharp) === null || _a === void 0 ? void 0 : _a.responseType) ?
778
- codegen_csharp_2.Local('ex', `new ${exports_1.ClientRuntime.name}.RestException<${each.language.csharp.responseType}>(responseMessage, await response)`) :
779
- codegen_csharp_2.Local('ex', `new ${exports_1.ClientRuntime.name}.RestException(responseMessage)`);
780
- yield ex.declarationStatement;
781
- yield `WriteError( new global::System.Management.Automation.ErrorRecord(${ex.value}, ${ex.value}.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { ${operationParameters.filter(e => codegen_csharp_1.valueOf(e.expression) !== 'null').map(each => `${each.name}=${each.expression}`).join(', ')} })
1129
+ for (const param of bodyParameters) {
1130
+ yield (0, codegen_csharp_1.If)(`(bool)(true == this.MyInvocation?.BoundParameters.ContainsKey("${param.name}"))`, `this.${param.name} = (${param.type.declaration})(this.MyInvocation?.BoundParameters["${param.name}"]);`);
1131
+ }
1132
+ });
1133
+ $this.add(updateBodyMethod);
1134
+ }
1135
+ const getPut = function* () {
1136
+ var _a;
1137
+ yield `${(_a = $this.bodyParameter) === null || _a === void 0 ? void 0 : _a.value} = await this.${$this.$('Client').invokeMethod(httpOperationName, ...[...pathParams, ...nonPathParams]).implementation} `;
1138
+ // PreProcess body parameter
1139
+ if (processGetResponse) {
1140
+ yield processGetResponse($this);
1141
+ }
1142
+ yield `this.${updateBodyMethod.name}();`;
1143
+ /** Instance:
1144
+ * _requestBodyParametersBody = await this.Client.GrafanaGetWithResult(SubscriptionId, ResourceGroupName, Name, this, Pipeline);
1145
+ * this.Update_requestBodyParametersBody();
1146
+ * */
1147
+ };
1148
+ return new codegen_csharp_1.Statements(getPut);
1149
+ }
1150
+ NewImplementResponseMethod() {
1151
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1152
+ const $this = this;
1153
+ const apiCall = $this.apiCall;
1154
+ const operationParameters = $this.operationParameters;
1155
+ const callbackMethods = $this.callbackMethods;
1156
+ const pipeline = $this.$('Pipeline');
1157
+ // make callback methods
1158
+ for (const each of (0, linq_1.values)($this.responses)) {
1159
+ const parameters = new Array();
1160
+ const isBinary = each.binary;
1161
+ parameters.push(new codegen_csharp_1.Parameter('responseMessage', codegen_csharp_1.System.Net.Http.HttpResponseMessage, { description: `the raw response message as an ${codegen_csharp_1.System.Net.Http.HttpResponseMessage}.` }));
1162
+ if ((_a = each.language.csharp) === null || _a === void 0 ? void 0 : _a.responseType) {
1163
+ parameters.push(new codegen_csharp_1.Parameter('response', codegen_csharp_1.System.Threading.Tasks.Task({ declaration: (_b = each.language.csharp) === null || _b === void 0 ? void 0 : _b.responseType }), {
1164
+ description: `the body result as a <see cref="${(_c = each.language.csharp) === null || _c === void 0 ? void 0 : _c.responseType.replace(/\[|\]|\?/g, '')}">${(_d = each.language.csharp) === null || _d === void 0 ? void 0 : _d.responseType}</see> from the remote call`
1165
+ }));
1166
+ }
1167
+ if ((_e = each.language.csharp) === null || _e === void 0 ? void 0 : _e.headerType) {
1168
+ parameters.push(new codegen_csharp_1.Parameter('headers', codegen_csharp_1.System.Threading.Tasks.Task({ declaration: each.language.csharp.headerType }), { description: `the header result as a <see cref="${each.language.csharp.headerType}" /> from the remote call` }));
1169
+ }
1170
+ if (isBinary) {
1171
+ parameters.push(new codegen_csharp_1.Parameter('response', codegen_csharp_1.System.Threading.Tasks.Task({ declaration: 'global::System.IO.Stream' }), { description: 'the body result as a <see cref="global::System.IO.Stream" /> from the remote call' }));
1172
+ }
1173
+ const override = `override${(0, codegen_1.pascalCase)(((_f = each.language.csharp) === null || _f === void 0 ? void 0 : _f.name) || '')}`;
1174
+ const returnNow = new codegen_csharp_1.Parameter('returnNow', codegen_csharp_1.System.Threading.Tasks.Task(codegen_csharp_1.dotnet.Bool), { modifier: codegen_csharp_2.ParameterModifier.Ref, description: `/// Determines if the rest of the ${(_g = each.language.csharp) === null || _g === void 0 ? void 0 : _g.name} method should be processed, or if the method should return immediately (set to true to skip further processing )` });
1175
+ const overrideResponseMethod = new codegen_csharp_1.PartialMethod(override, codegen_csharp_1.dotnet.Void, {
1176
+ parameters: [...parameters, returnNow],
1177
+ description: `<c>${override}</c> will be called before the regular ${(_h = each.language.csharp) === null || _h === void 0 ? void 0 : _h.name} has been processed, allowing customization of what happens on that response. Implement this method in a partial class to enable this behavior`,
1178
+ returnsDescription: `A <see cref="${codegen_csharp_1.System.Threading.Tasks.Task()}" /> that will be complete when handling of the method is completed.`
1179
+ });
1180
+ $this.add(overrideResponseMethod);
1181
+ const responseMethod = new codegen_csharp_1.Method(`${(_j = each.language.csharp) === null || _j === void 0 ? void 0 : _j.name}`, codegen_csharp_1.System.Threading.Tasks.Task(), {
1182
+ access: codegen_csharp_1.Access.Private,
1183
+ parameters,
1184
+ async: codegen_csharp_1.Modifier.Async,
1185
+ description: (_k = each.language.csharp) === null || _k === void 0 ? void 0 : _k.description,
1186
+ returnsDescription: `A <see cref="${codegen_csharp_1.System.Threading.Tasks.Task()}" /> that will be complete when handling of the method is completed.`
1187
+ });
1188
+ responseMethod.push((0, codegen_csharp_1.Using)('NoSynchronizationContext', ''));
1189
+ responseMethod.add(function* () {
1190
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
1191
+ const skip = (0, codegen_csharp_2.Local)('_returnNow', `${codegen_csharp_1.System.Threading.Tasks.Task(codegen_csharp_1.dotnet.Bool).declaration}.FromResult(${codegen_csharp_1.dotnet.False})`);
1192
+ yield skip.declarationStatement;
1193
+ yield `${overrideResponseMethod.invoke(...parameters, `ref ${skip.value}`)};`;
1194
+ yield `// if ${override} has returned true, then return right away.`;
1195
+ yield (0, codegen_csharp_1.If)((0, codegen_csharp_1.And)((0, codegen_csharp_1.IsNotNull)(skip), `await ${skip}`), (0, codegen_csharp_1.Return)());
1196
+ if ((_a = each.language.csharp) === null || _a === void 0 ? void 0 : _a.isErrorResponse) {
1197
+ // this should write an error to the error channel.
1198
+ yield `// Error Response : ${(_b = each.protocol.http) === null || _b === void 0 ? void 0 : _b.statusCodes[0]}`;
1199
+ const unexpected = function* () {
1200
+ var _a;
1201
+ yield '// Unrecognized Response. Create an error record based on what we have.';
1202
+ const ex = ((_a = each.language.csharp) === null || _a === void 0 ? void 0 : _a.responseType) ?
1203
+ (0, codegen_csharp_2.Local)('ex', `new ${exports_1.ClientRuntime.name}.RestException<${each.language.csharp.responseType}>(responseMessage, await response)`) :
1204
+ (0, codegen_csharp_2.Local)('ex', `new ${exports_1.ClientRuntime.name}.RestException(responseMessage)`);
1205
+ yield ex.declarationStatement;
1206
+ yield `WriteError( new global::System.Management.Automation.ErrorRecord(${ex.value}, ${ex.value}.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { ${operationParameters.filter(e => (0, codegen_csharp_1.valueOf)(e.expression) !== 'null').map(each => `${each.name}=${each.expression}`).join(', ')} })
782
1207
  {
783
1208
  ErrorDetails = new global::System.Management.Automation.ErrorDetails(${ex.value}.Message) { RecommendedAction = ${ex.value}.Action }
784
1209
  });`;
785
- };
786
- if (each.schema !== undefined) {
787
- // the schema should be the error information.
788
- // this supports both { error { message, code} } and { message, code}
789
- let props = schema_1.getAllPublicVirtualProperties((_c = each.schema.language.csharp) === null || _c === void 0 ? void 0 : _c.virtualProperties);
790
- const errorProperty = linq_1.values(props).first(p => p.property.serializedName === 'error');
791
- let ep = '';
792
- if (errorProperty) {
793
- props = schema_1.getAllPublicVirtualProperties((_d = errorProperty.property.schema.language.csharp) === null || _d === void 0 ? void 0 : _d.virtualProperties);
794
- ep = `${errorProperty.name}?.`;
795
- }
796
- const codeProp = props.find(p => p.name.toLowerCase().indexOf('code') > -1); // first property with 'code'
797
- const messageProp = props.find(p => p.name.toLowerCase().indexOf('message') > -1); // first property with 'message'
798
- const actionProp = props.find(p => p.name.toLowerCase().indexOf('action') > -1); // first property with 'action'
799
- if (codeProp && messageProp) {
800
- const lcode = new codegen_csharp_1.LocalVariable('code', codegen_csharp_1.dotnet.Var, { initializer: `(await response)?.${ep}${codeProp.name}` });
801
- const lmessage = new codegen_csharp_1.LocalVariable('message', codegen_csharp_1.dotnet.Var, { initializer: `(await response)?.${ep}${messageProp.name}` });
802
- const laction = actionProp ? new codegen_csharp_1.LocalVariable('action', codegen_csharp_1.dotnet.Var, { initializer: `(await response)?.${ep}${actionProp.name} ?? ${codegen_csharp_1.System.String.Empty}` }) : undefined;
803
- yield lcode;
804
- yield lmessage;
805
- yield laction;
806
- yield codegen_csharp_1.If(codegen_csharp_1.Or(codegen_csharp_1.IsNull(lcode), (codegen_csharp_1.IsNull(lmessage))), unexpected);
807
- yield codegen_csharp_1.Else(`WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{${lcode}}] : {${lmessage}}"), ${lcode}?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { ${operationParameters.filter(e => codegen_csharp_1.valueOf(e.expression) !== 'null').map(each => `${each.name}=${each.expression}`).join(', ')} })
1210
+ };
1211
+ if (each.schema !== undefined) {
1212
+ // the schema should be the error information.
1213
+ // this supports both { error { message, code} } and { message, code}
1214
+ let props = (0, schema_1.getAllPublicVirtualProperties)((_c = each.schema.language.csharp) === null || _c === void 0 ? void 0 : _c.virtualProperties);
1215
+ const errorProperty = (0, linq_1.values)(props).first(p => p.property.serializedName === 'error');
1216
+ let ep = '';
1217
+ if (errorProperty) {
1218
+ props = (0, schema_1.getAllPublicVirtualProperties)((_d = errorProperty.property.schema.language.csharp) === null || _d === void 0 ? void 0 : _d.virtualProperties);
1219
+ ep = `${errorProperty.name}?.`;
1220
+ }
1221
+ const codeProp = props.find(p => p.name.toLowerCase().indexOf('code') > -1); // first property with 'code'
1222
+ const messageProp = props.find(p => p.name.toLowerCase().indexOf('message') > -1); // first property with 'message'
1223
+ const actionProp = props.find(p => p.name.toLowerCase().indexOf('action') > -1); // first property with 'action'
1224
+ if (codeProp && messageProp) {
1225
+ const lcode = new codegen_csharp_1.LocalVariable('code', codegen_csharp_1.dotnet.Var, { initializer: `(await response)?.${ep}${codeProp.name}` });
1226
+ const lmessage = new codegen_csharp_1.LocalVariable('message', codegen_csharp_1.dotnet.Var, { initializer: `(await response)?.${ep}${messageProp.name}` });
1227
+ const laction = actionProp ? new codegen_csharp_1.LocalVariable('action', codegen_csharp_1.dotnet.Var, { initializer: `(await response)?.${ep}${actionProp.name} ?? ${codegen_csharp_1.System.String.Empty}` }) : undefined;
1228
+ yield lcode;
1229
+ yield lmessage;
1230
+ yield laction;
1231
+ yield (0, codegen_csharp_1.If)((0, codegen_csharp_1.Or)((0, codegen_csharp_1.IsNull)(lcode), ((0, codegen_csharp_1.IsNull)(lmessage))), unexpected);
1232
+ yield (0, codegen_csharp_1.Else)(`WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{${lcode}}] : {${lmessage}}"), ${lcode}?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { ${operationParameters.filter(e => (0, codegen_csharp_1.valueOf)(e.expression) !== 'null').map(each => `${each.name}=${each.expression}`).join(', ')} })
808
1233
  {
809
1234
  ErrorDetails = new global::System.Management.Automation.ErrorDetails(${lmessage}) { RecommendedAction = ${laction || codegen_csharp_1.System.String.Empty} }
810
1235
  });`);
811
- return;
812
- }
813
- else {
814
- yield unexpected;
815
- return;
816
- }
1236
+ return;
817
1237
  }
818
1238
  else {
819
1239
  yield unexpected;
820
1240
  return;
821
1241
  }
822
1242
  }
823
- yield `// ${(_e = each.language.csharp) === null || _e === void 0 ? void 0 : _e.name} - response for ${(_f = each.protocol.http) === null || _f === void 0 ? void 0 : _f.statusCodes[0]} / ${linq_1.values((_g = each.protocol.http) === null || _g === void 0 ? void 0 : _g.mediaTypes).join('/')}`;
824
- if ('schema' in each) {
825
- const schema = each.schema;
826
- if ((_h = apiCall.language.csharp) === null || _h === void 0 ? void 0 : _h.pageable) {
827
- const pageable = apiCall.language.csharp.pageable;
828
- if ($this.clientsidePagination) {
829
- yield '// clientside pagination enabled';
830
- }
831
- yield '// response should be returning an array of some kind. +Pageable';
832
- yield `// ${pageable.responseType} / ${pageable.itemName || '<none>'} / ${pageable.nextLinkName || '<none>'}`;
833
- switch (pageable.responseType) {
834
- // the result is (or works like a x-ms-pageable)
835
- case 'pageable':
836
- case 'nested-array':
837
- {
838
- const valueProperty = (_j = schema.properties) === null || _j === void 0 ? void 0 : _j.find(p => p.serializedName === pageable.itemName);
839
- const nextLinkProperty = (_l = (_k = schema) === null || _k === void 0 ? void 0 : _k.properties) === null || _l === void 0 ? void 0 : _l.find(p => p.serializedName === pageable.nextLinkName);
840
- if (valueProperty && nextLinkProperty) {
841
- // it's pageable!
842
- const result = new codegen_csharp_1.LocalVariable('result', codegen_csharp_1.dotnet.Var, { initializer: new codegen_csharp_1.LiteralExpression('await response') });
843
- yield result.declarationStatement;
844
- // write out the current contents
845
- const vp = schema_1.getVirtualPropertyFromPropertyName((_m = schema.language.csharp) === null || _m === void 0 ? void 0 : _m.virtualProperties, valueProperty.serializedName);
846
- if (vp) {
847
- if ($this.clientsidePagination) {
848
- yield (codegen_csharp_1.If('(ulong)result.Value.Count <= this.PagingParameters.Skip', function* () {
849
- yield ('this.PagingParameters.Skip = this.PagingParameters.Skip - (ulong)result.Value.Count;');
850
- }));
851
- yield codegen_csharp_1.Else(function* () {
852
- yield ('ulong toRead = Math.Min(this.PagingParameters.First, (ulong)result.Value.Count - this.PagingParameters.Skip);');
853
- yield ('var requiredResult = result.Value.GetRange((int)this.PagingParameters.Skip, (int)toRead);');
854
- yield $this.WriteObjectWithViewControl(`requiredResult`, true);
855
- yield ('this.PagingParameters.Skip = 0;');
856
- yield ('this.PagingParameters.First = this.PagingParameters.First <= toRead ? 0 : this.PagingParameters.First - toRead;');
857
- });
858
- }
859
- else {
860
- yield $this.WriteObjectWithViewControl(`${result.value}.${vp.name}`, true);
861
- }
862
- }
863
- const nl = schema_1.getVirtualPropertyFromPropertyName((_o = schema.language.csharp) === null || _o === void 0 ? void 0 : _o.virtualProperties, nextLinkProperty.serializedName);
864
- if (nl) {
865
- $this.add(new codegen_csharp_1.Field('_isFirst', codegen_csharp_1.dotnet.Bool, {
866
- access: codegen_csharp_1.Access.Private,
867
- initialValue: new codegen_csharp_1.LiteralExpression('true'),
868
- description: 'A flag to tell whether it is the first onOK call.'
869
- }));
870
- $this.add(new codegen_csharp_1.Field('_nextLink', codegen_csharp_1.dotnet.String, {
871
- access: codegen_csharp_1.Access.Private,
872
- description: 'Link to retrieve next page.'
873
- }));
874
- const nextLinkName = `${result.value}.${nl.name}`;
875
- yield `_nextLink = ${nextLinkName};`;
876
- const nextLinkCondition = $this.clientsidePagination ? '_nextLink != null && this.PagingParameters.First > 0' : '_nextLink != null';
877
- yield (codegen_csharp_1.If('_isFirst', function* () {
878
- yield '_isFirst = false;';
879
- yield (codegen_csharp_1.While(nextLinkCondition, codegen_csharp_1.If('responseMessage.RequestMessage is System.Net.Http.HttpRequestMessage requestMessage ', function* () {
880
- var _a;
881
- yield `requestMessage = requestMessage.Clone(new global::System.Uri( _nextLink ),${exports_1.ClientRuntime.Method.Get} );`;
882
- yield $this.eventListener.signal(powershell_declarations_1.Events.FollowingNextLink);
883
- yield `await this.${$this.$('Client').invokeMethod(`${(_a = apiCall.language.csharp) === null || _a === void 0 ? void 0 : _a.name}_Call`, ...[codegen_csharp_1.toExpression('requestMessage'), ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline]).implementation}`;
884
- })));
1243
+ else {
1244
+ yield unexpected;
1245
+ return;
1246
+ }
1247
+ }
1248
+ yield `// ${(_e = each.language.csharp) === null || _e === void 0 ? void 0 : _e.name} - response for ${(_f = each.protocol.http) === null || _f === void 0 ? void 0 : _f.statusCodes[0]} / ${(0, linq_1.values)((_g = each.protocol.http) === null || _g === void 0 ? void 0 : _g.mediaTypes).join('/')}`;
1249
+ if ('schema' in each) {
1250
+ const schema = each.schema;
1251
+ const props = (0, schema_1.getAllPublicVirtualProperties)((_h = schema.language.csharp) === null || _h === void 0 ? void 0 : _h.virtualProperties);
1252
+ const rType = $this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(schema, true, $this.state);
1253
+ const result = new codegen_csharp_1.LocalVariable('result', codegen_csharp_1.dotnet.Var, { initializer: new codegen_csharp_1.LiteralExpression('(await response)') });
1254
+ yield `// (await response) // should be ${rType.declaration}`;
1255
+ yield result.declarationStatement;
1256
+ if ((_j = apiCall.language.csharp) === null || _j === void 0 ? void 0 : _j.pageable) {
1257
+ const pageable = apiCall.language.csharp.pageable;
1258
+ if ($this.clientsidePagination) {
1259
+ yield '// clientside pagination enabled';
1260
+ }
1261
+ yield '// response should be returning an array of some kind. +Pageable';
1262
+ yield `// ${pageable.responseType} / ${pageable.itemName || '<none>'} / ${pageable.nextLinkName || '<none>'}`;
1263
+ switch (pageable.responseType) {
1264
+ // the result is (or works like a x-ms-pageable)
1265
+ case 'pageable':
1266
+ case 'nested-array':
1267
+ {
1268
+ const valueProperty = (_k = schema.properties) === null || _k === void 0 ? void 0 : _k.find(p => p.serializedName === pageable.itemName);
1269
+ const nextLinkProperty = (_l = schema === null || schema === void 0 ? void 0 : schema.properties) === null || _l === void 0 ? void 0 : _l.find(p => p.serializedName === pageable.nextLinkName);
1270
+ if (valueProperty && nextLinkProperty) {
1271
+ // it's pageable!
1272
+ // write out the current contents
1273
+ const vp = (0, schema_1.getVirtualPropertyFromPropertyName)((_m = schema.language.csharp) === null || _m === void 0 ? void 0 : _m.virtualProperties, valueProperty.serializedName);
1274
+ if (vp) {
1275
+ if ($this.clientsidePagination) {
1276
+ yield ((0, codegen_csharp_1.If)('(ulong)result.Value.Count <= this.PagingParameters.Skip', function* () {
1277
+ yield ('this.PagingParameters.Skip = this.PagingParameters.Skip - (ulong)result.Value.Count;');
885
1278
  }));
1279
+ yield (0, codegen_csharp_1.Else)(function* () {
1280
+ yield ('ulong toRead = Math.Min(this.PagingParameters.First, (ulong)result.Value.Count - this.PagingParameters.Skip);');
1281
+ yield ('var requiredResult = result.Value.GetRange((int)this.PagingParameters.Skip, (int)toRead);');
1282
+ yield $this.WriteObjectWithViewControl('requiredResult', true);
1283
+ yield ('this.PagingParameters.Skip = 0;');
1284
+ yield ('this.PagingParameters.First = this.PagingParameters.First <= toRead ? 0 : this.PagingParameters.First - toRead;');
1285
+ });
886
1286
  }
887
- return;
888
- }
889
- else if (valueProperty) {
890
- // it's just a nested array
891
- const p = codemodel_v3_1.getVirtualPropertyFromPropertyName((_p = schema.language.csharp) === null || _p === void 0 ? void 0 : _p.virtualProperties, valueProperty.serializedName);
892
- if (p) {
893
- yield $this.WriteObjectWithViewControl(`(await response).${p.name}`, true);
1287
+ else {
1288
+ yield $this.WriteObjectWithViewControl(`${result.value}.${vp.name}`, true);
894
1289
  }
895
- return;
896
1290
  }
1291
+ const nl = (0, schema_1.getVirtualPropertyFromPropertyName)((_o = schema.language.csharp) === null || _o === void 0 ? void 0 : _o.virtualProperties, nextLinkProperty.serializedName);
1292
+ if (nl) {
1293
+ $this.add(new codegen_csharp_1.Field('_isFirst', codegen_csharp_1.dotnet.Bool, {
1294
+ access: codegen_csharp_1.Access.Private,
1295
+ initialValue: new codegen_csharp_1.LiteralExpression('true'),
1296
+ description: 'A flag to tell whether it is the first onOK call.'
1297
+ }));
1298
+ $this.add(new codegen_csharp_1.Field('_nextLink', codegen_csharp_1.dotnet.String, {
1299
+ access: codegen_csharp_1.Access.Private,
1300
+ description: 'Link to retrieve next page.'
1301
+ }));
1302
+ const nextLinkName = `${result.value}.${nl.name}`;
1303
+ yield `_nextLink = ${nextLinkName};`;
1304
+ const nextLinkCondition = $this.clientsidePagination ? '!String.IsNullOrEmpty(_nextLink) && this.PagingParameters.First > 0' : '!String.IsNullOrEmpty(_nextLink)';
1305
+ yield ((0, codegen_csharp_1.If)('_isFirst', function* () {
1306
+ yield '_isFirst = false;';
1307
+ yield ((0, codegen_csharp_1.While)(nextLinkCondition, (0, codegen_csharp_1.If)('responseMessage.RequestMessage is System.Net.Http.HttpRequestMessage requestMessage ', function* () {
1308
+ var _a;
1309
+ yield `requestMessage = requestMessage.Clone(new global::System.Uri( _nextLink ),${exports_1.ClientRuntime.Method.Get} );`;
1310
+ yield $this.eventListener.signal(powershell_declarations_1.Events.FollowingNextLink);
1311
+ yield `await this.${$this.$('Client').invokeMethod(`${(_a = apiCall.language.csharp) === null || _a === void 0 ? void 0 : _a.name}_Call`, ...[(0, codegen_csharp_1.toExpression)('requestMessage'), ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline]).implementation}`;
1312
+ })));
1313
+ }));
1314
+ }
1315
+ return;
897
1316
  }
898
- break;
899
- // it's just an array,
900
- case 'array':
901
- // just write-object(enumerate) with the output
902
- yield $this.WriteObjectWithViewControl('(await response)', true);
903
- return;
904
- }
905
- // ok, let's see if the response type
906
- }
907
- const props = schema_1.getAllPublicVirtualProperties((_q = schema.language.csharp) === null || _q === void 0 ? void 0 : _q.virtualProperties);
908
- const outValue = (linq_1.length(props) === 1) ? `(await response).${props[0].name}` : '(await response)';
909
- // we expect to get back some data from this call.
910
- const rType = $this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(schema, true, $this.state);
911
- yield `// (await response) // should be ${rType.declaration}`;
912
- if ($this.hasStreamOutput && $this.outFileParameter) {
913
- const outfile = $this.outFileParameter;
914
- const provider = codegen_csharp_2.Local('provider');
915
- provider.initializer = undefined;
916
- const paths = codegen_csharp_2.Local('paths', `this.SessionState.Path.GetResolvedProviderPathFromPSPath(${outfile.value}, out ${provider.declarationExpression})`);
917
- yield paths.declarationStatement;
918
- yield codegen_csharp_1.If(`${provider.value}.Name != "FileSystem" || ${paths.value}.Count == 0`, `ThrowTerminatingError( new System.Management.Automation.ErrorRecord(new global::System.Exception("Invalid output path."),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, ${outfile.value}) );`);
919
- yield codegen_csharp_1.If(`${paths.value}.Count > 1`, `ThrowTerminatingError( new System.Management.Automation.ErrorRecord(new global::System.Exception("Multiple output paths not allowed."),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, ${outfile.value}) );`);
920
- if (rType.declaration === codegen_csharp_1.System.IO.Stream.declaration) {
921
- // this is a stream output. write to outfile
922
- const stream = codegen_csharp_2.Local('stream', 'await response');
923
- yield codegen_csharp_1.Using(stream.declarationExpression, function* () {
924
- const fileStream = codegen_csharp_2.Local('fileStream', `global::System.IO.File.OpenWrite(${paths.value}[0])`);
925
- yield codegen_csharp_1.Using(fileStream.declarationExpression, `await ${stream.value}.CopyToAsync(${fileStream.value});`);
926
- });
927
- }
928
- else {
929
- // assuming byte array output (via outValue)
930
- yield `global::System.IO.File.WriteAllBytes(${paths.value}[0],${outValue});`;
931
- }
932
- yield codegen_csharp_1.If('true == MyInvocation?.BoundParameters?.ContainsKey("PassThru")', function* () {
933
- // no return type. Let's just return ... true?
934
- yield 'WriteObject(true);';
935
- });
936
- return;
937
- }
938
- // let's just return the result object (or unwrapped result object)
939
- yield $this.WriteObjectWithViewControl(`${outValue}`);
940
- return;
941
- }
942
- // in m4, there will be no schema deinfed for the binary response, instead, we will have a field called binary with value true.
943
- if ('binary' in each) {
944
- yield '// (await response) // should be global::System.IO.Stream';
945
- if ($this.hasStreamOutput && $this.outFileParameter) {
946
- const outfile = $this.outFileParameter;
947
- const provider = codegen_csharp_2.Local('provider');
948
- provider.initializer = undefined;
949
- const paths = codegen_csharp_2.Local('paths', 'new global::System.Collections.ObjectModel.Collection<global::System.String>()');
950
- yield paths.declarationStatement;
951
- yield codegen_csharp_1.Try(function* () {
952
- yield `${paths.value} = this.SessionState.Path.GetResolvedProviderPathFromPSPath(${outfile.value}, out ${provider.declarationExpression});`;
953
- yield codegen_csharp_1.If(`${provider.value}.Name != "FileSystem" || ${paths.value}.Count == 0`, `ThrowTerminatingError(new System.Management.Automation.ErrorRecord(new global::System.Exception("Invalid output path."), string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, ${outfile.value}));`);
954
- yield codegen_csharp_1.If(`${paths.value}.Count > 1`, `ThrowTerminatingError(new System.Management.Automation.ErrorRecord(new global::System.Exception("Multiple output paths not allowed."), string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, ${outfile.value}));`);
955
- });
956
- const notfound = new codegen_csharp_1.Parameter('', { declaration: 'global::System.Management.Automation.ItemNotFoundException' });
957
- yield codegen_csharp_1.Catch(notfound, function* () {
958
- yield '// If the file does not exist, we will try to create it';
959
- yield `${paths.value}.Add(${outfile.value});`;
960
- });
961
- // this is a stream output. write to outfile
962
- const stream = codegen_csharp_2.Local('stream', 'await response');
963
- yield codegen_csharp_1.Using(stream.declarationExpression, function* () {
964
- const fileStream = codegen_csharp_2.Local('fileStream', `global::System.IO.File.OpenWrite(${paths.value}[0])`);
965
- yield codegen_csharp_1.Using(fileStream.declarationExpression, `await ${stream.value}.CopyToAsync(${fileStream.value});`);
966
- });
967
- yield codegen_csharp_1.If('true == MyInvocation?.BoundParameters?.ContainsKey("PassThru")', function* () {
968
- // no return type. Let's just return ... true?
969
- yield 'WriteObject(true);';
970
- });
971
- return;
972
- }
973
- }
974
- yield codegen_csharp_1.If('true == MyInvocation?.BoundParameters?.ContainsKey("PassThru")', function* () {
975
- // no return type. Let's just return ... true?
976
- yield 'WriteObject(true);';
977
- });
978
- });
979
- $this.add(responseMethod);
980
- }
981
- yield codegen_csharp_1.Try(function* () {
982
- // make the call.
983
- const actualCall = function* () {
984
- var _a, _b;
985
- yield $this.eventListener.signal(powershell_declarations_1.Events.CmdletBeforeAPICall);
986
- const nonPathParams = operationParameters.filter(each => !each.isPathParam);
987
- const allParams = [];
988
- const idOpParamsNotFromIdentity = [];
989
- const idOpParamsFromIdentity = [];
990
- const idOpParamsFromIdentityserializedName = [];
991
- const idschema = linq_1.values($this.state.project.model.schemas.objects).first(each => each.language.default.uid === 'universal-parameter-type');
992
- let serializationMode = null;
993
- if ($this.bodyParameter) {
994
- if ($this.operation.operationType === command_operation_1.OperationType.Create) {
995
- serializationMode = exports_1.ClientRuntime.SerializationMode.IncludeCreate;
996
- }
997
- else if ($this.operation.operationType === command_operation_1.OperationType.Update) {
998
- serializationMode = exports_1.ClientRuntime.SerializationMode.IncludeUpdate;
999
- }
1000
- }
1001
- if ($this.isViaIdentity) {
1002
- if (idschema) {
1003
- const allVPs = schema_1.getAllPublicVirtualProperties((_a = idschema.language.csharp) === null || _a === void 0 ? void 0 : _a.virtualProperties);
1004
- const props = [...linq_1.values(idschema.properties)];
1005
- operationParameters.forEach(each => {
1006
- var _a, _b, _c, _d, _e, _f;
1007
- const pascalName = codegen_1.pascalCase(`${each.name}`);
1008
- //push parameters that is not path parameters into allParams and idOpParamsNotFromIdentity
1009
- if (!each.isPathParam) {
1010
- const param = {
1011
- name: undefined,
1012
- value: codegen_csharp_1.valueOf(each.expression)
1013
- };
1014
- allParams.push(param);
1015
- idOpParamsNotFromIdentity.push(param);
1016
- return;
1017
- }
1018
- const match = props.find(p => codegen_1.pascalCase(p.serializedName) === pascalName);
1019
- if (match) {
1020
- const defaultOfType = $this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(match.schema, true, $this.state).defaultOfType;
1021
- // match up vp name
1022
- const vp = allVPs.find(pp => codegen_1.pascalCase(pp.property.serializedName) === pascalName);
1023
- //push path parameters that form current identity into allParams, idOpParamsFromIdentity and idOpParamsFromIdentityserializedName
1024
- if (vp && each.expression === codegen_csharp_1.dotnet.Null) {
1025
- const param = {
1026
- name: `${$this.inputObjectParameterName}.${vp.name}`,
1027
- value: `${$this.inputObjectParameterName}.${vp.name} ?? ${defaultOfType}`
1028
- };
1029
- allParams.push(param);
1030
- idOpParamsFromIdentity.push(param);
1031
- idOpParamsFromIdentityserializedName.push(match.serializedName);
1317
+ else if (valueProperty) {
1318
+ // it's just a nested array
1319
+ const p = (0, codemodel_v3_1.getVirtualPropertyFromPropertyName)((_p = schema.language.csharp) === null || _p === void 0 ? void 0 : _p.virtualProperties, valueProperty.serializedName);
1320
+ if (p) {
1321
+ yield $this.WriteObjectWithViewControl(`${result.value}.${p.name}`, true);
1322
+ }
1032
1323
  return;
1033
1324
  }
1034
- // fall back!
1035
- console.error(`Unable to match identity parameter '${each.name}' member to appropriate virtual parameter. (Guessing '${codegen_1.pascalCase((_b = (_a = match.language.csharp) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '')}').`);
1036
- //push path parameters that current identity does not contain into allParams and idOpParamsNotFromIdentity
1037
- const param = {
1038
- name: `${codegen_1.pascalCase((_d = (_c = match.language.csharp) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : '')}`,
1039
- value: `${codegen_1.pascalCase((_f = (_e = match.language.csharp) === null || _e === void 0 ? void 0 : _e.name) !== null && _f !== void 0 ? _f : '')}`
1040
- };
1041
- allParams.push(param);
1042
- idOpParamsNotFromIdentity.push(param);
1043
- }
1044
- else {
1045
- console.error(`Unable to match identity parameter '${each.name}' member to appropriate virtual parameter. (Guessing '${pascalName}')`);
1046
- /*
1047
- push path parameters do not match the name in identity schema into allParams and idOpParamsNotFromIdentity
1048
- for example, module 'Service' has only one GET API:
1049
- /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Service/resource1/{resource1Name}/resource2/{resource2Name}/resource3/{resource3Name}
1050
- the identity schema 'ServiceIdentity.cs' will have properties: {subscriptionId, resourceGroupName, resource1Name, resource2Name, resource3Name}
1051
- for variant which has (identity of resource2 + resource3Name) combined as parameters, the parameter name for 'resource3Name' is called 'Name' which do not match 'resource3Name' in 'ServiceIdentity.cs'
1052
- */
1053
- const param = {
1054
- name: `${pascalName}`,
1055
- value: `${pascalName}`
1056
- };
1057
- allParams.push(param);
1058
- idOpParamsNotFromIdentity.push(param);
1059
1325
  }
1060
- });
1326
+ break;
1327
+ // it's just an array,
1328
+ case 'array':
1329
+ // just write-object(enumerate) with the output
1330
+ yield $this.WriteObjectWithViewControl(result.value, true);
1331
+ return;
1061
1332
  }
1062
- const parameters = [codegen_csharp_1.toExpression(`${$this.inputObjectParameterName}.Id`), ...nonPathParams.map(each => each.expression), ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline];
1063
- //when identity does not contain property: 'Id'
1064
- const identityFromPathParams = function* () {
1065
- var _a;
1066
- yield '// try to call with PATH parameters from Input Object';
1067
- if (idschema) {
1068
- for (const opParam of idOpParamsFromIdentity) {
1069
- if (opParam && opParam.name) {
1070
- yield codegen_csharp_1.If(codegen_csharp_1.IsNull(opParam.name), `ThrowTerminatingError( new ${powershell_declarations_1.ErrorRecord}(new global::System.Exception("${$this.inputObjectParameterName} has null value for ${opParam.name}"),string.Empty, ${powershell_declarations_1.ErrorCategory('InvalidArgument')}, ${$this.inputObjectParameterName}) );`);
1071
- }
1072
- }
1073
- yield `await this.${$this.$('Client').invokeMethod(`${(_a = apiCall.language.csharp) === null || _a === void 0 ? void 0 : _a.name}`, ...[...allParams.map(each => codegen_csharp_1.toExpression(each.value)), ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline]).implementation}`;
1074
- }
1075
- };
1076
- //when identity does contain property: 'Id'
1077
- const identityParams = function* () {
1078
- var _a, _b, _c, _d;
1079
- const path = (_c = (_b = (_a = $this.operation.callGraph) === null || _a === void 0 ? void 0 : _a[0].requests) === null || _b === void 0 ? void 0 : _b[0].protocol.http) === null || _c === void 0 ? void 0 : _c.path;
1080
- let pathParams = '';
1081
- //append path parameters which are not part of current identity
1082
- idOpParamsNotFromIdentity.forEach(each => {
1083
- var _a;
1084
- const serializedName = (_a = linq_1.values($this.properties)
1085
- .where(p => p.metadata.parameterDefinition)
1086
- .first(p => p.name === each.name)) === null || _a === void 0 ? void 0 : _a.metadata.parameterDefinition.language.csharp.serializedName;
1087
- if (each.name && serializedName) {
1088
- if (!pathParams) {
1089
- pathParams += '$"';
1090
- }
1091
- const resourceName = resourceName_1.getResourceNameFromPath(path, serializedName);
1092
- if (resourceName) {
1093
- pathParams += `/${resourceName}/{(global::System.Uri.EscapeDataString(this.${each.name}.ToString()))}`;
1094
- }
1095
- }
1333
+ // ok, let's see if the response type
1334
+ }
1335
+ // we expect to get back some data from this call.
1336
+ if ($this.hasStreamOutput && $this.outFileParameter) {
1337
+ const outfile = $this.outFileParameter;
1338
+ const provider = (0, codegen_csharp_2.Local)('provider');
1339
+ provider.initializer = undefined;
1340
+ const paths = (0, codegen_csharp_2.Local)('paths', `this.SessionState.Path.GetResolvedProviderPathFromPSPath(${outfile.value}, out ${provider.declarationExpression})`);
1341
+ yield paths.declarationStatement;
1342
+ yield (0, codegen_csharp_1.If)(`${provider.value}.Name != "FileSystem" || ${paths.value}.Count == 0`, `ThrowTerminatingError( new System.Management.Automation.ErrorRecord(new global::System.Exception("Invalid output path."),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, ${outfile.value}) );`);
1343
+ yield (0, codegen_csharp_1.If)(`${paths.value}.Count > 1`, `ThrowTerminatingError( new System.Management.Automation.ErrorRecord(new global::System.Exception("Multiple output paths not allowed."),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, ${outfile.value}) );`);
1344
+ if (rType.declaration === codegen_csharp_1.System.IO.Stream.declaration) {
1345
+ // this is a stream output. write to outfile
1346
+ const stream = (0, codegen_csharp_2.Local)('stream', result.value);
1347
+ yield (0, codegen_csharp_1.Using)(stream.declarationExpression, function* () {
1348
+ const fileStream = (0, codegen_csharp_2.Local)('fileStream', `global::System.IO.File.OpenWrite(${paths.value}[0])`);
1349
+ yield (0, codegen_csharp_1.Using)(fileStream.declarationExpression, `await ${stream.value}.CopyToAsync(${fileStream.value});`);
1096
1350
  });
1097
- const hasPath = pathParams && pathParams.length > 0;
1098
- //add child resource to path for list operation
1099
- if ($this.operation.variant.startsWith('List') && (idOpParamsFromIdentityserializedName === null || idOpParamsFromIdentityserializedName === void 0 ? void 0 : idOpParamsFromIdentityserializedName[idOpParamsFromIdentityserializedName.length - 1])) {
1100
- const childResourceName = resourceName_1.getChildResourceNameFromPath(path, idOpParamsFromIdentityserializedName === null || idOpParamsFromIdentityserializedName === void 0 ? void 0 : idOpParamsFromIdentityserializedName[idOpParamsFromIdentityserializedName.length - 1]);
1101
- if (pathParams && pathParams.length > 0) {
1102
- pathParams += `/${childResourceName}`;
1103
- }
1104
- else {
1105
- pathParams += `"/${childResourceName}`;
1106
- }
1107
- }
1108
- if (pathParams && pathParams.length > 0) {
1109
- pathParams += '";';
1110
- yield `this.${$this.inputObjectParameterName}.Id += ${pathParams}`;
1111
- }
1112
- yield `await this.${$this.$('Client').invokeMethod(`${(_d = apiCall.language.csharp) === null || _d === void 0 ? void 0 : _d.name}ViaIdentity`, ...parameters).implementation}`;
1113
- };
1114
- if (idschema && linq_1.values(idschema.properties).first(each => { var _a; return ((_a = each.language.csharp) === null || _a === void 0 ? void 0 : _a.uid) === 'universal-parameter:resource identity'; })) {
1115
- if (serializationMode) {
1116
- parameters.push(serializationMode);
1117
- }
1118
- yield codegen_csharp_1.If(`${$this.inputObjectParameterName}?.Id != null`, identityParams);
1119
- yield codegen_csharp_1.Else(identityFromPathParams);
1120
1351
  }
1121
1352
  else {
1122
- yield identityFromPathParams;
1123
- }
1124
- }
1125
- else {
1126
- const parameters = [...operationParameters.map(each => each.expression), ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline];
1127
- if (serializationMode) {
1128
- parameters.push(serializationMode);
1353
+ // assuming byte array output (via result)
1354
+ yield `global::System.IO.File.WriteAllBytes(${paths.value}[0],${result.value});`;
1129
1355
  }
1130
- yield `await this.${$this.$('Client').invokeMethod(`${(_b = apiCall.language.csharp) === null || _b === void 0 ? void 0 : _b.name}`, ...parameters).implementation}`;
1356
+ yield (0, codegen_csharp_1.If)('true == MyInvocation?.BoundParameters?.ContainsKey("PassThru")', function* () {
1357
+ // no return type. Let's just return ... true?
1358
+ yield 'WriteObject(true);';
1359
+ });
1360
+ return;
1131
1361
  }
1132
- yield $this.eventListener.signal(powershell_declarations_1.Events.CmdletAfterAPICall);
1133
- };
1134
- if ($this.state.project.azure && operationParameters.find(each => each.expression && each.expression.value === 'SubscriptionId') && $this.operation.details.csharp.verb.toLowerCase() === 'get') {
1135
- yield 'foreach( var SubscriptionId in this.SubscriptionId )';
1136
- yield codegen_csharp_1.BlockStatement(actualCall);
1362
+ // let's just return the result object (or unwrapped result object)
1363
+ yield $this.WriteObjectWithViewControl(result.value);
1364
+ return;
1137
1365
  }
1138
- else {
1139
- yield actualCall;
1366
+ // in m4, there will be no schema deinfed for the binary response, instead, we will have a field called binary with value true.
1367
+ if ('binary' in each) {
1368
+ yield '// (await response) // should be global::System.IO.Stream';
1369
+ if ($this.hasStreamOutput && $this.outFileParameter) {
1370
+ const outfile = $this.outFileParameter;
1371
+ const provider = (0, codegen_csharp_2.Local)('provider');
1372
+ provider.initializer = undefined;
1373
+ const paths = (0, codegen_csharp_2.Local)('paths', 'new global::System.Collections.ObjectModel.Collection<global::System.String>()');
1374
+ yield paths.declarationStatement;
1375
+ yield (0, codegen_csharp_1.Try)(function* () {
1376
+ yield `${paths.value} = this.SessionState.Path.GetResolvedProviderPathFromPSPath(${outfile.value}, out ${provider.declarationExpression});`;
1377
+ yield (0, codegen_csharp_1.If)(`${provider.value}.Name != "FileSystem" || ${paths.value}.Count == 0`, `ThrowTerminatingError(new System.Management.Automation.ErrorRecord(new global::System.Exception("Invalid output path."), string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, ${outfile.value}));`);
1378
+ yield (0, codegen_csharp_1.If)(`${paths.value}.Count > 1`, `ThrowTerminatingError(new System.Management.Automation.ErrorRecord(new global::System.Exception("Multiple output paths not allowed."), string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, ${outfile.value}));`);
1379
+ });
1380
+ const notfound = new codegen_csharp_1.Parameter('', { declaration: 'global::System.Management.Automation.ItemNotFoundException' });
1381
+ yield (0, codegen_csharp_1.Catch)(notfound, function* () {
1382
+ yield '// If the file does not exist, we will try to create it';
1383
+ yield `${paths.value}.Add(${outfile.value});`;
1384
+ });
1385
+ // this is a stream output. write to outfile
1386
+ const stream = (0, codegen_csharp_2.Local)('stream', 'await response');
1387
+ yield (0, codegen_csharp_1.Using)(stream.declarationExpression, function* () {
1388
+ const fileStream = (0, codegen_csharp_2.Local)('fileStream', `global::System.IO.File.OpenWrite(${paths.value}[0])`);
1389
+ yield (0, codegen_csharp_1.Using)(fileStream.declarationExpression, `await ${stream.value}.CopyToAsync(${fileStream.value});`);
1390
+ });
1391
+ yield (0, codegen_csharp_1.If)('true == MyInvocation?.BoundParameters?.ContainsKey("PassThru")', function* () {
1392
+ // no return type. Let's just return ... true?
1393
+ yield 'WriteObject(true);';
1394
+ });
1395
+ return;
1396
+ }
1140
1397
  }
1398
+ yield (0, codegen_csharp_1.If)('true == MyInvocation?.BoundParameters?.ContainsKey("PassThru")', function* () {
1399
+ // no return type. Let's just return ... true?
1400
+ yield 'WriteObject(true);';
1401
+ });
1141
1402
  });
1142
- const ure = new codegen_csharp_1.Parameter('urexception', { declaration: `${exports_1.ClientRuntime.fullName}.UndeclaredResponseException` });
1143
- yield codegen_csharp_1.Catch(ure, function* () {
1144
- yield `WriteError(new global::System.Management.Automation.ErrorRecord(${ure.value}, ${ure.value}.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { ${operationParameters.filter(e => codegen_csharp_1.valueOf(e.expression) !== 'null').map(each => `${each.name}=${each.expression}`).join(',')}})
1145
- {
1146
- ErrorDetails = new global::System.Management.Automation.ErrorDetails(${ure.value}.Message) { RecommendedAction = ${ure.value}.Action }
1147
- });`;
1148
- });
1149
- yield codegen_csharp_1.Finally(function* () {
1150
- yield $this.eventListener.signalNoCheck(powershell_declarations_1.Events.CmdletProcessRecordAsyncEnd);
1151
- });
1152
- });
1403
+ $this.add(responseMethod);
1404
+ }
1153
1405
  }
1154
1406
  NewImplementSerialization(operation) {
1155
1407
  const $this = this;
@@ -1179,7 +1431,7 @@ class CmdletClass extends codegen_csharp_1.Class {
1179
1431
  //_parametersBody = this._parametersBody,
1180
1432
  //_resourceGroupName = this._resourceGroupName,
1181
1433
  //_subscriptionId = this._subscriptionId,
1182
- yield codegen_csharp_1.Return(i);
1434
+ yield (0, codegen_csharp_1.Return)(i);
1183
1435
  });
1184
1436
  }
1185
1437
  }
@@ -1194,7 +1446,7 @@ class CmdletClass extends codegen_csharp_1.Class {
1194
1446
  description: 'A dictionary to carry over additional data for pipeline.'
1195
1447
  }));
1196
1448
  const extensibleParametersProp = new codegen_csharp_1.Property('ExtensibleParameters', codegen_csharp_1.System.Collections.Generic.IDictionary(codegen_csharp_1.System.String, codegen_csharp_1.System.Object), { description: 'Accessor for extensibleParameters.' });
1197
- extensibleParametersProp.get = codegen_csharp_1.toExpression(`${extensibleParameters.value} `);
1449
+ extensibleParametersProp.get = (0, codegen_csharp_1.toExpression)(`${extensibleParameters.value} `);
1198
1450
  this.add(extensibleParametersProp);
1199
1451
  }
1200
1452
  implementIEventListener() {
@@ -1205,11 +1457,11 @@ class CmdletClass extends codegen_csharp_1.Class {
1205
1457
  description: `The <see cref="${codegen_csharp_1.System.Threading.CancellationTokenSource}" /> for this operation.`
1206
1458
  }));
1207
1459
  const cancellationTokenSource = new codegen_csharp_1.Property('CancellationTokenSource', codegen_csharp_1.System.Threading.CancellationTokenSource, { description: 'Accessor for cancellationTokenSource.' });
1208
- cancellationTokenSource.get = codegen_csharp_1.toExpression(`${cts.value} `);
1460
+ cancellationTokenSource.get = (0, codegen_csharp_1.toExpression)(`${cts.value} `);
1209
1461
  cancellationTokenSource.set = new codegen_csharp_1.Statements(cts.assign('value'));
1210
1462
  this.add(cancellationTokenSource);
1211
1463
  this.add(new codegen_csharp_1.LambdaProperty(`${exports_1.ClientRuntime.IEventListener}.Token`, codegen_csharp_1.System.Threading.CancellationToken, new codegen_csharp_1.LiteralExpression(`${cts.value}.Token`), { getAccess: codegen_csharp_1.Access.Default, setAccess: codegen_csharp_1.Access.Default, description: `<see cref="${exports_1.ClientRuntime}.IEventListener" /> cancellation token.` }));
1212
- this.cancellationToken = codegen_csharp_1.toExpression(`((${exports_1.ClientRuntime.IEventListener})this).Token`);
1464
+ this.cancellationToken = (0, codegen_csharp_1.toExpression)(`((${exports_1.ClientRuntime.IEventListener})this).Token`);
1213
1465
  this.add(new codegen_csharp_1.LambdaProperty(`${exports_1.ClientRuntime.IEventListener}.Cancel`, codegen_csharp_1.System.Action(), new codegen_csharp_1.LiteralExpression(`${cts.value}.Cancel`), { getAccess: codegen_csharp_1.Access.Default, setAccess: codegen_csharp_1.Access.Default, description: `<see cref="${exports_1.ClientRuntime}.IEventListener" /> cancellation delegate. Stops the cmdlet when called.` }));
1214
1466
  const id = new codegen_csharp_1.Parameter('id', codegen_csharp_1.dotnet.String, { description: 'The message id' });
1215
1467
  const token = new codegen_csharp_1.Parameter('token', codegen_csharp_1.System.Threading.CancellationToken, { description: 'The message cancellation token. When this call is cancelled, this should be <c>true</c>' });
@@ -1221,20 +1473,20 @@ class CmdletClass extends codegen_csharp_1.Class {
1221
1473
  description: 'Handles/Dispatches events during the call to the REST service.',
1222
1474
  returnsDescription: `A <see cref="${codegen_csharp_1.System.Threading.Tasks.Task()}" /> that will be complete when handling of the message is completed.`
1223
1475
  }));
1224
- signalMethod.push(codegen_csharp_1.Using('NoSynchronizationContext', ''));
1476
+ signalMethod.push((0, codegen_csharp_1.Using)('NoSynchronizationContext', ''));
1225
1477
  signalMethod.add(function* () {
1226
- yield codegen_csharp_1.If(`${token.value}.IsCancellationRequested`, codegen_csharp_1.Return());
1478
+ yield (0, codegen_csharp_1.If)(`${token.value}.IsCancellationRequested`, (0, codegen_csharp_1.Return)());
1227
1479
  // if the
1228
- const sw = codegen_csharp_1.Switch(id, [
1229
- codegen_csharp_1.TerminalCase(powershell_declarations_1.Events.Verbose.value, function* () {
1480
+ const sw = (0, codegen_csharp_1.Switch)(id, [
1481
+ (0, codegen_csharp_1.TerminalCase)(powershell_declarations_1.Events.Verbose.value, function* () {
1230
1482
  yield `WriteVerbose($"{(messageData().Message ?? ${codegen_csharp_1.System.String.Empty})}");`;
1231
- yield codegen_csharp_1.Return();
1483
+ yield (0, codegen_csharp_1.Return)();
1232
1484
  }),
1233
- codegen_csharp_1.TerminalCase(powershell_declarations_1.Events.Warning.value, function* () {
1485
+ (0, codegen_csharp_1.TerminalCase)(powershell_declarations_1.Events.Warning.value, function* () {
1234
1486
  yield `WriteWarning($"{(messageData().Message ?? ${codegen_csharp_1.System.String.Empty})}");`;
1235
- yield codegen_csharp_1.Return();
1487
+ yield (0, codegen_csharp_1.Return)();
1236
1488
  }),
1237
- codegen_csharp_1.TerminalCase(powershell_declarations_1.Events.Information.value, function* () {
1489
+ (0, codegen_csharp_1.TerminalCase)(powershell_declarations_1.Events.Information.value, function* () {
1238
1490
  if ($this.operation.asjob) {
1239
1491
  yield '// When an operation supports asjob, Information messages must go thru verbose.';
1240
1492
  yield `WriteVerbose($"INFORMATION: {(messageData().Message ?? ${codegen_csharp_1.System.String.Empty})}");`;
@@ -1244,17 +1496,17 @@ class CmdletClass extends codegen_csharp_1.Class {
1244
1496
  yield data.declarationStatement;
1245
1497
  yield 'WriteInformation(data.Message, new string[]{});';
1246
1498
  }
1247
- yield codegen_csharp_1.Return();
1499
+ yield (0, codegen_csharp_1.Return)();
1248
1500
  }),
1249
- codegen_csharp_1.TerminalCase(powershell_declarations_1.Events.Debug.value, function* () {
1501
+ (0, codegen_csharp_1.TerminalCase)(powershell_declarations_1.Events.Debug.value, function* () {
1250
1502
  yield `WriteDebug($"{(messageData().Message ?? ${codegen_csharp_1.System.String.Empty})}");`;
1251
- yield codegen_csharp_1.Return();
1503
+ yield (0, codegen_csharp_1.Return)();
1252
1504
  }),
1253
- codegen_csharp_1.TerminalCase(powershell_declarations_1.Events.Error.value, function* () {
1505
+ (0, codegen_csharp_1.TerminalCase)(powershell_declarations_1.Events.Error.value, function* () {
1254
1506
  yield 'WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) );';
1255
- yield codegen_csharp_1.Return();
1507
+ yield (0, codegen_csharp_1.Return)();
1256
1508
  }),
1257
- codegen_csharp_1.TerminalCase(powershell_declarations_1.Events.Progress.value, function* () {
1509
+ (0, codegen_csharp_1.TerminalCase)(powershell_declarations_1.Events.Progress.value, function* () {
1258
1510
  yield 'var data = messageData();';
1259
1511
  yield 'int progress = (int)data.Value;';
1260
1512
  yield 'string activityMessage, statusDescription;';
@@ -1277,14 +1529,14 @@ class CmdletClass extends codegen_csharp_1.Class {
1277
1529
  yield ' PercentComplete = progress,';
1278
1530
  yield 'RecordType = recordType';
1279
1531
  yield '});';
1280
- yield codegen_csharp_1.Return();
1532
+ yield (0, codegen_csharp_1.Return)();
1281
1533
  }),
1282
1534
  ]);
1283
1535
  if ($this.operation.asjob) {
1284
1536
  // if we support -AsJob, we support -NoWait
1285
- sw.add(codegen_csharp_1.Case(powershell_declarations_1.Events.DelayBeforePolling.value, function* () {
1537
+ sw.add((0, codegen_csharp_1.Case)(powershell_declarations_1.Events.DelayBeforePolling.value, function* () {
1286
1538
  yield 'var data = messageData();';
1287
- yield codegen_csharp_1.If('true == MyInvocation?.BoundParameters?.ContainsKey("NoWait")', function* () {
1539
+ yield (0, codegen_csharp_1.If)('true == MyInvocation?.BoundParameters?.ContainsKey("NoWait")', function* () {
1288
1540
  yield 'if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response)';
1289
1541
  yield '{';
1290
1542
  yield ' var asyncOperation = response.GetFirstHeader(@"Azure-AsyncOperation");';
@@ -1296,7 +1548,7 @@ class CmdletClass extends codegen_csharp_1.Class {
1296
1548
  yield ' return;';
1297
1549
  yield '}';
1298
1550
  });
1299
- yield codegen_csharp_1.Else(function* () {
1551
+ yield (0, codegen_csharp_1.Else)(function* () {
1300
1552
  yield 'if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response)';
1301
1553
  yield '{';
1302
1554
  yield ' int delay = (int)(response.Headers.RetryAfter?.Delta?.TotalSeconds ?? 30);';
@@ -1319,24 +1571,24 @@ class CmdletClass extends codegen_csharp_1.Class {
1319
1571
  if ($this.state.project.azure) {
1320
1572
  // in azure mode, we signal the AzAccount module with every event that makes it here.
1321
1573
  yield `await ${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.Signal(${id.value}, ${token.value}, ${messageData.value}, (i, t, m) => ((${exports_1.ClientRuntime.IEventListener})this).Signal(i, t, () => ${exports_1.ClientRuntime.EventDataConverter}.ConvertFrom(m()) as ${exports_1.ClientRuntime.EventData}), ${$this.invocationInfo.value}, this.ParameterSetName, ${$this.correlationId.value}, ${$this.processRecordId.value}, null );`;
1322
- yield codegen_csharp_1.If(`${token.value}.IsCancellationRequested`, codegen_csharp_1.Return());
1574
+ yield (0, codegen_csharp_1.If)(`${token.value}.IsCancellationRequested`, (0, codegen_csharp_1.Return)());
1323
1575
  }
1324
1576
  else {
1325
1577
  // In Non-Azure Modes, emit the Signal method without coorelation and processrecordid
1326
1578
  yield `await ${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.Signal(${id.value}, ${token.value}, ${messageData.value}, (i, t, m) => ((${exports_1.ClientRuntime.IEventListener})this).Signal(i, t, () => ${exports_1.ClientRuntime.EventDataConverter}.ConvertFrom(m()) as ${exports_1.ClientRuntime.EventData}), ${$this.invocationInfo.value}, this.ParameterSetName, null ); `;
1327
- yield codegen_csharp_1.If(`${token.value}.IsCancellationRequested`, codegen_csharp_1.Return());
1579
+ yield (0, codegen_csharp_1.If)(`${token.value}.IsCancellationRequested`, (0, codegen_csharp_1.Return)());
1328
1580
  }
1329
1581
  yield `WriteDebug($"{id}: {(messageData().Message ?? ${codegen_csharp_1.System.String.Empty})}");`;
1330
1582
  // any handling of the signal on our side...
1331
1583
  });
1332
1584
  }
1333
1585
  NewAddPowershellParameters(operation) {
1334
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
1586
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
1335
1587
  const vps = operation.details.csharp.virtualParameters || {
1336
1588
  body: [],
1337
1589
  operation: [],
1338
1590
  };
1339
- for (const parameter of linq_1.values(operation.parameters)) {
1591
+ for (const parameter of (0, linq_1.values)(operation.parameters)) {
1340
1592
  // these are the parameters that this command expects
1341
1593
  parameter.schema;
1342
1594
  const td = this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(parameter.schema, true, this.state);
@@ -1370,11 +1622,11 @@ class CmdletClass extends codegen_csharp_1.Class {
1370
1622
  *get() {
1371
1623
  const metadata = operation.extensions['x-ms-metadata'];
1372
1624
  const profiles = metadata.profiles || new linq_1.Dictionary();
1373
- yield codegen_csharp_1.Switch(`${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.Profile`, function* () {
1374
- for (const { key: profileName, value: apiVersion } of linq_1.items(profiles)) {
1375
- yield codegen_csharp_1.TerminalCase(`"${profileName}"`, codegen_csharp_1.Return(`"${apiVersion}"`));
1625
+ yield (0, codegen_csharp_1.Switch)(`${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.Profile`, function* () {
1626
+ for (const { key: profileName, value: apiVersion } of (0, linq_1.items)(profiles)) {
1627
+ yield (0, codegen_csharp_1.TerminalCase)(`"${profileName}"`, (0, codegen_csharp_1.Return)(`"${apiVersion}"`));
1376
1628
  }
1377
- yield codegen_csharp_1.TerminalDefaultCase(codegen_csharp_1.Return(`"${metadata.apiVersions[0]}"`));
1629
+ yield (0, codegen_csharp_1.TerminalDefaultCase)((0, codegen_csharp_1.Return)(`"${metadata.apiVersions[0]}"`));
1378
1630
  });
1379
1631
  }
1380
1632
  }));
@@ -1382,7 +1634,7 @@ class CmdletClass extends codegen_csharp_1.Class {
1382
1634
  }
1383
1635
  if (this.dropBodyParameter && parameter.details.csharp.isBodyParameter) {
1384
1636
  // we're supposed to use parameters for the body parameter instead of a big object
1385
- const expandedBodyParameter = this.add(new codegen_csharp_1.Field('_' + codegen_1.camelCase(parameter.details.csharp.name), td, {
1637
+ const expandedBodyParameter = this.add(new codegen_csharp_1.Field('_' + (0, codegen_1.camelCase)(parameter.details.csharp.name), td, {
1386
1638
  description: parameter.details.csharp.description,
1387
1639
  initialValue: (parameter.schema.type === codemodel_1.SchemaType.Array) ? codegen_csharp_1.dotnet.Null : `new ${(_a = parameter.schema.language.csharp) === null || _a === void 0 ? void 0 : _a.fullname}()`,
1388
1640
  access: codegen_csharp_1.Access.Private
@@ -1396,18 +1648,44 @@ class CmdletClass extends codegen_csharp_1.Class {
1396
1648
  const nullable = this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(vSchema, !!vParam.origin.required, this.state).isNullable;
1397
1649
  let cmdletParameter;
1398
1650
  if (propertyType.schema.type !== codemodel_1.SchemaType.Array) {
1651
+ if (vParam.name === 'IdentityType' && !this.disableTransformIdentityType &&
1652
+ (this.operation.commandType === command_operation_1.CommandType.ManagedIdentityNew || this.operation.commandType === command_operation_1.CommandType.ManagedIdentityUpdate)) {
1653
+ const enableSystemAssignedIdentity = new codegen_csharp_1.Property('EnableSystemAssignedIdentity', operation.details.csharp.verb.toLowerCase() === 'new' ? powershell_declarations_1.SwitchParameter : powershell_declarations_1.NullableBoolean, {
1654
+ set: operation.details.csharp.verb.toLowerCase() === 'new' ? (0, codegen_csharp_1.toExpression)(`${expandedBodyParameter.value}.${(0, model_class_1.getVirtualPropertyName)(vParam.origin) || vParam.origin.name} = value.IsPresent ? "SystemAssigned": null `) : undefined
1655
+ });
1656
+ enableSystemAssignedIdentity.description = 'Decides if enable a system assigned identity for the resource.';
1657
+ enableSystemAssignedIdentity.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ParameterAttribute, { parameters: [new codegen_csharp_1.LiteralExpression(`Mandatory = ${vParam.required && operation.details.csharp.verb.toLowerCase() !== 'new' ? 'true' : 'false'}`), new codegen_csharp_1.LiteralExpression(`HelpMessage = "${(0, codegen_1.escapeString)(enableSystemAssignedIdentity.description || '.')}"`)] }));
1658
+ if ((0, linq_1.length)(vParam.alias) > 0) {
1659
+ enableSystemAssignedIdentity.add(new codegen_csharp_1.Attribute(powershell_declarations_1.Alias, { parameters: vParam.alias.map(x => '"' + x + '"') }));
1660
+ }
1661
+ this.add(enableSystemAssignedIdentity);
1662
+ continue;
1663
+ }
1664
+ if (vParam.name === 'IdentityUserAssignedIdentity' || vParam.name === 'UserAssignedIdentity') {
1665
+ if (this.flattenUserAssignedIdentity && vParam.schema.type === 'dictionary') {
1666
+ const userAssignedIdentity = new codegen_csharp_1.Property('UserAssignedIdentity', codegen_csharp_1.dotnet.StringArray);
1667
+ userAssignedIdentity.description = 'The array of user assigned identities associated with the resource. The elements in array will be ARM resource ids in the form: \'/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}.\'';
1668
+ userAssignedIdentity.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ParameterAttribute, { parameters: [new codegen_csharp_1.LiteralExpression(`Mandatory = ${vParam.required ? 'true' : 'false'}`), new codegen_csharp_1.LiteralExpression(`HelpMessage = "${(0, codegen_1.escapeString)(userAssignedIdentity.description || '.')}"`)] }));
1669
+ userAssignedIdentity.add(new codegen_csharp_1.Attribute(powershell_declarations_1.AllowEmptyCollectionAttribute));
1670
+ if ((0, linq_1.length)(vParam.alias) > 0) {
1671
+ userAssignedIdentity.add(new codegen_csharp_1.Attribute(powershell_declarations_1.Alias, { parameters: vParam.alias.map(x => '"' + x + '"') }));
1672
+ }
1673
+ this.add(userAssignedIdentity);
1674
+ continue;
1675
+ }
1676
+ }
1399
1677
  cmdletParameter = new codegen_csharp_1.Property(vParam.name, propertyType, {
1400
- get: codegen_csharp_1.toExpression(`${expandedBodyParameter.value}.${model_class_1.getVirtualPropertyName(vParam.origin) || vParam.origin.name}${!nullable ? '' : ` ?? ${propertyType.defaultOfType}`}`),
1678
+ get: (0, codegen_csharp_1.toExpression)(`${expandedBodyParameter.value}.${(0, model_class_1.getVirtualPropertyName)(vParam.origin) || vParam.origin.name}${!nullable ? '' : ` ?? ${propertyType.defaultOfType}`}`),
1401
1679
  // get: toExpression(`null == ${expandedBodyParameter.value}.${vParam.origin.name} ? ${propertyType.defaultOfType} : (${propertyType.declaration}) ${expandedBodyParameter.value}.${vParam.origin.name}`),
1402
- set: codegen_csharp_1.toExpression(`${expandedBodyParameter.value}.${model_class_1.getVirtualPropertyName(vParam.origin) || vParam.origin.name} = value`),
1680
+ set: (0, codegen_csharp_1.toExpression)(`${expandedBodyParameter.value}.${(0, model_class_1.getVirtualPropertyName)(vParam.origin) || vParam.origin.name} = value`),
1403
1681
  new: PropertiesRequiringNew.has(vParam.name) ? codegen_csharp_1.Modifier.New : codegen_csharp_1.Modifier.None
1404
1682
  });
1405
1683
  }
1406
1684
  else {
1407
1685
  const fixedArrayPropertyType = this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(vSchema, true, this.state, true);
1408
1686
  cmdletParameter = new codegen_csharp_1.Property(vParam.name, fixedArrayPropertyType, {
1409
- get: codegen_csharp_1.toExpression(`${expandedBodyParameter.value}.${model_class_1.getVirtualPropertyName(vParam.origin) || vParam.origin.name}?.ToArray()${` ?? ${fixedArrayPropertyType.defaultOfType}`}`),
1410
- set: codegen_csharp_1.toExpression(`${expandedBodyParameter.value}.${model_class_1.getVirtualPropertyName(vParam.origin) || vParam.origin.name} = (value != null ? new ${propertyType.declaration}(value) : null)`),
1687
+ get: (0, codegen_csharp_1.toExpression)(`${expandedBodyParameter.value}.${(0, model_class_1.getVirtualPropertyName)(vParam.origin) || vParam.origin.name}?.ToArray()${` ?? ${fixedArrayPropertyType.defaultOfType}`}`),
1688
+ set: (0, codegen_csharp_1.toExpression)(`${expandedBodyParameter.value}.${(0, model_class_1.getVirtualPropertyName)(vParam.origin) || vParam.origin.name} = (value != null ? new ${propertyType.declaration}(value) : null)`),
1411
1689
  new: PropertiesRequiringNew.has(vParam.name) ? codegen_csharp_1.Modifier.New : codegen_csharp_1.Modifier.None
1412
1690
  });
1413
1691
  }
@@ -1430,7 +1708,7 @@ class CmdletClass extends codegen_csharp_1.Class {
1430
1708
  // we have to figure out if this is a standalone dictionary or a hybrid object/dictionary.
1431
1709
  // if it's a hybrid, we have to create another parameter like -<XXX>AdditionalProperties and have that dump the contents into the dictionary
1432
1710
  // if it's a standalone dictionary, we can just use hashtable instead
1433
- if (linq_1.length(vSchema.properties) === 0) {
1711
+ if ((0, linq_1.length)(vSchema.properties) === 0) {
1434
1712
  // it's a pure dictionary
1435
1713
  // add an attribute for changing the exported type.
1436
1714
  cmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ExportAsAttribute, { parameters: [`typeof(${codegen_csharp_1.System.Collections.Hashtable})`] }));
@@ -1447,49 +1725,49 @@ class CmdletClass extends codegen_csharp_1.Class {
1447
1725
  cmdletParameter.setAccess = codegen_csharp_1.Access.Internal;
1448
1726
  cmdletParameter.getAccess = codegen_csharp_1.Access.Internal;
1449
1727
  // create a InputFileXXX for the parameter
1450
- const ifname = vParam.name.toLowerCase() === 'value' ? 'InputFile' : codegen_1.pascalCase([vParam.name, 'Input', 'File']);
1728
+ const ifname = vParam.name.toLowerCase() === 'value' ? 'InputFile' : (0, codegen_1.pascalCase)([vParam.name, 'Input', 'File']);
1451
1729
  const inputFileParameter = new codegen_csharp_1.Property(ifname, codegen_csharp_1.dotnet.String, {
1452
1730
  // get: toExpression(`${expandedBodyParameter.value}.${vParam.origin.name}${vParam.required ? '' : ` ?? ${propertyType.defaultOfType}`}`),
1453
1731
  set: function* () {
1454
- const provider = codegen_csharp_2.Local('provider');
1732
+ const provider = (0, codegen_csharp_2.Local)('provider');
1455
1733
  provider.initializer = undefined;
1456
- const paths = codegen_csharp_2.Local('paths', `this.SessionState.Path.GetResolvedProviderPathFromPSPath(value, out ${provider.declarationExpression})`);
1734
+ const paths = (0, codegen_csharp_2.Local)('paths', `this.SessionState.Path.GetResolvedProviderPathFromPSPath(value, out ${provider.declarationExpression})`);
1457
1735
  yield paths.declarationStatement;
1458
- yield codegen_csharp_1.If(`${provider.value}.Name != "FileSystem" || ${paths.value}.Count == 0`, 'ThrowTerminatingError( new System.Management.Automation.ErrorRecord(new global::System.Exception("Invalid input path."),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, value) );');
1459
- yield codegen_csharp_1.If(`${paths.value}.Count > 1`, 'ThrowTerminatingError( new System.Management.Automation.ErrorRecord(new global::System.Exception("Multiple input paths not allowed."),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, value) );');
1736
+ yield (0, codegen_csharp_1.If)(`${provider.value}.Name != "FileSystem" || ${paths.value}.Count == 0`, 'ThrowTerminatingError( new System.Management.Automation.ErrorRecord(new global::System.Exception("Invalid input path."),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, value) );');
1737
+ yield (0, codegen_csharp_1.If)(`${paths.value}.Count > 1`, 'ThrowTerminatingError( new System.Management.Automation.ErrorRecord(new global::System.Exception("Multiple input paths not allowed."),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, value) );');
1460
1738
  yield cmdletParameter.assign(`global::System.IO.File.ReadAllBytes(${paths.value}[0])`);
1461
1739
  },
1462
- description: `Input File for ${cmdletParameter.name} (${codegen_1.escapeString(desc)})`
1740
+ description: `Input File for ${cmdletParameter.name} (${(0, codegen_1.escapeString)(desc)})`
1463
1741
  });
1464
- inputFileParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ParameterAttribute, { parameters: [new codegen_csharp_1.LiteralExpression(`Mandatory = ${vParam.required ? 'true' : 'false'}`), new codegen_csharp_1.LiteralExpression(`HelpMessage = "Input File for ${cmdletParameter.name} (${codegen_1.escapeString(desc || '.')})"`)] }));
1742
+ inputFileParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ParameterAttribute, { parameters: [new codegen_csharp_1.LiteralExpression(`Mandatory = ${vParam.required ? 'true' : 'false'}`), new codegen_csharp_1.LiteralExpression(`HelpMessage = "Input File for ${cmdletParameter.name} (${(0, codegen_1.escapeString)(desc || '.')})"`)] }));
1465
1743
  inputFileParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CategoryAttribute, { parameters: [`${powershell_declarations_1.ParameterCategory}.Body`] }));
1466
- if (linq_1.length(vParam.alias) > 0) {
1744
+ if ((0, linq_1.length)(vParam.alias) > 0) {
1467
1745
  inputFileParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.Alias, { parameters: vParam.alias.map(x => '"' + x + '"') }));
1468
1746
  }
1469
1747
  $this.add(inputFileParameter);
1470
1748
  }
1471
1749
  else {
1472
- cmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ParameterAttribute, { parameters: [new codegen_csharp_1.LiteralExpression(`Mandatory = ${vParam.required ? 'true' : 'false'}`), new codegen_csharp_1.LiteralExpression(`HelpMessage = "${codegen_1.escapeString(desc || '.')}"`)] }));
1750
+ cmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ParameterAttribute, { parameters: [new codegen_csharp_1.LiteralExpression(`Mandatory = ${vParam.required ? 'true' : 'false'}`), new codegen_csharp_1.LiteralExpression(`HelpMessage = "${(0, codegen_1.escapeString)(desc || '.')}"`)] }));
1473
1751
  cmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CategoryAttribute, { parameters: [`${powershell_declarations_1.ParameterCategory}.Body`] }));
1474
1752
  NewAddInfoAttribute(cmdletParameter, propertyType, !!vParam.required, false, desc, vParam.origin.property.serializedName);
1475
1753
  NewAddCompleterInfo(cmdletParameter, vParam);
1476
1754
  addParameterBreakingChange(cmdletParameter, vParam);
1477
- addPreviewMessage(cmdletParameter, vParam);
1755
+ addParameterPreviewMessage(cmdletParameter, vParam);
1478
1756
  addDefaultInfo(cmdletParameter, vParam);
1479
1757
  this.addDoNotExport(cmdletParameter, vParam);
1480
1758
  }
1481
- const addArgumentCompleter = isEnumImplementation(vParam.schema) || propertyType instanceof exports_1.ArrayOf && isEnumImplementation(propertyType.elementType.schema);
1759
+ const addArgumentCompleter = isEnumImplementation(vParam.schema) || propertyType instanceof exports_1.ArrayOf && isEnumImplementation(propertyType.schema.elementType);
1482
1760
  if (addArgumentCompleter) {
1483
- addPSArgumentCompleterAttribute(cmdletParameter, vParam.schema);
1761
+ propertyType instanceof exports_1.ArrayOf ? addPSArgumentCompleterAttribute(cmdletParameter, (_e = propertyType === null || propertyType === void 0 ? void 0 : propertyType.schema) === null || _e === void 0 ? void 0 : _e.elementType) : addPSArgumentCompleterAttribute(cmdletParameter, vParam.schema);
1484
1762
  }
1485
1763
  // add aliases if there is any
1486
- if (linq_1.length(vParam.alias) > 0) {
1764
+ if ((0, linq_1.length)(vParam.alias) > 0) {
1487
1765
  cmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.Alias, { parameters: vParam.alias.map(x => '"' + x + '"') }));
1488
1766
  }
1489
1767
  this.add(cmdletParameter);
1490
1768
  }
1491
1769
  const paramDictSchema = parameter.schema.type === codemodel_1.SchemaType.Dictionary ? parameter.schema :
1492
- parameter.schema.type === codemodel_1.SchemaType.Object ? (_f = (_e = parameter.schema.parents) === null || _e === void 0 ? void 0 : _e.immediate) === null || _f === void 0 ? void 0 : _f.find((s) => s.type === codemodel_1.SchemaType.Dictionary) :
1770
+ parameter.schema.type === codemodel_1.SchemaType.Object ? (_g = (_f = parameter.schema.parents) === null || _f === void 0 ? void 0 : _f.immediate) === null || _g === void 0 ? void 0 : _g.find((s) => s.type === codemodel_1.SchemaType.Dictionary) :
1493
1771
  undefined;
1494
1772
  if (paramDictSchema) {
1495
1773
  // if there is an additional properties on this type
@@ -1509,7 +1787,7 @@ class CmdletClass extends codegen_csharp_1.Class {
1509
1787
  }));
1510
1788
  this.bodyParameterInfo = {
1511
1789
  type: {
1512
- declaration: (_g = parameter.schema.language.csharp) === null || _g === void 0 ? void 0 : _g.fullname
1790
+ declaration: (_h = parameter.schema.language.csharp) === null || _h === void 0 ? void 0 : _h.fullname
1513
1791
  },
1514
1792
  valueType: paramDictSchema.elementType.type === codemodel_1.SchemaType.Any ? codegen_csharp_1.System.Object :
1515
1793
  this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(paramDictSchema.elementType, true, this.state)
@@ -1523,7 +1801,7 @@ class CmdletClass extends codegen_csharp_1.Class {
1523
1801
  const viaIdentityRegex = /ViaIdentity\d?/g;
1524
1802
  this.inputObjectParameterName = `${this.name.split(viaIdentityRegex)[1].split('Expanded')[0]}InputObject`;
1525
1803
  // add in the pipeline parameter for the identity
1526
- const idschema = linq_1.values(this.state.project.model.schemas.objects).first(each => each.language.default.uid === 'universal-parameter-type');
1804
+ const idschema = (0, linq_1.values)(this.state.project.model.schemas.objects).first(each => each.language.default.uid === 'universal-parameter-type');
1527
1805
  const idtd = this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(idschema, true, this.state);
1528
1806
  const idParam = this.add(new codegen_csharp_1.BackedProperty(this.inputObjectParameterName, idtd, {
1529
1807
  description: 'Identity Parameter'
@@ -1532,7 +1810,7 @@ class CmdletClass extends codegen_csharp_1.Class {
1532
1810
  idParam.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ParameterAttribute, { parameters }));
1533
1811
  idParam.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CategoryAttribute, { parameters: [`${powershell_declarations_1.ParameterCategory}.Path`] }));
1534
1812
  }
1535
- for (const vParam of linq_1.values(vps.operation)) {
1813
+ for (const vParam of (0, linq_1.values)(vps.operation)) {
1536
1814
  if (vParam.name === 'Host') {
1537
1815
  // skip 'Host'
1538
1816
  continue;
@@ -1566,13 +1844,13 @@ class CmdletClass extends codegen_csharp_1.Class {
1566
1844
  description: vParam.description
1567
1845
  }));
1568
1846
  const dictSchema = vSchema.type === codemodel_1.SchemaType.Dictionary ? vSchema :
1569
- vSchema.type === codemodel_1.SchemaType.Object ? (_j = (_h = vSchema.parents) === null || _h === void 0 ? void 0 : _h.immediate) === null || _j === void 0 ? void 0 : _j.find((s) => s.type === codemodel_1.SchemaType.Dictionary) :
1847
+ vSchema.type === codemodel_1.SchemaType.Object ? (_k = (_j = vSchema.parents) === null || _j === void 0 ? void 0 : _j.immediate) === null || _k === void 0 ? void 0 : _k.find((s) => s.type === codemodel_1.SchemaType.Dictionary) :
1570
1848
  undefined;
1571
1849
  if (dictSchema) {
1572
1850
  // we have to figure out if this is a standalone dictionary or a hybrid object/dictionary.
1573
1851
  // if it's a hybrid, we have to create another parameter like -<XXX>AdditionalProperties and have that dump the contents into the dictionary
1574
1852
  // if it's a standalone dictionary, we can just use hashtable instead
1575
- if (linq_1.length(vSchema.properties) === 0) {
1853
+ if ((0, linq_1.length)(vSchema.properties) === 0) {
1576
1854
  // it's a pure dictionary
1577
1855
  // change the property type to hashtable.
1578
1856
  // add an attribute to change the exported type.
@@ -1584,7 +1862,7 @@ class CmdletClass extends codegen_csharp_1.Class {
1584
1862
  }
1585
1863
  }
1586
1864
  this.thingsToSerialize.push(regularCmdletParameter);
1587
- const parameters = [new codegen_csharp_1.LiteralExpression(`Mandatory = ${vParam.required ? 'true' : 'false'}`), new codegen_csharp_1.LiteralExpression(`HelpMessage = "${codegen_1.escapeString(vParam.description) || '.'}"`)];
1865
+ const parameters = [new codegen_csharp_1.LiteralExpression(`Mandatory = ${vParam.required ? 'true' : 'false'}`), new codegen_csharp_1.LiteralExpression(`HelpMessage = "${(0, codegen_1.escapeString)(vParam.description) || '.'}"`)];
1588
1866
  if (!!origin && origin.details.csharp.isBodyParameter) {
1589
1867
  parameters.push(new codegen_csharp_1.LiteralExpression('ValueFromPipeline = true'));
1590
1868
  this.bodyParameter = regularCmdletParameter;
@@ -1594,24 +1872,24 @@ class CmdletClass extends codegen_csharp_1.Class {
1594
1872
  regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.AllowEmptyCollectionAttribute));
1595
1873
  }
1596
1874
  if (!!origin && !!propertyType) {
1597
- NewAddInfoAttribute(regularCmdletParameter, propertyType, (_k = vParam.required) !== null && _k !== void 0 ? _k : false, false, vParam.description, origin.name);
1875
+ NewAddInfoAttribute(regularCmdletParameter, propertyType, (_l = vParam.required) !== null && _l !== void 0 ? _l : false, false, vParam.description, origin.name);
1598
1876
  }
1599
1877
  NewAddCompleterInfo(regularCmdletParameter, vParam);
1600
1878
  addParameterBreakingChange(regularCmdletParameter, vParam);
1601
- addPreviewMessage(regularCmdletParameter, vParam);
1879
+ addParameterPreviewMessage(regularCmdletParameter, vParam);
1602
1880
  addDefaultInfo(regularCmdletParameter, vParam);
1603
1881
  this.addDoNotExport(regularCmdletParameter, vParam);
1604
1882
  // add aliases if there is any
1605
- if (linq_1.length(vParam.alias) > 0) {
1883
+ if ((0, linq_1.length)(vParam.alias) > 0) {
1606
1884
  regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.Alias, { parameters: vParam.alias.map(x => '"' + x + '"') }));
1607
1885
  }
1608
1886
  const httpParam = origin ? origin.details.csharp.httpParameter : null;
1609
1887
  //const uid = httpParam ? httpParam.details.csharp.uid : 'no-parameter';
1610
1888
  if (httpParam) {
1611
1889
  // xichen: Is it safe to compare by csharp serializedName? Because we no longer have uid
1612
- const cat = (_l = operation.callGraph[0].parameters) === null || _l === void 0 ? void 0 : _l.find((param) => { var _a, _b, _c; return !((_a = param.language.csharp) === null || _a === void 0 ? void 0 : _a.constantValue) && ((_b = param.language.csharp) === null || _b === void 0 ? void 0 : _b.serializedName) === ((_c = httpParam.language.csharp) === null || _c === void 0 ? void 0 : _c.serializedName); });
1890
+ const cat = (_m = this.apiCall.parameters) === null || _m === void 0 ? void 0 : _m.find((param) => { var _a, _b, _c; return !((_a = param.language.csharp) === null || _a === void 0 ? void 0 : _a.constantValue) && ((_b = param.language.csharp) === null || _b === void 0 ? void 0 : _b.serializedName) === ((_c = httpParam.language.csharp) === null || _c === void 0 ? void 0 : _c.serializedName); });
1613
1891
  if (cat) {
1614
- regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CategoryAttribute, { parameters: [`${powershell_declarations_1.ParameterCategory}.${codegen_1.pascalCase(((_m = cat.protocol.http) === null || _m === void 0 ? void 0 : _m.in))}`] }));
1892
+ regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CategoryAttribute, { parameters: [`${powershell_declarations_1.ParameterCategory}.${(0, codegen_1.pascalCase)(((_o = cat.protocol.http) === null || _o === void 0 ? void 0 : _o.in))}`] }));
1615
1893
  }
1616
1894
  }
1617
1895
  else {
@@ -1622,9 +1900,9 @@ class CmdletClass extends codegen_csharp_1.Class {
1622
1900
  }));
1623
1901
  }
1624
1902
  }
1625
- const addArgumentCompleter = isEnumImplementation(vParam.schema) || propertyType instanceof exports_1.ArrayOf && isEnumImplementation(propertyType.elementType.schema);
1903
+ const addArgumentCompleter = isEnumImplementation(vParam.schema) || propertyType instanceof exports_1.ArrayOf && isEnumImplementation(propertyType.schema.elementType);
1626
1904
  if (addArgumentCompleter) {
1627
- addPSArgumentCompleterAttribute(regularCmdletParameter, vParam.schema);
1905
+ propertyType instanceof exports_1.ArrayOf ? addPSArgumentCompleterAttribute(regularCmdletParameter, (_p = propertyType === null || propertyType === void 0 ? void 0 : propertyType.schema) === null || _p === void 0 ? void 0 : _p.elementType) : addPSArgumentCompleterAttribute(regularCmdletParameter, vParam.schema);
1628
1906
  }
1629
1907
  }
1630
1908
  const ifmatch = this.properties.find((v) => v.name.toLowerCase() === 'ifmatch');
@@ -1641,19 +1919,19 @@ class CmdletClass extends codegen_csharp_1.Class {
1641
1919
  addDoNotExport(cmdletParameter, vParam) {
1642
1920
  if (vParam.hidden) {
1643
1921
  this.state.message({
1644
- Channel: autorest_extension_base_1.Channel.Debug,
1922
+ Channel: extension_base_1.Channel.Debug,
1645
1923
  Text: `[DIRECTIVE] Applied 'hide' directive to parameter ${cmdletParameter.name}. Added attribute ${powershell_declarations_1.DoNotExportAttribute.declaration} to parameter.`,
1646
1924
  });
1647
1925
  cmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.DoNotExportAttribute));
1648
1926
  }
1649
1927
  }
1650
1928
  NewAddClassAttributes(operation, variantName) {
1651
- var _a, _b, _c, _d, _e, _f, _g, _h;
1929
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
1652
1930
  const cmdletAttribParams = [
1653
- category[operation.details.csharp.verb] ? powershell_declarations_1.verbEnum(category[operation.details.csharp.verb], operation.details.csharp.verb) : `"${operation.details.csharp.verb}"`,
1931
+ category[operation.details.csharp.verb] ? (0, powershell_declarations_1.verbEnum)(category[operation.details.csharp.verb], operation.details.csharp.verb) : `"${operation.details.csharp.verb}"`,
1654
1932
  new codegen_csharp_1.StringExpression(variantName)
1655
1933
  ];
1656
- if (this.NewIsWritableCmdlet(operation)) {
1934
+ if ((0, command_operation_1.isWritableCmdlet)(operation) && !operation.details.csharp.supportShouldProcess) {
1657
1935
  cmdletAttribParams.push('SupportsShouldProcess = true');
1658
1936
  }
1659
1937
  if (this.clientsidePagination) {
@@ -1663,21 +1941,21 @@ class CmdletClass extends codegen_csharp_1.Class {
1663
1941
  this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.InternalExportAttribute));
1664
1942
  const noun = `${operation.details.csharp.subjectPrefix}${operation.details.csharp.subject}`;
1665
1943
  const cmdletName = `${operation.details.csharp.verb}-${noun}${operation.details.csharp.name ? `_${operation.details.csharp.name}` : ''}`;
1666
- this.state.message({ Channel: autorest_extension_base_1.Channel.Debug, Text: `[DIRECTIVE] Applied 'hide' directive to ${cmdletName}. Added attribute ${powershell_declarations_1.InternalExportAttribute.declaration} to cmdlet.` });
1944
+ this.state.message({ Channel: extension_base_1.Channel.Debug, Text: `[DIRECTIVE] Applied 'hide' directive to ${cmdletName}. Added attribute ${powershell_declarations_1.InternalExportAttribute.declaration} to cmdlet.` });
1667
1945
  }
1668
1946
  this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CmdletAttribute, { parameters: cmdletAttribParams }));
1669
1947
  // add alias attribute if there is any aliases for this cmdlet
1670
- if (linq_1.length(operation.details.csharp.alias) > 0) {
1948
+ if ((0, linq_1.length)(operation.details.csharp.alias) > 0) {
1671
1949
  this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.Alias, { parameters: operation.details.csharp.alias.map((x) => '"' + x + '"') }));
1672
1950
  }
1673
1951
  let shouldAddPassThru = false;
1674
1952
  // set to hold the output types
1675
1953
  const outputTypes = new Set();
1676
- for (const httpOperation of linq_1.values(operation.callGraph)) {
1954
+ for (const httpOperation of (0, linq_1.values)(operation.callGraph)) {
1677
1955
  const pageableInfo = (_a = httpOperation.language.csharp) === null || _a === void 0 ? void 0 : _a.pageable;
1678
1956
  const v = httpOperation.responses && httpOperation.responses.length > 0 && httpOperation.responses[0] instanceof codemodel_1.SchemaResponse;
1679
1957
  // Add this for binary response in m4
1680
- for (const binary of linq_1.values(httpOperation.responses).selectNonNullable(each => each.binary)) {
1958
+ for (const binary of (0, linq_1.values)(httpOperation.responses).selectNonNullable(each => each.binary)) {
1681
1959
  if (binary) {
1682
1960
  // if this is a stream, skip the output type.
1683
1961
  this.hasStreamOutput = true;
@@ -1685,10 +1963,10 @@ class CmdletClass extends codegen_csharp_1.Class {
1685
1963
  outputTypes.add(`typeof(${codegen_csharp_1.dotnet.Bool})`);
1686
1964
  }
1687
1965
  }
1688
- for (const schema of linq_1.values(httpOperation.responses).selectNonNullable(each => each.schema)) {
1689
- const props = schema_1.getAllProperties(schema);
1966
+ for (const schema of (0, linq_1.values)(httpOperation.responses).selectNonNullable(each => each.schema)) {
1967
+ const props = (0, schema_1.getAllProperties)(schema);
1690
1968
  // does the target type just wrap a single output?
1691
- const resultSchema = linq_1.length(props) !== 1 ? schema : props[0].schema;
1969
+ const resultSchema = schema;
1692
1970
  // make sure return type for boolean stays boolean!
1693
1971
  if (resultSchema.type === codemodel_1.SchemaType.Boolean ||
1694
1972
  (resultSchema.type === codemodel_1.SchemaType.Choice && resultSchema.choiceType.type === codemodel_1.SchemaType.Boolean && resultSchema.choices.length === 1) ||
@@ -1709,12 +1987,14 @@ class CmdletClass extends codegen_csharp_1.Class {
1709
1987
  type = typeDeclaration.elementTypeDeclaration;
1710
1988
  }
1711
1989
  else if (pageableInfo && pageableInfo.responseType === 'pageable') {
1712
- if (typeDeclaration === undefined || ((_b = typeDeclaration.schema.properties) === null || _b === void 0 ? void 0 : _b.find(p => p.serializedName === pageableInfo.itemName)) === undefined) {
1990
+ if (typeDeclaration === undefined || (((_b = typeDeclaration.schema.properties) === null || _b === void 0 ? void 0 : _b.find(p => p.serializedName === pageableInfo.itemName)) === undefined
1991
+ && ((_c = typeDeclaration.schema.parents) === null || _c === void 0 ? void 0 : _c.all.find(s => { var _a; return (0, codemodel_1.isObjectSchema)(s) && ((_a = s.properties) === null || _a === void 0 ? void 0 : _a.find((p => p.serializedName === pageableInfo.itemName))) === undefined; })))) {
1713
1992
  //skip-for-time-being, since operationId does not support in m4 any more
1714
1993
  //throw new Error(`\n\nOn operation:\n '${httpOperation.operationId}' at '${httpOperation.path}'\n -- you have used 'x-ms-pageable' and there is no property name '${pageableInfo.itemName}' that is an array.\n\n`);
1715
1994
  throw new Error('An error needs to be more specific');
1716
1995
  }
1717
- const nestedSchema = (_d = (_c = typeDeclaration.schema.properties) === null || _c === void 0 ? void 0 : _c.find(p => p.serializedName === pageableInfo.itemName)) === null || _d === void 0 ? void 0 : _d.schema;
1996
+ const nestedSchema = (_g = (((_d = typeDeclaration.schema.properties) === null || _d === void 0 ? void 0 : _d.find(p => p.serializedName === pageableInfo.itemName))
1997
+ || ((_f = ((_e = typeDeclaration.schema.parents) === null || _e === void 0 ? void 0 : _e.all.find(s => { var _a; return (0, codemodel_1.isObjectSchema)(s) && ((_a = s.properties) === null || _a === void 0 ? void 0 : _a.find((p => p.serializedName === pageableInfo.itemName))); })).properties) === null || _f === void 0 ? void 0 : _f.find((p => p.serializedName === pageableInfo.itemName))))) === null || _g === void 0 ? void 0 : _g.schema;
1718
1998
  const nestedTypeDeclaration = this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(nestedSchema, true, this.state);
1719
1999
  type = nestedTypeDeclaration.elementTypeDeclaration;
1720
2000
  }
@@ -1731,8 +2011,8 @@ class CmdletClass extends codegen_csharp_1.Class {
1731
2011
  }
1732
2012
  // if any response does not return,
1733
2013
  // the cmdlet should have a PassThru parameter
1734
- shouldAddPassThru = shouldAddPassThru || linq_1.values(operation.callGraph)
1735
- .selectMany(httpOperation => linq_1.values((httpOperation.responses || []).concat(httpOperation.exceptions || [])))
2014
+ shouldAddPassThru = shouldAddPassThru || (0, linq_1.values)(operation.callGraph)
2015
+ .selectMany(httpOperation => (0, linq_1.values)((httpOperation.responses || []).concat(httpOperation.exceptions || [])))
1736
2016
  //.selectMany(responsesItem => responsesItem.value)
1737
2017
  .any(value => value.schema === undefined);
1738
2018
  if (outputTypes.size === 0) {
@@ -1743,11 +2023,13 @@ class CmdletClass extends codegen_csharp_1.Class {
1743
2023
  const breakingChange = operation.details.csharp.breakingChange;
1744
2024
  if (breakingChange.cmdlet) {
1745
2025
  const parameters = [];
1746
- if (breakingChange.cmdlet.deprecateByVersion) {
1747
- parameters.push(`"${breakingChange.cmdlet.deprecateByVersion}"`);
1748
- if (breakingChange.cmdlet.changeInEfectByDate)
1749
- parameters.push(`"${breakingChange.cmdlet.changeInEfectByDate}"`);
2026
+ if (!breakingChange.cmdlet.deprecateByVersion || !breakingChange.cmdlet.deprecateByAzVersion) {
2027
+ throw new Error('Cmdlet breaking change requires both \'deprecateByVersion\' and \'deprecateByAzVersion\', please refer to https://github.com/Azure/azure-powershell/blob/main/documentation/development-docs/breakingchange-for-autogen-module.md for more details.');
1750
2028
  }
2029
+ parameters.push(`"${breakingChange.cmdlet.deprecateByAzVersion}"`);
2030
+ parameters.push(`"${breakingChange.cmdlet.deprecateByVersion}"`);
2031
+ if (breakingChange.cmdlet.changeInEfectByDate)
2032
+ parameters.push(`"${breakingChange.cmdlet.changeInEfectByDate}"`);
1751
2033
  if (breakingChange.cmdlet.replacement)
1752
2034
  parameters.push(`ReplacementCmdletName = "${breakingChange.cmdlet.replacement}"`);
1753
2035
  if (breakingChange.cmdlet.changeDescription)
@@ -1757,11 +2039,13 @@ class CmdletClass extends codegen_csharp_1.Class {
1757
2039
  if (breakingChange.variant) {
1758
2040
  const parameters = [];
1759
2041
  parameters.push(`new string[] {"${breakingChange.variant.name}"}`);
1760
- if (breakingChange.variant.deprecateByVersion) {
1761
- parameters.push(`"${breakingChange.variant.deprecateByVersion}"`);
1762
- if (breakingChange.variant.changeInEfectByDate)
1763
- parameters.push(`"${breakingChange.variant.changeInEfectByDate}"`);
2042
+ if (!breakingChange.variant.deprecateByVersion || !breakingChange.variant.deprecateByAzVersion) {
2043
+ throw new Error('Cmdlet breaking change requires both \'deprecateByVersion\' and \'deprecateByAzVersion\', please refer to https://github.com/Azure/azure-powershell/blob/main/documentation/development-docs/breakingchange-for-autogen-module.md for more details.');
1764
2044
  }
2045
+ parameters.push(`"${breakingChange.variant.deprecateByAzVersion}"`);
2046
+ parameters.push(`"${breakingChange.variant.deprecateByVersion}"`);
2047
+ if (breakingChange.variant.changeInEfectByDate)
2048
+ parameters.push(`"${breakingChange.variant.changeInEfectByDate}"`);
1765
2049
  if (breakingChange.variant.changeDescription)
1766
2050
  parameters.push(`ChangeDescription = "${breakingChange.variant.changeDescription}"`);
1767
2051
  this.add(new codegen_csharp_1.Attribute(exports_1.ClientRuntime.ParameterSetBreakingChangeAttribute, { parameters: parameters }));
@@ -1775,11 +2059,13 @@ class CmdletClass extends codegen_csharp_1.Class {
1775
2059
  else {
1776
2060
  parameters.push(`"${outputTypes.values().next().value.replace(/typeof\((.*)\)/, '$1')}"`);
1777
2061
  }
1778
- if (breakingChange.output.deprecateByVersion) {
1779
- parameters.push(`"${breakingChange.output.deprecateByVersion}"`);
1780
- if (breakingChange.output.changeInEfectByDate)
1781
- parameters.push(`"${breakingChange.output.changeInEfectByDate}"`);
2062
+ if (!breakingChange.output.deprecateByVersion || !breakingChange.output.deprecateByAzVersion) {
2063
+ throw new Error('Cmdlet breaking change requires both \'deprecateByVersion\' and \'deprecateByAzVersion\', please refer to https://github.com/Azure/azure-powershell/blob/main/documentation/development-docs/breakingchange-for-autogen-module.md for more details.');
1782
2064
  }
2065
+ parameters.push(`"${breakingChange.output.deprecateByAzVersion}"`);
2066
+ parameters.push(`"${breakingChange.output.deprecateByVersion}"`);
2067
+ if (breakingChange.output.changeInEfectByDate)
2068
+ parameters.push(`"${breakingChange.output.changeInEfectByDate}"`);
1783
2069
  if (breakingChange.output.replacement)
1784
2070
  parameters.push(`ReplacementCmdletOutputType = "${breakingChange.output.replacement}"`);
1785
2071
  if (breakingChange.output.deprecatedOutputProperties) {
@@ -1798,8 +2084,12 @@ class CmdletClass extends codegen_csharp_1.Class {
1798
2084
  }
1799
2085
  }
1800
2086
  //add preview message attribute for cmdlet
1801
- if (operation.details.csharp.previewMessage) {
1802
- this.add(new codegen_csharp_1.Attribute(exports_1.ClientRuntime.PreviewMessageAttribute, { parameters: [`"${operation.details.csharp.previewMessage}"`] }));
2087
+ if (operation.details.csharp.previewAnnouncement) {
2088
+ const parameters = [];
2089
+ parameters.push(`"${operation.details.csharp.previewAnnouncement.previewMessage}"`);
2090
+ if (operation.details.csharp.previewAnnouncement.estimatedGaDate)
2091
+ parameters.push(`"${operation.details.csharp.previewAnnouncement.estimatedGaDate}"`);
2092
+ this.add(new codegen_csharp_1.Attribute(exports_1.ClientRuntime.PreviewMessageAttribute, { parameters: parameters }));
1803
2093
  }
1804
2094
  this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.OutputTypeAttribute, { parameters: [...outputTypes] }));
1805
2095
  if (shouldAddPassThru) {
@@ -1811,8 +2101,8 @@ class CmdletClass extends codegen_csharp_1.Class {
1811
2101
  // If defines externalDocs for operation
1812
2102
  if (operation.details.default.externalDocs) {
1813
2103
  this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ExternalDocsAttribute, {
1814
- parameters: [`${new codegen_csharp_1.StringExpression((_f = (_e = this.operation.details.default.externalDocs) === null || _e === void 0 ? void 0 : _e.url) !== null && _f !== void 0 ? _f : '')}`,
1815
- `${new codegen_csharp_1.StringExpression((_h = (_g = this.operation.details.default.externalDocs) === null || _g === void 0 ? void 0 : _g.description) !== null && _h !== void 0 ? _h : '')}`]
2104
+ parameters: [`${new codegen_csharp_1.StringExpression((_j = (_h = this.operation.details.default.externalDocs) === null || _h === void 0 ? void 0 : _h.url) !== null && _j !== void 0 ? _j : '')}`,
2105
+ `${new codegen_csharp_1.StringExpression((_l = (_k = this.operation.details.default.externalDocs) === null || _k === void 0 ? void 0 : _k.description) !== null && _l !== void 0 ? _l : '')}`]
1816
2106
  }));
1817
2107
  }
1818
2108
  this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.GeneratedAttribute));
@@ -1824,17 +2114,12 @@ class CmdletClass extends codegen_csharp_1.Class {
1824
2114
  });
1825
2115
  this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ProfileAttribute, { parameters: [...profileNames] }));
1826
2116
  }
1827
- this.operation.callGraph.forEach((operationInfo) => {
1828
- var _a;
1829
- let apiVersion = 'null';
1830
- if (operationInfo.apiVersions) {
1831
- apiVersion = operationInfo.apiVersions[0].version;
1832
- }
1833
- (_a = operationInfo.requests) === null || _a === void 0 ? void 0 : _a.forEach((request) => {
1834
- var _a, _b;
1835
- this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.HttpPathAttribute, { parameters: [`Path = "${(_b = (_a = request.protocol) === null || _a === void 0 ? void 0 : _a.http) === null || _b === void 0 ? void 0 : _b.path}"`, `ApiVersion = "${apiVersion}"`] }));
1836
- });
1837
- });
2117
+ if (this.operation.callGraph.length === 1) {
2118
+ this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.HttpPathAttribute, { parameters: [`Path = "${(_p = (_o = (_m = this.apiCall.requests) === null || _m === void 0 ? void 0 : _m[0].protocol) === null || _o === void 0 ? void 0 : _o.http) === null || _p === void 0 ? void 0 : _p.path}"`, `ApiVersion = "${(_q = this.apiCall.apiVersions) === null || _q === void 0 ? void 0 : _q[0].version}"`] }));
2119
+ }
2120
+ if (variantName.includes('ViaJsonString') || variantName.includes('ViaJsonFilePath')) {
2121
+ this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.NotSuggestDefaultParameterSetAttribute));
2122
+ }
1838
2123
  }
1839
2124
  }
1840
2125
  exports.CmdletClass = CmdletClass;