3
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
- let ejs = require ( 'ejs' )
6
+ const ejs = require ( 'ejs' ) ;
7
7
import { Schema as NewSchema , SchemaType , ArraySchema , SchemaResponse , HttpParameter , ObjectSchema , BinaryResponse , DictionarySchema , ChoiceSchema , SealedChoiceSchema } from '@azure-tools/codemodel' ;
8
8
import { command , getAllProperties , JsonType , http , getAllPublicVirtualProperties , getVirtualPropertyFromPropertyName , ParameterLocation , getAllVirtualProperties , VirtualParameter , VirtualProperty } from '@azure-tools/codemodel-v3' ;
9
9
import { CommandOperation , OperationType , VirtualParameter as NewVirtualParameter } from '../utils/command-operation' ;
@@ -15,7 +15,7 @@ import {
15
15
Switch , System , TerminalCase , toExpression , Try , Using , valueOf , Field , IsNull , Or , ExpressionOrLiteral , TerminalDefaultCase , xmlize , TypeDeclaration , And , IsNotNull , PartialMethod , Case , While
16
16
} from '@azure-tools/codegen-csharp' ;
17
17
import { ClientRuntime , EventListener , Schema , ArrayOf , EnumImplementation } from '../llcsharp/exports' ;
18
- import { Alias , ArgumentCompleterAttribute , AsyncCommandRuntime , AsyncJob , CmdletAttribute , ErrorCategory , ErrorRecord , Events , InvocationInfo , OutputTypeAttribute , ParameterAttribute , PSCmdlet , PSCredential , SwitchParameter , ValidateNotNull , verbEnum , GeneratedAttribute , DescriptionAttribute , ExternalDocsAttribute , CategoryAttribute , ParameterCategory , ProfileAttribute , PSObject , InternalExportAttribute , ExportAsAttribute , DefaultRunspace , RunspaceFactory , AllowEmptyCollectionAttribute , DoNotExportAttribute } from '../internal/powershell-declarations' ;
18
+ import { Alias , ArgumentCompleterAttribute , AsyncCommandRuntime , AsyncJob , CmdletAttribute , ErrorCategory , ErrorRecord , Events , InvocationInfo , OutputTypeAttribute , ParameterAttribute , PSCmdlet , PSCredential , SwitchParameter , ValidateNotNull , verbEnum , GeneratedAttribute , DescriptionAttribute , ExternalDocsAttribute , CategoryAttribute , ParameterCategory , ProfileAttribute , PSObject , InternalExportAttribute , ExportAsAttribute , DefaultRunspace , RunspaceFactory , AllowEmptyCollectionAttribute , DoNotExportAttribute , HttpPathAttribute } from '../internal/powershell-declarations' ;
19
19
import { State } from '../internal/state' ;
20
20
import { Channel } from '@azure-tools/autorest-extension-base' ;
21
21
import { IParameter } from '@azure-tools/codemodel-v3/dist/code-model/components' ;
@@ -1243,8 +1243,8 @@ export class CmdletClass extends Class {
1243
1243
yield Return ( ) ;
1244
1244
} ) ,
1245
1245
TerminalCase ( Events . Progress . value , function * ( ) {
1246
- yield 'var data = messageData();'
1247
- yield 'int progress = (int)data.Value;'
1246
+ yield 'var data = messageData();' ;
1247
+ yield 'int progress = (int)data.Value;' ;
1248
1248
yield 'string activityMessage, statusDescription;' ;
1249
1249
yield 'global::System.Management.Automation.ProgressRecordType recordType;' ;
1250
1250
@@ -1262,10 +1262,10 @@ export class CmdletClass extends Class {
1262
1262
yield '}' ;
1263
1263
1264
1264
// hardcode id = 1 because there is no need for nested progress bar
1265
- yield ` WriteProgress(new global::System.Management.Automation.ProgressRecord(1, activityMessage, statusDescription)` ;
1265
+ yield ' WriteProgress(new global::System.Management.Automation.ProgressRecord(1, activityMessage, statusDescription)' ;
1266
1266
yield '{' ;
1267
1267
yield ' PercentComplete = progress,' ;
1268
- yield 'RecordType = recordType'
1268
+ yield 'RecordType = recordType' ;
1269
1269
yield '});' ;
1270
1270
yield Return ( ) ;
1271
1271
} ) ,
@@ -1288,15 +1288,15 @@ export class CmdletClass extends Class {
1288
1288
yield ' return;' ;
1289
1289
yield '}' ;
1290
1290
} ) ;
1291
- yield Else ( function * ( ) {
1291
+ yield Else ( function * ( ) {
1292
1292
yield 'if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response)' ;
1293
1293
yield '{' ;
1294
1294
yield ' int delay = (int)(response.Headers.RetryAfter?.Delta?.TotalSeconds ?? 30);' ;
1295
1295
yield ' WriteDebug($"Delaying {delay} seconds before polling.");' ;
1296
1296
yield ' for (var now = 0; now < delay; ++now)' ;
1297
1297
yield ' {' ;
1298
1298
// hardcode id = 1 because there is no need for nested progress bar
1299
- yield ` WriteProgress(new global::System.Management.Automation.ProgressRecord(1, "In progress", "Checking operation status")` ;
1299
+ yield ' WriteProgress(new global::System.Management.Automation.ProgressRecord(1, "In progress", "Checking operation status")' ;
1300
1300
yield ' {' ;
1301
1301
yield ' PercentComplete = now * 100 / delay' ;
1302
1302
yield ' });' ;
@@ -1831,8 +1831,8 @@ export class CmdletClass extends Class {
1831
1831
// If defines externalDocs for operation
1832
1832
if ( operation . details . default . externalDocs ) {
1833
1833
this . add ( new Attribute ( ExternalDocsAttribute , {
1834
- parameters : [ `${ new StringExpression ( this . operation . details . default . externalDocs ?. url ?? "" ) } ` ,
1835
- `${ new StringExpression ( this . operation . details . default . externalDocs ?. description ?? "" ) } ` ]
1834
+ parameters : [ `${ new StringExpression ( this . operation . details . default . externalDocs ?. url ?? '' ) } ` ,
1835
+ `${ new StringExpression ( this . operation . details . default . externalDocs ?. description ?? '' ) } ` ]
1836
1836
} ) ) ;
1837
1837
}
1838
1838
@@ -1846,6 +1846,16 @@ export class CmdletClass extends Class {
1846
1846
1847
1847
this . add ( new Attribute ( ProfileAttribute , { parameters : [ ...profileNames ] } ) ) ;
1848
1848
}
1849
+
1850
+ this . operation . callGraph . forEach ( ( operationInfo ) => {
1851
+ let apiVersion = 'null' ;
1852
+ if ( operationInfo . apiVersions ) {
1853
+ apiVersion = operationInfo . apiVersions [ 0 ] . version ;
1854
+ }
1855
+ operationInfo . requests ?. forEach ( ( request ) => {
1856
+ this . add ( new Attribute ( HttpPathAttribute , { parameters : [ `Path = "${ request . protocol ?. http ?. path } "` , `ApiVersion = "${ apiVersion } "` ] } ) ) ;
1857
+ } ) ;
1858
+ } ) ;
1849
1859
}
1850
1860
}
1851
1861
0 commit comments