@@ -61,6 +61,12 @@ function generateArmResourceModel(resource: TspArmResource): string {
6161 const doc = generateDocs ( resource ) ;
6262 definitions . push ( doc ) ;
6363
64+ if ( resource . resourceKind === "PrivateEndpointConnectionResource" ) {
65+ definitions . push ( `model PrivateEndpointConnection is PrivateEndpointConnectionResource;` ) ;
66+ definitions . push ( `alias PrivateEndpointOperations = PrivateEndpoints<PrivateEndpointConnection>;` ) ;
67+ return definitions . join ( "\n" ) ;
68+ }
69+
6470 const decorators = generateDecorators ( resource . decorators ) ;
6571 decorators && definitions . push ( decorators ) ;
6672
@@ -91,13 +97,16 @@ function generateArmResourceOperationGroups(resource: TspArmResource): string {
9197 const definitions : string [ ] = [ ] ;
9298
9399 for ( const operationGroup of resource . resourceOperationGroups ) {
94- definitions . push ( generateArmResourceOperationGroup ( operationGroup ) ) ;
100+ definitions . push ( generateArmResourceOperationGroup ( operationGroup , resource ) ) ;
95101 }
96102
97103 return definitions . join ( "\n" ) ;
98104}
99105
100- function generateArmResourceOperationGroup ( operationGroup : TspArmResourceOperationGroup ) : string {
106+ function generateArmResourceOperationGroup (
107+ operationGroup : TspArmResourceOperationGroup ,
108+ resource : TspArmResource ,
109+ ) : string {
101110 const { isFullCompatible } = getOptions ( ) ;
102111
103112 const definitions : string [ ] = [ ] ;
@@ -138,10 +147,10 @@ function generateArmResourceOperationGroup(operationGroup: TspArmResourceOperati
138147
139148 const operationKind = operationGroup . isLegacy
140149 ? `${ operationGroup . legacyOperationGroup ! . interfaceName } .${ getLegacyOperationKind ( operation . kind ) } `
141- : getOperationKind ( operation ) ;
150+ : getOperationKind ( operation , resource ) ;
142151 if ( operation . kind === "ArmResourceActionSync" || operation . kind === "ArmResourceActionAsync" ) {
143152 definitions . push (
144- `${ operation . name } is ${ operationKind } <${ operation . targetResource ? ` ${ operation . targetResource } , ` : "" } ${ operation . resource } , ${ generateArmRequest (
153+ `${ operation . name } is ${ operationKind } <${ getSpecialParameter ( operation , resource ) } ${ operation . resource } , ${ generateArmRequest (
145154 operation . request ,
146155 ) } , ${ generateArmResponse ( operation . response ) } ${
147156 operation . baseParameters && ! operationGroup . isLegacy
@@ -153,15 +162,15 @@ function generateArmResourceOperationGroup(operationGroup: TspArmResourceOperati
153162 ) ;
154163 } else if ( operation . kind === "ArmResourceActionAsyncBase" ) {
155164 definitions . push (
156- `${ operation . name } is ${ operationKind } <${ operation . targetResource ? ` ${ operation . targetResource } , ` : "" } ${ operation . resource } , ${ generateArmRequest (
165+ `${ operation . name } is ${ operationKind } <${ getSpecialParameter ( operation , resource ) } ${ operation . resource } , ${ generateArmRequest (
157166 operation . request ,
158167 ) } , ${ generateArmResponse ( operation . response ) } , BaseParameters = ${ operation . baseParameters ! [ 0 ] } ${
159168 operation . parameters ? `, Parameters = { ${ generateParameters ( operation . parameters ) } }` : ""
160169 } ${ operation . optionalRequestBody === true ? `, OptionalRequestBody = true` : "" } >;`,
161170 ) ;
162171 } else {
163172 definitions . push (
164- `${ operation . name } is ${ operationKind } <${ operation . targetResource ? ` ${ operation . targetResource } , ` : "" } ${ operation . resource } ${
173+ `${ operation . name } is ${ operationKind } <${ getSpecialParameter ( operation , resource ) } ${ operation . resource } ${
165174 operation . patchModel ? `, PatchModel = ${ operation . patchModel } ` : ""
166175 } ${
167176 operation . baseParameters && ! operationGroup . isLegacy
@@ -187,55 +196,49 @@ function isPatchWithOptionalBody(operation: TspArmResourceOperation): boolean {
187196 ) ;
188197}
189198
190- function getOperationKind ( operation : TspArmResourceOperation ) : string {
199+ // These templates have special parameter as the first parameter
200+ // - Extension operations
201+ // - PrivateEndpointConnection operations
202+ function getSpecialParameter ( operation : TspArmResourceOperation , resource : TspArmResource ) : string {
203+ if ( operation . targetResource ) return `${ operation . targetResource } , ` ;
204+ if ( resource . resourceKind === "PrivateEndpointConnectionResource" ) return `${ resource . resourceParent ! . name } , ` ;
205+ return "" ;
206+ }
207+
208+ function getOperationKind ( operation : TspArmResourceOperation , resource : TspArmResource ) : string {
209+ if ( resource . resourceKind === "PrivateEndpointConnectionResource" )
210+ return `PrivateEndpointOperations.${ getPrivateEndpointConnectionOperationKind ( operation . kind ) } ` ;
191211 if ( operation . targetResource ) return `Extension.${ getExtensionOperationKind ( operation . kind ) } ` ;
192212 if ( isPatchWithOptionalBody ( operation ) ) return `Azure.ResourceManager.Legacy.${ operation . kind . replace ( "Arm" , "" ) } ` ;
193213 return operation . kind ;
194214}
195215
216+ function getPrivateEndpointConnectionOperationKind ( kind : TspArmOperationType ) : string {
217+ switch ( kind ) {
218+ case "ArmResourceListByParent" :
219+ return "ListByParent" ;
220+ default :
221+ return getOperationBaseKind ( kind ) ;
222+ }
223+ }
224+
196225function getExtensionOperationKind ( kind : TspArmOperationType ) : string {
197226 switch ( kind ) {
198- case "ArmResourceRead" :
199- return "Read" ;
200- case "ArmResourceCheckExistence" :
201- return "CheckExistence" ;
202- case "ArmResourceCreateOrReplaceSync" :
203- return "CreateOrReplaceSync" ;
204- case "ArmResourceCreateOrReplaceAsync" :
205- return "CreateOrReplaceAsync" ;
206- case "ArmResourcePatchSync" :
207- return "CustomPatchSync" ;
208- case "ArmResourcePatchAsync" :
209- return "CustomPatchAsync" ;
210- case "ArmCustomPatchSync" :
211- return "CustomPatchSync" ;
212- case "ArmCustomPatchAsync" :
213- return "CustomPatchAsync" ;
214- case "ArmResourceDeleteSync" :
215- return "DeleteSync" ;
216227 case "ArmResourceDeleteWithoutOkAsync" :
217228 return "DeleteWithoutOkAsync" ;
218- case "ArmResourceActionSync" :
219- return "ActionSync" ;
220- case "ArmResourceActionAsync" :
221- return "ActionAsync" ;
222- case "ArmResourceActionAsyncBase" :
223- return "ActionAsyncBase" ;
224229 case "ArmResourceListByParent" :
225230 return "ListByTarget" ;
226231 case "ArmListBySubscription" :
227232 return "List" ;
228233 case "ArmResourceListAtScope" :
229234 return "List" ;
235+ default :
236+ return getOperationBaseKind ( kind ) ;
230237 }
231238}
232239
233240function getLegacyOperationKind ( kind : TspArmOperationType ) : string {
234241 switch ( kind ) {
235- case "ArmResourceRead" :
236- return "Read" ;
237- case "ArmResourceCheckExistence" :
238- return "CheckExistence" ;
239242 case "ArmResourceCreateOrReplaceSync" :
240243 return "CreateOrUpdateSync" ;
241244 case "ArmResourceCreateOrReplaceAsync" :
@@ -244,14 +247,35 @@ function getLegacyOperationKind(kind: TspArmOperationType): string {
244247 return "PatchSync" ;
245248 case "ArmResourcePatchAsync" :
246249 return "PatchAsync" ;
250+ case "ArmResourceDeleteWithoutOkAsync" :
251+ return "DeleteWithoutOkAsync" ;
252+ default :
253+ return getOperationBaseKind ( kind ) ;
254+ }
255+ }
256+
257+ function getOperationBaseKind ( kind : TspArmOperationType ) : string {
258+ switch ( kind ) {
259+ case "ArmResourceRead" :
260+ return "Read" ;
261+ case "ArmResourceCheckExistence" :
262+ return "CheckExistence" ;
263+ case "ArmResourceCreateOrReplaceSync" :
264+ return "CreateOrReplaceSync" ;
265+ case "ArmResourceCreateOrReplaceAsync" :
266+ return "CreateOrReplaceAsync" ;
267+ case "ArmResourcePatchSync" :
268+ return "CustomPatchSync" ;
269+ case "ArmResourcePatchAsync" :
270+ return "CustomPatchAsync" ;
247271 case "ArmCustomPatchSync" :
248272 return "CustomPatchSync" ;
249273 case "ArmCustomPatchAsync" :
250274 return "CustomPatchAsync" ;
251275 case "ArmResourceDeleteSync" :
252276 return "DeleteSync" ;
253277 case "ArmResourceDeleteWithoutOkAsync" :
254- return "DeleteWithoutOkAsync " ;
278+ return "DeleteAsync " ;
255279 case "ArmResourceActionSync" :
256280 return "ActionSync" ;
257281 case "ArmResourceActionAsync" :
0 commit comments