@autorest/powershell 3.0.504 → 4.0.0-dev.10
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.
- package/.rush/temp/package-deps_build.json +95 -61
- package/.rush/temp/shrinkwrap-deps.json +249 -193
- package/autorest-configuration-for-sdk.md +122 -0
- package/autorest-configuration.md +2 -1
- package/dist/cmdlets/class.d.ts +1 -0
- package/dist/cmdlets/class.d.ts.map +1 -1
- package/dist/cmdlets/class.js +220 -90
- package/dist/cmdlets/class.js.map +1 -1
- package/dist/cmdlets/namespace.d.ts.map +1 -1
- package/dist/cmdlets/namespace.js +3 -1
- package/dist/cmdlets/namespace.js.map +1 -1
- package/dist/cmdlets/parameter.js +1 -0
- package/dist/cmdlets/parameter.js.map +1 -1
- package/dist/enums/namespace.js +2 -1
- package/dist/enums/namespace.js.map +1 -1
- package/dist/file-formats/md-file.js +1 -0
- package/dist/file-formats/md-file.js.map +1 -1
- package/dist/file-formats/psd-file.js +1 -0
- package/dist/file-formats/psd-file.js.map +1 -1
- package/dist/file-formats/psscript-file.js +1 -0
- package/dist/file-formats/psscript-file.js.map +1 -1
- package/dist/generators/csproj.js +1 -0
- package/dist/generators/csproj.js.map +1 -1
- package/dist/generators/gitattributes.js +1 -0
- package/dist/generators/gitattributes.js.map +1 -1
- package/dist/generators/gitignore.js +1 -0
- package/dist/generators/gitignore.js.map +1 -1
- package/dist/generators/inputhandler.custom.d.ts +3 -0
- package/dist/generators/inputhandler.custom.d.ts.map +1 -0
- package/dist/generators/inputhandler.custom.js +33 -0
- package/dist/generators/inputhandler.custom.js.map +1 -0
- package/dist/generators/nuspec.js +1 -0
- package/dist/generators/nuspec.js.map +1 -1
- package/dist/generators/psm1.custom.js +1 -0
- package/dist/generators/psm1.custom.js.map +1 -1
- package/dist/generators/psm1.internal.js +1 -0
- package/dist/generators/psm1.internal.js.map +1 -1
- package/dist/generators/psm1.js +2 -1
- package/dist/generators/psm1.js.map +1 -1
- package/dist/generators/readme.js +1 -0
- package/dist/generators/readme.js.map +1 -1
- package/dist/generators/script-cmdlet.js +3 -2
- package/dist/generators/script-cmdlet.js.map +1 -1
- package/dist/internal/name-inferrer.js +1 -0
- package/dist/internal/name-inferrer.js.map +1 -1
- package/dist/internal/powershell-declarations.d.ts +3 -0
- package/dist/internal/powershell-declarations.d.ts.map +1 -1
- package/dist/internal/powershell-declarations.js +3 -0
- package/dist/internal/powershell-declarations.js.map +1 -1
- package/dist/internal/project.d.ts +11 -9
- package/dist/internal/project.d.ts.map +1 -1
- package/dist/internal/project.js +30 -12
- package/dist/internal/project.js.map +1 -1
- package/dist/internal/state.js +1 -0
- package/dist/internal/state.js.map +1 -1
- package/dist/internal/verbs.js +1 -0
- package/dist/internal/verbs.js.map +1 -1
- package/dist/llcsharp/clientruntime.d.ts +7 -1
- package/dist/llcsharp/clientruntime.d.ts.map +1 -1
- package/dist/llcsharp/clientruntime.js +8 -1
- package/dist/llcsharp/clientruntime.js.map +1 -1
- package/dist/llcsharp/code-model.d.ts +1 -0
- package/dist/llcsharp/code-model.d.ts.map +1 -1
- package/dist/llcsharp/csharp-declarations.js +1 -0
- package/dist/llcsharp/csharp-declarations.js.map +1 -1
- package/dist/llcsharp/enums/enum.js +2 -1
- package/dist/llcsharp/enums/enum.js.map +1 -1
- package/dist/llcsharp/enums/namespace.js +1 -0
- package/dist/llcsharp/enums/namespace.js.map +1 -1
- package/dist/llcsharp/exports.js +23 -13
- package/dist/llcsharp/exports.js.map +1 -1
- package/dist/llcsharp/generator.js +1 -0
- package/dist/llcsharp/generator.js.map +1 -1
- package/dist/llcsharp/messages.js +1 -0
- package/dist/llcsharp/messages.js.map +1 -1
- package/dist/llcsharp/model/idictionary.js +1 -0
- package/dist/llcsharp/model/idictionary.js.map +1 -1
- package/dist/llcsharp/model/interface.d.ts +3 -2
- package/dist/llcsharp/model/interface.d.ts.map +1 -1
- package/dist/llcsharp/model/interface.js +14 -8
- package/dist/llcsharp/model/interface.js.map +1 -1
- package/dist/llcsharp/model/model-class-dictionary.js +1 -0
- package/dist/llcsharp/model/model-class-dictionary.js.map +1 -1
- package/dist/llcsharp/model/model-class-json.d.ts.map +1 -1
- package/dist/llcsharp/model/model-class-json.js +25 -3
- package/dist/llcsharp/model/model-class-json.js.map +1 -1
- package/dist/llcsharp/model/model-class-serializer.js +1 -0
- package/dist/llcsharp/model/model-class-serializer.js.map +1 -1
- package/dist/llcsharp/model/model-class.js +10 -9
- package/dist/llcsharp/model/model-class.js.map +1 -1
- package/dist/llcsharp/model/namespace.js +1 -0
- package/dist/llcsharp/model/namespace.js.map +1 -1
- package/dist/llcsharp/model/property.js +1 -0
- package/dist/llcsharp/model/property.js.map +1 -1
- package/dist/llcsharp/operation/api-class.js +1 -0
- package/dist/llcsharp/operation/api-class.js.map +1 -1
- package/dist/llcsharp/operation/method.d.ts +3 -1
- package/dist/llcsharp/operation/method.d.ts.map +1 -1
- package/dist/llcsharp/operation/method.js +30 -28
- package/dist/llcsharp/operation/method.js.map +1 -1
- package/dist/llcsharp/operation/namespace.js +1 -0
- package/dist/llcsharp/operation/namespace.js.map +1 -1
- package/dist/llcsharp/operation/parameter.js +1 -0
- package/dist/llcsharp/operation/parameter.js.map +1 -1
- package/dist/llcsharp/project.d.ts.map +1 -1
- package/dist/llcsharp/project.js +3 -1
- package/dist/llcsharp/project.js.map +1 -1
- package/dist/llcsharp/schema/Uuid.js +1 -0
- package/dist/llcsharp/schema/Uuid.js.map +1 -1
- package/dist/llcsharp/schema/array.js +1 -0
- package/dist/llcsharp/schema/array.js.map +1 -1
- package/dist/llcsharp/schema/binary.js +1 -0
- package/dist/llcsharp/schema/binary.js.map +1 -1
- package/dist/llcsharp/schema/boolean.js +1 -0
- package/dist/llcsharp/schema/boolean.js.map +1 -1
- package/dist/llcsharp/schema/byte-array.js +1 -0
- package/dist/llcsharp/schema/byte-array.js.map +1 -1
- package/dist/llcsharp/schema/char.js +1 -0
- package/dist/llcsharp/schema/char.js.map +1 -1
- package/dist/llcsharp/schema/date-time.d.ts.map +1 -1
- package/dist/llcsharp/schema/date-time.js +1 -0
- package/dist/llcsharp/schema/date-time.js.map +1 -1
- package/dist/llcsharp/schema/date.js +1 -0
- package/dist/llcsharp/schema/date.js.map +1 -1
- package/dist/llcsharp/schema/duration.js +1 -0
- package/dist/llcsharp/schema/duration.js.map +1 -1
- package/dist/llcsharp/schema/enum.d.ts +1 -5
- package/dist/llcsharp/schema/enum.d.ts.map +1 -1
- package/dist/llcsharp/schema/enum.js +1 -9
- package/dist/llcsharp/schema/enum.js.map +1 -1
- package/dist/llcsharp/schema/integer.js +1 -0
- package/dist/llcsharp/schema/integer.js.map +1 -1
- package/dist/llcsharp/schema/object.js +2 -1
- package/dist/llcsharp/schema/object.js.map +1 -1
- package/dist/llcsharp/schema/password.js +2 -1
- package/dist/llcsharp/schema/password.js.map +1 -1
- package/dist/llcsharp/schema/primitive.js +1 -0
- package/dist/llcsharp/schema/primitive.js.map +1 -1
- package/dist/llcsharp/schema/schema-resolver.d.ts +2 -3
- package/dist/llcsharp/schema/schema-resolver.d.ts.map +1 -1
- package/dist/llcsharp/schema/schema-resolver.js +4 -0
- package/dist/llcsharp/schema/schema-resolver.js.map +1 -1
- package/dist/llcsharp/schema/string.d.ts.map +1 -1
- package/dist/llcsharp/schema/string.js +1 -0
- package/dist/llcsharp/schema/string.js.map +1 -1
- package/dist/llcsharp/schema/uri.d.ts +10 -0
- package/dist/llcsharp/schema/uri.d.ts.map +1 -0
- package/dist/llcsharp/schema/uri.js +25 -0
- package/dist/llcsharp/schema/uri.js.map +1 -0
- package/dist/llcsharp/validations.js +1 -0
- package/dist/llcsharp/validations.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +11 -0
- package/dist/main.js.map +1 -1
- package/dist/models/model-extensions.js +7 -6
- package/dist/models/model-extensions.js.map +1 -1
- package/dist/module/module-class.js +2 -1
- package/dist/module/module-class.js.map +1 -1
- package/dist/module/module-namespace.js +1 -0
- package/dist/module/module-namespace.js.map +1 -1
- package/dist/plugins/add-azure-completers-v2.js +1 -0
- package/dist/plugins/add-azure-completers-v2.js.map +1 -1
- package/dist/plugins/create-commands-v2.d.ts.map +1 -1
- package/dist/plugins/create-commands-v2.js +18 -21
- package/dist/plugins/create-commands-v2.js.map +1 -1
- package/dist/plugins/cs-namer-v2.d.ts.map +1 -1
- package/dist/plugins/cs-namer-v2.js +9 -3
- package/dist/plugins/cs-namer-v2.js.map +1 -1
- package/dist/plugins/llcsharp-v2.js +1 -0
- package/dist/plugins/llcsharp-v2.js.map +1 -1
- package/dist/plugins/modifiers-v2.d.ts +4 -0
- package/dist/plugins/modifiers-v2.d.ts.map +1 -1
- package/dist/plugins/modifiers-v2.js +69 -13
- package/dist/plugins/modifiers-v2.js.map +1 -1
- package/dist/plugins/plugin-create-inline-properties.d.ts.map +1 -1
- package/dist/plugins/plugin-create-inline-properties.js +51 -4
- package/dist/plugins/plugin-create-inline-properties.js.map +1 -1
- package/dist/plugins/plugin-tweak-m4-model.js +4 -3
- package/dist/plugins/plugin-tweak-m4-model.js.map +1 -1
- package/dist/plugins/plugin-tweak-model-azure-v2.js +4 -3
- package/dist/plugins/plugin-tweak-model-azure-v2.js.map +1 -1
- package/dist/plugins/plugin-tweak-model.js +15 -14
- package/dist/plugins/plugin-tweak-model.js.map +1 -1
- package/dist/plugins/powershell-v2.d.ts.map +1 -1
- package/dist/plugins/powershell-v2.js +7 -2
- package/dist/plugins/powershell-v2.js.map +1 -1
- package/dist/plugins/ps-namer-v2.js +1 -0
- package/dist/plugins/ps-namer-v2.js.map +1 -1
- package/dist/plugins/sdk-create-inline-properties.d.ts +4 -0
- package/dist/plugins/sdk-create-inline-properties.d.ts.map +1 -0
- package/dist/plugins/sdk-create-inline-properties.js +552 -0
- package/dist/plugins/sdk-create-inline-properties.js.map +1 -0
- package/dist/plugins/sdk-cs-namer.d.ts +3 -0
- package/dist/plugins/sdk-cs-namer.d.ts.map +1 -0
- package/dist/plugins/sdk-cs-namer.js +385 -0
- package/dist/plugins/sdk-cs-namer.js.map +1 -0
- package/dist/plugins/sdk-cs-simplifier.d.ts +3 -0
- package/dist/plugins/sdk-cs-simplifier.d.ts.map +1 -0
- package/dist/plugins/sdk-cs-simplifier.js +154 -0
- package/dist/plugins/sdk-cs-simplifier.js.map +1 -0
- package/dist/plugins/sdk-generate.d.ts +3 -0
- package/dist/plugins/sdk-generate.d.ts.map +1 -0
- package/dist/plugins/sdk-generate.js +106 -0
- package/dist/plugins/sdk-generate.js.map +1 -0
- package/dist/plugins/sdk-tweak-model.d.ts +3 -0
- package/dist/plugins/sdk-tweak-model.d.ts.map +1 -0
- package/dist/plugins/sdk-tweak-model.js +357 -0
- package/dist/plugins/sdk-tweak-model.js.map +1 -0
- package/dist/sdk/project.d.ts +45 -0
- package/dist/sdk/project.d.ts.map +1 -0
- package/dist/sdk/project.js +56 -0
- package/dist/sdk/project.js.map +1 -0
- package/dist/sdk/state.d.ts +23 -0
- package/dist/sdk/state.d.ts.map +1 -0
- package/dist/sdk/state.js +28 -0
- package/dist/sdk/state.js.map +1 -0
- package/dist/sdk/utility.d.ts +32 -0
- package/dist/sdk/utility.d.ts.map +1 -0
- package/dist/sdk/utility.js +414 -0
- package/dist/sdk/utility.js.map +1 -0
- package/dist/utils/PwshModel.js +1 -0
- package/dist/utils/PwshModel.js.map +1 -1
- package/dist/utils/SdkModel.d.ts +7 -0
- package/dist/utils/SdkModel.d.ts.map +1 -0
- package/dist/utils/SdkModel.js +17 -0
- package/dist/utils/SdkModel.js.map +1 -0
- package/dist/utils/TrieNode.d.ts +10 -0
- package/dist/utils/TrieNode.d.ts.map +1 -0
- package/dist/utils/TrieNode.js +45 -0
- package/dist/utils/TrieNode.js.map +1 -0
- package/dist/utils/WrapComments.d.ts +2 -0
- package/dist/utils/WrapComments.d.ts.map +1 -0
- package/dist/utils/WrapComments.js +46 -0
- package/dist/utils/WrapComments.js.map +1 -0
- package/dist/utils/code-namer.d.ts +3 -0
- package/dist/utils/code-namer.d.ts.map +1 -0
- package/dist/utils/code-namer.js +38 -0
- package/dist/utils/code-namer.js.map +1 -0
- package/dist/utils/command-operation.d.ts +7 -0
- package/dist/utils/command-operation.d.ts.map +1 -1
- package/dist/utils/command-operation.js +8 -2
- package/dist/utils/command-operation.js.map +1 -1
- package/dist/utils/components.d.ts +2 -0
- package/dist/utils/components.d.ts.map +1 -1
- package/dist/utils/components.js +1 -0
- package/dist/utils/components.js.map +1 -1
- package/dist/utils/extensions.js +1 -0
- package/dist/utils/extensions.js.map +1 -1
- package/dist/utils/http-definitions.js +1 -0
- package/dist/utils/http-definitions.js.map +1 -1
- package/dist/utils/http-operation.js +1 -0
- package/dist/utils/http-operation.js.map +1 -1
- package/dist/utils/info.js +1 -0
- package/dist/utils/info.js.map +1 -1
- package/dist/utils/model-state.js +1 -0
- package/dist/utils/model-state.js.map +1 -1
- package/dist/utils/powershell-comment.js +11 -10
- package/dist/utils/powershell-comment.js.map +1 -1
- package/dist/utils/programatic-operation.js +2 -2
- package/dist/utils/programatic-operation.js.map +1 -1
- package/dist/utils/resolve-conflicts.js +1 -0
- package/dist/utils/resolve-conflicts.js.map +1 -1
- package/dist/utils/schema.d.ts +13 -0
- package/dist/utils/schema.d.ts.map +1 -1
- package/dist/utils/schema.js +39 -0
- package/dist/utils/schema.js.map +1 -1
- package/dist/utils/security-scheme.js +1 -0
- package/dist/utils/security-scheme.js.map +1 -1
- package/dist/utils/uid.js +1 -0
- package/dist/utils/uid.js.map +1 -1
- package/package.json +8 -7
- package/readme.md +5 -1
- package/resources/assets/build-module.ps1 +9 -5
- package/resources/assets/create-model-cmdlets.ps1 +14 -2
- package/resources/assets/generate-portal-ux.ps1 +379 -0
- package/resources/assets/tools/Resources/custom/New-AzDeployment.ps1 +2 -2
- package/resources/psruntime/Attributes/ExternalDocsAttribute.cs +30 -0
- package/resources/psruntime/BuildTime/Cmdlets/ExportPsd1.cs +1 -1
- package/resources/psruntime/BuildTime/Models/PsMarkdownTypes.cs +39 -4
- package/resources/psruntime/BuildTime/Models/PsProxyOutputs.cs +10 -4
- package/resources/psruntime/BuildTime/Models/PsProxyTypes.cs +6 -0
- package/resources/psruntime/BuildTime/PsAttributes.cs +7 -0
- package/resources/psruntime/BuildTime/PsHelpers.cs +1 -2
- package/resources/psruntime/MessageAttributeHelper.cs +1 -5
- package/resources/runtime/csharp/client/Context.cs +33 -0
- package/resources/runtime/csharp/client/InfoAttribute.cs +4 -0
- package/resources/runtime/csharp/client/InputHandler.cs +22 -0
- package/resources/runtime/csharp/client/SerializationMode.cs +5 -3
- package/resources/runtime/csharp/pipeline/Events.cs +2 -2
- package/resources/runtime/csharp/pipeline/PipelineMocking.cs +1 -1
- package/resources/runtime/csharp/xml/IXmlSerializable.cs +2 -2
- package/resources/templates/azureMethod.ejs +5 -0
- package/resources/templates/azureMethodGroup.ejs +46 -0
- package/resources/templates/azureServiceClient.ejs +80 -0
- package/resources/templates/enum.ejs +73 -0
- package/resources/templates/exception.ejs +52 -0
- package/resources/templates/extensionMethod.ejs +68 -0
- package/resources/templates/extensions.ejs +19 -0
- package/resources/templates/longRunningOperationMethod.ejs +43 -0
- package/resources/templates/method.ejs +65 -0
- package/resources/templates/methodBodyRestCall.ejs +317 -0
- package/resources/templates/methodGroupInterface.ejs +77 -0
- package/resources/templates/model.ejs +184 -0
- package/resources/templates/page.ejs +40 -0
- package/resources/templates/serviceClientBody.ejs +303 -0
- package/resources/templates/serviceClientInterface.ejs +55 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<% var key = methodGroup.$key == 'Operations' ? '' : methodGroup.$key-%>
|
|
2
|
+
<%# ToDo: currently assume the SyncMethodsGenerationMode is Essential type, and need to add support for other types -%>
|
|
3
|
+
/// <summary>
|
|
4
|
+
/// <%=method.language.default.description%>
|
|
5
|
+
<%# ToDo: add support for externaldocsurl -%>
|
|
6
|
+
/// </summary>
|
|
7
|
+
<%# ToDo: add <remarks> if there are both description and summary -%>
|
|
8
|
+
/// <param name='operations'>
|
|
9
|
+
/// The operations group for this extension method.
|
|
10
|
+
/// </param>
|
|
11
|
+
<% if(method.parameters && !method.language.default.pageable?.nextPageOperation) { method.parameters.filter(p => p.implementation != 'Client' && !project.helper.IsConstantParameter(p)).forEach(function (parameter) {-%>
|
|
12
|
+
/// <param name='<%-parameter.language.default.name%>'>
|
|
13
|
+
/// <%=parameter.language.default.description%>
|
|
14
|
+
/// </param>
|
|
15
|
+
<% });}-%>
|
|
16
|
+
<% if(method.language.default.pageable?.nextPageOperation) {-%>
|
|
17
|
+
/// <param name='nextPageLink'>
|
|
18
|
+
/// The NextLink from the previous successful call to List operation.
|
|
19
|
+
/// </param>
|
|
20
|
+
<% } -%>
|
|
21
|
+
<%# ToDo: add support for GetObsoleteAttribute-%>
|
|
22
|
+
<%# ToDo: add support for AccessModifier, assume public for the time being-%>
|
|
23
|
+
public static <%-method.language.default.returnType%> <%-method.language.default.name%>(this I<%-project.helper.PascalCase(key)%>Operations operations<%- method.language.default.syncMethodParameterDeclaration ? ', ' + method.language.default.syncMethodParameterDeclaration: '' %>)
|
|
24
|
+
{
|
|
25
|
+
<%# ToDo: need to handle different return type, body, header and the others including no return type-%>
|
|
26
|
+
<% if(method.language.default.returnType != 'void') {-%>
|
|
27
|
+
return ((I<%-project.helper.PascalCase(key)%>Operations)operations).<%-method.language.default.name%>Async(<%-method.language.default.syncMethodInvocationArgs%>).GetAwaiter().GetResult();
|
|
28
|
+
<% } else { -%>
|
|
29
|
+
((I<%-project.helper.PascalCase(key)%>Operations)operations).<%-method.language.default.name%>Async(<%-method.language.default.syncMethodInvocationArgs%>).GetAwaiter().GetResult();
|
|
30
|
+
<% } -%>
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/// <summary>
|
|
34
|
+
/// <%=method.language.default.description%>
|
|
35
|
+
<%# ToDo: add support for externaldocsurl -%>
|
|
36
|
+
/// </summary>
|
|
37
|
+
<%# ToDo: add <remarks> if there are both description and summary -%>
|
|
38
|
+
/// <param name='operations'>
|
|
39
|
+
/// The operations group for this extension method.
|
|
40
|
+
/// </param>
|
|
41
|
+
<% if(method.parameters && !method.language.default.pageable?.nextPageOperation) { method.parameters.filter(p => p.implementation != 'Client' && !project.helper.IsConstantParameter(p)).forEach(function (parameter) {-%>
|
|
42
|
+
/// <param name='<%-parameter.language.default.name%>'>
|
|
43
|
+
/// <%=parameter.language.default.description%>
|
|
44
|
+
/// </param>
|
|
45
|
+
<% });}-%>
|
|
46
|
+
<% if(method.language.default.pageable?.nextPageOperation) {-%>
|
|
47
|
+
/// <param name='nextPageLink'>
|
|
48
|
+
/// The NextLink from the previous successful call to List operation.
|
|
49
|
+
/// </param>
|
|
50
|
+
<% } -%>
|
|
51
|
+
/// <param name='cancellationToken'>
|
|
52
|
+
/// The cancellation token.
|
|
53
|
+
/// </param>
|
|
54
|
+
<%# ToDo: add support for GetObsoleteAttribute-%>
|
|
55
|
+
<%# ToDo: add support for AccessModifier, assume public for the time being-%>
|
|
56
|
+
public static async System.Threading.Tasks.Task<%- method.language.default.returnType != 'void' ? '<' + method.language.default.returnType + '>' : ''%> <%-method.language.default.name%>Async(this I<%-project.helper.PascalCase(key)%>Operations operations<%- method.language.default.asyncMethodParameterDeclaration ? ', ' + method.language.default.asyncMethodParameterDeclaration: '' %>)
|
|
57
|
+
{
|
|
58
|
+
<%# ToDo: need to handle different return type, body, header and the others including no return type-%>
|
|
59
|
+
<% if(method.language.default.returnType != 'void') {-%>
|
|
60
|
+
<%# ToDo: add support for primitive return-%>
|
|
61
|
+
using (var _result = await operations.<%-method.language.default.name%>WithHttpMessagesAsync(<%-method.language.default.asyncMethodInvocationArgs%>).ConfigureAwait(false))
|
|
62
|
+
{
|
|
63
|
+
return <%- method.language.default.responseType.startsWith('Microsoft.Rest.Azure.AzureOperationResponse') ? '_result.Body' : '_result.Headers'%>;
|
|
64
|
+
}
|
|
65
|
+
<% } else { -%>
|
|
66
|
+
(await operations.<%-method.language.default.name%>WithHttpMessagesAsync(<%-method.language.default.asyncMethodInvocationArgs%>).ConfigureAwait(false)).Dispose();
|
|
67
|
+
<% }-%>
|
|
68
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<%- project.commentHeader %>
|
|
2
|
+
<% var key = methodGroup.$key == 'Operations' ? '' : methodGroup.$key-%>
|
|
3
|
+
namespace <%- project.namespace %>
|
|
4
|
+
{
|
|
5
|
+
<% project.model.usings.forEach(function(using){ -%>
|
|
6
|
+
using <%- using %>;
|
|
7
|
+
<% }); -%>
|
|
8
|
+
|
|
9
|
+
/// <summary>
|
|
10
|
+
/// Extension methods for <%- project.helper.PascalCase(key) %>Operations
|
|
11
|
+
/// </summary>
|
|
12
|
+
public static partial class <%- project.helper.PascalCase(key) %>OperationsExtensions
|
|
13
|
+
{
|
|
14
|
+
<% methodGroup.operations.forEach(function(method){ -%>
|
|
15
|
+
<%# ToDo: add support for ExcludeFromInterface-%>
|
|
16
|
+
<%- include('extensionMethod', {method: method, group: methodGroup, project: project}) %>
|
|
17
|
+
<% }); -%>
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<% if (method.language.default.description) {-%>
|
|
2
|
+
/// <summary>
|
|
3
|
+
/// <%= method.language.default.description%>
|
|
4
|
+
<%# ToDo: add externaldocsurl -%>
|
|
5
|
+
/// </summary>
|
|
6
|
+
<% };-%>
|
|
7
|
+
<%# ToDo: add remark if both description and summary is provided, question here is in m4, there is no summary provided-%>
|
|
8
|
+
<% if(method.parameters&&!method.language.default.pageable?.nextPageOperation) { method.parameters.filter(p => p.implementation != 'Client' && !project.helper.IsConstantParameter(p)).forEach(function (parameter) {-%>
|
|
9
|
+
<%# ToDo: should use camel name instead of pascal name here -%>
|
|
10
|
+
/// <param name='<%-parameter.language.default.name%>'>
|
|
11
|
+
/// <%=parameter.language.default.description%>
|
|
12
|
+
/// </param>
|
|
13
|
+
<% });}-%>
|
|
14
|
+
<% (method.requests[0].parameters || []).filter(p=>p.protocol.http.in == 'body' && !project.helper.IsConstantParameter(p)).forEach(function(parameter){-%>
|
|
15
|
+
<%if(parameter.extensions && parameter.extensions['x-ms-client-flatten'] ) {-%>
|
|
16
|
+
<%project.helper.GetAllPublicVirtualProperties(parameter.schema.language.default.virtualProperties).filter(p => !project.helper.IsConstantProperty(p)).forEach(function(vp) {-%>
|
|
17
|
+
/// <param name='<%-vp.property.language.default.name%>'>
|
|
18
|
+
/// <%= vp.property.language.default.description%>
|
|
19
|
+
/// </param>
|
|
20
|
+
<%});-%>
|
|
21
|
+
<%} else {-%>
|
|
22
|
+
/// <param name='<%-parameter.language.default.name%>'>
|
|
23
|
+
/// <%= parameter.language.default.description%>
|
|
24
|
+
/// </param>
|
|
25
|
+
<%}-%>
|
|
26
|
+
<% });-%>
|
|
27
|
+
<% if(method.language.default.pageable?.nextPageOperation) {-%>
|
|
28
|
+
/// <param name='nextPageLink'>
|
|
29
|
+
/// The NextLink from the previous successful call to List operation.
|
|
30
|
+
/// </param>
|
|
31
|
+
<% } -%>
|
|
32
|
+
/// <param name='customHeaders'>
|
|
33
|
+
/// Headers that will be added to request.
|
|
34
|
+
/// </param>
|
|
35
|
+
/// <param name='cancellationToken'>
|
|
36
|
+
/// The cancellation token.
|
|
37
|
+
/// </param>
|
|
38
|
+
public async System.Threading.Tasks.Task<<%-method.language.default.responseType%>> <%-method.language.default.name%>WithHttpMessagesAsync(<%-method.language.default.asyncMethodParameterDeclarationWithCustomHeader%>)
|
|
39
|
+
{
|
|
40
|
+
// Send Request
|
|
41
|
+
<%-method.language.default.responseType%> _response = await Begin<%-method.language.default.name%>WithHttpMessagesAsync(<%-method.language.default.asyncMethodInvocationArgsWithCustomerHeaders%>).ConfigureAwait(false);
|
|
42
|
+
return await this.Client.<%-(method.requests[0].protocol.http.method == 'put' || method.requests[0].protocol.http.method == 'patch')?'GetPutOrPatch':(method.requests[0].protocol.http.method == 'post' || method.requests[0].protocol.http.method == 'delete')?'GetPostOrDelete':''%>OperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false);
|
|
43
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<% if (method.language.default.description) {-%>
|
|
2
|
+
/// <summary>
|
|
3
|
+
/// <%= method.language.default.description%>
|
|
4
|
+
<%# ToDo: add externaldocsurl -%>
|
|
5
|
+
/// </summary>
|
|
6
|
+
<% };-%>
|
|
7
|
+
<%# ToDo: add remark if both description and summary is provided, question here is in m4, there is no summary provided-%>
|
|
8
|
+
<% if(method.parameters&&!method.language.default.pageable?.nextPageOperation) { method.parameters.filter(p => p.implementation != 'Client' && !project.helper.IsConstantParameter(p)).forEach(function (parameter) {-%>
|
|
9
|
+
<%# ToDo: should use camel name instead of pascal name here -%>
|
|
10
|
+
/// <param name='<%-parameter.language.default.name%>'>
|
|
11
|
+
/// <%=parameter.language.default.description%>
|
|
12
|
+
/// </param>
|
|
13
|
+
<% });}-%>
|
|
14
|
+
<% (method.requests[0].parameters || []).filter(p=>p.protocol.http.in == 'body' && !project.helper.IsConstantParameter(p)).forEach(function(parameter){-%>
|
|
15
|
+
<%if(parameter.extensions && parameter.extensions['x-ms-client-flatten'] ) {-%>
|
|
16
|
+
<%project.helper.GetAllPublicVirtualProperties(parameter.schema.language.default.virtualProperties).filter(p => !project.helper.IsConstantProperty(p)).forEach(function(vp) {-%>
|
|
17
|
+
/// <param name='<%-vp.property.language.default.name%>'>
|
|
18
|
+
/// <%= vp.property.language.default.description%>
|
|
19
|
+
/// </param>
|
|
20
|
+
<%});-%>
|
|
21
|
+
<%} else {-%>
|
|
22
|
+
/// <param name='<%-parameter.language.default.name%>'>
|
|
23
|
+
/// <%= parameter.language.default.description%>
|
|
24
|
+
/// </param>
|
|
25
|
+
<%}-%>
|
|
26
|
+
<% });-%>
|
|
27
|
+
<% if(method.language.default.pageable?.nextPageOperation) {-%>
|
|
28
|
+
/// <param name='nextPageLink'>
|
|
29
|
+
/// The NextLink from the previous successful call to List operation.
|
|
30
|
+
/// </param>
|
|
31
|
+
<% } -%>
|
|
32
|
+
/// <param name='customHeaders'>
|
|
33
|
+
/// Headers that will be added to request.
|
|
34
|
+
/// </param>
|
|
35
|
+
/// <param name='cancellationToken'>
|
|
36
|
+
/// The cancellation token.
|
|
37
|
+
/// </param>
|
|
38
|
+
/// <exception cref="Microsoft.Rest.Azure.CloudException">
|
|
39
|
+
/// Thrown when the operation returned an invalid status code
|
|
40
|
+
/// </exception>
|
|
41
|
+
<% if ((method.responses || []).filter(p => p.schema).length > 0) {-%>
|
|
42
|
+
/// <exception cref="Microsoft.Rest.SerializationException">
|
|
43
|
+
/// Thrown when unable to deserialize the response
|
|
44
|
+
/// </exception>
|
|
45
|
+
<% };-%>
|
|
46
|
+
<%# ToDo: add isnullable check -%>
|
|
47
|
+
<% if (method.parameters.filter(p => p.schema.type != 'constant' && p.required)) {-%>
|
|
48
|
+
/// <exception cref="Microsoft.Rest.ValidationException">
|
|
49
|
+
/// Thrown when a required parameter is null
|
|
50
|
+
/// </exception>
|
|
51
|
+
/// <exception cref="System.ArgumentNullException">
|
|
52
|
+
/// Thrown when a required parameter is null
|
|
53
|
+
/// </exception>
|
|
54
|
+
<% };-%>
|
|
55
|
+
/// <return>
|
|
56
|
+
/// A response object containing the response body and response headers.
|
|
57
|
+
/// </return>
|
|
58
|
+
<%# ToDo: add GetObsoleteAttribute -%>
|
|
59
|
+
<%# ToDo: need to check in which case the method is not public(AccessModifier), currently set it to public -%>
|
|
60
|
+
public async System.Threading.Tasks.Task<<%-method.language.default.responseType%>> <%-method.language.default.name%>WithHttpMessagesAsync(<%-method.language.default.asyncMethodParameterDeclarationWithCustomHeader%>)
|
|
61
|
+
{
|
|
62
|
+
<%# ToDo: add support for method.Flavor, currently assume it is RestCall -%>
|
|
63
|
+
|
|
64
|
+
<%- include('methodBodyRestCall', {method: method}) -%>
|
|
65
|
+
}
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
<%- project.helper.HandleConstParameters(method)%>
|
|
2
|
+
<%# handle x-ms-client-request-id -%>
|
|
3
|
+
<% var clientRequestId = 'x-ms-client-request-id';
|
|
4
|
+
var requestId = 'x-ms-request-id';
|
|
5
|
+
(method.parameters||[]).filter(p => p.protocol.http.in == 'header').forEach(function (parameter) {
|
|
6
|
+
if (parameter.extensions && parameter.extensions['x-ms-client-request-id']) {
|
|
7
|
+
clientRequestId = parameter.language.default.serializedName;
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
if (method.extensions && method.extensions['x-ms-request-id']) {
|
|
11
|
+
requestId = method.extensions['x-ms-request-id'];
|
|
12
|
+
}
|
|
13
|
+
-%>
|
|
14
|
+
<%# end of handling x-ms-client-request-id -%>
|
|
15
|
+
<% if(method.language.default.pageable?.nextPageOperation) {-%>
|
|
16
|
+
if (nextPageLink == null)
|
|
17
|
+
{
|
|
18
|
+
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "nextPageLink");
|
|
19
|
+
}
|
|
20
|
+
<% }else{-%>
|
|
21
|
+
<% (method.requests[0].parameters || []).filter(p=>p.protocol.http.in == 'body').forEach(function(parameter){-%>
|
|
22
|
+
<%if(!(parameter.extensions && parameter.extensions['x-ms-client-flatten'])) {-%>
|
|
23
|
+
<% if (!project.helper.IsValueType(parameter.schema.type) && parameter.required && !project.helper.IsConstantParameter(parameter)) { -%>
|
|
24
|
+
if (<%-parameter.language.default.name%> == null)
|
|
25
|
+
{
|
|
26
|
+
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "<%-parameter.language.default.name%>");
|
|
27
|
+
}
|
|
28
|
+
<% } -%>
|
|
29
|
+
<%if(method.requests[0].protocol.http.method != 'patch') {-%>
|
|
30
|
+
<%-project.helper.ValidateType(parameter.schema, method, parameter.language.default.name, parameter.nullable)%>
|
|
31
|
+
<%}-%>
|
|
32
|
+
<%}-%>
|
|
33
|
+
<% });-%>
|
|
34
|
+
<% if(method.parameters) { method.parameters.filter(p => (p.schema.type != 'constant' && p.language.default.name != '$host') || p.language.default.name == 'ApiVersion').forEach(function (parameter) {-%>
|
|
35
|
+
<%# ToDo: add check IsNullable with required -%>
|
|
36
|
+
<% var prefix = parameter.implementation == 'Client' ? 'this.Client.' : ''-%>
|
|
37
|
+
<% if ( !(parameter.extensions && parameter.extensions['x-ms-parameter-grouping']) && parameter.required && !project.helper.IsValueType(parameter.schema.type) && !project.helper.IsConstantParameter(parameter)) {-%>
|
|
38
|
+
if (<%-prefix%><%-parameter.language.default.name%> == null)
|
|
39
|
+
{
|
|
40
|
+
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "<%-prefix%><%-parameter.language.default.name%>");
|
|
41
|
+
}
|
|
42
|
+
<% } -%>
|
|
43
|
+
<%-project.helper.ValidateType(parameter.schema, method, prefix + parameter.language.default.name, parameter.nullable)%>
|
|
44
|
+
<%});}-%>
|
|
45
|
+
<%(method.parameters || []).filter(p => p.protocol.http.in == 'complex').forEach(function(parameter) {-%>
|
|
46
|
+
<%-project.helper.PopulateGroupParameters(parameter)%>
|
|
47
|
+
<%});-%>
|
|
48
|
+
<%# support for p => p.IsConstant && !p.IsClientProperty -%>
|
|
49
|
+
<%(method.parameters || []).filter(p => p.implementation !== 'Client' && p.schema.type === 'constant' && p.required).forEach(function(parameter) {-%>
|
|
50
|
+
<%-project.helper.GetCsharpType(parameter.schema.valueType)%> <%-parameter.language.default.name%> = <%-parameter.schema.valueType.type === 'string' ? '"' + parameter.schema.value.value + '"' : parameter.schema.value.value%>;
|
|
51
|
+
<%});-%>
|
|
52
|
+
<%# ToDo: add support for BuildInputMappings -%>
|
|
53
|
+
<% (method.requests[0].parameters || []).filter(p=>p.protocol.http.in == 'body').forEach(function(parameter){-%>
|
|
54
|
+
<%if(parameter.extensions && parameter.extensions['x-ms-client-flatten']) {-%>
|
|
55
|
+
<%-parameter.schema.language.default.name%> <%-parameter.language.default.name%> = new <%-parameter.schema.language.default.name%>();
|
|
56
|
+
<% var vps = project.helper.GetAllPublicVirtualProperties(parameter.schema.language.default.virtualProperties)-%>
|
|
57
|
+
if(<%-vps.map(vp=>`${vp.property.language.default.name} != null`).join('||')%>)
|
|
58
|
+
{
|
|
59
|
+
<%vps.forEach(function(vp) {-%>
|
|
60
|
+
<%-parameter.language.default.name%>.<%-vp.property.language.csharp.name%> = <%-vp.property.language.default.name%>;
|
|
61
|
+
<%});-%>
|
|
62
|
+
}
|
|
63
|
+
<%}-%>
|
|
64
|
+
<% });-%>
|
|
65
|
+
<%}-%>
|
|
66
|
+
// Tracing
|
|
67
|
+
bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
|
|
68
|
+
string _invocationId = null;
|
|
69
|
+
if (_shouldTrace)
|
|
70
|
+
{
|
|
71
|
+
_invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString();
|
|
72
|
+
System.Collections.Generic.Dictionary<string, object> tracingParameters = new System.Collections.Generic.Dictionary<string, object>();
|
|
73
|
+
<% if(method.language.default.pageable?.nextPageOperation) {-%>
|
|
74
|
+
tracingParameters.Add("nextPageLink", nextPageLink);
|
|
75
|
+
<% }else{-%>
|
|
76
|
+
<%# ToDo: add support for Model.LogicalParameters.Where(p => !p.IsClientProperty)-%>
|
|
77
|
+
<%method.parameters.filter(p => p.implementation != 'Client' && p.protocol.http.in != 'complex').forEach(function(p) {-%>
|
|
78
|
+
tracingParameters.Add("<%-p.language.default.name%>", <%-p.language.default.name%>);
|
|
79
|
+
<%});-%>
|
|
80
|
+
<%# ToDo: currently we just add the unexpanded body parameter, and need to be fixed in the future %>
|
|
81
|
+
<% (method.requests[0].parameters || []).filter(p =>p.protocol.http.in == 'body').forEach(function (parameter) {-%>
|
|
82
|
+
tracingParameters.Add("<%-parameter.language.default.name%>", <%-parameter.language.default.name%>);
|
|
83
|
+
<% });-%>
|
|
84
|
+
<% }%>
|
|
85
|
+
tracingParameters.Add("cancellationToken", cancellationToken);
|
|
86
|
+
Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "<%-method.language.default.name%>", tracingParameters);
|
|
87
|
+
}
|
|
88
|
+
// Construct URL
|
|
89
|
+
<% if(method.language.default.pageable?.nextPageOperation) {-%>
|
|
90
|
+
string _url = "{nextLink}";
|
|
91
|
+
_url = _url.Replace("{nextLink}", nextPageLink);
|
|
92
|
+
<% }else{%>
|
|
93
|
+
<%# ToDo: may need to support AbsoluteUrl -%>
|
|
94
|
+
var _baseUrl = this.Client.BaseUri.AbsoluteUri;
|
|
95
|
+
<%# ToDo: buildurl, currently only added simple cases, besides we need to handle skip url encoding -%>
|
|
96
|
+
var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "<%-method.requests[0].protocol.http.path.substring(1)%>").ToString();
|
|
97
|
+
<%if (method.parameters) { method.parameters.filter(p => p.protocol.http.in == 'path').forEach(function (pathParameter) {
|
|
98
|
+
var prefix = pathParameter.implementation == 'Client' ? 'this.Client.' : '';
|
|
99
|
+
-%>
|
|
100
|
+
_url = _url.Replace("{<%-pathParameter.language.default.serializedName%>}", <%-project.helper.PathParameterString(pathParameter)%>);
|
|
101
|
+
<% });}-%>
|
|
102
|
+
<% }%>
|
|
103
|
+
System.Collections.Generic.List<string> _queryParameters = new System.Collections.Generic.List<string>();
|
|
104
|
+
<%if (method.parameters && !method.language.default.pageable?.nextPageOperation) { method.parameters.filter(p => p.protocol.http.in == 'query').forEach(function (queryParameter) { -%>
|
|
105
|
+
<% var prefix = queryParameter.implementation == 'Client' ? 'this.Client.' : ''-%>
|
|
106
|
+
<% if (queryParameter.extensions && queryParameter.extensions['x-ms-odata']) {-%>
|
|
107
|
+
if (<%-queryParameter.language.default.name%> != null)
|
|
108
|
+
{
|
|
109
|
+
var _<%-project.helper.CamelCase(queryParameter.schema.language.default.name)%> = <%-queryParameter.language.default.name%>.ToString();
|
|
110
|
+
if (!string.IsNullOrEmpty(_<%-project.helper.CamelCase(queryParameter.schema.language.default.name)%>))
|
|
111
|
+
{
|
|
112
|
+
_queryParameters.Add(_<%-project.helper.CamelCase(queryParameter.schema.language.default.name)%>);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
<% } else {-%>
|
|
116
|
+
if (<%-prefix%><%-queryParameter.language.default.name%> != null)
|
|
117
|
+
{
|
|
118
|
+
_queryParameters.Add(string.Format("<%-queryParameter.language.default.serializedName%>={0}", <%-project.helper.PathParameterString(queryParameter)%>));
|
|
119
|
+
}
|
|
120
|
+
<% }-%>
|
|
121
|
+
<% });}-%>
|
|
122
|
+
if (_queryParameters.Count > 0)
|
|
123
|
+
{
|
|
124
|
+
_url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
|
|
125
|
+
}
|
|
126
|
+
// Create HTTP transport objects
|
|
127
|
+
var _httpRequest = new System.Net.Http.HttpRequestMessage();
|
|
128
|
+
System.Net.Http.HttpResponseMessage _httpResponse = null;
|
|
129
|
+
_httpRequest.Method = new System.Net.Http.HttpMethod("<%-method.requests[0].protocol.http.method.toUpperCase()%>");
|
|
130
|
+
_httpRequest.RequestUri = new System.Uri(_url);
|
|
131
|
+
// Set Headers
|
|
132
|
+
<%# ToDo: Add headers except for following default ones -%>
|
|
133
|
+
if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value)
|
|
134
|
+
{
|
|
135
|
+
_httpRequest.Headers.TryAddWithoutValidation("<%-clientRequestId%>", System.Guid.NewGuid().ToString());
|
|
136
|
+
}
|
|
137
|
+
if (this.Client.AcceptLanguage != null)
|
|
138
|
+
{
|
|
139
|
+
if (_httpRequest.Headers.Contains("accept-language"))
|
|
140
|
+
{
|
|
141
|
+
_httpRequest.Headers.Remove("accept-language");
|
|
142
|
+
}
|
|
143
|
+
_httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage);
|
|
144
|
+
}
|
|
145
|
+
<% (method.parameters || []).filter(p => p.protocol.http.in == 'header').forEach(function(parameter) {
|
|
146
|
+
var prefix = parameter.implementation == 'Client' ? 'this.Client.' : ''-%>
|
|
147
|
+
if (<%-prefix%><%-parameter.language.default.name%> != null)
|
|
148
|
+
{
|
|
149
|
+
if (_httpRequest.Headers.Contains("<%-parameter.language.default.serializedName%>"))
|
|
150
|
+
{
|
|
151
|
+
_httpRequest.Headers.Remove("<%-parameter.language.default.serializedName%>");
|
|
152
|
+
}
|
|
153
|
+
_httpRequest.Headers.TryAddWithoutValidation("<%-parameter.language.default.serializedName%>", <%-prefix%><%-parameter.language.default.name%>);
|
|
154
|
+
}
|
|
155
|
+
<% });-%>
|
|
156
|
+
|
|
157
|
+
if (customHeaders != null)
|
|
158
|
+
{
|
|
159
|
+
foreach(var _header in customHeaders)
|
|
160
|
+
{
|
|
161
|
+
if (_httpRequest.Headers.Contains(_header.Key))
|
|
162
|
+
{
|
|
163
|
+
_httpRequest.Headers.Remove(_header.Key);
|
|
164
|
+
}
|
|
165
|
+
_httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
// Serialize Request
|
|
169
|
+
string _requestContent = null;
|
|
170
|
+
<%# ToDo: add RequestBody, formdata support-%>
|
|
171
|
+
<% (method.requests[0].parameters || []).filter(p =>p.protocol.http.in == 'body').forEach(function (parameter) {-%>
|
|
172
|
+
<%# ToDo: currently only support for an unexpanded nullable body, need other support in the future -%>
|
|
173
|
+
<% if (!project.helper.IsValueType(parameter.schema.type) && !project.helper.IsConstantParameter(parameter)) {-%>
|
|
174
|
+
if(<%-parameter.language.default.name%> != null)
|
|
175
|
+
{
|
|
176
|
+
_requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(<%-parameter.language.default.name%>, <%-project.helper.GetSerializationSettings(parameter.schema, 'this.Client')%>);
|
|
177
|
+
_httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8);
|
|
178
|
+
_httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
|
|
179
|
+
}
|
|
180
|
+
<% } else { -%>
|
|
181
|
+
_requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(<%-parameter.language.default.name%>, <%-project.helper.GetSerializationSettings(parameter.schema, 'this.Client')%>);
|
|
182
|
+
_httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8);
|
|
183
|
+
_httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
|
|
184
|
+
<% } -%>
|
|
185
|
+
<% });-%>
|
|
186
|
+
<%# ToDo: Need to confirm in which case Settings.AddCredentials is false -%>
|
|
187
|
+
// Set Credentials
|
|
188
|
+
if (this.Client.Credentials != null)
|
|
189
|
+
{
|
|
190
|
+
cancellationToken.ThrowIfCancellationRequested();
|
|
191
|
+
await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
|
|
192
|
+
}
|
|
193
|
+
// Send Request
|
|
194
|
+
if (_shouldTrace)
|
|
195
|
+
{
|
|
196
|
+
Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
|
|
197
|
+
}
|
|
198
|
+
cancellationToken.ThrowIfCancellationRequested();
|
|
199
|
+
<%# ToDo: Add support for primary type return -%>
|
|
200
|
+
<% var responseHeadersRead = method.requests[0].protocol.http.method === 'head' ? 'System.Net.Http.HttpCompletionOption.ResponseHeadersRead, ': '' -%>
|
|
201
|
+
_httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, <%-responseHeadersRead%>cancellationToken).ConfigureAwait(false);
|
|
202
|
+
if (_shouldTrace)
|
|
203
|
+
{
|
|
204
|
+
Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode;
|
|
208
|
+
cancellationToken.ThrowIfCancellationRequested();
|
|
209
|
+
string _responseContent = null;
|
|
210
|
+
|
|
211
|
+
if (<%-method.language.default.failureStatusCodePredicate%>)
|
|
212
|
+
{
|
|
213
|
+
var ex = new <%-project.helper.IsCloudErrorException(method) ? 'Microsoft.Rest.Azure.CloudException' : `${method.exceptions[0].schema.language.default.name}Exception`%>(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
|
|
214
|
+
<%# 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 -%>
|
|
215
|
+
try
|
|
216
|
+
{
|
|
217
|
+
<%# ToDo: Need to add support for primary type -%>
|
|
218
|
+
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
|
|
219
|
+
<%var errorClass = !project.helper.IsCloudErrorException(method) ? method.exceptions[0].schema.language.default.name : 'CloudError'-%>
|
|
220
|
+
<%-errorClass%> _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject<<%-errorClass%>>(_responseContent, this.Client.DeserializationSettings);
|
|
221
|
+
if (_errorBody != null)
|
|
222
|
+
{
|
|
223
|
+
<% if(project.helper.IsCloudErrorException(method)) { -%>
|
|
224
|
+
ex = new Microsoft.Rest.Azure.CloudException(_errorBody.Message);
|
|
225
|
+
<% } -%>
|
|
226
|
+
ex.Body = _errorBody;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
catch (Newtonsoft.Json.JsonException)
|
|
230
|
+
{
|
|
231
|
+
// Ignore the exception
|
|
232
|
+
}
|
|
233
|
+
ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent);
|
|
234
|
+
ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent);
|
|
235
|
+
<% if (project.helper.IsCloudErrorException(method)) {-%>
|
|
236
|
+
if (_httpResponse.Headers.Contains("<%-(method.extensions && method.extensions[requestId]) ?? requestId%>"))
|
|
237
|
+
{
|
|
238
|
+
ex.RequestId = _httpResponse.Headers.GetValues("<%-(method.extensions && method.extensions[requestId]) ?? requestId%>").FirstOrDefault();
|
|
239
|
+
}
|
|
240
|
+
<% } -%>
|
|
241
|
+
if (_shouldTrace)
|
|
242
|
+
{
|
|
243
|
+
Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex);
|
|
244
|
+
}
|
|
245
|
+
_httpRequest.Dispose();
|
|
246
|
+
if (_httpResponse != null)
|
|
247
|
+
{
|
|
248
|
+
_httpResponse.Dispose();
|
|
249
|
+
}
|
|
250
|
+
throw ex;
|
|
251
|
+
}
|
|
252
|
+
// Create Result
|
|
253
|
+
var _result = new <%-method.language.default.responseType%>();
|
|
254
|
+
_result.Request = _httpRequest;
|
|
255
|
+
_result.Response = _httpResponse;
|
|
256
|
+
<%- method.language.default.initializeResponseBody %>
|
|
257
|
+
if (_httpResponse.Headers.Contains("<%-requestId%>"))
|
|
258
|
+
{
|
|
259
|
+
_result.RequestId = _httpResponse.Headers.GetValues("<%-requestId%>").FirstOrDefault();
|
|
260
|
+
}
|
|
261
|
+
<%(method.responses || []).filter(r => r.schema).forEach(function(resp) {-%>
|
|
262
|
+
// Deserialize Response
|
|
263
|
+
if ((int)_statusCode == <%-resp.protocol.http.statusCodes[0]%>)
|
|
264
|
+
{
|
|
265
|
+
<%# ToDo: Need to add support for primary type -%>
|
|
266
|
+
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
|
|
267
|
+
<%# ToDo: support for XmlSerialization, guess we do not need it actually -%>
|
|
268
|
+
try
|
|
269
|
+
{
|
|
270
|
+
<%# ToDo: we assume the return is object, need to add support for other types including support nullable -%>
|
|
271
|
+
<% var respSchema = resp.schema;
|
|
272
|
+
if(resp.schema.type === 'choice' || (resp.schema.type === 'sealed-choice' && (respSchema.schema.choiceType.type != 'string' || (resp.schema.extensions && resp.schema.extensions['x-ms-model-as-string'])))){
|
|
273
|
+
respSchema = resp.schema.choiceType;
|
|
274
|
+
}
|
|
275
|
+
var deserializeType = method.language.default.deserializeType ? method.language.default.deserializeType : respSchema.language.csharp.fullname;
|
|
276
|
+
const postfix = (project.helper.IsValueType(respSchema.type) || project.helper.IsEnum(resp.schema)) ? '?' : '';
|
|
277
|
+
-%>
|
|
278
|
+
_result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject<<%-deserializeType + postfix%>>(_responseContent, <%-project.helper.GetDeserializationSettings(respSchema, 'this.Client')%>);
|
|
279
|
+
}
|
|
280
|
+
catch (Newtonsoft.Json.JsonException ex)
|
|
281
|
+
{
|
|
282
|
+
_httpRequest.Dispose();
|
|
283
|
+
if (_httpResponse != null)
|
|
284
|
+
{
|
|
285
|
+
_httpResponse.Dispose();
|
|
286
|
+
}
|
|
287
|
+
throw new Microsoft.Rest.SerializationException("Unable to deserialize the response.", _responseContent, ex);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
<% });-%>
|
|
291
|
+
<%# ToDo: add support for case Model.ReturnType.Body != null && Model.DefaultResponse.Body != null && !Model.Responses.Any()-%>
|
|
292
|
+
<%# ToDo: add support for case there are return in headers-%>
|
|
293
|
+
<% if (method.language.default.returnTypeHeader.name !== '') { -%>
|
|
294
|
+
try
|
|
295
|
+
{
|
|
296
|
+
_result.Headers = _httpResponse.GetHeadersAsJson().ToObject<<%-method.language.default.returnTypeHeader.name%>>(Newtonsoft.Json.JsonSerializer.Create(this.Client.DeserializationSettings));
|
|
297
|
+
}
|
|
298
|
+
catch (Newtonsoft.Json.JsonException ex)
|
|
299
|
+
{
|
|
300
|
+
_httpRequest.Dispose();
|
|
301
|
+
if (_httpResponse != null)
|
|
302
|
+
{
|
|
303
|
+
_httpResponse.Dispose();
|
|
304
|
+
}
|
|
305
|
+
throw new Microsoft.Rest.SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex);
|
|
306
|
+
}
|
|
307
|
+
<% } -%>
|
|
308
|
+
if (_shouldTrace)
|
|
309
|
+
{
|
|
310
|
+
Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result);
|
|
311
|
+
}
|
|
312
|
+
return _result;
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<%- project.commentHeader %>
|
|
2
|
+
<% var key = methodGroup.$key == 'Operations' ? '' : methodGroup.$key-%>
|
|
3
|
+
|
|
4
|
+
namespace <%- project.namespace %>
|
|
5
|
+
{
|
|
6
|
+
<% project.model.usings.forEach(function(using){ -%>
|
|
7
|
+
using <%- using %>;
|
|
8
|
+
<% }); -%>
|
|
9
|
+
|
|
10
|
+
<% var typeName = project.helper.PascalCase(key) + 'Operations' -%>
|
|
11
|
+
/// <summary>
|
|
12
|
+
/// <%- typeName %> operations.
|
|
13
|
+
/// </summary>
|
|
14
|
+
public partial interface I<%- typeName%>
|
|
15
|
+
{
|
|
16
|
+
<% methodGroup.operations.forEach(function(method){ -%>
|
|
17
|
+
<%# ToDo: support for ExcludeFromInterface -%>
|
|
18
|
+
<% if(method.language.default.description) {-%>
|
|
19
|
+
/// <summary>
|
|
20
|
+
/// <%= method.language.default.description%>
|
|
21
|
+
<%# ToDo: support for ExternalDocsUrl -%>
|
|
22
|
+
/// </summary>
|
|
23
|
+
/// <remarks>
|
|
24
|
+
/// <%= method.language.default.description%>
|
|
25
|
+
/// </remarks>
|
|
26
|
+
<% };-%>
|
|
27
|
+
<% if(!method.language.default.pageable?.nextPageOperation) {-%>
|
|
28
|
+
<% method.parameters.filter(p=>p.implementation != 'Client' && !project.helper.IsConstantParameter(p)).forEach(function(parameter){-%>
|
|
29
|
+
/// <param name='<%-parameter.language.default.name%>'>
|
|
30
|
+
/// <%= parameter.language.default.description%>
|
|
31
|
+
/// </param>
|
|
32
|
+
<% }); -%>
|
|
33
|
+
<% (method.requests[0].parameters || []).filter(p=>p.protocol.http.in == 'body' && !project.helper.IsConstantParameter(p)).forEach(function(parameter){-%>
|
|
34
|
+
<%if(parameter.extensions && parameter.extensions['x-ms-client-flatten'] ) {-%>
|
|
35
|
+
<%project.helper.GetAllPublicVirtualProperties(parameter.schema.language.default.virtualProperties).filter(p => !project.helper.IsConstantProperty(p)).forEach(function(vp) {-%>
|
|
36
|
+
/// <param name='<%-vp.property.language.default.name%>'>
|
|
37
|
+
/// <%= vp.property.language.default.description%>
|
|
38
|
+
/// </param>
|
|
39
|
+
<%});-%>
|
|
40
|
+
<%} else {-%>
|
|
41
|
+
/// <param name='<%-parameter.language.default.name%>'>
|
|
42
|
+
/// <%= parameter.language.default.description%>
|
|
43
|
+
/// </param>
|
|
44
|
+
<%}-%>
|
|
45
|
+
<% });-%>
|
|
46
|
+
<% };-%>
|
|
47
|
+
<% if(method.language.default.pageable?.nextPageOperation) {-%>
|
|
48
|
+
/// <param name='nextPageLink'>
|
|
49
|
+
/// The NextLink from the previous successful call to List operation.
|
|
50
|
+
/// </param>
|
|
51
|
+
<% } -%>
|
|
52
|
+
/// <param name='customHeaders'>
|
|
53
|
+
/// The headers that will be added to request.
|
|
54
|
+
/// </param>
|
|
55
|
+
/// <param name='cancellationToken'>
|
|
56
|
+
/// The cancellation token.
|
|
57
|
+
/// </param>
|
|
58
|
+
<%# ToDo: Need to figure out whether we could hand code the exception here -%>
|
|
59
|
+
/// <exception cref="Microsoft.Rest.Azure.CloudException">
|
|
60
|
+
/// Thrown when the operation returned an invalid status code
|
|
61
|
+
/// </exception>
|
|
62
|
+
<% if ((method.responses || []).filter(r => r.schema).length > 0) {-%>
|
|
63
|
+
/// <exception cref="Microsoft.Rest.SerializationException">
|
|
64
|
+
/// Thrown when unable to deserialize the response
|
|
65
|
+
/// </exception>
|
|
66
|
+
<% }; -%>
|
|
67
|
+
<% if (method.parameters.filter(p => p.required && p.nullable).length > 0 || (method.requests[0].parameters || []).filter(p => p.required && p.nullable).length > 0) {-%>
|
|
68
|
+
/// <exception cref="Microsoft.Rest.ValidationException">
|
|
69
|
+
/// Thrown when a required parameter is null
|
|
70
|
+
/// </exception>
|
|
71
|
+
<% }; -%>
|
|
72
|
+
<%# ToDo: support GetObsoleteAttribute, deprecated message?-%>
|
|
73
|
+
System.Threading.Tasks.Task<<%-method.language.default.responseType %>> <%- method.language.default.name%>WithHttpMessagesAsync(<%-method.language.default.asyncMethodParameterDeclarationWithCustomHeader%>);
|
|
74
|
+
|
|
75
|
+
<% }); -%>
|
|
76
|
+
}
|
|
77
|
+
}
|