11import { createAction } from '@openops/blocks-framework' ;
22import { hyperglanceAuth } from '../auth' ;
3- import { fetchRecommendations , getRecommendationsProp } from '../hgapi/recommendations' ;
43import { getDatasourceProp , getResourceTypeProp } from '../hgapi/common' ;
4+ import {
5+ fetchRecommendations ,
6+ getRecommendationsProp ,
7+ } from '../hgapi/recommendations' ;
58
69export const getRecommendations = createAction ( {
710 auth : hyperglanceAuth ,
811 name : 'getRecommendations' ,
912 displayName : 'Get Recommendations' ,
1013 description : 'Get Recommendations' ,
1114 props : {
12- datasource : getDatasourceProp ( { description :'Fetch recommendations in regards to this cloud provider' } ) ,
13- type : getResourceTypeProp ( { required : true , description :'Fetch recommendations in regards to this type of resource' } ) ,
14- recommendations :getRecommendationsProp ( )
15+ datasource : getDatasourceProp ( {
16+ description : 'Fetch recommendations in regards to this cloud provider' ,
17+ } ) ,
18+ type : getResourceTypeProp ( {
19+ required : true ,
20+ description : 'Fetch recommendations in regards to this type of resource' ,
21+ } ) ,
22+ recommendations : getRecommendationsProp ( ) ,
1523 } ,
1624 isWriteAction : false ,
17- async run ( context ) {
18- const { auth, propsValue} = context ;
19- const { datasource= "" , type= "" } = propsValue ;
20- return await fetchRecommendations ( auth , { resourceType :{ datasource, type} , recommendation : propsValue . recommendations } ) ;
21- }
22- } ) ;
25+ async run ( context ) {
26+ const { auth, propsValue } = context ;
27+ const { datasource = '' , type = '' } = propsValue ;
28+ return await fetchRecommendations ( auth , {
29+ resourceType : { datasource, type } ,
30+ recommendation : propsValue . recommendations ,
31+ } ) ;
32+ } ,
33+ } ) ;
0 commit comments