-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #150 from 4urcloud/dev-esteban-exportSaaSAddOn
Dev esteban export saas addOn
- Loading branch information
Showing
16 changed files
with
240 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { SaveConfig } from "../config.models"; | ||
|
||
export interface KexaSaveConfig extends SaveConfig { | ||
type: "kexa"; | ||
name: string; | ||
token: string; | ||
} |
30 changes: 30 additions & 0 deletions
30
Kexa/services/addOn/exportation/kexaExportation.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { getEnvVar } from "../../manageVarEnvironnement.service"; | ||
import { getContext, getNewLogger } from "../../logger.service"; | ||
import { ProviderResource } from "../../../models/providerResource.models"; | ||
import { getConfig } from "../../../helpers/loaderConfig"; | ||
import { KexaSaveConfig } from "../../../models/export/kexa/config.model"; | ||
|
||
const axios = require('axios'); | ||
const logger = getNewLogger("KexaExportationLogger"); | ||
const context = getContext(); | ||
//const addOnPropertyToSend: { [key: string]: Function; } = loadAddOnsCustomUtility("display", "propertyToSend"); | ||
|
||
export async function exportation(save: KexaSaveConfig, resources: ProviderResource): Promise<void>{ | ||
throw new Error("Not implemented"); | ||
if(!save.name) throw new Error("name is required"); | ||
let name = (await getEnvVar(save.name))??save.name; | ||
let token = (await getEnvVar(save.token))??save.token; | ||
logger.info(`Exportation to Kexa SaaS`); | ||
context?.log(`Exportation to Kexa SaaS`); | ||
const config = getConfig(); | ||
let configSend:any = {}; | ||
Object.keys(resources).forEach((providerName) => { | ||
configSend[providerName] = config[providerName]??[]; | ||
}); | ||
await axios.post((process.env.DOMAINEKEXA??`https://api.kexa.io`) + '/api/job/exportation', {resources: resources, configSend, save}, { | ||
headers: { | ||
User: name, | ||
Authorization: token | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ResultScan } from "../../../models/resultScan.models"; | ||
import { getEnvVar } from "../../manageVarEnvironnement.service"; | ||
import { getContext, getNewLogger } from "../../logger.service"; | ||
import { loadAddOnsCustomUtility } from "../../addOn.service"; | ||
import { KexaSaveConfig } from "../../../models/export/kexa/config.model"; | ||
|
||
const axios = require('axios'); | ||
const logger = getNewLogger("KexaSaveLogger"); | ||
const context = getContext(); | ||
//const addOnPropertyToSend: { [key: string]: Function; } = loadAddOnsCustomUtility("display", "propertyToSend"); | ||
|
||
export async function save(save: KexaSaveConfig, result: ResultScan[][]): Promise<void>{ | ||
throw new Error("Not implemented"); | ||
if(!save.name) throw new Error("name is required"); | ||
let name = (await getEnvVar(save.name))??save.name; | ||
let token = (await getEnvVar(save.token))??save.token; | ||
logger.info(`Saving to Kexa SaaS`); | ||
context?.log(`Saving to Kexa SaaS`); | ||
await axios.post((process.env.DOMAINEKEXA??`https://api.kexa.io`) + `/api/job/save`, {result: result, save}, { | ||
headers: { | ||
User: name, | ||
Authorization: token | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.14.0-SNAPSHOT.32.8960e5d | ||
1.14.0-devestebanexportsaasaddon.38.b0f21a8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"azure": [ | ||
{ | ||
"name": "Project A", | ||
"prefix": "PROJECTA-", | ||
"description": "First subscription (0) : Project A subscription", | ||
"rules": [ | ||
"Name of my rule" | ||
] | ||
}, | ||
{ | ||
"name": "Project B", | ||
"prefix": "PROJECTB-", | ||
"description": "Second subscription (1) : Project B subscription", | ||
"rules": [ | ||
"Name of my rule", | ||
"Another rules" | ||
] | ||
} | ||
], | ||
"save": [ | ||
{ | ||
"type": "kexa", | ||
"name": "name of the token or the name of the var environment where the real name is stored", | ||
"token": "token for kexa or the name of the var environment where the token is stored: the format is uuid4", | ||
"description": "example of save for kexa" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<div align="center"> | ||
<a href="https://www.kexa.io/modules"> | ||
<img src="../../images/kexa-no-background-color.png" alt="Logo" width="200"> | ||
</a> | ||
|
||
# <h3 align="center">Kexa SaaS</h3> | ||
|
||
<p align="center"> | ||
<br /> | ||
<a href="https://github.com/4urcloud/Kexa/issues">Report Bug</a> | ||
· | ||
<a href="https://github.com/4urcloud/Kexa/issues">Request Feature</a> | ||
</p> | ||
</div> | ||
|
||
## Configuration | ||
|
||
### Prerequire | ||
|
||
Create a token in the [web site](https://saas.kexa.io). | ||
|
||
### Default.json | ||
|
||
Keys mandatory: | ||
|
||
- name: the name of the key you generated in the Kexa portal | ||
- token: the token himself | ||
|
||
Example config for each identification you can use: | ||
![example config for kexa](../../config/demo/kexa.default.json) | ||
|
||
### Environment | ||
|
||
"name" and "token" can be use to refer to a specific value in your environnement with his name as value. | ||
|
||
### Utility | ||
|
||
By saving or exporting your data from your kexa to the SaaS service, you can use all the viewing tools available to you. | ||
The data sent using this method is in no way processed by anyone other than yourself. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters