@@ -97,6 +97,11 @@ export class AmazonQServiceManager extends BaseAmazonQServiceManager<
9797 this . state = state
9898 }
9999
100+ endpointOverride ( ) : string | undefined {
101+ return this . features . lsp . getClientInitializeParams ( ) ?. initializationOptions ?. aws ?. awsClientCapabilities
102+ ?. textDocument ?. inlineCompletionWithReferences ?. endpointOverride
103+ }
104+
100105 public static initInstance ( features : QServiceManagerFeatures ) : AmazonQServiceManager {
101106 if ( ! AmazonQServiceManager . instance ) {
102107 AmazonQServiceManager . instance = new AmazonQServiceManager ( features )
@@ -224,6 +229,10 @@ export class AmazonQServiceManager extends BaseAmazonQServiceManager<
224229 return
225230 }
226231
232+ const endpointOverride =
233+ this . features . lsp . getClientInitializeParams ( ) ?. initializationOptions ?. aws ?. awsClientCapabilities
234+ ?. textDocument ?. inlineCompletionWithReferences ?. endpointOverride
235+
227236 // Connection type changed to 'builderId'
228237
229238 if ( newConnectionType === 'builderId' ) {
@@ -234,7 +243,11 @@ export class AmazonQServiceManager extends BaseAmazonQServiceManager<
234243 // region set by client -> runtime region -> default region
235244 const clientParams = this . features . lsp . getClientInitializeParams ( )
236245
237- this . createCodewhispererServiceInstances ( 'builderId' , clientParams ?. initializationOptions ?. aws ?. region )
246+ this . createCodewhispererServiceInstances (
247+ 'builderId' ,
248+ clientParams ?. initializationOptions ?. aws ?. region ,
249+ endpointOverride
250+ )
238251 this . state = 'INITIALIZED'
239252 this . log ( 'Initialized Amazon Q service with builderId connection' )
240253
@@ -256,7 +269,7 @@ export class AmazonQServiceManager extends BaseAmazonQServiceManager<
256269 return
257270 }
258271
259- this . createCodewhispererServiceInstances ( 'identityCenter' )
272+ this . createCodewhispererServiceInstances ( 'identityCenter' , undefined , endpointOverride )
260273 this . state = 'INITIALIZED'
261274 this . log ( 'Initialized Amazon Q service with identityCenter connection' )
262275
@@ -358,7 +371,11 @@ export class AmazonQServiceManager extends BaseAmazonQServiceManager<
358371
359372 if ( ! this . activeIdcProfile ) {
360373 this . activeIdcProfile = newProfile
361- this . createCodewhispererServiceInstances ( 'identityCenter' , newProfile . identityDetails . region )
374+ this . createCodewhispererServiceInstances (
375+ 'identityCenter' ,
376+ newProfile . identityDetails . region ,
377+ this . endpointOverride ( )
378+ )
362379 this . state = 'INITIALIZED'
363380 this . log (
364381 `Initialized identityCenter connection to region ${ newProfile . identityDetails . region } for profile ${ newProfile . arn } `
@@ -410,7 +427,11 @@ export class AmazonQServiceManager extends BaseAmazonQServiceManager<
410427
411428 this . activeIdcProfile = newProfile
412429
413- this . createCodewhispererServiceInstances ( 'identityCenter' , newProfile . identityDetails . region )
430+ this . createCodewhispererServiceInstances (
431+ 'identityCenter' ,
432+ newProfile . identityDetails . region ,
433+ this . endpointOverride ( )
434+ )
414435 this . state = 'INITIALIZED'
415436
416437 return
@@ -489,7 +510,8 @@ export class AmazonQServiceManager extends BaseAmazonQServiceManager<
489510
490511 private createCodewhispererServiceInstances (
491512 connectionType : 'builderId' | 'identityCenter' ,
492- clientOrProfileRegion ?: string
513+ clientOrProfileRegion : string | undefined ,
514+ endpointOverride : string | undefined
493515 ) {
494516 this . logServiceState ( 'Initializing CodewhispererService' )
495517
@@ -504,10 +526,14 @@ export class AmazonQServiceManager extends BaseAmazonQServiceManager<
504526 this . region = region
505527 this . endpoint = endpoint
506528
507- this . cachedCodewhispererService = this . serviceFactory ( region , endpoint )
529+ if ( endpointOverride ) {
530+ this . endpoint = endpointOverride
531+ }
532+
533+ this . cachedCodewhispererService = this . serviceFactory ( region , this . endpoint )
508534 this . log ( `CodeWhispererToken service for connection type ${ connectionType } was initialized, region=${ region } ` )
509535
510- this . cachedStreamingClient = this . streamingClientFactory ( region , endpoint )
536+ this . cachedStreamingClient = this . streamingClientFactory ( region , this . endpoint )
511537 this . log ( `StreamingClient service for connection type ${ connectionType } was initialized, region=${ region } ` )
512538
513539 this . logServiceState ( 'CodewhispererService and StreamingClient Initialization finished' )
0 commit comments