Skip to content

Commit 8fd5281

Browse files
Fix linter issues (#1590)
Fixes OPS-3000
1 parent df773ea commit 8fd5281

15 files changed

Lines changed: 399 additions & 316 deletions

packages/blocks/hyperglance/src/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { createCustomApiCallAction } from '@openops/blocks-common';
22
import { createBlock, Property } from '@openops/blocks-framework';
33
import { BlockCategory } from '@openops/shared';
4-
import { HGAuth, hyperglanceAuth } from './lib/auth';
5-
import { getRecommendations} from './lib/actions/getRecommendations';
64
import { exportTopologyForGroup } from './lib/actions/exportTopologyForGroup';
7-
import { searchTopology } from './lib/actions/searchTopology';
85
import { getCollectorRecords } from './lib/actions/getCollectorRecords';
9-
import { getCollectorRecordStatus } from './lib/actions/getCollectorRecordStatus';
106
import { getCollectorRecordStatistics } from './lib/actions/getCollectorRecordStatistics';
7+
import { getCollectorRecordStatus } from './lib/actions/getCollectorRecordStatus';
8+
import { getRecommendations } from './lib/actions/getRecommendations';
9+
import { searchTopology } from './lib/actions/searchTopology';
10+
import { HGAuth, hyperglanceAuth } from './lib/auth';
1111

1212
export const hyperglance = createBlock({
1313
displayName: 'Hyperglance',
@@ -34,7 +34,7 @@ export const hyperglance = createBlock({
3434
'For more information, visit the [Hyperglance API documentation](https://support.hyperglance.com/knowledge/getting-started-with-the-hyperglance-api).',
3535
}),
3636
},
37-
name:'customHgApiCall'
37+
name: 'customHgApiCall',
3838
}),
3939
],
4040
triggers: [],

packages/blocks/hyperglance/src/lib/actions/exportTopologyForGroup.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
import { createAction } from '@openops/blocks-framework';
22
import { hyperglanceAuth } from '../auth';
3-
import { exportTopology, getAccountProp, getExportTypeProp, getIDProp, getIncludeDependenciesProp, getShowCostProp } from '../hgapi/topology';
43
import { getDatasourceProp } from '../hgapi/common';
4+
import {
5+
exportTopology,
6+
getAccountProp,
7+
getExportTypeProp,
8+
getIDProp,
9+
getIncludeDependenciesProp,
10+
getShowCostProp,
11+
} from '../hgapi/topology';
512

613
export const exportTopologyForGroup = createAction({
714
auth: hyperglanceAuth,
@@ -10,17 +17,16 @@ export const exportTopologyForGroup = createAction({
1017
description: 'Export a diagram group to PNG or Visio (VSDX)',
1118
props: {
1219
datasource: getDatasourceProp(),
13-
account:getAccountProp(),
14-
id:getIDProp(),
15-
includeDependencies:getIncludeDependenciesProp(),
16-
showCost:getShowCostProp(),
17-
exportType : getExportTypeProp()
20+
account: getAccountProp(),
21+
id: getIDProp(),
22+
includeDependencies: getIncludeDependenciesProp(),
23+
showCost: getShowCostProp(),
24+
exportType: getExportTypeProp(),
1825
},
1926
isWriteAction: false,
2027
async run(context) {
21-
const {auth, propsValue} = context;
22-
28+
const { auth, propsValue } = context;
29+
2330
return await exportTopology(auth, propsValue);
2431
},
2532
});
26-
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
import { createAction } from '@openops/blocks-framework';
22
import { hyperglanceAuth } from '../auth';
3+
import {
4+
getAliasDropdownProp,
5+
getRecordStatistics,
6+
} from '../hgapi/collectorRecords';
37
import { getDatasourceProp } from '../hgapi/common';
4-
import { getAliasDropdownProp, getRecordStatistics } from '../hgapi/collectorRecords';
58

69
export const getCollectorRecordStatistics = createAction({
710
auth: hyperglanceAuth,
811
name: 'getCollectorRecordStatistics',
912
displayName: 'Get Credential Statistics',
1013
description: 'Returns Collection Statistics for the credential',
1114
props: {
12-
datasource: getDatasourceProp({description:'Get credential of this cloud provider'}),
13-
alias: getAliasDropdownProp()
15+
datasource: getDatasourceProp({
16+
description: 'Get credential of this cloud provider',
17+
}),
18+
alias: getAliasDropdownProp(),
1419
},
1520
isWriteAction: false,
1621
async run(context) {
17-
const {datasource="", alias} = context.propsValue;
22+
const { datasource = '', alias } = context.propsValue;
1823
return await getRecordStatistics(context.auth, datasource, alias);
1924
},
20-
});
25+
});
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
import { createAction } from '@openops/blocks-framework';
22
import { hyperglanceAuth } from '../auth';
3+
import {
4+
getAliasDropdownProp,
5+
getRecordStatus,
6+
} from '../hgapi/collectorRecords';
37
import { getDatasourceProp } from '../hgapi/common';
4-
import { getAliasDropdownProp, getRecordStatus } from '../hgapi/collectorRecords';
58

69
export const getCollectorRecordStatus = createAction({
710
auth: hyperglanceAuth,
811
name: 'getCollectorRecordStatus',
912
displayName: 'Get Credential Status',
1013
description: 'Returns Collector Record Status',
1114
props: {
12-
datasource: getDatasourceProp({description:'Get credential of this cloud provider'}),
13-
alias: getAliasDropdownProp()
15+
datasource: getDatasourceProp({
16+
description: 'Get credential of this cloud provider',
17+
}),
18+
alias: getAliasDropdownProp(),
1419
},
1520
isWriteAction: false,
1621
async run(context) {
17-
const {datasource="", alias} = context.propsValue;
22+
const { datasource = '', alias } = context.propsValue;
1823
return await getRecordStatus(context.auth, datasource, alias);
1924
},
20-
});
25+
});
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
import { createAction } from '@openops/blocks-framework';
22
import { hyperglanceAuth } from '../auth';
3-
import { getDatasourceProp } from '../hgapi/common';
43
import { listRecords } from '../hgapi/collectorRecords';
4+
import { getDatasourceProp } from '../hgapi/common';
55

66
export const getCollectorRecords = createAction({
77
auth: hyperglanceAuth,
88
name: 'getCollectorRecords',
99
displayName: 'List Credentials',
1010
description: 'List All Hyperglance Credentials',
1111
props: {
12-
datasource: getDatasourceProp({description:'List credentials of this cloud provider'})
12+
datasource: getDatasourceProp({
13+
description: 'List credentials of this cloud provider',
14+
}),
1315
},
1416
isWriteAction: false,
1517
async run(context) {
16-
return await listRecords(context.auth, context.propsValue.datasource??"");
18+
return await listRecords(context.auth, context.propsValue.datasource ?? '');
1719
},
18-
});
20+
});
Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
11
import { createAction } from '@openops/blocks-framework';
22
import { hyperglanceAuth } from '../auth';
3-
import { fetchRecommendations, getRecommendationsProp } from '../hgapi/recommendations';
43
import { getDatasourceProp, getResourceTypeProp } from '../hgapi/common';
4+
import {
5+
fetchRecommendations,
6+
getRecommendationsProp,
7+
} from '../hgapi/recommendations';
58

69
export 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+
});
Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,35 @@
11
import { createAction } from '@openops/blocks-framework';
22
import { hyperglanceAuth } from '../auth';
3-
import { getAccountProp, getTagKeyProp, getTagValueProp, search, SearchPropsType } from '../hgapi/search';
43
import { getDatasourceProp, getResourceTypeProp } from '../hgapi/common';
4+
import {
5+
getAccountProp,
6+
getTagKeyProp,
7+
getTagValueProp,
8+
search,
9+
SearchPropsType,
10+
} from '../hgapi/search';
511

612
export const searchTopology = createAction({
713
auth: hyperglanceAuth,
814
name: 'searchTopology',
915
displayName: 'Get Resource List',
10-
description: 'Returns a list of all entities which match the applied filter criteria',
16+
description:
17+
'Returns a list of all entities which match the applied filter criteria',
1118
props: {
12-
datasource: getDatasourceProp({ required : false, description:'Get resources in regards to this cloud provider'}),
13-
type: getResourceTypeProp({required: true, description:'Get resources in regards to this type of resource'}),
14-
account:getAccountProp(),
19+
datasource: getDatasourceProp({
20+
required: false,
21+
description: 'Get resources in regards to this cloud provider',
22+
}),
23+
type: getResourceTypeProp({
24+
required: true,
25+
description: 'Get resources in regards to this type of resource',
26+
}),
27+
account: getAccountProp(),
1528
tagKey: getTagKeyProp(),
16-
tagValue: getTagValueProp()
29+
tagValue: getTagValueProp(),
1730
},
1831
isWriteAction: false,
1932
async run(context) {
2033
return await search(context.auth, context.propsValue as SearchPropsType);
2134
},
22-
});
35+
});

packages/blocks/hyperglance/src/lib/auth.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,27 @@ export const hyperglanceAuth = BlockAuth.CustomAuth({
1313
description: 'The instance URL for Hyperglance',
1414
required: true,
1515
}),
16-
authToken: Property.SecretText({
16+
authToken: Property.SecretText({
1717
displayName: 'Auth Token',
1818
description: 'The API auth token. E.g BASIC fhdhdhdbfbdb= ',
1919
required: true,
2020
}),
2121
},
2222
validate: async ({ auth }) => {
23-
try {
24-
await makeGetRequest(auth.instanceUrl+"/hgapi/", auth.authToken);
25-
return { valid: true };
26-
} catch (error: any) {
27-
const errorMessage = error?.response?.data?.message || error?.response?.statusText || error?.message || 'Unknown error';
28-
return {
29-
valid: false,
30-
error: errorMessage,
31-
};
32-
}
23+
try {
24+
await makeGetRequest(auth.instanceUrl + '/hgapi/', auth.authToken);
25+
return { valid: true };
26+
} catch (error: any) {
27+
const errorMessage =
28+
error?.response?.data?.message ||
29+
error?.response?.statusText ||
30+
error?.message ||
31+
'Unknown error';
32+
return {
33+
valid: false,
34+
error: errorMessage,
35+
};
36+
}
3337
},
3438
});
3539

packages/blocks/hyperglance/src/lib/callRestApi.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,25 @@ export async function makeGetRequest<T = unknown>(
1111
headers: {
1212
Authorization: `${authToken}`,
1313
'Content-Type': 'application/json',
14-
'Accept': '*/*'
14+
Accept: '*/*',
1515
},
1616
queryParams,
1717
});
1818
return response.body;
1919
}
2020

2121
export async function makePostRequest<T = unknown>(
22-
url: string,
23-
authToken: string,
24-
payload: any
22+
url: string,
23+
authToken: string,
24+
payload: any,
2525
): Promise<T> {
2626
const response = await httpClient.sendRequest<T>({
2727
method: HttpMethod.POST,
2828
url: url,
2929
headers: {
3030
Authorization: `${authToken}`,
3131
'Content-Type': 'application/json',
32-
'Accept': '*/*'
32+
Accept: '*/*',
3333
},
3434
body: payload,
3535
});
@@ -39,16 +39,16 @@ export async function makePostRequest<T = unknown>(
3939
//This will be used in future - delete credentials for example
4040
export async function makeDeleteRequest<T = unknown>(
4141
url: string,
42-
authToken: string
42+
authToken: string,
4343
): Promise<T> {
4444
const response = await httpClient.sendRequest({
4545
method: HttpMethod.DELETE,
4646
url: url,
4747
headers: {
4848
Authorization: `${authToken}`,
4949
'Content-Type': 'application/json',
50-
'Accept': '*/*'
51-
}
50+
Accept: '*/*',
51+
},
5252
});
5353
return response.body;
5454
}

0 commit comments

Comments
 (0)