@@ -455,14 +455,15 @@ export class CloudCli implements INodeType {
455455 const credentials = await this . getCredentials ( 'cloudCliApi' ) ;
456456 const baseUrl = credentials . host as string ;
457457
458- const response = await this . helpers . httpRequest ( {
459- method : 'GET' ,
460- url : `${ baseUrl } /environments` ,
461- headers : {
462- 'X-API-KEY' : credentials . apiKey as string ,
458+ const response = await this . helpers . httpRequestWithAuthentication . call (
459+ this ,
460+ 'cloudCliApi' ,
461+ {
462+ method : 'GET' ,
463+ url : `${ baseUrl } /environments` ,
464+ json : true ,
463465 } ,
464- json : true ,
465- } ) ;
466+ ) ;
466467
467468 const environments = ( response . environments || [ ] ) as IDataObject [ ] ;
468469
@@ -496,14 +497,15 @@ export class CloudCli implements INodeType {
496497 const baseUrl = credentials . host as string ;
497498
498499 try {
499- const response = await this . helpers . httpRequest ( {
500- method : 'GET' ,
501- url : `${ baseUrl } /environments/${ environmentId } ` ,
502- headers : {
503- 'X-API-KEY' : credentials . apiKey as string ,
500+ const response = await this . helpers . httpRequestWithAuthentication . call (
501+ this ,
502+ 'cloudCliApi' ,
503+ {
504+ method : 'GET' ,
505+ url : `${ baseUrl } /environments/${ environmentId } ` ,
506+ json : true ,
504507 } ,
505- json : true ,
506- } ) ;
508+ ) ;
507509
508510 const environmentName = ( response . name as string ) || '' ;
509511 // Remove spaces from the project name
@@ -530,11 +532,6 @@ export class CloudCli implements INodeType {
530532
531533 const credentials = await this . getCredentials ( 'cloudCliApi' ) ;
532534 const baseUrl = credentials . host as string ;
533- const apiKey = credentials . apiKey as string ;
534-
535- const headers : IDataObject = {
536- 'X-API-KEY' : apiKey ,
537- } ;
538535
539536 for ( let itemIndex = 0 ; itemIndex < items . length ; itemIndex ++ ) {
540537 try {
@@ -548,12 +545,15 @@ export class CloudCli implements INodeType {
548545 const status = this . getNodeParameter ( 'status' , itemIndex , '' ) as string ;
549546 const queryParams = status ? `?status=${ status } ` : '' ;
550547
551- const response = await this . helpers . httpRequest ( {
552- method : 'GET' ,
553- url : `${ baseUrl } /environments${ queryParams } ` ,
554- headers,
555- json : true ,
556- } ) ;
548+ const response = await this . helpers . httpRequestWithAuthentication . call (
549+ this ,
550+ 'cloudCliApi' ,
551+ {
552+ method : 'GET' ,
553+ url : `${ baseUrl } /environments${ queryParams } ` ,
554+ json : true ,
555+ } ,
556+ ) ;
557557
558558 // Extract environments array and return each as separate item
559559 const environments = ( response . environments || [ ] ) as IDataObject [ ] ;
@@ -568,12 +568,15 @@ export class CloudCli implements INodeType {
568568 const environmentIdValue = this . getNodeParameter ( 'environmentId' , itemIndex ) as { value : string } ;
569569 const environmentId = environmentIdValue . value ;
570570
571- responseData = await this . helpers . httpRequest ( {
572- method : 'GET' ,
573- url : `${ baseUrl } /environments/${ environmentId } ` ,
574- headers,
575- json : true ,
576- } ) ;
571+ responseData = await this . helpers . httpRequestWithAuthentication . call (
572+ this ,
573+ 'cloudCliApi' ,
574+ {
575+ method : 'GET' ,
576+ url : `${ baseUrl } /environments/${ environmentId } ` ,
577+ json : true ,
578+ } ,
579+ ) ;
577580 } else if ( operation === 'create' ) {
578581 const name = this . getNodeParameter ( 'name' , itemIndex ) as string ;
579582 const subdomain = this . getNodeParameter ( 'subdomain' , itemIndex ) as string ;
@@ -584,45 +587,57 @@ export class CloudCli implements INodeType {
584587 if ( githubUrl ) body . github_url = githubUrl ;
585588 if ( githubToken ) body . github_token = githubToken ;
586589
587- responseData = await this . helpers . httpRequest ( {
588- method : 'POST' ,
589- url : `${ baseUrl } /environments` ,
590- headers,
591- body,
592- json : true ,
593- } ) ;
590+ responseData = await this . helpers . httpRequestWithAuthentication . call (
591+ this ,
592+ 'cloudCliApi' ,
593+ {
594+ method : 'POST' ,
595+ url : `${ baseUrl } /environments` ,
596+ body,
597+ json : true ,
598+ } ,
599+ ) ;
594600 } else if ( operation === 'delete' ) {
595601 const environmentIdValue = this . getNodeParameter ( 'environmentId' , itemIndex ) as { value : string } ;
596602 const environmentId = environmentIdValue . value ;
597603
598- await this . helpers . httpRequest ( {
599- method : 'DELETE' ,
600- url : `${ baseUrl } /environments/${ environmentId } ` ,
601- headers,
602- json : true ,
603- } ) ;
604+ await this . helpers . httpRequestWithAuthentication . call (
605+ this ,
606+ 'cloudCliApi' ,
607+ {
608+ method : 'DELETE' ,
609+ url : `${ baseUrl } /environments/${ environmentId } ` ,
610+ json : true ,
611+ } ,
612+ ) ;
604613
605614 responseData = { deleted : true } ;
606615 } else if ( operation === 'start' ) {
607616 const environmentIdValue = this . getNodeParameter ( 'environmentId' , itemIndex ) as { value : string } ;
608617 const environmentId = environmentIdValue . value ;
609618
610- responseData = await this . helpers . httpRequest ( {
611- method : 'POST' ,
612- url : `${ baseUrl } /environments/${ environmentId } /start` ,
613- headers,
614- json : true ,
615- } ) ;
619+ responseData = await this . helpers . httpRequestWithAuthentication . call (
620+ this ,
621+ 'cloudCliApi' ,
622+ {
623+ method : 'POST' ,
624+ url : `${ baseUrl } /environments/${ environmentId } /start` ,
625+ json : true ,
626+ } ,
627+ ) ;
616628 } else if ( operation === 'stop' ) {
617629 const environmentIdValue = this . getNodeParameter ( 'environmentId' , itemIndex ) as { value : string } ;
618630 const environmentId = environmentIdValue . value ;
619631
620- responseData = await this . helpers . httpRequest ( {
621- method : 'POST' ,
622- url : `${ baseUrl } /environments/${ environmentId } /stop` ,
623- headers,
624- json : true ,
625- } ) ;
632+ responseData = await this . helpers . httpRequestWithAuthentication . call (
633+ this ,
634+ 'cloudCliApi' ,
635+ {
636+ method : 'POST' ,
637+ url : `${ baseUrl } /environments/${ environmentId } /stop` ,
638+ json : true ,
639+ } ,
640+ ) ;
626641 } else {
627642 throw new NodeOperationError ( this . getNode ( ) , `Unknown operation: ${ operation } ` , {
628643 itemIndex,
@@ -642,12 +657,15 @@ export class CloudCli implements INodeType {
642657 projectName = projectNameValue . value ;
643658 } else {
644659 // Fetch environment details to get the name
645- const envResponse = await this . helpers . httpRequest ( {
646- method : 'GET' ,
647- url : `${ baseUrl } /environments/${ environmentId } ` ,
648- headers,
649- json : true ,
650- } ) ;
660+ const envResponse = await this . helpers . httpRequestWithAuthentication . call (
661+ this ,
662+ 'cloudCliApi' ,
663+ {
664+ method : 'GET' ,
665+ url : `${ baseUrl } /environments/${ environmentId } ` ,
666+ json : true ,
667+ } ,
668+ ) ;
651669 const environmentName = ( envResponse . name as string ) || '' ;
652670 projectName = environmentName . replace ( / \s + / g, '' ) ;
653671 }
@@ -673,17 +691,20 @@ export class CloudCli implements INodeType {
673691 }
674692
675693 // Get the raw SSE stream response
676- const rawResponse = await this . helpers . httpRequest ( {
677- method : 'POST' ,
678- url : `${ baseUrl } /agent/execute` ,
679- headers : {
680- ...headers ,
681- 'Content-Type' : 'application/json' ,
694+ const rawResponse = await this . helpers . httpRequestWithAuthentication . call (
695+ this ,
696+ 'cloudCliApi' ,
697+ {
698+ method : 'POST' ,
699+ url : `${ baseUrl } /agent/execute` ,
700+ headers : {
701+ 'Content-Type' : 'application/json' ,
702+ } ,
703+ body,
704+ json : false , // Get raw text response
705+ timeout : 600000 , // 10 minutes timeout for long-running agent tasks
682706 } ,
683- body,
684- json : false , // Get raw text response
685- timeout : 600000 , // 10 minutes timeout for long-running agent tasks
686- } ) ;
707+ ) ;
687708
688709 // Parse SSE stream into events array
689710 try {
0 commit comments