@autorest/powershell 4.0.0-dev.8 → 4.0.617
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/operation/build/state.json +3 -0
- package/.rush/temp/package-deps_build.json +106 -103
- package/.rush/temp/shrinkwrap-deps.json +182 -234
- package/dist/cmdlets/class.d.ts +12 -1
- package/dist/cmdlets/class.d.ts.map +1 -1
- package/dist/cmdlets/class.js +693 -532
- package/dist/cmdlets/class.js.map +1 -1
- package/dist/cmdlets/namespace.d.ts.map +1 -1
- package/dist/cmdlets/namespace.js +38 -5
- package/dist/cmdlets/namespace.js.map +1 -1
- package/dist/enums/namespace.js +5 -5
- package/dist/enums/namespace.js.map +1 -1
- package/dist/generators/psm1.custom.js +2 -2
- package/dist/generators/psm1.custom.js.map +1 -1
- package/dist/generators/psm1.internal.js +2 -2
- package/dist/generators/psm1.internal.js.map +1 -1
- package/dist/generators/psm1.js +1 -1
- package/dist/generators/psm1.js.map +1 -1
- package/dist/generators/script-cmdlet.js +18 -18
- package/dist/generators/script-cmdlet.js.map +1 -1
- package/dist/internal/name-inferrer.d.ts +1 -1
- package/dist/internal/name-inferrer.d.ts.map +1 -1
- package/dist/internal/name-inferrer.js +12 -12
- package/dist/internal/name-inferrer.js.map +1 -1
- package/dist/internal/powershell-declarations.d.ts +2 -0
- package/dist/internal/powershell-declarations.d.ts.map +1 -1
- package/dist/internal/powershell-declarations.js +4 -2
- package/dist/internal/powershell-declarations.js.map +1 -1
- package/dist/internal/project.d.ts +3 -5
- package/dist/internal/project.d.ts.map +1 -1
- package/dist/internal/project.js +14 -18
- package/dist/internal/project.js.map +1 -1
- package/dist/internal/state.d.ts +1 -1
- package/dist/internal/state.d.ts.map +1 -1
- package/dist/llcsharp/clientruntime.d.ts +1 -0
- package/dist/llcsharp/clientruntime.d.ts.map +1 -1
- package/dist/llcsharp/clientruntime.js +12 -11
- package/dist/llcsharp/clientruntime.js.map +1 -1
- package/dist/llcsharp/code-model.d.ts +7 -7
- package/dist/llcsharp/code-model.d.ts.map +1 -1
- package/dist/llcsharp/enums/enum.d.ts +1 -1
- package/dist/llcsharp/enums/enum.d.ts.map +1 -1
- package/dist/llcsharp/enums/enum.js +42 -42
- package/dist/llcsharp/enums/enum.js.map +1 -1
- package/dist/llcsharp/exports.js +5 -1
- package/dist/llcsharp/exports.js.map +1 -1
- package/dist/llcsharp/generator.d.ts +1 -1
- package/dist/llcsharp/generator.d.ts.map +1 -1
- package/dist/llcsharp/model/idictionary.js +16 -16
- package/dist/llcsharp/model/idictionary.js.map +1 -1
- package/dist/llcsharp/model/interface.d.ts +1 -1
- package/dist/llcsharp/model/interface.d.ts.map +1 -1
- package/dist/llcsharp/model/interface.js +25 -11
- package/dist/llcsharp/model/interface.js.map +1 -1
- package/dist/llcsharp/model/model-class-dictionary.js +18 -18
- package/dist/llcsharp/model/model-class-dictionary.js.map +1 -1
- package/dist/llcsharp/model/model-class-json.js +19 -19
- package/dist/llcsharp/model/model-class-json.js.map +1 -1
- package/dist/llcsharp/model/model-class-serializer.d.ts +1 -1
- package/dist/llcsharp/model/model-class-serializer.d.ts.map +1 -1
- package/dist/llcsharp/model/model-class-serializer.js +6 -6
- package/dist/llcsharp/model/model-class-serializer.js.map +1 -1
- package/dist/llcsharp/model/model-class.d.ts +1 -1
- package/dist/llcsharp/model/model-class.d.ts.map +1 -1
- package/dist/llcsharp/model/model-class.js +97 -89
- package/dist/llcsharp/model/model-class.js.map +1 -1
- package/dist/llcsharp/model/namespace.d.ts +1 -1
- package/dist/llcsharp/model/namespace.d.ts.map +1 -1
- package/dist/llcsharp/model/namespace.js +4 -12
- package/dist/llcsharp/model/namespace.js.map +1 -1
- package/dist/llcsharp/model/property.d.ts +1 -1
- package/dist/llcsharp/model/property.d.ts.map +1 -1
- package/dist/llcsharp/model/property.js +20 -20
- package/dist/llcsharp/model/property.js.map +1 -1
- package/dist/llcsharp/operation/api-class.d.ts.map +1 -1
- package/dist/llcsharp/operation/api-class.js +26 -1
- package/dist/llcsharp/operation/api-class.js.map +1 -1
- package/dist/llcsharp/operation/method.d.ts +10 -5
- package/dist/llcsharp/operation/method.d.ts.map +1 -1
- package/dist/llcsharp/operation/method.js +276 -134
- package/dist/llcsharp/operation/method.js.map +1 -1
- package/dist/llcsharp/operation/parameter.d.ts +1 -1
- package/dist/llcsharp/operation/parameter.d.ts.map +1 -1
- package/dist/llcsharp/operation/parameter.js +10 -10
- package/dist/llcsharp/operation/parameter.js.map +1 -1
- package/dist/llcsharp/project.d.ts +4 -2
- package/dist/llcsharp/project.d.ts.map +1 -1
- package/dist/llcsharp/project.js +11 -3
- package/dist/llcsharp/project.js.map +1 -1
- package/dist/llcsharp/schema/Uuid.d.ts +1 -1
- package/dist/llcsharp/schema/Uuid.d.ts.map +1 -1
- package/dist/llcsharp/schema/Uuid.js +2 -2
- package/dist/llcsharp/schema/Uuid.js.map +1 -1
- package/dist/llcsharp/schema/array.d.ts +1 -1
- package/dist/llcsharp/schema/array.d.ts.map +1 -1
- package/dist/llcsharp/schema/array.js +45 -43
- package/dist/llcsharp/schema/array.js.map +1 -1
- package/dist/llcsharp/schema/binary.d.ts +1 -1
- package/dist/llcsharp/schema/binary.d.ts.map +1 -1
- package/dist/llcsharp/schema/binary.js +9 -9
- package/dist/llcsharp/schema/binary.js.map +1 -1
- package/dist/llcsharp/schema/boolean.d.ts +1 -1
- package/dist/llcsharp/schema/boolean.d.ts.map +1 -1
- package/dist/llcsharp/schema/byte-array.d.ts +1 -1
- package/dist/llcsharp/schema/byte-array.d.ts.map +1 -1
- package/dist/llcsharp/schema/byte-array.js +24 -24
- package/dist/llcsharp/schema/byte-array.js.map +1 -1
- package/dist/llcsharp/schema/char.d.ts +1 -1
- package/dist/llcsharp/schema/char.d.ts.map +1 -1
- package/dist/llcsharp/schema/char.js +1 -1
- package/dist/llcsharp/schema/char.js.map +1 -1
- package/dist/llcsharp/schema/date-time.d.ts +1 -1
- package/dist/llcsharp/schema/date-time.d.ts.map +1 -1
- package/dist/llcsharp/schema/date-time.js +45 -41
- package/dist/llcsharp/schema/date-time.js.map +1 -1
- package/dist/llcsharp/schema/date.d.ts +1 -1
- package/dist/llcsharp/schema/date.d.ts.map +1 -1
- package/dist/llcsharp/schema/duration.d.ts +1 -1
- package/dist/llcsharp/schema/duration.d.ts.map +1 -1
- package/dist/llcsharp/schema/duration.js +9 -7
- package/dist/llcsharp/schema/duration.js.map +1 -1
- package/dist/llcsharp/schema/enum.d.ts +6 -2
- package/dist/llcsharp/schema/enum.d.ts.map +1 -1
- package/dist/llcsharp/schema/enum.js +13 -4
- package/dist/llcsharp/schema/enum.js.map +1 -1
- package/dist/llcsharp/schema/extended-type-declaration.d.ts +1 -1
- package/dist/llcsharp/schema/extended-type-declaration.d.ts.map +1 -1
- package/dist/llcsharp/schema/fixed-array.d.ts +1 -1
- package/dist/llcsharp/schema/fixed-array.d.ts.map +1 -1
- package/dist/llcsharp/schema/fixed-array.js +44 -42
- package/dist/llcsharp/schema/fixed-array.js.map +1 -1
- package/dist/llcsharp/schema/integer.d.ts +1 -1
- package/dist/llcsharp/schema/integer.d.ts.map +1 -1
- package/dist/llcsharp/schema/integer.js +5 -5
- package/dist/llcsharp/schema/integer.js.map +1 -1
- package/dist/llcsharp/schema/object.d.ts +1 -1
- package/dist/llcsharp/schema/object.d.ts.map +1 -1
- package/dist/llcsharp/schema/object.js +28 -28
- package/dist/llcsharp/schema/object.js.map +1 -1
- package/dist/llcsharp/schema/password.d.ts +1 -1
- package/dist/llcsharp/schema/password.d.ts.map +1 -1
- package/dist/llcsharp/schema/password.js +13 -13
- package/dist/llcsharp/schema/password.js.map +1 -1
- package/dist/llcsharp/schema/primitive.d.ts +1 -1
- package/dist/llcsharp/schema/primitive.d.ts.map +1 -1
- package/dist/llcsharp/schema/primitive.js +40 -37
- package/dist/llcsharp/schema/primitive.js.map +1 -1
- package/dist/llcsharp/schema/schema-resolver.d.ts +1 -1
- package/dist/llcsharp/schema/schema-resolver.d.ts.map +1 -1
- package/dist/llcsharp/schema/schema-resolver.js +4 -9
- package/dist/llcsharp/schema/schema-resolver.js.map +1 -1
- package/dist/llcsharp/schema/string.d.ts +1 -1
- package/dist/llcsharp/schema/string.d.ts.map +1 -1
- package/dist/llcsharp/schema/string.js +48 -44
- package/dist/llcsharp/schema/string.js.map +1 -1
- package/dist/llcsharp/schema/uri.d.ts +1 -1
- package/dist/llcsharp/schema/uri.d.ts.map +1 -1
- package/dist/llcsharp/schema/uri.js +2 -2
- package/dist/llcsharp/schema/uri.js.map +1 -1
- package/dist/llcsharp/validations.js +2 -2
- package/dist/llcsharp/validations.js.map +1 -1
- package/dist/main.js +2 -2
- package/dist/main.js.map +1 -1
- package/dist/models/model-extensions.d.ts +1 -1
- package/dist/models/model-extensions.d.ts.map +1 -1
- package/dist/models/model-extensions.js +39 -39
- package/dist/models/model-extensions.js.map +1 -1
- package/dist/module/module-class.js +8 -8
- package/dist/module/module-class.js.map +1 -1
- package/dist/module/module-namespace.js +3 -3
- package/dist/module/module-namespace.js.map +1 -1
- package/dist/plugins/add-azure-completers-v2.d.ts +1 -1
- package/dist/plugins/add-azure-completers-v2.d.ts.map +1 -1
- package/dist/plugins/add-azure-completers-v2.js +3 -3
- package/dist/plugins/add-azure-completers-v2.js.map +1 -1
- package/dist/plugins/create-commands-v2.d.ts +9 -7
- package/dist/plugins/create-commands-v2.d.ts.map +1 -1
- package/dist/plugins/create-commands-v2.js +233 -62
- package/dist/plugins/create-commands-v2.js.map +1 -1
- package/dist/plugins/cs-namer-v2.d.ts +1 -1
- package/dist/plugins/cs-namer-v2.d.ts.map +1 -1
- package/dist/plugins/cs-namer-v2.js +40 -40
- package/dist/plugins/cs-namer-v2.js.map +1 -1
- package/dist/plugins/llcsharp-v2.d.ts +1 -1
- package/dist/plugins/llcsharp-v2.d.ts.map +1 -1
- package/dist/plugins/llcsharp-v2.js +12 -7
- package/dist/plugins/llcsharp-v2.js.map +1 -1
- package/dist/plugins/modifiers-v2.d.ts +1 -1
- package/dist/plugins/modifiers-v2.d.ts.map +1 -1
- package/dist/plugins/modifiers-v2.js +109 -78
- package/dist/plugins/modifiers-v2.js.map +1 -1
- package/dist/plugins/plugin-create-inline-properties.d.ts +1 -1
- package/dist/plugins/plugin-create-inline-properties.d.ts.map +1 -1
- package/dist/plugins/plugin-create-inline-properties.js +42 -31
- package/dist/plugins/plugin-create-inline-properties.js.map +1 -1
- package/dist/plugins/plugin-tweak-m4-model.d.ts +1 -1
- package/dist/plugins/plugin-tweak-m4-model.d.ts.map +1 -1
- package/dist/plugins/plugin-tweak-m4-model.js +19 -7
- package/dist/plugins/plugin-tweak-m4-model.js.map +1 -1
- package/dist/plugins/plugin-tweak-model-azure-v2.d.ts +1 -1
- package/dist/plugins/plugin-tweak-model-azure-v2.d.ts.map +1 -1
- package/dist/plugins/plugin-tweak-model-azure-v2.js +17 -17
- package/dist/plugins/plugin-tweak-model-azure-v2.js.map +1 -1
- package/dist/plugins/plugin-tweak-model.d.ts +1 -1
- package/dist/plugins/plugin-tweak-model.d.ts.map +1 -1
- package/dist/plugins/plugin-tweak-model.js +31 -31
- package/dist/plugins/plugin-tweak-model.js.map +1 -1
- package/dist/plugins/powershell-v2.d.ts +1 -1
- package/dist/plugins/powershell-v2.d.ts.map +1 -1
- package/dist/plugins/powershell-v2.js +26 -26
- package/dist/plugins/powershell-v2.js.map +1 -1
- package/dist/plugins/ps-namer-v2.d.ts +1 -1
- package/dist/plugins/ps-namer-v2.d.ts.map +1 -1
- package/dist/plugins/ps-namer-v2.js +31 -31
- package/dist/plugins/ps-namer-v2.js.map +1 -1
- package/dist/plugins/sdk-create-inline-properties.d.ts +1 -1
- package/dist/plugins/sdk-create-inline-properties.d.ts.map +1 -1
- package/dist/plugins/sdk-create-inline-properties.js +37 -37
- package/dist/plugins/sdk-create-inline-properties.js.map +1 -1
- package/dist/plugins/sdk-cs-namer.d.ts +1 -1
- package/dist/plugins/sdk-cs-namer.d.ts.map +1 -1
- package/dist/plugins/sdk-cs-namer.js +21 -21
- package/dist/plugins/sdk-cs-namer.js.map +1 -1
- package/dist/plugins/sdk-cs-simplifier.d.ts +1 -1
- package/dist/plugins/sdk-cs-simplifier.d.ts.map +1 -1
- package/dist/plugins/sdk-cs-simplifier.js +3 -3
- package/dist/plugins/sdk-cs-simplifier.js.map +1 -1
- package/dist/plugins/sdk-generate.d.ts +1 -1
- package/dist/plugins/sdk-generate.d.ts.map +1 -1
- package/dist/plugins/sdk-generate.js +14 -14
- package/dist/plugins/sdk-generate.js.map +1 -1
- package/dist/plugins/sdk-tweak-model.d.ts +1 -1
- package/dist/plugins/sdk-tweak-model.d.ts.map +1 -1
- package/dist/plugins/sdk-tweak-model.js +23 -23
- package/dist/plugins/sdk-tweak-model.js.map +1 -1
- package/dist/sdk/project.d.ts +2 -2
- package/dist/sdk/project.d.ts.map +1 -1
- package/dist/sdk/project.js +8 -8
- package/dist/sdk/project.js.map +1 -1
- package/dist/sdk/state.d.ts +2 -2
- package/dist/sdk/state.d.ts.map +1 -1
- package/dist/sdk/utility.d.ts +1 -1
- package/dist/sdk/utility.d.ts.map +1 -1
- package/dist/sdk/utility.js +17 -16
- package/dist/sdk/utility.js.map +1 -1
- package/dist/utils/PwshModel.d.ts +1 -1
- package/dist/utils/PwshModel.d.ts.map +1 -1
- package/dist/utils/PwshModel.js +1 -1
- package/dist/utils/PwshModel.js.map +1 -1
- package/dist/utils/SdkModel.d.ts +1 -1
- package/dist/utils/SdkModel.d.ts.map +1 -1
- package/dist/utils/SdkModel.js +1 -1
- package/dist/utils/SdkModel.js.map +1 -1
- package/dist/utils/command-operation.d.ts +9 -3
- package/dist/utils/command-operation.d.ts.map +1 -1
- package/dist/utils/command-operation.js +24 -4
- package/dist/utils/command-operation.js.map +1 -1
- package/dist/utils/components.d.ts +1 -1
- package/dist/utils/components.d.ts.map +1 -1
- package/dist/utils/components.js +2 -2
- package/dist/utils/components.js.map +1 -1
- package/dist/utils/http-operation.d.ts +2 -0
- package/dist/utils/http-operation.d.ts.map +1 -1
- package/dist/utils/http-operation.js +16 -12
- package/dist/utils/http-operation.js.map +1 -1
- package/dist/utils/model-state.d.ts +1 -1
- package/dist/utils/model-state.d.ts.map +1 -1
- package/dist/utils/model-state.js +20 -20
- package/dist/utils/model-state.js.map +1 -1
- package/dist/utils/programatic-operation.d.ts +1 -1
- package/dist/utils/programatic-operation.d.ts.map +1 -1
- package/dist/utils/programatic-operation.js +1 -1
- package/dist/utils/programatic-operation.js.map +1 -1
- package/dist/utils/resolve-conflicts.js +8 -8
- package/dist/utils/resolve-conflicts.js.map +1 -1
- package/dist/utils/resourceName.d.ts +3 -0
- package/dist/utils/resourceName.d.ts.map +1 -0
- package/dist/utils/resourceName.js +29 -0
- package/dist/utils/resourceName.js.map +1 -0
- package/dist/utils/schema.d.ts +1 -1
- package/dist/utils/schema.d.ts.map +1 -1
- package/dist/utils/schema.js +11 -11
- package/dist/utils/schema.js.map +1 -1
- package/dist/utils/security-scheme.d.ts +2 -2
- package/dist/utils/security-scheme.d.ts.map +1 -1
- package/dist/utils/security-scheme.js +2 -2
- package/dist/utils/security-scheme.js.map +1 -1
- package/dist/utils/sort-parameters.d.ts +3 -0
- package/dist/utils/sort-parameters.d.ts.map +1 -0
- package/dist/utils/sort-parameters.js +33 -0
- package/dist/utils/sort-parameters.js.map +1 -0
- package/package.json +7 -7
- package/resources/assets/build-module.ps1 +9 -4
- package/resources/assets/check-dependencies.ps1 +3 -3
- package/resources/assets/create-model-cmdlets.ps1 +33 -5
- package/resources/assets/export-surface.ps1 +3 -3
- package/resources/assets/generate-help.ps1 +5 -5
- package/resources/assets/generate-portal-ux.ps1 +3 -3
- package/resources/assets/run-module.ps1 +4 -4
- package/resources/assets/test-module.ps1 +5 -5
- package/resources/assets/tools/Resources/custom/New-AzDeployment.ps1 +2 -2
- package/resources/psruntime/Attributes/PSArgumentCompleterAttribute.cs +52 -0
- package/resources/psruntime/BuildTime/Cmdlets/ExportHelpMarkdown.cs +4 -1
- package/resources/psruntime/BuildTime/Cmdlets/ExportProxyCmdlet.cs +4 -1
- package/resources/psruntime/BuildTime/Cmdlets/ExportPsd1.cs +6 -4
- package/resources/psruntime/BuildTime/MarkdownRenderer.cs +16 -8
- package/resources/psruntime/BuildTime/Models/PsProxyOutputs.cs +20 -3
- package/resources/psruntime/BuildTime/Models/PsProxyTypes.cs +28 -2
- package/resources/psruntime/BuildTime/PsAttributes.cs +5 -0
- package/resources/psruntime/BuildTime/PsHelpers.cs +4 -3
- package/resources/psruntime/MessageAttribute.cs +23 -52
- package/resources/psruntime/MessageAttributeHelper.cs +5 -1
- package/resources/psruntime/Properties/Resources.Designer.cs +15 -2
- package/resources/psruntime/Properties/Resources.resx +4 -1
- package/resources/runtime/csharp/pipeline/ISendAsync.cs +113 -0
- package/resources/runtime/csharp/pipeline/PipelineMocking.cs +1 -1
package/dist/cmdlets/class.js
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.CmdletClass = exports.NewAddInfoAttribute = exports.addInfoAttribute = exports.addDefaultInfo = exports.addPreviewMessage = exports.addParameterBreakingChange = exports.NewAddCompleterInfo = exports.addCompleterInfo = exports.createStepper = void 0;
|
|
7
|
+
exports.CmdletClass = exports.NewAddInfoAttribute = exports.addInfoAttribute = exports.addDefaultInfo = exports.addPreviewMessage = exports.addParameterBreakingChange = exports.addPSArgumentCompleterAttribute = exports.isEnumImplementation = exports.NewAddCompleterInfo = exports.addCompleterInfo = exports.createStepper = void 0;
|
|
8
8
|
const ejs = require('ejs');
|
|
9
|
-
const codemodel_1 = require("@
|
|
9
|
+
const codemodel_1 = require("@autorest/codemodel");
|
|
10
10
|
const codemodel_v3_1 = require("@azure-tools/codemodel-v3");
|
|
11
11
|
const command_operation_1 = require("../utils/command-operation");
|
|
12
12
|
const schema_1 = require("../utils/schema");
|
|
@@ -15,9 +15,10 @@ const linq_1 = require("@azure-tools/linq");
|
|
|
15
15
|
const codegen_csharp_1 = require("@azure-tools/codegen-csharp");
|
|
16
16
|
const exports_1 = require("../llcsharp/exports");
|
|
17
17
|
const powershell_declarations_1 = require("../internal/powershell-declarations");
|
|
18
|
-
const
|
|
18
|
+
const extension_base_1 = require("@autorest/extension-base");
|
|
19
19
|
const codegen_csharp_2 = require("@azure-tools/codegen-csharp");
|
|
20
20
|
const model_class_1 = require("../llcsharp/model/model-class");
|
|
21
|
+
const resourceName_1 = require("../utils/resourceName");
|
|
21
22
|
const PropertiesRequiringNew = new Set(['Host', 'Events']);
|
|
22
23
|
const Verbs = {
|
|
23
24
|
Common: 'global::System.Management.Automation.VerbsCommon',
|
|
@@ -129,7 +130,7 @@ const category = {
|
|
|
129
130
|
'Use': Verbs.Other,
|
|
130
131
|
};
|
|
131
132
|
function createStepper(p) {
|
|
132
|
-
return codegen_csharp_1.toExpression(`${codegen_csharp_1.System.Linq.Enumerable.declaration}.Select<${exports_1.ClientRuntime.SendAsyncStep.declaration},${exports_1.ClientRuntime.SendAsyncStep.declaration}>(${p.value}, step =>
|
|
133
|
+
return (0, codegen_csharp_1.toExpression)(`${codegen_csharp_1.System.Linq.Enumerable.declaration}.Select<${exports_1.ClientRuntime.SendAsyncStep.declaration},${exports_1.ClientRuntime.SendAsyncStep.declaration}>(${p.value}, step =>
|
|
133
134
|
(r, c, n) => {
|
|
134
135
|
${powershell_declarations_1.DefaultRunspace.value} = ${powershell_declarations_1.DefaultRunspace.value} ?? ${powershell_declarations_1.RunspaceFactory.declaration}.CreateRunspace();
|
|
135
136
|
return step(r, c, n);
|
|
@@ -160,15 +161,27 @@ function NewAddCompleterInfo(targetProperty, parameter) {
|
|
|
160
161
|
}
|
|
161
162
|
}
|
|
162
163
|
exports.NewAddCompleterInfo = NewAddCompleterInfo;
|
|
164
|
+
function isEnumImplementation(schema) {
|
|
165
|
+
return ((schema === null || schema === void 0 ? void 0 : schema.type) === codemodel_1.SchemaType.SealedChoice && !schema.language.default.skip) ||
|
|
166
|
+
((schema === null || schema === void 0 ? void 0 : schema.extensions) && schema.extensions['x-ms-enum']);
|
|
167
|
+
}
|
|
168
|
+
exports.isEnumImplementation = isEnumImplementation;
|
|
169
|
+
function addPSArgumentCompleterAttribute(targetProperty, parameterSchema) {
|
|
170
|
+
const enumValues = (0, linq_1.values)(parameterSchema.language.csharp.enum.values).select(v => `"${v.value}"`).toArray().join(', ');
|
|
171
|
+
targetProperty.add(new codegen_csharp_1.Attribute(powershell_declarations_1.PSArgumentCompleterAttribute, { parameters: [`${enumValues}`] }));
|
|
172
|
+
}
|
|
173
|
+
exports.addPSArgumentCompleterAttribute = addPSArgumentCompleterAttribute;
|
|
163
174
|
function addParameterBreakingChange(targetProperty, parameter) {
|
|
164
175
|
if (parameter.breakingChange) {
|
|
165
176
|
const parameters = [];
|
|
166
177
|
parameters.push(`"${parameter.breakingChange.parameterName}"`);
|
|
167
|
-
if (parameter.breakingChange.deprecateByVersion) {
|
|
168
|
-
|
|
169
|
-
if (parameter.breakingChange.changeInEfectByDate)
|
|
170
|
-
parameters.push(`"${parameter.breakingChange.changeInEfectByDate}"`);
|
|
178
|
+
if (!parameter.breakingChange.deprecateByVersion || !parameter.breakingChange.deprecateByAzVersion) {
|
|
179
|
+
throw new Error(`breakingChange.deprecateByVersion and breakingChange.deprecateByAzVersion must be set for ${parameter.name}`);
|
|
171
180
|
}
|
|
181
|
+
parameters.push(`"${parameter.breakingChange.deprecateByVersion}"`);
|
|
182
|
+
parameters.push(`"${parameter.breakingChange.deprecateByAzVersion}"`);
|
|
183
|
+
if (parameter.breakingChange.changeInEfectByDate)
|
|
184
|
+
parameters.push(`"${parameter.breakingChange.changeInEfectByDate}"`);
|
|
172
185
|
if (parameter.breakingChange.replacement)
|
|
173
186
|
parameters.push(`ReplaceMentCmdletParameterName="${parameter.breakingChange.replacement}"`);
|
|
174
187
|
if (parameter.breakingChange.isBecomingMandatory)
|
|
@@ -320,6 +333,11 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
320
333
|
this.dropBodyParameter = operation.details.csharp.dropBodyParameter ? true : false;
|
|
321
334
|
this.apply(objectInitializer);
|
|
322
335
|
this.operation = operation;
|
|
336
|
+
this.apiCall = this.operation.callGraph[this.operation.callGraph.length - 1];
|
|
337
|
+
// create the response handlers
|
|
338
|
+
this.responses = [...(0, linq_1.values)(this.apiCall.responses), ...(0, linq_1.values)(this.apiCall.exceptions)];
|
|
339
|
+
this.callbackMethods = (0, linq_1.values)(this.responses).toArray().map(each => { var _a; return new codegen_csharp_1.LiteralExpression(((_a = each.language.csharp) === null || _a === void 0 ? void 0 : _a.name) || ''); });
|
|
340
|
+
this.operationParameters = [];
|
|
323
341
|
this.state = state;
|
|
324
342
|
this.thingsToSerialize = [];
|
|
325
343
|
this.variantName = variantName;
|
|
@@ -328,12 +346,13 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
328
346
|
this.interfaces.push(exports_1.ClientRuntime.IContext);
|
|
329
347
|
this.eventListener = new exports_1.EventListener(new codegen_csharp_1.LiteralExpression(`((${exports_1.ClientRuntime.IEventListener})this)`), true);
|
|
330
348
|
this.isViaIdentity = variantName.indexOf('ViaIdentity') > 0;
|
|
331
|
-
this.clientsidePagination = !!operation.details.csharp.clientsidePagination && !!((_a =
|
|
349
|
+
this.clientsidePagination = !!operation.details.csharp.clientsidePagination && !!((_a = this.apiCall.language.csharp) === null || _a === void 0 ? void 0 : _a.pageable);
|
|
350
|
+
this.inputObjectParameterName = 'InputObject';
|
|
332
351
|
}
|
|
333
352
|
async init() {
|
|
334
353
|
// basic stuff
|
|
335
354
|
this.addCommonStuff();
|
|
336
|
-
this.description = codegen_1.escapeString(this.operation.details.csharp.description);
|
|
355
|
+
this.description = (0, codegen_1.escapeString)(this.operation.details.csharp.description);
|
|
337
356
|
const $this = this;
|
|
338
357
|
this.add(new codegen_csharp_1.Method('BeginProcessing', codegen_csharp_1.dotnet.Void, {
|
|
339
358
|
override: codegen_csharp_1.Modifier.Override,
|
|
@@ -342,10 +361,10 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
342
361
|
*body() {
|
|
343
362
|
if ($this.state.project.azure) {
|
|
344
363
|
yield `var telemetryId = ${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.GetTelemetryId.Invoke();`;
|
|
345
|
-
yield codegen_csharp_1.If('telemetryId != "" && telemetryId != "internal"', '__correlationId = telemetryId;');
|
|
364
|
+
yield (0, codegen_csharp_1.If)('telemetryId != "" && telemetryId != "internal"', '__correlationId = telemetryId;');
|
|
346
365
|
}
|
|
347
366
|
yield 'Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials);';
|
|
348
|
-
yield codegen_csharp_1.If($this.$('Break'), `${exports_1.ClientRuntime.AttachDebugger}.Break();`);
|
|
367
|
+
yield (0, codegen_csharp_1.If)($this.$('Break'), `${exports_1.ClientRuntime.AttachDebugger}.Break();`);
|
|
349
368
|
yield $this.eventListener.syncSignal(powershell_declarations_1.Events.CmdletBeginProcessing);
|
|
350
369
|
}
|
|
351
370
|
}));
|
|
@@ -364,9 +383,45 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
364
383
|
this.implementIContext();
|
|
365
384
|
// add constructors
|
|
366
385
|
this.implementConstructors();
|
|
386
|
+
// add callback methods
|
|
387
|
+
this.NewImplementResponseMethod();
|
|
367
388
|
// processRecord
|
|
368
|
-
this.NewImplementProcessRecord(
|
|
369
|
-
|
|
389
|
+
this.NewImplementProcessRecord();
|
|
390
|
+
// find each parameter to the method, and find out where the value is going to come from.
|
|
391
|
+
this.operationParameters =
|
|
392
|
+
(0, linq_1.values)(this.apiCall.parameters).
|
|
393
|
+
// filter out constants and path parameters when using piping for identity
|
|
394
|
+
where(each => { var _a, _b; return !((_a = each.language.csharp) === null || _a === void 0 ? void 0 : _a.constantValue) && ((_b = each.language.default) === null || _b === void 0 ? void 0 : _b.name) !== '$host'; } /* && (!$this.isViaIdentity || each.in !== ParameterLocation.Path) */).
|
|
395
|
+
select(p => {
|
|
396
|
+
var _a, _b, _c;
|
|
397
|
+
return {
|
|
398
|
+
name: (_a = p.language.csharp) === null || _a === void 0 ? void 0 : _a.name,
|
|
399
|
+
param: (0, linq_1.values)(this.properties).
|
|
400
|
+
where(each => each.metadata.parameterDefinition).
|
|
401
|
+
first(each => { var _a, _b; return ((_a = each.metadata.parameterDefinition.language.csharp) === null || _a === void 0 ? void 0 : _a.serializedName) === ((_b = p.language.csharp) === null || _b === void 0 ? void 0 : _b.serializedName); }),
|
|
402
|
+
parameterLocation: (_c = (_b = p.protocol) === null || _b === void 0 ? void 0 : _b.http) === null || _c === void 0 ? void 0 : _c.in
|
|
403
|
+
};
|
|
404
|
+
}).
|
|
405
|
+
select(each => {
|
|
406
|
+
if (each.param) {
|
|
407
|
+
const httpParam = (each.param.metadata.parameterDefinition);
|
|
408
|
+
if (httpParam.required) {
|
|
409
|
+
return {
|
|
410
|
+
name: each.param,
|
|
411
|
+
expression: each.param,
|
|
412
|
+
parameterLocation: each.parameterLocation
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
const httpParamTD = this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(httpParam.schema, httpParam.required, this.state);
|
|
416
|
+
return {
|
|
417
|
+
name: each.param,
|
|
418
|
+
expression: (0, codegen_csharp_1.toExpression)(`this.InvocationInformation.BoundParameters.ContainsKey("${each.param.value}") ? ${each.param.value} : ${httpParamTD.defaultOfType}`),
|
|
419
|
+
parameterLocation: each.parameterLocation
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
return { name: each.name, expression: codegen_csharp_1.dotnet.Null, parameterLocation: each.parameterLocation };
|
|
423
|
+
}).toArray();
|
|
424
|
+
this.NewImplementProcessRecordAsync();
|
|
370
425
|
this.debugMode = await this.state.getValue('debug', false);
|
|
371
426
|
// json serialization
|
|
372
427
|
this.NewImplementSerialization(this.operation);
|
|
@@ -381,7 +436,7 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
381
436
|
var _a, _b, _c, _d, _e;
|
|
382
437
|
const header = super.headerComment;
|
|
383
438
|
let ops = '';
|
|
384
|
-
for (const httpOperation of linq_1.values(this.operation.callGraph)) {
|
|
439
|
+
for (const httpOperation of (0, linq_1.values)(this.operation.callGraph)) {
|
|
385
440
|
const request = (_a = httpOperation.requests) === null || _a === void 0 ? void 0 : _a[0];
|
|
386
441
|
if (!request) {
|
|
387
442
|
continue;
|
|
@@ -402,10 +457,10 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
402
457
|
ops = `${ops}\n variant: ${this.operation.details.csharp.name}`;
|
|
403
458
|
}
|
|
404
459
|
}
|
|
405
|
-
return ops ? `${header}\n${codegen_1.docComment(codegen_csharp_1.xmlize('remarks', ops))}` : header;
|
|
460
|
+
return ops ? `${header}\n${(0, codegen_1.docComment)((0, codegen_csharp_1.xmlize)('remarks', ops))}` : header;
|
|
406
461
|
}
|
|
407
462
|
AddSwitchViewProperty(responseType = codegen_csharp_1.dotnet.Object) {
|
|
408
|
-
|
|
463
|
+
const fieldNames = this.fields.map(f => f.name);
|
|
409
464
|
if (!fieldNames.includes('_responseSize')) {
|
|
410
465
|
this.add(new codegen_csharp_1.Field('_responseSize', codegen_csharp_1.dotnet.Int, {
|
|
411
466
|
initialValue: '0', description: 'A flag to tell whether it is the first returned object in a call. Zero means no response yet. One means 1 returned object. Two means multiple returned objects in response.', access: codegen_csharp_1.Access.Private
|
|
@@ -418,9 +473,9 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
418
473
|
}
|
|
419
474
|
}
|
|
420
475
|
FlushResponse(singleFlush = true) {
|
|
421
|
-
|
|
476
|
+
const fieldNames = this.fields.map(f => f.name);
|
|
422
477
|
return fieldNames.includes('_responseSize') ?
|
|
423
|
-
codegen_csharp_1.If(
|
|
478
|
+
(0, codegen_csharp_1.If)('1 ==_responseSize', function* () {
|
|
424
479
|
yield '// Flush buffer';
|
|
425
480
|
if (singleFlush) {
|
|
426
481
|
yield 'WriteObject(_firstResponse);';
|
|
@@ -430,42 +485,39 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
430
485
|
}
|
|
431
486
|
}) : '';
|
|
432
487
|
}
|
|
433
|
-
;
|
|
434
488
|
WriteObjectWithViewControl(valueName, isEnumerable = false) {
|
|
435
489
|
const $this = this;
|
|
436
490
|
if ($this.state.project.autoSwitchView) {
|
|
437
491
|
if (isEnumerable) {
|
|
438
492
|
return function* () {
|
|
439
|
-
yield `
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
yield
|
|
443
|
-
yield `_responseSize = 1;`;
|
|
493
|
+
yield (0, codegen_csharp_1.If)(`null != ${valueName}`, function* () {
|
|
494
|
+
yield (0, codegen_csharp_1.If)(`0 == _responseSize && 1 == ${valueName}.Count`, function* () {
|
|
495
|
+
yield `_firstResponse = ${valueName}[0];`;
|
|
496
|
+
yield '_responseSize = 1;';
|
|
444
497
|
});
|
|
445
|
-
yield codegen_csharp_1.Else(function* () {
|
|
498
|
+
yield (0, codegen_csharp_1.Else)(function* () {
|
|
446
499
|
yield $this.FlushResponse(false);
|
|
447
500
|
yield 'var values = new System.Collections.Generic.List<System.Management.Automation.PSObject>();';
|
|
448
|
-
yield codegen_csharp_1.ForEach(
|
|
449
|
-
yield
|
|
501
|
+
yield (0, codegen_csharp_1.ForEach)('value', valueName, function* () {
|
|
502
|
+
yield 'values.Add(value.AddMultipleTypeNameIntoPSObject());';
|
|
450
503
|
});
|
|
451
504
|
yield 'WriteObject(values, true); ';
|
|
452
|
-
yield
|
|
505
|
+
yield '_responseSize = 2;';
|
|
453
506
|
});
|
|
454
507
|
});
|
|
455
508
|
};
|
|
456
509
|
}
|
|
457
510
|
else {
|
|
458
511
|
return function* () {
|
|
459
|
-
yield `
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
yield
|
|
463
|
-
yield `_responseSize = 1;`;
|
|
512
|
+
yield (0, codegen_csharp_1.If)(`null != ${valueName}`, function* () {
|
|
513
|
+
yield (0, codegen_csharp_1.If)('0 == _responseSize', function* () {
|
|
514
|
+
yield `_firstResponse = ${valueName};`;
|
|
515
|
+
yield '_responseSize = 1;';
|
|
464
516
|
});
|
|
465
|
-
yield codegen_csharp_1.Else(function* () {
|
|
517
|
+
yield (0, codegen_csharp_1.Else)(function* () {
|
|
466
518
|
yield $this.FlushResponse(false);
|
|
467
|
-
yield `WriteObject(
|
|
468
|
-
yield
|
|
519
|
+
yield `WriteObject(${valueName}.AddMultipleTypeNameIntoPSObject());`;
|
|
520
|
+
yield '_responseSize = 2;';
|
|
469
521
|
});
|
|
470
522
|
});
|
|
471
523
|
};
|
|
@@ -480,7 +532,7 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
480
532
|
// add a private copy of invocation information for our own uses.
|
|
481
533
|
const privateInvocationInfo = this.add(new codegen_csharp_1.Field('__invocationInfo', powershell_declarations_1.InvocationInfo, { description: 'A copy of the Invocation Info (necessary to allow asJob to clone this cmdlet)', access: codegen_csharp_1.Access.Private }));
|
|
482
534
|
this.invocationInfo = new codegen_csharp_1.Property('InvocationInformation', powershell_declarations_1.InvocationInfo, { description: 'Accessor for our copy of the InvocationInfo.' });
|
|
483
|
-
this.invocationInfo.get = codegen_csharp_1.toExpression(`${privateInvocationInfo.value} = ${privateInvocationInfo.value} ?? this.MyInvocation `);
|
|
535
|
+
this.invocationInfo.get = (0, codegen_csharp_1.toExpression)(`${privateInvocationInfo.value} = ${privateInvocationInfo.value} ?? this.MyInvocation `);
|
|
484
536
|
this.invocationInfo.set = new codegen_csharp_1.Statements(privateInvocationInfo.assign('value'));
|
|
485
537
|
this.add(this.invocationInfo);
|
|
486
538
|
if (this.state.project.azure) {
|
|
@@ -506,6 +558,9 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
506
558
|
if ($this.state.project.autoSwitchView) {
|
|
507
559
|
yield $this.FlushResponse();
|
|
508
560
|
}
|
|
561
|
+
if (!$this.state.project.azure) {
|
|
562
|
+
yield $this.eventListener.syncSignal(powershell_declarations_1.Events.CmdletEndProcessing);
|
|
563
|
+
}
|
|
509
564
|
});
|
|
510
565
|
// debugging
|
|
511
566
|
const brk = this.add(new codegen_csharp_1.Property('Break', powershell_declarations_1.SwitchParameter, { attributes: [], description: 'Wait for .NET debugger to attach' }));
|
|
@@ -531,40 +586,27 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
531
586
|
proxyUri.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ParameterAttribute, { parameters: ['Mandatory = false', 'DontShow = true', 'HelpMessage = "The URI for the proxy server to use"'] }));
|
|
532
587
|
proxyUri.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CategoryAttribute, { parameters: [`${powershell_declarations_1.ParameterCategory}.Runtime`] }));
|
|
533
588
|
if (this.state.project.azure) {
|
|
534
|
-
this.defaultProfile = this.add(new codegen_csharp_1.Property('DefaultProfile', powershell_declarations_1.PSObject, { description: 'The
|
|
535
|
-
this.defaultProfile.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ParameterAttribute, { parameters: ['Mandatory = false', 'HelpMessage = "The
|
|
589
|
+
this.defaultProfile = this.add(new codegen_csharp_1.Property('DefaultProfile', powershell_declarations_1.PSObject, { description: 'The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription' }));
|
|
590
|
+
this.defaultProfile.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ParameterAttribute, { parameters: ['Mandatory = false', 'HelpMessage = "The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription."'] }));
|
|
536
591
|
this.defaultProfile.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ValidateNotNull));
|
|
537
592
|
this.defaultProfile.add(new codegen_csharp_1.Attribute(powershell_declarations_1.Alias, { parameters: ['"AzureRMContext"', '"AzureCredential"'] }));
|
|
538
593
|
this.defaultProfile.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CategoryAttribute, { parameters: [`${powershell_declarations_1.ParameterCategory}.Azure`] }));
|
|
539
594
|
}
|
|
540
595
|
}
|
|
541
|
-
|
|
542
|
-
var _a, _b;
|
|
543
|
-
if (operation.callGraph[0].requests) {
|
|
544
|
-
switch ((_b = (_a = operation.callGraph[0].requests[0]) === null || _a === void 0 ? void 0 : _a.protocol.http) === null || _b === void 0 ? void 0 : _b.method.toLowerCase()) {
|
|
545
|
-
case 'put':
|
|
546
|
-
case 'post':
|
|
547
|
-
case 'delete':
|
|
548
|
-
case 'patch':
|
|
549
|
-
return true;
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
return false;
|
|
553
|
-
}
|
|
554
|
-
NewImplementProcessRecord(operation) {
|
|
596
|
+
NewImplementProcessRecord() {
|
|
555
597
|
const $this = this;
|
|
556
|
-
const
|
|
598
|
+
const operation = $this.operation;
|
|
557
599
|
this.add(new codegen_csharp_1.Method('ProcessRecord', undefined, { access: codegen_csharp_1.Access.Protected, override: codegen_csharp_1.Modifier.Override, description: 'Performs execution of the command.' })).add(function* () {
|
|
558
600
|
yield $this.eventListener.syncSignal(powershell_declarations_1.Events.CmdletProcessRecordStart);
|
|
559
601
|
if ($this.state.project.azure) {
|
|
560
602
|
yield $this.processRecordId.assign('System.Guid.NewGuid().ToString()');
|
|
561
603
|
}
|
|
562
|
-
yield codegen_csharp_1.Try(function* () {
|
|
604
|
+
yield (0, codegen_csharp_1.Try)(function* () {
|
|
563
605
|
var _a;
|
|
564
606
|
yield '// work';
|
|
565
607
|
const normal = new codegen_csharp_1.Statements(function* () {
|
|
566
608
|
const acr = new codegen_csharp_1.LocalVariable('asyncCommandRuntime', codegen_csharp_1.dotnet.Var, { initializer: powershell_declarations_1.AsyncCommandRuntime.new(codegen_csharp_1.dotnet.This, $this.cancellationToken) });
|
|
567
|
-
yield codegen_csharp_1.Using(acr.declarationExpression, function* () {
|
|
609
|
+
yield (0, codegen_csharp_1.Using)(acr.declarationExpression, function* () {
|
|
568
610
|
yield `${acr}.Wait( ProcessRecordAsync(),${$this.cancellationToken});`;
|
|
569
611
|
});
|
|
570
612
|
});
|
|
@@ -577,7 +619,7 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
577
619
|
nowait.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CategoryAttribute, { parameters: [`${powershell_declarations_1.ParameterCategory}.Runtime`] }));
|
|
578
620
|
}
|
|
579
621
|
const work = operation.asjob ? function* () {
|
|
580
|
-
yield codegen_csharp_1.If('true == MyInvocation?.BoundParameters?.ContainsKey("AsJob")', function* () {
|
|
622
|
+
yield (0, codegen_csharp_1.If)('true == MyInvocation?.BoundParameters?.ContainsKey("AsJob")', function* () {
|
|
581
623
|
// clone the cmdlet instance, since the instance can be reused and overwrite data.
|
|
582
624
|
const instance = new codegen_csharp_1.LocalVariable('instance', codegen_csharp_1.dotnet.Var, { initializer: 'this.Clone()' });
|
|
583
625
|
yield instance.declarationStatement;
|
|
@@ -594,46 +636,48 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
594
636
|
// return the job to the user now.
|
|
595
637
|
yield `WriteObject(${job});`;
|
|
596
638
|
});
|
|
597
|
-
yield codegen_csharp_1.Else(normal);
|
|
639
|
+
yield (0, codegen_csharp_1.Else)(normal);
|
|
598
640
|
} : normal;
|
|
599
|
-
if (
|
|
600
|
-
yield codegen_csharp_1.If(`ShouldProcess($"Call remote '${(_a =
|
|
641
|
+
if ((0, command_operation_1.isWritableCmdlet)(operation) && !operation.details.csharp.supportShouldProcess) {
|
|
642
|
+
yield (0, codegen_csharp_1.If)(`ShouldProcess($"Call remote '${(_a = $this.apiCall.language.csharp) === null || _a === void 0 ? void 0 : _a.name}' operation")`, work);
|
|
601
643
|
}
|
|
602
644
|
else {
|
|
603
645
|
yield work;
|
|
604
646
|
}
|
|
605
647
|
});
|
|
606
648
|
const aggregateException = new codegen_csharp_1.Parameter('aggregateException', codegen_csharp_1.System.AggregateException);
|
|
607
|
-
yield codegen_csharp_1.Catch(aggregateException, function* () {
|
|
649
|
+
yield (0, codegen_csharp_1.Catch)(aggregateException, function* () {
|
|
608
650
|
yield '// unroll the inner exceptions to get the root cause';
|
|
609
|
-
yield codegen_csharp_1.ForEach('innerException', new codegen_csharp_1.LiteralExpression(`${aggregateException.use}.Flatten().InnerExceptions`), function* () {
|
|
651
|
+
yield (0, codegen_csharp_1.ForEach)('innerException', new codegen_csharp_1.LiteralExpression(`${aggregateException.use}.Flatten().InnerExceptions`), function* () {
|
|
610
652
|
yield $this.eventListener.syncSignal(powershell_declarations_1.Events.CmdletException, new codegen_csharp_1.LiteralExpression('$"{innerException.GetType().Name} - {innerException.Message} : {innerException.StackTrace}"'));
|
|
611
653
|
yield '// Write exception out to error channel.';
|
|
612
|
-
yield `WriteError( new ${powershell_declarations_1.ErrorRecord}(innerException,string.Empty, ${powershell_declarations_1.ErrorCategory('NotSpecified')}, null) );`;
|
|
654
|
+
yield `WriteError( new ${powershell_declarations_1.ErrorRecord}(innerException,string.Empty, ${(0, powershell_declarations_1.ErrorCategory)('NotSpecified')}, null) );`;
|
|
613
655
|
});
|
|
614
656
|
});
|
|
615
657
|
const exception = new codegen_csharp_1.Parameter('exception', codegen_csharp_1.System.Exception);
|
|
616
|
-
yield codegen_csharp_1.Catch(exception, function* () {
|
|
658
|
+
yield (0, codegen_csharp_1.Catch)(exception, function* () {
|
|
617
659
|
yield $this.eventListener.syncSignal(powershell_declarations_1.Events.CmdletException, new codegen_csharp_1.LiteralExpression(`$"{${exception.use}.GetType().Name} - {${exception.use}.Message} : {${exception.use}.StackTrace}"`));
|
|
618
660
|
yield '// Write exception out to error channel.';
|
|
619
|
-
yield `WriteError( new ${powershell_declarations_1.ErrorRecord}(${exception.use},string.Empty, ${powershell_declarations_1.ErrorCategory('NotSpecified')}, null) );`;
|
|
661
|
+
yield `WriteError( new ${powershell_declarations_1.ErrorRecord}(${exception.use},string.Empty, ${(0, powershell_declarations_1.ErrorCategory)('NotSpecified')}, null) );`;
|
|
620
662
|
}, { when: new codegen_csharp_1.LiteralExpression('(exception as System.Management.Automation.PipelineStoppedException)== null || (exception as System.Management.Automation.PipelineStoppedException).InnerException != null') });
|
|
621
|
-
yield codegen_csharp_1.Finally(function* () {
|
|
663
|
+
yield (0, codegen_csharp_1.Finally)(function* () {
|
|
622
664
|
yield $this.eventListener.syncSignalNoCheck(powershell_declarations_1.Events.CmdletProcessRecordEnd);
|
|
623
665
|
});
|
|
624
666
|
});
|
|
625
667
|
}
|
|
626
|
-
NewImplementProcessRecordAsync(
|
|
668
|
+
NewImplementProcessRecordAsync() {
|
|
627
669
|
const $this = this;
|
|
628
|
-
const
|
|
670
|
+
const operationParameters = $this.operationParameters;
|
|
671
|
+
const pipeline = $this.$('Pipeline');
|
|
672
|
+
this.serializationMode = this.bodyParameter ? (this.operation.operationType === command_operation_1.OperationType.Create ? exports_1.ClientRuntime.SerializationMode.IncludeCreate : (this.operation.operationType === command_operation_1.OperationType.Update ? exports_1.ClientRuntime.SerializationMode.IncludeUpdate : undefined)) : undefined;
|
|
673
|
+
const PRA = this.add(new codegen_csharp_1.Method('ProcessRecordAsync', codegen_csharp_1.System.Threading.Tasks.Task(), {
|
|
629
674
|
access: codegen_csharp_1.Access.Protected, async: codegen_csharp_1.Modifier.Async,
|
|
630
675
|
description: 'Performs execution of the command, working asynchronously if required.',
|
|
631
676
|
returnsDescription: `A <see cref="${codegen_csharp_1.System.Threading.Tasks.Task()}" /> that will be complete when handling of the method is completed.`
|
|
632
677
|
}));
|
|
633
678
|
// we don't want to use SynchContext here.
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
679
|
+
PRA.push((0, codegen_csharp_1.Using)('NoSynchronizationContext', ''));
|
|
680
|
+
PRA.add(function* () {
|
|
637
681
|
if ($this.apProp && $this.bodyParameter && $this.bodyParameterInfo) {
|
|
638
682
|
// yield `${ClientRuntime}.DictionaryExtensions.HashTableToDictionary<${$this.bodyParameterInfo.type.declaration},${$this.bodyParameterInfo.valueType.declaration}>(${$this.apProp.value},${$this.bodyParameter.Cast($this.bodyParameterInfo.type)});`;
|
|
639
683
|
let vt = $this.bodyParameterInfo.valueType.declaration;
|
|
@@ -643,16 +687,18 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
643
687
|
yield `${exports_1.ClientRuntime}.DictionaryExtensions.HashTableToDictionary<${vt}>(${$this.apProp.value},${$this.bodyParameter}.AdditionalProperties);`;
|
|
644
688
|
}
|
|
645
689
|
// construct the call to the operation
|
|
690
|
+
if (!$this.state.project.azure) {
|
|
691
|
+
yield $this.eventListener.signal(powershell_declarations_1.Events.CmdletProcessRecordAsyncStart);
|
|
692
|
+
}
|
|
646
693
|
yield $this.eventListener.signal(powershell_declarations_1.Events.CmdletGetPipeline);
|
|
647
|
-
const pipeline = $this.$('Pipeline');
|
|
648
694
|
if ($this.state.project.azure) {
|
|
649
695
|
yield pipeline.assign(new codegen_csharp_1.LiteralExpression(`${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.CreatePipeline(${$this.invocationInfo}, ${$this.correlationId}, ${$this.processRecordId}, this.ParameterSetName, this.ExtensibleParameters)`));
|
|
650
696
|
}
|
|
651
697
|
else {
|
|
652
698
|
yield pipeline.assign(new codegen_csharp_1.LiteralExpression(`${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.CreatePipeline(${$this.invocationInfo}, this.ParameterSetName, this.ExtensibleParameters)`));
|
|
653
699
|
}
|
|
654
|
-
yield codegen_csharp_1.If(codegen_csharp_1.IsNotNull($this.$('HttpPipelinePrepend')), pipeline.invokeMethod('Prepend', codegen_csharp_1.toExpression(`(this.CommandRuntime as Microsoft.Rest.ClientRuntime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(${$this.$('HttpPipelinePrepend')}) ?? ${$this.$('HttpPipelinePrepend')}`)));
|
|
655
|
-
yield codegen_csharp_1.If(codegen_csharp_1.IsNotNull($this.$('HttpPipelineAppend')), pipeline.invokeMethod('Append', codegen_csharp_1.toExpression(`(this.CommandRuntime as Microsoft.Rest.ClientRuntime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(${$this.$('HttpPipelineAppend')}) ?? ${$this.$('HttpPipelineAppend')}`)));
|
|
700
|
+
yield (0, codegen_csharp_1.If)((0, codegen_csharp_1.IsNotNull)($this.$('HttpPipelinePrepend')), pipeline.invokeMethod('Prepend', (0, codegen_csharp_1.toExpression)(`(this.CommandRuntime as Microsoft.Rest.ClientRuntime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(${$this.$('HttpPipelinePrepend')}) ?? ${$this.$('HttpPipelinePrepend')}`)));
|
|
701
|
+
yield (0, codegen_csharp_1.If)((0, codegen_csharp_1.IsNotNull)($this.$('HttpPipelineAppend')), pipeline.invokeMethod('Append', (0, codegen_csharp_1.toExpression)(`(this.CommandRuntime as Microsoft.Rest.ClientRuntime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(${$this.$('HttpPipelineAppend')}) ?? ${$this.$('HttpPipelineAppend')}`)));
|
|
656
702
|
yield '// get the client instance';
|
|
657
703
|
// Add input pipeline if it is configured by developers.
|
|
658
704
|
if ($this.operation.extensions.inputPipe) {
|
|
@@ -673,404 +719,518 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
673
719
|
};
|
|
674
720
|
for (const vParam of [...vps.body, ...vps.operation]) {
|
|
675
721
|
if (vParam.hidden) {
|
|
676
|
-
const td = $this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(vParam.schema, true, $this.state);
|
|
677
|
-
yield codegen_csharp_1.If(`true == this.MyInvocation?.BoundParameters?.ContainsKey("${vParam.name}")`, `${vParam.name} = (${td.declaration})this.MyInvocation.BoundParameters["${vParam.name}"];`);
|
|
722
|
+
const td = $this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(vParam.schema, true, $this.state, true);
|
|
723
|
+
yield (0, codegen_csharp_1.If)(`true == this.MyInvocation?.BoundParameters?.ContainsKey("${vParam.name}")`, `${vParam.name} = (${td.declaration})this.MyInvocation.BoundParameters["${vParam.name}"];`);
|
|
678
724
|
}
|
|
679
725
|
}
|
|
680
|
-
|
|
681
|
-
//
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
726
|
+
// is there a body parameter we should include?
|
|
727
|
+
// if ($this.bodyParameter) {
|
|
728
|
+
// operationParameters.push({ name: 'body', expression: $this.bodyParameter, isPathParam: false });
|
|
729
|
+
// }
|
|
730
|
+
yield (0, codegen_csharp_1.Try)(function* () {
|
|
731
|
+
// make the call.
|
|
732
|
+
let preProcess;
|
|
733
|
+
switch ($this.operation.commandType) {
|
|
734
|
+
case command_operation_1.CommandType.GetPut:
|
|
735
|
+
preProcess = $this.GetPutPreProcess;
|
|
736
|
+
break;
|
|
737
|
+
case command_operation_1.CommandType.Atomic:
|
|
738
|
+
default:
|
|
739
|
+
preProcess = undefined;
|
|
740
|
+
break;
|
|
741
|
+
}
|
|
742
|
+
const actualCall = function* () {
|
|
743
|
+
yield $this.eventListener.signal(powershell_declarations_1.Events.CmdletBeforeAPICall);
|
|
744
|
+
yield $this.ImplementCall(preProcess);
|
|
745
|
+
yield $this.eventListener.signal(powershell_declarations_1.Events.CmdletAfterAPICall);
|
|
693
746
|
};
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
747
|
+
if ($this.state.project.azure && operationParameters.find(each => each.expression && each.expression.value === 'SubscriptionId') && $this.operation.details.csharp.verb.toLowerCase() === 'get') {
|
|
748
|
+
yield 'foreach( var SubscriptionId in this.SubscriptionId )';
|
|
749
|
+
yield (0, codegen_csharp_1.BlockStatement)(actualCall);
|
|
750
|
+
}
|
|
751
|
+
else {
|
|
752
|
+
yield actualCall;
|
|
753
|
+
}
|
|
754
|
+
});
|
|
755
|
+
const ure = new codegen_csharp_1.Parameter('urexception', { declaration: `${exports_1.ClientRuntime.fullName}.UndeclaredResponseException` });
|
|
756
|
+
yield (0, codegen_csharp_1.Catch)(ure, function* () {
|
|
757
|
+
yield `WriteError(new global::System.Management.Automation.ErrorRecord(${ure.value}, ${ure.value}.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { ${operationParameters.filter(e => (0, codegen_csharp_1.valueOf)(e.expression) !== 'null').map(each => `${each.name}=${each.expression}`).join(',')}})
|
|
758
|
+
{
|
|
759
|
+
ErrorDetails = new global::System.Management.Automation.ErrorDetails(${ure.value}.Message) { RecommendedAction = ${ure.value}.Action }
|
|
760
|
+
});`;
|
|
761
|
+
});
|
|
762
|
+
yield (0, codegen_csharp_1.Finally)(function* () {
|
|
763
|
+
yield $this.eventListener.signalNoCheck(powershell_declarations_1.Events.CmdletProcessRecordAsyncEnd);
|
|
764
|
+
});
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
*ImplementCall(preProcess) {
|
|
768
|
+
var _a, _b;
|
|
769
|
+
const $this = this;
|
|
770
|
+
const operation = $this.operation;
|
|
771
|
+
const apiCall = $this.apiCall;
|
|
772
|
+
const operationParameters = $this.operationParameters;
|
|
773
|
+
const callbackMethods = $this.callbackMethods;
|
|
774
|
+
const pipeline = $this.$('Pipeline');
|
|
775
|
+
const serializationMode = $this.serializationMode;
|
|
776
|
+
const bodyParameter = this.bodyParameter ? { name: 'body', value: (0, codegen_csharp_1.valueOf)(this.bodyParameter) } : undefined;
|
|
777
|
+
const pathParamsNotInIdentity = [];
|
|
778
|
+
const pathParamsInIdentity = [];
|
|
779
|
+
const pathParamsInIdentitySerializedName = [];
|
|
780
|
+
const headerParams = [];
|
|
781
|
+
const queryParams = [];
|
|
782
|
+
const otherParams = [];
|
|
783
|
+
const idschema = (0, linq_1.values)($this.state.project.model.schemas.objects).first(each => each.language.default.uid === 'universal-parameter-type');
|
|
784
|
+
let httpOperationName = `${(_a = apiCall.language.csharp) === null || _a === void 0 ? void 0 : _a.name}`;
|
|
785
|
+
if (idschema) {
|
|
786
|
+
const allVPs = (0, schema_1.getAllPublicVirtualProperties)((_b = idschema.language.csharp) === null || _b === void 0 ? void 0 : _b.virtualProperties);
|
|
787
|
+
const props = [...(0, linq_1.values)(idschema.properties)];
|
|
788
|
+
operationParameters.forEach(each => {
|
|
789
|
+
var _a, _b, _c, _d, _e, _f;
|
|
790
|
+
const pascalName = (0, codegen_1.pascalCase)(`${each.name}`);
|
|
791
|
+
//push parameters that is not path parameters into allParams and idOpParamsNotFromIdentity
|
|
792
|
+
if (each.parameterLocation !== codemodel_v3_1.ParameterLocation.Path) {
|
|
793
|
+
const param = {
|
|
794
|
+
name: undefined,
|
|
795
|
+
value: (0, codegen_csharp_1.valueOf)(each.expression)
|
|
796
|
+
};
|
|
797
|
+
switch (each.parameterLocation) {
|
|
798
|
+
case codemodel_v3_1.ParameterLocation.Header:
|
|
799
|
+
headerParams.push(param);
|
|
800
|
+
break;
|
|
801
|
+
case codemodel_v3_1.ParameterLocation.Query:
|
|
802
|
+
queryParams.push(param);
|
|
803
|
+
break;
|
|
804
|
+
default:
|
|
805
|
+
otherParams.push(param);
|
|
806
|
+
break;
|
|
807
|
+
}
|
|
808
|
+
return;
|
|
809
|
+
}
|
|
810
|
+
else {
|
|
811
|
+
const match = props.find(p => (0, codegen_1.pascalCase)(p.serializedName) === pascalName);
|
|
812
|
+
if (match) {
|
|
813
|
+
const defaultOfType = $this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(match.schema, true, $this.state).defaultOfType;
|
|
814
|
+
// match up vp name
|
|
815
|
+
const vp = allVPs.find(pp => (0, codegen_1.pascalCase)(pp.property.serializedName) === pascalName);
|
|
816
|
+
//push path parameters that form current identity into allParams, idOpParamsFromIdentity and idOpParamsFromIdentityserializedName
|
|
817
|
+
if (vp && each.expression === codegen_csharp_1.dotnet.Null) {
|
|
818
|
+
const param = {
|
|
819
|
+
name: `${$this.inputObjectParameterName}.${vp.name}`,
|
|
820
|
+
value: `${$this.inputObjectParameterName}.${vp.name} ?? ${defaultOfType}`
|
|
821
|
+
};
|
|
822
|
+
pathParamsInIdentity.push(param);
|
|
823
|
+
pathParamsInIdentitySerializedName.push(match.serializedName);
|
|
824
|
+
return;
|
|
825
|
+
}
|
|
826
|
+
// fall back!
|
|
827
|
+
console.error(`Unable to match identity parameter '${each.name}' member to appropriate virtual parameter. (Guessing '${(0, codegen_1.pascalCase)((_b = (_a = match.language.csharp) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '')}').`);
|
|
828
|
+
//push path parameters that current identity does not contain into allParams and idOpParamsNotFromIdentity
|
|
829
|
+
const param = {
|
|
830
|
+
name: `${(0, codegen_1.pascalCase)((_d = (_c = match.language.csharp) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : '')}`,
|
|
831
|
+
value: `${(0, codegen_1.pascalCase)((_f = (_e = match.language.csharp) === null || _e === void 0 ? void 0 : _e.name) !== null && _f !== void 0 ? _f : '')}`
|
|
703
832
|
};
|
|
833
|
+
pathParamsNotInIdentity.push(param);
|
|
834
|
+
}
|
|
835
|
+
else {
|
|
836
|
+
console.error(`Unable to match identity parameter '${each.name}' member to appropriate virtual parameter. (Guessing '${pascalName}')`);
|
|
837
|
+
/*
|
|
838
|
+
push path parameters do not match the name in identity schema into allParams and idOpParamsNotFromIdentity
|
|
839
|
+
for example, module 'Service' has only one GET API:
|
|
840
|
+
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Service/resource1/{resource1Name}/resource2/{resource2Name}/resource3/{resource3Name}
|
|
841
|
+
the identity schema 'ServiceIdentity.cs' will have properties: {subscriptionId, resourceGroupName, resource1Name, resource2Name, resource3Name}
|
|
842
|
+
for variant which has (identity of resource2 + resource3Name) combined as parameters, the parameter name for 'resource3Name' is called 'Name' which do not match 'resource3Name' in 'ServiceIdentity.cs'
|
|
843
|
+
*/
|
|
844
|
+
const param = {
|
|
845
|
+
name: `${pascalName}`,
|
|
846
|
+
value: `${pascalName}`
|
|
847
|
+
};
|
|
848
|
+
pathParamsNotInIdentity.push(param);
|
|
704
849
|
}
|
|
705
|
-
const httpParamTD = $this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(httpParam.schema, httpParam.required, $this.state);
|
|
706
|
-
return {
|
|
707
|
-
name: each.param,
|
|
708
|
-
expression: codegen_csharp_1.toExpression(`this.InvocationInformation.BoundParameters.ContainsKey("${each.param.value}") ? ${each.param.value} : ${httpParamTD.defaultOfType}`),
|
|
709
|
-
isPathParam: each.isPathParam
|
|
710
|
-
};
|
|
711
850
|
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
}
|
|
851
|
+
});
|
|
852
|
+
}
|
|
853
|
+
if ($this.isViaIdentity) {
|
|
854
|
+
//when identity does not contain property: 'Id'
|
|
855
|
+
const identityFromPathParams = function* () {
|
|
856
|
+
yield '// try to call with PATH parameters from Input Object';
|
|
857
|
+
if (idschema) {
|
|
858
|
+
for (const opParam of pathParamsInIdentity) {
|
|
859
|
+
if (opParam && opParam.name) {
|
|
860
|
+
yield (0, codegen_csharp_1.If)((0, codegen_csharp_1.IsNull)(opParam.name), `ThrowTerminatingError( new ${powershell_declarations_1.ErrorRecord}(new global::System.Exception("${$this.inputObjectParameterName} has null value for ${opParam.name}"),string.Empty, ${(0, powershell_declarations_1.ErrorCategory)('InvalidArgument')}, ${$this.inputObjectParameterName}) );`);
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
const pathParameters = [...pathParamsInIdentity.map(each => (0, codegen_csharp_1.toExpression)(each.value)), ...pathParamsNotInIdentity.map(each => (0, codegen_csharp_1.toExpression)(each.value))];
|
|
864
|
+
const nonPathParameters = [...headerParams.map(each => (0, codegen_csharp_1.toExpression)(each.value)), ...queryParams.map(each => (0, codegen_csharp_1.toExpression)(each.value)), ...otherParams.map(each => (0, codegen_csharp_1.toExpression)(each.value))];
|
|
865
|
+
const parameters = bodyParameter ? [...pathParameters, ...nonPathParameters, (0, codegen_csharp_1.toExpression)(bodyParameter.value), ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline] : [...pathParameters, ...nonPathParameters, ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline];
|
|
866
|
+
if (serializationMode) {
|
|
867
|
+
parameters.push(serializationMode);
|
|
868
|
+
}
|
|
869
|
+
if (preProcess) {
|
|
870
|
+
yield preProcess($this, pathParameters, [...otherParams.map(each => (0, codegen_csharp_1.toExpression)(each.value)), codegen_csharp_1.dotnet.This, pipeline], false);
|
|
871
|
+
}
|
|
872
|
+
yield `await this.${$this.$('Client').invokeMethod(httpOperationName, ...parameters).implementation}`;
|
|
873
|
+
}
|
|
874
|
+
};
|
|
875
|
+
//when identity does contain property: 'Id'
|
|
876
|
+
const identityParams = function* () {
|
|
877
|
+
var _a, _b;
|
|
878
|
+
const path = (_b = (_a = apiCall.requests) === null || _a === void 0 ? void 0 : _a[0].protocol.http) === null || _b === void 0 ? void 0 : _b.path;
|
|
879
|
+
let pathParams = '';
|
|
880
|
+
//append path parameters which are not part of current identity
|
|
881
|
+
pathParamsNotInIdentity.forEach(each => {
|
|
882
|
+
var _a;
|
|
883
|
+
const serializedName = (_a = (0, linq_1.values)($this.properties)
|
|
884
|
+
.where(p => p.metadata.parameterDefinition)
|
|
885
|
+
.first(p => p.name === each.name)) === null || _a === void 0 ? void 0 : _a.metadata.parameterDefinition.language.csharp.serializedName;
|
|
886
|
+
if (each.name && serializedName) {
|
|
887
|
+
if (!pathParams) {
|
|
888
|
+
pathParams += '$"';
|
|
889
|
+
}
|
|
890
|
+
const resourceName = (0, resourceName_1.getResourceNameFromPath)(path, serializedName);
|
|
891
|
+
if (resourceName) {
|
|
892
|
+
pathParams += `/${resourceName}/{(global::System.Uri.EscapeDataString(this.${each.name}.ToString()))}`;
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
});
|
|
896
|
+
//add child resource to path for list operation
|
|
897
|
+
if ($this.operation.variant.startsWith('List') && (pathParamsInIdentitySerializedName === null || pathParamsInIdentitySerializedName === void 0 ? void 0 : pathParamsInIdentitySerializedName[pathParamsInIdentitySerializedName.length - 1])) {
|
|
898
|
+
const childResourceName = (0, resourceName_1.getChildResourceNameFromPath)(path, pathParamsInIdentitySerializedName === null || pathParamsInIdentitySerializedName === void 0 ? void 0 : pathParamsInIdentitySerializedName[pathParamsInIdentitySerializedName.length - 1]);
|
|
899
|
+
if (pathParams && pathParams.length > 0) {
|
|
900
|
+
pathParams += `/${childResourceName}`;
|
|
901
|
+
}
|
|
902
|
+
else {
|
|
903
|
+
pathParams += `"/${childResourceName}`;
|
|
904
|
+
}
|
|
730
905
|
}
|
|
731
|
-
if (
|
|
732
|
-
|
|
906
|
+
if (pathParams && pathParams.length > 0) {
|
|
907
|
+
pathParams += '";';
|
|
908
|
+
yield `this.${$this.inputObjectParameterName}.Id += ${pathParams}`;
|
|
733
909
|
}
|
|
734
|
-
|
|
735
|
-
|
|
910
|
+
const pathParameters = [(0, codegen_csharp_1.toExpression)(`${$this.inputObjectParameterName}.Id`)];
|
|
911
|
+
const nonPathParameters = [...headerParams.map(each => (0, codegen_csharp_1.toExpression)(each.value)), ...queryParams.map(each => (0, codegen_csharp_1.toExpression)(each.value)), ...otherParams.map(each => (0, codegen_csharp_1.toExpression)(each.value))];
|
|
912
|
+
const parameters = bodyParameter ? [...pathParameters, ...nonPathParameters, (0, codegen_csharp_1.toExpression)(bodyParameter.value), ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline] : [...pathParameters, ...nonPathParameters, ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline];
|
|
913
|
+
if (serializationMode) {
|
|
914
|
+
parameters.push(serializationMode);
|
|
736
915
|
}
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
});
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
916
|
+
if (preProcess) {
|
|
917
|
+
yield preProcess($this, pathParameters, [...otherParams.map(each => (0, codegen_csharp_1.toExpression)(each.value)), codegen_csharp_1.dotnet.This, pipeline], true);
|
|
918
|
+
}
|
|
919
|
+
yield `await this.${$this.$('Client').invokeMethod(`${httpOperationName}ViaIdentity`, ...parameters).implementation}`;
|
|
920
|
+
};
|
|
921
|
+
if (idschema && (0, linq_1.values)(idschema.properties).first(each => { var _a; return ((_a = each.language.csharp) === null || _a === void 0 ? void 0 : _a.uid) === 'universal-parameter:resource identity'; })) {
|
|
922
|
+
yield (0, codegen_csharp_1.If)(`${$this.inputObjectParameterName}?.Id != null`, identityParams);
|
|
923
|
+
yield (0, codegen_csharp_1.Else)(identityFromPathParams);
|
|
924
|
+
}
|
|
925
|
+
else {
|
|
926
|
+
yield identityFromPathParams;
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
else {
|
|
930
|
+
const pathParameters = [...pathParamsInIdentity.map(each => (0, codegen_csharp_1.toExpression)(each.value)), ...pathParamsNotInIdentity.map(each => (0, codegen_csharp_1.toExpression)(each.value))];
|
|
931
|
+
const nonPathParameters = [...headerParams.map(each => (0, codegen_csharp_1.toExpression)(each.value)), ...queryParams.map(each => (0, codegen_csharp_1.toExpression)(each.value)), ...otherParams.map(each => (0, codegen_csharp_1.toExpression)(each.value))];
|
|
932
|
+
let parameters = bodyParameter ? [...pathParameters, ...nonPathParameters, (0, codegen_csharp_1.toExpression)(bodyParameter.value), ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline] : [...pathParameters, ...nonPathParameters, ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline];
|
|
933
|
+
if (serializationMode) {
|
|
934
|
+
parameters.push(serializationMode);
|
|
935
|
+
}
|
|
936
|
+
if (operation.variant.includes('ViaJsonString') || operation.variant.includes('ViaJsonFilePath')) {
|
|
937
|
+
httpOperationName = `${httpOperationName}ViaJsonString`;
|
|
938
|
+
const jsonParameter = new codegen_csharp_1.Field('_jsonString', codegen_csharp_1.System.String);
|
|
939
|
+
parameters = [...pathParameters, ...nonPathParameters, jsonParameter, ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline];
|
|
940
|
+
}
|
|
941
|
+
if (preProcess) {
|
|
942
|
+
yield preProcess($this, pathParameters, [...otherParams.map(each => (0, codegen_csharp_1.toExpression)(each.value)), codegen_csharp_1.dotnet.This, pipeline], false);
|
|
943
|
+
}
|
|
944
|
+
yield `await this.${$this.$('Client').invokeMethod(httpOperationName, ...parameters).implementation}`;
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
GetPutPreProcess(cmdlet, pathParams, nonPathParams, viaIdentity) {
|
|
948
|
+
var _a, _b;
|
|
949
|
+
const $this = cmdlet;
|
|
950
|
+
const updateBodyMethod = new codegen_csharp_1.Method(`Update${(_a = $this.bodyParameter) === null || _a === void 0 ? void 0 : _a.value}`, codegen_csharp_1.dotnet.Void, {
|
|
951
|
+
access: codegen_csharp_1.Access.Private
|
|
952
|
+
});
|
|
953
|
+
const httpOperationName = `${(_b = $this.operation.callGraph[0].language.csharp) === null || _b === void 0 ? void 0 : _b.name}${viaIdentity ? 'ViaIdentity' : ''}WithResult`;
|
|
954
|
+
if (!$this.hasMethodWithSameDeclaration(updateBodyMethod)) {
|
|
955
|
+
updateBodyMethod.add(function* () {
|
|
956
|
+
const bodyParameters = $this.properties.filter(each => {
|
|
957
|
+
for (const attribute of each.attributes) {
|
|
958
|
+
for (const parameter of attribute.parameters) {
|
|
959
|
+
if ('global::Microsoft.Rest.ParameterCategory.Body' === (0, codegen_csharp_1.valueOf)(parameter)) {
|
|
960
|
+
return true;
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
return false;
|
|
751
965
|
});
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
966
|
+
for (const param of bodyParameters) {
|
|
967
|
+
yield (0, codegen_csharp_1.If)(`(bool)(true == this.MyInvocation?.BoundParameters.ContainsKey("${param.name}"))`, `this.${param.name} = (${param.type.declaration})(this.MyInvocation?.BoundParameters["${param.name}"]);`);
|
|
968
|
+
}
|
|
969
|
+
});
|
|
970
|
+
$this.add(updateBodyMethod);
|
|
971
|
+
}
|
|
972
|
+
const getPut = function* () {
|
|
973
|
+
var _a;
|
|
974
|
+
yield `${(_a = $this.bodyParameter) === null || _a === void 0 ? void 0 : _a.value} = await this.${$this.$('Client').invokeMethod(httpOperationName, ...[...pathParams, ...nonPathParams]).implementation}`;
|
|
975
|
+
yield `this.${updateBodyMethod.name}();`;
|
|
976
|
+
};
|
|
977
|
+
return new codegen_csharp_1.Statements(getPut);
|
|
978
|
+
}
|
|
979
|
+
NewImplementResponseMethod() {
|
|
980
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
981
|
+
const $this = this;
|
|
982
|
+
const apiCall = $this.apiCall;
|
|
983
|
+
const operationParameters = $this.operationParameters;
|
|
984
|
+
const callbackMethods = $this.callbackMethods;
|
|
985
|
+
const pipeline = $this.$('Pipeline');
|
|
986
|
+
// make callback methods
|
|
987
|
+
for (const each of (0, linq_1.values)($this.responses)) {
|
|
988
|
+
const parameters = new Array();
|
|
989
|
+
const isBinary = each.binary;
|
|
990
|
+
parameters.push(new codegen_csharp_1.Parameter('responseMessage', codegen_csharp_1.System.Net.Http.HttpResponseMessage, { description: `the raw response message as an ${codegen_csharp_1.System.Net.Http.HttpResponseMessage}.` }));
|
|
991
|
+
if ((_a = each.language.csharp) === null || _a === void 0 ? void 0 : _a.responseType) {
|
|
992
|
+
parameters.push(new codegen_csharp_1.Parameter('response', codegen_csharp_1.System.Threading.Tasks.Task({ declaration: (_b = each.language.csharp) === null || _b === void 0 ? void 0 : _b.responseType }), {
|
|
993
|
+
description: `the body result as a <see cref="${(_c = each.language.csharp) === null || _c === void 0 ? void 0 : _c.responseType.replace(/\[|\]|\?/g, '')}">${(_d = each.language.csharp) === null || _d === void 0 ? void 0 : _d.responseType}</see> from the remote call`
|
|
994
|
+
}));
|
|
995
|
+
}
|
|
996
|
+
if ((_e = each.language.csharp) === null || _e === void 0 ? void 0 : _e.headerType) {
|
|
997
|
+
parameters.push(new codegen_csharp_1.Parameter('headers', codegen_csharp_1.System.Threading.Tasks.Task({ declaration: each.language.csharp.headerType }), { description: `the header result as a <see cref="${each.language.csharp.headerType}" /> from the remote call` }));
|
|
998
|
+
}
|
|
999
|
+
if (isBinary) {
|
|
1000
|
+
parameters.push(new codegen_csharp_1.Parameter('response', codegen_csharp_1.System.Threading.Tasks.Task({ declaration: 'global::System.IO.Stream' }), { description: 'the body result as a <see cref="global::System.IO.Stream" /> from the remote call' }));
|
|
1001
|
+
}
|
|
1002
|
+
const override = `override${(0, codegen_1.pascalCase)(((_f = each.language.csharp) === null || _f === void 0 ? void 0 : _f.name) || '')}`;
|
|
1003
|
+
const returnNow = new codegen_csharp_1.Parameter('returnNow', codegen_csharp_1.System.Threading.Tasks.Task(codegen_csharp_1.dotnet.Bool), { modifier: codegen_csharp_2.ParameterModifier.Ref, description: `/// Determines if the rest of the ${(_g = each.language.csharp) === null || _g === void 0 ? void 0 : _g.name} method should be processed, or if the method should return immediately (set to true to skip further processing )` });
|
|
1004
|
+
const overrideResponseMethod = new codegen_csharp_1.PartialMethod(override, codegen_csharp_1.dotnet.Void, {
|
|
1005
|
+
parameters: [...parameters, returnNow],
|
|
1006
|
+
description: `<c>${override}</c> will be called before the regular ${(_h = each.language.csharp) === null || _h === void 0 ? void 0 : _h.name} has been processed, allowing customization of what happens on that response. Implement this method in a partial class to enable this behavior`,
|
|
1007
|
+
returnsDescription: `A <see cref="${codegen_csharp_1.System.Threading.Tasks.Task()}" /> that will be complete when handling of the method is completed.`
|
|
1008
|
+
});
|
|
1009
|
+
$this.add(overrideResponseMethod);
|
|
1010
|
+
const responseMethod = new codegen_csharp_1.Method(`${(_j = each.language.csharp) === null || _j === void 0 ? void 0 : _j.name}`, codegen_csharp_1.System.Threading.Tasks.Task(), {
|
|
1011
|
+
access: codegen_csharp_1.Access.Private,
|
|
1012
|
+
parameters,
|
|
1013
|
+
async: codegen_csharp_1.Modifier.Async,
|
|
1014
|
+
description: (_k = each.language.csharp) === null || _k === void 0 ? void 0 : _k.description,
|
|
1015
|
+
returnsDescription: `A <see cref="${codegen_csharp_1.System.Threading.Tasks.Task()}" /> that will be complete when handling of the method is completed.`
|
|
1016
|
+
});
|
|
1017
|
+
responseMethod.push((0, codegen_csharp_1.Using)('NoSynchronizationContext', ''));
|
|
1018
|
+
responseMethod.add(function* () {
|
|
1019
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
1020
|
+
const skip = (0, codegen_csharp_2.Local)('_returnNow', `${codegen_csharp_1.System.Threading.Tasks.Task(codegen_csharp_1.dotnet.Bool).declaration}.FromResult(${codegen_csharp_1.dotnet.False})`);
|
|
1021
|
+
yield skip.declarationStatement;
|
|
1022
|
+
yield `${overrideResponseMethod.invoke(...parameters, `ref ${skip.value}`)};`;
|
|
1023
|
+
yield `// if ${override} has returned true, then return right away.`;
|
|
1024
|
+
yield (0, codegen_csharp_1.If)((0, codegen_csharp_1.And)((0, codegen_csharp_1.IsNotNull)(skip), `await ${skip}`), (0, codegen_csharp_1.Return)());
|
|
1025
|
+
if ((_a = each.language.csharp) === null || _a === void 0 ? void 0 : _a.isErrorResponse) {
|
|
1026
|
+
// this should write an error to the error channel.
|
|
1027
|
+
yield `// Error Response : ${(_b = each.protocol.http) === null || _b === void 0 ? void 0 : _b.statusCodes[0]}`;
|
|
1028
|
+
const unexpected = function* () {
|
|
1029
|
+
var _a;
|
|
1030
|
+
yield '// Unrecognized Response. Create an error record based on what we have.';
|
|
1031
|
+
const ex = ((_a = each.language.csharp) === null || _a === void 0 ? void 0 : _a.responseType) ?
|
|
1032
|
+
(0, codegen_csharp_2.Local)('ex', `new ${exports_1.ClientRuntime.name}.RestException<${each.language.csharp.responseType}>(responseMessage, await response)`) :
|
|
1033
|
+
(0, codegen_csharp_2.Local)('ex', `new ${exports_1.ClientRuntime.name}.RestException(responseMessage)`);
|
|
1034
|
+
yield ex.declarationStatement;
|
|
1035
|
+
yield `WriteError( new global::System.Management.Automation.ErrorRecord(${ex.value}, ${ex.value}.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { ${operationParameters.filter(e => (0, codegen_csharp_1.valueOf)(e.expression) !== 'null').map(each => `${each.name}=${each.expression}`).join(', ')} })
|
|
771
1036
|
{
|
|
772
1037
|
ErrorDetails = new global::System.Management.Automation.ErrorDetails(${ex.value}.Message) { RecommendedAction = ${ex.value}.Action }
|
|
773
1038
|
});`;
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
1039
|
+
};
|
|
1040
|
+
if (each.schema !== undefined) {
|
|
1041
|
+
// the schema should be the error information.
|
|
1042
|
+
// this supports both { error { message, code} } and { message, code}
|
|
1043
|
+
let props = (0, schema_1.getAllPublicVirtualProperties)((_c = each.schema.language.csharp) === null || _c === void 0 ? void 0 : _c.virtualProperties);
|
|
1044
|
+
const errorProperty = (0, linq_1.values)(props).first(p => p.property.serializedName === 'error');
|
|
1045
|
+
let ep = '';
|
|
1046
|
+
if (errorProperty) {
|
|
1047
|
+
props = (0, schema_1.getAllPublicVirtualProperties)((_d = errorProperty.property.schema.language.csharp) === null || _d === void 0 ? void 0 : _d.virtualProperties);
|
|
1048
|
+
ep = `${errorProperty.name}?.`;
|
|
1049
|
+
}
|
|
1050
|
+
const codeProp = props.find(p => p.name.toLowerCase().indexOf('code') > -1); // first property with 'code'
|
|
1051
|
+
const messageProp = props.find(p => p.name.toLowerCase().indexOf('message') > -1); // first property with 'message'
|
|
1052
|
+
const actionProp = props.find(p => p.name.toLowerCase().indexOf('action') > -1); // first property with 'action'
|
|
1053
|
+
if (codeProp && messageProp) {
|
|
1054
|
+
const lcode = new codegen_csharp_1.LocalVariable('code', codegen_csharp_1.dotnet.Var, { initializer: `(await response)?.${ep}${codeProp.name}` });
|
|
1055
|
+
const lmessage = new codegen_csharp_1.LocalVariable('message', codegen_csharp_1.dotnet.Var, { initializer: `(await response)?.${ep}${messageProp.name}` });
|
|
1056
|
+
const laction = actionProp ? new codegen_csharp_1.LocalVariable('action', codegen_csharp_1.dotnet.Var, { initializer: `(await response)?.${ep}${actionProp.name} ?? ${codegen_csharp_1.System.String.Empty}` }) : undefined;
|
|
1057
|
+
yield lcode;
|
|
1058
|
+
yield lmessage;
|
|
1059
|
+
yield laction;
|
|
1060
|
+
yield (0, codegen_csharp_1.If)((0, codegen_csharp_1.Or)((0, codegen_csharp_1.IsNull)(lcode), ((0, codegen_csharp_1.IsNull)(lmessage))), unexpected);
|
|
1061
|
+
yield (0, codegen_csharp_1.Else)(`WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{${lcode}}] : {${lmessage}}"), ${lcode}?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { ${operationParameters.filter(e => (0, codegen_csharp_1.valueOf)(e.expression) !== 'null').map(each => `${each.name}=${each.expression}`).join(', ')} })
|
|
797
1062
|
{
|
|
798
1063
|
ErrorDetails = new global::System.Management.Automation.ErrorDetails(${lmessage}) { RecommendedAction = ${laction || codegen_csharp_1.System.String.Empty} }
|
|
799
1064
|
});`);
|
|
800
|
-
|
|
801
|
-
}
|
|
802
|
-
else {
|
|
803
|
-
yield unexpected;
|
|
804
|
-
return;
|
|
805
|
-
}
|
|
1065
|
+
return;
|
|
806
1066
|
}
|
|
807
1067
|
else {
|
|
808
1068
|
yield unexpected;
|
|
809
1069
|
return;
|
|
810
1070
|
}
|
|
811
1071
|
}
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
}
|
|
848
|
-
else {
|
|
849
|
-
yield $this.WriteObjectWithViewControl(`${result.value}.${vp.name}`, true);
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
const nl = schema_1.getVirtualPropertyFromPropertyName((_o = schema.language.csharp) === null || _o === void 0 ? void 0 : _o.virtualProperties, nextLinkProperty.serializedName);
|
|
853
|
-
if (nl) {
|
|
854
|
-
$this.add(new codegen_csharp_1.Field('_isFirst', codegen_csharp_1.dotnet.Bool, {
|
|
855
|
-
access: codegen_csharp_1.Access.Private,
|
|
856
|
-
initialValue: new codegen_csharp_1.LiteralExpression('true'),
|
|
857
|
-
description: 'A flag to tell whether it is the first onOK call.'
|
|
858
|
-
}));
|
|
859
|
-
$this.add(new codegen_csharp_1.Field('_nextLink', codegen_csharp_1.dotnet.String, {
|
|
860
|
-
access: codegen_csharp_1.Access.Private,
|
|
861
|
-
description: 'Link to retrieve next page.'
|
|
862
|
-
}));
|
|
863
|
-
const nextLinkName = `${result.value}.${nl.name}`;
|
|
864
|
-
yield `_nextLink = ${nextLinkName};`;
|
|
865
|
-
const nextLinkCondition = $this.clientsidePagination ? '_nextLink != null && this.PagingParameters.First > 0' : '_nextLink != null';
|
|
866
|
-
yield (codegen_csharp_1.If('_isFirst', function* () {
|
|
867
|
-
yield '_isFirst = false;';
|
|
868
|
-
yield (codegen_csharp_1.While(nextLinkCondition, codegen_csharp_1.If('responseMessage.RequestMessage is System.Net.Http.HttpRequestMessage requestMessage ', function* () {
|
|
869
|
-
var _a;
|
|
870
|
-
yield `requestMessage = requestMessage.Clone(new global::System.Uri( _nextLink ),${exports_1.ClientRuntime.Method.Get} );`;
|
|
871
|
-
yield $this.eventListener.signal(powershell_declarations_1.Events.FollowingNextLink);
|
|
872
|
-
yield `await this.${$this.$('Client').invokeMethod(`${(_a = apiCall.language.csharp) === null || _a === void 0 ? void 0 : _a.name}_Call`, ...[codegen_csharp_1.toExpression('requestMessage'), ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline]).implementation}`;
|
|
873
|
-
})));
|
|
1072
|
+
else {
|
|
1073
|
+
yield unexpected;
|
|
1074
|
+
return;
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
yield `// ${(_e = each.language.csharp) === null || _e === void 0 ? void 0 : _e.name} - response for ${(_f = each.protocol.http) === null || _f === void 0 ? void 0 : _f.statusCodes[0]} / ${(0, linq_1.values)((_g = each.protocol.http) === null || _g === void 0 ? void 0 : _g.mediaTypes).join('/')}`;
|
|
1078
|
+
if ('schema' in each) {
|
|
1079
|
+
const schema = each.schema;
|
|
1080
|
+
const props = (0, schema_1.getAllPublicVirtualProperties)((_h = schema.language.csharp) === null || _h === void 0 ? void 0 : _h.virtualProperties);
|
|
1081
|
+
const rType = $this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(schema, true, $this.state);
|
|
1082
|
+
const result = new codegen_csharp_1.LocalVariable('result', codegen_csharp_1.dotnet.Var, { initializer: new codegen_csharp_1.LiteralExpression('(await response)') });
|
|
1083
|
+
yield `// (await response) // should be ${rType.declaration}`;
|
|
1084
|
+
yield result.declarationStatement;
|
|
1085
|
+
if ((_j = apiCall.language.csharp) === null || _j === void 0 ? void 0 : _j.pageable) {
|
|
1086
|
+
const pageable = apiCall.language.csharp.pageable;
|
|
1087
|
+
if ($this.clientsidePagination) {
|
|
1088
|
+
yield '// clientside pagination enabled';
|
|
1089
|
+
}
|
|
1090
|
+
yield '// response should be returning an array of some kind. +Pageable';
|
|
1091
|
+
yield `// ${pageable.responseType} / ${pageable.itemName || '<none>'} / ${pageable.nextLinkName || '<none>'}`;
|
|
1092
|
+
switch (pageable.responseType) {
|
|
1093
|
+
// the result is (or works like a x-ms-pageable)
|
|
1094
|
+
case 'pageable':
|
|
1095
|
+
case 'nested-array':
|
|
1096
|
+
{
|
|
1097
|
+
const valueProperty = (_k = schema.properties) === null || _k === void 0 ? void 0 : _k.find(p => p.serializedName === pageable.itemName);
|
|
1098
|
+
const nextLinkProperty = (_l = schema === null || schema === void 0 ? void 0 : schema.properties) === null || _l === void 0 ? void 0 : _l.find(p => p.serializedName === pageable.nextLinkName);
|
|
1099
|
+
if (valueProperty && nextLinkProperty) {
|
|
1100
|
+
// it's pageable!
|
|
1101
|
+
// write out the current contents
|
|
1102
|
+
const vp = (0, schema_1.getVirtualPropertyFromPropertyName)((_m = schema.language.csharp) === null || _m === void 0 ? void 0 : _m.virtualProperties, valueProperty.serializedName);
|
|
1103
|
+
if (vp) {
|
|
1104
|
+
if ($this.clientsidePagination) {
|
|
1105
|
+
yield ((0, codegen_csharp_1.If)('(ulong)result.Value.Count <= this.PagingParameters.Skip', function* () {
|
|
1106
|
+
yield ('this.PagingParameters.Skip = this.PagingParameters.Skip - (ulong)result.Value.Count;');
|
|
874
1107
|
}));
|
|
1108
|
+
yield (0, codegen_csharp_1.Else)(function* () {
|
|
1109
|
+
yield ('ulong toRead = Math.Min(this.PagingParameters.First, (ulong)result.Value.Count - this.PagingParameters.Skip);');
|
|
1110
|
+
yield ('var requiredResult = result.Value.GetRange((int)this.PagingParameters.Skip, (int)toRead);');
|
|
1111
|
+
yield $this.WriteObjectWithViewControl('requiredResult', true);
|
|
1112
|
+
yield ('this.PagingParameters.Skip = 0;');
|
|
1113
|
+
yield ('this.PagingParameters.First = this.PagingParameters.First <= toRead ? 0 : this.PagingParameters.First - toRead;');
|
|
1114
|
+
});
|
|
875
1115
|
}
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
else if (valueProperty) {
|
|
879
|
-
// it's just a nested array
|
|
880
|
-
const p = codemodel_v3_1.getVirtualPropertyFromPropertyName((_p = schema.language.csharp) === null || _p === void 0 ? void 0 : _p.virtualProperties, valueProperty.serializedName);
|
|
881
|
-
if (p) {
|
|
882
|
-
yield $this.WriteObjectWithViewControl(`(await response).${p.name}`, true);
|
|
1116
|
+
else {
|
|
1117
|
+
yield $this.WriteObjectWithViewControl(`${result.value}.${vp.name}`, true);
|
|
883
1118
|
}
|
|
884
|
-
return;
|
|
885
1119
|
}
|
|
1120
|
+
const nl = (0, schema_1.getVirtualPropertyFromPropertyName)((_o = schema.language.csharp) === null || _o === void 0 ? void 0 : _o.virtualProperties, nextLinkProperty.serializedName);
|
|
1121
|
+
if (nl) {
|
|
1122
|
+
$this.add(new codegen_csharp_1.Field('_isFirst', codegen_csharp_1.dotnet.Bool, {
|
|
1123
|
+
access: codegen_csharp_1.Access.Private,
|
|
1124
|
+
initialValue: new codegen_csharp_1.LiteralExpression('true'),
|
|
1125
|
+
description: 'A flag to tell whether it is the first onOK call.'
|
|
1126
|
+
}));
|
|
1127
|
+
$this.add(new codegen_csharp_1.Field('_nextLink', codegen_csharp_1.dotnet.String, {
|
|
1128
|
+
access: codegen_csharp_1.Access.Private,
|
|
1129
|
+
description: 'Link to retrieve next page.'
|
|
1130
|
+
}));
|
|
1131
|
+
const nextLinkName = `${result.value}.${nl.name}`;
|
|
1132
|
+
yield `_nextLink = ${nextLinkName};`;
|
|
1133
|
+
const nextLinkCondition = $this.clientsidePagination ? '!String.IsNullOrEmpty(_nextLink) && this.PagingParameters.First > 0' : '!String.IsNullOrEmpty(_nextLink)';
|
|
1134
|
+
yield ((0, codegen_csharp_1.If)('_isFirst', function* () {
|
|
1135
|
+
yield '_isFirst = false;';
|
|
1136
|
+
yield ((0, codegen_csharp_1.While)(nextLinkCondition, (0, codegen_csharp_1.If)('responseMessage.RequestMessage is System.Net.Http.HttpRequestMessage requestMessage ', function* () {
|
|
1137
|
+
var _a;
|
|
1138
|
+
yield `requestMessage = requestMessage.Clone(new global::System.Uri( _nextLink ),${exports_1.ClientRuntime.Method.Get} );`;
|
|
1139
|
+
yield $this.eventListener.signal(powershell_declarations_1.Events.FollowingNextLink);
|
|
1140
|
+
yield `await this.${$this.$('Client').invokeMethod(`${(_a = apiCall.language.csharp) === null || _a === void 0 ? void 0 : _a.name}_Call`, ...[(0, codegen_csharp_1.toExpression)('requestMessage'), ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline]).implementation}`;
|
|
1141
|
+
})));
|
|
1142
|
+
}));
|
|
1143
|
+
}
|
|
1144
|
+
return;
|
|
886
1145
|
}
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
const outfile = $this.outFileParameter;
|
|
903
|
-
const provider = codegen_csharp_2.Local('provider');
|
|
904
|
-
provider.initializer = undefined;
|
|
905
|
-
const paths = codegen_csharp_2.Local('paths', `this.SessionState.Path.GetResolvedProviderPathFromPSPath(${outfile.value}, out ${provider.declarationExpression})`);
|
|
906
|
-
yield paths.declarationStatement;
|
|
907
|
-
yield codegen_csharp_1.If(`${provider.value}.Name != "FileSystem" || ${paths.value}.Count == 0`, `ThrowTerminatingError( new System.Management.Automation.ErrorRecord(new global::System.Exception("Invalid output path."),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, ${outfile.value}) );`);
|
|
908
|
-
yield codegen_csharp_1.If(`${paths.value}.Count > 1`, `ThrowTerminatingError( new System.Management.Automation.ErrorRecord(new global::System.Exception("Multiple output paths not allowed."),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, ${outfile.value}) );`);
|
|
909
|
-
if (rType.declaration === codegen_csharp_1.System.IO.Stream.declaration) {
|
|
910
|
-
// this is a stream output. write to outfile
|
|
911
|
-
const stream = codegen_csharp_2.Local('stream', 'await response');
|
|
912
|
-
yield codegen_csharp_1.Using(stream.declarationExpression, function* () {
|
|
913
|
-
const fileStream = codegen_csharp_2.Local('fileStream', `global::System.IO.File.OpenWrite(${paths.value}[0])`);
|
|
914
|
-
yield codegen_csharp_1.Using(fileStream.declarationExpression, `await ${stream.value}.CopyToAsync(${fileStream.value});`);
|
|
915
|
-
});
|
|
916
|
-
}
|
|
917
|
-
else {
|
|
918
|
-
// assuming byte array output (via outValue)
|
|
919
|
-
yield `global::System.IO.File.WriteAllBytes(${paths.value}[0],${outValue});`;
|
|
920
|
-
}
|
|
921
|
-
yield codegen_csharp_1.If('true == MyInvocation?.BoundParameters?.ContainsKey("PassThru")', function* () {
|
|
922
|
-
// no return type. Let's just return ... true?
|
|
923
|
-
yield 'WriteObject(true);';
|
|
924
|
-
});
|
|
925
|
-
return;
|
|
1146
|
+
else if (valueProperty) {
|
|
1147
|
+
// it's just a nested array
|
|
1148
|
+
const p = (0, codemodel_v3_1.getVirtualPropertyFromPropertyName)((_p = schema.language.csharp) === null || _p === void 0 ? void 0 : _p.virtualProperties, valueProperty.serializedName);
|
|
1149
|
+
if (p) {
|
|
1150
|
+
yield $this.WriteObjectWithViewControl(`${result.value}.${p.name}`, true);
|
|
1151
|
+
}
|
|
1152
|
+
return;
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
break;
|
|
1156
|
+
// it's just an array,
|
|
1157
|
+
case 'array':
|
|
1158
|
+
// just write-object(enumerate) with the output
|
|
1159
|
+
yield $this.WriteObjectWithViewControl(result.value, true);
|
|
1160
|
+
return;
|
|
926
1161
|
}
|
|
927
|
-
//
|
|
928
|
-
yield $this.WriteObjectWithViewControl(`${outValue}`);
|
|
929
|
-
return;
|
|
1162
|
+
// ok, let's see if the response type
|
|
930
1163
|
}
|
|
931
|
-
//
|
|
932
|
-
if (
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
yield `${paths.value} = this.SessionState.Path.GetResolvedProviderPathFromPSPath(${outfile.value}, out ${provider.declarationExpression});`;
|
|
942
|
-
yield codegen_csharp_1.If(`${provider.value}.Name != "FileSystem" || ${paths.value}.Count == 0`, `ThrowTerminatingError(new System.Management.Automation.ErrorRecord(new global::System.Exception("Invalid output path."), string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, ${outfile.value}));`);
|
|
943
|
-
yield codegen_csharp_1.If(`${paths.value}.Count > 1`, `ThrowTerminatingError(new System.Management.Automation.ErrorRecord(new global::System.Exception("Multiple output paths not allowed."), string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, ${outfile.value}));`);
|
|
944
|
-
});
|
|
945
|
-
const notfound = new codegen_csharp_1.Parameter('', { declaration: 'global::System.Management.Automation.ItemNotFoundException' });
|
|
946
|
-
yield codegen_csharp_1.Catch(notfound, function* () {
|
|
947
|
-
yield '// If the file does not exist, we will try to create it';
|
|
948
|
-
yield `${paths.value}.Add(${outfile.value});`;
|
|
949
|
-
});
|
|
1164
|
+
// we expect to get back some data from this call.
|
|
1165
|
+
if ($this.hasStreamOutput && $this.outFileParameter) {
|
|
1166
|
+
const outfile = $this.outFileParameter;
|
|
1167
|
+
const provider = (0, codegen_csharp_2.Local)('provider');
|
|
1168
|
+
provider.initializer = undefined;
|
|
1169
|
+
const paths = (0, codegen_csharp_2.Local)('paths', `this.SessionState.Path.GetResolvedProviderPathFromPSPath(${outfile.value}, out ${provider.declarationExpression})`);
|
|
1170
|
+
yield paths.declarationStatement;
|
|
1171
|
+
yield (0, codegen_csharp_1.If)(`${provider.value}.Name != "FileSystem" || ${paths.value}.Count == 0`, `ThrowTerminatingError( new System.Management.Automation.ErrorRecord(new global::System.Exception("Invalid output path."),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, ${outfile.value}) );`);
|
|
1172
|
+
yield (0, codegen_csharp_1.If)(`${paths.value}.Count > 1`, `ThrowTerminatingError( new System.Management.Automation.ErrorRecord(new global::System.Exception("Multiple output paths not allowed."),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, ${outfile.value}) );`);
|
|
1173
|
+
if (rType.declaration === codegen_csharp_1.System.IO.Stream.declaration) {
|
|
950
1174
|
// this is a stream output. write to outfile
|
|
951
|
-
const stream = codegen_csharp_2.Local('stream',
|
|
952
|
-
yield codegen_csharp_1.Using(stream.declarationExpression, function* () {
|
|
953
|
-
const fileStream = codegen_csharp_2.Local('fileStream', `global::System.IO.File.OpenWrite(${paths.value}[0])`);
|
|
954
|
-
yield codegen_csharp_1.Using(fileStream.declarationExpression, `await ${stream.value}.CopyToAsync(${fileStream.value});`);
|
|
955
|
-
});
|
|
956
|
-
yield codegen_csharp_1.If('true == MyInvocation?.BoundParameters?.ContainsKey("PassThru")', function* () {
|
|
957
|
-
// no return type. Let's just return ... true?
|
|
958
|
-
yield 'WriteObject(true);';
|
|
1175
|
+
const stream = (0, codegen_csharp_2.Local)('stream', result.value);
|
|
1176
|
+
yield (0, codegen_csharp_1.Using)(stream.declarationExpression, function* () {
|
|
1177
|
+
const fileStream = (0, codegen_csharp_2.Local)('fileStream', `global::System.IO.File.OpenWrite(${paths.value}[0])`);
|
|
1178
|
+
yield (0, codegen_csharp_1.Using)(fileStream.declarationExpression, `await ${stream.value}.CopyToAsync(${fileStream.value});`);
|
|
959
1179
|
});
|
|
960
|
-
return;
|
|
961
|
-
}
|
|
962
|
-
}
|
|
963
|
-
yield codegen_csharp_1.If('true == MyInvocation?.BoundParameters?.ContainsKey("PassThru")', function* () {
|
|
964
|
-
// no return type. Let's just return ... true?
|
|
965
|
-
yield 'WriteObject(true);';
|
|
966
|
-
});
|
|
967
|
-
});
|
|
968
|
-
$this.add(responseMethod);
|
|
969
|
-
}
|
|
970
|
-
yield codegen_csharp_1.Try(function* () {
|
|
971
|
-
// make the call.
|
|
972
|
-
const actualCall = function* () {
|
|
973
|
-
var _a, _b;
|
|
974
|
-
yield $this.eventListener.signal(powershell_declarations_1.Events.CmdletBeforeAPICall);
|
|
975
|
-
const idOpParams = operationParameters.filter(each => !each.isPathParam);
|
|
976
|
-
const idschema = linq_1.values($this.state.project.model.schemas.objects).first(each => each.language.default.uid === 'universal-parameter-type');
|
|
977
|
-
let serializationMode = null;
|
|
978
|
-
if ($this.bodyParameter) {
|
|
979
|
-
if ($this.operation.operationType === command_operation_1.OperationType.Create) {
|
|
980
|
-
serializationMode = exports_1.ClientRuntime.SerializationMode.IncludeCreate;
|
|
981
|
-
}
|
|
982
|
-
else if ($this.operation.operationType === command_operation_1.OperationType.Update) {
|
|
983
|
-
serializationMode = exports_1.ClientRuntime.SerializationMode.IncludeUpdate;
|
|
984
|
-
}
|
|
985
|
-
}
|
|
986
|
-
if ($this.isViaIdentity) {
|
|
987
|
-
const identityFromPathParams = function* () {
|
|
988
|
-
var _a, _b;
|
|
989
|
-
yield '// try to call with PATH parameters from Input Object';
|
|
990
|
-
if (idschema) {
|
|
991
|
-
const allVPs = schema_1.getAllPublicVirtualProperties((_a = idschema.language.csharp) === null || _a === void 0 ? void 0 : _a.virtualProperties);
|
|
992
|
-
const props = [...linq_1.values(idschema.properties)];
|
|
993
|
-
const idOpParams = operationParameters.map(each => {
|
|
994
|
-
var _a, _b, _c, _d, _e, _f;
|
|
995
|
-
const pascalName = codegen_1.pascalCase(`${each.name}`);
|
|
996
|
-
if (!each.isPathParam) {
|
|
997
|
-
return {
|
|
998
|
-
name: undefined,
|
|
999
|
-
value: codegen_csharp_1.valueOf(each.expression)
|
|
1000
|
-
};
|
|
1001
|
-
}
|
|
1002
|
-
const match = props.find(p => codegen_1.pascalCase(p.serializedName) === pascalName);
|
|
1003
|
-
if (match) {
|
|
1004
|
-
const defaultOfType = $this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(match.schema, true, $this.state).defaultOfType;
|
|
1005
|
-
// match up vp name
|
|
1006
|
-
const vp = allVPs.find(pp => codegen_1.pascalCase(pp.property.serializedName) === pascalName);
|
|
1007
|
-
if (vp) {
|
|
1008
|
-
return {
|
|
1009
|
-
name: `InputObject.${vp.name}`,
|
|
1010
|
-
value: `InputObject.${vp.name} ?? ${defaultOfType}`
|
|
1011
|
-
};
|
|
1012
|
-
}
|
|
1013
|
-
// fall back!
|
|
1014
|
-
console.error(`Unable to match identity parameter '${each.name}' member to appropriate virtual parameter. (Guessing '${codegen_1.pascalCase((_b = (_a = match.language.csharp) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '')}').`);
|
|
1015
|
-
return {
|
|
1016
|
-
name: `InputObject.${codegen_1.pascalCase((_d = (_c = match.language.csharp) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : '')}`,
|
|
1017
|
-
value: `InputObject.${codegen_1.pascalCase((_f = (_e = match.language.csharp) === null || _e === void 0 ? void 0 : _e.name) !== null && _f !== void 0 ? _f : '')} ?? ${defaultOfType}`
|
|
1018
|
-
};
|
|
1019
|
-
}
|
|
1020
|
-
console.error(`Unable to match identity parameter '${each.name}' member to appropriate virtual parameter. (Guessing '${pascalName}')`);
|
|
1021
|
-
return {
|
|
1022
|
-
name: `InputObject.${pascalName}`,
|
|
1023
|
-
value: `InputObject.${pascalName}`
|
|
1024
|
-
};
|
|
1025
|
-
});
|
|
1026
|
-
for (const opParam of idOpParams) {
|
|
1027
|
-
if (opParam.name) {
|
|
1028
|
-
yield codegen_csharp_1.If(codegen_csharp_1.IsNull(opParam.name), `ThrowTerminatingError(new ${powershell_declarations_1.ErrorRecord}(new global::System.Exception("InputObject has null value for ${opParam.name}"),string.Empty, ${powershell_declarations_1.ErrorCategory('InvalidArgument')}, InputObject));`);
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
yield `await this.${$this.$('Client').invokeMethod(`${(_b = apiCall.language.csharp) === null || _b === void 0 ? void 0 : _b.name}`, ...[...idOpParams.map(each => codegen_csharp_1.toExpression(each.value)), ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline]).implementation}`;
|
|
1032
|
-
}
|
|
1033
|
-
};
|
|
1034
|
-
if (idschema && linq_1.values(idschema.properties).first(each => { var _a; return ((_a = each.language.csharp) === null || _a === void 0 ? void 0 : _a.uid) === 'universal-parameter:resource identity'; })) {
|
|
1035
|
-
const parameters = [codegen_csharp_1.toExpression('InputObject.Id'), ...idOpParams.map(each => each.expression), ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline];
|
|
1036
|
-
if (serializationMode) {
|
|
1037
|
-
parameters.push(serializationMode);
|
|
1038
|
-
}
|
|
1039
|
-
yield codegen_csharp_1.If('InputObject?.Id != null', `await this.${$this.$('Client').invokeMethod(`${(_a = apiCall.language.csharp) === null || _a === void 0 ? void 0 : _a.name}ViaIdentity`, ...parameters).implementation}`);
|
|
1040
|
-
yield codegen_csharp_1.Else(identityFromPathParams);
|
|
1041
1180
|
}
|
|
1042
1181
|
else {
|
|
1043
|
-
|
|
1182
|
+
// assuming byte array output (via result)
|
|
1183
|
+
yield `global::System.IO.File.WriteAllBytes(${paths.value}[0],${result.value});`;
|
|
1044
1184
|
}
|
|
1185
|
+
yield (0, codegen_csharp_1.If)('true == MyInvocation?.BoundParameters?.ContainsKey("PassThru")', function* () {
|
|
1186
|
+
// no return type. Let's just return ... true?
|
|
1187
|
+
yield 'WriteObject(true);';
|
|
1188
|
+
});
|
|
1189
|
+
return;
|
|
1045
1190
|
}
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
parameters.push(serializationMode);
|
|
1050
|
-
}
|
|
1051
|
-
yield `await this.${$this.$('Client').invokeMethod(`${(_b = apiCall.language.csharp) === null || _b === void 0 ? void 0 : _b.name}`, ...parameters).implementation}`;
|
|
1052
|
-
}
|
|
1053
|
-
yield $this.eventListener.signal(powershell_declarations_1.Events.CmdletAfterAPICall);
|
|
1054
|
-
};
|
|
1055
|
-
if ($this.state.project.azure && operationParameters.find(each => each.expression && each.expression.value === 'SubscriptionId') && $this.operation.details.csharp.verb.toLowerCase() === 'get') {
|
|
1056
|
-
yield 'foreach( var SubscriptionId in this.SubscriptionId )';
|
|
1057
|
-
yield codegen_csharp_1.BlockStatement(actualCall);
|
|
1191
|
+
// let's just return the result object (or unwrapped result object)
|
|
1192
|
+
yield $this.WriteObjectWithViewControl(result.value);
|
|
1193
|
+
return;
|
|
1058
1194
|
}
|
|
1059
|
-
|
|
1060
|
-
|
|
1195
|
+
// in m4, there will be no schema deinfed for the binary response, instead, we will have a field called binary with value true.
|
|
1196
|
+
if ('binary' in each) {
|
|
1197
|
+
yield '// (await response) // should be global::System.IO.Stream';
|
|
1198
|
+
if ($this.hasStreamOutput && $this.outFileParameter) {
|
|
1199
|
+
const outfile = $this.outFileParameter;
|
|
1200
|
+
const provider = (0, codegen_csharp_2.Local)('provider');
|
|
1201
|
+
provider.initializer = undefined;
|
|
1202
|
+
const paths = (0, codegen_csharp_2.Local)('paths', 'new global::System.Collections.ObjectModel.Collection<global::System.String>()');
|
|
1203
|
+
yield paths.declarationStatement;
|
|
1204
|
+
yield (0, codegen_csharp_1.Try)(function* () {
|
|
1205
|
+
yield `${paths.value} = this.SessionState.Path.GetResolvedProviderPathFromPSPath(${outfile.value}, out ${provider.declarationExpression});`;
|
|
1206
|
+
yield (0, codegen_csharp_1.If)(`${provider.value}.Name != "FileSystem" || ${paths.value}.Count == 0`, `ThrowTerminatingError(new System.Management.Automation.ErrorRecord(new global::System.Exception("Invalid output path."), string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, ${outfile.value}));`);
|
|
1207
|
+
yield (0, codegen_csharp_1.If)(`${paths.value}.Count > 1`, `ThrowTerminatingError(new System.Management.Automation.ErrorRecord(new global::System.Exception("Multiple output paths not allowed."), string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, ${outfile.value}));`);
|
|
1208
|
+
});
|
|
1209
|
+
const notfound = new codegen_csharp_1.Parameter('', { declaration: 'global::System.Management.Automation.ItemNotFoundException' });
|
|
1210
|
+
yield (0, codegen_csharp_1.Catch)(notfound, function* () {
|
|
1211
|
+
yield '// If the file does not exist, we will try to create it';
|
|
1212
|
+
yield `${paths.value}.Add(${outfile.value});`;
|
|
1213
|
+
});
|
|
1214
|
+
// this is a stream output. write to outfile
|
|
1215
|
+
const stream = (0, codegen_csharp_2.Local)('stream', 'await response');
|
|
1216
|
+
yield (0, codegen_csharp_1.Using)(stream.declarationExpression, function* () {
|
|
1217
|
+
const fileStream = (0, codegen_csharp_2.Local)('fileStream', `global::System.IO.File.OpenWrite(${paths.value}[0])`);
|
|
1218
|
+
yield (0, codegen_csharp_1.Using)(fileStream.declarationExpression, `await ${stream.value}.CopyToAsync(${fileStream.value});`);
|
|
1219
|
+
});
|
|
1220
|
+
yield (0, codegen_csharp_1.If)('true == MyInvocation?.BoundParameters?.ContainsKey("PassThru")', function* () {
|
|
1221
|
+
// no return type. Let's just return ... true?
|
|
1222
|
+
yield 'WriteObject(true);';
|
|
1223
|
+
});
|
|
1224
|
+
return;
|
|
1225
|
+
}
|
|
1061
1226
|
}
|
|
1227
|
+
yield (0, codegen_csharp_1.If)('true == MyInvocation?.BoundParameters?.ContainsKey("PassThru")', function* () {
|
|
1228
|
+
// no return type. Let's just return ... true?
|
|
1229
|
+
yield 'WriteObject(true);';
|
|
1230
|
+
});
|
|
1062
1231
|
});
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
yield `WriteError(new global::System.Management.Automation.ErrorRecord(${ure.value}, ${ure.value}.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { ${operationParameters.filter(e => codegen_csharp_1.valueOf(e.expression) !== 'null').map(each => `${each.name}=${each.expression}`).join(',')}})
|
|
1066
|
-
{
|
|
1067
|
-
ErrorDetails = new global::System.Management.Automation.ErrorDetails(${ure.value}.Message) { RecommendedAction = ${ure.value}.Action }
|
|
1068
|
-
});`;
|
|
1069
|
-
});
|
|
1070
|
-
yield codegen_csharp_1.Finally(function* () {
|
|
1071
|
-
yield $this.eventListener.signalNoCheck(powershell_declarations_1.Events.CmdletProcessRecordAsyncEnd);
|
|
1072
|
-
});
|
|
1073
|
-
});
|
|
1232
|
+
$this.add(responseMethod);
|
|
1233
|
+
}
|
|
1074
1234
|
}
|
|
1075
1235
|
NewImplementSerialization(operation) {
|
|
1076
1236
|
const $this = this;
|
|
@@ -1100,7 +1260,7 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1100
1260
|
//_parametersBody = this._parametersBody,
|
|
1101
1261
|
//_resourceGroupName = this._resourceGroupName,
|
|
1102
1262
|
//_subscriptionId = this._subscriptionId,
|
|
1103
|
-
yield codegen_csharp_1.Return(i);
|
|
1263
|
+
yield (0, codegen_csharp_1.Return)(i);
|
|
1104
1264
|
});
|
|
1105
1265
|
}
|
|
1106
1266
|
}
|
|
@@ -1115,7 +1275,7 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1115
1275
|
description: 'A dictionary to carry over additional data for pipeline.'
|
|
1116
1276
|
}));
|
|
1117
1277
|
const extensibleParametersProp = new codegen_csharp_1.Property('ExtensibleParameters', codegen_csharp_1.System.Collections.Generic.IDictionary(codegen_csharp_1.System.String, codegen_csharp_1.System.Object), { description: 'Accessor for extensibleParameters.' });
|
|
1118
|
-
extensibleParametersProp.get = codegen_csharp_1.toExpression(`${extensibleParameters.value} `);
|
|
1278
|
+
extensibleParametersProp.get = (0, codegen_csharp_1.toExpression)(`${extensibleParameters.value} `);
|
|
1119
1279
|
this.add(extensibleParametersProp);
|
|
1120
1280
|
}
|
|
1121
1281
|
implementIEventListener() {
|
|
@@ -1126,11 +1286,11 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1126
1286
|
description: `The <see cref="${codegen_csharp_1.System.Threading.CancellationTokenSource}" /> for this operation.`
|
|
1127
1287
|
}));
|
|
1128
1288
|
const cancellationTokenSource = new codegen_csharp_1.Property('CancellationTokenSource', codegen_csharp_1.System.Threading.CancellationTokenSource, { description: 'Accessor for cancellationTokenSource.' });
|
|
1129
|
-
cancellationTokenSource.get = codegen_csharp_1.toExpression(`${cts.value} `);
|
|
1289
|
+
cancellationTokenSource.get = (0, codegen_csharp_1.toExpression)(`${cts.value} `);
|
|
1130
1290
|
cancellationTokenSource.set = new codegen_csharp_1.Statements(cts.assign('value'));
|
|
1131
1291
|
this.add(cancellationTokenSource);
|
|
1132
1292
|
this.add(new codegen_csharp_1.LambdaProperty(`${exports_1.ClientRuntime.IEventListener}.Token`, codegen_csharp_1.System.Threading.CancellationToken, new codegen_csharp_1.LiteralExpression(`${cts.value}.Token`), { getAccess: codegen_csharp_1.Access.Default, setAccess: codegen_csharp_1.Access.Default, description: `<see cref="${exports_1.ClientRuntime}.IEventListener" /> cancellation token.` }));
|
|
1133
|
-
this.cancellationToken = codegen_csharp_1.toExpression(`((${exports_1.ClientRuntime.IEventListener})this).Token`);
|
|
1293
|
+
this.cancellationToken = (0, codegen_csharp_1.toExpression)(`((${exports_1.ClientRuntime.IEventListener})this).Token`);
|
|
1134
1294
|
this.add(new codegen_csharp_1.LambdaProperty(`${exports_1.ClientRuntime.IEventListener}.Cancel`, codegen_csharp_1.System.Action(), new codegen_csharp_1.LiteralExpression(`${cts.value}.Cancel`), { getAccess: codegen_csharp_1.Access.Default, setAccess: codegen_csharp_1.Access.Default, description: `<see cref="${exports_1.ClientRuntime}.IEventListener" /> cancellation delegate. Stops the cmdlet when called.` }));
|
|
1135
1295
|
const id = new codegen_csharp_1.Parameter('id', codegen_csharp_1.dotnet.String, { description: 'The message id' });
|
|
1136
1296
|
const token = new codegen_csharp_1.Parameter('token', codegen_csharp_1.System.Threading.CancellationToken, { description: 'The message cancellation token. When this call is cancelled, this should be <c>true</c>' });
|
|
@@ -1142,20 +1302,20 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1142
1302
|
description: 'Handles/Dispatches events during the call to the REST service.',
|
|
1143
1303
|
returnsDescription: `A <see cref="${codegen_csharp_1.System.Threading.Tasks.Task()}" /> that will be complete when handling of the message is completed.`
|
|
1144
1304
|
}));
|
|
1145
|
-
signalMethod.push(codegen_csharp_1.Using('NoSynchronizationContext', ''));
|
|
1305
|
+
signalMethod.push((0, codegen_csharp_1.Using)('NoSynchronizationContext', ''));
|
|
1146
1306
|
signalMethod.add(function* () {
|
|
1147
|
-
yield codegen_csharp_1.If(`${token.value}.IsCancellationRequested`, codegen_csharp_1.Return());
|
|
1307
|
+
yield (0, codegen_csharp_1.If)(`${token.value}.IsCancellationRequested`, (0, codegen_csharp_1.Return)());
|
|
1148
1308
|
// if the
|
|
1149
|
-
const sw = codegen_csharp_1.Switch(id, [
|
|
1150
|
-
codegen_csharp_1.TerminalCase(powershell_declarations_1.Events.Verbose.value, function* () {
|
|
1309
|
+
const sw = (0, codegen_csharp_1.Switch)(id, [
|
|
1310
|
+
(0, codegen_csharp_1.TerminalCase)(powershell_declarations_1.Events.Verbose.value, function* () {
|
|
1151
1311
|
yield `WriteVerbose($"{(messageData().Message ?? ${codegen_csharp_1.System.String.Empty})}");`;
|
|
1152
|
-
yield codegen_csharp_1.Return();
|
|
1312
|
+
yield (0, codegen_csharp_1.Return)();
|
|
1153
1313
|
}),
|
|
1154
|
-
codegen_csharp_1.TerminalCase(powershell_declarations_1.Events.Warning.value, function* () {
|
|
1314
|
+
(0, codegen_csharp_1.TerminalCase)(powershell_declarations_1.Events.Warning.value, function* () {
|
|
1155
1315
|
yield `WriteWarning($"{(messageData().Message ?? ${codegen_csharp_1.System.String.Empty})}");`;
|
|
1156
|
-
yield codegen_csharp_1.Return();
|
|
1316
|
+
yield (0, codegen_csharp_1.Return)();
|
|
1157
1317
|
}),
|
|
1158
|
-
codegen_csharp_1.TerminalCase(powershell_declarations_1.Events.Information.value, function* () {
|
|
1318
|
+
(0, codegen_csharp_1.TerminalCase)(powershell_declarations_1.Events.Information.value, function* () {
|
|
1159
1319
|
if ($this.operation.asjob) {
|
|
1160
1320
|
yield '// When an operation supports asjob, Information messages must go thru verbose.';
|
|
1161
1321
|
yield `WriteVerbose($"INFORMATION: {(messageData().Message ?? ${codegen_csharp_1.System.String.Empty})}");`;
|
|
@@ -1165,17 +1325,17 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1165
1325
|
yield data.declarationStatement;
|
|
1166
1326
|
yield 'WriteInformation(data.Message, new string[]{});';
|
|
1167
1327
|
}
|
|
1168
|
-
yield codegen_csharp_1.Return();
|
|
1328
|
+
yield (0, codegen_csharp_1.Return)();
|
|
1169
1329
|
}),
|
|
1170
|
-
codegen_csharp_1.TerminalCase(powershell_declarations_1.Events.Debug.value, function* () {
|
|
1330
|
+
(0, codegen_csharp_1.TerminalCase)(powershell_declarations_1.Events.Debug.value, function* () {
|
|
1171
1331
|
yield `WriteDebug($"{(messageData().Message ?? ${codegen_csharp_1.System.String.Empty})}");`;
|
|
1172
|
-
yield codegen_csharp_1.Return();
|
|
1332
|
+
yield (0, codegen_csharp_1.Return)();
|
|
1173
1333
|
}),
|
|
1174
|
-
codegen_csharp_1.TerminalCase(powershell_declarations_1.Events.Error.value, function* () {
|
|
1334
|
+
(0, codegen_csharp_1.TerminalCase)(powershell_declarations_1.Events.Error.value, function* () {
|
|
1175
1335
|
yield 'WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) );';
|
|
1176
|
-
yield codegen_csharp_1.Return();
|
|
1336
|
+
yield (0, codegen_csharp_1.Return)();
|
|
1177
1337
|
}),
|
|
1178
|
-
codegen_csharp_1.TerminalCase(powershell_declarations_1.Events.Progress.value, function* () {
|
|
1338
|
+
(0, codegen_csharp_1.TerminalCase)(powershell_declarations_1.Events.Progress.value, function* () {
|
|
1179
1339
|
yield 'var data = messageData();';
|
|
1180
1340
|
yield 'int progress = (int)data.Value;';
|
|
1181
1341
|
yield 'string activityMessage, statusDescription;';
|
|
@@ -1198,14 +1358,14 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1198
1358
|
yield ' PercentComplete = progress,';
|
|
1199
1359
|
yield 'RecordType = recordType';
|
|
1200
1360
|
yield '});';
|
|
1201
|
-
yield codegen_csharp_1.Return();
|
|
1361
|
+
yield (0, codegen_csharp_1.Return)();
|
|
1202
1362
|
}),
|
|
1203
1363
|
]);
|
|
1204
1364
|
if ($this.operation.asjob) {
|
|
1205
1365
|
// if we support -AsJob, we support -NoWait
|
|
1206
|
-
sw.add(codegen_csharp_1.Case(powershell_declarations_1.Events.DelayBeforePolling.value, function* () {
|
|
1366
|
+
sw.add((0, codegen_csharp_1.Case)(powershell_declarations_1.Events.DelayBeforePolling.value, function* () {
|
|
1207
1367
|
yield 'var data = messageData();';
|
|
1208
|
-
yield codegen_csharp_1.If('true == MyInvocation?.BoundParameters?.ContainsKey("NoWait")', function* () {
|
|
1368
|
+
yield (0, codegen_csharp_1.If)('true == MyInvocation?.BoundParameters?.ContainsKey("NoWait")', function* () {
|
|
1209
1369
|
yield 'if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response)';
|
|
1210
1370
|
yield '{';
|
|
1211
1371
|
yield ' var asyncOperation = response.GetFirstHeader(@"Azure-AsyncOperation");';
|
|
@@ -1217,7 +1377,7 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1217
1377
|
yield ' return;';
|
|
1218
1378
|
yield '}';
|
|
1219
1379
|
});
|
|
1220
|
-
yield codegen_csharp_1.Else(function* () {
|
|
1380
|
+
yield (0, codegen_csharp_1.Else)(function* () {
|
|
1221
1381
|
yield 'if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response)';
|
|
1222
1382
|
yield '{';
|
|
1223
1383
|
yield ' int delay = (int)(response.Headers.RetryAfter?.Delta?.TotalSeconds ?? 30);';
|
|
@@ -1240,12 +1400,12 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1240
1400
|
if ($this.state.project.azure) {
|
|
1241
1401
|
// in azure mode, we signal the AzAccount module with every event that makes it here.
|
|
1242
1402
|
yield `await ${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.Signal(${id.value}, ${token.value}, ${messageData.value}, (i, t, m) => ((${exports_1.ClientRuntime.IEventListener})this).Signal(i, t, () => ${exports_1.ClientRuntime.EventDataConverter}.ConvertFrom(m()) as ${exports_1.ClientRuntime.EventData}), ${$this.invocationInfo.value}, this.ParameterSetName, ${$this.correlationId.value}, ${$this.processRecordId.value}, null );`;
|
|
1243
|
-
yield codegen_csharp_1.If(`${token.value}.IsCancellationRequested`, codegen_csharp_1.Return());
|
|
1403
|
+
yield (0, codegen_csharp_1.If)(`${token.value}.IsCancellationRequested`, (0, codegen_csharp_1.Return)());
|
|
1244
1404
|
}
|
|
1245
1405
|
else {
|
|
1246
1406
|
// In Non-Azure Modes, emit the Signal method without coorelation and processrecordid
|
|
1247
1407
|
yield `await ${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.Signal(${id.value}, ${token.value}, ${messageData.value}, (i, t, m) => ((${exports_1.ClientRuntime.IEventListener})this).Signal(i, t, () => ${exports_1.ClientRuntime.EventDataConverter}.ConvertFrom(m()) as ${exports_1.ClientRuntime.EventData}), ${$this.invocationInfo.value}, this.ParameterSetName, null ); `;
|
|
1248
|
-
yield codegen_csharp_1.If(`${token.value}.IsCancellationRequested`, codegen_csharp_1.Return());
|
|
1408
|
+
yield (0, codegen_csharp_1.If)(`${token.value}.IsCancellationRequested`, (0, codegen_csharp_1.Return)());
|
|
1249
1409
|
}
|
|
1250
1410
|
yield `WriteDebug($"{id}: {(messageData().Message ?? ${codegen_csharp_1.System.String.Empty})}");`;
|
|
1251
1411
|
// any handling of the signal on our side...
|
|
@@ -1257,7 +1417,7 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1257
1417
|
body: [],
|
|
1258
1418
|
operation: [],
|
|
1259
1419
|
};
|
|
1260
|
-
for (const parameter of linq_1.values(operation.parameters)) {
|
|
1420
|
+
for (const parameter of (0, linq_1.values)(operation.parameters)) {
|
|
1261
1421
|
// these are the parameters that this command expects
|
|
1262
1422
|
parameter.schema;
|
|
1263
1423
|
const td = this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(parameter.schema, true, this.state);
|
|
@@ -1291,11 +1451,11 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1291
1451
|
*get() {
|
|
1292
1452
|
const metadata = operation.extensions['x-ms-metadata'];
|
|
1293
1453
|
const profiles = metadata.profiles || new linq_1.Dictionary();
|
|
1294
|
-
yield codegen_csharp_1.Switch(`${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.Profile`, function* () {
|
|
1295
|
-
for (const { key: profileName, value: apiVersion } of linq_1.items(profiles)) {
|
|
1296
|
-
yield codegen_csharp_1.TerminalCase(`"${profileName}"`, codegen_csharp_1.Return(`"${apiVersion}"`));
|
|
1454
|
+
yield (0, codegen_csharp_1.Switch)(`${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.Profile`, function* () {
|
|
1455
|
+
for (const { key: profileName, value: apiVersion } of (0, linq_1.items)(profiles)) {
|
|
1456
|
+
yield (0, codegen_csharp_1.TerminalCase)(`"${profileName}"`, (0, codegen_csharp_1.Return)(`"${apiVersion}"`));
|
|
1297
1457
|
}
|
|
1298
|
-
yield codegen_csharp_1.TerminalDefaultCase(codegen_csharp_1.Return(`"${metadata.apiVersions[0]}"`));
|
|
1458
|
+
yield (0, codegen_csharp_1.TerminalDefaultCase)((0, codegen_csharp_1.Return)(`"${metadata.apiVersions[0]}"`));
|
|
1299
1459
|
});
|
|
1300
1460
|
}
|
|
1301
1461
|
}));
|
|
@@ -1303,7 +1463,7 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1303
1463
|
}
|
|
1304
1464
|
if (this.dropBodyParameter && parameter.details.csharp.isBodyParameter) {
|
|
1305
1465
|
// we're supposed to use parameters for the body parameter instead of a big object
|
|
1306
|
-
const expandedBodyParameter = this.add(new codegen_csharp_1.Field('_' + codegen_1.camelCase(parameter.details.csharp.name), td, {
|
|
1466
|
+
const expandedBodyParameter = this.add(new codegen_csharp_1.Field('_' + (0, codegen_1.camelCase)(parameter.details.csharp.name), td, {
|
|
1307
1467
|
description: parameter.details.csharp.description,
|
|
1308
1468
|
initialValue: (parameter.schema.type === codemodel_1.SchemaType.Array) ? codegen_csharp_1.dotnet.Null : `new ${(_a = parameter.schema.language.csharp) === null || _a === void 0 ? void 0 : _a.fullname}()`,
|
|
1309
1469
|
access: codegen_csharp_1.Access.Private
|
|
@@ -1318,17 +1478,17 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1318
1478
|
let cmdletParameter;
|
|
1319
1479
|
if (propertyType.schema.type !== codemodel_1.SchemaType.Array) {
|
|
1320
1480
|
cmdletParameter = new codegen_csharp_1.Property(vParam.name, propertyType, {
|
|
1321
|
-
get: codegen_csharp_1.toExpression(`${expandedBodyParameter.value}.${model_class_1.getVirtualPropertyName(vParam.origin) || vParam.origin.name}${!nullable ? '' : ` ?? ${propertyType.defaultOfType}`}`),
|
|
1481
|
+
get: (0, codegen_csharp_1.toExpression)(`${expandedBodyParameter.value}.${(0, model_class_1.getVirtualPropertyName)(vParam.origin) || vParam.origin.name}${!nullable ? '' : ` ?? ${propertyType.defaultOfType}`}`),
|
|
1322
1482
|
// get: toExpression(`null == ${expandedBodyParameter.value}.${vParam.origin.name} ? ${propertyType.defaultOfType} : (${propertyType.declaration}) ${expandedBodyParameter.value}.${vParam.origin.name}`),
|
|
1323
|
-
set: codegen_csharp_1.toExpression(`${expandedBodyParameter.value}.${model_class_1.getVirtualPropertyName(vParam.origin) || vParam.origin.name} = value`),
|
|
1483
|
+
set: (0, codegen_csharp_1.toExpression)(`${expandedBodyParameter.value}.${(0, model_class_1.getVirtualPropertyName)(vParam.origin) || vParam.origin.name} = value`),
|
|
1324
1484
|
new: PropertiesRequiringNew.has(vParam.name) ? codegen_csharp_1.Modifier.New : codegen_csharp_1.Modifier.None
|
|
1325
1485
|
});
|
|
1326
1486
|
}
|
|
1327
1487
|
else {
|
|
1328
1488
|
const fixedArrayPropertyType = this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(vSchema, true, this.state, true);
|
|
1329
1489
|
cmdletParameter = new codegen_csharp_1.Property(vParam.name, fixedArrayPropertyType, {
|
|
1330
|
-
get: codegen_csharp_1.toExpression(`${expandedBodyParameter.value}.${model_class_1.getVirtualPropertyName(vParam.origin) || vParam.origin.name}?.ToArray()${` ?? ${fixedArrayPropertyType.defaultOfType}`}`),
|
|
1331
|
-
set: codegen_csharp_1.toExpression(`${expandedBodyParameter.value}.${model_class_1.getVirtualPropertyName(vParam.origin) || vParam.origin.name} = (value != null ? new ${propertyType.declaration}(value) : null)`),
|
|
1490
|
+
get: (0, codegen_csharp_1.toExpression)(`${expandedBodyParameter.value}.${(0, model_class_1.getVirtualPropertyName)(vParam.origin) || vParam.origin.name}?.ToArray()${` ?? ${fixedArrayPropertyType.defaultOfType}`}`),
|
|
1491
|
+
set: (0, codegen_csharp_1.toExpression)(`${expandedBodyParameter.value}.${(0, model_class_1.getVirtualPropertyName)(vParam.origin) || vParam.origin.name} = (value != null ? new ${propertyType.declaration}(value) : null)`),
|
|
1332
1492
|
new: PropertiesRequiringNew.has(vParam.name) ? codegen_csharp_1.Modifier.New : codegen_csharp_1.Modifier.None
|
|
1333
1493
|
});
|
|
1334
1494
|
}
|
|
@@ -1351,7 +1511,7 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1351
1511
|
// we have to figure out if this is a standalone dictionary or a hybrid object/dictionary.
|
|
1352
1512
|
// if it's a hybrid, we have to create another parameter like -<XXX>AdditionalProperties and have that dump the contents into the dictionary
|
|
1353
1513
|
// if it's a standalone dictionary, we can just use hashtable instead
|
|
1354
|
-
if (linq_1.length(vSchema.properties) === 0) {
|
|
1514
|
+
if ((0, linq_1.length)(vSchema.properties) === 0) {
|
|
1355
1515
|
// it's a pure dictionary
|
|
1356
1516
|
// add an attribute for changing the exported type.
|
|
1357
1517
|
cmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ExportAsAttribute, { parameters: [`typeof(${codegen_csharp_1.System.Collections.Hashtable})`] }));
|
|
@@ -1368,29 +1528,29 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1368
1528
|
cmdletParameter.setAccess = codegen_csharp_1.Access.Internal;
|
|
1369
1529
|
cmdletParameter.getAccess = codegen_csharp_1.Access.Internal;
|
|
1370
1530
|
// create a InputFileXXX for the parameter
|
|
1371
|
-
const ifname = vParam.name.toLowerCase() === 'value' ? 'InputFile' : codegen_1.pascalCase([vParam.name, 'Input', 'File']);
|
|
1531
|
+
const ifname = vParam.name.toLowerCase() === 'value' ? 'InputFile' : (0, codegen_1.pascalCase)([vParam.name, 'Input', 'File']);
|
|
1372
1532
|
const inputFileParameter = new codegen_csharp_1.Property(ifname, codegen_csharp_1.dotnet.String, {
|
|
1373
1533
|
// get: toExpression(`${expandedBodyParameter.value}.${vParam.origin.name}${vParam.required ? '' : ` ?? ${propertyType.defaultOfType}`}`),
|
|
1374
1534
|
set: function* () {
|
|
1375
|
-
const provider = codegen_csharp_2.Local('provider');
|
|
1535
|
+
const provider = (0, codegen_csharp_2.Local)('provider');
|
|
1376
1536
|
provider.initializer = undefined;
|
|
1377
|
-
const paths = codegen_csharp_2.Local('paths', `this.SessionState.Path.GetResolvedProviderPathFromPSPath(value, out ${provider.declarationExpression})`);
|
|
1537
|
+
const paths = (0, codegen_csharp_2.Local)('paths', `this.SessionState.Path.GetResolvedProviderPathFromPSPath(value, out ${provider.declarationExpression})`);
|
|
1378
1538
|
yield paths.declarationStatement;
|
|
1379
|
-
yield codegen_csharp_1.If(`${provider.value}.Name != "FileSystem" || ${paths.value}.Count == 0`, 'ThrowTerminatingError( new System.Management.Automation.ErrorRecord(new global::System.Exception("Invalid input path."),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, value) );');
|
|
1380
|
-
yield codegen_csharp_1.If(`${paths.value}.Count > 1`, 'ThrowTerminatingError( new System.Management.Automation.ErrorRecord(new global::System.Exception("Multiple input paths not allowed."),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, value) );');
|
|
1539
|
+
yield (0, codegen_csharp_1.If)(`${provider.value}.Name != "FileSystem" || ${paths.value}.Count == 0`, 'ThrowTerminatingError( new System.Management.Automation.ErrorRecord(new global::System.Exception("Invalid input path."),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, value) );');
|
|
1540
|
+
yield (0, codegen_csharp_1.If)(`${paths.value}.Count > 1`, 'ThrowTerminatingError( new System.Management.Automation.ErrorRecord(new global::System.Exception("Multiple input paths not allowed."),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, value) );');
|
|
1381
1541
|
yield cmdletParameter.assign(`global::System.IO.File.ReadAllBytes(${paths.value}[0])`);
|
|
1382
1542
|
},
|
|
1383
|
-
description: `Input File for ${cmdletParameter.name} (${codegen_1.escapeString(desc)})`
|
|
1543
|
+
description: `Input File for ${cmdletParameter.name} (${(0, codegen_1.escapeString)(desc)})`
|
|
1384
1544
|
});
|
|
1385
|
-
inputFileParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ParameterAttribute, { parameters: [new codegen_csharp_1.LiteralExpression(`Mandatory = ${vParam.required ? 'true' : 'false'}`), new codegen_csharp_1.LiteralExpression(`HelpMessage = "Input File for ${cmdletParameter.name} (${codegen_1.escapeString(desc || '.')})"`)] }));
|
|
1545
|
+
inputFileParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ParameterAttribute, { parameters: [new codegen_csharp_1.LiteralExpression(`Mandatory = ${vParam.required ? 'true' : 'false'}`), new codegen_csharp_1.LiteralExpression(`HelpMessage = "Input File for ${cmdletParameter.name} (${(0, codegen_1.escapeString)(desc || '.')})"`)] }));
|
|
1386
1546
|
inputFileParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CategoryAttribute, { parameters: [`${powershell_declarations_1.ParameterCategory}.Body`] }));
|
|
1387
|
-
if (linq_1.length(vParam.alias) > 0) {
|
|
1547
|
+
if ((0, linq_1.length)(vParam.alias) > 0) {
|
|
1388
1548
|
inputFileParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.Alias, { parameters: vParam.alias.map(x => '"' + x + '"') }));
|
|
1389
1549
|
}
|
|
1390
1550
|
$this.add(inputFileParameter);
|
|
1391
1551
|
}
|
|
1392
1552
|
else {
|
|
1393
|
-
cmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ParameterAttribute, { parameters: [new codegen_csharp_1.LiteralExpression(`Mandatory = ${vParam.required ? 'true' : 'false'}`), new codegen_csharp_1.LiteralExpression(`HelpMessage = "${codegen_1.escapeString(desc || '.')}"`)] }));
|
|
1553
|
+
cmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ParameterAttribute, { parameters: [new codegen_csharp_1.LiteralExpression(`Mandatory = ${vParam.required ? 'true' : 'false'}`), new codegen_csharp_1.LiteralExpression(`HelpMessage = "${(0, codegen_1.escapeString)(desc || '.')}"`)] }));
|
|
1394
1554
|
cmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CategoryAttribute, { parameters: [`${powershell_declarations_1.ParameterCategory}.Body`] }));
|
|
1395
1555
|
NewAddInfoAttribute(cmdletParameter, propertyType, !!vParam.required, false, desc, vParam.origin.property.serializedName);
|
|
1396
1556
|
NewAddCompleterInfo(cmdletParameter, vParam);
|
|
@@ -1399,13 +1559,12 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1399
1559
|
addDefaultInfo(cmdletParameter, vParam);
|
|
1400
1560
|
this.addDoNotExport(cmdletParameter, vParam);
|
|
1401
1561
|
}
|
|
1402
|
-
const
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
cmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ArgumentCompleterAttribute, { parameters: [`typeof(${hasEnum ? propertyType.elementType.declaration : propertyType.declaration})`] }));
|
|
1562
|
+
const addArgumentCompleter = isEnumImplementation(vParam.schema) || propertyType instanceof exports_1.ArrayOf && isEnumImplementation(propertyType.elementType.schema);
|
|
1563
|
+
if (addArgumentCompleter) {
|
|
1564
|
+
addPSArgumentCompleterAttribute(cmdletParameter, vParam.schema);
|
|
1406
1565
|
}
|
|
1407
1566
|
// add aliases if there is any
|
|
1408
|
-
if (linq_1.length(vParam.alias) > 0) {
|
|
1567
|
+
if ((0, linq_1.length)(vParam.alias) > 0) {
|
|
1409
1568
|
cmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.Alias, { parameters: vParam.alias.map(x => '"' + x + '"') }));
|
|
1410
1569
|
}
|
|
1411
1570
|
this.add(cmdletParameter);
|
|
@@ -1442,17 +1601,19 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1442
1601
|
}
|
|
1443
1602
|
}
|
|
1444
1603
|
if (this.isViaIdentity) {
|
|
1604
|
+
const viaIdentityRegex = /ViaIdentity\d?/g;
|
|
1605
|
+
this.inputObjectParameterName = `${this.name.split(viaIdentityRegex)[1].split('Expanded')[0]}InputObject`;
|
|
1445
1606
|
// add in the pipeline parameter for the identity
|
|
1446
|
-
const idschema = linq_1.values(this.state.project.model.schemas.objects).first(each => each.language.default.uid === 'universal-parameter-type');
|
|
1607
|
+
const idschema = (0, linq_1.values)(this.state.project.model.schemas.objects).first(each => each.language.default.uid === 'universal-parameter-type');
|
|
1447
1608
|
const idtd = this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(idschema, true, this.state);
|
|
1448
|
-
const idParam = this.add(new codegen_csharp_1.BackedProperty(
|
|
1609
|
+
const idParam = this.add(new codegen_csharp_1.BackedProperty(this.inputObjectParameterName, idtd, {
|
|
1449
1610
|
description: 'Identity Parameter'
|
|
1450
1611
|
}));
|
|
1451
1612
|
const parameters = [new codegen_csharp_1.LiteralExpression('Mandatory = true'), new codegen_csharp_1.LiteralExpression('HelpMessage = "Identity Parameter"'), new codegen_csharp_1.LiteralExpression('ValueFromPipeline = true')];
|
|
1452
1613
|
idParam.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ParameterAttribute, { parameters }));
|
|
1453
1614
|
idParam.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CategoryAttribute, { parameters: [`${powershell_declarations_1.ParameterCategory}.Path`] }));
|
|
1454
1615
|
}
|
|
1455
|
-
for (const vParam of linq_1.values(vps.operation)) {
|
|
1616
|
+
for (const vParam of (0, linq_1.values)(vps.operation)) {
|
|
1456
1617
|
if (vParam.name === 'Host') {
|
|
1457
1618
|
// skip 'Host'
|
|
1458
1619
|
continue;
|
|
@@ -1492,7 +1653,7 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1492
1653
|
// we have to figure out if this is a standalone dictionary or a hybrid object/dictionary.
|
|
1493
1654
|
// if it's a hybrid, we have to create another parameter like -<XXX>AdditionalProperties and have that dump the contents into the dictionary
|
|
1494
1655
|
// if it's a standalone dictionary, we can just use hashtable instead
|
|
1495
|
-
if (linq_1.length(vSchema.properties) === 0) {
|
|
1656
|
+
if ((0, linq_1.length)(vSchema.properties) === 0) {
|
|
1496
1657
|
// it's a pure dictionary
|
|
1497
1658
|
// change the property type to hashtable.
|
|
1498
1659
|
// add an attribute to change the exported type.
|
|
@@ -1504,7 +1665,7 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1504
1665
|
}
|
|
1505
1666
|
}
|
|
1506
1667
|
this.thingsToSerialize.push(regularCmdletParameter);
|
|
1507
|
-
const parameters = [new codegen_csharp_1.LiteralExpression(`Mandatory = ${vParam.required ? 'true' : 'false'}`), new codegen_csharp_1.LiteralExpression(`HelpMessage = "${codegen_1.escapeString(vParam.description) || '.'}"`)];
|
|
1668
|
+
const parameters = [new codegen_csharp_1.LiteralExpression(`Mandatory = ${vParam.required ? 'true' : 'false'}`), new codegen_csharp_1.LiteralExpression(`HelpMessage = "${(0, codegen_1.escapeString)(vParam.description) || '.'}"`)];
|
|
1508
1669
|
if (!!origin && origin.details.csharp.isBodyParameter) {
|
|
1509
1670
|
parameters.push(new codegen_csharp_1.LiteralExpression('ValueFromPipeline = true'));
|
|
1510
1671
|
this.bodyParameter = regularCmdletParameter;
|
|
@@ -1522,16 +1683,16 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1522
1683
|
addDefaultInfo(regularCmdletParameter, vParam);
|
|
1523
1684
|
this.addDoNotExport(regularCmdletParameter, vParam);
|
|
1524
1685
|
// add aliases if there is any
|
|
1525
|
-
if (linq_1.length(vParam.alias) > 0) {
|
|
1686
|
+
if ((0, linq_1.length)(vParam.alias) > 0) {
|
|
1526
1687
|
regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.Alias, { parameters: vParam.alias.map(x => '"' + x + '"') }));
|
|
1527
1688
|
}
|
|
1528
1689
|
const httpParam = origin ? origin.details.csharp.httpParameter : null;
|
|
1529
1690
|
//const uid = httpParam ? httpParam.details.csharp.uid : 'no-parameter';
|
|
1530
1691
|
if (httpParam) {
|
|
1531
1692
|
// xichen: Is it safe to compare by csharp serializedName? Because we no longer have uid
|
|
1532
|
-
const cat = (_l =
|
|
1693
|
+
const cat = (_l = this.apiCall.parameters) === null || _l === void 0 ? void 0 : _l.find((param) => { var _a, _b, _c; return !((_a = param.language.csharp) === null || _a === void 0 ? void 0 : _a.constantValue) && ((_b = param.language.csharp) === null || _b === void 0 ? void 0 : _b.serializedName) === ((_c = httpParam.language.csharp) === null || _c === void 0 ? void 0 : _c.serializedName); });
|
|
1533
1694
|
if (cat) {
|
|
1534
|
-
regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CategoryAttribute, { parameters: [`${powershell_declarations_1.ParameterCategory}.${codegen_1.pascalCase(((_m = cat.protocol.http) === null || _m === void 0 ? void 0 : _m.in))}`] }));
|
|
1695
|
+
regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CategoryAttribute, { parameters: [`${powershell_declarations_1.ParameterCategory}.${(0, codegen_1.pascalCase)(((_m = cat.protocol.http) === null || _m === void 0 ? void 0 : _m.in))}`] }));
|
|
1535
1696
|
}
|
|
1536
1697
|
}
|
|
1537
1698
|
else {
|
|
@@ -1542,10 +1703,9 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1542
1703
|
}));
|
|
1543
1704
|
}
|
|
1544
1705
|
}
|
|
1545
|
-
const
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ArgumentCompleterAttribute, { parameters: [`typeof(${hasEnum ? propertyType.elementType.declaration : propertyType.declaration})`] }));
|
|
1706
|
+
const addArgumentCompleter = isEnumImplementation(vParam.schema) || propertyType instanceof exports_1.ArrayOf && isEnumImplementation(propertyType.elementType.schema);
|
|
1707
|
+
if (addArgumentCompleter) {
|
|
1708
|
+
addPSArgumentCompleterAttribute(regularCmdletParameter, vParam.schema);
|
|
1549
1709
|
}
|
|
1550
1710
|
}
|
|
1551
1711
|
const ifmatch = this.properties.find((v) => v.name.toLowerCase() === 'ifmatch');
|
|
@@ -1562,19 +1722,19 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1562
1722
|
addDoNotExport(cmdletParameter, vParam) {
|
|
1563
1723
|
if (vParam.hidden) {
|
|
1564
1724
|
this.state.message({
|
|
1565
|
-
Channel:
|
|
1725
|
+
Channel: extension_base_1.Channel.Debug,
|
|
1566
1726
|
Text: `[DIRECTIVE] Applied 'hide' directive to parameter ${cmdletParameter.name}. Added attribute ${powershell_declarations_1.DoNotExportAttribute.declaration} to parameter.`,
|
|
1567
1727
|
});
|
|
1568
1728
|
cmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.DoNotExportAttribute));
|
|
1569
1729
|
}
|
|
1570
1730
|
}
|
|
1571
1731
|
NewAddClassAttributes(operation, variantName) {
|
|
1572
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1732
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
1573
1733
|
const cmdletAttribParams = [
|
|
1574
|
-
category[operation.details.csharp.verb] ? powershell_declarations_1.verbEnum(category[operation.details.csharp.verb], operation.details.csharp.verb) : `"${operation.details.csharp.verb}"`,
|
|
1734
|
+
category[operation.details.csharp.verb] ? (0, powershell_declarations_1.verbEnum)(category[operation.details.csharp.verb], operation.details.csharp.verb) : `"${operation.details.csharp.verb}"`,
|
|
1575
1735
|
new codegen_csharp_1.StringExpression(variantName)
|
|
1576
1736
|
];
|
|
1577
|
-
if (
|
|
1737
|
+
if ((0, command_operation_1.isWritableCmdlet)(operation) && !operation.details.csharp.supportShouldProcess) {
|
|
1578
1738
|
cmdletAttribParams.push('SupportsShouldProcess = true');
|
|
1579
1739
|
}
|
|
1580
1740
|
if (this.clientsidePagination) {
|
|
@@ -1584,21 +1744,21 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1584
1744
|
this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.InternalExportAttribute));
|
|
1585
1745
|
const noun = `${operation.details.csharp.subjectPrefix}${operation.details.csharp.subject}`;
|
|
1586
1746
|
const cmdletName = `${operation.details.csharp.verb}-${noun}${operation.details.csharp.name ? `_${operation.details.csharp.name}` : ''}`;
|
|
1587
|
-
this.state.message({ Channel:
|
|
1747
|
+
this.state.message({ Channel: extension_base_1.Channel.Debug, Text: `[DIRECTIVE] Applied 'hide' directive to ${cmdletName}. Added attribute ${powershell_declarations_1.InternalExportAttribute.declaration} to cmdlet.` });
|
|
1588
1748
|
}
|
|
1589
1749
|
this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CmdletAttribute, { parameters: cmdletAttribParams }));
|
|
1590
1750
|
// add alias attribute if there is any aliases for this cmdlet
|
|
1591
|
-
if (linq_1.length(operation.details.csharp.alias) > 0) {
|
|
1751
|
+
if ((0, linq_1.length)(operation.details.csharp.alias) > 0) {
|
|
1592
1752
|
this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.Alias, { parameters: operation.details.csharp.alias.map((x) => '"' + x + '"') }));
|
|
1593
1753
|
}
|
|
1594
1754
|
let shouldAddPassThru = false;
|
|
1595
1755
|
// set to hold the output types
|
|
1596
1756
|
const outputTypes = new Set();
|
|
1597
|
-
for (const httpOperation of linq_1.values(operation.callGraph)) {
|
|
1757
|
+
for (const httpOperation of (0, linq_1.values)(operation.callGraph)) {
|
|
1598
1758
|
const pageableInfo = (_a = httpOperation.language.csharp) === null || _a === void 0 ? void 0 : _a.pageable;
|
|
1599
1759
|
const v = httpOperation.responses && httpOperation.responses.length > 0 && httpOperation.responses[0] instanceof codemodel_1.SchemaResponse;
|
|
1600
1760
|
// Add this for binary response in m4
|
|
1601
|
-
for (const binary of linq_1.values(httpOperation.responses).selectNonNullable(each => each.binary)) {
|
|
1761
|
+
for (const binary of (0, linq_1.values)(httpOperation.responses).selectNonNullable(each => each.binary)) {
|
|
1602
1762
|
if (binary) {
|
|
1603
1763
|
// if this is a stream, skip the output type.
|
|
1604
1764
|
this.hasStreamOutput = true;
|
|
@@ -1606,10 +1766,10 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1606
1766
|
outputTypes.add(`typeof(${codegen_csharp_1.dotnet.Bool})`);
|
|
1607
1767
|
}
|
|
1608
1768
|
}
|
|
1609
|
-
for (const schema of linq_1.values(httpOperation.responses).selectNonNullable(each => each.schema)) {
|
|
1610
|
-
const props = schema_1.getAllProperties(schema);
|
|
1769
|
+
for (const schema of (0, linq_1.values)(httpOperation.responses).selectNonNullable(each => each.schema)) {
|
|
1770
|
+
const props = (0, schema_1.getAllProperties)(schema);
|
|
1611
1771
|
// does the target type just wrap a single output?
|
|
1612
|
-
const resultSchema =
|
|
1772
|
+
const resultSchema = schema;
|
|
1613
1773
|
// make sure return type for boolean stays boolean!
|
|
1614
1774
|
if (resultSchema.type === codemodel_1.SchemaType.Boolean ||
|
|
1615
1775
|
(resultSchema.type === codemodel_1.SchemaType.Choice && resultSchema.choiceType.type === codemodel_1.SchemaType.Boolean && resultSchema.choices.length === 1) ||
|
|
@@ -1652,8 +1812,8 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1652
1812
|
}
|
|
1653
1813
|
// if any response does not return,
|
|
1654
1814
|
// the cmdlet should have a PassThru parameter
|
|
1655
|
-
shouldAddPassThru = shouldAddPassThru || linq_1.values(operation.callGraph)
|
|
1656
|
-
.selectMany(httpOperation => linq_1.values((httpOperation.responses || []).concat(httpOperation.exceptions || [])))
|
|
1815
|
+
shouldAddPassThru = shouldAddPassThru || (0, linq_1.values)(operation.callGraph)
|
|
1816
|
+
.selectMany(httpOperation => (0, linq_1.values)((httpOperation.responses || []).concat(httpOperation.exceptions || [])))
|
|
1657
1817
|
//.selectMany(responsesItem => responsesItem.value)
|
|
1658
1818
|
.any(value => value.schema === undefined);
|
|
1659
1819
|
if (outputTypes.size === 0) {
|
|
@@ -1664,11 +1824,13 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1664
1824
|
const breakingChange = operation.details.csharp.breakingChange;
|
|
1665
1825
|
if (breakingChange.cmdlet) {
|
|
1666
1826
|
const parameters = [];
|
|
1667
|
-
if (breakingChange.cmdlet.deprecateByVersion) {
|
|
1668
|
-
|
|
1669
|
-
if (breakingChange.cmdlet.changeInEfectByDate)
|
|
1670
|
-
parameters.push(`"${breakingChange.cmdlet.changeInEfectByDate}"`);
|
|
1827
|
+
if (!breakingChange.cmdlet.deprecateByVersion || !breakingChange.cmdlet.deprecateByAzVersion) {
|
|
1828
|
+
throw new Error('Cmdlet breaking change requires both \'deprecateByVersion\' and \'deprecateByAzVersion\', please refer to https://github.com/Azure/azure-powershell/blob/main/documentation/development-docs/breakingchange-for-autogen-module.md for more details.');
|
|
1671
1829
|
}
|
|
1830
|
+
parameters.push(`"${breakingChange.cmdlet.deprecateByVersion}"`);
|
|
1831
|
+
parameters.push(`"${breakingChange.cmdlet.deprecateByAzVersion}"`);
|
|
1832
|
+
if (breakingChange.cmdlet.changeInEfectByDate)
|
|
1833
|
+
parameters.push(`"${breakingChange.cmdlet.changeInEfectByDate}"`);
|
|
1672
1834
|
if (breakingChange.cmdlet.replacement)
|
|
1673
1835
|
parameters.push(`ReplacementCmdletName = "${breakingChange.cmdlet.replacement}"`);
|
|
1674
1836
|
if (breakingChange.cmdlet.changeDescription)
|
|
@@ -1678,11 +1840,13 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1678
1840
|
if (breakingChange.variant) {
|
|
1679
1841
|
const parameters = [];
|
|
1680
1842
|
parameters.push(`new string[] {"${breakingChange.variant.name}"}`);
|
|
1681
|
-
if (breakingChange.
|
|
1682
|
-
|
|
1683
|
-
if (breakingChange.variant.changeInEfectByDate)
|
|
1684
|
-
parameters.push(`"${breakingChange.variant.changeInEfectByDate}"`);
|
|
1843
|
+
if (!breakingChange.output.deprecateByVersion || !breakingChange.output.deprecateByAzVersion) {
|
|
1844
|
+
throw new Error('Cmdlet breaking change requires both \'deprecateByVersion\' and \'deprecateByAzVersion\', please refer to https://github.com/Azure/azure-powershell/blob/main/documentation/development-docs/breakingchange-for-autogen-module.md for more details.');
|
|
1685
1845
|
}
|
|
1846
|
+
parameters.push(`"${breakingChange.output.deprecateByVersion}"`);
|
|
1847
|
+
parameters.push(`"${breakingChange.output.deprecateByAzVersion}"`);
|
|
1848
|
+
if (breakingChange.output.changeInEfectByDate)
|
|
1849
|
+
parameters.push(`"${breakingChange.output.changeInEfectByDate}"`);
|
|
1686
1850
|
if (breakingChange.variant.changeDescription)
|
|
1687
1851
|
parameters.push(`ChangeDescription = "${breakingChange.variant.changeDescription}"`);
|
|
1688
1852
|
this.add(new codegen_csharp_1.Attribute(exports_1.ClientRuntime.ParameterSetBreakingChangeAttribute, { parameters: parameters }));
|
|
@@ -1696,11 +1860,13 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1696
1860
|
else {
|
|
1697
1861
|
parameters.push(`"${outputTypes.values().next().value.replace(/typeof\((.*)\)/, '$1')}"`);
|
|
1698
1862
|
}
|
|
1699
|
-
if (breakingChange.output.deprecateByVersion) {
|
|
1700
|
-
|
|
1701
|
-
if (breakingChange.output.changeInEfectByDate)
|
|
1702
|
-
parameters.push(`"${breakingChange.output.changeInEfectByDate}"`);
|
|
1863
|
+
if (!breakingChange.output.deprecateByVersion || !breakingChange.output.deprecateByAzVersion) {
|
|
1864
|
+
throw new Error('Cmdlet breaking change requires both \'deprecateByVersion\' and \'deprecateByAzVersion\', please refer to https://github.com/Azure/azure-powershell/blob/main/documentation/development-docs/breakingchange-for-autogen-module.md for more details.');
|
|
1703
1865
|
}
|
|
1866
|
+
parameters.push(`"${breakingChange.output.deprecateByVersion}"`);
|
|
1867
|
+
parameters.push(`"${breakingChange.output.deprecateByAzVersion}"`);
|
|
1868
|
+
if (breakingChange.output.changeInEfectByDate)
|
|
1869
|
+
parameters.push(`"${breakingChange.output.changeInEfectByDate}"`);
|
|
1704
1870
|
if (breakingChange.output.replacement)
|
|
1705
1871
|
parameters.push(`ReplacementCmdletOutputType = "${breakingChange.output.replacement}"`);
|
|
1706
1872
|
if (breakingChange.output.deprecatedOutputProperties) {
|
|
@@ -1745,17 +1911,12 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1745
1911
|
});
|
|
1746
1912
|
this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ProfileAttribute, { parameters: [...profileNames] }));
|
|
1747
1913
|
}
|
|
1748
|
-
this.operation.callGraph.
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
(_a = operationInfo.requests) === null || _a === void 0 ? void 0 : _a.forEach((request) => {
|
|
1755
|
-
var _a, _b;
|
|
1756
|
-
this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.HttpPathAttribute, { parameters: [`Path = "${(_b = (_a = request.protocol) === null || _a === void 0 ? void 0 : _a.http) === null || _b === void 0 ? void 0 : _b.path}"`, `ApiVersion = "${apiVersion}"`] }));
|
|
1757
|
-
});
|
|
1758
|
-
});
|
|
1914
|
+
if (this.operation.callGraph.length === 1) {
|
|
1915
|
+
this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.HttpPathAttribute, { parameters: [`Path = "${(_l = (_k = (_j = this.apiCall.requests) === null || _j === void 0 ? void 0 : _j[0].protocol) === null || _k === void 0 ? void 0 : _k.http) === null || _l === void 0 ? void 0 : _l.path}"`, `ApiVersion = "${(_m = this.apiCall.apiVersions) === null || _m === void 0 ? void 0 : _m[0].version}"`] }));
|
|
1916
|
+
}
|
|
1917
|
+
if (variantName.includes('ViaJsonString') || variantName.includes('ViaJsonFilePath')) {
|
|
1918
|
+
this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.NotSuggestDefaultParameterSetAttribute));
|
|
1919
|
+
}
|
|
1759
1920
|
}
|
|
1760
1921
|
}
|
|
1761
1922
|
exports.CmdletClass = CmdletClass;
|