@autorest/powershell 4.0.0-dev.1 → 4.0.0-dev.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.rush/temp/package-deps_build.json +94 -60
- package/.rush/temp/shrinkwrap-deps.json +22 -22
- package/autorest-configuration-for-sdk.md +122 -0
- package/autorest-configuration.md +4 -2
- package/dist/cmdlets/class.d.ts +1 -0
- package/dist/cmdlets/class.d.ts.map +1 -1
- package/dist/cmdlets/class.js +218 -82
- package/dist/cmdlets/class.js.map +1 -1
- package/dist/cmdlets/namespace.d.ts.map +1 -1
- package/dist/cmdlets/namespace.js +3 -1
- package/dist/cmdlets/namespace.js.map +1 -1
- package/dist/cmdlets/parameter.js +1 -0
- package/dist/cmdlets/parameter.js.map +1 -1
- package/dist/enums/namespace.js +2 -1
- package/dist/enums/namespace.js.map +1 -1
- package/dist/file-formats/md-file.js +1 -0
- package/dist/file-formats/md-file.js.map +1 -1
- package/dist/file-formats/psd-file.js +1 -0
- package/dist/file-formats/psd-file.js.map +1 -1
- package/dist/file-formats/psscript-file.js +1 -0
- package/dist/file-formats/psscript-file.js.map +1 -1
- package/dist/generators/csproj.js +1 -0
- package/dist/generators/csproj.js.map +1 -1
- package/dist/generators/gitattributes.js +1 -0
- package/dist/generators/gitattributes.js.map +1 -1
- package/dist/generators/gitignore.js +1 -0
- package/dist/generators/gitignore.js.map +1 -1
- package/dist/generators/inputhandler.custom.d.ts +3 -0
- package/dist/generators/inputhandler.custom.d.ts.map +1 -0
- package/dist/generators/inputhandler.custom.js +33 -0
- package/dist/generators/inputhandler.custom.js.map +1 -0
- package/dist/generators/nuspec.js +1 -0
- package/dist/generators/nuspec.js.map +1 -1
- package/dist/generators/psm1.custom.js +1 -0
- package/dist/generators/psm1.custom.js.map +1 -1
- package/dist/generators/psm1.internal.js +1 -0
- package/dist/generators/psm1.internal.js.map +1 -1
- package/dist/generators/psm1.js +3 -2
- package/dist/generators/psm1.js.map +1 -1
- package/dist/generators/readme.js +1 -0
- package/dist/generators/readme.js.map +1 -1
- package/dist/generators/script-cmdlet.js +2 -1
- package/dist/generators/script-cmdlet.js.map +1 -1
- package/dist/internal/name-inferrer.js +1 -0
- package/dist/internal/name-inferrer.js.map +1 -1
- package/dist/internal/powershell-declarations.d.ts +3 -0
- package/dist/internal/powershell-declarations.d.ts.map +1 -1
- package/dist/internal/powershell-declarations.js +3 -0
- package/dist/internal/powershell-declarations.js.map +1 -1
- package/dist/internal/project.d.ts +12 -9
- package/dist/internal/project.d.ts.map +1 -1
- package/dist/internal/project.js +31 -12
- package/dist/internal/project.js.map +1 -1
- package/dist/internal/state.js +1 -0
- package/dist/internal/state.js.map +1 -1
- package/dist/internal/verbs.js +1 -0
- package/dist/internal/verbs.js.map +1 -1
- package/dist/llcsharp/clientruntime.d.ts +3 -0
- package/dist/llcsharp/clientruntime.d.ts.map +1 -1
- package/dist/llcsharp/clientruntime.js +4 -0
- package/dist/llcsharp/clientruntime.js.map +1 -1
- package/dist/llcsharp/code-model.d.ts +1 -0
- package/dist/llcsharp/code-model.d.ts.map +1 -1
- package/dist/llcsharp/csharp-declarations.js +1 -0
- package/dist/llcsharp/csharp-declarations.js.map +1 -1
- package/dist/llcsharp/enums/enum.js +2 -1
- package/dist/llcsharp/enums/enum.js.map +1 -1
- package/dist/llcsharp/enums/namespace.js +1 -0
- package/dist/llcsharp/enums/namespace.js.map +1 -1
- package/dist/llcsharp/exports.js +23 -13
- package/dist/llcsharp/exports.js.map +1 -1
- package/dist/llcsharp/generator.js +1 -0
- package/dist/llcsharp/generator.js.map +1 -1
- package/dist/llcsharp/messages.js +1 -0
- package/dist/llcsharp/messages.js.map +1 -1
- package/dist/llcsharp/model/idictionary.js +1 -0
- package/dist/llcsharp/model/idictionary.js.map +1 -1
- package/dist/llcsharp/model/interface.d.ts.map +1 -1
- package/dist/llcsharp/model/interface.js +2 -1
- package/dist/llcsharp/model/interface.js.map +1 -1
- package/dist/llcsharp/model/model-class-dictionary.js +1 -0
- package/dist/llcsharp/model/model-class-dictionary.js.map +1 -1
- package/dist/llcsharp/model/model-class-json.d.ts.map +1 -1
- package/dist/llcsharp/model/model-class-json.js +12 -2
- package/dist/llcsharp/model/model-class-json.js.map +1 -1
- package/dist/llcsharp/model/model-class-serializer.js +1 -0
- package/dist/llcsharp/model/model-class-serializer.js.map +1 -1
- package/dist/llcsharp/model/model-class.js +11 -10
- package/dist/llcsharp/model/model-class.js.map +1 -1
- package/dist/llcsharp/model/namespace.js +1 -0
- package/dist/llcsharp/model/namespace.js.map +1 -1
- package/dist/llcsharp/model/property.js +1 -0
- package/dist/llcsharp/model/property.js.map +1 -1
- package/dist/llcsharp/operation/api-class.js +1 -0
- package/dist/llcsharp/operation/api-class.js.map +1 -1
- package/dist/llcsharp/operation/method.d.ts.map +1 -1
- package/dist/llcsharp/operation/method.js +21 -27
- package/dist/llcsharp/operation/method.js.map +1 -1
- package/dist/llcsharp/operation/namespace.js +1 -0
- package/dist/llcsharp/operation/namespace.js.map +1 -1
- package/dist/llcsharp/operation/parameter.js +1 -0
- package/dist/llcsharp/operation/parameter.js.map +1 -1
- package/dist/llcsharp/project.d.ts.map +1 -1
- package/dist/llcsharp/project.js +3 -1
- package/dist/llcsharp/project.js.map +1 -1
- package/dist/llcsharp/schema/Uuid.js +1 -0
- package/dist/llcsharp/schema/Uuid.js.map +1 -1
- package/dist/llcsharp/schema/array.js +1 -0
- package/dist/llcsharp/schema/array.js.map +1 -1
- package/dist/llcsharp/schema/binary.js +1 -0
- package/dist/llcsharp/schema/binary.js.map +1 -1
- package/dist/llcsharp/schema/boolean.js +1 -0
- package/dist/llcsharp/schema/boolean.js.map +1 -1
- package/dist/llcsharp/schema/byte-array.js +1 -0
- package/dist/llcsharp/schema/byte-array.js.map +1 -1
- package/dist/llcsharp/schema/char.js +1 -0
- package/dist/llcsharp/schema/char.js.map +1 -1
- package/dist/llcsharp/schema/date-time.d.ts.map +1 -1
- package/dist/llcsharp/schema/date-time.js +1 -0
- package/dist/llcsharp/schema/date-time.js.map +1 -1
- package/dist/llcsharp/schema/date.js +1 -0
- package/dist/llcsharp/schema/date.js.map +1 -1
- package/dist/llcsharp/schema/duration.js +1 -0
- package/dist/llcsharp/schema/duration.js.map +1 -1
- package/dist/llcsharp/schema/enum.js +1 -0
- package/dist/llcsharp/schema/enum.js.map +1 -1
- package/dist/llcsharp/schema/integer.js +1 -0
- package/dist/llcsharp/schema/integer.js.map +1 -1
- package/dist/llcsharp/schema/object.js +1 -0
- package/dist/llcsharp/schema/object.js.map +1 -1
- package/dist/llcsharp/schema/password.js +2 -1
- package/dist/llcsharp/schema/password.js.map +1 -1
- package/dist/llcsharp/schema/primitive.js +1 -0
- package/dist/llcsharp/schema/primitive.js.map +1 -1
- package/dist/llcsharp/schema/schema-resolver.d.ts +2 -3
- package/dist/llcsharp/schema/schema-resolver.d.ts.map +1 -1
- package/dist/llcsharp/schema/schema-resolver.js +4 -0
- package/dist/llcsharp/schema/schema-resolver.js.map +1 -1
- package/dist/llcsharp/schema/string.d.ts.map +1 -1
- package/dist/llcsharp/schema/string.js +1 -0
- package/dist/llcsharp/schema/string.js.map +1 -1
- package/dist/llcsharp/schema/uri.d.ts +10 -0
- package/dist/llcsharp/schema/uri.d.ts.map +1 -0
- package/dist/llcsharp/schema/uri.js +25 -0
- package/dist/llcsharp/schema/uri.js.map +1 -0
- package/dist/llcsharp/validations.js +1 -0
- package/dist/llcsharp/validations.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +11 -0
- package/dist/main.js.map +1 -1
- package/dist/models/model-extensions.js +7 -6
- package/dist/models/model-extensions.js.map +1 -1
- package/dist/module/module-class.js +2 -1
- package/dist/module/module-class.js.map +1 -1
- package/dist/module/module-namespace.js +1 -0
- package/dist/module/module-namespace.js.map +1 -1
- package/dist/plugins/add-azure-completers-v2.js +1 -0
- package/dist/plugins/add-azure-completers-v2.js.map +1 -1
- package/dist/plugins/create-commands-v2.d.ts.map +1 -1
- package/dist/plugins/create-commands-v2.js +6 -4
- package/dist/plugins/create-commands-v2.js.map +1 -1
- package/dist/plugins/cs-namer-v2.js +4 -3
- package/dist/plugins/cs-namer-v2.js.map +1 -1
- package/dist/plugins/llcsharp-v2.js +1 -0
- package/dist/plugins/llcsharp-v2.js.map +1 -1
- package/dist/plugins/modifiers-v2.d.ts +4 -0
- package/dist/plugins/modifiers-v2.d.ts.map +1 -1
- package/dist/plugins/modifiers-v2.js +69 -13
- package/dist/plugins/modifiers-v2.js.map +1 -1
- package/dist/plugins/plugin-create-inline-properties.d.ts.map +1 -1
- package/dist/plugins/plugin-create-inline-properties.js +16 -1
- package/dist/plugins/plugin-create-inline-properties.js.map +1 -1
- package/dist/plugins/plugin-tweak-m4-model.js +4 -3
- package/dist/plugins/plugin-tweak-m4-model.js.map +1 -1
- package/dist/plugins/plugin-tweak-model-azure-v2.js +4 -3
- package/dist/plugins/plugin-tweak-model-azure-v2.js.map +1 -1
- package/dist/plugins/plugin-tweak-model.js +15 -14
- package/dist/plugins/plugin-tweak-model.js.map +1 -1
- package/dist/plugins/powershell-v2.d.ts.map +1 -1
- package/dist/plugins/powershell-v2.js +8 -2
- package/dist/plugins/powershell-v2.js.map +1 -1
- package/dist/plugins/ps-namer-v2.js +1 -0
- package/dist/plugins/ps-namer-v2.js.map +1 -1
- package/dist/plugins/sdk-create-inline-properties.d.ts +4 -0
- package/dist/plugins/sdk-create-inline-properties.d.ts.map +1 -0
- package/dist/plugins/sdk-create-inline-properties.js +552 -0
- package/dist/plugins/sdk-create-inline-properties.js.map +1 -0
- package/dist/plugins/sdk-cs-namer.d.ts +3 -0
- package/dist/plugins/sdk-cs-namer.d.ts.map +1 -0
- package/dist/plugins/sdk-cs-namer.js +385 -0
- package/dist/plugins/sdk-cs-namer.js.map +1 -0
- package/dist/plugins/sdk-cs-simplifier.d.ts +3 -0
- package/dist/plugins/sdk-cs-simplifier.d.ts.map +1 -0
- package/dist/plugins/sdk-cs-simplifier.js +154 -0
- package/dist/plugins/sdk-cs-simplifier.js.map +1 -0
- package/dist/plugins/sdk-generate.d.ts +3 -0
- package/dist/plugins/sdk-generate.d.ts.map +1 -0
- package/dist/plugins/sdk-generate.js +106 -0
- package/dist/plugins/sdk-generate.js.map +1 -0
- package/dist/plugins/sdk-tweak-model.d.ts +3 -0
- package/dist/plugins/sdk-tweak-model.d.ts.map +1 -0
- package/dist/plugins/sdk-tweak-model.js +357 -0
- package/dist/plugins/sdk-tweak-model.js.map +1 -0
- package/dist/sdk/project.d.ts +45 -0
- package/dist/sdk/project.d.ts.map +1 -0
- package/dist/sdk/project.js +56 -0
- package/dist/sdk/project.js.map +1 -0
- package/dist/sdk/state.d.ts +23 -0
- package/dist/sdk/state.d.ts.map +1 -0
- package/dist/sdk/state.js +28 -0
- package/dist/sdk/state.js.map +1 -0
- package/dist/sdk/utility.d.ts +32 -0
- package/dist/sdk/utility.d.ts.map +1 -0
- package/dist/sdk/utility.js +414 -0
- package/dist/sdk/utility.js.map +1 -0
- package/dist/utils/PwshModel.js +1 -0
- package/dist/utils/PwshModel.js.map +1 -1
- package/dist/utils/SdkModel.d.ts +7 -0
- package/dist/utils/SdkModel.d.ts.map +1 -0
- package/dist/utils/SdkModel.js +17 -0
- package/dist/utils/SdkModel.js.map +1 -0
- package/dist/utils/TrieNode.d.ts +10 -0
- package/dist/utils/TrieNode.d.ts.map +1 -0
- package/dist/utils/TrieNode.js +45 -0
- package/dist/utils/TrieNode.js.map +1 -0
- package/dist/utils/WrapComments.d.ts +2 -0
- package/dist/utils/WrapComments.d.ts.map +1 -0
- package/dist/utils/WrapComments.js +46 -0
- package/dist/utils/WrapComments.js.map +1 -0
- package/dist/utils/code-namer.d.ts +3 -0
- package/dist/utils/code-namer.d.ts.map +1 -0
- package/dist/utils/code-namer.js +38 -0
- package/dist/utils/code-namer.js.map +1 -0
- package/dist/utils/command-operation.d.ts +1 -0
- package/dist/utils/command-operation.d.ts.map +1 -1
- package/dist/utils/command-operation.js +2 -2
- package/dist/utils/command-operation.js.map +1 -1
- package/dist/utils/components.d.ts +2 -0
- package/dist/utils/components.d.ts.map +1 -1
- package/dist/utils/components.js +1 -0
- package/dist/utils/components.js.map +1 -1
- package/dist/utils/extensions.js +1 -0
- package/dist/utils/extensions.js.map +1 -1
- package/dist/utils/http-definitions.js +1 -0
- package/dist/utils/http-definitions.js.map +1 -1
- package/dist/utils/http-operation.js +1 -0
- package/dist/utils/http-operation.js.map +1 -1
- package/dist/utils/info.js +1 -0
- package/dist/utils/info.js.map +1 -1
- package/dist/utils/model-state.js +1 -0
- package/dist/utils/model-state.js.map +1 -1
- package/dist/utils/powershell-comment.js +11 -10
- package/dist/utils/powershell-comment.js.map +1 -1
- package/dist/utils/programatic-operation.js +2 -2
- package/dist/utils/programatic-operation.js.map +1 -1
- package/dist/utils/resolve-conflicts.js +1 -0
- package/dist/utils/resolve-conflicts.js.map +1 -1
- package/dist/utils/schema.d.ts +4 -0
- package/dist/utils/schema.d.ts.map +1 -1
- package/dist/utils/schema.js +28 -0
- package/dist/utils/schema.js.map +1 -1
- package/dist/utils/security-scheme.js +1 -0
- package/dist/utils/security-scheme.js.map +1 -1
- package/dist/utils/uid.js +1 -0
- package/dist/utils/uid.js.map +1 -1
- package/package.json +6 -5
- package/readme.md +5 -1
- package/resources/assets/build-module.ps1 +9 -1
- package/resources/assets/create-model-cmdlets.ps1 +8 -5
- package/resources/assets/custom/README.md +1 -1
- package/resources/assets/docs/README.md +1 -1
- package/resources/assets/exports/README.md +1 -1
- package/resources/assets/generate-portal-ux.ps1 +379 -0
- package/resources/assets/how-to.md +1 -1
- package/resources/assets/internal/README.md +1 -1
- package/resources/assets/tools/Resources/docs/README.md +1 -1
- package/resources/assets/tools/Resources/how-to.md +1 -1
- package/resources/modules/Az.Accounts/2.7.5/Az.Accounts.nuspec +1 -1
- package/resources/modules/Az.Accounts/2.7.5/Az.Accounts.psd1 +1 -1
- package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.Cmdlets.Accounts.dll-Help.xml +34 -34
- package/resources/modules/Az.Accounts/2.7.5/en-US/about_az.help.txt +1 -1
- package/resources/modules/Az.Accounts/2.7.5/package/services/metadata/core-properties/1aa0749a068a4238881858013f1a5b7f.psmdcp +1 -1
- package/resources/psruntime/Attributes/ExternalDocsAttribute.cs +30 -0
- package/resources/psruntime/BuildTime/Models/PsMarkdownTypes.cs +39 -4
- package/resources/psruntime/BuildTime/Models/PsProxyOutputs.cs +8 -2
- package/resources/psruntime/BuildTime/Models/PsProxyTypes.cs +6 -0
- package/resources/psruntime/BuildTime/PsAttributes.cs +7 -0
- package/resources/runtime/csharp/client/Context.cs +33 -0
- package/resources/runtime/csharp/client/InfoAttribute.cs +1 -0
- package/resources/runtime/csharp/client/InputHandler.cs +22 -0
- package/resources/runtime/csharp/pipeline/Events.cs +2 -2
- package/resources/templates/azureMethod.ejs +5 -0
- package/resources/templates/azureMethodGroup.ejs +46 -0
- package/resources/templates/azureServiceClient.ejs +80 -0
- package/resources/templates/enum.ejs +73 -0
- package/resources/templates/exception.ejs +52 -0
- package/resources/templates/extensionMethod.ejs +68 -0
- package/resources/templates/extensions.ejs +19 -0
- package/resources/templates/longRunningOperationMethod.ejs +43 -0
- package/resources/templates/method.ejs +65 -0
- package/resources/templates/methodBodyRestCall.ejs +317 -0
- package/resources/templates/methodGroupInterface.ejs +77 -0
- package/resources/templates/model.ejs +184 -0
- package/resources/templates/page.ejs +40 -0
- package/resources/templates/serviceClientBody.ejs +303 -0
- package/resources/templates/serviceClientInterface.ejs +55 -0
package/dist/cmdlets/class.js
CHANGED
|
@@ -4,8 +4,11 @@
|
|
|
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;
|
|
8
|
+
const ejs = require('ejs');
|
|
7
9
|
const codemodel_1 = require("@azure-tools/codemodel");
|
|
8
10
|
const codemodel_v3_1 = require("@azure-tools/codemodel-v3");
|
|
11
|
+
const command_operation_1 = require("../utils/command-operation");
|
|
9
12
|
const schema_1 = require("../utils/schema");
|
|
10
13
|
const codegen_1 = require("@azure-tools/codegen");
|
|
11
14
|
const linq_1 = require("@azure-tools/linq");
|
|
@@ -159,7 +162,7 @@ function NewAddCompleterInfo(targetProperty, parameter) {
|
|
|
159
162
|
exports.NewAddCompleterInfo = NewAddCompleterInfo;
|
|
160
163
|
function addParameterBreakingChange(targetProperty, parameter) {
|
|
161
164
|
if (parameter.breakingChange) {
|
|
162
|
-
|
|
165
|
+
const parameters = [];
|
|
163
166
|
parameters.push(`"${parameter.breakingChange.parameterName}"`);
|
|
164
167
|
if (parameter.breakingChange.deprecateByVersion) {
|
|
165
168
|
parameters.push(`"${parameter.breakingChange.deprecateByVersion}"`);
|
|
@@ -179,7 +182,7 @@ function addParameterBreakingChange(targetProperty, parameter) {
|
|
|
179
182
|
}
|
|
180
183
|
else {
|
|
181
184
|
// for primitive types, should use name, otherwise use fullname which contains namespace
|
|
182
|
-
parameters.push(`OldParamaterType="${parameter.schema.language.csharp.fullname.startsWith(
|
|
185
|
+
parameters.push(`OldParamaterType="${parameter.schema.language.csharp.fullname.startsWith('<') ? parameter.schema.language.csharp.name : parameter.schema.language.csharp.fullname}"`);
|
|
183
186
|
}
|
|
184
187
|
parameters.push(`NewParameterType="${parameter.breakingChange.newParameterType}"`);
|
|
185
188
|
}
|
|
@@ -201,7 +204,8 @@ function addDefaultInfo(targetProperty, parameter) {
|
|
|
201
204
|
parameters: [
|
|
202
205
|
new codegen_csharp_1.LiteralExpression(`\nName = ${new codegen_csharp_1.StringExpression(parameter.defaultInfo.name || '').value}`),
|
|
203
206
|
new codegen_csharp_1.LiteralExpression(`\nDescription =${new codegen_csharp_1.StringExpression(parameter.defaultInfo.description || '').value}`),
|
|
204
|
-
new codegen_csharp_1.LiteralExpression(`\nScript = ${new codegen_csharp_1.StringExpression(parameter.defaultInfo.script).value}`)
|
|
207
|
+
new codegen_csharp_1.LiteralExpression(`\nScript = ${new codegen_csharp_1.StringExpression(parameter.defaultInfo.script).value}`),
|
|
208
|
+
new codegen_csharp_1.LiteralExpression(`\nSetCondition = ${new codegen_csharp_1.StringExpression(parameter.defaultInfo['set-condition'] || '').value}`)
|
|
205
209
|
]
|
|
206
210
|
}));
|
|
207
211
|
}
|
|
@@ -321,6 +325,7 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
321
325
|
this.variantName = variantName;
|
|
322
326
|
this.hasStreamOutput = false;
|
|
323
327
|
this.interfaces.push(exports_1.ClientRuntime.IEventListener);
|
|
328
|
+
this.interfaces.push(exports_1.ClientRuntime.IContext);
|
|
324
329
|
this.eventListener = new exports_1.EventListener(new codegen_csharp_1.LiteralExpression(`((${exports_1.ClientRuntime.IEventListener})this)`), true);
|
|
325
330
|
this.isViaIdentity = variantName.indexOf('ViaIdentity') > 0;
|
|
326
331
|
this.clientsidePagination = !!operation.details.csharp.clientsidePagination && !!((_a = operation.callGraph[0].language.csharp) === null || _a === void 0 ? void 0 : _a.pageable);
|
|
@@ -337,7 +342,7 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
337
342
|
*body() {
|
|
338
343
|
if ($this.state.project.azure) {
|
|
339
344
|
yield `var telemetryId = ${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.GetTelemetryId.Invoke();`;
|
|
340
|
-
yield codegen_csharp_1.If('telemetryId != "" && telemetryId != "internal"',
|
|
345
|
+
yield codegen_csharp_1.If('telemetryId != "" && telemetryId != "internal"', '__correlationId = telemetryId;');
|
|
341
346
|
}
|
|
342
347
|
yield 'Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials);';
|
|
343
348
|
yield codegen_csharp_1.If($this.$('Break'), `${exports_1.ClientRuntime.AttachDebugger}.Break();`);
|
|
@@ -355,6 +360,8 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
355
360
|
this.NewAddPowershellParameters(this.operation);
|
|
356
361
|
// implement IEventListener
|
|
357
362
|
this.implementIEventListener();
|
|
363
|
+
// implement part of the IContext
|
|
364
|
+
this.implementIContext();
|
|
358
365
|
// add constructors
|
|
359
366
|
this.implementConstructors();
|
|
360
367
|
// processRecord
|
|
@@ -379,8 +386,8 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
379
386
|
if (!request) {
|
|
380
387
|
continue;
|
|
381
388
|
}
|
|
382
|
-
const httpMethod = (_c = (_b = request.protocol.http) === null || _b === void 0 ? void 0 : _b.method
|
|
383
|
-
const httpPath = (_e = (_d = request.protocol.http) === null || _d === void 0 ? void 0 : _d.path
|
|
389
|
+
const httpMethod = (_c = (_b = request.protocol.http) === null || _b === void 0 ? void 0 : _b.method) !== null && _c !== void 0 ? _c : '';
|
|
390
|
+
const httpPath = (_e = (_d = request.protocol.http) === null || _d === void 0 ? void 0 : _d.path) !== null && _e !== void 0 ? _e : '';
|
|
384
391
|
ops = `${ops}\n[OpenAPI] ${httpOperation.language.default.name}=>${httpMethod.toUpperCase()}:"${httpPath}"`;
|
|
385
392
|
if (this.debugMode) {
|
|
386
393
|
// x-ms-metadata seems no longer exists
|
|
@@ -410,7 +417,7 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
410
417
|
this.processRecordId = this.add(new codegen_csharp_1.Field('__processRecordId', codegen_csharp_1.dotnet.String, { description: 'A unique id generatd for the this cmdlet when ProcessRecord() is called.', access: codegen_csharp_1.Access.Private }));
|
|
411
418
|
}
|
|
412
419
|
// pipeline property
|
|
413
|
-
this.add(new codegen_csharp_1.Property('Pipeline', exports_1.ClientRuntime.HttpPipeline, { getAccess: codegen_csharp_1.Access.
|
|
420
|
+
this.add(new codegen_csharp_1.Property('Pipeline', exports_1.ClientRuntime.HttpPipeline, { getAccess: codegen_csharp_1.Access.Public, setAccess: codegen_csharp_1.Access.Public, description: `The instance of the <see cref="${exports_1.ClientRuntime.HttpPipeline}" /> that the remote call will use.` }));
|
|
414
421
|
// client API property (gs01: fill this in correctly)
|
|
415
422
|
const clientAPI = new codegen_csharp_1.ClassType((_a = this.state.model.language.csharp) === null || _a === void 0 ? void 0 : _a.namespace, ((_b = this.state.model.language.csharp) === null || _b === void 0 ? void 0 : _b.name) || '');
|
|
416
423
|
this.add(new codegen_csharp_1.LambdaProperty('Client', clientAPI, new codegen_csharp_1.LiteralExpression(`${this.state.project.serviceNamespace.moduleClass.declaration}.Instance.ClientAPI`), { description: 'The reference to the client API class.' }));
|
|
@@ -562,14 +569,37 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
562
569
|
yield $this.eventListener.signal(powershell_declarations_1.Events.CmdletGetPipeline);
|
|
563
570
|
const pipeline = $this.$('Pipeline');
|
|
564
571
|
if ($this.state.project.azure) {
|
|
565
|
-
yield pipeline.assign(new codegen_csharp_1.LiteralExpression(`${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.CreatePipeline(${$this.invocationInfo}, ${$this.correlationId}, ${$this.processRecordId}, this.ParameterSetName)`));
|
|
572
|
+
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)`));
|
|
566
573
|
}
|
|
567
574
|
else {
|
|
568
|
-
yield pipeline.assign(new codegen_csharp_1.LiteralExpression(`${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.CreatePipeline(${$this.invocationInfo}, this.ParameterSetName)`));
|
|
575
|
+
yield pipeline.assign(new codegen_csharp_1.LiteralExpression(`${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.CreatePipeline(${$this.invocationInfo}, this.ParameterSetName, this.ExtensibleParameters)`));
|
|
569
576
|
}
|
|
570
577
|
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')}`)));
|
|
571
578
|
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')}`)));
|
|
572
579
|
yield '// get the client instance';
|
|
580
|
+
// Add input pipeline if it is configured by developers.
|
|
581
|
+
if ($this.operation.extensions.inputPipe) {
|
|
582
|
+
const handlers = $this.operation.extensions.inputPipe;
|
|
583
|
+
// default priority is 100
|
|
584
|
+
handlers.sort((a, b) => { return (a.priority || 100) - (b.priority || 100); });
|
|
585
|
+
for (const { index, handler } of handlers.map((handler, index) => ({ index, handler }))) {
|
|
586
|
+
yield `var handler_${index} = new ${handler.name}();`;
|
|
587
|
+
if (index > 0) {
|
|
588
|
+
yield `handler_${index - 1}.SetNextHandler(handler_${index});`;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
yield 'handler_0.Process(this);';
|
|
592
|
+
}
|
|
593
|
+
const vps = $this.operation.details.csharp.virtualParameters || {
|
|
594
|
+
body: [],
|
|
595
|
+
operation: [],
|
|
596
|
+
};
|
|
597
|
+
for (const vParam of [...vps.body, ...vps.operation]) {
|
|
598
|
+
if (vParam.hidden) {
|
|
599
|
+
const td = $this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(vParam.schema, true, $this.state);
|
|
600
|
+
yield codegen_csharp_1.If(`true == this.MyInvocation?.BoundParameters?.ContainsKey("${vParam.name}")`, `${vParam.name} = (${td.declaration})this.MyInvocation.BoundParameters["${vParam.name}"];`);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
573
603
|
const apiCall = operation.callGraph[0];
|
|
574
604
|
// find each parameter to the method, and find out where the value is going to come from.
|
|
575
605
|
const operationParameters = linq_1.values(apiCall.parameters).
|
|
@@ -625,7 +655,7 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
625
655
|
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` }));
|
|
626
656
|
}
|
|
627
657
|
if (isBinary) {
|
|
628
|
-
parameters.push(new codegen_csharp_1.Parameter('response', codegen_csharp_1.System.Threading.Tasks.Task({ declaration: 'global::System.IO.Stream' }), { description:
|
|
658
|
+
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' }));
|
|
629
659
|
}
|
|
630
660
|
const override = `override${codegen_1.pascalCase(((_f = each.language.csharp) === null || _f === void 0 ? void 0 : _f.name) || '')}`;
|
|
631
661
|
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 )` });
|
|
@@ -727,15 +757,15 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
727
757
|
const vp = schema_1.getVirtualPropertyFromPropertyName((_m = schema.language.csharp) === null || _m === void 0 ? void 0 : _m.virtualProperties, valueProperty.serializedName);
|
|
728
758
|
if (vp) {
|
|
729
759
|
if ($this.clientsidePagination) {
|
|
730
|
-
yield (codegen_csharp_1.If(
|
|
731
|
-
yield (
|
|
760
|
+
yield (codegen_csharp_1.If('(ulong)result.Value.Length <= this.PagingParameters.Skip', function* () {
|
|
761
|
+
yield ('this.PagingParameters.Skip = this.PagingParameters.Skip - (ulong)result.Value.Length;');
|
|
732
762
|
}));
|
|
733
763
|
yield codegen_csharp_1.Else(function* () {
|
|
734
|
-
yield (
|
|
735
|
-
yield (
|
|
736
|
-
yield (
|
|
737
|
-
yield (
|
|
738
|
-
yield (
|
|
764
|
+
yield ('ulong toRead = Math.Min(this.PagingParameters.First, (ulong)result.Value.Length - this.PagingParameters.Skip);');
|
|
765
|
+
yield ('var requiredResult = result.Value.SubArray((int)this.PagingParameters.Skip, (int)toRead);');
|
|
766
|
+
yield ('WriteObject(requiredResult, true);');
|
|
767
|
+
yield ('this.PagingParameters.Skip = 0;');
|
|
768
|
+
yield ('this.PagingParameters.First = this.PagingParameters.First <= toRead ? 0 : this.PagingParameters.First - toRead;');
|
|
739
769
|
});
|
|
740
770
|
}
|
|
741
771
|
else {
|
|
@@ -746,18 +776,18 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
746
776
|
if (nl) {
|
|
747
777
|
$this.add(new codegen_csharp_1.Field('_isFirst', codegen_csharp_1.dotnet.Bool, {
|
|
748
778
|
access: codegen_csharp_1.Access.Private,
|
|
749
|
-
initialValue: new codegen_csharp_1.LiteralExpression(
|
|
750
|
-
description:
|
|
779
|
+
initialValue: new codegen_csharp_1.LiteralExpression('true'),
|
|
780
|
+
description: 'A flag to tell whether it is the first onOK call.'
|
|
751
781
|
}));
|
|
752
782
|
$this.add(new codegen_csharp_1.Field('_nextLink', codegen_csharp_1.dotnet.String, {
|
|
753
783
|
access: codegen_csharp_1.Access.Private,
|
|
754
|
-
description:
|
|
784
|
+
description: 'Link to retrieve next page.'
|
|
755
785
|
}));
|
|
756
786
|
const nextLinkName = `${result.value}.${nl.name}`;
|
|
757
787
|
yield `_nextLink = ${nextLinkName};`;
|
|
758
|
-
|
|
759
|
-
yield (codegen_csharp_1.If(
|
|
760
|
-
yield
|
|
788
|
+
const nextLinkCondition = $this.clientsidePagination ? '_nextLink != null && this.PagingParameters.First > 0' : '_nextLink != null';
|
|
789
|
+
yield (codegen_csharp_1.If('_isFirst', function* () {
|
|
790
|
+
yield '_isFirst = false;';
|
|
761
791
|
yield (codegen_csharp_1.While(nextLinkCondition, codegen_csharp_1.If('responseMessage.RequestMessage is System.Net.Http.HttpRequestMessage requestMessage ', function* () {
|
|
762
792
|
var _a;
|
|
763
793
|
yield `requestMessage = requestMessage.Clone(new global::System.Uri( _nextLink ),${exports_1.ClientRuntime.Method.Get} );`;
|
|
@@ -823,21 +853,21 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
823
853
|
}
|
|
824
854
|
// in m4, there will be no schema deinfed for the binary response, instead, we will have a field called binary with value true.
|
|
825
855
|
if ('binary' in each) {
|
|
826
|
-
yield
|
|
856
|
+
yield '// (await response) // should be global::System.IO.Stream';
|
|
827
857
|
if ($this.hasStreamOutput && $this.outFileParameter) {
|
|
828
858
|
const outfile = $this.outFileParameter;
|
|
829
859
|
const provider = codegen_csharp_2.Local('provider');
|
|
830
860
|
provider.initializer = undefined;
|
|
831
|
-
const paths = codegen_csharp_2.Local('paths',
|
|
861
|
+
const paths = codegen_csharp_2.Local('paths', 'new global::System.Collections.ObjectModel.Collection<global::System.String>()');
|
|
832
862
|
yield paths.declarationStatement;
|
|
833
863
|
yield codegen_csharp_1.Try(function* () {
|
|
834
864
|
yield `${paths.value} = this.SessionState.Path.GetResolvedProviderPathFromPSPath(${outfile.value}, out ${provider.declarationExpression});`;
|
|
835
865
|
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}) );`);
|
|
836
866
|
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}) );`);
|
|
837
867
|
});
|
|
838
|
-
const notfound = new codegen_csharp_1.Parameter('', { declaration:
|
|
868
|
+
const notfound = new codegen_csharp_1.Parameter('', { declaration: 'global::System.Management.Automation.ItemNotFoundException' });
|
|
839
869
|
yield codegen_csharp_1.Catch(notfound, function* () {
|
|
840
|
-
yield
|
|
870
|
+
yield '// If the file does not exist, we will try to create it';
|
|
841
871
|
yield `${paths.value}.Add(${outfile.value});`;
|
|
842
872
|
});
|
|
843
873
|
// this is a stream output. write to outfile
|
|
@@ -867,6 +897,15 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
867
897
|
yield $this.eventListener.signal(powershell_declarations_1.Events.CmdletBeforeAPICall);
|
|
868
898
|
const idOpParams = operationParameters.filter(each => !each.isPathParam);
|
|
869
899
|
const idschema = linq_1.values($this.state.project.model.schemas.objects).first(each => each.language.default.uid === 'universal-parameter-type');
|
|
900
|
+
let serializationMode = null;
|
|
901
|
+
if ($this.bodyParameter) {
|
|
902
|
+
if ($this.operation.operationType === command_operation_1.OperationType.Create) {
|
|
903
|
+
serializationMode = exports_1.ClientRuntime.SerializationMode.IncludeCreate;
|
|
904
|
+
}
|
|
905
|
+
else if ($this.operation.operationType === command_operation_1.OperationType.Update) {
|
|
906
|
+
serializationMode = exports_1.ClientRuntime.SerializationMode.IncludeUpdate;
|
|
907
|
+
}
|
|
908
|
+
}
|
|
870
909
|
if ($this.isViaIdentity) {
|
|
871
910
|
const identityFromPathParams = function* () {
|
|
872
911
|
var _a, _b;
|
|
@@ -895,10 +934,10 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
895
934
|
};
|
|
896
935
|
}
|
|
897
936
|
// fall back!
|
|
898
|
-
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
|
|
937
|
+
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 : '')}').`);
|
|
899
938
|
return {
|
|
900
|
-
name: `InputObject.${codegen_1.pascalCase((_d = (_c = match.language.csharp) === null || _c === void 0 ? void 0 : _c.name
|
|
901
|
-
value: `InputObject.${codegen_1.pascalCase((_f = (_e = match.language.csharp) === null || _e === void 0 ? void 0 : _e.name
|
|
939
|
+
name: `InputObject.${codegen_1.pascalCase((_d = (_c = match.language.csharp) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : '')}`,
|
|
940
|
+
value: `InputObject.${codegen_1.pascalCase((_f = (_e = match.language.csharp) === null || _e === void 0 ? void 0 : _e.name) !== null && _f !== void 0 ? _f : '')} ?? ${defaultOfType}`
|
|
902
941
|
};
|
|
903
942
|
}
|
|
904
943
|
console.error(`Unable to match idenity parameter '${each.name}' member to appropriate virtual parameter. (Guessing '${pascalName}')`);
|
|
@@ -916,7 +955,11 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
916
955
|
}
|
|
917
956
|
};
|
|
918
957
|
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'; })) {
|
|
919
|
-
|
|
958
|
+
const parameters = [codegen_csharp_1.toExpression('InputObject.Id'), ...idOpParams.map(each => each.expression), ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline];
|
|
959
|
+
if (serializationMode) {
|
|
960
|
+
parameters.push(serializationMode);
|
|
961
|
+
}
|
|
962
|
+
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}`);
|
|
920
963
|
yield codegen_csharp_1.Else(identityFromPathParams);
|
|
921
964
|
}
|
|
922
965
|
else {
|
|
@@ -924,7 +967,11 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
924
967
|
}
|
|
925
968
|
}
|
|
926
969
|
else {
|
|
927
|
-
|
|
970
|
+
const parameters = [...operationParameters.map(each => each.expression), ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline];
|
|
971
|
+
if (serializationMode) {
|
|
972
|
+
parameters.push(serializationMode);
|
|
973
|
+
}
|
|
974
|
+
yield `await this.${$this.$('Client').invokeMethod(`${(_b = apiCall.language.csharp) === null || _b === void 0 ? void 0 : _b.name}`, ...parameters).implementation}`;
|
|
928
975
|
}
|
|
929
976
|
yield $this.eventListener.signal(powershell_declarations_1.Events.CmdletAfterAPICall);
|
|
930
977
|
};
|
|
@@ -984,6 +1031,16 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
984
1031
|
// default constructor
|
|
985
1032
|
this.add(new codegen_csharp_1.Constructor(this, { description: `Intializes a new instance of the <see cref="${this.name}" /> cmdlet class.` }));
|
|
986
1033
|
}
|
|
1034
|
+
implementIContext() {
|
|
1035
|
+
const extensibleParameters = this.add(new codegen_csharp_1.Field('_extensibleParameters', codegen_csharp_1.System.Collections.Generic.Dictionary(codegen_csharp_1.System.String, codegen_csharp_1.System.Object), {
|
|
1036
|
+
access: codegen_csharp_1.Access.Private,
|
|
1037
|
+
initialValue: new codegen_csharp_1.LiteralExpression('new System.Collections.Generic.Dictionary<string, object>()'),
|
|
1038
|
+
description: 'A dictionary to carry over additional data for pipeline.'
|
|
1039
|
+
}));
|
|
1040
|
+
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.' });
|
|
1041
|
+
extensibleParametersProp.get = codegen_csharp_1.toExpression(`${extensibleParameters.value} `);
|
|
1042
|
+
this.add(extensibleParametersProp);
|
|
1043
|
+
}
|
|
987
1044
|
implementIEventListener() {
|
|
988
1045
|
const $this = this;
|
|
989
1046
|
const cts = this.add(new codegen_csharp_1.Field('_cancellationTokenSource', codegen_csharp_1.System.Threading.CancellationTokenSource, {
|
|
@@ -991,6 +1048,10 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
991
1048
|
initialValue: new codegen_csharp_1.LiteralExpression(`new ${codegen_csharp_1.System.Threading.CancellationTokenSource.declaration}()`),
|
|
992
1049
|
description: `The <see cref="${codegen_csharp_1.System.Threading.CancellationTokenSource}" /> for this operation.`
|
|
993
1050
|
}));
|
|
1051
|
+
const cancellationTokenSource = new codegen_csharp_1.Property('CancellationTokenSource', codegen_csharp_1.System.Threading.CancellationTokenSource, { description: 'Accessor for cancellationTokenSource.' });
|
|
1052
|
+
cancellationTokenSource.get = codegen_csharp_1.toExpression(`${cts.value} `);
|
|
1053
|
+
cancellationTokenSource.set = new codegen_csharp_1.Statements(cts.assign('value'));
|
|
1054
|
+
this.add(cancellationTokenSource);
|
|
994
1055
|
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.` }));
|
|
995
1056
|
this.cancellationToken = codegen_csharp_1.toExpression(`((${exports_1.ClientRuntime.IEventListener})this).Token`);
|
|
996
1057
|
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.` }));
|
|
@@ -1037,12 +1098,37 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1037
1098
|
yield 'WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) );';
|
|
1038
1099
|
yield codegen_csharp_1.Return();
|
|
1039
1100
|
}),
|
|
1101
|
+
codegen_csharp_1.TerminalCase(powershell_declarations_1.Events.Progress.value, function* () {
|
|
1102
|
+
yield 'var data = messageData();';
|
|
1103
|
+
yield 'int progress = (int)data.Value;';
|
|
1104
|
+
yield 'string activityMessage, statusDescription;';
|
|
1105
|
+
yield 'global::System.Management.Automation.ProgressRecordType recordType;';
|
|
1106
|
+
yield 'if (progress < 100)';
|
|
1107
|
+
yield '{';
|
|
1108
|
+
yield ' activityMessage = "In progress";';
|
|
1109
|
+
yield ' statusDescription = "Checking operation status";';
|
|
1110
|
+
yield ' recordType = System.Management.Automation.ProgressRecordType.Processing;';
|
|
1111
|
+
yield '}';
|
|
1112
|
+
yield 'else';
|
|
1113
|
+
yield '{';
|
|
1114
|
+
yield ' activityMessage = "Completed";';
|
|
1115
|
+
yield ' statusDescription = "Completed";';
|
|
1116
|
+
yield ' recordType = System.Management.Automation.ProgressRecordType.Completed;';
|
|
1117
|
+
yield '}';
|
|
1118
|
+
// hardcode id = 1 because there is no need for nested progress bar
|
|
1119
|
+
yield 'WriteProgress(new global::System.Management.Automation.ProgressRecord(1, activityMessage, statusDescription)';
|
|
1120
|
+
yield '{';
|
|
1121
|
+
yield ' PercentComplete = progress,';
|
|
1122
|
+
yield 'RecordType = recordType';
|
|
1123
|
+
yield '});';
|
|
1124
|
+
yield codegen_csharp_1.Return();
|
|
1125
|
+
}),
|
|
1040
1126
|
]);
|
|
1041
1127
|
if ($this.operation.asjob) {
|
|
1042
1128
|
// if we support -AsJob, we support -NoWait
|
|
1043
1129
|
sw.add(codegen_csharp_1.Case(powershell_declarations_1.Events.DelayBeforePolling.value, function* () {
|
|
1130
|
+
yield 'var data = messageData();';
|
|
1044
1131
|
yield codegen_csharp_1.If('true == MyInvocation?.BoundParameters?.ContainsKey("NoWait")', function* () {
|
|
1045
|
-
yield 'var data = messageData();';
|
|
1046
1132
|
yield 'if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response)';
|
|
1047
1133
|
yield '{';
|
|
1048
1134
|
yield ' var asyncOperation = response.GetFirstHeader(@"Azure-AsyncOperation");';
|
|
@@ -1054,6 +1140,22 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1054
1140
|
yield ' return;';
|
|
1055
1141
|
yield '}';
|
|
1056
1142
|
});
|
|
1143
|
+
yield codegen_csharp_1.Else(function* () {
|
|
1144
|
+
yield 'if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response)';
|
|
1145
|
+
yield '{';
|
|
1146
|
+
yield ' int delay = (int)(response.Headers.RetryAfter?.Delta?.TotalSeconds ?? 30);';
|
|
1147
|
+
yield ' WriteDebug($"Delaying {delay} seconds before polling.");';
|
|
1148
|
+
yield ' for (var now = 0; now < delay; ++now)';
|
|
1149
|
+
yield ' {';
|
|
1150
|
+
// hardcode id = 1 because there is no need for nested progress bar
|
|
1151
|
+
yield ' WriteProgress(new global::System.Management.Automation.ProgressRecord(1, "In progress", "Checking operation status")';
|
|
1152
|
+
yield ' {';
|
|
1153
|
+
yield ' PercentComplete = now * 100 / delay';
|
|
1154
|
+
yield ' });';
|
|
1155
|
+
yield ` await global::System.Threading.Tasks.Task.Delay(1000, ${token.use});`;
|
|
1156
|
+
yield ' }';
|
|
1157
|
+
yield '}';
|
|
1158
|
+
});
|
|
1057
1159
|
}));
|
|
1058
1160
|
}
|
|
1059
1161
|
// the whole switch statement
|
|
@@ -1124,7 +1226,7 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1124
1226
|
}
|
|
1125
1227
|
if (this.dropBodyParameter && parameter.details.csharp.isBodyParameter) {
|
|
1126
1228
|
// we're supposed to use parameters for the body parameter instead of a big object
|
|
1127
|
-
const expandedBodyParameter = this.add(new codegen_csharp_1.Field(
|
|
1229
|
+
const expandedBodyParameter = this.add(new codegen_csharp_1.Field('_' + codegen_1.camelCase(parameter.details.csharp.name), td, {
|
|
1128
1230
|
description: parameter.details.csharp.description,
|
|
1129
1231
|
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}()`,
|
|
1130
1232
|
access: codegen_csharp_1.Access.Private
|
|
@@ -1210,7 +1312,6 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1210
1312
|
this.addDoNotExport(cmdletParameter, vParam);
|
|
1211
1313
|
}
|
|
1212
1314
|
const isEnum = propertyType instanceof exports_1.EnumImplementation;
|
|
1213
|
-
;
|
|
1214
1315
|
const hasEnum = propertyType instanceof exports_1.ArrayOf && propertyType.elementType instanceof exports_1.EnumImplementation;
|
|
1215
1316
|
if (isEnum || hasEnum) {
|
|
1216
1317
|
cmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ArgumentCompleterAttribute, { parameters: [`typeof(${hasEnum ? propertyType.elementType.declaration : propertyType.declaration})`] }));
|
|
@@ -1268,52 +1369,65 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1268
1369
|
// skip 'Host'
|
|
1269
1370
|
continue;
|
|
1270
1371
|
}
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
//
|
|
1276
|
-
this.add(new codegen_csharp_1.BackedProperty(vParam.name, codegen_csharp_1.
|
|
1277
|
-
metadata: {
|
|
1278
|
-
parameterDefinition: origin.details.csharp.httpParameter
|
|
1279
|
-
},
|
|
1280
|
-
description: vParam.description
|
|
1281
|
-
})) :
|
|
1282
|
-
// everything else
|
|
1283
|
-
this.add(new codegen_csharp_1.BackedProperty(vParam.name, propertyType, {
|
|
1284
|
-
metadata: {
|
|
1285
|
-
parameterDefinition: origin.details.csharp.httpParameter
|
|
1286
|
-
},
|
|
1372
|
+
let regularCmdletParameter;
|
|
1373
|
+
let origin = null;
|
|
1374
|
+
let propertyType = null;
|
|
1375
|
+
if (vParam.type) {
|
|
1376
|
+
// Handle parameters added through directives
|
|
1377
|
+
regularCmdletParameter = this.add(new codegen_csharp_1.BackedProperty(vParam.name, new codegen_csharp_1.ClassType('', vParam.type), {
|
|
1287
1378
|
description: vParam.description
|
|
1288
1379
|
}));
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1380
|
+
}
|
|
1381
|
+
else {
|
|
1382
|
+
const vSchema = vParam.schema;
|
|
1383
|
+
propertyType = this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(vSchema, true, this.state);
|
|
1384
|
+
origin = vParam.origin;
|
|
1385
|
+
regularCmdletParameter = (this.state.project.azure && vParam.name === 'SubscriptionId' && operation.details.csharp.verb.toLowerCase() === 'get') ?
|
|
1386
|
+
// special case for subscription id
|
|
1387
|
+
this.add(new codegen_csharp_1.BackedProperty(vParam.name, codegen_csharp_1.dotnet.StringArray, {
|
|
1388
|
+
metadata: {
|
|
1389
|
+
parameterDefinition: origin.details.csharp.httpParameter
|
|
1390
|
+
},
|
|
1391
|
+
description: vParam.description
|
|
1392
|
+
})) :
|
|
1393
|
+
// everything else
|
|
1394
|
+
this.add(new codegen_csharp_1.BackedProperty(vParam.name, propertyType, {
|
|
1395
|
+
metadata: {
|
|
1396
|
+
parameterDefinition: origin.details.csharp.httpParameter
|
|
1397
|
+
},
|
|
1398
|
+
description: vParam.description
|
|
1399
|
+
}));
|
|
1400
|
+
const dictSchema = vSchema.type === codemodel_1.SchemaType.Dictionary ? vSchema :
|
|
1401
|
+
vSchema.type === codemodel_1.SchemaType.Object ? (_j = (_h = vSchema.parents) === null || _h === void 0 ? void 0 : _h.immediate) === null || _j === void 0 ? void 0 : _j.find((s) => s.type === codemodel_1.SchemaType.Dictionary) :
|
|
1402
|
+
undefined;
|
|
1403
|
+
if (dictSchema) {
|
|
1404
|
+
// we have to figure out if this is a standalone dictionary or a hybrid object/dictionary.
|
|
1405
|
+
// if it's a hybrid, we have to create another parameter like -<XXX>AdditionalProperties and have that dump the contents into the dictionary
|
|
1406
|
+
// if it's a standalone dictionary, we can just use hashtable instead
|
|
1407
|
+
if (linq_1.length(vSchema.properties) === 0) {
|
|
1408
|
+
// it's a pure dictionary
|
|
1409
|
+
// change the property type to hashtable.
|
|
1410
|
+
// add an attribute to change the exported type.
|
|
1411
|
+
regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ExportAsAttribute, { parameters: [`typeof(${codegen_csharp_1.System.Collections.Hashtable})`] }));
|
|
1412
|
+
}
|
|
1413
|
+
else {
|
|
1414
|
+
// it's a hybrid. We need to add an additional property that puts its items into the target container
|
|
1415
|
+
}
|
|
1304
1416
|
}
|
|
1305
1417
|
}
|
|
1306
1418
|
this.thingsToSerialize.push(regularCmdletParameter);
|
|
1307
1419
|
const parameters = [new codegen_csharp_1.LiteralExpression(`Mandatory = ${vParam.required ? 'true' : 'false'}`), new codegen_csharp_1.LiteralExpression(`HelpMessage = "${codegen_1.escapeString(vParam.description) || '.'}"`)];
|
|
1308
|
-
if (origin.details.csharp.isBodyParameter) {
|
|
1420
|
+
if (!!origin && origin.details.csharp.isBodyParameter) {
|
|
1309
1421
|
parameters.push(new codegen_csharp_1.LiteralExpression('ValueFromPipeline = true'));
|
|
1310
1422
|
this.bodyParameter = regularCmdletParameter;
|
|
1311
1423
|
}
|
|
1312
1424
|
regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ParameterAttribute, { parameters }));
|
|
1313
|
-
if (vParam.schema.type === codemodel_1.SchemaType.Array) {
|
|
1425
|
+
if (!vParam.type && vParam.schema.type === codemodel_1.SchemaType.Array) {
|
|
1314
1426
|
regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.AllowEmptyCollectionAttribute));
|
|
1315
1427
|
}
|
|
1316
|
-
|
|
1428
|
+
if (!!origin && !!propertyType) {
|
|
1429
|
+
NewAddInfoAttribute(regularCmdletParameter, propertyType, (_k = vParam.required) !== null && _k !== void 0 ? _k : false, false, vParam.description, origin.name);
|
|
1430
|
+
}
|
|
1317
1431
|
NewAddCompleterInfo(regularCmdletParameter, vParam);
|
|
1318
1432
|
addParameterBreakingChange(regularCmdletParameter, vParam);
|
|
1319
1433
|
addPreviewMessage(regularCmdletParameter, vParam);
|
|
@@ -1323,7 +1437,7 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1323
1437
|
if (linq_1.length(vParam.alias) > 0) {
|
|
1324
1438
|
regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.Alias, { parameters: vParam.alias.map(x => '"' + x + '"') }));
|
|
1325
1439
|
}
|
|
1326
|
-
const httpParam = origin.details.csharp.httpParameter;
|
|
1440
|
+
const httpParam = origin ? origin.details.csharp.httpParameter : null;
|
|
1327
1441
|
//const uid = httpParam ? httpParam.details.csharp.uid : 'no-parameter';
|
|
1328
1442
|
if (httpParam) {
|
|
1329
1443
|
// xichen: Is it safe to compare by csharp serializedName? Because we no longer have uid
|
|
@@ -1332,13 +1446,17 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1332
1446
|
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))}`] }));
|
|
1333
1447
|
}
|
|
1334
1448
|
}
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1449
|
+
else {
|
|
1450
|
+
const isBodyParameter = origin ? origin.details.csharp.isBodyParameter : false;
|
|
1451
|
+
if (isBodyParameter) {
|
|
1452
|
+
regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CategoryAttribute, {
|
|
1453
|
+
parameters: [`${powershell_declarations_1.ParameterCategory}.Body`],
|
|
1454
|
+
}));
|
|
1455
|
+
}
|
|
1338
1456
|
}
|
|
1339
1457
|
const isEnum = propertyType instanceof exports_1.EnumImplementation;
|
|
1340
1458
|
const hasEnum = propertyType instanceof exports_1.ArrayOf && propertyType.elementType instanceof exports_1.EnumImplementation;
|
|
1341
|
-
if (isEnum || hasEnum) {
|
|
1459
|
+
if (propertyType && (isEnum || hasEnum)) {
|
|
1342
1460
|
regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ArgumentCompleterAttribute, { parameters: [`typeof(${hasEnum ? propertyType.elementType.declaration : propertyType.declaration})`] }));
|
|
1343
1461
|
}
|
|
1344
1462
|
}
|
|
@@ -1363,7 +1481,7 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1363
1481
|
}
|
|
1364
1482
|
}
|
|
1365
1483
|
NewAddClassAttributes(operation, variantName) {
|
|
1366
|
-
var _a, _b, _c, _d;
|
|
1484
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1367
1485
|
const cmdletAttribParams = [
|
|
1368
1486
|
category[operation.details.csharp.verb] ? powershell_declarations_1.verbEnum(category[operation.details.csharp.verb], operation.details.csharp.verb) : `"${operation.details.csharp.verb}"`,
|
|
1369
1487
|
new codegen_csharp_1.StringExpression(variantName)
|
|
@@ -1455,9 +1573,9 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1455
1573
|
}
|
|
1456
1574
|
//add breaking change attributes for cmdlet, variant, output type
|
|
1457
1575
|
if (operation.details.csharp.breakingChange) {
|
|
1458
|
-
|
|
1576
|
+
const breakingChange = operation.details.csharp.breakingChange;
|
|
1459
1577
|
if (breakingChange.cmdlet) {
|
|
1460
|
-
|
|
1578
|
+
const parameters = [];
|
|
1461
1579
|
if (breakingChange.cmdlet.deprecateByVersion) {
|
|
1462
1580
|
parameters.push(`"${breakingChange.cmdlet.deprecateByVersion}"`);
|
|
1463
1581
|
if (breakingChange.cmdlet.changeInEfectByDate)
|
|
@@ -1470,7 +1588,7 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1470
1588
|
this.add(new codegen_csharp_1.Attribute(exports_1.ClientRuntime.CmdletBreakingChangeAttribute, { parameters: parameters }));
|
|
1471
1589
|
}
|
|
1472
1590
|
if (breakingChange.variant) {
|
|
1473
|
-
|
|
1591
|
+
const parameters = [];
|
|
1474
1592
|
parameters.push(`new string[] {"${breakingChange.variant.name}"}`);
|
|
1475
1593
|
if (breakingChange.variant.deprecateByVersion) {
|
|
1476
1594
|
parameters.push(`"${breakingChange.variant.deprecateByVersion}"`);
|
|
@@ -1482,13 +1600,13 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1482
1600
|
this.add(new codegen_csharp_1.Attribute(exports_1.ClientRuntime.ParameterSetBreakingChangeAttribute, { parameters: parameters }));
|
|
1483
1601
|
}
|
|
1484
1602
|
if (breakingChange.output) {
|
|
1485
|
-
|
|
1603
|
+
const parameters = [];
|
|
1486
1604
|
// if deprecated output types are set in directive, use it
|
|
1487
1605
|
if (breakingChange.output.deprecatedCmdLetOutputType) {
|
|
1488
1606
|
parameters.push(`"${breakingChange.output.deprecatedCmdLetOutputType}"`);
|
|
1489
1607
|
}
|
|
1490
1608
|
else {
|
|
1491
|
-
parameters.push(`"${outputTypes.values().next().value.replace(/typeof\((.*)\)/,
|
|
1609
|
+
parameters.push(`"${outputTypes.values().next().value.replace(/typeof\((.*)\)/, '$1')}"`);
|
|
1492
1610
|
}
|
|
1493
1611
|
if (breakingChange.output.deprecateByVersion) {
|
|
1494
1612
|
parameters.push(`"${breakingChange.output.deprecateByVersion}"`);
|
|
@@ -1498,12 +1616,12 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1498
1616
|
if (breakingChange.output.replacement)
|
|
1499
1617
|
parameters.push(`ReplacementCmdletOutputType="${breakingChange.output.replacement}"`);
|
|
1500
1618
|
if (breakingChange.output.deprecatedOutputProperties) {
|
|
1501
|
-
|
|
1619
|
+
const properties = Object.assign([], breakingChange.output.deprecatedOutputProperties);
|
|
1502
1620
|
properties.forEach((element, index) => properties[index] = '"' + element + '"');
|
|
1503
1621
|
parameters.push(`DeprecatedOutputProperties=new string[] {${properties.join(',')}}`);
|
|
1504
1622
|
}
|
|
1505
1623
|
if (breakingChange.output.newOutputProperties) {
|
|
1506
|
-
|
|
1624
|
+
const properties = Object.assign([], breakingChange.output.newOutputProperties);
|
|
1507
1625
|
properties.forEach((element, index) => properties[index] = '"' + element + '"');
|
|
1508
1626
|
parameters.push(`NewOutputProperties=new string[] {${properties.join(',')}}`);
|
|
1509
1627
|
}
|
|
@@ -1523,6 +1641,13 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1523
1641
|
passThru.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CategoryAttribute, { parameters: [`${powershell_declarations_1.ParameterCategory}.Runtime`] }));
|
|
1524
1642
|
}
|
|
1525
1643
|
this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.DescriptionAttribute, { parameters: [new codegen_csharp_1.StringExpression(this.description)] }));
|
|
1644
|
+
// If defines externalDocs for operation
|
|
1645
|
+
if (operation.details.default.externalDocs) {
|
|
1646
|
+
this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ExternalDocsAttribute, {
|
|
1647
|
+
parameters: [`${new codegen_csharp_1.StringExpression((_f = (_e = this.operation.details.default.externalDocs) === null || _e === void 0 ? void 0 : _e.url) !== null && _f !== void 0 ? _f : '')}`,
|
|
1648
|
+
`${new codegen_csharp_1.StringExpression((_h = (_g = this.operation.details.default.externalDocs) === null || _g === void 0 ? void 0 : _g.description) !== null && _h !== void 0 ? _h : '')}`]
|
|
1649
|
+
}));
|
|
1650
|
+
}
|
|
1526
1651
|
this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.GeneratedAttribute));
|
|
1527
1652
|
if (operation.extensions && operation.extensions['x-ms-metadata'] && operation.extensions['x-ms-metadata'].profiles) {
|
|
1528
1653
|
const profileNames = Object.keys(operation.extensions && operation.extensions['x-ms-metadata'].profiles);
|
|
@@ -1532,6 +1657,17 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1532
1657
|
});
|
|
1533
1658
|
this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ProfileAttribute, { parameters: [...profileNames] }));
|
|
1534
1659
|
}
|
|
1660
|
+
this.operation.callGraph.forEach((operationInfo) => {
|
|
1661
|
+
var _a;
|
|
1662
|
+
let apiVersion = 'null';
|
|
1663
|
+
if (operationInfo.apiVersions) {
|
|
1664
|
+
apiVersion = operationInfo.apiVersions[0].version;
|
|
1665
|
+
}
|
|
1666
|
+
(_a = operationInfo.requests) === null || _a === void 0 ? void 0 : _a.forEach((request) => {
|
|
1667
|
+
var _a, _b;
|
|
1668
|
+
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}"`] }));
|
|
1669
|
+
});
|
|
1670
|
+
});
|
|
1535
1671
|
}
|
|
1536
1672
|
}
|
|
1537
1673
|
exports.CmdletClass = CmdletClass;
|