@azure-typespec/http-client-csharp-provisioning 1.0.0-alpha.20260313.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 (277) hide show
  1. package/README.md +40 -0
  2. package/dist/emitter/emitter.d.ts +4 -0
  3. package/dist/emitter/emitter.d.ts.map +1 -0
  4. package/dist/emitter/emitter.js +11 -0
  5. package/dist/emitter/emitter.js.map +1 -0
  6. package/dist/emitter/index.d.ts +3 -0
  7. package/dist/emitter/index.d.ts.map +1 -0
  8. package/dist/emitter/index.js +5 -0
  9. package/dist/emitter/index.js.map +1 -0
  10. package/dist/emitter/lib/lib.d.ts +4 -0
  11. package/dist/emitter/lib/lib.d.ts.map +1 -0
  12. package/dist/emitter/lib/lib.js +15 -0
  13. package/dist/emitter/lib/lib.js.map +1 -0
  14. package/dist/emitter/options.d.ts +6 -0
  15. package/dist/emitter/options.d.ts.map +1 -0
  16. package/dist/emitter/options.js +11 -0
  17. package/dist/emitter/options.js.map +1 -0
  18. package/dist/generator/Azure.Core.Expressions.DataFactory.dll +0 -0
  19. package/dist/generator/Azure.Core.dll +0 -0
  20. package/dist/generator/Azure.Generator.Management.dll +0 -0
  21. package/dist/generator/Azure.Generator.Provisioning.deps.json +1062 -0
  22. package/dist/generator/Azure.Generator.Provisioning.dll +0 -0
  23. package/dist/generator/Azure.Generator.Provisioning.pdb +0 -0
  24. package/dist/generator/Azure.Generator.Provisioning.xml +1051 -0
  25. package/dist/generator/Azure.Generator.dll +0 -0
  26. package/dist/generator/Azure.Provisioning.dll +0 -0
  27. package/dist/generator/Azure.ResourceManager.dll +0 -0
  28. package/dist/generator/CommandLine.dll +0 -0
  29. package/dist/generator/Humanizer.dll +0 -0
  30. package/dist/generator/Microsoft.Bcl.AsyncInterfaces.dll +0 -0
  31. package/dist/generator/Microsoft.Build.Framework.dll +0 -0
  32. package/dist/generator/Microsoft.Build.dll +0 -0
  33. package/dist/generator/Microsoft.CodeAnalysis.CSharp.Workspaces.dll +0 -0
  34. package/dist/generator/Microsoft.CodeAnalysis.CSharp.dll +0 -0
  35. package/dist/generator/Microsoft.CodeAnalysis.Workspaces.dll +0 -0
  36. package/dist/generator/Microsoft.CodeAnalysis.dll +0 -0
  37. package/dist/generator/Microsoft.Extensions.Configuration.Abstractions.dll +0 -0
  38. package/dist/generator/Microsoft.Extensions.DependencyInjection.Abstractions.dll +0 -0
  39. package/dist/generator/Microsoft.Extensions.Diagnostics.Abstractions.dll +0 -0
  40. package/dist/generator/Microsoft.Extensions.FileProviders.Abstractions.dll +0 -0
  41. package/dist/generator/Microsoft.Extensions.Hosting.Abstractions.dll +0 -0
  42. package/dist/generator/Microsoft.Extensions.Logging.Abstractions.dll +0 -0
  43. package/dist/generator/Microsoft.Extensions.Options.dll +0 -0
  44. package/dist/generator/Microsoft.Extensions.Primitives.dll +0 -0
  45. package/dist/generator/Microsoft.NET.StringTools.dll +0 -0
  46. package/dist/generator/Microsoft.TypeSpec.Generator.ClientModel.dll +0 -0
  47. package/dist/generator/Microsoft.TypeSpec.Generator.Input.dll +0 -0
  48. package/dist/generator/Microsoft.TypeSpec.Generator.dll +0 -0
  49. package/dist/generator/Microsoft.TypeSpec.Generator.runtimeconfig.json +12 -0
  50. package/dist/generator/Newtonsoft.Json.dll +0 -0
  51. package/dist/generator/NuGet.Common.dll +0 -0
  52. package/dist/generator/NuGet.Configuration.dll +0 -0
  53. package/dist/generator/NuGet.Frameworks.dll +0 -0
  54. package/dist/generator/NuGet.Packaging.dll +0 -0
  55. package/dist/generator/NuGet.Protocol.dll +0 -0
  56. package/dist/generator/NuGet.Versioning.dll +0 -0
  57. package/dist/generator/Shared/Core/AppContextSwitchHelper.cs +42 -0
  58. package/dist/generator/Shared/Core/AsyncLockWithValue.cs +260 -0
  59. package/dist/generator/Shared/Core/AzureKeyCredentialPolicy.cs +50 -0
  60. package/dist/generator/Shared/Core/ClientDiagnostics.cs +73 -0
  61. package/dist/generator/Shared/Core/DiagnosticScope.cs +473 -0
  62. package/dist/generator/Shared/Core/DiagnosticScopeFactory.cs +104 -0
  63. package/dist/generator/Shared/Core/FixedDelayWithNoJitterStrategy.cs +26 -0
  64. package/dist/generator/Shared/Core/ForwardsClientCallsAttribute.cs +39 -0
  65. package/dist/generator/Shared/Core/HttpMessageSanitizer.cs +198 -0
  66. package/dist/generator/Shared/Core/IOperationSource.cs +14 -0
  67. package/dist/generator/Shared/Core/NextLinkOperationImplementation.cs +701 -0
  68. package/dist/generator/Shared/Core/NoValueResponseOfT.cs +39 -0
  69. package/dist/generator/Shared/Core/OperationFinalStateVia.cs +16 -0
  70. package/dist/generator/Shared/Core/OperationInternal.cs +263 -0
  71. package/dist/generator/Shared/Core/OperationInternalBase.cs +234 -0
  72. package/dist/generator/Shared/Core/OperationInternalOfT.cs +431 -0
  73. package/dist/generator/Shared/Core/OperationPoller.cs +114 -0
  74. package/dist/generator/Shared/Core/RawRequestUriBuilder.cs +229 -0
  75. package/dist/generator/Shared/Core/RequestHeaderExtensions.cs +132 -0
  76. package/dist/generator/Shared/Core/SequentialDelayStrategy.cs +38 -0
  77. package/dist/generator/Shared/Core/TaskExtensions.cs +313 -0
  78. package/dist/generator/Shared/Core/TypeFormatters.cs +159 -0
  79. package/dist/generator/Shared/Core/VoidValue.cs +10 -0
  80. package/dist/generator/System.ClientModel.dll +0 -0
  81. package/dist/generator/System.ComponentModel.Composition.dll +0 -0
  82. package/dist/generator/System.Composition.AttributedModel.dll +0 -0
  83. package/dist/generator/System.Composition.Convention.dll +0 -0
  84. package/dist/generator/System.Composition.Hosting.dll +0 -0
  85. package/dist/generator/System.Composition.Runtime.dll +0 -0
  86. package/dist/generator/System.Composition.TypedParts.dll +0 -0
  87. package/dist/generator/System.Configuration.ConfigurationManager.dll +0 -0
  88. package/dist/generator/System.Diagnostics.EventLog.dll +0 -0
  89. package/dist/generator/System.Memory.Data.dll +0 -0
  90. package/dist/generator/System.Reflection.MetadataLoadContext.dll +0 -0
  91. package/dist/generator/System.Security.Cryptography.Pkcs.dll +0 -0
  92. package/dist/generator/System.Security.Cryptography.ProtectedData.dll +0 -0
  93. package/dist/generator/cs/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  94. package/dist/generator/cs/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  95. package/dist/generator/cs/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  96. package/dist/generator/cs/Microsoft.CodeAnalysis.resources.dll +0 -0
  97. package/dist/generator/de/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  98. package/dist/generator/de/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  99. package/dist/generator/de/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  100. package/dist/generator/de/Microsoft.CodeAnalysis.resources.dll +0 -0
  101. package/dist/generator/es/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  102. package/dist/generator/es/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  103. package/dist/generator/es/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  104. package/dist/generator/es/Microsoft.CodeAnalysis.resources.dll +0 -0
  105. package/dist/generator/fr/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  106. package/dist/generator/fr/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  107. package/dist/generator/fr/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  108. package/dist/generator/fr/Microsoft.CodeAnalysis.resources.dll +0 -0
  109. package/dist/generator/it/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  110. package/dist/generator/it/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  111. package/dist/generator/it/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  112. package/dist/generator/it/Microsoft.CodeAnalysis.resources.dll +0 -0
  113. package/dist/generator/ja/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  114. package/dist/generator/ja/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  115. package/dist/generator/ja/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  116. package/dist/generator/ja/Microsoft.CodeAnalysis.resources.dll +0 -0
  117. package/dist/generator/ko/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  118. package/dist/generator/ko/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  119. package/dist/generator/ko/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  120. package/dist/generator/ko/Microsoft.CodeAnalysis.resources.dll +0 -0
  121. package/dist/generator/net10.0/Azure.Core.Expressions.DataFactory.dll +0 -0
  122. package/dist/generator/net10.0/Azure.Core.dll +0 -0
  123. package/dist/generator/net10.0/Azure.Generator.Management.dll +0 -0
  124. package/dist/generator/net10.0/Azure.Generator.Provisioning.deps.json +1062 -0
  125. package/dist/generator/net10.0/Azure.Generator.Provisioning.dll +0 -0
  126. package/dist/generator/net10.0/Azure.Generator.Provisioning.pdb +0 -0
  127. package/dist/generator/net10.0/Azure.Generator.Provisioning.xml +1051 -0
  128. package/dist/generator/net10.0/Azure.Generator.dll +0 -0
  129. package/dist/generator/net10.0/Azure.Provisioning.dll +0 -0
  130. package/dist/generator/net10.0/Azure.ResourceManager.dll +0 -0
  131. package/dist/generator/net10.0/CommandLine.dll +0 -0
  132. package/dist/generator/net10.0/Humanizer.dll +0 -0
  133. package/dist/generator/net10.0/Microsoft.Bcl.AsyncInterfaces.dll +0 -0
  134. package/dist/generator/net10.0/Microsoft.Build.Framework.dll +0 -0
  135. package/dist/generator/net10.0/Microsoft.Build.dll +0 -0
  136. package/dist/generator/net10.0/Microsoft.CodeAnalysis.CSharp.Workspaces.dll +0 -0
  137. package/dist/generator/net10.0/Microsoft.CodeAnalysis.CSharp.dll +0 -0
  138. package/dist/generator/net10.0/Microsoft.CodeAnalysis.Workspaces.dll +0 -0
  139. package/dist/generator/net10.0/Microsoft.CodeAnalysis.dll +0 -0
  140. package/dist/generator/net10.0/Microsoft.Extensions.Configuration.Abstractions.dll +0 -0
  141. package/dist/generator/net10.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll +0 -0
  142. package/dist/generator/net10.0/Microsoft.Extensions.Diagnostics.Abstractions.dll +0 -0
  143. package/dist/generator/net10.0/Microsoft.Extensions.FileProviders.Abstractions.dll +0 -0
  144. package/dist/generator/net10.0/Microsoft.Extensions.Hosting.Abstractions.dll +0 -0
  145. package/dist/generator/net10.0/Microsoft.Extensions.Logging.Abstractions.dll +0 -0
  146. package/dist/generator/net10.0/Microsoft.Extensions.Options.dll +0 -0
  147. package/dist/generator/net10.0/Microsoft.Extensions.Primitives.dll +0 -0
  148. package/dist/generator/net10.0/Microsoft.NET.StringTools.dll +0 -0
  149. package/dist/generator/net10.0/Microsoft.TypeSpec.Generator.ClientModel.dll +0 -0
  150. package/dist/generator/net10.0/Microsoft.TypeSpec.Generator.Input.dll +0 -0
  151. package/dist/generator/net10.0/Microsoft.TypeSpec.Generator.dll +0 -0
  152. package/dist/generator/net10.0/Newtonsoft.Json.dll +0 -0
  153. package/dist/generator/net10.0/NuGet.Common.dll +0 -0
  154. package/dist/generator/net10.0/NuGet.Configuration.dll +0 -0
  155. package/dist/generator/net10.0/NuGet.Frameworks.dll +0 -0
  156. package/dist/generator/net10.0/NuGet.Packaging.dll +0 -0
  157. package/dist/generator/net10.0/NuGet.Protocol.dll +0 -0
  158. package/dist/generator/net10.0/NuGet.Versioning.dll +0 -0
  159. package/dist/generator/net10.0/Shared/Core/AppContextSwitchHelper.cs +42 -0
  160. package/dist/generator/net10.0/Shared/Core/AsyncLockWithValue.cs +260 -0
  161. package/dist/generator/net10.0/Shared/Core/AzureKeyCredentialPolicy.cs +50 -0
  162. package/dist/generator/net10.0/Shared/Core/ClientDiagnostics.cs +73 -0
  163. package/dist/generator/net10.0/Shared/Core/DiagnosticScope.cs +473 -0
  164. package/dist/generator/net10.0/Shared/Core/DiagnosticScopeFactory.cs +104 -0
  165. package/dist/generator/net10.0/Shared/Core/FixedDelayWithNoJitterStrategy.cs +26 -0
  166. package/dist/generator/net10.0/Shared/Core/ForwardsClientCallsAttribute.cs +39 -0
  167. package/dist/generator/net10.0/Shared/Core/HttpMessageSanitizer.cs +198 -0
  168. package/dist/generator/net10.0/Shared/Core/IOperationSource.cs +14 -0
  169. package/dist/generator/net10.0/Shared/Core/NextLinkOperationImplementation.cs +701 -0
  170. package/dist/generator/net10.0/Shared/Core/NoValueResponseOfT.cs +39 -0
  171. package/dist/generator/net10.0/Shared/Core/OperationFinalStateVia.cs +16 -0
  172. package/dist/generator/net10.0/Shared/Core/OperationInternal.cs +263 -0
  173. package/dist/generator/net10.0/Shared/Core/OperationInternalBase.cs +234 -0
  174. package/dist/generator/net10.0/Shared/Core/OperationInternalOfT.cs +431 -0
  175. package/dist/generator/net10.0/Shared/Core/OperationPoller.cs +114 -0
  176. package/dist/generator/net10.0/Shared/Core/RawRequestUriBuilder.cs +229 -0
  177. package/dist/generator/net10.0/Shared/Core/RequestHeaderExtensions.cs +132 -0
  178. package/dist/generator/net10.0/Shared/Core/SequentialDelayStrategy.cs +38 -0
  179. package/dist/generator/net10.0/Shared/Core/TaskExtensions.cs +313 -0
  180. package/dist/generator/net10.0/Shared/Core/TypeFormatters.cs +159 -0
  181. package/dist/generator/net10.0/Shared/Core/VoidValue.cs +10 -0
  182. package/dist/generator/net10.0/System.ClientModel.dll +0 -0
  183. package/dist/generator/net10.0/System.ComponentModel.Composition.dll +0 -0
  184. package/dist/generator/net10.0/System.Composition.AttributedModel.dll +0 -0
  185. package/dist/generator/net10.0/System.Composition.Convention.dll +0 -0
  186. package/dist/generator/net10.0/System.Composition.Hosting.dll +0 -0
  187. package/dist/generator/net10.0/System.Composition.Runtime.dll +0 -0
  188. package/dist/generator/net10.0/System.Composition.TypedParts.dll +0 -0
  189. package/dist/generator/net10.0/System.Configuration.ConfigurationManager.dll +0 -0
  190. package/dist/generator/net10.0/System.Diagnostics.EventLog.dll +0 -0
  191. package/dist/generator/net10.0/System.Memory.Data.dll +0 -0
  192. package/dist/generator/net10.0/System.Reflection.MetadataLoadContext.dll +0 -0
  193. package/dist/generator/net10.0/System.Security.Cryptography.Pkcs.dll +0 -0
  194. package/dist/generator/net10.0/System.Security.Cryptography.ProtectedData.dll +0 -0
  195. package/dist/generator/net10.0/cs/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  196. package/dist/generator/net10.0/cs/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  197. package/dist/generator/net10.0/cs/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  198. package/dist/generator/net10.0/cs/Microsoft.CodeAnalysis.resources.dll +0 -0
  199. package/dist/generator/net10.0/de/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  200. package/dist/generator/net10.0/de/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  201. package/dist/generator/net10.0/de/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  202. package/dist/generator/net10.0/de/Microsoft.CodeAnalysis.resources.dll +0 -0
  203. package/dist/generator/net10.0/es/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  204. package/dist/generator/net10.0/es/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  205. package/dist/generator/net10.0/es/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  206. package/dist/generator/net10.0/es/Microsoft.CodeAnalysis.resources.dll +0 -0
  207. package/dist/generator/net10.0/fr/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  208. package/dist/generator/net10.0/fr/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  209. package/dist/generator/net10.0/fr/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  210. package/dist/generator/net10.0/fr/Microsoft.CodeAnalysis.resources.dll +0 -0
  211. package/dist/generator/net10.0/it/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  212. package/dist/generator/net10.0/it/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  213. package/dist/generator/net10.0/it/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  214. package/dist/generator/net10.0/it/Microsoft.CodeAnalysis.resources.dll +0 -0
  215. package/dist/generator/net10.0/ja/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  216. package/dist/generator/net10.0/ja/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  217. package/dist/generator/net10.0/ja/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  218. package/dist/generator/net10.0/ja/Microsoft.CodeAnalysis.resources.dll +0 -0
  219. package/dist/generator/net10.0/ko/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  220. package/dist/generator/net10.0/ko/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  221. package/dist/generator/net10.0/ko/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  222. package/dist/generator/net10.0/ko/Microsoft.CodeAnalysis.resources.dll +0 -0
  223. package/dist/generator/net10.0/pl/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  224. package/dist/generator/net10.0/pl/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  225. package/dist/generator/net10.0/pl/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  226. package/dist/generator/net10.0/pl/Microsoft.CodeAnalysis.resources.dll +0 -0
  227. package/dist/generator/net10.0/pt-BR/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  228. package/dist/generator/net10.0/pt-BR/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  229. package/dist/generator/net10.0/pt-BR/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  230. package/dist/generator/net10.0/pt-BR/Microsoft.CodeAnalysis.resources.dll +0 -0
  231. package/dist/generator/net10.0/ru/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  232. package/dist/generator/net10.0/ru/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  233. package/dist/generator/net10.0/ru/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  234. package/dist/generator/net10.0/ru/Microsoft.CodeAnalysis.resources.dll +0 -0
  235. package/dist/generator/net10.0/runtimes/win/lib/net6.0/System.Security.Cryptography.Pkcs.dll +0 -0
  236. package/dist/generator/net10.0/runtimes/win/lib/net8.0/System.Diagnostics.EventLog.Messages.dll +0 -0
  237. package/dist/generator/net10.0/runtimes/win/lib/net8.0/System.Diagnostics.EventLog.dll +0 -0
  238. package/dist/generator/net10.0/tr/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  239. package/dist/generator/net10.0/tr/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  240. package/dist/generator/net10.0/tr/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  241. package/dist/generator/net10.0/tr/Microsoft.CodeAnalysis.resources.dll +0 -0
  242. package/dist/generator/net10.0/zh-Hans/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  243. package/dist/generator/net10.0/zh-Hans/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  244. package/dist/generator/net10.0/zh-Hans/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  245. package/dist/generator/net10.0/zh-Hans/Microsoft.CodeAnalysis.resources.dll +0 -0
  246. package/dist/generator/net10.0/zh-Hant/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  247. package/dist/generator/net10.0/zh-Hant/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  248. package/dist/generator/net10.0/zh-Hant/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  249. package/dist/generator/net10.0/zh-Hant/Microsoft.CodeAnalysis.resources.dll +0 -0
  250. package/dist/generator/pl/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  251. package/dist/generator/pl/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  252. package/dist/generator/pl/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  253. package/dist/generator/pl/Microsoft.CodeAnalysis.resources.dll +0 -0
  254. package/dist/generator/pt-BR/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  255. package/dist/generator/pt-BR/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  256. package/dist/generator/pt-BR/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  257. package/dist/generator/pt-BR/Microsoft.CodeAnalysis.resources.dll +0 -0
  258. package/dist/generator/ru/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  259. package/dist/generator/ru/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  260. package/dist/generator/ru/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  261. package/dist/generator/ru/Microsoft.CodeAnalysis.resources.dll +0 -0
  262. package/dist/generator/runtimes/win/lib/net6.0/System.Security.Cryptography.Pkcs.dll +0 -0
  263. package/dist/generator/runtimes/win/lib/net8.0/System.Diagnostics.EventLog.Messages.dll +0 -0
  264. package/dist/generator/runtimes/win/lib/net8.0/System.Diagnostics.EventLog.dll +0 -0
  265. package/dist/generator/tr/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  266. package/dist/generator/tr/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  267. package/dist/generator/tr/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  268. package/dist/generator/tr/Microsoft.CodeAnalysis.resources.dll +0 -0
  269. package/dist/generator/zh-Hans/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  270. package/dist/generator/zh-Hans/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  271. package/dist/generator/zh-Hans/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  272. package/dist/generator/zh-Hans/Microsoft.CodeAnalysis.resources.dll +0 -0
  273. package/dist/generator/zh-Hant/Microsoft.CodeAnalysis.CSharp.Workspaces.resources.dll +0 -0
  274. package/dist/generator/zh-Hant/Microsoft.CodeAnalysis.CSharp.resources.dll +0 -0
  275. package/dist/generator/zh-Hant/Microsoft.CodeAnalysis.Workspaces.resources.dll +0 -0
  276. package/dist/generator/zh-Hant/Microsoft.CodeAnalysis.resources.dll +0 -0
  277. package/package.json +64 -0
@@ -0,0 +1,701 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT License.
3
+
4
+ #nullable enable
5
+
6
+ using System;
7
+ using System.ClientModel.Primitives;
8
+ using System.Collections.Generic;
9
+ using System.IO;
10
+ using System.Linq;
11
+ using System.Net;
12
+ using System.Text.Json;
13
+ using System.Threading;
14
+ using System.Threading.Tasks;
15
+ using Azure.Core.Pipeline;
16
+
17
+ namespace Azure.Core
18
+ {
19
+ internal class NextLinkOperationImplementation : IOperation
20
+ {
21
+ internal const string NotSet = "NOT_SET";
22
+ internal const string RehydrationTokenVersion = "1.0.0";
23
+ private const string ApiVersionParam = "api-version";
24
+ private static readonly string[] FailureStates = { "failed", "canceled" };
25
+ private static readonly string[] SuccessStates = { "succeeded" };
26
+
27
+ private readonly HeaderSource _headerSource;
28
+ private readonly Uri _startRequestUri;
29
+ private readonly OperationFinalStateVia _finalStateVia;
30
+ private readonly HttpPipeline _pipeline;
31
+ private readonly string? _apiVersion;
32
+
33
+ private string? _lastKnownLocation;
34
+ private string _nextRequestUri;
35
+
36
+ // We can only get OperationId when
37
+ // - The operation is still in progress and nextRequestUri contains it
38
+ // - During rehydration, rehydrationToken.Id is the operation id
39
+ public string OperationId { get; private set; } = NotSet;
40
+ public RequestMethod RequestMethod { get; }
41
+
42
+ public static IOperation Create(
43
+ HttpPipeline pipeline,
44
+ RequestMethod requestMethod,
45
+ Uri startRequestUri,
46
+ Response response,
47
+ OperationFinalStateVia finalStateVia,
48
+ bool skipApiVersionOverride = false,
49
+ string? apiVersionOverrideValue = null)
50
+ {
51
+ string? apiVersionStr = null;
52
+ if (apiVersionOverrideValue is not null)
53
+ {
54
+ apiVersionStr = apiVersionOverrideValue;
55
+ }
56
+ else
57
+ {
58
+ apiVersionStr = !skipApiVersionOverride && TryGetApiVersion(startRequestUri, out ReadOnlySpan<char> apiVersion) ? apiVersion.ToString() : null;
59
+ }
60
+ var headerSource = GetHeaderSource(requestMethod, startRequestUri, response, apiVersionStr, out string nextRequestUri, out bool isNextRequestPolling);
61
+
62
+ string? lastKnownLocation;
63
+ if (!response.Headers.TryGetValue("Location", out lastKnownLocation))
64
+ {
65
+ lastKnownLocation = null;
66
+ }
67
+
68
+ NextLinkOperationImplementation operation = new(pipeline, requestMethod, startRequestUri, nextRequestUri, headerSource, lastKnownLocation, finalStateVia, apiVersionStr, isNextRequestPolling: isNextRequestPolling);
69
+
70
+ if (headerSource == HeaderSource.None && IsFinalState(response, headerSource, out var failureState, out _))
71
+ {
72
+ return new CompletedOperation(failureState ?? GetOperationStateFromFinalResponse(requestMethod, response), operation);
73
+ }
74
+
75
+ return operation;
76
+ }
77
+
78
+ public static IOperation<T> Create<T>(
79
+ IOperationSource<T> operationSource,
80
+ HttpPipeline pipeline,
81
+ RequestMethod requestMethod,
82
+ Uri startRequestUri,
83
+ Response response,
84
+ OperationFinalStateVia finalStateVia,
85
+ bool skipApiVersionOverride = false,
86
+ string? apiVersionOverrideValue = null)
87
+ {
88
+ var operation = Create(pipeline, requestMethod, startRequestUri, response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue);
89
+ return new OperationToOperationOfT<T>(operationSource, operation);
90
+ }
91
+
92
+ public static IOperation<T> Create<T>(
93
+ IOperationSource<T> operationSource,
94
+ IOperation operation)
95
+ => new OperationToOperationOfT<T>(operationSource, operation);
96
+
97
+ public static IOperation Create(
98
+ HttpPipeline pipeline,
99
+ RehydrationToken rehydrationToken)
100
+ {
101
+ AssertNotNull(rehydrationToken, nameof(rehydrationToken));
102
+ AssertNotNull(pipeline, nameof(pipeline));
103
+
104
+ // TODO: Once we remove NextLinkOperationImplementation from internal shared and make it internal to Azure.Core only in https://github.com/Azure/azure-sdk-for-net/issues/43260
105
+ // We can access the internal members from RehydrationToken directly
106
+ var data = ModelReaderWriter.Write(rehydrationToken!, ModelReaderWriterOptions.Json, AzureCoreContext.Default);
107
+ using var document = JsonDocument.Parse(data);
108
+ var lroDetails = document.RootElement;
109
+
110
+ // We are sure that the following properties exists in the serialized rehydrationToken
111
+ var initialUri = lroDetails.GetProperty("initialUri").GetString();
112
+ if (!Uri.TryCreate(initialUri, UriKind.Absolute, out var startRequestUri))
113
+ {
114
+ throw new ArgumentException($"\"initialUri\" property on \"rehydrationToken\" is an invalid Uri", nameof(rehydrationToken));
115
+ }
116
+
117
+ // We are sure that the following properties(apart from nullable lastKnownLocation) are not null as they are required in the rehydrationToken
118
+ string nextRequestUri = lroDetails.GetProperty("nextRequestUri").GetString()!;
119
+ string requestMethodStr = lroDetails.GetProperty("requestMethod").GetString()!;
120
+ RequestMethod requestMethod = new RequestMethod(requestMethodStr)!;
121
+ string? lastKnownLocation = lroDetails.GetProperty("lastKnownLocation").GetString();
122
+
123
+ string finalStateViaStr = lroDetails.GetProperty("finalStateVia").GetString()!;
124
+ OperationFinalStateVia finalStateVia;
125
+ if (Enum.IsDefined(typeof(OperationFinalStateVia), finalStateViaStr))
126
+ {
127
+ finalStateVia = (OperationFinalStateVia)Enum.Parse(typeof(OperationFinalStateVia), finalStateViaStr);
128
+ }
129
+ else
130
+ {
131
+ finalStateVia = OperationFinalStateVia.Location;
132
+ }
133
+
134
+ string headerSourceStr = lroDetails.GetProperty("headerSource").GetString()!;
135
+ HeaderSource headerSource;
136
+ if (Enum.IsDefined(typeof(HeaderSource), headerSourceStr))
137
+ {
138
+ headerSource = (HeaderSource)Enum.Parse(typeof(HeaderSource), headerSourceStr);
139
+ }
140
+ else
141
+ {
142
+ headerSource = HeaderSource.None;
143
+ }
144
+
145
+ return new NextLinkOperationImplementation(pipeline, requestMethod, startRequestUri, nextRequestUri, headerSource, lastKnownLocation, finalStateVia, null, rehydrationToken.Id);
146
+ }
147
+
148
+ private NextLinkOperationImplementation(
149
+ HttpPipeline pipeline,
150
+ RequestMethod requestMethod,
151
+ Uri startRequestUri,
152
+ string nextRequestUri,
153
+ HeaderSource headerSource,
154
+ string? lastKnownLocation,
155
+ OperationFinalStateVia finalStateVia,
156
+ string? apiVersion,
157
+ string? operationId = null,
158
+ bool isNextRequestPolling = false)
159
+ {
160
+ AssertNotNull(pipeline, nameof(pipeline));
161
+ AssertNotNull(requestMethod, nameof(requestMethod));
162
+ AssertNotNull(startRequestUri, nameof(startRequestUri));
163
+ AssertNotNull(nextRequestUri, nameof(nextRequestUri));
164
+ AssertNotNull(headerSource, nameof(headerSource));
165
+ AssertNotNull(finalStateVia, nameof(finalStateVia));
166
+
167
+ RequestMethod = requestMethod;
168
+ _headerSource = headerSource;
169
+ _startRequestUri = startRequestUri;
170
+ _nextRequestUri = nextRequestUri;
171
+ _lastKnownLocation = lastKnownLocation;
172
+ _finalStateVia = finalStateVia;
173
+ _pipeline = pipeline;
174
+ _apiVersion = apiVersion;
175
+ if (operationId is not null)
176
+ {
177
+ OperationId = operationId;
178
+ }
179
+ else if (isNextRequestPolling)
180
+ {
181
+ OperationId = ParseOperationId(startRequestUri, nextRequestUri);
182
+ }
183
+ }
184
+
185
+ private static string ParseOperationId(Uri startRequestUri, string nextRequestUri)
186
+ {
187
+ if (Uri.TryCreate(nextRequestUri, UriKind.Absolute, out var nextLink) && nextLink.Scheme != "file")
188
+ {
189
+ return nextLink.Segments.Last();
190
+ }
191
+ else
192
+ {
193
+ return new Uri(startRequestUri, nextRequestUri).Segments.Last();
194
+ }
195
+ }
196
+
197
+ public RehydrationToken GetRehydrationToken()
198
+ => GetRehydrationToken(RequestMethod, _startRequestUri, _nextRequestUri, _headerSource.ToString(), _lastKnownLocation, _finalStateVia.ToString(), OperationId);
199
+
200
+ public static RehydrationToken GetRehydrationToken(
201
+ RequestMethod requestMethod,
202
+ Uri startRequestUri,
203
+ Response response,
204
+ OperationFinalStateVia finalStateVia)
205
+ {
206
+ AssertNotNull(requestMethod, nameof(requestMethod));
207
+ AssertNotNull(startRequestUri, nameof(startRequestUri));
208
+ AssertNotNull(response, nameof(response));
209
+ AssertNotNull(finalStateVia, nameof(finalStateVia));
210
+
211
+ var headerSource = GetHeaderSource(requestMethod, startRequestUri, response, null, out string nextRequestUri, out bool isNextRequestPolling);
212
+ string? lastKnownLocation;
213
+ if (!response.Headers.TryGetValue("Location", out lastKnownLocation))
214
+ {
215
+ lastKnownLocation = null;
216
+ }
217
+ return GetRehydrationToken(requestMethod, startRequestUri, nextRequestUri, headerSource.ToString(), lastKnownLocation, finalStateVia.ToString(), isNextRequestPolling ? ParseOperationId(startRequestUri, nextRequestUri) : null);
218
+ }
219
+
220
+ public static RehydrationToken GetRehydrationToken(
221
+ RequestMethod requestMethod,
222
+ Uri startRequestUri,
223
+ string nextRequestUri,
224
+ string headerSource,
225
+ string? lastKnownLocation,
226
+ string finalStateVia,
227
+ string? operationId = null)
228
+ {
229
+ // TODO: Once we remove NextLinkOperationImplementation from internal shared and make it internal to Azure.Core only in https://github.com/Azure/azure-sdk-for-net/issues/43260
230
+ // We can access the internal members from RehydrationToken directly
231
+ var json = $$"""
232
+ {"version":"{{RehydrationTokenVersion}}","id":{{ConstructStringValue(operationId)}},"requestMethod":"{{requestMethod}}","initialUri":"{{startRequestUri.AbsoluteUri}}","nextRequestUri":"{{nextRequestUri}}","headerSource":"{{headerSource}}","finalStateVia":"{{finalStateVia}}","lastKnownLocation":{{ConstructStringValue(lastKnownLocation)}}}
233
+ """;
234
+ var data = new BinaryData(json);
235
+ return ModelReaderWriter.Read<RehydrationToken>(data, ModelReaderWriterOptions.Json, AzureCoreContext.Default);
236
+ }
237
+
238
+ private static string? ConstructStringValue(string? value) => value is null ? "null" : $"\"{value}\"";
239
+
240
+ public async ValueTask<OperationState> UpdateStateAsync(bool async, CancellationToken cancellationToken)
241
+ {
242
+ Response response = async
243
+ ? await GetResponseAsync(_nextRequestUri, cancellationToken).ConfigureAwait(false)
244
+ : GetResponse(_nextRequestUri, cancellationToken);
245
+
246
+ var hasCompleted = IsFinalState(response, _headerSource, out var failureState, out var resourceLocation);
247
+ if (failureState != null)
248
+ {
249
+ return failureState.Value;
250
+ }
251
+
252
+ if (hasCompleted)
253
+ {
254
+ string? finalUri = GetFinalUri(resourceLocation);
255
+ Response finalResponse;
256
+ if (finalUri != null)
257
+ {
258
+ finalResponse = async
259
+ ? await GetResponseAsync(finalUri, cancellationToken).ConfigureAwait(false)
260
+ : GetResponse(finalUri, cancellationToken);
261
+ }
262
+ else
263
+ {
264
+ finalResponse = response;
265
+ }
266
+ return GetOperationStateFromFinalResponse(RequestMethod, finalResponse);
267
+ }
268
+
269
+ UpdateNextRequestUri(response.Headers);
270
+ return OperationState.Pending(response);
271
+ }
272
+
273
+ private static OperationState GetOperationStateFromFinalResponse(RequestMethod requestMethod, Response response)
274
+ {
275
+ switch (response.Status)
276
+ {
277
+ case 200:
278
+ case 201 when requestMethod == RequestMethod.Put:
279
+ case 204 when requestMethod != RequestMethod.Put && requestMethod != RequestMethod.Patch:
280
+ return OperationState.Success(response);
281
+ default:
282
+ return OperationState.Failure(response);
283
+ }
284
+ }
285
+
286
+ private void UpdateNextRequestUri(ResponseHeaders headers)
287
+ {
288
+ var hasLocation = headers.TryGetValue("Location", out string? location);
289
+ if (hasLocation)
290
+ {
291
+ _lastKnownLocation = location;
292
+ }
293
+
294
+ switch (_headerSource)
295
+ {
296
+ case HeaderSource.OperationLocation when headers.TryGetValue("Operation-Location", out string? operationLocation):
297
+ _nextRequestUri = AppendOrReplaceApiVersion(operationLocation, _apiVersion);
298
+ OperationId = ParseOperationId(_startRequestUri, _nextRequestUri);
299
+ return;
300
+ case HeaderSource.AzureAsyncOperation when headers.TryGetValue("Azure-AsyncOperation", out string? azureAsyncOperation):
301
+ _nextRequestUri = AppendOrReplaceApiVersion(azureAsyncOperation, _apiVersion);
302
+ OperationId = ParseOperationId(_startRequestUri, _nextRequestUri);
303
+ return;
304
+ case HeaderSource.Location when hasLocation:
305
+ _nextRequestUri = AppendOrReplaceApiVersion(location!, _apiVersion);
306
+ OperationId = ParseOperationId(_startRequestUri, _nextRequestUri);
307
+ return;
308
+ }
309
+ }
310
+
311
+ internal static string AppendOrReplaceApiVersion(string uri, string? apiVersion)
312
+ {
313
+ if (!string.IsNullOrEmpty(apiVersion))
314
+ {
315
+ var uriSpan = uri.AsSpan();
316
+ var apiVersionParamSpan = ApiVersionParam.AsSpan();
317
+ var apiVersionIndex = uriSpan.IndexOf(apiVersionParamSpan);
318
+ if (apiVersionIndex == -1)
319
+ {
320
+ var concatSymbol = uriSpan.IndexOf('?') > -1 ? "&" : "?";
321
+ return $"{uri}{concatSymbol}api-version={apiVersion}";
322
+ }
323
+ else
324
+ {
325
+ var lengthToEndOfApiVersionParam = apiVersionIndex + ApiVersionParam.Length;
326
+ ReadOnlySpan<char> remaining = uriSpan.Slice(lengthToEndOfApiVersionParam);
327
+ bool apiVersionHasEqualSign = false;
328
+ if (remaining.IndexOf('=') == 0)
329
+ {
330
+ remaining = remaining.Slice(1);
331
+ lengthToEndOfApiVersionParam += 1;
332
+ apiVersionHasEqualSign = true;
333
+ }
334
+ var indexOfFirstSignAfterApiVersion = remaining.IndexOf('&');
335
+ ReadOnlySpan<char> uriBeforeApiVersion = uriSpan.Slice(0, lengthToEndOfApiVersionParam);
336
+ if (indexOfFirstSignAfterApiVersion == -1)
337
+ {
338
+ return string.Concat(uriBeforeApiVersion.ToString(), apiVersionHasEqualSign ? string.Empty : "=", apiVersion);
339
+ }
340
+ else
341
+ {
342
+ ReadOnlySpan<char> uriAfterApiVersion = uriSpan.Slice(indexOfFirstSignAfterApiVersion + lengthToEndOfApiVersionParam);
343
+ return string.Concat(uriBeforeApiVersion.ToString(), apiVersionHasEqualSign ? string.Empty : "=", apiVersion, uriAfterApiVersion.ToString());
344
+ }
345
+ }
346
+ }
347
+ return uri;
348
+ }
349
+
350
+ internal static bool TryGetApiVersion(Uri startRequestUri, out ReadOnlySpan<char> apiVersion)
351
+ {
352
+ apiVersion = default;
353
+ ReadOnlySpan<char> uriSpan = startRequestUri.Query.AsSpan();
354
+ int startIndex = uriSpan.IndexOf(ApiVersionParam.AsSpan());
355
+ if (startIndex == -1)
356
+ {
357
+ return false;
358
+ }
359
+ startIndex += ApiVersionParam.Length;
360
+ ReadOnlySpan<char> remaining = uriSpan.Slice(startIndex);
361
+ if (remaining.IndexOf('=') == 0)
362
+ {
363
+ remaining = remaining.Slice(1);
364
+ startIndex += 1;
365
+ }
366
+ else
367
+ {
368
+ return false;
369
+ }
370
+ int endIndex = remaining.IndexOf('&');
371
+ int length = endIndex == -1 ? uriSpan.Length - startIndex : endIndex;
372
+ apiVersion = uriSpan.Slice(startIndex, length);
373
+ return true;
374
+ }
375
+
376
+ /// <summary>
377
+ /// This function is used to get the final request uri after the lro has completed.
378
+ /// </summary>
379
+ private string? GetFinalUri(string? resourceLocation)
380
+ {
381
+ // Set final uri as null if the response for initial request doesn't contain header "Operation-Location" or "Azure-AsyncOperation".
382
+ if (_headerSource is not (HeaderSource.OperationLocation or HeaderSource.AzureAsyncOperation))
383
+ {
384
+ return null;
385
+ }
386
+
387
+ // Set final uri as null if initial request is a delete method.
388
+ if (RequestMethod == RequestMethod.Delete)
389
+ {
390
+ return null;
391
+ }
392
+
393
+ // Handle final-state-via options: https://github.com/Azure/autorest/blob/main/docs/extensions/readme.md#x-ms-long-running-operation-options
394
+ switch (_finalStateVia)
395
+ {
396
+ case OperationFinalStateVia.LocationOverride when !string.IsNullOrEmpty(_lastKnownLocation):
397
+ return _lastKnownLocation;
398
+ case OperationFinalStateVia.OperationLocation or OperationFinalStateVia.AzureAsyncOperation when RequestMethod == RequestMethod.Post:
399
+ return null;
400
+ case OperationFinalStateVia.OriginalUri:
401
+ return _startRequestUri.AbsoluteUri;
402
+ }
403
+
404
+ // If response body contains resourceLocation, use it: https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#target-resource-location
405
+ if (resourceLocation != null)
406
+ {
407
+ return resourceLocation;
408
+ }
409
+
410
+ // If initial request is PUT or PATCH, return initial request Uri
411
+ if (RequestMethod == RequestMethod.Put || RequestMethod == RequestMethod.Patch)
412
+ {
413
+ return _startRequestUri.AbsoluteUri;
414
+ }
415
+
416
+ // If response for initial request contains header "Location", return last known location
417
+ if (!string.IsNullOrEmpty(_lastKnownLocation))
418
+ {
419
+ return _lastKnownLocation;
420
+ }
421
+
422
+ return null;
423
+ }
424
+
425
+ private Response GetResponse(string uri, CancellationToken cancellationToken)
426
+ {
427
+ using HttpMessage message = CreateRequest(uri);
428
+ _pipeline.Send(message, cancellationToken);
429
+
430
+ // If we are doing final get for a delete LRO with 404, just return empty response with 204
431
+ if (message.Response.Status == 404 && RequestMethod == RequestMethod.Delete)
432
+ {
433
+ return new EmptyResponse(HttpStatusCode.NoContent, message.Response.ClientRequestId);
434
+ }
435
+ return message.Response;
436
+ }
437
+
438
+ private async ValueTask<Response> GetResponseAsync(string uri, CancellationToken cancellationToken)
439
+ {
440
+ using HttpMessage message = CreateRequest(uri);
441
+ await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
442
+
443
+ // If we are doing final get for a delete LRO with 404, just return empty response with 204
444
+ if (message.Response.Status == 404 && RequestMethod == RequestMethod.Delete)
445
+ {
446
+ return new EmptyResponse(HttpStatusCode.NoContent, message.Response.ClientRequestId);
447
+ }
448
+ return message.Response;
449
+ }
450
+
451
+ /// <summary>
452
+ /// This is only used for final get of the delete LRO, we just want to return an empty response with 204 to the user for this case.
453
+ /// </summary>
454
+ private sealed class EmptyResponse : Response
455
+ {
456
+ public EmptyResponse(HttpStatusCode status, string clientRequestId)
457
+ {
458
+ Status = (int)status;
459
+ ReasonPhrase = status.ToString();
460
+ ClientRequestId = clientRequestId;
461
+ }
462
+
463
+ public override int Status { get; }
464
+
465
+ public override string ReasonPhrase { get; }
466
+
467
+ public override Stream? ContentStream { get => null; set => throw new InvalidOperationException("Should not set ContentStream for an empty response."); }
468
+ public override string ClientRequestId { get; set; }
469
+
470
+ public override void Dispose()
471
+ {
472
+ }
473
+
474
+ /// <inheritdoc />
475
+ #if HAS_INTERNALS_VISIBLE_CORE
476
+ internal
477
+ #endif
478
+ protected override bool ContainsHeader(string name) => false;
479
+
480
+ /// <inheritdoc />
481
+ #if HAS_INTERNALS_VISIBLE_CORE
482
+ internal
483
+ #endif
484
+ protected override IEnumerable<HttpHeader> EnumerateHeaders() => Array.Empty<HttpHeader>();
485
+
486
+ /// <inheritdoc />
487
+ #if HAS_INTERNALS_VISIBLE_CORE
488
+ internal
489
+ #endif
490
+ protected override bool TryGetHeader(string name, out string value)
491
+ {
492
+ value = string.Empty;
493
+ return false;
494
+ }
495
+
496
+ /// <inheritdoc />
497
+ #if HAS_INTERNALS_VISIBLE_CORE
498
+ internal
499
+ #endif
500
+ protected override bool TryGetHeaderValues(string name, out IEnumerable<string> values)
501
+ {
502
+ values = Array.Empty<string>();
503
+ return false;
504
+ }
505
+ }
506
+
507
+ private HttpMessage CreateRequest(string uri)
508
+ {
509
+ HttpMessage message = _pipeline.CreateMessage();
510
+ Request request = message.Request;
511
+ request.Method = RequestMethod.Get;
512
+
513
+ if (Uri.TryCreate(uri, UriKind.Absolute, out var nextLink) && nextLink.Scheme != "file")
514
+ {
515
+ request.Uri.Reset(nextLink);
516
+ }
517
+ else
518
+ {
519
+ request.Uri.Reset(new Uri(_startRequestUri, uri));
520
+ }
521
+
522
+ return message;
523
+ }
524
+
525
+ private static bool IsFinalState(Response response, HeaderSource headerSource, out OperationState? failureState, out string? resourceLocation)
526
+ {
527
+ failureState = null;
528
+ resourceLocation = null;
529
+
530
+ if (headerSource == HeaderSource.Location)
531
+ {
532
+ return response.Status != 202;
533
+ }
534
+
535
+ if (response.Status is >= 200 and <= 204)
536
+ {
537
+ if (response.ContentStream is { Length: > 0 })
538
+ {
539
+ try
540
+ {
541
+ using JsonDocument document = JsonDocument.Parse(response.ContentStream);
542
+ var root = document.RootElement;
543
+ switch (headerSource)
544
+ {
545
+ case HeaderSource.None when root.TryGetProperty("properties", out var properties) && properties.TryGetProperty("provisioningState", out JsonElement property):
546
+ case HeaderSource.OperationLocation when root.TryGetProperty("status", out property):
547
+ case HeaderSource.AzureAsyncOperation when root.TryGetProperty("status", out property):
548
+ var state = GetRequiredString(property).ToLowerInvariant();
549
+ if (FailureStates.Contains(state))
550
+ {
551
+ failureState = OperationState.Failure(response);
552
+ return true;
553
+ }
554
+ else if (!SuccessStates.Contains(state))
555
+ {
556
+ return false;
557
+ }
558
+ else
559
+ {
560
+ if (headerSource is HeaderSource.OperationLocation or HeaderSource.AzureAsyncOperation && root.TryGetProperty("resourceLocation", out var resourceLocationProperty))
561
+ {
562
+ resourceLocation = resourceLocationProperty.GetString();
563
+ }
564
+ return true;
565
+ }
566
+ }
567
+ }
568
+ finally
569
+ {
570
+ // It is required to reset the position of the content after reading as this response may be used for deserialization.
571
+ response.ContentStream.Position = 0;
572
+ }
573
+ }
574
+
575
+ // If headerSource is None and provisioningState was not found, it defaults to Succeeded.
576
+ if (headerSource == HeaderSource.None)
577
+ {
578
+ return true;
579
+ }
580
+ }
581
+
582
+ failureState = OperationState.Failure(response);
583
+ return true;
584
+ }
585
+
586
+ private static string GetRequiredString(in JsonElement element)
587
+ {
588
+ var value = element.GetString();
589
+ if (value == null)
590
+ throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'.");
591
+
592
+ return value;
593
+ }
594
+
595
+ private static bool ShouldIgnoreHeader(RequestMethod method, Response response)
596
+ => method.Method == RequestMethod.Patch.Method && response.Status == 200;
597
+
598
+ // Since this method is static, we can't manipulate the instance property OperationId of the class. We need to return isRequestPolling to update the OperationId after creaing the instance.
599
+ private static HeaderSource GetHeaderSource(RequestMethod requestMethod, Uri requestUri, Response response, string? apiVersion, out string nextRequestUri, out bool isNextRequestPolling)
600
+ {
601
+ isNextRequestPolling = false;
602
+ if (ShouldIgnoreHeader(requestMethod, response))
603
+ {
604
+ nextRequestUri = requestUri.AbsoluteUri;
605
+ return HeaderSource.None;
606
+ }
607
+
608
+ var headers = response.Headers;
609
+ if (headers.TryGetValue("Operation-Location", out var operationLocationUri))
610
+ {
611
+ nextRequestUri = AppendOrReplaceApiVersion(operationLocationUri, apiVersion);
612
+ isNextRequestPolling = true;
613
+ return HeaderSource.OperationLocation;
614
+ }
615
+
616
+ if (headers.TryGetValue("Azure-AsyncOperation", out var azureAsyncOperationUri))
617
+ {
618
+ nextRequestUri = AppendOrReplaceApiVersion(azureAsyncOperationUri, apiVersion);
619
+ isNextRequestPolling = true;
620
+ return HeaderSource.AzureAsyncOperation;
621
+ }
622
+
623
+ if (headers.TryGetValue("Location", out var locationUri))
624
+ {
625
+ nextRequestUri = AppendOrReplaceApiVersion(locationUri, apiVersion);
626
+ isNextRequestPolling = true;
627
+ return HeaderSource.Location;
628
+ }
629
+
630
+ nextRequestUri = requestUri.AbsoluteUri;
631
+ return HeaderSource.None;
632
+ }
633
+
634
+ private static void AssertNotNull<T>(T value, string name)
635
+ {
636
+ if (value is null)
637
+ {
638
+ throw new ArgumentNullException(name);
639
+ }
640
+ }
641
+
642
+ private enum HeaderSource
643
+ {
644
+ None,
645
+ OperationLocation,
646
+ AzureAsyncOperation,
647
+ Location
648
+ }
649
+
650
+ private class CompletedOperation : IOperation
651
+ {
652
+ private readonly OperationState _operationState;
653
+
654
+ private readonly NextLinkOperationImplementation _operation;
655
+
656
+ public CompletedOperation(OperationState operationState, NextLinkOperationImplementation operation)
657
+ {
658
+ _operationState = operationState;
659
+ _operation = operation;
660
+ }
661
+
662
+ public ValueTask<OperationState> UpdateStateAsync(bool async, CancellationToken cancellationToken) => new(_operationState);
663
+
664
+ public RehydrationToken GetRehydrationToken() => _operation.GetRehydrationToken();
665
+ }
666
+
667
+ private sealed class OperationToOperationOfT<T> : IOperation<T>
668
+ {
669
+ private readonly IOperationSource<T> _operationSource;
670
+ private readonly IOperation _operation;
671
+
672
+ public OperationToOperationOfT(IOperationSource<T> operationSource, IOperation operation)
673
+ {
674
+ _operationSource = operationSource;
675
+ _operation = operation;
676
+ }
677
+
678
+ public async ValueTask<OperationState<T>> UpdateStateAsync(bool async, CancellationToken cancellationToken)
679
+ {
680
+ var state = await _operation.UpdateStateAsync(async, cancellationToken).ConfigureAwait(false);
681
+ if (state.HasSucceeded)
682
+ {
683
+ var result = async
684
+ ? await _operationSource.CreateResultAsync(state.RawResponse, cancellationToken).ConfigureAwait(false)
685
+ : _operationSource.CreateResult(state.RawResponse, cancellationToken);
686
+
687
+ return OperationState<T>.Success(state.RawResponse, result);
688
+ }
689
+
690
+ if (state.HasCompleted)
691
+ {
692
+ return OperationState<T>.Failure(state.RawResponse, state.OperationFailedException);
693
+ }
694
+
695
+ return OperationState<T>.Pending(state.RawResponse);
696
+ }
697
+
698
+ public RehydrationToken GetRehydrationToken() => _operation.GetRehydrationToken();
699
+ }
700
+ }
701
+ }