@autorest/powershell 4.0.0-dev.4 → 4.0.0-dev.5

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 (245) hide show
  1. package/.rush/temp/package-deps_build.json +41 -19
  2. package/.rush/temp/shrinkwrap-deps.json +13 -7
  3. package/autorest-configuration-for-sdk.md +110 -0
  4. package/autorest-configuration.md +2 -1
  5. package/dist/cmdlets/class.d.ts.map +1 -1
  6. package/dist/cmdlets/class.js +41 -8
  7. package/dist/cmdlets/class.js.map +1 -1
  8. package/dist/cmdlets/namespace.js +1 -0
  9. package/dist/cmdlets/namespace.js.map +1 -1
  10. package/dist/cmdlets/parameter.js +1 -0
  11. package/dist/cmdlets/parameter.js.map +1 -1
  12. package/dist/enums/namespace.js +2 -1
  13. package/dist/enums/namespace.js.map +1 -1
  14. package/dist/file-formats/md-file.js +1 -0
  15. package/dist/file-formats/md-file.js.map +1 -1
  16. package/dist/file-formats/psd-file.js +1 -0
  17. package/dist/file-formats/psd-file.js.map +1 -1
  18. package/dist/file-formats/psscript-file.js +1 -0
  19. package/dist/file-formats/psscript-file.js.map +1 -1
  20. package/dist/generators/csproj.js +1 -0
  21. package/dist/generators/csproj.js.map +1 -1
  22. package/dist/generators/gitattributes.js +1 -0
  23. package/dist/generators/gitattributes.js.map +1 -1
  24. package/dist/generators/gitignore.js +1 -0
  25. package/dist/generators/gitignore.js.map +1 -1
  26. package/dist/generators/inputhandler.custom.js +1 -0
  27. package/dist/generators/inputhandler.custom.js.map +1 -1
  28. package/dist/generators/nuspec.js +1 -0
  29. package/dist/generators/nuspec.js.map +1 -1
  30. package/dist/generators/psm1.custom.js +1 -0
  31. package/dist/generators/psm1.custom.js.map +1 -1
  32. package/dist/generators/psm1.internal.js +1 -0
  33. package/dist/generators/psm1.internal.js.map +1 -1
  34. package/dist/generators/psm1.js +1 -0
  35. package/dist/generators/psm1.js.map +1 -1
  36. package/dist/generators/readme.js +1 -0
  37. package/dist/generators/readme.js.map +1 -1
  38. package/dist/generators/script-cmdlet.js +1 -0
  39. package/dist/generators/script-cmdlet.js.map +1 -1
  40. package/dist/internal/name-inferrer.js +1 -0
  41. package/dist/internal/name-inferrer.js.map +1 -1
  42. package/dist/internal/powershell-declarations.d.ts +2 -0
  43. package/dist/internal/powershell-declarations.d.ts.map +1 -1
  44. package/dist/internal/powershell-declarations.js +2 -0
  45. package/dist/internal/powershell-declarations.js.map +1 -1
  46. package/dist/internal/project.js +1 -0
  47. package/dist/internal/project.js.map +1 -1
  48. package/dist/internal/state.js +1 -0
  49. package/dist/internal/state.js.map +1 -1
  50. package/dist/internal/verbs.js +1 -0
  51. package/dist/internal/verbs.js.map +1 -1
  52. package/dist/llcsharp/clientruntime.d.ts +1 -0
  53. package/dist/llcsharp/clientruntime.d.ts.map +1 -1
  54. package/dist/llcsharp/clientruntime.js +2 -0
  55. package/dist/llcsharp/clientruntime.js.map +1 -1
  56. package/dist/llcsharp/csharp-declarations.js +1 -0
  57. package/dist/llcsharp/csharp-declarations.js.map +1 -1
  58. package/dist/llcsharp/enums/enum.js +1 -0
  59. package/dist/llcsharp/enums/enum.js.map +1 -1
  60. package/dist/llcsharp/enums/namespace.js +1 -0
  61. package/dist/llcsharp/enums/namespace.js.map +1 -1
  62. package/dist/llcsharp/exports.js +23 -13
  63. package/dist/llcsharp/exports.js.map +1 -1
  64. package/dist/llcsharp/generator.js +1 -0
  65. package/dist/llcsharp/generator.js.map +1 -1
  66. package/dist/llcsharp/messages.js +1 -0
  67. package/dist/llcsharp/messages.js.map +1 -1
  68. package/dist/llcsharp/model/idictionary.js +1 -0
  69. package/dist/llcsharp/model/idictionary.js.map +1 -1
  70. package/dist/llcsharp/model/interface.js +2 -1
  71. package/dist/llcsharp/model/interface.js.map +1 -1
  72. package/dist/llcsharp/model/model-class-dictionary.js +1 -0
  73. package/dist/llcsharp/model/model-class-dictionary.js.map +1 -1
  74. package/dist/llcsharp/model/model-class-json.js +1 -0
  75. package/dist/llcsharp/model/model-class-json.js.map +1 -1
  76. package/dist/llcsharp/model/model-class-serializer.js +1 -0
  77. package/dist/llcsharp/model/model-class-serializer.js.map +1 -1
  78. package/dist/llcsharp/model/model-class.js +3 -1
  79. package/dist/llcsharp/model/model-class.js.map +1 -1
  80. package/dist/llcsharp/model/namespace.js +1 -0
  81. package/dist/llcsharp/model/namespace.js.map +1 -1
  82. package/dist/llcsharp/model/property.js +1 -0
  83. package/dist/llcsharp/model/property.js.map +1 -1
  84. package/dist/llcsharp/operation/api-class.js +1 -0
  85. package/dist/llcsharp/operation/api-class.js.map +1 -1
  86. package/dist/llcsharp/operation/method.d.ts.map +1 -1
  87. package/dist/llcsharp/operation/method.js +14 -21
  88. package/dist/llcsharp/operation/method.js.map +1 -1
  89. package/dist/llcsharp/operation/namespace.js +1 -0
  90. package/dist/llcsharp/operation/namespace.js.map +1 -1
  91. package/dist/llcsharp/operation/parameter.js +1 -0
  92. package/dist/llcsharp/operation/parameter.js.map +1 -1
  93. package/dist/llcsharp/project.js +1 -0
  94. package/dist/llcsharp/project.js.map +1 -1
  95. package/dist/llcsharp/schema/Uuid.js +1 -0
  96. package/dist/llcsharp/schema/Uuid.js.map +1 -1
  97. package/dist/llcsharp/schema/array.js +1 -0
  98. package/dist/llcsharp/schema/array.js.map +1 -1
  99. package/dist/llcsharp/schema/binary.js +1 -0
  100. package/dist/llcsharp/schema/binary.js.map +1 -1
  101. package/dist/llcsharp/schema/boolean.js +1 -0
  102. package/dist/llcsharp/schema/boolean.js.map +1 -1
  103. package/dist/llcsharp/schema/byte-array.js +1 -0
  104. package/dist/llcsharp/schema/byte-array.js.map +1 -1
  105. package/dist/llcsharp/schema/char.js +1 -0
  106. package/dist/llcsharp/schema/char.js.map +1 -1
  107. package/dist/llcsharp/schema/date-time.js +1 -0
  108. package/dist/llcsharp/schema/date-time.js.map +1 -1
  109. package/dist/llcsharp/schema/date.js +1 -0
  110. package/dist/llcsharp/schema/date.js.map +1 -1
  111. package/dist/llcsharp/schema/duration.js +1 -0
  112. package/dist/llcsharp/schema/duration.js.map +1 -1
  113. package/dist/llcsharp/schema/enum.js +1 -0
  114. package/dist/llcsharp/schema/enum.js.map +1 -1
  115. package/dist/llcsharp/schema/integer.js +1 -0
  116. package/dist/llcsharp/schema/integer.js.map +1 -1
  117. package/dist/llcsharp/schema/object.js +1 -0
  118. package/dist/llcsharp/schema/object.js.map +1 -1
  119. package/dist/llcsharp/schema/password.js +1 -0
  120. package/dist/llcsharp/schema/password.js.map +1 -1
  121. package/dist/llcsharp/schema/primitive.js +1 -0
  122. package/dist/llcsharp/schema/primitive.js.map +1 -1
  123. package/dist/llcsharp/schema/schema-resolver.d.ts +2 -3
  124. package/dist/llcsharp/schema/schema-resolver.d.ts.map +1 -1
  125. package/dist/llcsharp/schema/schema-resolver.js +4 -0
  126. package/dist/llcsharp/schema/schema-resolver.js.map +1 -1
  127. package/dist/llcsharp/schema/string.js +1 -0
  128. package/dist/llcsharp/schema/string.js.map +1 -1
  129. package/dist/llcsharp/schema/uri.d.ts +10 -0
  130. package/dist/llcsharp/schema/uri.d.ts.map +1 -0
  131. package/dist/llcsharp/schema/uri.js +25 -0
  132. package/dist/llcsharp/schema/uri.js.map +1 -0
  133. package/dist/llcsharp/validations.js +1 -0
  134. package/dist/llcsharp/validations.js.map +1 -1
  135. package/dist/main.d.ts.map +1 -1
  136. package/dist/main.js +7 -0
  137. package/dist/main.js.map +1 -1
  138. package/dist/models/model-extensions.js +1 -0
  139. package/dist/models/model-extensions.js.map +1 -1
  140. package/dist/module/module-class.js +1 -0
  141. package/dist/module/module-class.js.map +1 -1
  142. package/dist/module/module-namespace.js +1 -0
  143. package/dist/module/module-namespace.js.map +1 -1
  144. package/dist/plugins/add-azure-completers-v2.js +1 -0
  145. package/dist/plugins/add-azure-completers-v2.js.map +1 -1
  146. package/dist/plugins/create-commands-v2.d.ts.map +1 -1
  147. package/dist/plugins/create-commands-v2.js +4 -2
  148. package/dist/plugins/create-commands-v2.js.map +1 -1
  149. package/dist/plugins/cs-namer-v2.js +3 -2
  150. package/dist/plugins/cs-namer-v2.js.map +1 -1
  151. package/dist/plugins/llcsharp-v2.js +1 -0
  152. package/dist/plugins/llcsharp-v2.js.map +1 -1
  153. package/dist/plugins/modifiers-v2.js +4 -3
  154. package/dist/plugins/modifiers-v2.js.map +1 -1
  155. package/dist/plugins/plugin-create-inline-properties.d.ts.map +1 -1
  156. package/dist/plugins/plugin-create-inline-properties.js +16 -1
  157. package/dist/plugins/plugin-create-inline-properties.js.map +1 -1
  158. package/dist/plugins/plugin-tweak-m4-model.js +2 -1
  159. package/dist/plugins/plugin-tweak-m4-model.js.map +1 -1
  160. package/dist/plugins/plugin-tweak-model-azure-v2.js +4 -3
  161. package/dist/plugins/plugin-tweak-model-azure-v2.js.map +1 -1
  162. package/dist/plugins/plugin-tweak-model.js +13 -12
  163. package/dist/plugins/plugin-tweak-model.js.map +1 -1
  164. package/dist/plugins/powershell-v2.d.ts.map +1 -1
  165. package/dist/plugins/powershell-v2.js +9 -0
  166. package/dist/plugins/powershell-v2.js.map +1 -1
  167. package/dist/plugins/ps-namer-v2.js +1 -0
  168. package/dist/plugins/ps-namer-v2.js.map +1 -1
  169. package/dist/plugins/sdk-cs-namer.d.ts +3 -0
  170. package/dist/plugins/sdk-cs-namer.d.ts.map +1 -0
  171. package/dist/plugins/sdk-cs-namer.js +213 -0
  172. package/dist/plugins/sdk-cs-namer.js.map +1 -0
  173. package/dist/plugins/sdk-generate.d.ts +3 -0
  174. package/dist/plugins/sdk-generate.d.ts.map +1 -0
  175. package/dist/plugins/sdk-generate.js +60 -0
  176. package/dist/plugins/sdk-generate.js.map +1 -0
  177. package/dist/plugins/sdk-tweak-model.d.ts +3 -0
  178. package/dist/plugins/sdk-tweak-model.d.ts.map +1 -0
  179. package/dist/plugins/sdk-tweak-model.js +198 -0
  180. package/dist/plugins/sdk-tweak-model.js.map +1 -0
  181. package/dist/sdk/project.d.ts +44 -0
  182. package/dist/sdk/project.d.ts.map +1 -0
  183. package/dist/sdk/project.js +45 -0
  184. package/dist/sdk/project.js.map +1 -0
  185. package/dist/sdk/state.d.ts +23 -0
  186. package/dist/sdk/state.d.ts.map +1 -0
  187. package/dist/sdk/state.js +28 -0
  188. package/dist/sdk/state.js.map +1 -0
  189. package/dist/sdk/utility.d.ts +5 -0
  190. package/dist/sdk/utility.d.ts.map +1 -0
  191. package/dist/sdk/utility.js +17 -0
  192. package/dist/sdk/utility.js.map +1 -0
  193. package/dist/utils/PwshModel.js +1 -0
  194. package/dist/utils/PwshModel.js.map +1 -1
  195. package/dist/utils/SdkModel.d.ts +7 -0
  196. package/dist/utils/SdkModel.d.ts.map +1 -0
  197. package/dist/utils/SdkModel.js +17 -0
  198. package/dist/utils/SdkModel.js.map +1 -0
  199. package/dist/utils/command-operation.js +2 -2
  200. package/dist/utils/command-operation.js.map +1 -1
  201. package/dist/utils/components.d.ts +2 -0
  202. package/dist/utils/components.d.ts.map +1 -1
  203. package/dist/utils/components.js +1 -0
  204. package/dist/utils/components.js.map +1 -1
  205. package/dist/utils/extensions.js +1 -0
  206. package/dist/utils/extensions.js.map +1 -1
  207. package/dist/utils/http-definitions.js +1 -0
  208. package/dist/utils/http-definitions.js.map +1 -1
  209. package/dist/utils/http-operation.js +1 -0
  210. package/dist/utils/http-operation.js.map +1 -1
  211. package/dist/utils/info.js +1 -0
  212. package/dist/utils/info.js.map +1 -1
  213. package/dist/utils/model-state.js +1 -0
  214. package/dist/utils/model-state.js.map +1 -1
  215. package/dist/utils/powershell-comment.js +1 -0
  216. package/dist/utils/powershell-comment.js.map +1 -1
  217. package/dist/utils/programatic-operation.js +2 -2
  218. package/dist/utils/programatic-operation.js.map +1 -1
  219. package/dist/utils/resolve-conflicts.js +1 -0
  220. package/dist/utils/resolve-conflicts.js.map +1 -1
  221. package/dist/utils/schema.js +1 -0
  222. package/dist/utils/schema.js.map +1 -1
  223. package/dist/utils/security-scheme.js +1 -0
  224. package/dist/utils/security-scheme.js.map +1 -1
  225. package/dist/utils/uid.js +1 -0
  226. package/dist/utils/uid.js.map +1 -1
  227. package/package.json +4 -3
  228. package/readme.md +5 -1
  229. package/resources/psruntime/Attributes/ExternalDocsAttribute.cs +30 -0
  230. package/resources/psruntime/BuildTime/Models/PsMarkdownTypes.cs +37 -2
  231. package/resources/psruntime/BuildTime/Models/PsProxyOutputs.cs +3 -1
  232. package/resources/psruntime/BuildTime/Models/PsProxyTypes.cs +4 -0
  233. package/resources/runtime/csharp/pipeline/Events.cs +2 -2
  234. package/resources/templates/azureMethod.ejs +4 -0
  235. package/resources/templates/azureMethodGroup.ejs +45 -0
  236. package/resources/templates/azureServiceClient.ejs +71 -0
  237. package/resources/templates/extensionMethod.ejs +57 -0
  238. package/resources/templates/extensions.ejs +19 -0
  239. package/resources/templates/method.ejs +46 -0
  240. package/resources/templates/methodBodyRestCall.ejs +183 -0
  241. package/resources/templates/methodGroup.ejs +7 -0
  242. package/resources/templates/methodGroupInterface.ejs +53 -0
  243. package/resources/templates/model.ejs +71 -0
  244. package/resources/templates/serviceClientBody.ejs +305 -0
  245. package/resources/templates/serviceClientInterface.ejs +54 -0
@@ -0,0 +1,183 @@
1
+ <% if(method.parameters) { method.parameters.filter(p => (p.schema.type != 'constant' && p.language.default.name != '$host') || p.language.default.name == 'ApiVersion').forEach(function (parameter) {-%>
2
+ <%# ToDo: add check IsNullable with required -%>
3
+ <% var prefix = parameter.implementation == 'Client' ? 'this.Client.' : ''-%>
4
+ <% if (parameter.required) {-%>
5
+ if (<%-prefix%><%-parameter.language.default.name%> == null)
6
+ {
7
+ throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "<%-prefix%><%-parameter.language.default.name%>");
8
+ }
9
+ <% } -%>
10
+ <%# ToDo: add support for parameter.CanBeValidated && (Model.HttpMethod != HttpMethod.Patch || parameter.Location != ParameterLocation.Body)-%>
11
+ <%});}-%>
12
+ <%# ToDo: add support for p => p.IsConstant && !p.IsClientProperty -%>
13
+ <%# ToDo: add support for BuildInputMappings -%>
14
+ // Tracing
15
+ bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
16
+ string _invocationId = null;
17
+ if (_shouldTrace)
18
+ {
19
+ _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString();
20
+ System.Collections.Generic.Dictionary<string, object> tracingParameters = new System.Collections.Generic.Dictionary<string, object>();
21
+ <%# ToDo: add support for Model.LogicalParameters.Where(p => !p.IsClientProperty)-%>
22
+ tracingParameters.Add("cancellationToken", cancellationToken);
23
+ Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "<%-method.language.default.name%>", tracingParameters);
24
+ }
25
+ // Construct URL
26
+ <%# ToDo: may need to support AbsoluteUrl -%>
27
+ var _baseUrl = this.Client.BaseUri.AbsoluteUri;
28
+ <%# ToDo: buildurl, currently only added simple cases, besides we need to handle skip url encoding -%>
29
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "<%-method.requests[0].protocol.http.path.substring(1)%>").ToString();
30
+ <%if (method.parameters) { method.parameters.filter(p => p.protocol.http.in == 'path').forEach(function (pathParameter) { -%>
31
+ _url = _url.Replace("{<%-pathParameter.language.default.serializedName%>}", System.Uri.EscapeDataString(this.Client.<%-pathParameter.language.default.name%>));
32
+ <% });}-%>
33
+ System.Collections.Generic.List<string> _queryParameters = new System.Collections.Generic.List<string>();
34
+ <%if (method.parameters) { method.parameters.filter(p => p.protocol.http.in == 'query').forEach(function (queryParameter) { -%>
35
+ <% var prefix = queryParameter.implementation == 'Client' ? 'this.Client.' : ''-%>
36
+ if (<%-prefix%><%-queryParameter.language.default.name%> != null)
37
+ {
38
+ _queryParameters.Add(string.Format("<%-queryParameter.language.default.serializedName%>={0}", System.Uri.EscapeDataString(<%-prefix%><%-queryParameter.language.default.name%>)));
39
+ }
40
+ <% });}-%>
41
+ if (_queryParameters.Count > 0)
42
+ {
43
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
44
+ }
45
+ // Create HTTP transport objects
46
+ var _httpRequest = new System.Net.Http.HttpRequestMessage();
47
+ System.Net.Http.HttpResponseMessage _httpResponse = null;
48
+ _httpRequest.Method = new System.Net.Http.HttpMethod("<%-method.requests[0].protocol.http.method.toUpperCase()%>");
49
+ _httpRequest.RequestUri = new System.Uri(_url);
50
+ // Set Headers
51
+ <%# ToDo: Add headers except for following default ones -%>
52
+ if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value)
53
+ {
54
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
55
+ }
56
+ if (this.Client.AcceptLanguage != null)
57
+ {
58
+ if (_httpRequest.Headers.Contains("accept-language"))
59
+ {
60
+ _httpRequest.Headers.Remove("accept-language");
61
+ }
62
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage);
63
+ }
64
+
65
+
66
+ if (customHeaders != null)
67
+ {
68
+ foreach(var _header in customHeaders)
69
+ {
70
+ if (_httpRequest.Headers.Contains(_header.Key))
71
+ {
72
+ _httpRequest.Headers.Remove(_header.Key);
73
+ }
74
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
75
+ }
76
+ }
77
+ // Serialize Request
78
+ string _requestContent = null;
79
+ <%# ToDo: add RequestBody, formdata support-%>
80
+ <%# ToDo: Need to confirm in which case Settings.AddCredentials is false -%>
81
+ // Set Credentials
82
+ if (this.Client.Credentials != null)
83
+ {
84
+ cancellationToken.ThrowIfCancellationRequested();
85
+ await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
86
+ }
87
+ // Send Request
88
+ if (_shouldTrace)
89
+ {
90
+ Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
91
+ }
92
+ cancellationToken.ThrowIfCancellationRequested();
93
+ <%# ToDo: Add support for primary type return and head method-%>
94
+ _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
95
+ if (_shouldTrace)
96
+ {
97
+ Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
98
+ }
99
+
100
+ System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode;
101
+ cancellationToken.ThrowIfCancellationRequested();
102
+ string _responseContent = null;
103
+
104
+ if (<%-method.language.default.failureStatusCodePredicate%>)
105
+ {
106
+ var ex = new Microsoft.Rest.Azure.CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
107
+ <%# ToDo: not sure whether there is the case that there is no default response(error). If so, we will need to add support for it -%>
108
+ try
109
+ {
110
+ <%# ToDo: Need to add support for primary type -%>
111
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
112
+ CloudError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseContent, this.Client.DeserializationSettings);
113
+ if (_errorBody != null)
114
+ {
115
+ ex = new Microsoft.Rest.Azure.CloudException(_errorBody.Message);
116
+ ex.Body = _errorBody;
117
+ }
118
+ }
119
+ catch (Newtonsoft.Json.JsonException)
120
+ {
121
+ // Ignore the exception
122
+ }
123
+ ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent);
124
+ ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent);
125
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
126
+ {
127
+ ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
128
+ }
129
+ if (_shouldTrace)
130
+ {
131
+ Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex);
132
+ }
133
+ _httpRequest.Dispose();
134
+ if (_httpResponse != null)
135
+ {
136
+ _httpResponse.Dispose();
137
+ }
138
+ throw ex;
139
+ }
140
+ // Create Result
141
+ var _result = new <%-method.language.default.responseType%>();
142
+ _result.Request = _httpRequest;
143
+ _result.Response = _httpResponse;
144
+ <%# Todo: need to add support for head method, see InitializeResponseBody for details-%>
145
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
146
+ {
147
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
148
+ }
149
+ <%method.responses.filter(r => r.schema).forEach(function(resp) {-%>
150
+ // Deserialize Response
151
+ if ((int)_statusCode == <%-resp.protocol.http.statusCodes[0]%>)
152
+ {
153
+ <%# ToDo: Need to add support for primary type -%>
154
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
155
+ <%# ToDo: support for XmlSerialization, guess we do not need it actually -%>
156
+ try
157
+ {
158
+ <%# ToDo: we assume the return is object, need to add support for other types including support nullable -%>
159
+ _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject<<%-resp.schema.language.csharp.name%>>(_responseContent, this.Client.DeserializationSettings);
160
+ }
161
+ catch (Newtonsoft.Json.JsonException ex)
162
+ {
163
+ _httpRequest.Dispose();
164
+ if (_httpResponse != null)
165
+ {
166
+ _httpResponse.Dispose();
167
+ }
168
+ throw new Microsoft.Rest.SerializationException("Unable to deserialize the response.", _responseContent, ex);
169
+ }
170
+ }
171
+ <% });-%>
172
+ <%# ToDo: add support for case Model.ReturnType.Body != null && Model.DefaultResponse.Body != null && !Model.Responses.Any()-%>
173
+ <%# ToDo: add support for case there are return in headers-%>
174
+ if (_shouldTrace)
175
+ {
176
+ Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result);
177
+ }
178
+ return _result;
179
+
180
+
181
+
182
+
183
+
@@ -0,0 +1,7 @@
1
+ namespace Microsoft.Azure.PowerShell.Cmdlets {
2
+ <% methodGroup.operations.forEach(function(method){ %>
3
+ <%- include('method', {method: method}) -%>
4
+
5
+ <% }); %>
6
+ }
7
+
@@ -0,0 +1,53 @@
1
+ <%- project.commentHeader %>
2
+
3
+ namespace <%- project.namespace %>
4
+ {
5
+ <% project.model.usings.forEach(function(using){ -%>
6
+ using <%- using %>;
7
+ <% }); -%>
8
+
9
+ <% var typeName = methodGroup.$key + 'Operations' -%>
10
+ /// <summary>
11
+ /// <%- typeName %> operations.
12
+ /// </summary>
13
+ public partial interface I<%- typeName%>
14
+ {
15
+ <% methodGroup.operations.forEach(function(method){ -%>
16
+ <%# ToDo: support for ExcludeFromInterface -%>
17
+ <% if(method.language.default.description) {-%>
18
+ /// <summary>
19
+ /// <%= method.language.default.description%>
20
+ <%# ToDo: support for ExternalDocsUrl -%>
21
+ /// </summary>
22
+ /// <remarks>
23
+ /// <%= method.language.default.description%>
24
+ /// </remarks>
25
+ <% };-%>
26
+ <% method.parameters.filter(p=>p.implementation != 'Client').forEach(function(parameter){-%>
27
+ /// <param name='<%-parameter.language.default.name%>'>
28
+ /// <%= parameter.language.default.description%>
29
+ /// </param>
30
+ <% }); -%>
31
+ /// <param name='customHeaders'>
32
+ /// The headers that will be added to request.
33
+ /// </param>
34
+ /// <param name='cancellationToken'>
35
+ /// </param>
36
+ <%# ToDo: Need to figure out whether we could hand code the exception here -%>
37
+ /// <exception cref="Microsoft.Rest.Azure.CloudException">
38
+ /// </exception>
39
+ <% if (method.responses.filter(r => r.schema).length > 0) {-%>
40
+ /// <exception cref="Microsoft.Rest.SerializationException">
41
+ /// Thrown when unable to deserialize the response
42
+ /// </exception>
43
+ <% }; -%>
44
+ <% if (method.parameters.filter(p => p.required && p.nullable).length > 0) {-%>
45
+ /// <exception cref="Microsoft.Rest.ValidationException">
46
+ /// Thrown when a required parameter is null
47
+ /// </exception>
48
+ <% }; -%>
49
+ <%# ToDo: support GetObsoleteAttribute, deprecated message?-%>
50
+ System.Threading.Tasks.Task<<%-method.language.default.responseType %>> <%- method.language.default.name%>WithHttpMessagesAsync(<%-method.language.default.asyncMethodParameterDeclarationWithCustomHeader%>);
51
+ <% }); -%>
52
+ }
53
+ }
@@ -0,0 +1,71 @@
1
+ <%- project.commentHeader %>
2
+
3
+ namespace <%- project.namespace %>.Models
4
+ {
5
+ using System.Linq;
6
+
7
+ <%# ToDo: need to populate effectiveDocumentation in the model-%>
8
+ <% if (model.language.default.description) {-%>
9
+ /// <summary>
10
+ /// <%=model.language.default.description%>
11
+ /// </summary>
12
+ <% }-%>
13
+ <% if (model.summary && model.language.default.description) { -%>
14
+ /// <remarks>
15
+ /// <%=model.language.default.description %>
16
+ /// </remarks>
17
+ <% } -%>
18
+ <%# ToDo: support NeedsPolymorphicConverter-%>
19
+ <%# ToDo: support NeedsTransformationConverter-%>
20
+ <%# ToDo: support ObsoleteAttribute-%>
21
+ public partial class <%-model.language.default.name%><%- model.parents ? " : " + model.parents.immediate[0].language.default.name: ""%>
22
+ {
23
+ /// <summary>
24
+ /// Initializes a new instance of the <%= model.language.default.name%> class.
25
+ /// </summary>
26
+ public <%- model.language.default.name%>()
27
+ {
28
+ <%#ToDo support for object model that contains ContainsConstantProperties-%>
29
+ CustomInit();
30
+ }
31
+ <%#ToDo support for constructorParameters in the model, the constructorParameter is mapped to properties for the time being%>
32
+ <% if (model.properties) {-%>
33
+ /// <summary>
34
+ /// Initializes a new instance of the <%=model.language.default.name%> class.
35
+ /// </summary>
36
+ <%#ToDo support for constructorParametersDocumentation in the model, priority 0-%>
37
+ <%model.properties.forEach(function(p) {-%>
38
+ /// <param name="<%-p.language.default.name%>"><%-p.language.default.description%></param>
39
+ <%});-%>
40
+ public <%- model.language.default.name%>(<%-model.language.default.constructorParametersDeclaration%>)
41
+ <%#ToDo support for BaseConstructorCall in the model-%>
42
+ {
43
+ <%#ToDo support for InstanceProperties in the model, non const properties, priority 0-%>
44
+ <%model.properties.forEach(function(p) {-%>
45
+ this.<%-p.language.csharp.name%> = <%-p.language.default.name%>;
46
+ <%});-%>
47
+ CustomInit();
48
+ }
49
+ <% };-%>
50
+ <%#ToDo support for ClassProperties in the model, const properties-%>
51
+
52
+ /// <summary>
53
+ /// An initialization method that performs custom operations like setting defaults
54
+ /// </summary>
55
+ partial void CustomInit();
56
+
57
+ <%#ToDo support for InstanceProperties in the model, non const properties, priority 0, line 407-%>
58
+ <% if (model.properties) { model.properties.filter(p => p.schema.type != 'constant').forEach(function(p){-%>
59
+ /// <summary>
60
+ /// <%-p.language.csharp.formattedPropertySummary%>
61
+ /// </summary>
62
+ [Newtonsoft.Json.JsonProperty(PropertyName = "<%-p.serializedName%>")]
63
+ <% var type = p.schema.language.csharp.fullname-%>
64
+ <%type = p.schema.type == 'object' || type == 'string' ? type : type + '?'-%>
65
+ public <%-type %> <%-p.language.csharp.name%> {get; <%- p.readOnly ? "private " : ""-%>set; }
66
+ <% });} -%>
67
+ <%#ToDo support for ClassProperties in the model, const properties -%>
68
+ <%#ToDo support for ShouldValidateChain-%>
69
+ <%#ToDo support for ShouldGenerateXmlSerialization, guess we do not need to support it-%>
70
+ }
71
+ }
@@ -0,0 +1,305 @@
1
+ /// <summary>
2
+ /// The base URI of the service.
3
+ /// </summary>
4
+ <%# ToDo: Add support for customBaseUri, priority is low-%>
5
+ public System.Uri BaseUri { get; set; }
6
+ /// <summary>
7
+ /// Gets or sets json serialization settings.
8
+ /// </summary>
9
+ public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; }
10
+ /// <summary>
11
+ /// Gets or sets json deserialization settings.
12
+ /// </summary>
13
+ public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; }
14
+ <% project.model.globalParameters.filter(p=>p.language.default.name != '$host').forEach(function(parameter) {-%>
15
+ /// <summary>
16
+ /// <%=parameter.language.default.description%>
17
+ /// </summary>
18
+ <% var type = parameter.schema.type == 'constant' ? parameter.schema.valueType.language.csharp.fullname : parameter.schema.language.csharp.fullname-%>
19
+ <%type = type.includes('.') || type == 'string' ? type : type + '?'-%>
20
+ <% if (parameter.readOnly || parameter.schema.type == 'constant') {-%>
21
+ public <%- type %> <%- parameter.language.default.name%> { get; private set; }
22
+ <% } else {-%>
23
+ public <%- type %> <%- parameter.language.default.name%> { get; set;}
24
+ <% }%>
25
+ <%});-%>
26
+ <% project.model.operationGroups.forEach(function(methodGroup){ -%>
27
+ /// <summary>
28
+ /// Gets the I<%- methodGroup.$key %>Operations
29
+ /// </summary>
30
+ public virtual I<%- methodGroup.$key %>Operations <%- methodGroup.$key %> { get; private set; }
31
+ <% }); -%>
32
+ /// <summary>
33
+ /// Initializes a new instance of the <%-project.model.info.title%> class.
34
+ /// </summary>
35
+ /// <param name='httpClient'>
36
+ /// HttpClient to be used
37
+ /// </param>
38
+ /// <param name='disposeHttpClient'>
39
+ /// True: will dispose the provided httpClient on calling <%-project.model.info.title%>.Dispose(). False: will not dispose provided httpClient</param>
40
+ <%# ToDo: Add support for case that ContainsCredentials is false, low priority-%>
41
+ protected <%-project.model.info.title%>(System.Net.Http.HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient)
42
+ {
43
+ this.Initialize();
44
+ }
45
+ /// <summary>
46
+ /// Initializes a new instance of the <%-project.model.info.title%> class.
47
+ /// </summary>
48
+ /// <param name='handlers'>
49
+ /// Optional. The delegating handlers to add to the http client pipeline.
50
+ /// </param>
51
+ protected <%-project.model.info.title%>(params System.Net.Http.DelegatingHandler[] handlers) : base(handlers)
52
+ {
53
+ this.Initialize();
54
+ }
55
+ /// <summary>
56
+ /// Initializes a new instance of the <%-project.model.info.title%> class.
57
+ /// </summary>
58
+ /// <param name='rootHandler'>
59
+ /// Optional. The http client handler used to handle http transport.
60
+ /// </param>
61
+ /// <param name='handlers'>
62
+ /// Optional. The delegating handlers to add to the http client pipeline.
63
+ /// </param>
64
+ protected <%-project.model.info.title%>(System.Net.Http.HttpClientHandler rootHandler, params System.Net.Http.DelegatingHandler[] handlers) : base(rootHandler, handlers)
65
+ {
66
+ this.Initialize();
67
+ }
68
+ <%# ToDo: following true means !IsCustomBaseUri, may need to implement IsCustomBaseUri, low priority -%>
69
+ <% if(true) {-%>
70
+ /// <summary>
71
+ /// Initializes a new instance of the <%-project.model.info.title%> class.
72
+ /// </summary>
73
+ /// <param name='baseUri'>
74
+ /// Optional. The base URI of the service.
75
+ /// </param>
76
+ /// <param name='handlers'>
77
+ /// Optional. The delegating handlers to add to the http client pipeline.
78
+ /// </param>
79
+ /// <exception cref="System.ArgumentNullException">
80
+ /// Thrown when a required parameter is null
81
+ /// </exception>
82
+ protected <%-project.model.info.title%>(System.Uri baseUri, params System.Net.Http.DelegatingHandler[] handlers) : this(handlers)
83
+ {
84
+ if (baseUri == null)
85
+ {
86
+ throw new System.ArgumentNullException("baseUri");
87
+ }
88
+ this.BaseUri = baseUri;
89
+ }
90
+ /// <summary>
91
+ /// Initializes a new instance of the <%-project.model.info.title%> class.
92
+ /// </summary>
93
+ /// <param name='baseUri'>
94
+ /// Optional. The base URI of the service.
95
+ /// </param>
96
+ /// <param name='rootHandler'>
97
+ /// Optional. The http client handler used to handle http transport.
98
+ /// </param>
99
+ /// <param name='handlers'>
100
+ /// Optional. The delegating handlers to add to the http client pipeline.
101
+ /// </param>
102
+ /// <exception cref="System.ArgumentNullException">
103
+ /// Thrown when a required parameter is null
104
+ /// </exception>
105
+ protected <%-project.model.info.title%>(System.Uri baseUri, System.Net.Http.HttpClientHandler rootHandler, params System.Net.Http.DelegatingHandler[] handlers) : this(rootHandler, handlers)
106
+ {
107
+ if (baseUri == null)
108
+ {
109
+ throw new System.ArgumentNullException("baseUri");
110
+ }
111
+
112
+ this.BaseUri = baseUri;
113
+ }
114
+ <% } -%>
115
+ <% var parameters = project.model.globalParameters.filter(p => p.required && p.readOnly)
116
+ if (parameters.length > 0) {-%>
117
+ /// <summary>
118
+ /// Initializes a new instance of the <%-project.model.info.title%> class.
119
+ /// </summary>
120
+ <%parameters.forEach(function(parameter){-%>
121
+ /// <param name='<%-project.helper.CamelCase(parameter.language.default.name)%>'
122
+ /// Required. <%-parameter.language.default.description%>
123
+ /// </param>
124
+ <%});-%>
125
+ /// <param name='handlers'>
126
+ /// Optional. The delegating handlers to add to the http client pipeline.
127
+ /// </param>
128
+ /// <exception cref="System.ArgumentNullException">
129
+ /// Thrown when a required parameter is null
130
+ /// </exception>
131
+ <%# ToDo: assume the access is public, need to figure the logic of ConstructorVisibility-%>
132
+ public <%-project.model.info.title%>(<%-project.model.language.default.requiredConstructorParametersDeclaration%>, params System.Net.Http.DelegatingHandler[] handlers) : this(handlers)
133
+ {
134
+ <%parameters.forEach(function(parameter) {-%>
135
+ if (<%-project.helper.CamelCase(parameter.language.default.name)%> == null)
136
+ {
137
+ throw new System.ArgumentNullException("<%-project.helper.CamelCase(parameter.language.default.name)%>");
138
+ }
139
+ <%});-%>
140
+ <%parameters.forEach(function(parameter) {-%>
141
+ this.<%-parameter.language.default.name%> = <%-project.helper.CamelCase(parameter.language.default.name)%>;
142
+ <%if(parameter.schema.language.csharp.fullname == 'Microsoft.Rest.ServiceClientCredentials') {-%>
143
+ if (this.Credentials != null)
144
+ {
145
+ this.Credentials.InitializeServiceClient(this);
146
+ }
147
+ <% }-%>
148
+ <%});-%>
149
+ }
150
+ /// <summary>
151
+ /// Initializes a new instance of the <%-project.model.info.title%> class.
152
+ /// </summary>
153
+ <%parameters.forEach(function(parameter) {-%>
154
+ /// <param name="<%-project.helper.CamelCase(parameter.language.default.name)%>">
155
+ /// Required. <%-parameter.language.default.description%>
156
+ /// </param>
157
+ <%});-%>
158
+ /// <param name='httpClient'>
159
+ /// HttpClient to be used
160
+ /// </param>
161
+ /// <param name='disposeHttpClient'>
162
+ /// True: will dispose the provided httpClient on calling <%-project.model.info.title%>.Dispose(). False: will not dispose provided httpClient</param>
163
+ /// <exception cref="System.ArgumentNullException">
164
+ /// Thrown when a required parameter is null
165
+ /// </exception>
166
+ public <%-project.model.info.title%>(<%-project.model.language.default.requiredConstructorParametersDeclaration%>, System.Net.Http.HttpClient httpClient, bool disposeHttpClient) : this(httpClient, disposeHttpClient)
167
+ {
168
+ <%parameters.forEach(function(parameter) {-%>
169
+ if (<%-project.helper.CamelCase(parameter.language.default.name)%> == null)
170
+ {
171
+ throw new System.ArgumentNullException("<%-project.helper.CamelCase(parameter.language.default.name)%>");
172
+ }
173
+ <%});-%>
174
+ <%parameters.forEach(function(parameter) {-%>
175
+ this.<%-parameter.language.default.name%> = <%-project.helper.CamelCase(parameter.language.default.name)%>;
176
+ <%if(parameter.schema.language.csharp.fullname == 'Microsoft.Rest.ServiceClientCredentials') {-%>
177
+ if (this.Credentials != null)
178
+ {
179
+ this.Credentials.InitializeServiceClient(this);
180
+ }
181
+ <% }-%>
182
+ <%});-%>
183
+ }
184
+ /// <summary>
185
+ /// Initializes a new instance of the <%-project.model.info.title%> class.
186
+ /// </summary>
187
+ <%parameters.forEach(function(parameter) {-%>
188
+ /// <param name="<%-project.helper.CamelCase(parameter.language.default.name)%>">
189
+ /// Required. <%-parameter.language.default.description%>
190
+ /// </param>
191
+ <%});-%>
192
+ /// <param name='rootHandler'>
193
+ /// Optional. The http client handler used to handle http transport.
194
+ /// </param>
195
+ /// <param name='handlers'>
196
+ /// Optional. The delegating handlers to add to the http client pipeline.
197
+ /// </param>
198
+ /// <exception cref="System.ArgumentNullException">
199
+ /// Thrown when a required parameter is null
200
+ /// </exception>
201
+ public <%-project.model.info.title%>(<%-project.model.language.default.requiredConstructorParametersDeclaration%>, System.Net.Http.HttpClientHandler rootHandler, params System.Net.Http.DelegatingHandler[] handlers) : this(rootHandler, handlers)
202
+ {
203
+ <%parameters.forEach(function(parameter) {-%>
204
+ if (<%-project.helper.CamelCase(parameter.language.default.name)%> == null)
205
+ {
206
+ throw new System.ArgumentNullException("<%-project.helper.CamelCase(parameter.language.default.name)%>");
207
+ }
208
+ <%});-%>
209
+ <%parameters.forEach(function(parameter) {-%>
210
+ this.<%-parameter.language.default.name%> = <%-project.helper.CamelCase(parameter.language.default.name)%>;
211
+ <%if(parameter.schema.language.csharp.fullname == 'Microsoft.Rest.ServiceClientCredentials') {-%>
212
+ if (this.Credentials != null)
213
+ {
214
+ this.Credentials.InitializeServiceClient(this);
215
+ }
216
+ <% }-%>
217
+ <%});-%>
218
+ }
219
+ <%# ToDo: following true means !IsCustomBaseUri, may need to implement IsCustomBaseUri, low priority -%>
220
+ <%if (true) {-%>
221
+ /// <summary>
222
+ /// Initializes a new instance of the <%-project.model.info.title%> class.
223
+ /// </summary>
224
+ /// <param name='baseUri'>
225
+ /// Optional. The base URI of the service.
226
+ /// </param>
227
+ <%parameters.forEach(function(parameter) {-%>
228
+ /// <param name="<%-project.helper.CamelCase(parameter.language.default.name)%>">
229
+ /// Required. <%-parameter.language.default.description%>
230
+ /// </param>
231
+ <%});-%>
232
+ /// <param name='rootHandler'>
233
+ /// Optional. The http client handler used to handle http transport.
234
+ /// </param>
235
+ /// <param name='handlers'>
236
+ /// Optional. The delegating handlers to add to the http client pipeline.
237
+ /// </param>
238
+ /// <exception cref="System.ArgumentNullException">
239
+ /// Thrown when a required parameter is null
240
+ /// </exception>
241
+ public <%-project.model.info.title%>(System.Uri baseUri, <%-project.model.language.default.requiredConstructorParametersDeclaration%>, params System.Net.Http.DelegatingHandler[] handlers) : this(handlers)
242
+ {
243
+ if (baseUri == null)
244
+ {
245
+ throw new System.ArgumentNullException("baseUri");
246
+ }
247
+ <%parameters.forEach(function(parameter) {-%>
248
+ if (<%-project.helper.CamelCase(parameter.language.default.name)%> == null)
249
+ {
250
+ throw new System.ArgumentNullException("<%-project.helper.CamelCase(parameter.language.default.name)%>");
251
+ }
252
+ <%});-%>
253
+ this.BaseUri = baseUri;
254
+ <%parameters.forEach(function(parameter) {-%>
255
+ this.<%-parameter.language.default.name%> = <%-project.helper.CamelCase(parameter.language.default.name)%>;
256
+ <%if(parameter.schema.language.csharp.fullname == 'Microsoft.Rest.ServiceClientCredentials') {-%>
257
+ if (this.Credentials != null)
258
+ {
259
+ this.Credentials.InitializeServiceClient(this);
260
+ }
261
+ <% }-%>
262
+ <%});-%>
263
+ }
264
+ /// <summary>
265
+ /// Initializes a new instance of the <%-project.model.info.title%> class.
266
+ /// </summary>
267
+ /// <param name='baseUri'>
268
+ /// Optional. The base URI of the service.
269
+ /// </param>
270
+ <%parameters.forEach(function(parameter) {-%>
271
+ /// <param name="<%-project.helper.CamelCase(parameter.language.default.name)%>">
272
+ /// Required. <%-parameter.language.default.description%>
273
+ /// </param>
274
+ <%});-%>
275
+ /// <param name='rootHandler'>
276
+ /// Optional. The http client handler used to handle http transport.
277
+ /// </param>
278
+ /// <exception cref="System.ArgumentNullException">
279
+ /// Thrown when a required parameter is null
280
+ /// </exception>
281
+ public <%-project.model.info.title%>(System.Uri baseUri, <%-project.model.language.default.requiredConstructorParametersDeclaration%>, System.Net.Http.HttpClientHandler rootHandler, params System.Net.Http.DelegatingHandler[] handlers) : this(rootHandler, handlers)
282
+ {
283
+ if (baseUri == null)
284
+ {
285
+ throw new System.ArgumentNullException("baseUri");
286
+ }
287
+ <%parameters.forEach(function(parameter) {-%>
288
+ if (<%-project.helper.CamelCase(parameter.language.default.name)%> == null)
289
+ {
290
+ throw new System.ArgumentNullException("<%-project.helper.CamelCase(parameter.language.default.name)%>");
291
+ }
292
+ <%});-%>
293
+ this.BaseUri = baseUri;
294
+ <%parameters.forEach(function(parameter) {-%>
295
+ this.<%-parameter.language.default.name%> = <%-project.helper.CamelCase(parameter.language.default.name)%>;
296
+ <%if(parameter.schema.language.csharp.fullname == 'Microsoft.Rest.ServiceClientCredentials') {-%>
297
+ if (this.Credentials != null)
298
+ {
299
+ this.Credentials.InitializeServiceClient(this);
300
+ }
301
+ <% }-%>
302
+ <%});-%>
303
+ }
304
+ <%}-%>
305
+ <% }-%>