@autorest/powershell 4.0.0-dev.8 → 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 (494) hide show
  1. package/.rush/temp/package-deps_build.json +214 -206
  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 +27 -2
  6. package/dist/cmdlets/class.d.ts.map +1 -1
  7. package/dist/cmdlets/class.js +913 -549
  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 +3 -0
  38. package/dist/internal/powershell-declarations.d.ts.map +1 -1
  39. package/dist/internal/powershell-declarations.js +5 -2
  40. package/dist/internal/powershell-declarations.js.map +1 -1
  41. package/dist/internal/project.d.ts +14 -8
  42. package/dist/internal/project.d.ts.map +1 -1
  43. package/dist/internal/project.js +27 -20
  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 +25 -11
  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 +4 -12
  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 +10 -5
  101. package/dist/llcsharp/project.d.ts.map +1 -1
  102. package/dist/llcsharp/project.js +15 -4
  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 +5 -9
  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 +17 -7
  193. package/dist/plugins/create-commands-v2.d.ts.map +1 -1
  194. package/dist/plugins/create-commands-v2.js +302 -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 +14 -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 +135 -88
  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 +39 -10
  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/resourceName.d.ts +3 -0
  297. package/dist/utils/resourceName.d.ts.map +1 -0
  298. package/dist/utils/resourceName.js +29 -0
  299. package/dist/utils/resourceName.js.map +1 -0
  300. package/dist/utils/schema.d.ts +1 -1
  301. package/dist/utils/schema.d.ts.map +1 -1
  302. package/dist/utils/schema.js +11 -11
  303. package/dist/utils/schema.js.map +1 -1
  304. package/dist/utils/security-scheme.d.ts +2 -2
  305. package/dist/utils/security-scheme.d.ts.map +1 -1
  306. package/dist/utils/security-scheme.js +2 -2
  307. package/dist/utils/security-scheme.js.map +1 -1
  308. package/dist/utils/sort-parameters.d.ts +3 -0
  309. package/dist/utils/sort-parameters.d.ts.map +1 -0
  310. package/dist/utils/sort-parameters.js +33 -0
  311. package/dist/utils/sort-parameters.js.map +1 -0
  312. package/dist/utils/tsp-generator.d.ts +3 -0
  313. package/dist/utils/tsp-generator.d.ts.map +1 -0
  314. package/dist/utils/tsp-generator.js +65 -0
  315. package/dist/utils/tsp-generator.js.map +1 -0
  316. package/dist/utils/tsp-host.d.ts +42 -0
  317. package/dist/utils/tsp-host.d.ts.map +1 -0
  318. package/dist/utils/tsp-host.js +56 -0
  319. package/dist/utils/tsp-host.js.map +1 -0
  320. package/generators/readme.ts +0 -3
  321. package/package.json +11 -10
  322. package/resources/assets/build-module.ps1 +31 -4
  323. package/resources/assets/check-dependencies.ps1 +3 -3
  324. package/resources/assets/create-model-cmdlets.ps1 +34 -5
  325. package/resources/assets/export-surface.ps1 +3 -3
  326. package/resources/assets/generate-help.ps1 +5 -5
  327. package/resources/assets/generate-portal-ux.ps1 +9 -25
  328. package/resources/assets/run-module.ps1 +4 -4
  329. package/resources/assets/test/loadEnv.ps1 +1 -1
  330. package/resources/assets/test-module.ps1 +11 -7
  331. package/resources/assets/tools/Resources/README.md +0 -3
  332. package/resources/assets/tools/Resources/custom/New-AzDeployment.ps1 +2 -2
  333. package/resources/assets/tools/Resources/how-to.md +2 -0
  334. package/resources/built-time-cmdlets.csproj +1 -0
  335. package/resources/modules/Az.Accounts/2.13.1/Accounts.format.ps1xml +554 -0
  336. package/resources/modules/Az.Accounts/2.13.1/Accounts.generated.format.ps1xml +471 -0
  337. package/resources/modules/Az.Accounts/2.13.1/Accounts.types.ps1xml +306 -0
  338. package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Az.Accounts.nuspec +4 -5
  339. package/resources/modules/Az.Accounts/2.13.1/Az.Accounts.psd1 +389 -0
  340. package/resources/modules/Az.Accounts/2.13.1/Az.Accounts.psm1 +365 -0
  341. package/resources/modules/Az.Accounts/2.13.1/FuzzySharp.dll +0 -0
  342. package/resources/modules/Az.Accounts/2.13.1/Microsoft.ApplicationInsights.dll +0 -0
  343. package/resources/modules/Az.Accounts/2.13.1/Microsoft.Azure.PowerShell.AssemblyLoading.dll +0 -0
  344. package/resources/modules/Az.Accounts/2.13.1/Microsoft.Azure.PowerShell.Authentication.Abstractions.dll +0 -0
  345. package/resources/modules/Az.Accounts/2.13.1/Microsoft.Azure.PowerShell.Authentication.ResourceManager.dll +0 -0
  346. package/resources/modules/Az.Accounts/2.13.1/Microsoft.Azure.PowerShell.Authentication.dll +0 -0
  347. package/resources/modules/Az.Accounts/2.13.1/Microsoft.Azure.PowerShell.AuthenticationAssemblyLoadContext.dll +0 -0
  348. package/resources/modules/Az.Accounts/2.13.1/Microsoft.Azure.PowerShell.Authenticators.dll +0 -0
  349. package/resources/modules/Az.Accounts/2.13.1/Microsoft.Azure.PowerShell.Clients.Aks.dll +0 -0
  350. package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Microsoft.Azure.PowerShell.Clients.Authorization.dll +0 -0
  351. package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Microsoft.Azure.PowerShell.Clients.Compute.dll +0 -0
  352. package/resources/modules/Az.Accounts/2.13.1/Microsoft.Azure.PowerShell.Clients.Graph.Rbac.dll +0 -0
  353. package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Microsoft.Azure.PowerShell.Clients.KeyVault.dll +0 -0
  354. package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Microsoft.Azure.PowerShell.Clients.Monitor.dll +0 -0
  355. package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Microsoft.Azure.PowerShell.Clients.Network.dll +0 -0
  356. package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Microsoft.Azure.PowerShell.Clients.PolicyInsights.dll +0 -0
  357. package/resources/modules/Az.Accounts/2.13.1/Microsoft.Azure.PowerShell.Clients.ResourceManager.dll +0 -0
  358. package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Microsoft.Azure.PowerShell.Clients.Storage.Management.dll +0 -0
  359. package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Microsoft.Azure.PowerShell.Clients.Websites.dll +0 -0
  360. package/resources/modules/Az.Accounts/2.13.1/Microsoft.Azure.PowerShell.Cmdlets.Accounts.dll +0 -0
  361. package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Microsoft.Azure.PowerShell.Cmdlets.Accounts.dll-Help.xml +2510 -779
  362. package/resources/modules/Az.Accounts/2.13.1/Microsoft.Azure.PowerShell.Common.Share.dll +0 -0
  363. package/resources/modules/Az.Accounts/2.13.1/Microsoft.Azure.PowerShell.Common.dll +0 -0
  364. package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Microsoft.Azure.PowerShell.Storage.dll +0 -0
  365. package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Microsoft.Azure.PowerShell.Strategies.dll +0 -0
  366. package/resources/modules/Az.Accounts/2.13.1/Microsoft.Rest.ClientRuntime.dll +0 -0
  367. package/resources/modules/Az.Accounts/2.13.1/PostImportScripts/LoadAuthenticators.ps1 +222 -0
  368. package/resources/modules/Az.Accounts/2.13.1/StartupScripts/AzError.ps1 +281 -0
  369. package/resources/modules/Az.Accounts/2.13.1/StartupScripts/InitializeAssemblyResolver.ps1 +242 -0
  370. package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/[Content_Types].xml +2 -3
  371. package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/_rels/.rels +2 -2
  372. package/resources/modules/Az.Accounts/2.13.1/lib/netcoreapp2.1/Azure.Core.dll +0 -0
  373. package/resources/modules/Az.Accounts/2.13.1/lib/netcoreapp2.1/Microsoft.Identity.Client.dll +0 -0
  374. package/resources/modules/Az.Accounts/2.13.1/lib/netcoreapp3.1/Microsoft.Identity.Client.Extensions.Msal.dll +0 -0
  375. package/resources/modules/Az.Accounts/2.13.1/lib/netfx/Azure.Core.dll +0 -0
  376. package/resources/modules/Az.Accounts/2.13.1/lib/netfx/Microsoft.Identity.Client.Extensions.Msal.dll +0 -0
  377. package/resources/modules/Az.Accounts/2.13.1/lib/netfx/Microsoft.Identity.Client.dll +0 -0
  378. package/resources/modules/Az.Accounts/2.13.1/lib/netfx/Newtonsoft.Json.dll +0 -0
  379. package/resources/modules/Az.Accounts/2.13.1/lib/netfx/System.Diagnostics.DiagnosticSource.dll +0 -0
  380. package/resources/modules/Az.Accounts/2.13.1/lib/netfx/System.Reflection.DispatchProxy.dll +0 -0
  381. package/resources/modules/Az.Accounts/2.13.1/lib/netfx/System.Runtime.CompilerServices.Unsafe.dll +0 -0
  382. package/resources/modules/Az.Accounts/2.13.1/lib/netstandard2.0/Azure.Identity.BrokeredAuthentication.dll +0 -0
  383. package/resources/modules/Az.Accounts/2.13.1/lib/netstandard2.0/Azure.Identity.dll +0 -0
  384. package/resources/modules/Az.Accounts/2.13.1/lib/netstandard2.0/Microsoft.Identity.Client.Broker.dll +0 -0
  385. package/resources/modules/Az.Accounts/2.13.1/lib/netstandard2.0/Microsoft.Identity.Client.NativeInterop.dll +0 -0
  386. package/resources/modules/Az.Accounts/2.13.1/lib/netstandard2.0/Microsoft.IdentityModel.Abstractions.dll +0 -0
  387. package/resources/modules/Az.Accounts/2.13.1/lib/netstandard2.0/System.Security.AccessControl.dll +0 -0
  388. package/resources/modules/Az.Accounts/2.13.1/lib/netstandard2.0/System.Security.Permissions.dll +0 -0
  389. package/resources/modules/Az.Accounts/2.13.1/lib/netstandard2.0/System.Security.Principal.Windows.dll +0 -0
  390. package/resources/modules/Az.Accounts/2.13.1/lib/netstandard2.0/msalruntime.dll +0 -0
  391. package/resources/modules/Az.Accounts/2.13.1/lib/netstandard2.0/msalruntime_arm64.dll +0 -0
  392. package/resources/modules/Az.Accounts/2.13.1/lib/netstandard2.0/msalruntime_x86.dll +0 -0
  393. package/resources/modules/Az.Accounts/2.13.1/package/services/metadata/core-properties/f9ac9c2e40914e78a646a7b0b997403b.psmdcp +11 -0
  394. package/resources/psruntime/Attributes/PSArgumentCompleterAttribute.cs +52 -0
  395. package/resources/psruntime/BuildTime/Cmdlets/ExportHelpMarkdown.cs +4 -1
  396. package/resources/psruntime/BuildTime/Cmdlets/ExportProxyCmdlet.cs +6 -3
  397. package/resources/psruntime/BuildTime/Cmdlets/ExportPsd1.cs +7 -4
  398. package/resources/psruntime/BuildTime/Cmdlets/ExportTestStub.cs +130 -81
  399. package/resources/psruntime/BuildTime/Cmdlets/NewAssemblyInfo.cs +64 -0
  400. package/resources/psruntime/BuildTime/MarkdownRenderer.cs +17 -9
  401. package/resources/psruntime/BuildTime/Models/PsProxyOutputs.cs +53 -8
  402. package/resources/psruntime/BuildTime/Models/PsProxyTypes.cs +35 -11
  403. package/resources/psruntime/BuildTime/PsAttributes.cs +5 -0
  404. package/resources/psruntime/BuildTime/PsHelpers.cs +4 -3
  405. package/resources/psruntime/MessageAttribute.cs +45 -55
  406. package/resources/psruntime/MessageAttributeHelper.cs +30 -7
  407. package/resources/psruntime/Properties/Resources.Designer.cs +25 -3
  408. package/resources/psruntime/Properties/Resources.resx +8 -2
  409. package/resources/runtime/csharp/pipeline/ISendAsync.cs +113 -0
  410. package/resources/runtime/csharp/pipeline/PipelineMocking.cs +1 -1
  411. package/resources/templates/azureMethod.ejs +2 -2
  412. package/resources/templates/azureMethodGroup.ejs +2 -2
  413. package/resources/templates/azureServiceClient.ejs +11 -4
  414. package/resources/templates/enum.ejs +3 -3
  415. package/resources/templates/extensionMethod.ejs +18 -12
  416. package/resources/templates/extensions.ejs +9 -2
  417. package/resources/templates/longRunningOperationMethod.ejs +10 -8
  418. package/resources/templates/method.ejs +10 -8
  419. package/resources/templates/methodBodyRestCall.ejs +77 -32
  420. package/resources/templates/methodGroupInterface.ejs +2 -61
  421. package/resources/templates/methodGroupInterfaceBody.ejs +60 -0
  422. package/resources/templates/model.ejs +15 -15
  423. package/resources/templates/serviceClientBody.ejs +8 -8
  424. package/resources/templates/serviceClientInterface.ejs +10 -4
  425. package/resources/utils/Get-SubscriptionIdTestSafe.ps1 +7 -0
  426. package/dist/utils/WrapComments.d.ts +0 -2
  427. package/dist/utils/WrapComments.d.ts.map +0 -1
  428. package/dist/utils/WrapComments.js +0 -46
  429. package/dist/utils/WrapComments.js.map +0 -1
  430. package/resources/modules/Az.Accounts/2.7.5/Accounts.format.ps1xml +0 -496
  431. package/resources/modules/Az.Accounts/2.7.5/Accounts.generated.format.ps1xml +0 -468
  432. package/resources/modules/Az.Accounts/2.7.5/Accounts.types.ps1xml +0 -303
  433. package/resources/modules/Az.Accounts/2.7.5/Az.Accounts.psd1 +0 -387
  434. package/resources/modules/Az.Accounts/2.7.5/Az.Accounts.psm1 +0 -375
  435. package/resources/modules/Az.Accounts/2.7.5/AzSharedAlcAssemblies/Azure.Core.dll +0 -0
  436. package/resources/modules/Az.Accounts/2.7.5/AzSharedAlcAssemblies/Azure.Identity.dll +0 -0
  437. package/resources/modules/Az.Accounts/2.7.5/AzSharedAlcAssemblies/Microsoft.Identity.Client.Extensions.Msal.dll +0 -0
  438. package/resources/modules/Az.Accounts/2.7.5/AzSharedAlcAssemblies/Microsoft.Identity.Client.dll +0 -0
  439. package/resources/modules/Az.Accounts/2.7.5/Microsoft.ApplicationInsights.dll +0 -0
  440. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.Authentication.Abstractions.dll +0 -0
  441. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.Authentication.ResourceManager.deps.json +0 -2309
  442. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.Authentication.ResourceManager.dll +0 -0
  443. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.Authentication.deps.json +0 -2273
  444. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.Authentication.dll +0 -0
  445. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.AuthenticationAssemblyLoadContext.deps.json +0 -1316
  446. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.AuthenticationAssemblyLoadContext.dll +0 -0
  447. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.Authenticators.dll +0 -0
  448. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.Clients.Aks.dll +0 -0
  449. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.Clients.Graph.Rbac.dll +0 -0
  450. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.Clients.ResourceManager.dll +0 -0
  451. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.Cmdlets.Accounts.deps.json +0 -2413
  452. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.Cmdlets.Accounts.dll +0 -0
  453. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.Common.Share.dll +0 -0
  454. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.Common.dll +0 -0
  455. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Rest.ClientRuntime.dll +0 -0
  456. package/resources/modules/Az.Accounts/2.7.5/PostImportScripts/LoadAuthenticators.ps1 +0 -219
  457. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/Azure.Core.dll +0 -0
  458. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/Azure.Identity.dll +0 -0
  459. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/Microsoft.Azure.PowerShell.Authenticators.dll +0 -0
  460. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/Microsoft.Bcl.AsyncInterfaces.dll +0 -0
  461. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/Microsoft.Identity.Client.Extensions.Msal.dll +0 -0
  462. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/Microsoft.Identity.Client.dll +0 -0
  463. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/Newtonsoft.Json.12.0.3.dll +0 -0
  464. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/Newtonsoft.Json.dll +0 -0
  465. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/System.Diagnostics.DiagnosticSource.dll +0 -0
  466. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/System.Memory.Data.dll +0 -0
  467. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/System.Reflection.DispatchProxy.dll +0 -0
  468. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/System.Runtime.CompilerServices.Unsafe.dll +0 -0
  469. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/System.Security.AccessControl.dll +0 -0
  470. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/System.Security.Permissions.dll +0 -0
  471. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/System.Security.Principal.Windows.dll +0 -0
  472. package/resources/modules/Az.Accounts/2.7.5/PreloadAssemblies/System.Text.Json.dll +0 -0
  473. package/resources/modules/Az.Accounts/2.7.5/StartupScripts/AzError.ps1 +0 -278
  474. package/resources/modules/Az.Accounts/2.7.5/StartupScripts/InitializeAssemblyResolver.ps1 +0 -234
  475. package/resources/modules/Az.Accounts/2.7.5/package/services/metadata/core-properties/1aa0749a068a4238881858013f1a5b7f.psmdcp +0 -11
  476. /package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Hyak.Common.dll +0 -0
  477. /package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Microsoft.Azure.Common.dll +0 -0
  478. /package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Microsoft.Rest.ClientRuntime.Azure.dll +0 -0
  479. /package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Microsoft.WindowsAzure.Storage.DataMovement.dll +0 -0
  480. /package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/Microsoft.WindowsAzure.Storage.dll +0 -0
  481. /package/resources/modules/Az.Accounts/{2.7.5 → 2.13.1}/en-US/about_az.help.txt +0 -0
  482. /package/resources/modules/Az.Accounts/{2.7.5/PreloadAssemblies → 2.13.1/lib/netfx}/System.Numerics.Vectors.dll +0 -0
  483. /package/resources/modules/Az.Accounts/{2.7.5/PreloadAssemblies → 2.13.1/lib/netfx}/System.Security.Cryptography.Cng.dll +0 -0
  484. /package/resources/modules/Az.Accounts/{2.7.5/PreloadAssemblies → 2.13.1/lib/netfx}/System.Text.Encodings.Web.dll +0 -0
  485. /package/resources/modules/Az.Accounts/{2.7.5/PreloadAssemblies → 2.13.1/lib/netfx}/System.Xml.ReaderWriter.dll +0 -0
  486. /package/resources/modules/Az.Accounts/{2.7.5/AzSharedAlcAssemblies → 2.13.1/lib/netstandard2.0}/Microsoft.Bcl.AsyncInterfaces.dll +0 -0
  487. /package/resources/modules/Az.Accounts/{2.7.5/PreloadAssemblies → 2.13.1/lib/netstandard2.0}/System.Buffers.dll +0 -0
  488. /package/resources/modules/Az.Accounts/{2.7.5/AzSharedAlcAssemblies → 2.13.1/lib/netstandard2.0}/System.Memory.Data.dll +0 -0
  489. /package/resources/modules/Az.Accounts/{2.7.5/PreloadAssemblies → 2.13.1/lib/netstandard2.0}/System.Memory.dll +0 -0
  490. /package/resources/modules/Az.Accounts/{2.7.5/PreloadAssemblies → 2.13.1/lib/netstandard2.0}/System.Net.Http.WinHttpHandler.dll +0 -0
  491. /package/resources/modules/Az.Accounts/{2.7.5/PreloadAssemblies → 2.13.1/lib/netstandard2.0}/System.Private.ServiceModel.dll +0 -0
  492. /package/resources/modules/Az.Accounts/{2.7.5/PreloadAssemblies → 2.13.1/lib/netstandard2.0}/System.ServiceModel.Primitives.dll +0 -0
  493. /package/resources/modules/Az.Accounts/{2.7.5/AzSharedAlcAssemblies → 2.13.1/lib/netstandard2.0}/System.Text.Json.dll +0 -0
  494. /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.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,9 +15,10 @@ 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
+ const resourceName_1 = require("../utils/resourceName");
21
22
  const PropertiesRequiringNew = new Set(['Host', 'Events']);
22
23
  const Verbs = {
23
24
  Common: 'global::System.Management.Automation.VerbsCommon',
@@ -129,7 +130,7 @@ const category = {
129
130
  'Use': Verbs.Other,
130
131
  };
131
132
  function createStepper(p) {
132
- 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 =>
133
134
  (r, c, n) => {
134
135
  ${powershell_declarations_1.DefaultRunspace.value} = ${powershell_declarations_1.DefaultRunspace.value} ?? ${powershell_declarations_1.RunspaceFactory.declaration}.CreateRunspace();
135
136
  return step(r, c, n);
@@ -160,15 +161,27 @@ function NewAddCompleterInfo(targetProperty, parameter) {
160
161
  }
161
162
  }
162
163
  exports.NewAddCompleterInfo = NewAddCompleterInfo;
164
+ function isEnumImplementation(schema) {
165
+ return ((schema === null || schema === void 0 ? void 0 : schema.type) === codemodel_1.SchemaType.SealedChoice && !schema.language.default.skip) ||
166
+ ((schema === null || schema === void 0 ? void 0 : schema.extensions) && schema.extensions['x-ms-enum']);
167
+ }
168
+ exports.isEnumImplementation = isEnumImplementation;
169
+ function addPSArgumentCompleterAttribute(targetProperty, parameterSchema) {
170
+ const enumValues = (0, linq_1.values)(parameterSchema.language.csharp.enum.values).select(v => `"${v.value}"`).toArray().join(', ');
171
+ targetProperty.add(new codegen_csharp_1.Attribute(powershell_declarations_1.PSArgumentCompleterAttribute, { parameters: [`${enumValues}`] }));
172
+ }
173
+ exports.addPSArgumentCompleterAttribute = addPSArgumentCompleterAttribute;
163
174
  function addParameterBreakingChange(targetProperty, parameter) {
164
175
  if (parameter.breakingChange) {
165
176
  const parameters = [];
166
177
  parameters.push(`"${parameter.breakingChange.parameterName}"`);
167
- if (parameter.breakingChange.deprecateByVersion) {
168
- parameters.push(`"${parameter.breakingChange.deprecateByVersion}"`);
169
- if (parameter.breakingChange.changeInEfectByDate)
170
- 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}`);
171
180
  }
181
+ parameters.push(`"${parameter.breakingChange.deprecateByAzVersion}"`);
182
+ parameters.push(`"${parameter.breakingChange.deprecateByVersion}"`);
183
+ if (parameter.breakingChange.changeInEfectByDate)
184
+ parameters.push(`"${parameter.breakingChange.changeInEfectByDate}"`);
172
185
  if (parameter.breakingChange.replacement)
173
186
  parameters.push(`ReplaceMentCmdletParameterName="${parameter.breakingChange.replacement}"`);
174
187
  if (parameter.breakingChange.isBecomingMandatory)
@@ -192,12 +205,16 @@ function addParameterBreakingChange(targetProperty, parameter) {
192
205
  }
193
206
  }
194
207
  exports.addParameterBreakingChange = addParameterBreakingChange;
195
- function addPreviewMessage(targetProperty, parameter) {
196
- if (parameter.previewMessage) {
197
- 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 }));
198
215
  }
199
216
  }
200
- exports.addPreviewMessage = addPreviewMessage;
217
+ exports.addParameterPreviewMessage = addParameterPreviewMessage;
201
218
  function addDefaultInfo(targetProperty, parameter) {
202
219
  if (parameter.defaultInfo && parameter.defaultInfo.script) {
203
220
  targetProperty.add(new codegen_csharp_1.Attribute(exports_1.ClientRuntime.DefaultInfoAttribute, {
@@ -320,6 +337,11 @@ class CmdletClass extends codegen_csharp_1.Class {
320
337
  this.dropBodyParameter = operation.details.csharp.dropBodyParameter ? true : false;
321
338
  this.apply(objectInitializer);
322
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 = [];
323
345
  this.state = state;
324
346
  this.thingsToSerialize = [];
325
347
  this.variantName = variantName;
@@ -328,13 +350,16 @@ class CmdletClass extends codegen_csharp_1.Class {
328
350
  this.interfaces.push(exports_1.ClientRuntime.IContext);
329
351
  this.eventListener = new exports_1.EventListener(new codegen_csharp_1.LiteralExpression(`((${exports_1.ClientRuntime.IEventListener})this)`), true);
330
352
  this.isViaIdentity = variantName.indexOf('ViaIdentity') > 0;
331
- 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);
354
+ this.inputObjectParameterName = 'InputObject';
332
355
  }
333
356
  async init() {
334
357
  // basic stuff
335
358
  this.addCommonStuff();
336
- this.description = codegen_1.escapeString(this.operation.details.csharp.description);
359
+ this.description = (0, codegen_1.escapeString)(this.operation.details.csharp.description);
337
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);
338
363
  this.add(new codegen_csharp_1.Method('BeginProcessing', codegen_csharp_1.dotnet.Void, {
339
364
  override: codegen_csharp_1.Modifier.Override,
340
365
  access: codegen_csharp_1.Access.Protected,
@@ -342,10 +367,10 @@ class CmdletClass extends codegen_csharp_1.Class {
342
367
  *body() {
343
368
  if ($this.state.project.azure) {
344
369
  yield `var telemetryId = ${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.GetTelemetryId.Invoke();`;
345
- yield codegen_csharp_1.If('telemetryId != "" && telemetryId != "internal"', '__correlationId = telemetryId;');
370
+ yield (0, codegen_csharp_1.If)('telemetryId != "" && telemetryId != "internal"', '__correlationId = telemetryId;');
346
371
  }
347
372
  yield 'Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials);';
348
- 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();`);
349
374
  yield $this.eventListener.syncSignal(powershell_declarations_1.Events.CmdletBeginProcessing);
350
375
  }
351
376
  }));
@@ -364,9 +389,48 @@ class CmdletClass extends codegen_csharp_1.Class {
364
389
  this.implementIContext();
365
390
  // add constructors
366
391
  this.implementConstructors();
392
+ // add callback methods
393
+ this.NewImplementResponseMethod();
367
394
  // processRecord
368
- this.NewImplementProcessRecord(this.operation);
369
- 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
+ }
370
434
  this.debugMode = await this.state.getValue('debug', false);
371
435
  // json serialization
372
436
  this.NewImplementSerialization(this.operation);
@@ -381,7 +445,7 @@ class CmdletClass extends codegen_csharp_1.Class {
381
445
  var _a, _b, _c, _d, _e;
382
446
  const header = super.headerComment;
383
447
  let ops = '';
384
- for (const httpOperation of linq_1.values(this.operation.callGraph)) {
448
+ for (const httpOperation of (0, linq_1.values)(this.operation.callGraph)) {
385
449
  const request = (_a = httpOperation.requests) === null || _a === void 0 ? void 0 : _a[0];
386
450
  if (!request) {
387
451
  continue;
@@ -402,10 +466,10 @@ class CmdletClass extends codegen_csharp_1.Class {
402
466
  ops = `${ops}\n variant: ${this.operation.details.csharp.name}`;
403
467
  }
404
468
  }
405
- 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;
406
470
  }
407
471
  AddSwitchViewProperty(responseType = codegen_csharp_1.dotnet.Object) {
408
- var fieldNames = this.fields.map(f => f.name);
472
+ const fieldNames = this.fields.map(f => f.name);
409
473
  if (!fieldNames.includes('_responseSize')) {
410
474
  this.add(new codegen_csharp_1.Field('_responseSize', codegen_csharp_1.dotnet.Int, {
411
475
  initialValue: '0', description: 'A flag to tell whether it is the first returned object in a call. Zero means no response yet. One means 1 returned object. Two means multiple returned objects in response.', access: codegen_csharp_1.Access.Private
@@ -418,9 +482,9 @@ class CmdletClass extends codegen_csharp_1.Class {
418
482
  }
419
483
  }
420
484
  FlushResponse(singleFlush = true) {
421
- var fieldNames = this.fields.map(f => f.name);
485
+ const fieldNames = this.fields.map(f => f.name);
422
486
  return fieldNames.includes('_responseSize') ?
423
- codegen_csharp_1.If(`1 ==_responseSize`, function* () {
487
+ (0, codegen_csharp_1.If)('1 ==_responseSize', function* () {
424
488
  yield '// Flush buffer';
425
489
  if (singleFlush) {
426
490
  yield 'WriteObject(_firstResponse);';
@@ -430,49 +494,46 @@ class CmdletClass extends codegen_csharp_1.Class {
430
494
  }
431
495
  }) : '';
432
496
  }
433
- ;
434
497
  WriteObjectWithViewControl(valueName, isEnumerable = false) {
435
498
  const $this = this;
436
499
  if ($this.state.project.autoSwitchView) {
437
500
  if (isEnumerable) {
438
501
  return function* () {
439
- yield `var outputObjects = ${valueName};`;
440
- yield codegen_csharp_1.If(`null != outputObjects`, function* () {
441
- yield codegen_csharp_1.If(`0 == _responseSize && 1 == outputObjects.Count`, function* () {
442
- yield `_firstResponse = outputObjects[0];`;
443
- yield `_responseSize = 1;`;
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];`;
505
+ yield '_responseSize = 1;';
444
506
  });
445
- yield codegen_csharp_1.Else(function* () {
507
+ yield (0, codegen_csharp_1.Else)(function* () {
446
508
  yield $this.FlushResponse(false);
447
509
  yield 'var values = new System.Collections.Generic.List<System.Management.Automation.PSObject>();';
448
- yield codegen_csharp_1.ForEach(`value`, `outputObjects`, function* () {
449
- yield `values.Add(value.AddMultipleTypeNameIntoPSObject());`;
510
+ yield (0, codegen_csharp_1.ForEach)('value', valueName, function* () {
511
+ yield 'values.Add(value.AddMultipleTypeNameIntoPSObject());';
450
512
  });
451
513
  yield 'WriteObject(values, true); ';
452
- yield `_responseSize = 2;`;
514
+ yield '_responseSize = 2;';
453
515
  });
454
516
  });
455
517
  };
456
518
  }
457
519
  else {
458
520
  return function* () {
459
- yield `var outputObject = ${valueName};`;
460
- yield codegen_csharp_1.If(`null != outputObject`, function* () {
461
- yield codegen_csharp_1.If(`0 == _responseSize`, function* () {
462
- yield `_firstResponse = outputObject;`;
463
- yield `_responseSize = 1;`;
521
+ yield (0, codegen_csharp_1.If)(`null != ${valueName}`, function* () {
522
+ yield (0, codegen_csharp_1.If)('0 == _responseSize', function* () {
523
+ yield `_firstResponse = ${valueName};`;
524
+ yield '_responseSize = 1;';
464
525
  });
465
- yield codegen_csharp_1.Else(function* () {
526
+ yield (0, codegen_csharp_1.Else)(function* () {
466
527
  yield $this.FlushResponse(false);
467
- yield `WriteObject(outputObject.AddMultipleTypeNameIntoPSObject());`;
468
- yield `_responseSize = 2;`;
528
+ yield `WriteObject(${valueName}.AddMultipleTypeNameIntoPSObject());`;
529
+ yield '_responseSize = 2;';
469
530
  });
470
531
  });
471
532
  };
472
533
  }
473
534
  }
474
535
  else {
475
- return `WriteObject(${valueName}, ${isEnumerable})`;
536
+ return `WriteObject(${valueName}, ${isEnumerable});`;
476
537
  }
477
538
  }
478
539
  addCommonStuff() {
@@ -480,7 +541,7 @@ class CmdletClass extends codegen_csharp_1.Class {
480
541
  // add a private copy of invocation information for our own uses.
481
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 }));
482
543
  this.invocationInfo = new codegen_csharp_1.Property('InvocationInformation', powershell_declarations_1.InvocationInfo, { description: 'Accessor for our copy of the InvocationInfo.' });
483
- 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 `);
484
545
  this.invocationInfo.set = new codegen_csharp_1.Statements(privateInvocationInfo.assign('value'));
485
546
  this.add(this.invocationInfo);
486
547
  if (this.state.project.azure) {
@@ -506,6 +567,21 @@ class CmdletClass extends codegen_csharp_1.Class {
506
567
  if ($this.state.project.autoSwitchView) {
507
568
  yield $this.FlushResponse();
508
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
+ }
509
585
  });
510
586
  // debugging
511
587
  const brk = this.add(new codegen_csharp_1.Property('Break', powershell_declarations_1.SwitchParameter, { attributes: [], description: 'Wait for .NET debugger to attach' }));
@@ -531,40 +607,27 @@ class CmdletClass extends codegen_csharp_1.Class {
531
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"'] }));
532
608
  proxyUri.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CategoryAttribute, { parameters: [`${powershell_declarations_1.ParameterCategory}.Runtime`] }));
533
609
  if (this.state.project.azure) {
534
- 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' }));
535
- 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."'] }));
536
612
  this.defaultProfile.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ValidateNotNull));
537
613
  this.defaultProfile.add(new codegen_csharp_1.Attribute(powershell_declarations_1.Alias, { parameters: ['"AzureRMContext"', '"AzureCredential"'] }));
538
614
  this.defaultProfile.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CategoryAttribute, { parameters: [`${powershell_declarations_1.ParameterCategory}.Azure`] }));
539
615
  }
540
616
  }
541
- NewIsWritableCmdlet(operation) {
542
- var _a, _b;
543
- if (operation.callGraph[0].requests) {
544
- 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()) {
545
- case 'put':
546
- case 'post':
547
- case 'delete':
548
- case 'patch':
549
- return true;
550
- }
551
- }
552
- return false;
553
- }
554
- NewImplementProcessRecord(operation) {
617
+ NewImplementProcessRecord() {
555
618
  const $this = this;
556
- const writable = this.NewIsWritableCmdlet(operation);
619
+ const operation = $this.operation;
557
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* () {
558
621
  yield $this.eventListener.syncSignal(powershell_declarations_1.Events.CmdletProcessRecordStart);
559
622
  if ($this.state.project.azure) {
560
623
  yield $this.processRecordId.assign('System.Guid.NewGuid().ToString()');
561
624
  }
562
- yield codegen_csharp_1.Try(function* () {
625
+ yield (0, codegen_csharp_1.Try)(function* () {
563
626
  var _a;
564
627
  yield '// work';
565
628
  const normal = new codegen_csharp_1.Statements(function* () {
566
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) });
567
- yield codegen_csharp_1.Using(acr.declarationExpression, function* () {
630
+ yield (0, codegen_csharp_1.Using)(acr.declarationExpression, function* () {
568
631
  yield `${acr}.Wait( ProcessRecordAsync(),${$this.cancellationToken});`;
569
632
  });
570
633
  });
@@ -577,7 +640,7 @@ class CmdletClass extends codegen_csharp_1.Class {
577
640
  nowait.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CategoryAttribute, { parameters: [`${powershell_declarations_1.ParameterCategory}.Runtime`] }));
578
641
  }
579
642
  const work = operation.asjob ? function* () {
580
- yield codegen_csharp_1.If('true == MyInvocation?.BoundParameters?.ContainsKey("AsJob")', function* () {
643
+ yield (0, codegen_csharp_1.If)('true == MyInvocation?.BoundParameters?.ContainsKey("AsJob")', function* () {
581
644
  // clone the cmdlet instance, since the instance can be reused and overwrite data.
582
645
  const instance = new codegen_csharp_1.LocalVariable('instance', codegen_csharp_1.dotnet.Var, { initializer: 'this.Clone()' });
583
646
  yield instance.declarationStatement;
@@ -594,46 +657,51 @@ class CmdletClass extends codegen_csharp_1.Class {
594
657
  // return the job to the user now.
595
658
  yield `WriteObject(${job});`;
596
659
  });
597
- yield codegen_csharp_1.Else(normal);
660
+ yield (0, codegen_csharp_1.Else)(normal);
598
661
  } : normal;
599
- if (writable) {
600
- 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);
601
664
  }
602
665
  else {
603
666
  yield work;
604
667
  }
605
668
  });
606
669
  const aggregateException = new codegen_csharp_1.Parameter('aggregateException', codegen_csharp_1.System.AggregateException);
607
- yield codegen_csharp_1.Catch(aggregateException, function* () {
670
+ yield (0, codegen_csharp_1.Catch)(aggregateException, function* () {
608
671
  yield '// unroll the inner exceptions to get the root cause';
609
- 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* () {
610
673
  yield $this.eventListener.syncSignal(powershell_declarations_1.Events.CmdletException, new codegen_csharp_1.LiteralExpression('$"{innerException.GetType().Name} - {innerException.Message} : {innerException.StackTrace}"'));
611
674
  yield '// Write exception out to error channel.';
612
- 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) );`;
613
676
  });
614
677
  });
615
678
  const exception = new codegen_csharp_1.Parameter('exception', codegen_csharp_1.System.Exception);
616
- yield codegen_csharp_1.Catch(exception, function* () {
679
+ yield (0, codegen_csharp_1.Catch)(exception, function* () {
617
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}"`));
618
681
  yield '// Write exception out to error channel.';
619
- 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) );`;
620
683
  }, { when: new codegen_csharp_1.LiteralExpression('(exception as System.Management.Automation.PipelineStoppedException)== null || (exception as System.Management.Automation.PipelineStoppedException).InnerException != null') });
621
- yield codegen_csharp_1.Finally(function* () {
684
+ yield (0, codegen_csharp_1.Finally)(function* () {
622
685
  yield $this.eventListener.syncSignalNoCheck(powershell_declarations_1.Events.CmdletProcessRecordEnd);
623
686
  });
624
687
  });
625
688
  }
626
- NewImplementProcessRecordAsync(operation) {
689
+ NewImplementProcessRecordAsync() {
627
690
  const $this = this;
628
- 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(), {
629
698
  access: codegen_csharp_1.Access.Protected, async: codegen_csharp_1.Modifier.Async,
630
699
  description: 'Performs execution of the command, working asynchronously if required.',
631
700
  returnsDescription: `A <see cref="${codegen_csharp_1.System.Threading.Tasks.Task()}" /> that will be complete when handling of the method is completed.`
632
701
  }));
633
702
  // we don't want to use SynchContext here.
634
- PAR.push(codegen_csharp_1.Using('NoSynchronizationContext', ''));
635
- PAR.add(function* () {
636
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
703
+ PRA.push((0, codegen_csharp_1.Using)('NoSynchronizationContext', ''));
704
+ PRA.add(function* () {
637
705
  if ($this.apProp && $this.bodyParameter && $this.bodyParameterInfo) {
638
706
  // yield `${ClientRuntime}.DictionaryExtensions.HashTableToDictionary<${$this.bodyParameterInfo.type.declaration},${$this.bodyParameterInfo.valueType.declaration}>(${$this.apProp.value},${$this.bodyParameter.Cast($this.bodyParameterInfo.type)});`;
639
707
  let vt = $this.bodyParameterInfo.valueType.declaration;
@@ -643,16 +711,18 @@ class CmdletClass extends codegen_csharp_1.Class {
643
711
  yield `${exports_1.ClientRuntime}.DictionaryExtensions.HashTableToDictionary<${vt}>(${$this.apProp.value},${$this.bodyParameter}.AdditionalProperties);`;
644
712
  }
645
713
  // construct the call to the operation
714
+ if (!$this.state.project.azure) {
715
+ yield $this.eventListener.signal(powershell_declarations_1.Events.CmdletProcessRecordAsyncStart);
716
+ }
646
717
  yield $this.eventListener.signal(powershell_declarations_1.Events.CmdletGetPipeline);
647
- const pipeline = $this.$('Pipeline');
648
718
  if ($this.state.project.azure) {
649
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)`));
650
720
  }
651
721
  else {
652
722
  yield pipeline.assign(new codegen_csharp_1.LiteralExpression(`${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.CreatePipeline(${$this.invocationInfo}, this.ParameterSetName, this.ExtensibleParameters)`));
653
723
  }
654
- 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')}`)));
655
- 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')}`)));
656
726
  yield '// get the client instance';
657
727
  // Add input pipeline if it is configured by developers.
658
728
  if ($this.operation.extensions.inputPipe) {
@@ -673,404 +743,665 @@ class CmdletClass extends codegen_csharp_1.Class {
673
743
  };
674
744
  for (const vParam of [...vps.body, ...vps.operation]) {
675
745
  if (vParam.hidden) {
676
- const td = $this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(vParam.schema, true, $this.state);
677
- yield codegen_csharp_1.If(`true == this.MyInvocation?.BoundParameters?.ContainsKey("${vParam.name}")`, `${vParam.name} = (${td.declaration})this.MyInvocation.BoundParameters["${vParam.name}"];`);
746
+ const td = $this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(vParam.schema, true, $this.state, true);
747
+ yield (0, codegen_csharp_1.If)(`true == this.MyInvocation?.BoundParameters?.ContainsKey("${vParam.name}")`, `${vParam.name} = (${td.declaration})this.MyInvocation.BoundParameters["${vParam.name}"];`);
678
748
  }
679
749
  }
680
- const apiCall = operation.callGraph[0];
681
- // find each parameter to the method, and find out where the value is going to come from.
682
- const operationParameters = linq_1.values(apiCall.parameters).
683
- // filter out constants and path parameters when using piping for identity
684
- 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) */).
685
- select(p => {
686
- var _a, _b;
687
- return {
688
- name: (_a = p.language.csharp) === null || _a === void 0 ? void 0 : _a.name,
689
- param: linq_1.values($this.properties).
690
- where(each => each.metadata.parameterDefinition).
691
- 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); }),
692
- 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);
693
776
  };
694
- }).
695
- select(each => {
696
- if (each.param) {
697
- const httpParam = (each.param.metadata.parameterDefinition);
698
- if (httpParam.required) {
699
- return {
700
- name: each.param,
701
- expression: each.param,
702
- 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 : '')}`
703
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);
704
904
  }
705
- const httpParamTD = $this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(httpParam.schema, httpParam.required, $this.state);
706
- return {
707
- name: each.param,
708
- expression: codegen_csharp_1.toExpression(`this.InvocationInformation.BoundParameters.ContainsKey("${each.param.value}") ? ${each.param.value} : ${httpParamTD.defaultOfType}`),
709
- isPathParam: each.isPathParam
710
- };
711
905
  }
712
- return { name: each.name, expression: codegen_csharp_1.dotnet.Null, isPathParam: each.isPathParam };
713
- }).toArray();
714
- // is there a body parameter we should include?
715
- if ($this.bodyParameter) {
716
- operationParameters.push({ name: 'body', expression: $this.bodyParameter, isPathParam: false });
717
- }
718
- // create the response handlers
719
- const responses = [...linq_1.values(apiCall.responses), ...linq_1.values(apiCall.exceptions)];
720
- 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) || ''); });
721
- // make callback methods
722
- for (const each of linq_1.values(responses)) {
723
- const isBinary = each.binary;
724
- const parameters = new Array();
725
- 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}.` }));
726
- if ((_a = each.language.csharp) === null || _a === void 0 ? void 0 : _a.responseType) {
727
- 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 }), {
728
- 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`
729
- }));
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
+ }
730
960
  }
731
- if ((_e = each.language.csharp) === null || _e === void 0 ? void 0 : _e.headerType) {
732
- 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}`;
733
964
  }
734
- if (isBinary) {
735
- 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);
736
970
  }
737
- const override = `override${codegen_1.pascalCase(((_f = each.language.csharp) === null || _f === void 0 ? void 0 : _f.name) || '')}`;
738
- 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 )` });
739
- const overrideResponseMethod = new codegen_csharp_1.PartialMethod(override, codegen_csharp_1.dotnet.Void, {
740
- parameters: [...parameters, returnNow],
741
- 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`,
742
- 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;`;
743
1087
  });
744
- $this.add(overrideResponseMethod);
745
- 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(), {
746
- access: codegen_csharp_1.Access.Private,
747
- parameters,
748
- async: codegen_csharp_1.Modifier.Async,
749
- description: (_k = each.language.csharp) === null || _k === void 0 ? void 0 : _k.description,
750
- 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;
751
1128
  });
752
- responseMethod.push(codegen_csharp_1.Using('NoSynchronizationContext', ''));
753
- responseMethod.add(function* () {
754
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
755
- 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})`);
756
- yield skip.declarationStatement;
757
- yield `${overrideResponseMethod.invoke(...parameters, `ref ${skip.value}`)};`;
758
- yield `// if ${override} has returned true, then return right away.`;
759
- yield codegen_csharp_1.If(codegen_csharp_1.And(codegen_csharp_1.IsNotNull(skip), `await ${skip}`), codegen_csharp_1.Return());
760
- if ((_a = each.language.csharp) === null || _a === void 0 ? void 0 : _a.isErrorResponse) {
761
- // this should write an error to the error channel.
762
- yield `// Error Response : ${(_b = each.protocol.http) === null || _b === void 0 ? void 0 : _b.statusCodes[0]}`;
763
- const unexpected = function* () {
764
- var _a;
765
- yield '// Unrecognized Response. Create an error record based on what we have.';
766
- const ex = ((_a = each.language.csharp) === null || _a === void 0 ? void 0 : _a.responseType) ?
767
- codegen_csharp_2.Local('ex', `new ${exports_1.ClientRuntime.name}.RestException<${each.language.csharp.responseType}>(responseMessage, await response)`) :
768
- codegen_csharp_2.Local('ex', `new ${exports_1.ClientRuntime.name}.RestException(responseMessage)`);
769
- yield ex.declarationStatement;
770
- 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(', ')} })
771
1207
  {
772
1208
  ErrorDetails = new global::System.Management.Automation.ErrorDetails(${ex.value}.Message) { RecommendedAction = ${ex.value}.Action }
773
1209
  });`;
774
- };
775
- if (each.schema !== undefined) {
776
- // the schema should be the error information.
777
- // this supports both { error { message, code} } and { message, code}
778
- let props = schema_1.getAllPublicVirtualProperties((_c = each.schema.language.csharp) === null || _c === void 0 ? void 0 : _c.virtualProperties);
779
- const errorProperty = linq_1.values(props).first(p => p.property.serializedName === 'error');
780
- let ep = '';
781
- if (errorProperty) {
782
- props = schema_1.getAllPublicVirtualProperties((_d = errorProperty.property.schema.language.csharp) === null || _d === void 0 ? void 0 : _d.virtualProperties);
783
- ep = `${errorProperty.name}?.`;
784
- }
785
- const codeProp = props.find(p => p.name.toLowerCase().indexOf('code') > -1); // first property with 'code'
786
- const messageProp = props.find(p => p.name.toLowerCase().indexOf('message') > -1); // first property with 'message'
787
- const actionProp = props.find(p => p.name.toLowerCase().indexOf('action') > -1); // first property with 'action'
788
- if (codeProp && messageProp) {
789
- const lcode = new codegen_csharp_1.LocalVariable('code', codegen_csharp_1.dotnet.Var, { initializer: `(await response)?.${ep}${codeProp.name}` });
790
- const lmessage = new codegen_csharp_1.LocalVariable('message', codegen_csharp_1.dotnet.Var, { initializer: `(await response)?.${ep}${messageProp.name}` });
791
- 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;
792
- yield lcode;
793
- yield lmessage;
794
- yield laction;
795
- yield codegen_csharp_1.If(codegen_csharp_1.Or(codegen_csharp_1.IsNull(lcode), (codegen_csharp_1.IsNull(lmessage))), unexpected);
796
- 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(', ')} })
797
1233
  {
798
1234
  ErrorDetails = new global::System.Management.Automation.ErrorDetails(${lmessage}) { RecommendedAction = ${laction || codegen_csharp_1.System.String.Empty} }
799
1235
  });`);
800
- return;
801
- }
802
- else {
803
- yield unexpected;
804
- return;
805
- }
1236
+ return;
806
1237
  }
807
1238
  else {
808
1239
  yield unexpected;
809
1240
  return;
810
1241
  }
811
1242
  }
812
- 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('/')}`;
813
- if ('schema' in each) {
814
- const schema = each.schema;
815
- if ((_h = apiCall.language.csharp) === null || _h === void 0 ? void 0 : _h.pageable) {
816
- const pageable = apiCall.language.csharp.pageable;
817
- if ($this.clientsidePagination) {
818
- yield '// clientside pagination enabled';
819
- }
820
- yield '// response should be returning an array of some kind. +Pageable';
821
- yield `// ${pageable.responseType} / ${pageable.itemName || '<none>'} / ${pageable.nextLinkName || '<none>'}`;
822
- switch (pageable.responseType) {
823
- // the result is (or works like a x-ms-pageable)
824
- case 'pageable':
825
- case 'nested-array':
826
- {
827
- const valueProperty = (_j = schema.properties) === null || _j === void 0 ? void 0 : _j.find(p => p.serializedName === pageable.itemName);
828
- 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);
829
- if (valueProperty && nextLinkProperty) {
830
- // it's pageable!
831
- const result = new codegen_csharp_1.LocalVariable('result', codegen_csharp_1.dotnet.Var, { initializer: new codegen_csharp_1.LiteralExpression('await response') });
832
- yield result.declarationStatement;
833
- // write out the current contents
834
- const vp = schema_1.getVirtualPropertyFromPropertyName((_m = schema.language.csharp) === null || _m === void 0 ? void 0 : _m.virtualProperties, valueProperty.serializedName);
835
- if (vp) {
836
- if ($this.clientsidePagination) {
837
- yield (codegen_csharp_1.If('(ulong)result.Value.Length <= this.PagingParameters.Skip', function* () {
838
- yield ('this.PagingParameters.Skip = this.PagingParameters.Skip - (ulong)result.Value.Length;');
839
- }));
840
- yield codegen_csharp_1.Else(function* () {
841
- yield ('ulong toRead = Math.Min(this.PagingParameters.First, (ulong)result.Value.Length - this.PagingParameters.Skip);');
842
- yield ('var requiredResult = result.Value.SubArray((int)this.PagingParameters.Skip, (int)toRead);');
843
- yield $this.WriteObjectWithViewControl(`requiredResult`, true);
844
- yield ('this.PagingParameters.Skip = 0;');
845
- yield ('this.PagingParameters.First = this.PagingParameters.First <= toRead ? 0 : this.PagingParameters.First - toRead;');
846
- });
847
- }
848
- else {
849
- yield $this.WriteObjectWithViewControl(`${result.value}.${vp.name}`, true);
850
- }
851
- }
852
- const nl = schema_1.getVirtualPropertyFromPropertyName((_o = schema.language.csharp) === null || _o === void 0 ? void 0 : _o.virtualProperties, nextLinkProperty.serializedName);
853
- if (nl) {
854
- $this.add(new codegen_csharp_1.Field('_isFirst', codegen_csharp_1.dotnet.Bool, {
855
- access: codegen_csharp_1.Access.Private,
856
- initialValue: new codegen_csharp_1.LiteralExpression('true'),
857
- description: 'A flag to tell whether it is the first onOK call.'
858
- }));
859
- $this.add(new codegen_csharp_1.Field('_nextLink', codegen_csharp_1.dotnet.String, {
860
- access: codegen_csharp_1.Access.Private,
861
- description: 'Link to retrieve next page.'
862
- }));
863
- const nextLinkName = `${result.value}.${nl.name}`;
864
- yield `_nextLink = ${nextLinkName};`;
865
- const nextLinkCondition = $this.clientsidePagination ? '_nextLink != null && this.PagingParameters.First > 0' : '_nextLink != null';
866
- yield (codegen_csharp_1.If('_isFirst', function* () {
867
- yield '_isFirst = false;';
868
- yield (codegen_csharp_1.While(nextLinkCondition, codegen_csharp_1.If('responseMessage.RequestMessage is System.Net.Http.HttpRequestMessage requestMessage ', function* () {
869
- var _a;
870
- yield `requestMessage = requestMessage.Clone(new global::System.Uri( _nextLink ),${exports_1.ClientRuntime.Method.Get} );`;
871
- yield $this.eventListener.signal(powershell_declarations_1.Events.FollowingNextLink);
872
- 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}`;
873
- })));
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;');
874
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
+ });
875
1286
  }
876
- return;
877
- }
878
- else if (valueProperty) {
879
- // it's just a nested array
880
- const p = codemodel_v3_1.getVirtualPropertyFromPropertyName((_p = schema.language.csharp) === null || _p === void 0 ? void 0 : _p.virtualProperties, valueProperty.serializedName);
881
- if (p) {
882
- yield $this.WriteObjectWithViewControl(`(await response).${p.name}`, true);
1287
+ else {
1288
+ yield $this.WriteObjectWithViewControl(`${result.value}.${vp.name}`, true);
883
1289
  }
884
- return;
885
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;
886
1316
  }
887
- break;
888
- // it's just an array,
889
- case 'array':
890
- // just write-object(enumerate) with the output
891
- yield $this.WriteObjectWithViewControl('(await response)', true);
892
- return;
893
- }
894
- // ok, let's see if the response type
895
- }
896
- const props = schema_1.getAllPublicVirtualProperties((_q = schema.language.csharp) === null || _q === void 0 ? void 0 : _q.virtualProperties);
897
- const outValue = (linq_1.length(props) === 1) ? `(await response).${props[0].name}` : '(await response)';
898
- // we expect to get back some data from this call.
899
- const rType = $this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(schema, true, $this.state);
900
- yield `// (await response) // should be ${rType.declaration}`;
901
- if ($this.hasStreamOutput && $this.outFileParameter) {
902
- const outfile = $this.outFileParameter;
903
- const provider = codegen_csharp_2.Local('provider');
904
- provider.initializer = undefined;
905
- const paths = codegen_csharp_2.Local('paths', `this.SessionState.Path.GetResolvedProviderPathFromPSPath(${outfile.value}, out ${provider.declarationExpression})`);
906
- yield paths.declarationStatement;
907
- 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}) );`);
908
- 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}) );`);
909
- if (rType.declaration === codegen_csharp_1.System.IO.Stream.declaration) {
910
- // this is a stream output. write to outfile
911
- const stream = codegen_csharp_2.Local('stream', 'await response');
912
- yield codegen_csharp_1.Using(stream.declarationExpression, function* () {
913
- const fileStream = codegen_csharp_2.Local('fileStream', `global::System.IO.File.OpenWrite(${paths.value}[0])`);
914
- yield codegen_csharp_1.Using(fileStream.declarationExpression, `await ${stream.value}.CopyToAsync(${fileStream.value});`);
915
- });
916
- }
917
- else {
918
- // assuming byte array output (via outValue)
919
- yield `global::System.IO.File.WriteAllBytes(${paths.value}[0],${outValue});`;
920
- }
921
- yield codegen_csharp_1.If('true == MyInvocation?.BoundParameters?.ContainsKey("PassThru")', function* () {
922
- // no return type. Let's just return ... true?
923
- yield 'WriteObject(true);';
924
- });
925
- return;
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
+ }
1323
+ return;
1324
+ }
1325
+ }
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;
926
1332
  }
927
- // let's just return the result object (or unwrapped result object)
928
- yield $this.WriteObjectWithViewControl(`${outValue}`);
929
- return;
1333
+ // ok, let's see if the response type
930
1334
  }
931
- // in m4, there will be no schema deinfed for the binary response, instead, we will have a field called binary with value true.
932
- if ('binary' in each) {
933
- yield '// (await response) // should be global::System.IO.Stream';
934
- if ($this.hasStreamOutput && $this.outFileParameter) {
935
- const outfile = $this.outFileParameter;
936
- const provider = codegen_csharp_2.Local('provider');
937
- provider.initializer = undefined;
938
- const paths = codegen_csharp_2.Local('paths', 'new global::System.Collections.ObjectModel.Collection<global::System.String>()');
939
- yield paths.declarationStatement;
940
- yield codegen_csharp_1.Try(function* () {
941
- yield `${paths.value} = this.SessionState.Path.GetResolvedProviderPathFromPSPath(${outfile.value}, out ${provider.declarationExpression});`;
942
- 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}));`);
943
- 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}));`);
944
- });
945
- const notfound = new codegen_csharp_1.Parameter('', { declaration: 'global::System.Management.Automation.ItemNotFoundException' });
946
- yield codegen_csharp_1.Catch(notfound, function* () {
947
- yield '// If the file does not exist, we will try to create it';
948
- yield `${paths.value}.Add(${outfile.value});`;
949
- });
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) {
950
1345
  // this is a stream output. write to outfile
951
- const stream = codegen_csharp_2.Local('stream', 'await response');
952
- yield codegen_csharp_1.Using(stream.declarationExpression, function* () {
953
- const fileStream = codegen_csharp_2.Local('fileStream', `global::System.IO.File.OpenWrite(${paths.value}[0])`);
954
- yield codegen_csharp_1.Using(fileStream.declarationExpression, `await ${stream.value}.CopyToAsync(${fileStream.value});`);
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});`);
955
1350
  });
956
- yield codegen_csharp_1.If('true == MyInvocation?.BoundParameters?.ContainsKey("PassThru")', function* () {
957
- // no return type. Let's just return ... true?
958
- yield 'WriteObject(true);';
959
- });
960
- return;
961
- }
962
- }
963
- yield codegen_csharp_1.If('true == MyInvocation?.BoundParameters?.ContainsKey("PassThru")', function* () {
964
- // no return type. Let's just return ... true?
965
- yield 'WriteObject(true);';
966
- });
967
- });
968
- $this.add(responseMethod);
969
- }
970
- yield codegen_csharp_1.Try(function* () {
971
- // make the call.
972
- const actualCall = function* () {
973
- var _a, _b;
974
- yield $this.eventListener.signal(powershell_declarations_1.Events.CmdletBeforeAPICall);
975
- const idOpParams = operationParameters.filter(each => !each.isPathParam);
976
- const idschema = linq_1.values($this.state.project.model.schemas.objects).first(each => each.language.default.uid === 'universal-parameter-type');
977
- let serializationMode = null;
978
- if ($this.bodyParameter) {
979
- if ($this.operation.operationType === command_operation_1.OperationType.Create) {
980
- serializationMode = exports_1.ClientRuntime.SerializationMode.IncludeCreate;
981
- }
982
- else if ($this.operation.operationType === command_operation_1.OperationType.Update) {
983
- serializationMode = exports_1.ClientRuntime.SerializationMode.IncludeUpdate;
984
- }
985
- }
986
- if ($this.isViaIdentity) {
987
- const identityFromPathParams = function* () {
988
- var _a, _b;
989
- yield '// try to call with PATH parameters from Input Object';
990
- if (idschema) {
991
- const allVPs = schema_1.getAllPublicVirtualProperties((_a = idschema.language.csharp) === null || _a === void 0 ? void 0 : _a.virtualProperties);
992
- const props = [...linq_1.values(idschema.properties)];
993
- const idOpParams = operationParameters.map(each => {
994
- var _a, _b, _c, _d, _e, _f;
995
- const pascalName = codegen_1.pascalCase(`${each.name}`);
996
- if (!each.isPathParam) {
997
- return {
998
- name: undefined,
999
- value: codegen_csharp_1.valueOf(each.expression)
1000
- };
1001
- }
1002
- const match = props.find(p => codegen_1.pascalCase(p.serializedName) === pascalName);
1003
- if (match) {
1004
- const defaultOfType = $this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(match.schema, true, $this.state).defaultOfType;
1005
- // match up vp name
1006
- const vp = allVPs.find(pp => codegen_1.pascalCase(pp.property.serializedName) === pascalName);
1007
- if (vp) {
1008
- return {
1009
- name: `InputObject.${vp.name}`,
1010
- value: `InputObject.${vp.name} ?? ${defaultOfType}`
1011
- };
1012
- }
1013
- // fall back!
1014
- 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 : '')}').`);
1015
- return {
1016
- name: `InputObject.${codegen_1.pascalCase((_d = (_c = match.language.csharp) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : '')}`,
1017
- value: `InputObject.${codegen_1.pascalCase((_f = (_e = match.language.csharp) === null || _e === void 0 ? void 0 : _e.name) !== null && _f !== void 0 ? _f : '')} ?? ${defaultOfType}`
1018
- };
1019
- }
1020
- console.error(`Unable to match identity parameter '${each.name}' member to appropriate virtual parameter. (Guessing '${pascalName}')`);
1021
- return {
1022
- name: `InputObject.${pascalName}`,
1023
- value: `InputObject.${pascalName}`
1024
- };
1025
- });
1026
- for (const opParam of idOpParams) {
1027
- if (opParam.name) {
1028
- yield codegen_csharp_1.If(codegen_csharp_1.IsNull(opParam.name), `ThrowTerminatingError(new ${powershell_declarations_1.ErrorRecord}(new global::System.Exception("InputObject has null value for ${opParam.name}"),string.Empty, ${powershell_declarations_1.ErrorCategory('InvalidArgument')}, InputObject));`);
1029
- }
1030
- }
1031
- yield `await this.${$this.$('Client').invokeMethod(`${(_b = apiCall.language.csharp) === null || _b === void 0 ? void 0 : _b.name}`, ...[...idOpParams.map(each => codegen_csharp_1.toExpression(each.value)), ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline]).implementation}`;
1032
- }
1033
- };
1034
- 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'; })) {
1035
- const parameters = [codegen_csharp_1.toExpression('InputObject.Id'), ...idOpParams.map(each => each.expression), ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline];
1036
- if (serializationMode) {
1037
- parameters.push(serializationMode);
1038
- }
1039
- yield codegen_csharp_1.If('InputObject?.Id != null', `await this.${$this.$('Client').invokeMethod(`${(_a = apiCall.language.csharp) === null || _a === void 0 ? void 0 : _a.name}ViaIdentity`, ...parameters).implementation}`);
1040
- yield codegen_csharp_1.Else(identityFromPathParams);
1041
1351
  }
1042
1352
  else {
1043
- yield identityFromPathParams;
1353
+ // assuming byte array output (via result)
1354
+ yield `global::System.IO.File.WriteAllBytes(${paths.value}[0],${result.value});`;
1044
1355
  }
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;
1045
1361
  }
1046
- else {
1047
- const parameters = [...operationParameters.map(each => each.expression), ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline];
1048
- if (serializationMode) {
1049
- parameters.push(serializationMode);
1050
- }
1051
- yield `await this.${$this.$('Client').invokeMethod(`${(_b = apiCall.language.csharp) === null || _b === void 0 ? void 0 : _b.name}`, ...parameters).implementation}`;
1052
- }
1053
- yield $this.eventListener.signal(powershell_declarations_1.Events.CmdletAfterAPICall);
1054
- };
1055
- if ($this.state.project.azure && operationParameters.find(each => each.expression && each.expression.value === 'SubscriptionId') && $this.operation.details.csharp.verb.toLowerCase() === 'get') {
1056
- yield 'foreach( var SubscriptionId in this.SubscriptionId )';
1057
- 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;
1058
1365
  }
1059
- else {
1060
- 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
+ }
1061
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
+ });
1062
1402
  });
1063
- const ure = new codegen_csharp_1.Parameter('urexception', { declaration: `${exports_1.ClientRuntime.fullName}.UndeclaredResponseException` });
1064
- yield codegen_csharp_1.Catch(ure, function* () {
1065
- 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(',')}})
1066
- {
1067
- ErrorDetails = new global::System.Management.Automation.ErrorDetails(${ure.value}.Message) { RecommendedAction = ${ure.value}.Action }
1068
- });`;
1069
- });
1070
- yield codegen_csharp_1.Finally(function* () {
1071
- yield $this.eventListener.signalNoCheck(powershell_declarations_1.Events.CmdletProcessRecordAsyncEnd);
1072
- });
1073
- });
1403
+ $this.add(responseMethod);
1404
+ }
1074
1405
  }
1075
1406
  NewImplementSerialization(operation) {
1076
1407
  const $this = this;
@@ -1100,7 +1431,7 @@ class CmdletClass extends codegen_csharp_1.Class {
1100
1431
  //_parametersBody = this._parametersBody,
1101
1432
  //_resourceGroupName = this._resourceGroupName,
1102
1433
  //_subscriptionId = this._subscriptionId,
1103
- yield codegen_csharp_1.Return(i);
1434
+ yield (0, codegen_csharp_1.Return)(i);
1104
1435
  });
1105
1436
  }
1106
1437
  }
@@ -1115,7 +1446,7 @@ class CmdletClass extends codegen_csharp_1.Class {
1115
1446
  description: 'A dictionary to carry over additional data for pipeline.'
1116
1447
  }));
1117
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.' });
1118
- extensibleParametersProp.get = codegen_csharp_1.toExpression(`${extensibleParameters.value} `);
1449
+ extensibleParametersProp.get = (0, codegen_csharp_1.toExpression)(`${extensibleParameters.value} `);
1119
1450
  this.add(extensibleParametersProp);
1120
1451
  }
1121
1452
  implementIEventListener() {
@@ -1126,11 +1457,11 @@ class CmdletClass extends codegen_csharp_1.Class {
1126
1457
  description: `The <see cref="${codegen_csharp_1.System.Threading.CancellationTokenSource}" /> for this operation.`
1127
1458
  }));
1128
1459
  const cancellationTokenSource = new codegen_csharp_1.Property('CancellationTokenSource', codegen_csharp_1.System.Threading.CancellationTokenSource, { description: 'Accessor for cancellationTokenSource.' });
1129
- cancellationTokenSource.get = codegen_csharp_1.toExpression(`${cts.value} `);
1460
+ cancellationTokenSource.get = (0, codegen_csharp_1.toExpression)(`${cts.value} `);
1130
1461
  cancellationTokenSource.set = new codegen_csharp_1.Statements(cts.assign('value'));
1131
1462
  this.add(cancellationTokenSource);
1132
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.` }));
1133
- 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`);
1134
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.` }));
1135
1466
  const id = new codegen_csharp_1.Parameter('id', codegen_csharp_1.dotnet.String, { description: 'The message id' });
1136
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>' });
@@ -1142,20 +1473,20 @@ class CmdletClass extends codegen_csharp_1.Class {
1142
1473
  description: 'Handles/Dispatches events during the call to the REST service.',
1143
1474
  returnsDescription: `A <see cref="${codegen_csharp_1.System.Threading.Tasks.Task()}" /> that will be complete when handling of the message is completed.`
1144
1475
  }));
1145
- signalMethod.push(codegen_csharp_1.Using('NoSynchronizationContext', ''));
1476
+ signalMethod.push((0, codegen_csharp_1.Using)('NoSynchronizationContext', ''));
1146
1477
  signalMethod.add(function* () {
1147
- 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)());
1148
1479
  // if the
1149
- const sw = codegen_csharp_1.Switch(id, [
1150
- 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* () {
1151
1482
  yield `WriteVerbose($"{(messageData().Message ?? ${codegen_csharp_1.System.String.Empty})}");`;
1152
- yield codegen_csharp_1.Return();
1483
+ yield (0, codegen_csharp_1.Return)();
1153
1484
  }),
1154
- codegen_csharp_1.TerminalCase(powershell_declarations_1.Events.Warning.value, function* () {
1485
+ (0, codegen_csharp_1.TerminalCase)(powershell_declarations_1.Events.Warning.value, function* () {
1155
1486
  yield `WriteWarning($"{(messageData().Message ?? ${codegen_csharp_1.System.String.Empty})}");`;
1156
- yield codegen_csharp_1.Return();
1487
+ yield (0, codegen_csharp_1.Return)();
1157
1488
  }),
1158
- codegen_csharp_1.TerminalCase(powershell_declarations_1.Events.Information.value, function* () {
1489
+ (0, codegen_csharp_1.TerminalCase)(powershell_declarations_1.Events.Information.value, function* () {
1159
1490
  if ($this.operation.asjob) {
1160
1491
  yield '// When an operation supports asjob, Information messages must go thru verbose.';
1161
1492
  yield `WriteVerbose($"INFORMATION: {(messageData().Message ?? ${codegen_csharp_1.System.String.Empty})}");`;
@@ -1165,17 +1496,17 @@ class CmdletClass extends codegen_csharp_1.Class {
1165
1496
  yield data.declarationStatement;
1166
1497
  yield 'WriteInformation(data.Message, new string[]{});';
1167
1498
  }
1168
- yield codegen_csharp_1.Return();
1499
+ yield (0, codegen_csharp_1.Return)();
1169
1500
  }),
1170
- codegen_csharp_1.TerminalCase(powershell_declarations_1.Events.Debug.value, function* () {
1501
+ (0, codegen_csharp_1.TerminalCase)(powershell_declarations_1.Events.Debug.value, function* () {
1171
1502
  yield `WriteDebug($"{(messageData().Message ?? ${codegen_csharp_1.System.String.Empty})}");`;
1172
- yield codegen_csharp_1.Return();
1503
+ yield (0, codegen_csharp_1.Return)();
1173
1504
  }),
1174
- codegen_csharp_1.TerminalCase(powershell_declarations_1.Events.Error.value, function* () {
1505
+ (0, codegen_csharp_1.TerminalCase)(powershell_declarations_1.Events.Error.value, function* () {
1175
1506
  yield 'WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) );';
1176
- yield codegen_csharp_1.Return();
1507
+ yield (0, codegen_csharp_1.Return)();
1177
1508
  }),
1178
- codegen_csharp_1.TerminalCase(powershell_declarations_1.Events.Progress.value, function* () {
1509
+ (0, codegen_csharp_1.TerminalCase)(powershell_declarations_1.Events.Progress.value, function* () {
1179
1510
  yield 'var data = messageData();';
1180
1511
  yield 'int progress = (int)data.Value;';
1181
1512
  yield 'string activityMessage, statusDescription;';
@@ -1198,14 +1529,14 @@ class CmdletClass extends codegen_csharp_1.Class {
1198
1529
  yield ' PercentComplete = progress,';
1199
1530
  yield 'RecordType = recordType';
1200
1531
  yield '});';
1201
- yield codegen_csharp_1.Return();
1532
+ yield (0, codegen_csharp_1.Return)();
1202
1533
  }),
1203
1534
  ]);
1204
1535
  if ($this.operation.asjob) {
1205
1536
  // if we support -AsJob, we support -NoWait
1206
- 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* () {
1207
1538
  yield 'var data = messageData();';
1208
- yield codegen_csharp_1.If('true == MyInvocation?.BoundParameters?.ContainsKey("NoWait")', function* () {
1539
+ yield (0, codegen_csharp_1.If)('true == MyInvocation?.BoundParameters?.ContainsKey("NoWait")', function* () {
1209
1540
  yield 'if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response)';
1210
1541
  yield '{';
1211
1542
  yield ' var asyncOperation = response.GetFirstHeader(@"Azure-AsyncOperation");';
@@ -1217,7 +1548,7 @@ class CmdletClass extends codegen_csharp_1.Class {
1217
1548
  yield ' return;';
1218
1549
  yield '}';
1219
1550
  });
1220
- yield codegen_csharp_1.Else(function* () {
1551
+ yield (0, codegen_csharp_1.Else)(function* () {
1221
1552
  yield 'if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response)';
1222
1553
  yield '{';
1223
1554
  yield ' int delay = (int)(response.Headers.RetryAfter?.Delta?.TotalSeconds ?? 30);';
@@ -1240,24 +1571,24 @@ class CmdletClass extends codegen_csharp_1.Class {
1240
1571
  if ($this.state.project.azure) {
1241
1572
  // in azure mode, we signal the AzAccount module with every event that makes it here.
1242
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 );`;
1243
- 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)());
1244
1575
  }
1245
1576
  else {
1246
1577
  // In Non-Azure Modes, emit the Signal method without coorelation and processrecordid
1247
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 ); `;
1248
- 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)());
1249
1580
  }
1250
1581
  yield `WriteDebug($"{id}: {(messageData().Message ?? ${codegen_csharp_1.System.String.Empty})}");`;
1251
1582
  // any handling of the signal on our side...
1252
1583
  });
1253
1584
  }
1254
1585
  NewAddPowershellParameters(operation) {
1255
- 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;
1256
1587
  const vps = operation.details.csharp.virtualParameters || {
1257
1588
  body: [],
1258
1589
  operation: [],
1259
1590
  };
1260
- for (const parameter of linq_1.values(operation.parameters)) {
1591
+ for (const parameter of (0, linq_1.values)(operation.parameters)) {
1261
1592
  // these are the parameters that this command expects
1262
1593
  parameter.schema;
1263
1594
  const td = this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(parameter.schema, true, this.state);
@@ -1291,11 +1622,11 @@ class CmdletClass extends codegen_csharp_1.Class {
1291
1622
  *get() {
1292
1623
  const metadata = operation.extensions['x-ms-metadata'];
1293
1624
  const profiles = metadata.profiles || new linq_1.Dictionary();
1294
- yield codegen_csharp_1.Switch(`${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.Profile`, function* () {
1295
- for (const { key: profileName, value: apiVersion } of linq_1.items(profiles)) {
1296
- 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}"`));
1297
1628
  }
1298
- 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]}"`));
1299
1630
  });
1300
1631
  }
1301
1632
  }));
@@ -1303,7 +1634,7 @@ class CmdletClass extends codegen_csharp_1.Class {
1303
1634
  }
1304
1635
  if (this.dropBodyParameter && parameter.details.csharp.isBodyParameter) {
1305
1636
  // we're supposed to use parameters for the body parameter instead of a big object
1306
- 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, {
1307
1638
  description: parameter.details.csharp.description,
1308
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}()`,
1309
1640
  access: codegen_csharp_1.Access.Private
@@ -1317,18 +1648,44 @@ class CmdletClass extends codegen_csharp_1.Class {
1317
1648
  const nullable = this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(vSchema, !!vParam.origin.required, this.state).isNullable;
1318
1649
  let cmdletParameter;
1319
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
+ }
1320
1677
  cmdletParameter = new codegen_csharp_1.Property(vParam.name, propertyType, {
1321
- 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}`}`),
1322
1679
  // get: toExpression(`null == ${expandedBodyParameter.value}.${vParam.origin.name} ? ${propertyType.defaultOfType} : (${propertyType.declaration}) ${expandedBodyParameter.value}.${vParam.origin.name}`),
1323
- 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`),
1324
1681
  new: PropertiesRequiringNew.has(vParam.name) ? codegen_csharp_1.Modifier.New : codegen_csharp_1.Modifier.None
1325
1682
  });
1326
1683
  }
1327
1684
  else {
1328
1685
  const fixedArrayPropertyType = this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(vSchema, true, this.state, true);
1329
1686
  cmdletParameter = new codegen_csharp_1.Property(vParam.name, fixedArrayPropertyType, {
1330
- get: codegen_csharp_1.toExpression(`${expandedBodyParameter.value}.${model_class_1.getVirtualPropertyName(vParam.origin) || vParam.origin.name}?.ToArray()${` ?? ${fixedArrayPropertyType.defaultOfType}`}`),
1331
- 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)`),
1332
1689
  new: PropertiesRequiringNew.has(vParam.name) ? codegen_csharp_1.Modifier.New : codegen_csharp_1.Modifier.None
1333
1690
  });
1334
1691
  }
@@ -1351,7 +1708,7 @@ class CmdletClass extends codegen_csharp_1.Class {
1351
1708
  // we have to figure out if this is a standalone dictionary or a hybrid object/dictionary.
1352
1709
  // if it's a hybrid, we have to create another parameter like -<XXX>AdditionalProperties and have that dump the contents into the dictionary
1353
1710
  // if it's a standalone dictionary, we can just use hashtable instead
1354
- if (linq_1.length(vSchema.properties) === 0) {
1711
+ if ((0, linq_1.length)(vSchema.properties) === 0) {
1355
1712
  // it's a pure dictionary
1356
1713
  // add an attribute for changing the exported type.
1357
1714
  cmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ExportAsAttribute, { parameters: [`typeof(${codegen_csharp_1.System.Collections.Hashtable})`] }));
@@ -1368,50 +1725,49 @@ class CmdletClass extends codegen_csharp_1.Class {
1368
1725
  cmdletParameter.setAccess = codegen_csharp_1.Access.Internal;
1369
1726
  cmdletParameter.getAccess = codegen_csharp_1.Access.Internal;
1370
1727
  // create a InputFileXXX for the parameter
1371
- 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']);
1372
1729
  const inputFileParameter = new codegen_csharp_1.Property(ifname, codegen_csharp_1.dotnet.String, {
1373
1730
  // get: toExpression(`${expandedBodyParameter.value}.${vParam.origin.name}${vParam.required ? '' : ` ?? ${propertyType.defaultOfType}`}`),
1374
1731
  set: function* () {
1375
- const provider = codegen_csharp_2.Local('provider');
1732
+ const provider = (0, codegen_csharp_2.Local)('provider');
1376
1733
  provider.initializer = undefined;
1377
- 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})`);
1378
1735
  yield paths.declarationStatement;
1379
- 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) );');
1380
- 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) );');
1381
1738
  yield cmdletParameter.assign(`global::System.IO.File.ReadAllBytes(${paths.value}[0])`);
1382
1739
  },
1383
- description: `Input File for ${cmdletParameter.name} (${codegen_1.escapeString(desc)})`
1740
+ description: `Input File for ${cmdletParameter.name} (${(0, codegen_1.escapeString)(desc)})`
1384
1741
  });
1385
- 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 || '.')})"`)] }));
1386
1743
  inputFileParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CategoryAttribute, { parameters: [`${powershell_declarations_1.ParameterCategory}.Body`] }));
1387
- if (linq_1.length(vParam.alias) > 0) {
1744
+ if ((0, linq_1.length)(vParam.alias) > 0) {
1388
1745
  inputFileParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.Alias, { parameters: vParam.alias.map(x => '"' + x + '"') }));
1389
1746
  }
1390
1747
  $this.add(inputFileParameter);
1391
1748
  }
1392
1749
  else {
1393
- 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 || '.')}"`)] }));
1394
1751
  cmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CategoryAttribute, { parameters: [`${powershell_declarations_1.ParameterCategory}.Body`] }));
1395
1752
  NewAddInfoAttribute(cmdletParameter, propertyType, !!vParam.required, false, desc, vParam.origin.property.serializedName);
1396
1753
  NewAddCompleterInfo(cmdletParameter, vParam);
1397
1754
  addParameterBreakingChange(cmdletParameter, vParam);
1398
- addPreviewMessage(cmdletParameter, vParam);
1755
+ addParameterPreviewMessage(cmdletParameter, vParam);
1399
1756
  addDefaultInfo(cmdletParameter, vParam);
1400
1757
  this.addDoNotExport(cmdletParameter, vParam);
1401
1758
  }
1402
- const isEnum = propertyType instanceof exports_1.EnumImplementation;
1403
- const hasEnum = propertyType instanceof exports_1.ArrayOf && propertyType.elementType instanceof exports_1.EnumImplementation;
1404
- if (isEnum || hasEnum) {
1405
- cmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ArgumentCompleterAttribute, { parameters: [`typeof(${hasEnum ? propertyType.elementType.declaration : propertyType.declaration})`] }));
1759
+ const addArgumentCompleter = isEnumImplementation(vParam.schema) || propertyType instanceof exports_1.ArrayOf && isEnumImplementation(propertyType.schema.elementType);
1760
+ if (addArgumentCompleter) {
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);
1406
1762
  }
1407
1763
  // add aliases if there is any
1408
- if (linq_1.length(vParam.alias) > 0) {
1764
+ if ((0, linq_1.length)(vParam.alias) > 0) {
1409
1765
  cmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.Alias, { parameters: vParam.alias.map(x => '"' + x + '"') }));
1410
1766
  }
1411
1767
  this.add(cmdletParameter);
1412
1768
  }
1413
1769
  const paramDictSchema = parameter.schema.type === codemodel_1.SchemaType.Dictionary ? parameter.schema :
1414
- 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) :
1415
1771
  undefined;
1416
1772
  if (paramDictSchema) {
1417
1773
  // if there is an additional properties on this type
@@ -1431,7 +1787,7 @@ class CmdletClass extends codegen_csharp_1.Class {
1431
1787
  }));
1432
1788
  this.bodyParameterInfo = {
1433
1789
  type: {
1434
- 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
1435
1791
  },
1436
1792
  valueType: paramDictSchema.elementType.type === codemodel_1.SchemaType.Any ? codegen_csharp_1.System.Object :
1437
1793
  this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(paramDictSchema.elementType, true, this.state)
@@ -1442,17 +1798,19 @@ class CmdletClass extends codegen_csharp_1.Class {
1442
1798
  }
1443
1799
  }
1444
1800
  if (this.isViaIdentity) {
1801
+ const viaIdentityRegex = /ViaIdentity\d?/g;
1802
+ this.inputObjectParameterName = `${this.name.split(viaIdentityRegex)[1].split('Expanded')[0]}InputObject`;
1445
1803
  // add in the pipeline parameter for the identity
1446
- 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');
1447
1805
  const idtd = this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(idschema, true, this.state);
1448
- const idParam = this.add(new codegen_csharp_1.BackedProperty('InputObject', idtd, {
1806
+ const idParam = this.add(new codegen_csharp_1.BackedProperty(this.inputObjectParameterName, idtd, {
1449
1807
  description: 'Identity Parameter'
1450
1808
  }));
1451
1809
  const parameters = [new codegen_csharp_1.LiteralExpression('Mandatory = true'), new codegen_csharp_1.LiteralExpression('HelpMessage = "Identity Parameter"'), new codegen_csharp_1.LiteralExpression('ValueFromPipeline = true')];
1452
1810
  idParam.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ParameterAttribute, { parameters }));
1453
1811
  idParam.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CategoryAttribute, { parameters: [`${powershell_declarations_1.ParameterCategory}.Path`] }));
1454
1812
  }
1455
- for (const vParam of linq_1.values(vps.operation)) {
1813
+ for (const vParam of (0, linq_1.values)(vps.operation)) {
1456
1814
  if (vParam.name === 'Host') {
1457
1815
  // skip 'Host'
1458
1816
  continue;
@@ -1486,13 +1844,13 @@ class CmdletClass extends codegen_csharp_1.Class {
1486
1844
  description: vParam.description
1487
1845
  }));
1488
1846
  const dictSchema = vSchema.type === codemodel_1.SchemaType.Dictionary ? vSchema :
1489
- 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) :
1490
1848
  undefined;
1491
1849
  if (dictSchema) {
1492
1850
  // we have to figure out if this is a standalone dictionary or a hybrid object/dictionary.
1493
1851
  // if it's a hybrid, we have to create another parameter like -<XXX>AdditionalProperties and have that dump the contents into the dictionary
1494
1852
  // if it's a standalone dictionary, we can just use hashtable instead
1495
- if (linq_1.length(vSchema.properties) === 0) {
1853
+ if ((0, linq_1.length)(vSchema.properties) === 0) {
1496
1854
  // it's a pure dictionary
1497
1855
  // change the property type to hashtable.
1498
1856
  // add an attribute to change the exported type.
@@ -1504,7 +1862,7 @@ class CmdletClass extends codegen_csharp_1.Class {
1504
1862
  }
1505
1863
  }
1506
1864
  this.thingsToSerialize.push(regularCmdletParameter);
1507
- 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) || '.'}"`)];
1508
1866
  if (!!origin && origin.details.csharp.isBodyParameter) {
1509
1867
  parameters.push(new codegen_csharp_1.LiteralExpression('ValueFromPipeline = true'));
1510
1868
  this.bodyParameter = regularCmdletParameter;
@@ -1514,24 +1872,24 @@ class CmdletClass extends codegen_csharp_1.Class {
1514
1872
  regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.AllowEmptyCollectionAttribute));
1515
1873
  }
1516
1874
  if (!!origin && !!propertyType) {
1517
- 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);
1518
1876
  }
1519
1877
  NewAddCompleterInfo(regularCmdletParameter, vParam);
1520
1878
  addParameterBreakingChange(regularCmdletParameter, vParam);
1521
- addPreviewMessage(regularCmdletParameter, vParam);
1879
+ addParameterPreviewMessage(regularCmdletParameter, vParam);
1522
1880
  addDefaultInfo(regularCmdletParameter, vParam);
1523
1881
  this.addDoNotExport(regularCmdletParameter, vParam);
1524
1882
  // add aliases if there is any
1525
- if (linq_1.length(vParam.alias) > 0) {
1883
+ if ((0, linq_1.length)(vParam.alias) > 0) {
1526
1884
  regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.Alias, { parameters: vParam.alias.map(x => '"' + x + '"') }));
1527
1885
  }
1528
1886
  const httpParam = origin ? origin.details.csharp.httpParameter : null;
1529
1887
  //const uid = httpParam ? httpParam.details.csharp.uid : 'no-parameter';
1530
1888
  if (httpParam) {
1531
1889
  // xichen: Is it safe to compare by csharp serializedName? Because we no longer have uid
1532
- 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); });
1533
1891
  if (cat) {
1534
- 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))}`] }));
1535
1893
  }
1536
1894
  }
1537
1895
  else {
@@ -1542,10 +1900,9 @@ class CmdletClass extends codegen_csharp_1.Class {
1542
1900
  }));
1543
1901
  }
1544
1902
  }
1545
- const isEnum = propertyType instanceof exports_1.EnumImplementation;
1546
- const hasEnum = propertyType instanceof exports_1.ArrayOf && propertyType.elementType instanceof exports_1.EnumImplementation;
1547
- if (propertyType && (isEnum || hasEnum)) {
1548
- regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ArgumentCompleterAttribute, { parameters: [`typeof(${hasEnum ? propertyType.elementType.declaration : propertyType.declaration})`] }));
1903
+ const addArgumentCompleter = isEnumImplementation(vParam.schema) || propertyType instanceof exports_1.ArrayOf && isEnumImplementation(propertyType.schema.elementType);
1904
+ if (addArgumentCompleter) {
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);
1549
1906
  }
1550
1907
  }
1551
1908
  const ifmatch = this.properties.find((v) => v.name.toLowerCase() === 'ifmatch');
@@ -1562,19 +1919,19 @@ class CmdletClass extends codegen_csharp_1.Class {
1562
1919
  addDoNotExport(cmdletParameter, vParam) {
1563
1920
  if (vParam.hidden) {
1564
1921
  this.state.message({
1565
- Channel: autorest_extension_base_1.Channel.Debug,
1922
+ Channel: extension_base_1.Channel.Debug,
1566
1923
  Text: `[DIRECTIVE] Applied 'hide' directive to parameter ${cmdletParameter.name}. Added attribute ${powershell_declarations_1.DoNotExportAttribute.declaration} to parameter.`,
1567
1924
  });
1568
1925
  cmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.DoNotExportAttribute));
1569
1926
  }
1570
1927
  }
1571
1928
  NewAddClassAttributes(operation, variantName) {
1572
- 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;
1573
1930
  const cmdletAttribParams = [
1574
- 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}"`,
1575
1932
  new codegen_csharp_1.StringExpression(variantName)
1576
1933
  ];
1577
- if (this.NewIsWritableCmdlet(operation)) {
1934
+ if ((0, command_operation_1.isWritableCmdlet)(operation) && !operation.details.csharp.supportShouldProcess) {
1578
1935
  cmdletAttribParams.push('SupportsShouldProcess = true');
1579
1936
  }
1580
1937
  if (this.clientsidePagination) {
@@ -1584,21 +1941,21 @@ class CmdletClass extends codegen_csharp_1.Class {
1584
1941
  this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.InternalExportAttribute));
1585
1942
  const noun = `${operation.details.csharp.subjectPrefix}${operation.details.csharp.subject}`;
1586
1943
  const cmdletName = `${operation.details.csharp.verb}-${noun}${operation.details.csharp.name ? `_${operation.details.csharp.name}` : ''}`;
1587
- 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.` });
1588
1945
  }
1589
1946
  this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CmdletAttribute, { parameters: cmdletAttribParams }));
1590
1947
  // add alias attribute if there is any aliases for this cmdlet
1591
- if (linq_1.length(operation.details.csharp.alias) > 0) {
1948
+ if ((0, linq_1.length)(operation.details.csharp.alias) > 0) {
1592
1949
  this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.Alias, { parameters: operation.details.csharp.alias.map((x) => '"' + x + '"') }));
1593
1950
  }
1594
1951
  let shouldAddPassThru = false;
1595
1952
  // set to hold the output types
1596
1953
  const outputTypes = new Set();
1597
- for (const httpOperation of linq_1.values(operation.callGraph)) {
1954
+ for (const httpOperation of (0, linq_1.values)(operation.callGraph)) {
1598
1955
  const pageableInfo = (_a = httpOperation.language.csharp) === null || _a === void 0 ? void 0 : _a.pageable;
1599
1956
  const v = httpOperation.responses && httpOperation.responses.length > 0 && httpOperation.responses[0] instanceof codemodel_1.SchemaResponse;
1600
1957
  // Add this for binary response in m4
1601
- 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)) {
1602
1959
  if (binary) {
1603
1960
  // if this is a stream, skip the output type.
1604
1961
  this.hasStreamOutput = true;
@@ -1606,10 +1963,10 @@ class CmdletClass extends codegen_csharp_1.Class {
1606
1963
  outputTypes.add(`typeof(${codegen_csharp_1.dotnet.Bool})`);
1607
1964
  }
1608
1965
  }
1609
- for (const schema of linq_1.values(httpOperation.responses).selectNonNullable(each => each.schema)) {
1610
- 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);
1611
1968
  // does the target type just wrap a single output?
1612
- const resultSchema = linq_1.length(props) !== 1 ? schema : props[0].schema;
1969
+ const resultSchema = schema;
1613
1970
  // make sure return type for boolean stays boolean!
1614
1971
  if (resultSchema.type === codemodel_1.SchemaType.Boolean ||
1615
1972
  (resultSchema.type === codemodel_1.SchemaType.Choice && resultSchema.choiceType.type === codemodel_1.SchemaType.Boolean && resultSchema.choices.length === 1) ||
@@ -1630,12 +1987,14 @@ class CmdletClass extends codegen_csharp_1.Class {
1630
1987
  type = typeDeclaration.elementTypeDeclaration;
1631
1988
  }
1632
1989
  else if (pageableInfo && pageableInfo.responseType === 'pageable') {
1633
- 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; })))) {
1634
1992
  //skip-for-time-being, since operationId does not support in m4 any more
1635
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`);
1636
1994
  throw new Error('An error needs to be more specific');
1637
1995
  }
1638
- 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;
1639
1998
  const nestedTypeDeclaration = this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(nestedSchema, true, this.state);
1640
1999
  type = nestedTypeDeclaration.elementTypeDeclaration;
1641
2000
  }
@@ -1652,8 +2011,8 @@ class CmdletClass extends codegen_csharp_1.Class {
1652
2011
  }
1653
2012
  // if any response does not return,
1654
2013
  // the cmdlet should have a PassThru parameter
1655
- shouldAddPassThru = shouldAddPassThru || linq_1.values(operation.callGraph)
1656
- .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 || [])))
1657
2016
  //.selectMany(responsesItem => responsesItem.value)
1658
2017
  .any(value => value.schema === undefined);
1659
2018
  if (outputTypes.size === 0) {
@@ -1664,11 +2023,13 @@ class CmdletClass extends codegen_csharp_1.Class {
1664
2023
  const breakingChange = operation.details.csharp.breakingChange;
1665
2024
  if (breakingChange.cmdlet) {
1666
2025
  const parameters = [];
1667
- if (breakingChange.cmdlet.deprecateByVersion) {
1668
- parameters.push(`"${breakingChange.cmdlet.deprecateByVersion}"`);
1669
- if (breakingChange.cmdlet.changeInEfectByDate)
1670
- 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.');
1671
2028
  }
2029
+ parameters.push(`"${breakingChange.cmdlet.deprecateByAzVersion}"`);
2030
+ parameters.push(`"${breakingChange.cmdlet.deprecateByVersion}"`);
2031
+ if (breakingChange.cmdlet.changeInEfectByDate)
2032
+ parameters.push(`"${breakingChange.cmdlet.changeInEfectByDate}"`);
1672
2033
  if (breakingChange.cmdlet.replacement)
1673
2034
  parameters.push(`ReplacementCmdletName = "${breakingChange.cmdlet.replacement}"`);
1674
2035
  if (breakingChange.cmdlet.changeDescription)
@@ -1678,11 +2039,13 @@ class CmdletClass extends codegen_csharp_1.Class {
1678
2039
  if (breakingChange.variant) {
1679
2040
  const parameters = [];
1680
2041
  parameters.push(`new string[] {"${breakingChange.variant.name}"}`);
1681
- if (breakingChange.variant.deprecateByVersion) {
1682
- parameters.push(`"${breakingChange.variant.deprecateByVersion}"`);
1683
- if (breakingChange.variant.changeInEfectByDate)
1684
- 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.');
1685
2044
  }
2045
+ parameters.push(`"${breakingChange.variant.deprecateByAzVersion}"`);
2046
+ parameters.push(`"${breakingChange.variant.deprecateByVersion}"`);
2047
+ if (breakingChange.variant.changeInEfectByDate)
2048
+ parameters.push(`"${breakingChange.variant.changeInEfectByDate}"`);
1686
2049
  if (breakingChange.variant.changeDescription)
1687
2050
  parameters.push(`ChangeDescription = "${breakingChange.variant.changeDescription}"`);
1688
2051
  this.add(new codegen_csharp_1.Attribute(exports_1.ClientRuntime.ParameterSetBreakingChangeAttribute, { parameters: parameters }));
@@ -1696,11 +2059,13 @@ class CmdletClass extends codegen_csharp_1.Class {
1696
2059
  else {
1697
2060
  parameters.push(`"${outputTypes.values().next().value.replace(/typeof\((.*)\)/, '$1')}"`);
1698
2061
  }
1699
- if (breakingChange.output.deprecateByVersion) {
1700
- parameters.push(`"${breakingChange.output.deprecateByVersion}"`);
1701
- if (breakingChange.output.changeInEfectByDate)
1702
- 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.');
1703
2064
  }
2065
+ parameters.push(`"${breakingChange.output.deprecateByAzVersion}"`);
2066
+ parameters.push(`"${breakingChange.output.deprecateByVersion}"`);
2067
+ if (breakingChange.output.changeInEfectByDate)
2068
+ parameters.push(`"${breakingChange.output.changeInEfectByDate}"`);
1704
2069
  if (breakingChange.output.replacement)
1705
2070
  parameters.push(`ReplacementCmdletOutputType = "${breakingChange.output.replacement}"`);
1706
2071
  if (breakingChange.output.deprecatedOutputProperties) {
@@ -1719,8 +2084,12 @@ class CmdletClass extends codegen_csharp_1.Class {
1719
2084
  }
1720
2085
  }
1721
2086
  //add preview message attribute for cmdlet
1722
- if (operation.details.csharp.previewMessage) {
1723
- 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 }));
1724
2093
  }
1725
2094
  this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.OutputTypeAttribute, { parameters: [...outputTypes] }));
1726
2095
  if (shouldAddPassThru) {
@@ -1732,8 +2101,8 @@ class CmdletClass extends codegen_csharp_1.Class {
1732
2101
  // If defines externalDocs for operation
1733
2102
  if (operation.details.default.externalDocs) {
1734
2103
  this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ExternalDocsAttribute, {
1735
- 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 : '')}`,
1736
- `${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 : '')}`]
1737
2106
  }));
1738
2107
  }
1739
2108
  this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.GeneratedAttribute));
@@ -1745,17 +2114,12 @@ class CmdletClass extends codegen_csharp_1.Class {
1745
2114
  });
1746
2115
  this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ProfileAttribute, { parameters: [...profileNames] }));
1747
2116
  }
1748
- this.operation.callGraph.forEach((operationInfo) => {
1749
- var _a;
1750
- let apiVersion = 'null';
1751
- if (operationInfo.apiVersions) {
1752
- apiVersion = operationInfo.apiVersions[0].version;
1753
- }
1754
- (_a = operationInfo.requests) === null || _a === void 0 ? void 0 : _a.forEach((request) => {
1755
- var _a, _b;
1756
- 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}"`] }));
1757
- });
1758
- });
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
+ }
1759
2123
  }
1760
2124
  }
1761
2125
  exports.CmdletClass = CmdletClass;