@azure-tools/typespec-go 0.14.2 → 0.15.0-dev.4

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 (280) hide show
  1. package/CHANGELOG.md +669 -0
  2. package/README.md +6 -4
  3. package/dist/{codegen.go/src/core/clientFactory.d.ts → src/codegen/core/client-factory.d.ts} +2 -2
  4. package/dist/src/codegen/core/client-factory.d.ts.map +1 -0
  5. package/dist/{codegen.go/src/core/clientFactory.js → src/codegen/core/client-factory.js} +29 -24
  6. package/dist/src/codegen/core/client-factory.js.map +1 -0
  7. package/dist/{codegen.go/src/core/cloudConfig.d.ts → src/codegen/core/cloud-config.d.ts} +2 -2
  8. package/dist/src/codegen/core/cloud-config.d.ts.map +1 -0
  9. package/dist/{codegen.go/src/core/cloudConfig.js → src/codegen/core/cloud-config.js} +10 -9
  10. package/dist/src/codegen/core/cloud-config.js.map +1 -0
  11. package/dist/{codegen.go/src → src/codegen}/core/constants.d.ts +1 -1
  12. package/dist/src/codegen/core/constants.d.ts.map +1 -0
  13. package/dist/{codegen.go/src → src/codegen}/core/constants.js +9 -9
  14. package/dist/src/codegen/core/constants.js.map +1 -0
  15. package/dist/{codegen.go/src → src/codegen}/core/errors.d.ts +1 -1
  16. package/dist/src/codegen/core/errors.d.ts.map +1 -0
  17. package/dist/src/codegen/core/errors.js.map +1 -0
  18. package/dist/{codegen.go/src → src/codegen}/core/example.d.ts +1 -1
  19. package/dist/src/codegen/core/example.d.ts.map +1 -0
  20. package/dist/{codegen.go/src → src/codegen}/core/example.js +155 -140
  21. package/dist/src/codegen/core/example.js.map +1 -0
  22. package/dist/{codegen.go/src → src/codegen}/core/gomod.d.ts +1 -1
  23. package/dist/src/codegen/core/gomod.d.ts.map +1 -0
  24. package/dist/{codegen.go/src → src/codegen}/core/gomod.js +8 -8
  25. package/dist/src/codegen/core/gomod.js.map +1 -0
  26. package/dist/{codegen.go/src → src/codegen}/core/helpers.d.ts +5 -5
  27. package/dist/src/codegen/core/helpers.d.ts.map +1 -0
  28. package/dist/{codegen.go/src → src/codegen}/core/helpers.js +308 -284
  29. package/dist/src/codegen/core/helpers.js.map +1 -0
  30. package/dist/{codegen.go/src → src/codegen}/core/imports.d.ts +1 -1
  31. package/dist/src/codegen/core/imports.d.ts.map +1 -0
  32. package/dist/{codegen.go/src → src/codegen}/core/imports.js +19 -18
  33. package/dist/src/codegen/core/imports.js.map +1 -0
  34. package/dist/{codegen.go/src → src/codegen}/core/interfaces.d.ts +1 -1
  35. package/dist/src/codegen/core/interfaces.d.ts.map +1 -0
  36. package/dist/{codegen.go/src → src/codegen}/core/interfaces.js +5 -5
  37. package/dist/src/codegen/core/interfaces.js.map +1 -0
  38. package/dist/{codegen.go/src → src/codegen}/core/license.d.ts +1 -1
  39. package/dist/src/codegen/core/license.d.ts.map +1 -0
  40. package/dist/src/codegen/core/license.js.map +1 -0
  41. package/dist/src/codegen/core/metadata.d.ts +3 -0
  42. package/dist/src/codegen/core/metadata.d.ts.map +1 -0
  43. package/dist/{codegen.go/src → src/codegen}/core/metadata.js +1 -1
  44. package/dist/src/codegen/core/metadata.js.map +1 -0
  45. package/dist/{codegen.go/src → src/codegen}/core/models.d.ts +2 -2
  46. package/dist/src/codegen/core/models.d.ts.map +1 -0
  47. package/dist/{codegen.go/src → src/codegen}/core/models.js +215 -184
  48. package/dist/src/codegen/core/models.js.map +1 -0
  49. package/dist/{codegen.go/src → src/codegen}/core/operations.d.ts +1 -1
  50. package/dist/src/codegen/core/operations.d.ts.map +1 -0
  51. package/dist/{codegen.go/src → src/codegen}/core/operations.js +383 -360
  52. package/dist/src/codegen/core/operations.js.map +1 -0
  53. package/dist/{codegen.go/src → src/codegen}/core/options.d.ts +1 -1
  54. package/dist/src/codegen/core/options.d.ts.map +1 -0
  55. package/dist/{codegen.go/src → src/codegen}/core/options.js +11 -11
  56. package/dist/src/codegen/core/options.js.map +1 -0
  57. package/dist/{codegen.go/src → src/codegen}/core/polymorphics.d.ts +1 -1
  58. package/dist/src/codegen/core/polymorphics.d.ts.map +1 -0
  59. package/dist/{codegen.go/src → src/codegen}/core/polymorphics.js +30 -30
  60. package/dist/src/codegen/core/polymorphics.js.map +1 -0
  61. package/dist/{codegen.go/src → src/codegen}/core/responses.d.ts +1 -1
  62. package/dist/src/codegen/core/responses.d.ts.map +1 -0
  63. package/dist/{codegen.go/src → src/codegen}/core/responses.js +28 -28
  64. package/dist/src/codegen/core/responses.js.map +1 -0
  65. package/dist/{codegen.go/src → src/codegen}/core/version.d.ts +1 -1
  66. package/dist/src/codegen/core/version.d.ts.map +1 -0
  67. package/dist/{codegen.go/src → src/codegen}/core/version.js +4 -4
  68. package/dist/src/codegen/core/version.js.map +1 -0
  69. package/dist/{codegen.go/src/core/xmlAdditionalProps.d.ts → src/codegen/core/xml-additional-props.d.ts} +2 -2
  70. package/dist/src/codegen/core/xml-additional-props.d.ts.map +1 -0
  71. package/dist/{codegen.go/src/core/xmlAdditionalProps.js → src/codegen/core/xml-additional-props.js} +11 -11
  72. package/dist/src/codegen/core/xml-additional-props.js.map +1 -0
  73. package/dist/{codegen.go/src → src/codegen}/emitter.d.ts +2 -2
  74. package/dist/src/codegen/emitter.d.ts.map +1 -0
  75. package/dist/{codegen.go/src → src/codegen}/emitter.js +58 -54
  76. package/dist/src/codegen/emitter.js.map +1 -0
  77. package/dist/{codegen.go/src → src/codegen}/fake/factory.d.ts +1 -1
  78. package/dist/src/codegen/fake/factory.d.ts.map +1 -0
  79. package/dist/{codegen.go/src → src/codegen}/fake/factory.js +22 -21
  80. package/dist/src/codegen/fake/factory.js.map +1 -0
  81. package/dist/{codegen.go/src → src/codegen}/fake/internal.d.ts +1 -1
  82. package/dist/src/codegen/fake/internal.d.ts.map +1 -0
  83. package/dist/{codegen.go/src → src/codegen}/fake/internal.js +13 -13
  84. package/dist/src/codegen/fake/internal.js.map +1 -0
  85. package/dist/{codegen.go/src → src/codegen}/fake/servers.d.ts +1 -1
  86. package/dist/src/codegen/fake/servers.d.ts.map +1 -0
  87. package/dist/{codegen.go/src → src/codegen}/fake/servers.js +332 -300
  88. package/dist/src/codegen/fake/servers.js.map +1 -0
  89. package/dist/src/codegen/index.d.ts +4 -0
  90. package/dist/src/codegen/index.d.ts.map +1 -0
  91. package/dist/{codegen.go/src → src/codegen}/index.js +3 -3
  92. package/dist/src/codegen/index.js.map +1 -0
  93. package/dist/{codemodel.go/src → src/codemodel}/client.d.ts +25 -25
  94. package/dist/src/codemodel/client.d.ts.map +1 -0
  95. package/dist/{codemodel.go/src → src/codemodel}/client.js +32 -32
  96. package/dist/src/codemodel/client.js.map +1 -0
  97. package/dist/{codemodel.go/src/codeModel.d.ts → src/codemodel/code-model.d.ts} +3 -3
  98. package/dist/src/codemodel/code-model.d.ts.map +1 -0
  99. package/dist/{codemodel.go/src/codeModel.js → src/codemodel/code-model.js} +1 -1
  100. package/dist/src/codemodel/code-model.js.map +1 -0
  101. package/dist/{codemodel.go/src → src/codemodel}/errors.d.ts +5 -5
  102. package/dist/src/codemodel/errors.d.ts.map +1 -0
  103. package/dist/{codemodel.go/src → src/codemodel}/errors.js +1 -1
  104. package/dist/src/codemodel/errors.js.map +1 -0
  105. package/dist/{codemodel.go/src → src/codemodel}/examples.d.ts +13 -13
  106. package/dist/src/codemodel/examples.d.ts.map +1 -0
  107. package/dist/{codemodel.go/src → src/codemodel}/examples.js +10 -10
  108. package/dist/src/codemodel/examples.js.map +1 -0
  109. package/dist/src/codemodel/index.d.ts +9 -0
  110. package/dist/src/codemodel/index.d.ts.map +1 -0
  111. package/dist/{codemodel.go/src → src/codemodel}/index.js +8 -8
  112. package/dist/src/codemodel/index.js.map +1 -0
  113. package/dist/{codemodel.go/src → src/codemodel}/method.d.ts +1 -1
  114. package/dist/src/codemodel/method.d.ts.map +1 -0
  115. package/dist/src/codemodel/method.js.map +1 -0
  116. package/dist/{codemodel.go/src → src/codemodel}/module.d.ts +8 -8
  117. package/dist/src/codemodel/module.d.ts.map +1 -0
  118. package/dist/{codemodel.go/src → src/codemodel}/module.js +12 -11
  119. package/dist/src/codemodel/module.js.map +1 -0
  120. package/dist/{codemodel.go/src → src/codemodel}/param.d.ts +26 -26
  121. package/dist/src/codemodel/param.d.ts.map +1 -0
  122. package/dist/{codemodel.go/src → src/codemodel}/param.js +56 -53
  123. package/dist/src/codemodel/param.js.map +1 -0
  124. package/dist/{codemodel.go/src → src/codemodel}/result.d.ts +15 -15
  125. package/dist/src/codemodel/result.d.ts.map +1 -0
  126. package/dist/{codemodel.go/src → src/codemodel}/result.js +27 -27
  127. package/dist/src/codemodel/result.js.map +1 -0
  128. package/dist/{codemodel.go/src → src/codemodel}/type.d.ts +30 -30
  129. package/dist/src/codemodel/type.d.ts.map +1 -0
  130. package/dist/{codemodel.go/src → src/codemodel}/type.js +77 -76
  131. package/dist/src/codemodel/type.js.map +1 -0
  132. package/dist/{typespec-go/src → src}/emitter.d.ts +2 -3
  133. package/dist/src/emitter.d.ts.map +1 -0
  134. package/dist/{typespec-go/src → src}/emitter.js +56 -45
  135. package/dist/src/emitter.js.map +1 -0
  136. package/dist/src/index.d.ts +3 -0
  137. package/dist/src/index.d.ts.map +1 -0
  138. package/dist/{typespec-go/src → src}/index.js +2 -2
  139. package/dist/src/index.js.map +1 -0
  140. package/dist/{typespec-go/src → src}/lib.d.ts +16 -16
  141. package/dist/src/lib.d.ts.map +1 -0
  142. package/dist/{typespec-go/src → src}/lib.js +60 -61
  143. package/dist/src/lib.js.map +1 -0
  144. package/dist/src/naming/index.d.ts +3 -0
  145. package/dist/src/naming/index.d.ts.map +1 -0
  146. package/dist/{naming.go/src → src/naming}/index.js +2 -2
  147. package/dist/src/naming/index.js.map +1 -0
  148. package/dist/src/naming/mappings.d.ts.map +1 -0
  149. package/dist/src/naming/mappings.js +294 -0
  150. package/dist/src/naming/mappings.js.map +1 -0
  151. package/dist/src/naming/naming.d.ts.map +1 -0
  152. package/dist/{naming.go/src → src/naming}/naming.js +10 -10
  153. package/dist/src/naming/naming.js.map +1 -0
  154. package/dist/{typespec-go/src → src}/tcgcadapter/adapter.d.ts +3 -3
  155. package/dist/src/tcgcadapter/adapter.d.ts.map +1 -0
  156. package/dist/{typespec-go/src → src}/tcgcadapter/adapter.js +35 -31
  157. package/dist/src/tcgcadapter/adapter.js.map +1 -0
  158. package/dist/{typespec-go/src → src}/tcgcadapter/clients.d.ts +1 -1
  159. package/dist/src/tcgcadapter/clients.d.ts.map +1 -0
  160. package/dist/{typespec-go/src → src}/tcgcadapter/clients.js +360 -310
  161. package/dist/src/tcgcadapter/clients.js.map +1 -0
  162. package/dist/{typespec-go/src → src}/tcgcadapter/errors.d.ts +2 -2
  163. package/dist/src/tcgcadapter/errors.d.ts.map +1 -0
  164. package/dist/{typespec-go/src → src}/tcgcadapter/errors.js +1 -1
  165. package/dist/src/tcgcadapter/errors.js.map +1 -0
  166. package/dist/{typespec-go/src → src}/tcgcadapter/helpers.d.ts +3 -3
  167. package/dist/src/tcgcadapter/helpers.d.ts.map +1 -0
  168. package/dist/{typespec-go/src → src}/tcgcadapter/helpers.js +41 -30
  169. package/dist/src/tcgcadapter/helpers.js.map +1 -0
  170. package/dist/{typespec-go/src → src}/tcgcadapter/metadata.d.ts +2 -2
  171. package/dist/src/tcgcadapter/metadata.d.ts.map +1 -0
  172. package/dist/src/tcgcadapter/metadata.js +47 -0
  173. package/dist/src/tcgcadapter/metadata.js.map +1 -0
  174. package/dist/{typespec-go/src → src}/tcgcadapter/types.d.ts +2 -2
  175. package/dist/src/tcgcadapter/types.d.ts.map +1 -0
  176. package/dist/{typespec-go/src → src}/tcgcadapter/types.js +221 -193
  177. package/dist/src/tcgcadapter/types.js.map +1 -0
  178. package/package.json +77 -62
  179. package/dist/codegen.go/src/core/clientFactory.d.ts.map +0 -1
  180. package/dist/codegen.go/src/core/clientFactory.js.map +0 -1
  181. package/dist/codegen.go/src/core/cloudConfig.d.ts.map +0 -1
  182. package/dist/codegen.go/src/core/cloudConfig.js.map +0 -1
  183. package/dist/codegen.go/src/core/constants.d.ts.map +0 -1
  184. package/dist/codegen.go/src/core/constants.js.map +0 -1
  185. package/dist/codegen.go/src/core/errors.d.ts.map +0 -1
  186. package/dist/codegen.go/src/core/errors.js.map +0 -1
  187. package/dist/codegen.go/src/core/example.d.ts.map +0 -1
  188. package/dist/codegen.go/src/core/example.js.map +0 -1
  189. package/dist/codegen.go/src/core/gomod.d.ts.map +0 -1
  190. package/dist/codegen.go/src/core/gomod.js.map +0 -1
  191. package/dist/codegen.go/src/core/helpers.d.ts.map +0 -1
  192. package/dist/codegen.go/src/core/helpers.js.map +0 -1
  193. package/dist/codegen.go/src/core/imports.d.ts.map +0 -1
  194. package/dist/codegen.go/src/core/imports.js.map +0 -1
  195. package/dist/codegen.go/src/core/interfaces.d.ts.map +0 -1
  196. package/dist/codegen.go/src/core/interfaces.js.map +0 -1
  197. package/dist/codegen.go/src/core/license.d.ts.map +0 -1
  198. package/dist/codegen.go/src/core/license.js.map +0 -1
  199. package/dist/codegen.go/src/core/metadata.d.ts +0 -3
  200. package/dist/codegen.go/src/core/metadata.d.ts.map +0 -1
  201. package/dist/codegen.go/src/core/metadata.js.map +0 -1
  202. package/dist/codegen.go/src/core/models.d.ts.map +0 -1
  203. package/dist/codegen.go/src/core/models.js.map +0 -1
  204. package/dist/codegen.go/src/core/operations.d.ts.map +0 -1
  205. package/dist/codegen.go/src/core/operations.js.map +0 -1
  206. package/dist/codegen.go/src/core/options.d.ts.map +0 -1
  207. package/dist/codegen.go/src/core/options.js.map +0 -1
  208. package/dist/codegen.go/src/core/polymorphics.d.ts.map +0 -1
  209. package/dist/codegen.go/src/core/polymorphics.js.map +0 -1
  210. package/dist/codegen.go/src/core/responses.d.ts.map +0 -1
  211. package/dist/codegen.go/src/core/responses.js.map +0 -1
  212. package/dist/codegen.go/src/core/version.d.ts.map +0 -1
  213. package/dist/codegen.go/src/core/version.js.map +0 -1
  214. package/dist/codegen.go/src/core/xmlAdditionalProps.d.ts.map +0 -1
  215. package/dist/codegen.go/src/core/xmlAdditionalProps.js.map +0 -1
  216. package/dist/codegen.go/src/emitter.d.ts.map +0 -1
  217. package/dist/codegen.go/src/emitter.js.map +0 -1
  218. package/dist/codegen.go/src/fake/factory.d.ts.map +0 -1
  219. package/dist/codegen.go/src/fake/factory.js.map +0 -1
  220. package/dist/codegen.go/src/fake/internal.d.ts.map +0 -1
  221. package/dist/codegen.go/src/fake/internal.js.map +0 -1
  222. package/dist/codegen.go/src/fake/servers.d.ts.map +0 -1
  223. package/dist/codegen.go/src/fake/servers.js.map +0 -1
  224. package/dist/codegen.go/src/index.d.ts +0 -4
  225. package/dist/codegen.go/src/index.d.ts.map +0 -1
  226. package/dist/codegen.go/src/index.js.map +0 -1
  227. package/dist/codemodel.go/src/client.d.ts.map +0 -1
  228. package/dist/codemodel.go/src/client.js.map +0 -1
  229. package/dist/codemodel.go/src/codeModel.d.ts.map +0 -1
  230. package/dist/codemodel.go/src/codeModel.js.map +0 -1
  231. package/dist/codemodel.go/src/errors.d.ts.map +0 -1
  232. package/dist/codemodel.go/src/errors.js.map +0 -1
  233. package/dist/codemodel.go/src/examples.d.ts.map +0 -1
  234. package/dist/codemodel.go/src/examples.js.map +0 -1
  235. package/dist/codemodel.go/src/index.d.ts +0 -9
  236. package/dist/codemodel.go/src/index.d.ts.map +0 -1
  237. package/dist/codemodel.go/src/index.js.map +0 -1
  238. package/dist/codemodel.go/src/method.d.ts.map +0 -1
  239. package/dist/codemodel.go/src/method.js.map +0 -1
  240. package/dist/codemodel.go/src/module.d.ts.map +0 -1
  241. package/dist/codemodel.go/src/module.js.map +0 -1
  242. package/dist/codemodel.go/src/param.d.ts.map +0 -1
  243. package/dist/codemodel.go/src/param.js.map +0 -1
  244. package/dist/codemodel.go/src/result.d.ts.map +0 -1
  245. package/dist/codemodel.go/src/result.js.map +0 -1
  246. package/dist/codemodel.go/src/type.d.ts.map +0 -1
  247. package/dist/codemodel.go/src/type.js.map +0 -1
  248. package/dist/naming.go/src/index.d.ts +0 -3
  249. package/dist/naming.go/src/index.d.ts.map +0 -1
  250. package/dist/naming.go/src/index.js.map +0 -1
  251. package/dist/naming.go/src/mappings.d.ts.map +0 -1
  252. package/dist/naming.go/src/mappings.js +0 -294
  253. package/dist/naming.go/src/mappings.js.map +0 -1
  254. package/dist/naming.go/src/naming.d.ts.map +0 -1
  255. package/dist/naming.go/src/naming.js.map +0 -1
  256. package/dist/typespec-go/src/emitter.d.ts.map +0 -1
  257. package/dist/typespec-go/src/emitter.js.map +0 -1
  258. package/dist/typespec-go/src/index.d.ts +0 -3
  259. package/dist/typespec-go/src/index.d.ts.map +0 -1
  260. package/dist/typespec-go/src/index.js.map +0 -1
  261. package/dist/typespec-go/src/lib.d.ts.map +0 -1
  262. package/dist/typespec-go/src/lib.js.map +0 -1
  263. package/dist/typespec-go/src/tcgcadapter/adapter.d.ts.map +0 -1
  264. package/dist/typespec-go/src/tcgcadapter/adapter.js.map +0 -1
  265. package/dist/typespec-go/src/tcgcadapter/clients.d.ts.map +0 -1
  266. package/dist/typespec-go/src/tcgcadapter/clients.js.map +0 -1
  267. package/dist/typespec-go/src/tcgcadapter/errors.d.ts.map +0 -1
  268. package/dist/typespec-go/src/tcgcadapter/errors.js.map +0 -1
  269. package/dist/typespec-go/src/tcgcadapter/helpers.d.ts.map +0 -1
  270. package/dist/typespec-go/src/tcgcadapter/helpers.js.map +0 -1
  271. package/dist/typespec-go/src/tcgcadapter/metadata.d.ts.map +0 -1
  272. package/dist/typespec-go/src/tcgcadapter/metadata.js +0 -21
  273. package/dist/typespec-go/src/tcgcadapter/metadata.js.map +0 -1
  274. package/dist/typespec-go/src/tcgcadapter/types.d.ts.map +0 -1
  275. package/dist/typespec-go/src/tcgcadapter/types.js.map +0 -1
  276. /package/dist/{codegen.go/src → src/codegen}/core/errors.js +0 -0
  277. /package/dist/{codegen.go/src → src/codegen}/core/license.js +0 -0
  278. /package/dist/{codemodel.go/src → src/codemodel}/method.js +0 -0
  279. /package/dist/{naming.go/src → src/naming}/mappings.d.ts +0 -0
  280. /package/dist/{naming.go/src → src/naming}/naming.d.ts +0 -0
@@ -2,11 +2,11 @@
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Licensed under the MIT License. See License.txt in the project root for license information.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- import * as go from '../../../codemodel.go/src/index.js';
6
- import * as naming from '../../../naming.go/src/naming.js';
7
- import * as helpers from './helpers.js';
8
- import { ImportManager } from './imports.js';
9
- import { CodegenError } from './errors.js';
5
+ import * as go from "../../codemodel/index.js";
6
+ import * as naming from "../../naming/naming.js";
7
+ import { CodegenError } from "./errors.js";
8
+ import * as helpers from "./helpers.js";
9
+ import { ImportManager } from "./imports.js";
10
10
  // represents the generated content for an operation group
11
11
  export class OperationGroupContent {
12
12
  name;
@@ -30,22 +30,24 @@ export function generateOperations(pkg, target, options) {
30
30
  if (pkg.clients.length === 0) {
31
31
  return operations;
32
32
  }
33
- const azureARM = target === 'azure-arm';
33
+ const azureARM = target === "azure-arm";
34
34
  for (const client of pkg.clients) {
35
35
  // the list of packages to import
36
36
  const imports = new ImportManager(pkg);
37
37
  if (client.methods.length > 0) {
38
38
  // add standard imports for clients with methods.
39
39
  // clients that are purely hierarchical (i.e. having no APIs) won't need them.
40
- imports.add('net/http');
41
- imports.add('github.com/Azure/azure-sdk-for-go/sdk/azcore/policy');
42
- imports.add('github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime');
40
+ imports.add("net/http");
41
+ imports.add("github.com/Azure/azure-sdk-for-go/sdk/azcore/policy");
42
+ imports.add("github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime");
43
43
  }
44
- imports.add(azureARM ? 'github.com/Azure/azure-sdk-for-go/sdk/azcore/arm' : 'github.com/Azure/azure-sdk-for-go/sdk/azcore');
44
+ imports.add(azureARM
45
+ ? "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
46
+ : "github.com/Azure/azure-sdk-for-go/sdk/azcore");
45
47
  // generate client type
46
48
  let clientText = helpers.formatDocComment(client.docs);
47
49
  clientText += "// Don't use this type directly, use ";
48
- if (client.instance?.kind === 'constructable' && client.instance.constructors.length === 1) {
50
+ if (client.instance?.kind === "constructable" && client.instance.constructors.length === 1) {
49
51
  clientText += `${client.instance.constructors[0].name}() instead.\n`;
50
52
  }
51
53
  else if (client.parent) {
@@ -58,12 +60,12 @@ export function generateOperations(pkg, target, options) {
58
60
  }
59
61
  }
60
62
  if (!accessorMethod) {
61
- throw new CodegenError('InternalError', `didn't find accessor method for client ${client.name} on parent client ${client.parent.name}`);
63
+ throw new CodegenError("InternalError", `didn't find accessor method for client ${client.name} on parent client ${client.parent.name}`);
62
64
  }
63
65
  clientText += `[${client.parent.name}.${accessorMethod}] instead.\n`;
64
66
  }
65
67
  else {
66
- clientText += 'a constructor function instead.\n';
68
+ clientText += "a constructor function instead.\n";
67
69
  }
68
70
  if (client.apiVersions.length > 0) {
69
71
  clientText += `//\n// Generated from API version`;
@@ -71,7 +73,7 @@ export function generateOperations(pkg, target, options) {
71
73
  clientText += `s ${client.apiVersions
72
74
  .map((v) => v.literal.literal)
73
75
  .sort()
74
- .join(', ')}\n`;
76
+ .join(", ")}\n`;
75
77
  }
76
78
  else {
77
79
  clientText += ` ${client.apiVersions[0].literal.literal}\n`;
@@ -79,12 +81,12 @@ export function generateOperations(pkg, target, options) {
79
81
  }
80
82
  const indent = new helpers.Indentation();
81
83
  clientText += `type ${client.name} struct {\n`;
82
- clientText += `${indent.get()}internal *${azureARM ? 'arm' : 'azcore'}.Client\n`;
84
+ clientText += `${indent.get()}internal *${azureARM ? "arm" : "azcore"}.Client\n`;
83
85
  // check for any optional host params
84
86
  const optionalParams = new Array();
85
87
  const isParamPointer = function (param) {
86
88
  // for client params, only optional and flag types are passed by pointer
87
- return param.style === 'flag' || param.style === 'optional';
89
+ return param.style === "flag" || param.style === "optional";
88
90
  };
89
91
  // now emit any client params (non parameterized host params case)
90
92
  if (client.parameters.length > 0) {
@@ -95,7 +97,7 @@ export function generateOperations(pkg, target, options) {
95
97
  }
96
98
  if (clientParam.group) {
97
99
  if (!addedGroups.has(clientParam.group.groupName)) {
98
- clientText += `${indent.get()}${naming.uncapitalize(clientParam.group.groupName)} ${!isParamPointer(clientParam) ? '' : '*'}${clientParam.group.groupName}\n`;
100
+ clientText += `${indent.get()}${naming.uncapitalize(clientParam.group.groupName)} ${!isParamPointer(clientParam) ? "" : "*"}${clientParam.group.groupName}\n`;
99
101
  addedGroups.add(clientParam.group.groupName);
100
102
  }
101
103
  continue;
@@ -113,17 +115,17 @@ export function generateOperations(pkg, target, options) {
113
115
  }
114
116
  }
115
117
  // end of client definition
116
- clientText += '}\n\n';
118
+ clientText += "}\n\n";
117
119
  clientText += generateConstructors(client, target, imports, indent);
118
120
  // generate client accessors and operations
119
- let opText = '';
121
+ let opText = "";
120
122
  for (const clientAccessor of client.clientAccessors) {
121
123
  imports.addForType(clientAccessor.returns);
122
124
  const subClientDecl = go.getTypeDeclaration(clientAccessor.returns, pkg);
123
125
  opText += helpers.formatDocComment(clientAccessor.docs);
124
126
  opText += `func (client *${client.name}) ${clientAccessor.name}(${getAPIParametersSig(clientAccessor, imports)}) *${subClientDecl} {\n`;
125
127
  opText += `${indent.get()}return &${subClientDecl}{\n`;
126
- const initFields = new Array('internal: client.internal');
128
+ const initFields = new Array("internal: client.internal");
127
129
  // propagate all client params
128
130
  for (const param of clientAccessor.parameters) {
129
131
  // by convention, the client accessor params have the
@@ -159,11 +161,14 @@ export function generateOperations(pkg, target, options) {
159
161
  }
160
162
  opText += generateOperation(method, options, imports, indent);
161
163
  opText += createProtocolRequest(azureARM, method, imports, indent);
162
- if (method.kind !== 'lroMethod') {
164
+ if (method.kind !== "lroMethod") {
163
165
  // LRO responses are handled elsewhere, with the exception of pageable LROs
164
166
  opText += createProtocolResponse(method, imports, indent);
165
167
  }
166
- if (go.isPageableMethod(method) && method.strategy?.kind === 'nextLink' && method.strategy.method && !nextPageMethods.includes(method.strategy.method)) {
168
+ if (go.isPageableMethod(method) &&
169
+ method.strategy?.kind === "nextLink" &&
170
+ method.strategy.method &&
171
+ !nextPageMethods.includes(method.strategy.method)) {
167
172
  // track the next page methods to generate as multiple operations can use the same next page operation
168
173
  nextPageMethods.push(method.strategy.method);
169
174
  }
@@ -189,12 +194,12 @@ export function generateOperations(pkg, target, options) {
189
194
  * @returns the client constructor code or the empty string
190
195
  */
191
196
  function generateConstructors(client, type, imports, indent) {
192
- if (client.instance?.kind !== 'constructable') {
193
- return '';
197
+ if (client.instance?.kind !== "constructable") {
198
+ return "";
194
199
  }
195
200
  const clientOptions = client.instance.options;
196
- let ctorText = '';
197
- if (clientOptions.kind === 'clientOptions') {
201
+ let ctorText = "";
202
+ if (clientOptions.kind === "clientOptions") {
198
203
  // for non-ARM, the options type will always be a parameter group
199
204
  ctorText += `// ${clientOptions.name} contains the optional values for creating a [${client.name}].\n`;
200
205
  ctorText += `type ${clientOptions.name} struct {\n${indent.get()}azcore.ClientOptions\n`;
@@ -206,13 +211,13 @@ function generateConstructors(client, type, imports, indent) {
206
211
  ctorText += helpers.formatDocCommentWithPrefix(naming.ensureNameCase(param.name), param.docs);
207
212
  if (go.isClientSideDefault(param.style)) {
208
213
  if (!param.docs.description && !param.docs.summary) {
209
- ctorText += '\n';
214
+ ctorText += "\n";
210
215
  }
211
- ctorText += `${indent.get()}${helpers.comment(`The default value is ${helpers.formatLiteralValue(param.style.defaultValue, false)}`, '// ')}.\n`;
216
+ ctorText += `${indent.get()}${helpers.comment(`The default value is ${helpers.formatLiteralValue(param.style.defaultValue, false)}`, "// ")}.\n`;
212
217
  }
213
218
  ctorText += `${indent.get()}${naming.ensureNameCase(param.name)} *${go.getTypeDeclaration(param.type, client.pkg)}\n`;
214
219
  }
215
- ctorText += '}\n\n';
220
+ ctorText += "}\n\n";
216
221
  }
217
222
  for (const constructor of client.instance.constructors) {
218
223
  const ctorParams = new Array();
@@ -242,28 +247,28 @@ function generateConstructors(client, type, imports, indent) {
242
247
  }
243
248
  }
244
249
  const emitProlog = function (optionsTypeName, tokenAuth, plOpts) {
245
- imports.add('github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime');
250
+ imports.add("github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime");
246
251
  let bodyText = `${indent.get()}if options == nil {\n`;
247
252
  bodyText += `${indent.push().get()}options = &${optionsTypeName}{}\n`;
248
253
  bodyText += `${indent.pop().get()}}\n`;
249
- let apiVersionConfig = '';
254
+ let apiVersionConfig = "";
250
255
  // check if there's an api version parameter
251
256
  let apiVersionParam;
252
257
  for (const param of consolidatedCtorParams) {
253
258
  switch (param.kind) {
254
- case 'headerScalarParam':
255
- case 'pathScalarParam':
256
- case 'queryScalarParam':
257
- case 'uriParam':
259
+ case "headerScalarParam":
260
+ case "pathScalarParam":
261
+ case "queryScalarParam":
262
+ case "uriParam":
258
263
  if (param.isApiVersion) {
259
264
  apiVersionParam = param;
260
265
  }
261
266
  }
262
267
  }
263
268
  if (tokenAuth) {
264
- imports.add('github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud');
265
- imports.add('fmt');
266
- imports.add('reflect');
269
+ imports.add("github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud");
270
+ imports.add("fmt");
271
+ imports.add("reflect");
267
272
  bodyText += `${indent.get()}if reflect.ValueOf(options.Cloud).IsZero() {\n`;
268
273
  bodyText += `${indent.push().get()}options.Cloud = cloud.AzurePublic\n`;
269
274
  bodyText += `${indent.pop().get()}}\n`;
@@ -278,17 +283,17 @@ function generateConstructors(client, type, imports, indent) {
278
283
  let location;
279
284
  let name;
280
285
  switch (apiVersionParam.kind) {
281
- case 'headerScalarParam':
282
- location = 'Header';
286
+ case "headerScalarParam":
287
+ location = "Header";
283
288
  name = apiVersionParam.headerName;
284
289
  break;
285
- case 'pathScalarParam':
286
- case 'uriParam':
287
- location = 'Path';
290
+ case "pathScalarParam":
291
+ case "uriParam":
292
+ location = "Path";
288
293
  // name isn't used for the path case
289
294
  break;
290
- case 'queryScalarParam':
291
- location = 'QueryParam';
295
+ case "queryScalarParam":
296
+ location = "QueryParam";
292
297
  name = apiVersionParam.queryParameter;
293
298
  break;
294
299
  }
@@ -299,22 +304,22 @@ function generateConstructors(client, type, imports, indent) {
299
304
  indent.pop(); // back to level 2
300
305
  }
301
306
  else {
302
- name = '';
307
+ name = "";
303
308
  }
304
309
  indent.push(); // level 3 for APIVersionOptions fields
305
310
  apiVersionConfig = `\n${indent.pop().get()}APIVersion: runtime.APIVersionOptions{${name}\n${indent.push().get()}Location: runtime.APIVersionLocation${location},\n${indent.pop().get()}},`;
306
311
  indent.pop(); // back to level 1
307
312
  if (!plOpts) {
308
- apiVersionConfig += '\n';
313
+ apiVersionConfig += "\n";
309
314
  }
310
315
  }
311
- bodyText += `${indent.get()}cl, err := azcore.NewClient(moduleName, moduleVersion, runtime.PipelineOptions{${apiVersionConfig}${plOpts ?? ''}}, &options.ClientOptions)\n`;
316
+ bodyText += `${indent.get()}cl, err := azcore.NewClient(moduleName, moduleVersion, runtime.PipelineOptions{${apiVersionConfig}${plOpts ?? ""}}, &options.ClientOptions)\n`;
312
317
  return bodyText;
313
318
  };
314
319
  // check if there's a credential parameter
315
320
  let credentialParam;
316
321
  for (const param of constructor.parameters) {
317
- if (param.kind === 'credentialParam') {
322
+ if (param.kind === "credentialParam") {
318
323
  credentialParam = param;
319
324
  break;
320
325
  }
@@ -322,12 +327,14 @@ function generateConstructors(client, type, imports, indent) {
322
327
  let prolog;
323
328
  if (credentialParam) {
324
329
  switch (credentialParam.type.kind) {
325
- case 'tokenCredential':
326
- imports.add('github.com/Azure/azure-sdk-for-go/sdk/azcore');
327
- paramDocs.push(helpers.formatCommentAsBulletItem('credential', { summary: 'used to authorize requests. Usually a credential from azidentity.' }));
330
+ case "tokenCredential":
331
+ imports.add("github.com/Azure/azure-sdk-for-go/sdk/azcore");
332
+ paramDocs.push(helpers.formatCommentAsBulletItem("credential", {
333
+ summary: "used to authorize requests. Usually a credential from azidentity.",
334
+ }));
328
335
  switch (clientOptions.kind) {
329
- case 'clientOptions': {
330
- imports.add('github.com/Azure/azure-sdk-for-go/sdk/azcore/policy');
336
+ case "clientOptions": {
337
+ imports.add("github.com/Azure/azure-sdk-for-go/sdk/azcore/policy");
331
338
  indent.push(); // level 2 for PipelineOptions fields
332
339
  indent.push(); // level 3 for BearerTokenOptions fields
333
340
  const tokenPolicyOpts = `&policy.BearerTokenOptions{\n${indent.get()}InsecureAllowCredentialWithHTTP: options.InsecureAllowCredentialWithHTTP,\n${indent.pop().get()}}`;
@@ -337,9 +344,9 @@ function generateConstructors(client, type, imports, indent) {
337
344
  prolog = emitProlog(go.getTypeDeclaration(clientOptions, client.pkg), true, tokenPolicy);
338
345
  break;
339
346
  }
340
- case 'armClientOptions':
347
+ case "armClientOptions":
341
348
  // this is the ARM case
342
- imports.add('github.com/Azure/azure-sdk-for-go/sdk/azcore/arm');
349
+ imports.add("github.com/Azure/azure-sdk-for-go/sdk/azcore/arm");
343
350
  prolog = `${indent.get()}cl, err := arm.NewClient(moduleName, moduleVersion, credential, options)\n`;
344
351
  break;
345
352
  }
@@ -351,23 +358,25 @@ function generateConstructors(client, type, imports, indent) {
351
358
  }
352
359
  // add client options last
353
360
  ctorParams.push(`options ${helpers.formatParameterTypeName(client.pkg, clientOptions)}`);
354
- paramDocs.push(helpers.formatCommentAsBulletItem('options', { summary: 'Contains optional client configuration. Pass nil to accept the default values.' }));
361
+ paramDocs.push(helpers.formatCommentAsBulletItem("options", {
362
+ summary: "Contains optional client configuration. Pass nil to accept the default values.",
363
+ }));
355
364
  ctorText += `// ${constructor.name} creates a new instance of ${client.name} with the specified values.\n`;
356
365
  for (const doc of paramDocs) {
357
366
  ctorText += doc;
358
367
  }
359
- ctorText += `func ${constructor.name}(${ctorParams.join(', ')}) (*${client.name}, error) {\n`;
368
+ ctorText += `func ${constructor.name}(${ctorParams.join(", ")}) (*${client.name}, error) {\n`;
360
369
  ctorText += prolog;
361
370
  ctorText += `${indent.get()}if err != nil {\n`;
362
371
  ctorText += `${indent.push().get()}return nil, err\n`;
363
372
  ctorText += `${indent.pop().get()}}\n`;
364
373
  // handle any client-side defaults
365
- if (clientOptions.kind === 'clientOptions') {
374
+ if (clientOptions.kind === "clientOptions") {
366
375
  for (const param of clientOptions.parameters) {
367
376
  if (go.isClientSideDefault(param.style)) {
368
377
  let name;
369
378
  if (go.isAPIVersionParameter(param)) {
370
- name = 'APIVersion';
379
+ name = "APIVersion";
371
380
  }
372
381
  else {
373
382
  name = naming.ensureNameCase(param.name);
@@ -384,7 +393,7 @@ function generateConstructors(client, type, imports, indent) {
384
393
  // the endpoint param is always the first ctor param
385
394
  const endpointParam = client.instance.constructors[0].parameters[0];
386
395
  if (client.instance.endpoint.supplemental.parameters.length > 0) {
387
- imports.add('strings');
396
+ imports.add("strings");
388
397
  ctorText += `${indent.get()}host := "${client.instance.endpoint.supplemental.path}"\n`;
389
398
  for (const param of client.instance.endpoint.supplemental.parameters) {
390
399
  ctorText += `${indent.get()}host = strings.ReplaceAll(host, "{${param.uriPathSegment}}", ${helpers.formatValue(param.name, param.type, imports)})\n`;
@@ -397,7 +406,7 @@ function generateConstructors(client, type, imports, indent) {
397
406
  }
398
407
  }
399
408
  // construct client literal
400
- let clientVar = 'client';
409
+ let clientVar = "client";
401
410
  // ensure clientVar doesn't collide with any params
402
411
  for (const param of consolidatedCtorParams) {
403
412
  if (param.name === clientVar) {
@@ -421,16 +430,16 @@ function generateConstructors(client, type, imports, indent) {
421
430
  indent.pop();
422
431
  ctorText += `${indent.get()}}\n`;
423
432
  ctorText += `${indent.get()}return ${clientVar}, nil\n`;
424
- ctorText += '}\n\n';
433
+ ctorText += "}\n\n";
425
434
  }
426
435
  return ctorText;
427
436
  }
428
437
  // use this to generate the code that will help process values returned in response headers
429
438
  function formatHeaderResponseValue(method, headerResp, respObj, zeroResp, imports, indent) {
430
439
  // dictionaries are handled slightly different so we do that first
431
- if (headerResp.kind === 'headerMapResponse') {
432
- imports.add('github.com/Azure/azure-sdk-for-go/sdk/azcore/to');
433
- imports.add('strings');
440
+ if (headerResp.kind === "headerMapResponse") {
441
+ imports.add("github.com/Azure/azure-sdk-for-go/sdk/azcore/to");
442
+ imports.add("strings");
434
443
  const headerPrefix = headerResp.headerName;
435
444
  let text = `${indent.get()}for hh := range resp.Header {\n`;
436
445
  text += `${indent.push().get()}if len(hh) > len("${headerPrefix}") && strings.EqualFold(hh[:len("${headerPrefix}")], "${headerPrefix}") {\n`;
@@ -445,52 +454,52 @@ function formatHeaderResponseValue(method, headerResp, respObj, zeroResp, import
445
454
  let text = `${indent.get()}if val := resp.Header.Get("${headerResp.headerName}"); val != "" {\n`;
446
455
  indent.push();
447
456
  let name = naming.uncapitalize(headerResp.fieldName);
448
- let byRef = '&';
457
+ let byRef = "&";
449
458
  switch (headerResp.type.kind) {
450
- case 'constant':
451
- case 'etag':
459
+ case "constant":
460
+ case "etag":
452
461
  text += `${indent.get()}${respObj}.${headerResp.fieldName} = (*${go.getTypeDeclaration(headerResp.type, method.receiver.type.pkg)})(&val)\n`;
453
462
  indent.pop();
454
463
  text += `${indent.get()}}\n`;
455
464
  return text;
456
- case 'encodedBytes':
465
+ case "encodedBytes":
457
466
  // a base-64 encoded value in string format
458
- imports.add('encoding/base64');
467
+ imports.add("encoding/base64");
459
468
  text += `${indent.get()}${name}, err := base64.${helpers.formatBytesEncoding(headerResp.type.encoding)}Encoding.DecodeString(val)\n`;
460
- byRef = '';
469
+ byRef = "";
461
470
  break;
462
- case 'literal':
471
+ case "literal":
463
472
  text += `${indent.get()}${respObj}.${headerResp.fieldName} = &val\n`;
464
473
  indent.pop();
465
474
  text += `${indent.get()}}\n`;
466
475
  return text;
467
- case 'scalar':
468
- text += emitScalarParsing(headerResp.type, 'val', name, imports, indent);
476
+ case "scalar":
477
+ text += emitScalarParsing(headerResp.type, "val", name, imports, indent);
469
478
  break;
470
- case 'string':
479
+ case "string":
471
480
  text += `${indent.get()}${respObj}.${headerResp.fieldName} = &val\n`;
472
481
  text += `${indent.pop().get()}}\n`;
473
482
  return text;
474
- case 'time':
475
- imports.add('time');
483
+ case "time":
484
+ imports.add("time");
476
485
  switch (headerResp.type.format) {
477
- case 'RFC1123':
478
- case 'RFC3339':
479
- case 'RFC7231':
480
- text += `${indent.get()}${name}, err := time.Parse(${headerResp.type.format === 'RFC3339' ? helpers.RFC3339Format : helpers.RFC1123Format}, val)\n`;
486
+ case "RFC1123":
487
+ case "RFC3339":
488
+ case "RFC7231":
489
+ text += `${indent.get()}${name}, err := time.Parse(${headerResp.type.format === "RFC3339" ? helpers.RFC3339Format : helpers.RFC1123Format}, val)\n`;
481
490
  break;
482
- case 'PlainDate':
491
+ case "PlainDate":
483
492
  text += `${indent.get()}${name}, err := time.Parse(${helpers.plainDateFormat}, val)\n`;
484
493
  break;
485
- case 'PlainTime':
494
+ case "PlainTime":
486
495
  text += `${indent.get()}${name}, err := time.Parse(${helpers.plainTimeFormat}, val)\n`;
487
496
  break;
488
- case 'Unix':
489
- imports.add('strconv');
490
- imports.add('github.com/Azure/azure-sdk-for-go/sdk/azcore/to');
497
+ case "Unix":
498
+ imports.add("strconv");
499
+ imports.add("github.com/Azure/azure-sdk-for-go/sdk/azcore/to");
491
500
  text += `${indent.get()}sec, err := strconv.ParseInt(val, 10, 64)\n`;
492
- name = 'to.Ptr(time.Unix(sec, 0))';
493
- byRef = '';
501
+ name = "to.Ptr(time.Unix(sec, 0))";
502
+ byRef = "";
494
503
  break;
495
504
  default:
496
505
  headerResp.type.format;
@@ -517,20 +526,22 @@ function formatHeaderResponseValue(method, headerResp, respObj, zeroResp, import
517
526
  * @returns the scalar parsing code
518
527
  */
519
528
  function emitScalarParsing(scalar, src, dst, imports, indent) {
520
- imports.add('strconv');
529
+ imports.add("strconv");
521
530
  switch (scalar.type) {
522
- case 'bool':
531
+ case "bool":
523
532
  return `${indent.get()}${dst}, err := strconv.ParseBool(${src})\n`;
524
- case 'float32':
525
- return `${indent.get()}${dst}32, err := strconv.ParseFloat(${src}, 32)\n` + `${indent.get()}${dst} := float32(${dst}32)\n`;
526
- case 'float64':
533
+ case "float32":
534
+ return (`${indent.get()}${dst}32, err := strconv.ParseFloat(${src}, 32)\n` +
535
+ `${indent.get()}${dst} := float32(${dst}32)\n`);
536
+ case "float64":
527
537
  return `${indent.get()}${dst}, err := strconv.ParseFloat(${src}, 64)\n`;
528
- case 'int32':
529
- return `${indent.get()}${dst}32, err := strconv.ParseInt(${src}, 10, 32)\n` + `${indent.get()}${dst} := int32(${dst}32)\n`;
530
- case 'int64':
538
+ case "int32":
539
+ return (`${indent.get()}${dst}32, err := strconv.ParseInt(${src}, 10, 32)\n` +
540
+ `${indent.get()}${dst} := int32(${dst}32)\n`);
541
+ case "int64":
531
542
  return `${indent.get()}${dst}, err := strconv.ParseInt(${src}, 10, 64)\n`;
532
543
  default:
533
- throw new CodegenError('InternalError', `unhandled scalar type ${scalar.type}`);
544
+ throw new CodegenError("InternalError", `unhandled scalar type ${scalar.type}`);
534
545
  }
535
546
  }
536
547
  /**
@@ -548,10 +559,10 @@ function emitScalarParsing(scalar, src, dst, imports, indent) {
548
559
  function getZeroReturnValue(method, apiType) {
549
560
  let returnType = `${method.returns.name}{}`;
550
561
  if (go.isLROMethod(method)) {
551
- if (apiType === 'lro' || apiType === 'op') {
562
+ if (apiType === "lro" || apiType === "op") {
552
563
  // the api returns a *Poller[T]
553
564
  // the operation returns an *http.Response
554
- returnType = 'nil';
565
+ returnType = "nil";
555
566
  }
556
567
  }
557
568
  return returnType;
@@ -566,17 +577,17 @@ function getZeroReturnValue(method, apiType) {
566
577
  * note that this can cause the function to return the empty string when segments.length === 1
567
578
  * @returns the sequence of nil checks
568
579
  */
569
- function generateNilChecks(segments, varName = 'page', omitLastSegment = false) {
580
+ function generateNilChecks(segments, varName = "page", omitLastSegment = false) {
570
581
  const checks = [];
571
582
  let segmentCount = segments.length;
572
583
  if (omitLastSegment) {
573
584
  segmentCount -= 1;
574
585
  }
575
586
  for (let i = 0; i < segmentCount; i++) {
576
- const currentPath = [varName, ...segments.map((segment) => segment.name).slice(0, i + 1)].join('.');
587
+ const currentPath = [varName, ...segments.map((segment) => segment.name).slice(0, i + 1)].join(".");
577
588
  checks.push(`${currentPath} != nil`);
578
589
  }
579
- return checks.join(' && ');
590
+ return checks.join(" && ");
580
591
  }
581
592
  /**
582
593
  * emits code that calls runtime.NewPager
@@ -588,7 +599,7 @@ function generateNilChecks(segments, varName = 'page', omitLastSegment = false)
588
599
  * @returns the complete call to runtime.NewPager(...)
589
600
  */
590
601
  function emitPagerDefinition(method, options, imports, indent) {
591
- imports.add('context');
602
+ imports.add("context");
592
603
  let text = `runtime.NewPager(runtime.PagingHandler[${method.returns.name}]{\n`;
593
604
  text += `${indent.push().get()}More: func(page ${method.returns.name}) bool {\n`;
594
605
  indent.push();
@@ -599,13 +610,13 @@ function emitPagerDefinition(method, options, imports, indent) {
599
610
  text += `${indent.get()}return ${nilChecks} && len(*page.${nextLinkPath}) > 0\n`;
600
611
  };
601
612
  switch (method.strategy.kind) {
602
- case 'continuationToken': {
613
+ case "continuationToken": {
603
614
  switch (method.strategy.responseToken.kind) {
604
- case 'headerScalarResponse':
615
+ case "headerScalarResponse":
605
616
  const tokenRespField = method.strategy.responseToken.fieldName;
606
617
  text += `${indent.get()}return page.${tokenRespField} != nil && len(*page.${tokenRespField}) > 0\n`;
607
618
  break;
608
- case 'nextLink':
619
+ case "nextLink":
609
620
  moreForNextLinkPath(method.strategy.responseToken);
610
621
  break;
611
622
  default:
@@ -613,7 +624,7 @@ function emitPagerDefinition(method, options, imports, indent) {
613
624
  }
614
625
  break;
615
626
  }
616
- case 'nextLink': {
627
+ case "nextLink": {
617
628
  moreForNextLinkPath(method.strategy);
618
629
  break;
619
630
  }
@@ -636,33 +647,33 @@ function emitPagerDefinition(method, options, imports, indent) {
636
647
  const emitStatusCodeCheckAndResponse = function (respVarName, indent) {
637
648
  let content = `${indent.get()}${helpers.buildIfBlock(indent, {
638
649
  condition: `!runtime.HasStatusCode(${respVarName}, http.StatusOK)`,
639
- body: (indent) => `${indent.get()}return ${getZeroReturnValue(method, 'op')}, runtime.NewResponseError(${respVarName})\n`,
650
+ body: (indent) => `${indent.get()}return ${getZeroReturnValue(method, "op")}, runtime.NewResponseError(${respVarName})\n`,
640
651
  })}\n`;
641
652
  content += `${indent.get()}return client.${method.naming.responseMethod}(${respVarName})\n`;
642
653
  return content;
643
654
  };
644
655
  if (method.strategy) {
645
656
  switch (method.strategy.kind) {
646
- case 'continuationToken': {
657
+ case "continuationToken": {
647
658
  const ms = method.strategy;
648
- const optionsCopy = 'nextOpts';
659
+ const optionsCopy = "nextOpts";
649
660
  text += `${indent.get()}${optionsCopy} := ${method.optionalParamsGroup.groupName}{}\n`;
650
661
  text += `${indent.get()}${helpers.buildIfBlock(indent, {
651
662
  condition: `${method.optionalParamsGroup.name} != nil`,
652
663
  body: (indent) => `${indent.get()}${optionsCopy} = *${method.optionalParamsGroup.name}\n`,
653
664
  })}\n`;
654
665
  let respToken;
655
- let nestedNilChecks = '';
666
+ let nestedNilChecks = "";
656
667
  switch (ms.responseToken.kind) {
657
- case 'headerScalarResponse':
668
+ case "headerScalarResponse":
658
669
  respToken = ms.responseToken.fieldName;
659
670
  break;
660
- case 'nextLink':
671
+ case "nextLink":
661
672
  respToken = helpers.buildNextLinkPath(ms.responseToken);
662
673
  if (ms.responseToken.nextLinkPath.length > 1) {
663
674
  // we don't need to check the last field for nil as we'll just
664
675
  // assign it to the corresponding field in the options param
665
- nestedNilChecks = ` && ${generateNilChecks(ms.responseToken.nextLinkPath, 'page', true)}`;
676
+ nestedNilChecks = ` && ${generateNilChecks(ms.responseToken.nextLinkPath, "page", true)}`;
666
677
  }
667
678
  break;
668
679
  }
@@ -670,17 +681,17 @@ function emitPagerDefinition(method, options, imports, indent) {
670
681
  condition: `page != nil${nestedNilChecks}`,
671
682
  body: (indent) => `${indent.get()}${optionsCopy}.${ms.requestToken.name} = page.${respToken}\n`,
672
683
  })}\n`;
673
- text += callCreateRequestWithErrCheck(method, 'req', indent, `&${optionsCopy}`);
674
- text += callPipelineDoWithErrCheck(method, 'req', 'resp', indent);
675
- text += emitStatusCodeCheckAndResponse('resp', indent);
684
+ text += callCreateRequestWithErrCheck(method, "req", indent, `&${optionsCopy}`);
685
+ text += callPipelineDoWithErrCheck(method, "req", "resp", indent);
686
+ text += emitStatusCodeCheckAndResponse("resp", indent);
676
687
  break;
677
688
  }
678
- case 'nextLink': {
689
+ case "nextLink": {
679
690
  const nextLinkPath = helpers.buildNextLinkPath(method.strategy);
680
691
  let nextLinkVar;
681
- if (method.kind === 'pageableMethod') {
692
+ if (method.kind === "pageableMethod") {
682
693
  text += `${indent.get()}nextLink := ""\n`;
683
- nextLinkVar = 'nextLink';
694
+ nextLinkVar = "nextLink";
684
695
  text += `${indent.get()}if page != nil {\n`;
685
696
  text += `${indent.push().get()}nextLink = *page.${nextLinkPath}\n`;
686
697
  text += `${indent.pop().get()}}\n`;
@@ -693,13 +704,15 @@ function emitPagerDefinition(method, options, imports, indent) {
693
704
  text += `${indent.pop().get()}}, `;
694
705
  // nextPageMethod might be absent in some cases, see https://github.com/Azure/autorest/issues/4393
695
706
  if (method.strategy.method) {
696
- const nextOpParams = helpers.getCreateRequestParametersSig(method.strategy.method).split(',');
707
+ const nextOpParams = helpers
708
+ .getCreateRequestParametersSig(method.strategy.method)
709
+ .split(",");
697
710
  // keep the parameter names from the name/type tuples and find nextLink param
698
711
  for (let i = 0; i < nextOpParams.length; ++i) {
699
- const paramName = nextOpParams[i].trim().split(' ')[0];
700
- const paramType = nextOpParams[i].trim().split(' ')[1];
701
- if (paramName.startsWith('next') && paramType === 'string') {
702
- nextOpParams[i] = 'encodedNextLink';
712
+ const paramName = nextOpParams[i].trim().split(" ")[0];
713
+ const paramType = nextOpParams[i].trim().split(" ")[1];
714
+ if (paramName.startsWith("next") && paramType === "string") {
715
+ nextOpParams[i] = "encodedNextLink";
703
716
  }
704
717
  else {
705
718
  nextOpParams[i] = paramName;
@@ -709,17 +722,17 @@ function emitPagerDefinition(method, options, imports, indent) {
709
722
  indent.push();
710
723
  text += `&runtime.FetcherForNextLinkOptions{\n`;
711
724
  text += `${indent.get()}NextReq: func(ctx context.Context, encodedNextLink string) (*policy.Request, error) {\n`;
712
- text += `${indent.push().get()}return client.${method.strategy.method.name}(${nextOpParams.join(', ')})\n`;
725
+ text += `${indent.push().get()}return client.${method.strategy.method.name}(${nextOpParams.join(", ")})\n`;
713
726
  text += `${indent.pop().get()}},\n`;
714
727
  text += `${indent.pop().get()}})\n`;
715
728
  }
716
- else if (method.nextLinkVerb !== 'get') {
729
+ else if (method.nextLinkVerb !== "get") {
717
730
  text += `&runtime.FetcherForNextLinkOptions{\n`;
718
731
  text += `${indent.push().get()}HTTPVerb: http.Method${naming.capitalize(method.nextLinkVerb)},\n`;
719
732
  text += `${indent.pop().get()}})\n`;
720
733
  }
721
734
  else {
722
- text += 'nil)\n';
735
+ text += "nil)\n";
723
736
  }
724
737
  text += `${indent.get()}if err != nil {\n`;
725
738
  text += `${indent.push().get()}return ${method.returns.name}{}, err\n`;
@@ -730,9 +743,9 @@ function emitPagerDefinition(method, options, imports, indent) {
730
743
  }
731
744
  else {
732
745
  // this is the singular page case, no fetcher helper required
733
- text += callCreateRequestWithErrCheck(method, 'req', indent);
734
- text += callPipelineDoWithErrCheck(method, 'req', 'resp', indent);
735
- text += emitStatusCodeCheckAndResponse('resp', indent);
746
+ text += callCreateRequestWithErrCheck(method, "req", indent);
747
+ text += callPipelineDoWithErrCheck(method, "req", "resp", indent);
748
+ text += emitStatusCodeCheckAndResponse("resp", indent);
736
749
  }
737
750
  text += `${indent.pop().get()}},\n`; // end Fetcher func
738
751
  if (options.injectSpans) {
@@ -754,8 +767,8 @@ function emitPagerDefinition(method, options, imports, indent) {
754
767
  function callCreateRequestWithErrCheck(method, reqVarName, indent, optionsParam) {
755
768
  const reqParams = helpers.getCreateRequestParameters(method, optionsParam);
756
769
  let text = `${indent.get()}${reqVarName}, err := client.${method.naming.requestMethod}(${reqParams})\n`;
757
- const zeroResp = getZeroReturnValue(method, 'op');
758
- text += `${indent.get()}${helpers.buildErrCheck(indent, 'err', zeroResp)}\n`;
770
+ const zeroResp = getZeroReturnValue(method, "op");
771
+ text += `${indent.get()}${helpers.buildErrCheck(indent, "err", zeroResp)}\n`;
759
772
  return text;
760
773
  }
761
774
  /**
@@ -770,17 +783,17 @@ function callCreateRequestWithErrCheck(method, reqVarName, indent, optionsParam)
770
783
  */
771
784
  function callPipelineDoWithErrCheck(method, reqVarName, respVarName, indent) {
772
785
  let text = `${indent.get()}${respVarName}, err := client.internal.Pipeline().Do(${reqVarName})\n`;
773
- const zeroResp = getZeroReturnValue(method, 'op');
774
- text += `${indent.get()}${helpers.buildErrCheck(indent, 'err', zeroResp)}\n`;
786
+ const zeroResp = getZeroReturnValue(method, "op");
787
+ text += `${indent.get()}${helpers.buildErrCheck(indent, "err", zeroResp)}\n`;
775
788
  return text;
776
789
  }
777
790
  function genRespErrorDoc(method) {
778
- if (!(method.returns.result?.kind === 'headAsBooleanResult') && !go.isPageableMethod(method)) {
791
+ if (!(method.returns.result?.kind === "headAsBooleanResult") && !go.isPageableMethod(method)) {
779
792
  // when head-as-boolean is enabled, no error is returned for 4xx status codes.
780
793
  // pager constructors don't return an error
781
- return '// If the operation fails it returns an *azcore.ResponseError type.\n';
794
+ return "// If the operation fails it returns an *azcore.ResponseError type.\n";
782
795
  }
783
- return '';
796
+ return "";
784
797
  }
785
798
  /**
786
799
  * returns the receiver definition for a client
@@ -789,16 +802,16 @@ function genRespErrorDoc(method) {
789
802
  * @returns the receiver definition
790
803
  */
791
804
  function getClientReceiverDefinition(receiver) {
792
- return `(${receiver.name} ${receiver.byValue ? '' : '*'}${receiver.type.name})`;
805
+ return `(${receiver.name} ${receiver.byValue ? "" : "*"}${receiver.type.name})`;
793
806
  }
794
807
  function generateOperation(method, options, imports, indent) {
795
808
  const params = getAPIParametersSig(method, imports);
796
- const returns = generateReturnsInfo(method, 'op');
809
+ const returns = generateReturnsInfo(method, "op");
797
810
  let methodName = method.name;
798
- if (method.kind === 'pageableMethod') {
811
+ if (method.kind === "pageableMethod") {
799
812
  methodName = fixUpMethodName(method);
800
813
  }
801
- let text = '';
814
+ let text = "";
802
815
  const respErrDoc = genRespErrorDoc(method);
803
816
  if (method.docs.summary || method.docs.description) {
804
817
  text += helpers.formatDocCommentWithPrefix(methodName, method.docs);
@@ -818,18 +831,18 @@ function generateOperation(method, options, imports, indent) {
818
831
  text += helpers.formatCommentAsBulletItem(param.name, param.docs);
819
832
  }
820
833
  }
821
- text += `func ${getClientReceiverDefinition(method.receiver)} ${methodName}(${params}) (${returns.join(', ')}) {\n`;
822
- if (method.kind === 'pageableMethod') {
834
+ text += `func ${getClientReceiverDefinition(method.receiver)} ${methodName}(${params}) (${returns.join(", ")}) {\n`;
835
+ if (method.kind === "pageableMethod") {
823
836
  text += `${indent.get()}return `;
824
837
  text += emitPagerDefinition(method, options, imports, indent);
825
- text += '}\n\n';
838
+ text += "}\n\n";
826
839
  return text;
827
840
  }
828
841
  text += `${indent.get()}var err error\n`;
829
842
  let operationName = `"${method.receiver.type.name}.${fixUpMethodName(method)}"`;
830
843
  if (options.generateFakes && options.injectSpans) {
831
844
  text += `${indent.get()}const operationName = ${operationName}\n`;
832
- operationName = 'operationName';
845
+ operationName = "operationName";
833
846
  }
834
847
  if (options.generateFakes) {
835
848
  text += `${indent.get()}ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, ${operationName})\n`;
@@ -838,16 +851,17 @@ function generateOperation(method, options, imports, indent) {
838
851
  text += `${indent.get()}ctx, endSpan := runtime.StartSpan(ctx, ${operationName}, client.internal.Tracer(), nil)\n`;
839
852
  text += `${indent.get()}defer func() { endSpan(err) }()\n`;
840
853
  }
841
- const zeroResp = getZeroReturnValue(method, 'op');
842
- text += callCreateRequestWithErrCheck(method, 'req', indent);
843
- text += callPipelineDoWithErrCheck(method, 'req', 'httpResp', indent);
854
+ const zeroResp = getZeroReturnValue(method, "op");
855
+ text += callCreateRequestWithErrCheck(method, "req", indent);
856
+ text += callPipelineDoWithErrCheck(method, "req", "httpResp", indent);
844
857
  text += `${indent.get()}if !runtime.HasStatusCode(httpResp, ${helpers.formatStatusCodes(method.httpStatusCodes)}) {\n`;
845
858
  indent.push();
846
859
  text += `${indent.get()}err = runtime.NewResponseError(httpResp)\n`;
847
860
  text += `${indent.get()}return ${zeroResp}, err\n`;
848
861
  text += `${indent.pop().get()}}\n`;
849
862
  // HAB with headers response is handled in protocol responder
850
- if (method.returns.result?.kind === 'headAsBooleanResult' && method.returns.headers.length === 0) {
863
+ if (method.returns.result?.kind === "headAsBooleanResult" &&
864
+ method.returns.headers.length === 0) {
851
865
  text += `${indent.get()}return ${method.returns.name}{${method.returns.result.fieldName}: httpResp.StatusCode >= 200 && httpResp.StatusCode < 300}, nil\n`;
852
866
  }
853
867
  else {
@@ -859,14 +873,14 @@ function generateOperation(method, options, imports, indent) {
859
873
  text += `${indent.get()}resp, err := client.${method.naming.responseMethod}(httpResp)\n`;
860
874
  text += `${indent.get()}return resp, err\n`;
861
875
  }
862
- else if (method.returns.result?.kind === 'binaryResult') {
876
+ else if (method.returns.result?.kind === "binaryResult") {
863
877
  text += `${indent.get()}return ${method.returns.name}{${method.returns.result.fieldName}: httpResp.Body}, nil\n`;
864
878
  }
865
879
  else {
866
880
  text += `${indent.get()}return ${method.returns.name}{}, nil\n`;
867
881
  }
868
882
  }
869
- text += '}\n\n';
883
+ text += "}\n\n";
870
884
  return text;
871
885
  }
872
886
  /**
@@ -880,16 +894,16 @@ function generateOperation(method, options, imports, indent) {
880
894
  * @returns setter code or the empty string
881
895
  */
882
896
  function emitMultipartContentTypeSetter(paramName, wireType, indent) {
883
- let text = '';
897
+ let text = "";
884
898
  const unwrapped = helpers.recursiveUnwrapMapSlice(wireType);
885
- if (unwrapped.kind !== 'multipartContent' || !unwrapped.contentType) {
899
+ if (unwrapped.kind !== "multipartContent" || !unwrapped.contentType) {
886
900
  return text;
887
901
  }
888
902
  switch (wireType.kind) {
889
- case 'multipartContent':
903
+ case "multipartContent":
890
904
  text += `${indent.get()}${paramName}.ContentType = ${unwrapped.contentType.literal}\n`;
891
905
  break;
892
- case 'slice':
906
+ case "slice":
893
907
  text += `${indent.get()}for i := range ${paramName} {\n`;
894
908
  text += `${indent.push().get()}${paramName}[i].ContentType = ${unwrapped.contentType.literal}\n`;
895
909
  text += `${indent.pop().get()}}\n`;
@@ -899,30 +913,30 @@ function emitMultipartContentTypeSetter(paramName, wireType, indent) {
899
913
  }
900
914
  function createProtocolRequest(azureARM, method, imports, indent) {
901
915
  let name = method.name;
902
- if (method.kind !== 'nextPageMethod') {
916
+ if (method.kind !== "nextPageMethod") {
903
917
  name = method.naming.requestMethod;
904
918
  }
905
919
  for (const param of method.parameters) {
906
- if (param.location !== 'method' || !go.isRequiredParameter(param.style)) {
920
+ if (param.location !== "method" || !go.isRequiredParameter(param.style)) {
907
921
  continue;
908
922
  }
909
923
  imports.addForType(param.type);
910
924
  }
911
- const returns = ['*policy.Request', 'error'];
912
- let text = `${helpers.comment(name, '// ')} creates the ${method.name} request.\n`;
913
- text += `func ${getClientReceiverDefinition(method.receiver)} ${name}(${helpers.getCreateRequestParametersSig(method)}) (${returns.join(', ')}) {\n`;
925
+ const returns = ["*policy.Request", "error"];
926
+ let text = `${helpers.comment(name, "// ")} creates the ${method.name} request.\n`;
927
+ text += `func ${getClientReceiverDefinition(method.receiver)} ${name}(${helpers.getCreateRequestParametersSig(method)}) (${returns.join(", ")}) {\n`;
914
928
  const hostParams = new Array();
915
929
  for (const parameter of method.receiver.type.parameters) {
916
- if (parameter.kind === 'uriParam') {
930
+ if (parameter.kind === "uriParam") {
917
931
  hostParams.push(parameter);
918
932
  }
919
933
  }
920
934
  let hostParam;
921
935
  if (azureARM) {
922
- hostParam = 'client.internal.Endpoint()';
936
+ hostParam = "client.internal.Endpoint()";
923
937
  }
924
- else if (method.receiver.type.instance?.kind === 'templatedHost') {
925
- imports.add('strings');
938
+ else if (method.receiver.type.instance?.kind === "templatedHost") {
939
+ imports.add("strings");
926
940
  // we have a templated host
927
941
  text += `${indent.get()}host := "${method.receiver.type.instance.path}"\n`;
928
942
  // get all the host params on the client
@@ -931,18 +945,18 @@ function createProtocolRequest(azureARM, method, imports, indent) {
931
945
  }
932
946
  // check for any method local host params
933
947
  for (const param of method.parameters) {
934
- if (param.location === 'method' && param.kind === 'uriParam') {
948
+ if (param.location === "method" && param.kind === "uriParam") {
935
949
  text += `${indent.get()}host = strings.ReplaceAll(host, "{${param.uriPathSegment}}", ${helpers.formatValue(helpers.getParamName(param), param.type, imports)})\n`;
936
950
  }
937
951
  }
938
- hostParam = 'host';
952
+ hostParam = "host";
939
953
  }
940
954
  else if (hostParams.length === 1) {
941
955
  // simple parameterized host case
942
- hostParam = 'client.' + hostParams[0].name;
956
+ hostParam = "client." + hostParams[0].name;
943
957
  }
944
958
  else {
945
- throw new CodegenError('InternalError', `no host or endpoint defined for method ${method.receiver.type.name}.${method.name}`);
959
+ throw new CodegenError("InternalError", `no host or endpoint defined for method ${method.receiver.type.name}.${method.name}`);
946
960
  }
947
961
  const methodParamGroups = helpers.getMethodParamGroups(method);
948
962
  const hasPathParams = methodParamGroups.pathParams.length > 0;
@@ -952,7 +966,7 @@ function createProtocolRequest(azureARM, method, imports, indent) {
952
966
  // actually reference the path params (i.e. no params with which to replace the tokens).
953
967
  // so, if a path contains tokens but there are no path params, skip emitting the path.
954
968
  const pathStr = method.httpPath;
955
- const pathContainsParms = pathStr.includes('{');
969
+ const pathContainsParms = pathStr.includes("{");
956
970
  if (hasPathParams || (!pathContainsParms && pathStr.length > 1)) {
957
971
  // there are path params, or the path doesn't contain tokens and is not "/" so emit it
958
972
  text += `${indent.get()}urlPath := "${method.httpPath}"\n`;
@@ -961,42 +975,42 @@ function createProtocolRequest(azureARM, method, imports, indent) {
961
975
  // helper to build nil checks for param groups
962
976
  const emitParamGroupCheck = function (param) {
963
977
  if (!param.group) {
964
- throw new CodegenError('InternalError', `emitParamGroupCheck called for ungrouped parameter ${param.name}`);
978
+ throw new CodegenError("InternalError", `emitParamGroupCheck called for ungrouped parameter ${param.name}`);
965
979
  }
966
- let client = '';
967
- if (param.location === 'client') {
968
- client = 'client.';
980
+ let client = "";
981
+ if (param.location === "client") {
982
+ client = "client.";
969
983
  }
970
984
  const paramGroupName = naming.uncapitalize(param.group.name);
971
985
  let optionalParamGroupCheck = `${client}${paramGroupName} != nil && `;
972
986
  if (param.group.required) {
973
- optionalParamGroupCheck = '';
987
+ optionalParamGroupCheck = "";
974
988
  }
975
989
  return `${indent.get()}if ${optionalParamGroupCheck}${client}${paramGroupName}.${naming.capitalize(param.name)} != nil {\n`;
976
990
  };
977
991
  if (hasPathParams) {
978
992
  // swagger defines path params, emit path and replace tokens
979
- imports.add('strings');
993
+ imports.add("strings");
980
994
  // replace path parameters
981
995
  for (const pp of methodParamGroups.pathParams) {
982
996
  let paramValue;
983
997
  let optionalPathSep = false;
984
- if (pp.style === 'literal') {
998
+ if (pp.style === "literal") {
985
999
  // literals are always scalar types and require no empty checks
986
1000
  paramValue = helpers.formatParamValue(pp, imports, indent);
987
1001
  }
988
- else if (pp.style === 'required' || pp.location === 'client') {
1002
+ else if (pp.style === "required" || pp.location === "client") {
989
1003
  // NOTE: we include client params here since they behave
990
1004
  // like required params (i.e. not grouped).
991
1005
  // emit check to ensure path param isn't an empty string
992
- if (pp.kind === 'pathScalarParam') {
1006
+ if (pp.kind === "pathScalarParam") {
993
1007
  const choiceIsString = function (type) {
994
- return type.kind === 'constant' && type.type === 'string';
1008
+ return type.kind === "constant" && type.type === "string";
995
1009
  };
996
1010
  // we only need to do this for params that have an underlying type of string
997
- if ((pp.type.kind === 'string' || choiceIsString(pp.type)) && !pp.omitEmptyStringCheck) {
1011
+ if ((pp.type.kind === "string" || choiceIsString(pp.type)) && !pp.omitEmptyStringCheck) {
998
1012
  const paramName = helpers.getParamName(pp);
999
- imports.add('errors');
1013
+ imports.add("errors");
1000
1014
  text += `${indent.get()}if ${paramName} == "" {\n`;
1001
1015
  text += `${indent.push().get()}return nil, errors.New("parameter ${paramName} cannot be empty")\n`;
1002
1016
  text += `${indent.pop().get()}}\n`;
@@ -1006,11 +1020,11 @@ function createProtocolRequest(azureARM, method, imports, indent) {
1006
1020
  // for collection-based path params, we emit the empty check
1007
1021
  // after calling helpers.formatParamValue as that will have the
1008
1022
  // var name that contains the slice.
1009
- if (pp.kind === 'pathCollectionParam') {
1023
+ if (pp.kind === "pathCollectionParam") {
1010
1024
  const paramName = helpers.getParamName(pp);
1011
1025
  const joinedParamName = `${paramName}Param`;
1012
1026
  text += `${indent.get()}${joinedParamName} := ${paramValue}\n`;
1013
- imports.add('errors');
1027
+ imports.add("errors");
1014
1028
  text += `${indent.get()}if len(${joinedParamName}) == 0 {\n`;
1015
1029
  text += `${indent.push().get()}return nil, errors.New("parameter ${paramName} cannot be empty")\n`;
1016
1030
  text += `${indent.pop().get()}}\n`;
@@ -1018,7 +1032,7 @@ function createProtocolRequest(azureARM, method, imports, indent) {
1018
1032
  }
1019
1033
  }
1020
1034
  else if (go.isClientSideDefault(pp.style)) {
1021
- const defaultValue = naming.uncapitalize(pp.name) + 'Default';
1035
+ const defaultValue = naming.uncapitalize(pp.name) + "Default";
1022
1036
  text += `${indent.get()}${defaultValue} := ${helpers.formatLiteralValue(pp.style.defaultValue, true)}\n`;
1023
1037
  text += emitParamGroupCheck(pp);
1024
1038
  text += `${indent.push().get()}${defaultValue} = ${helpers.getParamName(pp)}\n`;
@@ -1038,13 +1052,13 @@ function createProtocolRequest(azureARM, method, imports, indent) {
1038
1052
  // - /foo/bar/{optional}
1039
1053
  // - /foo/bar{/optional}
1040
1054
  // for the second case, we need to include a forward slash
1041
- if (method.httpPath[method.httpPath.indexOf(`{${pp.pathSegment}}`) - 1] !== '/') {
1055
+ if (method.httpPath[method.httpPath.indexOf(`{${pp.pathSegment}}`) - 1] !== "/") {
1042
1056
  optionalPathSep = true;
1043
1057
  }
1044
1058
  }
1045
1059
  const emitPathEscape = function () {
1046
1060
  if (pp.isEncoded) {
1047
- imports.add('net/url');
1061
+ imports.add("net/url");
1048
1062
  return `url.PathEscape(${paramValue})`;
1049
1063
  }
1050
1064
  return paramValue;
@@ -1068,16 +1082,18 @@ function createProtocolRequest(azureARM, method, imports, indent) {
1068
1082
  const encodedParams = methodParamGroups.encodedQueryParams;
1069
1083
  const unencodedParams = methodParamGroups.unencodedQueryParams;
1070
1084
  const emitQueryParam = function (qp, setter) {
1071
- let qpText = '';
1072
- if (qp.location === 'method' && go.isClientSideDefault(qp.style)) {
1085
+ let qpText;
1086
+ if (qp.location === "method" && go.isClientSideDefault(qp.style)) {
1073
1087
  qpText = emitClientSideDefault(qp, qp.style, (name, val) => {
1074
1088
  return `${indent.get()}reqQP.Set(${name}, ${val})`;
1075
1089
  }, imports, indent);
1076
1090
  }
1077
- else if (go.isRequiredParameter(qp.style) || go.isLiteralParameter(qp.style) || (qp.location === 'client' && go.isClientSideDefault(qp.style))) {
1091
+ else if (go.isRequiredParameter(qp.style) ||
1092
+ go.isLiteralParameter(qp.style) ||
1093
+ (qp.location === "client" && go.isClientSideDefault(qp.style))) {
1078
1094
  qpText = `${indent.get()}${setter}\n`;
1079
1095
  }
1080
- else if (qp.location === 'client' && !qp.group) {
1096
+ else if (qp.location === "client" && !qp.group) {
1081
1097
  // global optional param
1082
1098
  qpText = `${indent.get()}if client.${qp.name} != nil {\n`;
1083
1099
  qpText += `${indent.push().get()}${setter}\n`;
@@ -1097,27 +1113,27 @@ function createProtocolRequest(azureARM, method, imports, indent) {
1097
1113
  return helpers.sortAscending(a.queryParameter, b.queryParameter);
1098
1114
  })) {
1099
1115
  let setter;
1100
- if (qp.kind === 'queryCollectionParam' && qp.collectionFormat === 'multi') {
1116
+ if (qp.kind === "queryCollectionParam" && qp.collectionFormat === "multi") {
1101
1117
  setter = `for _, qv := range ${helpers.getParamName(qp)} {\n`;
1102
1118
  // emit a type conversion for the qv based on the array's element type
1103
1119
  let queryVal;
1104
1120
  const arrayQP = qp.type;
1105
1121
  switch (arrayQP.elementType.kind) {
1106
- case 'constant':
1122
+ case "constant":
1107
1123
  switch (arrayQP.elementType.type) {
1108
- case 'string':
1109
- queryVal = 'string(qv)';
1124
+ case "string":
1125
+ queryVal = "string(qv)";
1110
1126
  break;
1111
1127
  default:
1112
- imports.add('fmt');
1128
+ imports.add("fmt");
1113
1129
  queryVal = 'fmt.Sprintf("%d", qv)';
1114
1130
  }
1115
1131
  break;
1116
- case 'string':
1117
- queryVal = 'qv';
1132
+ case "string":
1133
+ queryVal = "qv";
1118
1134
  break;
1119
1135
  default:
1120
- imports.add('fmt');
1136
+ imports.add("fmt");
1121
1137
  queryVal = 'fmt.Sprintf("%v", qv)';
1122
1138
  }
1123
1139
  setter += `${indent.push().get()}reqQP.Add("${qp.queryParameter}", ${queryVal})\n`;
@@ -1133,7 +1149,7 @@ function createProtocolRequest(azureARM, method, imports, indent) {
1133
1149
  // thus not applicable for URIs. the correct URI encoding for SP is %20. note that literal '+'
1134
1150
  // characters are encoded by reqQP.Encode() as %2B so there's no risk of replacing them.
1135
1151
  // see https://www.rfc-editor.org/rfc/rfc3986 sections 2.1, 2.2, and 3.4
1136
- imports.add('strings');
1152
+ imports.add("strings");
1137
1153
  text += `${indent.get()}req.Raw().URL.RawQuery = strings.ReplaceAll(reqQP.Encode(), "+", "%20")\n`;
1138
1154
  }
1139
1155
  // tack on any unencoded params to the end
@@ -1148,7 +1164,7 @@ function createProtocolRequest(azureARM, method, imports, indent) {
1148
1164
  return helpers.sortAscending(a.queryParameter, b.queryParameter);
1149
1165
  })) {
1150
1166
  let setter;
1151
- if (qp.kind === 'queryCollectionParam' && qp.collectionFormat === 'multi') {
1167
+ if (qp.kind === "queryCollectionParam" && qp.collectionFormat === "multi") {
1152
1168
  setter = `for _, qv := range ${helpers.getParamName(qp)} {\n`;
1153
1169
  setter += `${indent.push().get()}unencodedParams = append(unencodedParams, "${qp.queryParameter}="+qv)\n`;
1154
1170
  setter += `${indent.pop().get()}}`;
@@ -1158,16 +1174,16 @@ function createProtocolRequest(azureARM, method, imports, indent) {
1158
1174
  }
1159
1175
  text += emitQueryParam(qp, setter);
1160
1176
  }
1161
- imports.add('strings');
1177
+ imports.add("strings");
1162
1178
  text += `${indent.get()}req.Raw().URL.RawQuery = strings.Join(unencodedParams, "&")\n`;
1163
1179
  }
1164
- if (method.kind !== 'nextPageMethod' && method.returns.result?.kind === 'binaryResult') {
1180
+ if (method.kind !== "nextPageMethod" && method.returns.result?.kind === "binaryResult") {
1165
1181
  // skip auto-body downloading for binary stream responses
1166
1182
  text += `${indent.get()}runtime.SkipBodyDownload(req)\n`;
1167
1183
  }
1168
1184
  // add specific request headers
1169
1185
  const emitHeaderSet = function (headerParam) {
1170
- if (headerParam.kind === 'headerMapParam') {
1186
+ if (headerParam.kind === "headerMapParam") {
1171
1187
  let headerText = `${indent.get()}for k, v := range ${helpers.getParamName(headerParam)} {\n`;
1172
1188
  headerText += `${indent.push().get()}if v != nil {\n`;
1173
1189
  headerText += `${indent.push().get()}req.Raw().Header["${headerParam.headerName}"+k] = []string{*v}\n`;
@@ -1175,7 +1191,7 @@ function createProtocolRequest(azureARM, method, imports, indent) {
1175
1191
  headerText += `${indent.pop().get()}}\n`;
1176
1192
  return headerText;
1177
1193
  }
1178
- else if (headerParam.location === 'method' && go.isClientSideDefault(headerParam.style)) {
1194
+ else if (headerParam.location === "method" && go.isClientSideDefault(headerParam.style)) {
1179
1195
  return emitClientSideDefault(headerParam, headerParam.style, (name, val) => {
1180
1196
  return `${indent.get()}req.Raw().Header[${name}] = []string{${val}}`;
1181
1197
  }, imports, indent);
@@ -1190,34 +1206,36 @@ function createProtocolRequest(azureARM, method, imports, indent) {
1190
1206
  })) {
1191
1207
  if (param.headerName.match(/^content-type$/i)) {
1192
1208
  // canonicalize content-type as req.SetBody checks for it via its canonicalized name :(
1193
- param.headerName = 'Content-Type';
1209
+ param.headerName = "Content-Type";
1194
1210
  // there's a corner case where we have a content-type param with no body
1195
1211
  // param. for this case we still need to set the header inline.
1196
1212
  const bodyParam = methodParamGroups.bodyParam;
1197
- if (bodyParam?.bodyFormat === 'binary' || bodyParam?.bodyFormat === 'Text') {
1213
+ if (bodyParam?.bodyFormat === "binary" || bodyParam?.bodyFormat === "Text") {
1198
1214
  // if the content-type is from a param, then the param will be passed
1199
1215
  // explicitly to runtime.SetBody() so don't emit code to set it inline.
1200
1216
  // NOTE: only binary/text payloads call runtime.SetBody().
1201
1217
  if (go.isClientSideDefault(param.style)) {
1202
- text += emitClientSideDefault(param, param.style, () => '', imports, indent);
1218
+ text += emitClientSideDefault(param, param.style, () => "", imports, indent);
1203
1219
  continue;
1204
1220
  }
1205
- else if (param.style === 'required') {
1221
+ else if (param.style === "required") {
1206
1222
  continue;
1207
1223
  }
1208
1224
  }
1209
1225
  }
1210
- if (param.headerName === 'Content-Type' && param.style === 'literal') {
1226
+ if (param.headerName === "Content-Type" && param.style === "literal") {
1211
1227
  // the content-type header will be set as part of emitSetBodyWithErrCheck
1212
1228
  // to handle cases where the body param is optional. we don't want to set
1213
1229
  // the content-type if the body is nil.
1214
1230
  // we do it like this as tsp specifies content-type while swagger does not.
1215
1231
  contentType = helpers.formatParamValue(param, imports, indent);
1216
1232
  }
1217
- else if (go.isRequiredParameter(param.style) || go.isLiteralParameter(param.style) || go.isClientSideDefault(param.style)) {
1233
+ else if (go.isRequiredParameter(param.style) ||
1234
+ go.isLiteralParameter(param.style) ||
1235
+ go.isClientSideDefault(param.style)) {
1218
1236
  text += emitHeaderSet(param);
1219
1237
  }
1220
- else if (param.location === 'client' && !param.group) {
1238
+ else if (param.location === "client" && !param.group) {
1221
1239
  // global optional param
1222
1240
  text += `${indent.get()}if client.${param.name} != nil {\n`;
1223
1241
  indent.push();
@@ -1239,7 +1257,7 @@ function createProtocolRequest(azureARM, method, imports, indent) {
1239
1257
  const multipartBodyParams = methodParamGroups.multipartBodyParams;
1240
1258
  const partialBodyParams = methodParamGroups.partialBodyParams;
1241
1259
  const emitSetBodyWithErrCheck = function (setBodyParam, contentType) {
1242
- let content = '';
1260
+ let content = "";
1243
1261
  if (contentType) {
1244
1262
  content += `${indent.get()}req.Raw().Header["Content-Type"] = []string{${contentType}}\n`;
1245
1263
  }
@@ -1252,36 +1270,36 @@ function createProtocolRequest(azureARM, method, imports, indent) {
1252
1270
  /** returns the source value for the content type */
1253
1271
  const getContentTypeValue = function (src) {
1254
1272
  switch (src.kind) {
1255
- case 'literal':
1273
+ case "literal":
1256
1274
  return helpers.formatLiteralValue(src, false);
1257
- case 'parameterRef': {
1275
+ case "parameterRef": {
1258
1276
  // find the param
1259
1277
  for (const param of method.parameters) {
1260
- if (param.kind === 'headerScalarParam' && param.name === src.name) {
1278
+ if (param.kind === "headerScalarParam" && param.name === src.name) {
1261
1279
  if (go.isClientSideDefault(param.style)) {
1262
1280
  return getClientSideDefaultVarName(param);
1263
1281
  }
1264
1282
  let paramName = helpers.getParamName(param);
1265
- if (param.type.kind === 'constant') {
1283
+ if (param.type.kind === "constant") {
1266
1284
  paramName = `string(${paramName})`;
1267
1285
  }
1268
1286
  return paramName;
1269
1287
  }
1270
1288
  }
1271
- throw new CodegenError('InternalError', `didn't find parameter reference ${src.name}`);
1289
+ throw new CodegenError("InternalError", `didn't find parameter reference ${src.name}`);
1272
1290
  }
1273
1291
  }
1274
1292
  };
1275
- if (bodyParam.bodyFormat === 'JSON' || bodyParam.bodyFormat === 'XML') {
1293
+ if (bodyParam.bodyFormat === "JSON" || bodyParam.bodyFormat === "XML") {
1276
1294
  // default to the body param name
1277
1295
  let body = helpers.getParamName(bodyParam);
1278
- if (bodyParam.type.kind === 'literal') {
1296
+ if (bodyParam.type.kind === "literal") {
1279
1297
  // if the value is constant, embed it directly
1280
1298
  body = helpers.formatLiteralValue(bodyParam.type, true);
1281
1299
  }
1282
- else if (bodyParam.bodyFormat === 'XML' && bodyParam.type.kind === 'slice') {
1300
+ else if (bodyParam.bodyFormat === "XML" && bodyParam.type.kind === "slice") {
1283
1301
  // for XML payloads, create a wrapper type if the payload is an array
1284
- imports.add('encoding/xml');
1302
+ imports.add("encoding/xml");
1285
1303
  text += `${indent.get()}type wrapper struct {\n`;
1286
1304
  indent.push();
1287
1305
  let tagName;
@@ -1294,49 +1312,49 @@ function createProtocolRequest(azureARM, method, imports, indent) {
1294
1312
  text += `${indent.get()}XMLName xml.Name \`xml:"${tagName}"\`\n`;
1295
1313
  const fieldName = naming.capitalize(bodyParam.name);
1296
1314
  let tag = go.getTypeDeclaration(bodyParam.type.elementType, method.receiver.type.pkg);
1297
- if (bodyParam.type.elementType.kind === 'model' && bodyParam.type.elementType.xml?.name) {
1315
+ if (bodyParam.type.elementType.kind === "model" && bodyParam.type.elementType.xml?.name) {
1298
1316
  tag = bodyParam.type.elementType.xml.name;
1299
1317
  }
1300
1318
  text += `${indent.get()}${fieldName} *${go.getTypeDeclaration(bodyParam.type, method.receiver.type.pkg)} \`xml:"${tag}"\`\n`;
1301
1319
  text += `${indent.pop().get()}}\n`;
1302
- let addr = '&';
1320
+ let addr = "&";
1303
1321
  if (!go.isRequiredParameter(bodyParam.style) && !bodyParam.byValue) {
1304
- addr = '';
1322
+ addr = "";
1305
1323
  }
1306
1324
  body = `wrapper{${fieldName}: ${addr}${body}}`;
1307
1325
  }
1308
- else if (bodyParam.type.kind === 'time' && bodyParam.type.format !== 'RFC3339') {
1326
+ else if (bodyParam.type.kind === "time" && bodyParam.type.format !== "RFC3339") {
1309
1327
  // wrap the body in the internal time type
1310
1328
  // no need for RFC3339 as the JSON marshaler defaults to that.
1311
- imports.add('github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/datetime');
1329
+ imports.add("github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/datetime");
1312
1330
  body = `datetime.${bodyParam.type.format}(${body})`;
1313
1331
  }
1314
1332
  else if (isArrayOfDateTimeForMarshalling(bodyParam.type)) {
1315
1333
  const timeInfo = isArrayOfDateTimeForMarshalling(bodyParam.type);
1316
- let elementPtr = '*';
1334
+ let elementPtr = "*";
1317
1335
  if (timeInfo?.elemByVal) {
1318
- elementPtr = '';
1336
+ elementPtr = "";
1319
1337
  }
1320
- imports.add('github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/datetime');
1338
+ imports.add("github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/datetime");
1321
1339
  text += `${indent.get()}aux := make([]${elementPtr}datetime.${timeInfo?.format}, len(${body}))\n`;
1322
1340
  text += `${indent.get()}for i := 0; i < len(${body}); i++ {\n`;
1323
1341
  text += `${indent.push().get()}aux[i] = (${elementPtr}datetime.${timeInfo?.format})(${body}[i])\n`;
1324
1342
  text += `${indent.pop().get()}}\n`;
1325
- body = 'aux';
1343
+ body = "aux";
1326
1344
  }
1327
1345
  else if (isMapOfDateTime(bodyParam.type)) {
1328
- let timeType = isMapOfDateTime(bodyParam.type);
1329
- imports.add('github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/datetime');
1346
+ const timeType = isMapOfDateTime(bodyParam.type);
1347
+ imports.add("github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/datetime");
1330
1348
  text += `${indent.get()}aux := map[string]*datetime.${timeType}{}\n`;
1331
1349
  text += `${indent.get()}for k, v := range ${body} {\n`;
1332
1350
  text += `${indent.push().get()}aux[k] = (*datetime.${timeType})(v)\n`;
1333
1351
  text += `${indent.pop().get()}}\n`;
1334
- body = 'aux';
1352
+ body = "aux";
1335
1353
  }
1336
1354
  let setBody = `runtime.MarshalAs${getMediaFormat(bodyParam.type, bodyParam.bodyFormat, `req, ${body}`)}`;
1337
- if (bodyParam.type.kind === 'rawJSON') {
1338
- imports.add('bytes');
1339
- imports.add('github.com/Azure/azure-sdk-for-go/sdk/azcore/streaming');
1355
+ if (bodyParam.type.kind === "rawJSON") {
1356
+ imports.add("bytes");
1357
+ imports.add("github.com/Azure/azure-sdk-for-go/sdk/azcore/streaming");
1340
1358
  setBody = `req.SetBody(streaming.NopCloser(bytes.NewReader(${body})), "application/${bodyParam.bodyFormat.toLowerCase()}")`;
1341
1359
  }
1342
1360
  if (go.isRequiredParameter(bodyParam.style) || go.isLiteralParameter(bodyParam.style)) {
@@ -1353,7 +1371,7 @@ function createProtocolRequest(azureARM, method, imports, indent) {
1353
1371
  text += `${indent.get()}return req, nil\n`;
1354
1372
  }
1355
1373
  }
1356
- else if (bodyParam.bodyFormat === 'binary') {
1374
+ else if (bodyParam.bodyFormat === "binary") {
1357
1375
  if (go.isRequiredParameter(bodyParam.style)) {
1358
1376
  text += emitSetBodyWithErrCheck(`req.SetBody(${bodyParam.name}, ${getContentTypeValue(bodyParam.contentType)})`, contentType);
1359
1377
  text += `${indent.get()}return req, nil\n`;
@@ -1368,9 +1386,9 @@ function createProtocolRequest(azureARM, method, imports, indent) {
1368
1386
  text += `${indent.get()}return req, nil\n`;
1369
1387
  }
1370
1388
  }
1371
- else if (bodyParam.bodyFormat === 'Text') {
1372
- imports.add('strings');
1373
- imports.add('github.com/Azure/azure-sdk-for-go/sdk/azcore/streaming');
1389
+ else if (bodyParam.bodyFormat === "Text") {
1390
+ imports.add("strings");
1391
+ imports.add("github.com/Azure/azure-sdk-for-go/sdk/azcore/streaming");
1374
1392
  if (go.isRequiredParameter(bodyParam.style)) {
1375
1393
  text += `${indent.get()}body := streaming.NopCloser(strings.NewReader(${bodyParam.name}))\n`;
1376
1394
  text += emitSetBodyWithErrCheck(`req.SetBody(body, ${getContentTypeValue(bodyParam.contentType)})`, contentType);
@@ -1429,7 +1447,9 @@ function createProtocolRequest(azureARM, method, imports, indent) {
1429
1447
  // note that tsp only allows homogeneous content types, which is why it's safe
1430
1448
  // to unwrap the first param's type and check its contentType field.
1431
1449
  text += emitMultipartContentTypeSetter(multipartBodyParams[0].name, multipartBodyParams[0].type, indent);
1432
- if (multipartBodyParams.length === 1 && multipartBodyParams[0].type.kind === 'model' && multipartBodyParams[0].type.annotations.multipartFormData) {
1450
+ if (multipartBodyParams.length === 1 &&
1451
+ multipartBodyParams[0].type.kind === "model" &&
1452
+ multipartBodyParams[0].type.annotations.multipartFormData) {
1433
1453
  // emit content type setters for model fields that have a fixed content type.
1434
1454
  // toMultipartFormData() converts the model to map[string]any but doesn't set ContentType,
1435
1455
  // so we must set it on each MultipartContent field before the conversion.
@@ -1462,7 +1482,7 @@ function createProtocolRequest(azureARM, method, imports, indent) {
1462
1482
  }
1463
1483
  else if (formBodyParams.length > 0) {
1464
1484
  const emitFormData = function (param, setter) {
1465
- let formDataText = '';
1485
+ let formDataText;
1466
1486
  if (go.isRequiredParameter(param.style)) {
1467
1487
  formDataText = `${indent.get()}${setter}\n`;
1468
1488
  }
@@ -1473,9 +1493,9 @@ function createProtocolRequest(azureARM, method, imports, indent) {
1473
1493
  }
1474
1494
  return formDataText;
1475
1495
  };
1476
- imports.add('net/url');
1477
- imports.add('strings');
1478
- imports.add('github.com/Azure/azure-sdk-for-go/sdk/azcore/streaming');
1496
+ imports.add("net/url");
1497
+ imports.add("strings");
1498
+ imports.add("github.com/Azure/azure-sdk-for-go/sdk/azcore/streaming");
1479
1499
  text += `${indent.get()}formData := url.Values{}\n`;
1480
1500
  // find all the form body params
1481
1501
  for (const param of formBodyParams) {
@@ -1489,7 +1509,7 @@ function createProtocolRequest(azureARM, method, imports, indent) {
1489
1509
  else {
1490
1510
  text += `${indent.get()}return req, nil\n`;
1491
1511
  }
1492
- text += '}\n\n';
1512
+ text += "}\n\n";
1493
1513
  return text;
1494
1514
  }
1495
1515
  /**
@@ -1499,7 +1519,7 @@ function createProtocolRequest(azureARM, method, imports, indent) {
1499
1519
  * @returns the var name
1500
1520
  */
1501
1521
  function getClientSideDefaultVarName(param) {
1502
- return naming.uncapitalize(param.name) + 'Default';
1522
+ return naming.uncapitalize(param.name) + "Default";
1503
1523
  }
1504
1524
  function emitClientSideDefault(param, csd, setterFormat, imports, indent) {
1505
1525
  const defaultVar = getClientSideDefaultVarName(param);
@@ -1509,12 +1529,12 @@ function emitClientSideDefault(param, csd, setterFormat, imports, indent) {
1509
1529
  text += `${indent.pop().get()}}\n`;
1510
1530
  let serializedName;
1511
1531
  switch (param.kind) {
1512
- case 'headerCollectionParam':
1513
- case 'headerScalarParam':
1532
+ case "headerCollectionParam":
1533
+ case "headerScalarParam":
1514
1534
  serializedName = param.headerName;
1515
1535
  break;
1516
- case 'queryCollectionParam':
1517
- case 'queryScalarParam':
1536
+ case "queryCollectionParam":
1537
+ case "queryScalarParam":
1518
1538
  serializedName = param.queryParameter;
1519
1539
  break;
1520
1540
  }
@@ -1523,32 +1543,32 @@ function emitClientSideDefault(param, csd, setterFormat, imports, indent) {
1523
1543
  // setterFormat can return the empty string in some cases.
1524
1544
  // if it does, there's no need for an extra new-line char.
1525
1545
  if (setterFormatText.length > 0) {
1526
- text += '\n';
1546
+ text += "\n";
1527
1547
  }
1528
1548
  return text;
1529
1549
  }
1530
1550
  function getMediaFormat(type, mediaType, param) {
1531
1551
  let marshaller = mediaType;
1532
- let format = '';
1533
- if (type.kind === 'encodedBytes') {
1534
- marshaller = 'ByteArray';
1552
+ let format = "";
1553
+ if (type.kind === "encodedBytes") {
1554
+ marshaller = "ByteArray";
1535
1555
  format = `, runtime.Base64${type.encoding}Format`;
1536
1556
  }
1537
1557
  return `${marshaller}(${param}${format})`;
1538
1558
  }
1539
1559
  function isArrayOfDateTimeForMarshalling(paramType) {
1540
- if (paramType.kind !== 'slice') {
1560
+ if (paramType.kind !== "slice") {
1541
1561
  return undefined;
1542
1562
  }
1543
- if (paramType.elementType.kind !== 'time') {
1563
+ if (paramType.elementType.kind !== "time") {
1544
1564
  return undefined;
1545
1565
  }
1546
1566
  switch (paramType.elementType.format) {
1547
- case 'PlainDate':
1548
- case 'RFC1123':
1549
- case 'RFC7231':
1550
- case 'PlainTime':
1551
- case 'Unix':
1567
+ case "PlainDate":
1568
+ case "RFC1123":
1569
+ case "RFC7231":
1570
+ case "PlainTime":
1571
+ case "Unix":
1552
1572
  return {
1553
1573
  format: paramType.elementType.format,
1554
1574
  elemByVal: paramType.elementTypeByValue,
@@ -1564,11 +1584,11 @@ function needsResponseHandler(method) {
1564
1584
  return helpers.hasSchemaResponse(method) || method.returns.headers.length > 0;
1565
1585
  }
1566
1586
  function generateResponseUnmarshaller(method, type, format, unmarshalTarget, imports, indent) {
1567
- let unmarshallerText = '';
1568
- const zeroValue = getZeroReturnValue(method, 'handler');
1569
- if (type.kind === 'time') {
1587
+ let unmarshallerText = "";
1588
+ const zeroValue = getZeroReturnValue(method, "handler");
1589
+ if (type.kind === "time") {
1570
1590
  // use the designated time type for unmarshalling
1571
- imports.add('github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/datetime');
1591
+ imports.add("github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/datetime");
1572
1592
  unmarshallerText += `${indent.get()}var aux *datetime.${type.format}\n`;
1573
1593
  unmarshallerText += `${indent.get()}if err := runtime.UnmarshalAs${format}(resp, &aux); err != nil {\n`;
1574
1594
  unmarshallerText += `${indent.push().get()}return ${zeroValue}, err\n`;
@@ -1579,11 +1599,11 @@ function generateResponseUnmarshaller(method, type, format, unmarshalTarget, imp
1579
1599
  else if (isArrayOfDateTime(type)) {
1580
1600
  // unmarshalling arrays of date/time is a little more involved
1581
1601
  const timeInfo = isArrayOfDateTime(type);
1582
- let elementPtr = '*';
1602
+ let elementPtr = "*";
1583
1603
  if (timeInfo?.elemByVal) {
1584
- elementPtr = '';
1604
+ elementPtr = "";
1585
1605
  }
1586
- imports.add('github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/datetime');
1606
+ imports.add("github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/datetime");
1587
1607
  unmarshallerText += `${indent.get()}var aux []${elementPtr}datetime.${timeInfo?.format}\n`;
1588
1608
  unmarshallerText += `${indent.get()}if err := runtime.UnmarshalAs${format}(resp, &aux); err != nil {\n`;
1589
1609
  unmarshallerText += `${indent.push().get()}return ${zeroValue}, err\n`;
@@ -1596,8 +1616,8 @@ function generateResponseUnmarshaller(method, type, format, unmarshalTarget, imp
1596
1616
  return unmarshallerText;
1597
1617
  }
1598
1618
  else if (isMapOfDateTime(type)) {
1599
- let timeType = isMapOfDateTime(type);
1600
- imports.add('github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/datetime');
1619
+ const timeType = isMapOfDateTime(type);
1620
+ imports.add("github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/datetime");
1601
1621
  unmarshallerText += `${indent.get()}aux := map[string]*datetime.${timeType}{}\n`;
1602
1622
  unmarshallerText += `${indent.get()}if err := runtime.UnmarshalAs${format}(resp, &aux); err != nil {\n`;
1603
1623
  unmarshallerText += `${indent.push().get()}return ${zeroValue}, err\n`;
@@ -1609,8 +1629,8 @@ function generateResponseUnmarshaller(method, type, format, unmarshalTarget, imp
1609
1629
  unmarshallerText += `${indent.get()}result.${helpers.getResultFieldName(method)} = cp\n`;
1610
1630
  return unmarshallerText;
1611
1631
  }
1612
- if (format === 'JSON' || format === 'XML') {
1613
- if (type.kind === 'rawJSON') {
1632
+ if (format === "JSON" || format === "XML") {
1633
+ if (type.kind === "rawJSON") {
1614
1634
  unmarshallerText += `${indent.get()}body, err := runtime.Payload(resp)\n`;
1615
1635
  unmarshallerText += `${indent.get()}if err != nil {\n`;
1616
1636
  unmarshallerText += `${indent.push().get()}return ${zeroValue}, err\n`;
@@ -1623,43 +1643,43 @@ function generateResponseUnmarshaller(method, type, format, unmarshalTarget, imp
1623
1643
  unmarshallerText += `${indent.pop().get()}}\n`;
1624
1644
  }
1625
1645
  }
1626
- else if (format === 'Text') {
1646
+ else if (format === "Text") {
1627
1647
  unmarshallerText += `${indent.get()}body, err := runtime.Payload(resp)\n`;
1628
1648
  unmarshallerText += `${indent.get()}if err != nil {\n`;
1629
1649
  unmarshallerText += `${indent.push().get()}return ${zeroValue}, err\n`;
1630
1650
  unmarshallerText += `${indent.pop().get()}}\n`;
1631
1651
  let resultVar;
1632
1652
  switch (type.kind) {
1633
- case 'scalar':
1634
- resultVar = 'parsedBody';
1635
- unmarshallerText += emitScalarParsing(type, 'string(body)', resultVar, imports, indent);
1636
- unmarshallerText += `${indent.get()}${helpers.buildErrCheck(indent, 'err', zeroValue)}\n`;
1653
+ case "scalar":
1654
+ resultVar = "parsedBody";
1655
+ unmarshallerText += emitScalarParsing(type, "string(body)", resultVar, imports, indent);
1656
+ unmarshallerText += `${indent.get()}${helpers.buildErrCheck(indent, "err", zeroValue)}\n`;
1637
1657
  break;
1638
- case 'string':
1639
- resultVar = 'txt';
1658
+ case "string":
1659
+ resultVar = "txt";
1640
1660
  unmarshallerText += `${indent.get()}${resultVar} := string(body)\n`;
1641
1661
  break;
1642
1662
  default:
1643
- throw new CodegenError('UnsupportedTsp', `unsupported text return kind ${type.kind} for method ${method.receiver.type.name}.${method.name}`);
1663
+ throw new CodegenError("UnsupportedTsp", `unsupported text return kind ${type.kind} for method ${method.receiver.type.name}.${method.name}`);
1644
1664
  }
1645
1665
  unmarshallerText += `${indent.get()}${unmarshalTarget} = &${resultVar}\n`;
1646
1666
  }
1647
1667
  else {
1648
1668
  // the remaining formats should have been handled elsewhere
1649
- throw new CodegenError('InternalError', `unhandled format ${format} for operation ${method.receiver.type.name}.${method.name}`);
1669
+ throw new CodegenError("InternalError", `unhandled format ${format} for operation ${method.receiver.type.name}.${method.name}`);
1650
1670
  }
1651
1671
  return unmarshallerText;
1652
1672
  }
1653
1673
  function createProtocolResponse(method, imports, indent) {
1654
1674
  if (!needsResponseHandler(method)) {
1655
- return '';
1675
+ return "";
1656
1676
  }
1657
1677
  const name = method.naming.responseMethod;
1658
- let text = `${helpers.comment(name, '// ')} handles the ${method.name} response.\n`;
1659
- text += `func ${getClientReceiverDefinition(method.receiver)} ${name}(resp *http.Response) (${generateReturnsInfo(method, 'handler').join(', ')}) {\n`;
1678
+ let text = `${helpers.comment(name, "// ")} handles the ${method.name} response.\n`;
1679
+ text += `func ${getClientReceiverDefinition(method.receiver)} ${name}(resp *http.Response) (${generateReturnsInfo(method, "handler").join(", ")}) {\n`;
1660
1680
  const addHeaders = function (headers) {
1661
1681
  for (const header of headers) {
1662
- text += formatHeaderResponseValue(method, header, 'result', `${method.returns.name}{}`, imports, indent);
1682
+ text += formatHeaderResponseValue(method, header, "result", `${method.returns.name}{}`, imports, indent);
1663
1683
  }
1664
1684
  };
1665
1685
  const result = method.returns.result;
@@ -1670,8 +1690,8 @@ function createProtocolResponse(method, imports, indent) {
1670
1690
  }
1671
1691
  else {
1672
1692
  switch (result.kind) {
1673
- case 'anyResult':
1674
- imports.add('fmt');
1693
+ case "anyResult":
1694
+ imports.add("fmt");
1675
1695
  text += `${indent.get()}result := ${method.returns.name}{}\n`;
1676
1696
  addHeaders(method.returns.headers);
1677
1697
  text += `${indent.get()}switch resp.StatusCode {\n`;
@@ -1683,54 +1703,54 @@ function createProtocolResponse(method, imports, indent) {
1683
1703
  continue;
1684
1704
  }
1685
1705
  text += `${indent.get()}var val ${go.getTypeDeclaration(resultType, method.receiver.type.pkg)}\n`;
1686
- text += generateResponseUnmarshaller(method, resultType, result.format, 'val', imports, indent);
1706
+ text += generateResponseUnmarshaller(method, resultType, result.format, "val", imports, indent);
1687
1707
  text += `${indent.get()}result.Value = val\n`;
1688
1708
  }
1689
1709
  text += `${indent.get()}default:\n`;
1690
- text += `${indent.push().get()}return ${getZeroReturnValue(method, 'handler')}, fmt.Errorf("unhandled HTTP status code %d", resp.StatusCode)\n`;
1710
+ text += `${indent.push().get()}return ${getZeroReturnValue(method, "handler")}, fmt.Errorf("unhandled HTTP status code %d", resp.StatusCode)\n`;
1691
1711
  text += `${indent.pop().get()}}\n`;
1692
1712
  break;
1693
- case 'binaryResult':
1713
+ case "binaryResult":
1694
1714
  text += `${indent.get()}result := ${method.returns.name}{${result.fieldName}: resp.Body}\n`;
1695
1715
  addHeaders(method.returns.headers);
1696
1716
  break;
1697
- case 'headAsBooleanResult':
1717
+ case "headAsBooleanResult":
1698
1718
  text += `${indent.get()}result := ${method.returns.name}{${result.fieldName}: resp.StatusCode >= 200 && resp.StatusCode < 300}\n`;
1699
1719
  addHeaders(method.returns.headers);
1700
1720
  break;
1701
- case 'modelResult':
1721
+ case "modelResult":
1702
1722
  text += `${indent.get()}result := ${method.returns.name}{}\n`;
1703
1723
  addHeaders(method.returns.headers);
1704
1724
  text += generateResponseUnmarshaller(method, result.modelType, result.format, `result.${helpers.getResultFieldName(method)}`, imports, indent);
1705
1725
  break;
1706
- case 'monomorphicResult':
1726
+ case "monomorphicResult":
1707
1727
  text += `${indent.get()}result := ${method.returns.name}{}\n`;
1708
1728
  addHeaders(method.returns.headers);
1709
1729
  let target = `result.${helpers.getResultFieldName(method)}`;
1710
1730
  // when unmarshalling a wrapped XML array, unmarshal into the response envelope
1711
- if (result.format === 'XML' && result.monomorphicType.kind === 'slice') {
1712
- target = 'result';
1731
+ if (result.format === "XML" && result.monomorphicType.kind === "slice") {
1732
+ target = "result";
1713
1733
  }
1714
1734
  text += generateResponseUnmarshaller(method, result.monomorphicType, result.format, target, imports, indent);
1715
1735
  break;
1716
- case 'polymorphicResult':
1736
+ case "polymorphicResult":
1717
1737
  text += `${indent.get()}result := ${method.returns.name}{}\n`;
1718
1738
  addHeaders(method.returns.headers);
1719
- text += generateResponseUnmarshaller(method, result.interface, result.format, 'result', imports, indent);
1739
+ text += generateResponseUnmarshaller(method, result.interface, result.format, "result", imports, indent);
1720
1740
  break;
1721
1741
  default:
1722
1742
  result;
1723
1743
  }
1724
1744
  }
1725
1745
  text += `${indent.get()}return result, nil\n`;
1726
- text += '}\n\n';
1746
+ text += "}\n\n";
1727
1747
  return text;
1728
1748
  }
1729
1749
  function isArrayOfDateTime(paramType) {
1730
- if (paramType.kind !== 'slice') {
1750
+ if (paramType.kind !== "slice") {
1731
1751
  return undefined;
1732
1752
  }
1733
- if (paramType.elementType.kind !== 'time') {
1753
+ if (paramType.elementType.kind !== "time") {
1734
1754
  return undefined;
1735
1755
  }
1736
1756
  return {
@@ -1739,10 +1759,10 @@ function isArrayOfDateTime(paramType) {
1739
1759
  };
1740
1760
  }
1741
1761
  function isMapOfDateTime(paramType) {
1742
- if (paramType.kind !== 'map') {
1762
+ if (paramType.kind !== "map") {
1743
1763
  return undefined;
1744
1764
  }
1745
- if (paramType.valueType.kind !== 'time') {
1765
+ if (paramType.valueType.kind !== "time") {
1746
1766
  return undefined;
1747
1767
  }
1748
1768
  return paramType.valueType.format;
@@ -1757,7 +1777,7 @@ function isMapOfDateTime(paramType) {
1757
1777
  */
1758
1778
  function getAPIParametersSig(method, imports) {
1759
1779
  const params = new Array();
1760
- if (method.kind === 'clientAccessor') {
1780
+ if (method.kind === "clientAccessor") {
1761
1781
  // client accessor params don't have a concept
1762
1782
  // of optionality nor do they contain literals
1763
1783
  for (const param of method.parameters) {
@@ -1767,18 +1787,18 @@ function getAPIParametersSig(method, imports) {
1767
1787
  }
1768
1788
  else {
1769
1789
  const methodParams = helpers.getMethodParameters(method);
1770
- if (method.kind !== 'pageableMethod') {
1771
- imports.add('context');
1772
- params.push('ctx context.Context');
1790
+ if (method.kind !== "pageableMethod") {
1791
+ imports.add("context");
1792
+ params.push("ctx context.Context");
1773
1793
  }
1774
1794
  for (const methodParam of methodParams) {
1775
- if (methodParam.kind !== 'paramGroup') {
1795
+ if (methodParam.kind !== "paramGroup") {
1776
1796
  imports.addForType(methodParam.type);
1777
1797
  }
1778
1798
  params.push(`${methodParam.name} ${helpers.formatParameterTypeName(method.receiver.type.pkg, methodParam)}`);
1779
1799
  }
1780
1800
  }
1781
- return params.join(', ');
1801
+ return params.join(", ");
1782
1802
  }
1783
1803
  // returns the return signature where each entry is the type name
1784
1804
  // e.g. [ '*string', 'error' ]
@@ -1789,60 +1809,60 @@ function getAPIParametersSig(method, imports) {
1789
1809
  function generateReturnsInfo(method, apiType) {
1790
1810
  let returnType = method.returns.name;
1791
1811
  switch (method.kind) {
1792
- case 'lroMethod':
1793
- case 'lroPageableMethod':
1812
+ case "lroMethod":
1813
+ case "lroPageableMethod":
1794
1814
  switch (apiType) {
1795
- case 'api':
1796
- if (method.kind === 'lroPageableMethod') {
1815
+ case "api":
1816
+ if (method.kind === "lroPageableMethod") {
1797
1817
  returnType = `*runtime.Poller[*runtime.Pager[${returnType}]]`;
1798
1818
  }
1799
1819
  else {
1800
1820
  returnType = `*runtime.Poller[${returnType}]`;
1801
1821
  }
1802
1822
  break;
1803
- case 'handler':
1823
+ case "handler":
1804
1824
  // we only have a handler for operations that return a schema
1805
- if (method.kind !== 'lroPageableMethod') {
1806
- throw new CodegenError('InternalError', `handler being generated for non-pageable LRO ${method.name} which is unexpected`);
1825
+ if (method.kind !== "lroPageableMethod") {
1826
+ throw new CodegenError("InternalError", `handler being generated for non-pageable LRO ${method.name} which is unexpected`);
1807
1827
  }
1808
1828
  break;
1809
- case 'op':
1810
- returnType = '*http.Response';
1829
+ case "op":
1830
+ returnType = "*http.Response";
1811
1831
  break;
1812
1832
  }
1813
1833
  break;
1814
- case 'pageableMethod':
1834
+ case "pageableMethod":
1815
1835
  switch (apiType) {
1816
- case 'api':
1817
- case 'op':
1836
+ case "api":
1837
+ case "op":
1818
1838
  // pager operations don't return an error
1819
1839
  return [`*runtime.Pager[${returnType}]`];
1820
1840
  }
1821
1841
  break;
1822
1842
  }
1823
- return [returnType, 'error'];
1843
+ return [returnType, "error"];
1824
1844
  }
1825
1845
  function generateLROBeginMethod(method, options, imports, indent) {
1826
1846
  const params = getAPIParametersSig(method, imports);
1827
- const returns = generateReturnsInfo(method, 'api');
1828
- imports.add('github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime');
1829
- let text = '';
1847
+ const returns = generateReturnsInfo(method, "api");
1848
+ imports.add("github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime");
1849
+ let text = "";
1830
1850
  if (method.docs.summary || method.docs.description) {
1831
1851
  text += helpers.formatDocCommentWithPrefix(fixUpMethodName(method), method.docs);
1832
1852
  text += genRespErrorDoc(method);
1833
1853
  }
1834
- const zeroResp = getZeroReturnValue(method, 'lro');
1854
+ const zeroResp = getZeroReturnValue(method, "lro");
1835
1855
  const methodParams = helpers.getMethodParameters(method);
1836
1856
  for (const param of methodParams) {
1837
1857
  text += helpers.formatCommentAsBulletItem(param.name, param.docs);
1838
1858
  }
1839
- text += `func ${getClientReceiverDefinition(method.receiver)} ${fixUpMethodName(method)}(${params}) (${returns.join(', ')}) {\n`;
1840
- let pollerType = 'nil';
1859
+ text += `func ${getClientReceiverDefinition(method.receiver)} ${fixUpMethodName(method)}(${params}) (${returns.join(", ")}) {\n`;
1860
+ let pollerType = "nil";
1841
1861
  let pollerTypeParam = `[${method.returns.name}]`;
1842
- if (method.kind === 'lroPageableMethod') {
1862
+ if (method.kind === "lroPageableMethod") {
1843
1863
  // for paged LROs, we construct a pager and pass it to the LRO ctor.
1844
1864
  pollerTypeParam = `[*runtime.Pager${pollerTypeParam}]`;
1845
- pollerType = '&pager';
1865
+ pollerType = "&pager";
1846
1866
  text += `${indent.get()}pager := `;
1847
1867
  text += emitPagerDefinition(method, options, imports, indent);
1848
1868
  }
@@ -1854,49 +1874,52 @@ function generateLROBeginMethod(method, options, imports, indent) {
1854
1874
  text += `${indent.get()}if err != nil {\n`;
1855
1875
  text += `${indent.push().get()}return ${zeroResp}, err\n`;
1856
1876
  text += `${indent.pop().get()}}\n`;
1857
- let finalStateVia = '';
1877
+ let finalStateVia = "";
1858
1878
  // LRO operation might have a special configuration set in x-ms-long-running-operation-options
1859
1879
  // which indicates a specific url to perform the final Get operation on
1860
1880
  if (method.finalStateVia) {
1861
1881
  switch (method.finalStateVia) {
1862
- case 'azure-async-operation':
1863
- finalStateVia = 'runtime.FinalStateViaAzureAsyncOp';
1882
+ case "azure-async-operation":
1883
+ finalStateVia = "runtime.FinalStateViaAzureAsyncOp";
1864
1884
  break;
1865
- case 'location':
1866
- finalStateVia = 'runtime.FinalStateViaLocation';
1885
+ case "location":
1886
+ finalStateVia = "runtime.FinalStateViaLocation";
1867
1887
  break;
1868
- case 'original-uri':
1869
- finalStateVia = 'runtime.FinalStateViaOriginalURI';
1888
+ case "original-uri":
1889
+ finalStateVia = "runtime.FinalStateViaOriginalURI";
1870
1890
  break;
1871
- case 'operation-location':
1872
- finalStateVia = 'runtime.FinalStateViaOpLocation';
1891
+ case "operation-location":
1892
+ finalStateVia = "runtime.FinalStateViaOpLocation";
1873
1893
  break;
1874
1894
  default:
1875
- throw new CodegenError('InternalError', `unhandled final-state-via value ${finalStateVia}`);
1895
+ throw new CodegenError("InternalError", `unhandled final-state-via value ${finalStateVia}`);
1876
1896
  }
1877
1897
  }
1878
1898
  text += `${indent.get()}poller, err := runtime.NewPoller`;
1879
- if (finalStateVia === '' && pollerType === 'nil' && !options.injectSpans) {
1899
+ if (finalStateVia === "" && pollerType === "nil" && !options.injectSpans) {
1880
1900
  // the generic type param is redundant when it's also specified in the
1881
1901
  // options struct so we only include it when there's no options.
1882
1902
  text += pollerTypeParam;
1883
1903
  }
1884
- text += '(resp, client.internal.Pipeline(), ';
1885
- if (finalStateVia === '' && pollerType === 'nil' && !options.injectSpans && !method.operationLocationResultPath) {
1904
+ text += "(resp, client.internal.Pipeline(), ";
1905
+ if (finalStateVia === "" &&
1906
+ pollerType === "nil" &&
1907
+ !options.injectSpans &&
1908
+ !method.operationLocationResultPath) {
1886
1909
  // no options
1887
- text += 'nil)\n';
1910
+ text += "nil)\n";
1888
1911
  }
1889
1912
  else {
1890
1913
  // at least one option
1891
1914
  indent.push();
1892
1915
  text += `&runtime.NewPollerOptions${pollerTypeParam}{\n`;
1893
- if (finalStateVia !== '') {
1916
+ if (finalStateVia !== "") {
1894
1917
  text += `${indent.get()}FinalStateVia: ${finalStateVia},\n`;
1895
1918
  }
1896
1919
  if (method.operationLocationResultPath) {
1897
1920
  text += `${indent.get()}OperationLocationResultPath: "${method.operationLocationResultPath}",\n`;
1898
1921
  }
1899
- if (pollerType !== 'nil') {
1922
+ if (pollerType !== "nil") {
1900
1923
  text += `${indent.get()}Response: ${pollerType},\n`;
1901
1924
  }
1902
1925
  if (options.injectSpans) {
@@ -1911,17 +1934,17 @@ function generateLROBeginMethod(method, options, imports, indent) {
1911
1934
  indent.push();
1912
1935
  // creating the poller from resume token branch
1913
1936
  text += `${indent.get()}return runtime.NewPollerFromResumeToken`;
1914
- if (pollerType === 'nil' && !options.injectSpans) {
1937
+ if (pollerType === "nil" && !options.injectSpans) {
1915
1938
  text += pollerTypeParam;
1916
1939
  }
1917
- text += '(options.ResumeToken, client.internal.Pipeline(), ';
1918
- if (pollerType === 'nil' && !options.injectSpans) {
1919
- text += 'nil)\n';
1940
+ text += "(options.ResumeToken, client.internal.Pipeline(), ";
1941
+ if (pollerType === "nil" && !options.injectSpans) {
1942
+ text += "nil)\n";
1920
1943
  }
1921
1944
  else {
1922
1945
  indent.push();
1923
1946
  text += `&runtime.NewPollerFromResumeTokenOptions${pollerTypeParam}{\n`;
1924
- if (pollerType !== 'nil') {
1947
+ if (pollerType !== "nil") {
1925
1948
  text += `${indent.get()}Response: ${pollerType},\n`;
1926
1949
  }
1927
1950
  if (options.injectSpans) {
@@ -1932,27 +1955,27 @@ function generateLROBeginMethod(method, options, imports, indent) {
1932
1955
  }
1933
1956
  indent.pop();
1934
1957
  text += `${indent.get()}}\n`;
1935
- text += '}\n\n';
1958
+ text += "}\n\n";
1936
1959
  return text;
1937
1960
  }
1938
1961
  export function fixUpMethodName(method) {
1939
1962
  switch (method.kind) {
1940
- case 'lroMethod':
1941
- case 'lroPageableMethod':
1963
+ case "lroMethod":
1964
+ case "lroPageableMethod":
1942
1965
  return `Begin${method.name}`;
1943
- case 'pageableMethod': {
1944
- let N = 'N';
1966
+ case "pageableMethod": {
1967
+ let N = "N";
1945
1968
  let name = method.name;
1946
1969
  if (method.name[0] !== method.name[0].toUpperCase()) {
1947
1970
  // the method isn't exported; don't export the pager ctor
1948
- N = 'n';
1971
+ N = "n";
1949
1972
  // ensure correct casing of the emitted function name e.g.,
1950
1973
  // "listThings" -> "newListThingsPager"
1951
1974
  name = name[0].toUpperCase() + name.substring(1);
1952
1975
  }
1953
1976
  return `${N}ew${name}Pager`;
1954
1977
  }
1955
- case 'method':
1978
+ case "method":
1956
1979
  return method.name;
1957
1980
  }
1958
1981
  }