Skip to content

Commit df773ea

Browse files
daveagillrashmi-sy
andauthored
Add Hyperglance block (#1589)
Fixes OPS-3000 This PR adds the initial version of the Hyperglance block. ## Additional Notes <img width="675" height="464" alt="image" src="https://github.com/user-attachments/assets/af965262-d7c1-4023-98d0-aaca66186825" /> Actions added in this PR: * Export Diagram * Get Recommendations * Get Resource List * Get Credential Statistics * Get Credential Status * List Credentials * Custom API Call ## Testing Checklist Check all that apply: - [x] I tested the feature thoroughly, including edge cases - [x] I verified all affected areas still work as expected - [x] Automated tests were added/updated if necessary - [x] Changes are backwards compatible with any existing data, otherwise a migration script is provided Co-authored-by: Rashmi Shenoy <rshenoy@hyperglance.com>
1 parent 4d3bb04 commit df773ea

24 files changed

Lines changed: 747 additions & 0 deletions
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"extends": ["../../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7+
"rules": {}
8+
},
9+
{
10+
"files": ["*.ts", "*.tsx"],
11+
"rules": {}
12+
},
13+
{
14+
"files": ["*.js", "*.jsx"],
15+
"rules": {}
16+
}
17+
]
18+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# blocks-hyperglance
2+
3+
This library was generated with [Nx](https://nx.dev).
4+
5+
## Building
6+
7+
Run `nx build blocks-hyperglance` to build the library.
8+
9+
## Running unit tests
10+
11+
Run `nx test blocks-hyperglance` to execute the unit tests via [Jest](https://jestjs.io).
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export default {
2+
displayName: 'blocks-hyperglance',
3+
preset: '../../../jest.preset.js',
4+
setupFiles: ['../../../jest.env.js'],
5+
testEnvironment: 'node',
6+
transform: {
7+
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
8+
},
9+
moduleFileExtensions: ['ts', 'js', 'html'],
10+
coverageDirectory: '../../../coverage/packages/blocks/hyperglance',
11+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "hyperglance",
3+
"version": "0.0.1"
4+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "blocks-hyperglance",
3+
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "packages/blocks/hyperglance/src",
5+
"projectType": "library",
6+
"tags": [],
7+
"targets": {
8+
"build": {
9+
"executor": "@nx/js:tsc",
10+
"outputs": ["{options.outputPath}"],
11+
"options": {
12+
"outputPath": "dist/packages/blocks/hyperglance",
13+
"tsConfig": "packages/blocks/hyperglance/tsconfig.lib.json",
14+
"packageJson": "packages/blocks/hyperglance/package.json",
15+
"main": "packages/blocks/hyperglance/src/index.ts",
16+
"assets": ["packages/blocks/hyperglance/*.md"],
17+
"buildableProjectDepsInPackageJsonType": "dependencies",
18+
"updateBuildableProjectDepsInPackageJson": true
19+
}
20+
},
21+
"test": {
22+
"executor": "@nx/jest:jest",
23+
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
24+
"options": {
25+
"jestConfig": "packages/blocks/hyperglance/jest.config.ts"
26+
}
27+
},
28+
"lint": {
29+
"executor": "@nx/eslint:lint",
30+
"outputs": ["{options.outputFile}"]
31+
}
32+
}
33+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { createCustomApiCallAction } from '@openops/blocks-common';
2+
import { createBlock, Property } from '@openops/blocks-framework';
3+
import { BlockCategory } from '@openops/shared';
4+
import { HGAuth, hyperglanceAuth } from './lib/auth';
5+
import { getRecommendations} from './lib/actions/getRecommendations';
6+
import { exportTopologyForGroup } from './lib/actions/exportTopologyForGroup';
7+
import { searchTopology } from './lib/actions/searchTopology';
8+
import { getCollectorRecords } from './lib/actions/getCollectorRecords';
9+
import { getCollectorRecordStatus } from './lib/actions/getCollectorRecordStatus';
10+
import { getCollectorRecordStatistics } from './lib/actions/getCollectorRecordStatistics';
11+
12+
export const hyperglance = createBlock({
13+
displayName: 'Hyperglance',
14+
auth: hyperglanceAuth,
15+
minimumSupportedRelease: '0.20.0',
16+
logoUrl: 'https://static.openops.com/blocks/hyperglance.svg',
17+
authors: [],
18+
categories: [BlockCategory.FINOPS],
19+
actions: [
20+
exportTopologyForGroup,
21+
getCollectorRecordStatistics,
22+
getCollectorRecordStatus,
23+
getRecommendations,
24+
searchTopology,
25+
getCollectorRecords,
26+
createCustomApiCallAction({
27+
baseUrl: (auth) => {
28+
return `${(auth as HGAuth).instanceUrl}/hgapi/`;
29+
},
30+
auth: hyperglanceAuth,
31+
additionalProps: {
32+
documentation: Property.MarkDown({
33+
value:
34+
'For more information, visit the [Hyperglance API documentation](https://support.hyperglance.com/knowledge/getting-started-with-the-hyperglance-api).',
35+
}),
36+
},
37+
name:'customHgApiCall'
38+
}),
39+
],
40+
triggers: [],
41+
});
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { createAction } from '@openops/blocks-framework';
2+
import { hyperglanceAuth } from '../auth';
3+
import { exportTopology, getAccountProp, getExportTypeProp, getIDProp, getIncludeDependenciesProp, getShowCostProp } from '../hgapi/topology';
4+
import { getDatasourceProp } from '../hgapi/common';
5+
6+
export const exportTopologyForGroup = createAction({
7+
auth: hyperglanceAuth,
8+
name: 'exportTopologyForGroup',
9+
displayName: 'Export Diagram',
10+
description: 'Export a diagram group to PNG or Visio (VSDX)',
11+
props: {
12+
datasource: getDatasourceProp(),
13+
account:getAccountProp(),
14+
id:getIDProp(),
15+
includeDependencies:getIncludeDependenciesProp(),
16+
showCost:getShowCostProp(),
17+
exportType : getExportTypeProp()
18+
},
19+
isWriteAction: false,
20+
async run(context) {
21+
const {auth, propsValue} = context;
22+
23+
return await exportTopology(auth, propsValue);
24+
},
25+
});
26+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { createAction } from '@openops/blocks-framework';
2+
import { hyperglanceAuth } from '../auth';
3+
import { getDatasourceProp } from '../hgapi/common';
4+
import { getAliasDropdownProp, getRecordStatistics } from '../hgapi/collectorRecords';
5+
6+
export const getCollectorRecordStatistics = createAction({
7+
auth: hyperglanceAuth,
8+
name: 'getCollectorRecordStatistics',
9+
displayName: 'Get Credential Statistics',
10+
description: 'Returns Collection Statistics for the credential',
11+
props: {
12+
datasource: getDatasourceProp({description:'Get credential of this cloud provider'}),
13+
alias: getAliasDropdownProp()
14+
},
15+
isWriteAction: false,
16+
async run(context) {
17+
const {datasource="", alias} = context.propsValue;
18+
return await getRecordStatistics(context.auth, datasource, alias);
19+
},
20+
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { createAction } from '@openops/blocks-framework';
2+
import { hyperglanceAuth } from '../auth';
3+
import { getDatasourceProp } from '../hgapi/common';
4+
import { getAliasDropdownProp, getRecordStatus } from '../hgapi/collectorRecords';
5+
6+
export const getCollectorRecordStatus = createAction({
7+
auth: hyperglanceAuth,
8+
name: 'getCollectorRecordStatus',
9+
displayName: 'Get Credential Status',
10+
description: 'Returns Collector Record Status',
11+
props: {
12+
datasource: getDatasourceProp({description:'Get credential of this cloud provider'}),
13+
alias: getAliasDropdownProp()
14+
},
15+
isWriteAction: false,
16+
async run(context) {
17+
const {datasource="", alias} = context.propsValue;
18+
return await getRecordStatus(context.auth, datasource, alias);
19+
},
20+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { createAction } from '@openops/blocks-framework';
2+
import { hyperglanceAuth } from '../auth';
3+
import { getDatasourceProp } from '../hgapi/common';
4+
import { listRecords } from '../hgapi/collectorRecords';
5+
6+
export const getCollectorRecords = createAction({
7+
auth: hyperglanceAuth,
8+
name: 'getCollectorRecords',
9+
displayName: 'List Credentials',
10+
description: 'List All Hyperglance Credentials',
11+
props: {
12+
datasource: getDatasourceProp({description:'List credentials of this cloud provider'})
13+
},
14+
isWriteAction: false,
15+
async run(context) {
16+
return await listRecords(context.auth, context.propsValue.datasource??"");
17+
},
18+
});

0 commit comments

Comments
 (0)