Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added test email feature in email configuration #2059

Merged
merged 3 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions deepfence_frontend/apps/dashboard/api-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -11069,6 +11069,103 @@
"security": [{ "bearer_token": [] }]
}
},
"/deepfence/settings/email/test": {
"post": {
"tags": ["Settings"],
"summary": "Test Configured Email",
"description": "Test Configured Email",
"operationId": "testConfiguredEmail",
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/ModelMessageResponse" }
}
}
},
"400": {
"description": "Bad Request",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/ApiDocsBadRequestResponse" }
}
}
},
"401": { "description": "Unauthorized" },
"403": { "description": "Forbidden" },
"404": {
"description": "Not Found",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/ApiDocsFailureResponse" }
}
}
},
"500": {
"description": "Internal Server Error",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/ApiDocsFailureResponse" }
}
}
}
},
"security": [{ "bearer_token": [] }]
}
},
"/deepfence/settings/email/test-unconfigured": {
"post": {
"tags": ["Settings"],
"summary": "Test Unconfigured Email",
"description": "Test Unconfigured Email",
"operationId": "testUnconfiguredEmail",
"requestBody": {
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/ModelEmailConfigurationAdd" }
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/ModelMessageResponse" }
}
}
},
"400": {
"description": "Bad Request",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/ApiDocsBadRequestResponse" }
}
}
},
"401": { "description": "Unauthorized" },
"403": { "description": "Forbidden" },
"404": {
"description": "Not Found",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/ApiDocsFailureResponse" }
}
}
},
"500": {
"description": "Internal Server Error",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/ApiDocsFailureResponse" }
}
}
}
},
"security": [{ "bearer_token": [] }]
}
},
"/deepfence/settings/email/{config_id}": {
"delete": {
"tags": ["Settings"],
Expand Down Expand Up @@ -13712,6 +13809,7 @@
"properties": {
"amazon_access_key": { "type": "string" },
"amazon_secret_key": { "type": "string" },
"apikey": { "type": "string" },
"created_by_user_id": { "type": "integer" },
"email_id": { "type": "string" },
"email_provider": { "type": "string" },
Expand Down
1 change: 1 addition & 0 deletions deepfence_frontend/apps/dashboard/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ export function getSettingsApiClient() {
registerThreatMapperLicense: settingsApi.registerLicense.bind(settingsApi),
getThreatMapperLicense: settingsApi.getLicense.bind(settingsApi),
deleteThreatMapperLicense: settingsApi.deleteLicense.bind(settingsApi),
testUnconfiguredEmail: settingsApi.testUnconfiguredEmail.bind(settingsApi),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ export interface RegisterLicenseRequest {
modelRegisterLicenseRequest?: ModelRegisterLicenseRequest;
}

export interface TestUnconfiguredEmailRequest {
modelEmailConfigurationAdd?: ModelEmailConfigurationAdd;
}

export interface UpdateScheduledTaskRequest {
id: number;
modelUpdateScheduledTaskRequest?: ModelUpdateScheduledTaskRequest;
Expand Down Expand Up @@ -376,6 +380,37 @@ export interface SettingsApiInterface {
*/
registerLicense(requestParameters: RegisterLicenseRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ModelRegisterLicenseResponse>;

/**
* Test Configured Email
* @summary Test Configured Email
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof SettingsApiInterface
*/
testConfiguredEmailRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ModelMessageResponse>>;

/**
* Test Configured Email
* Test Configured Email
*/
testConfiguredEmail(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ModelMessageResponse>;

/**
* Test Unconfigured Email
* @summary Test Unconfigured Email
* @param {ModelEmailConfigurationAdd} [modelEmailConfigurationAdd]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof SettingsApiInterface
*/
testUnconfiguredEmailRaw(requestParameters: TestUnconfiguredEmailRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ModelMessageResponse>>;

/**
* Test Unconfigured Email
* Test Unconfigured Email
*/
testUnconfiguredEmail(requestParameters: TestUnconfiguredEmailRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ModelMessageResponse>;

/**
* Update scheduled task
* @summary Update scheduled task
Expand Down Expand Up @@ -1056,6 +1091,81 @@ export class SettingsApi extends runtime.BaseAPI implements SettingsApiInterface
return await response.value();
}

/**
* Test Configured Email
* Test Configured Email
*/
async testConfiguredEmailRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ModelMessageResponse>> {
const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};

if (this.configuration && this.configuration.accessToken) {
const token = this.configuration.accessToken;
const tokenString = await token("bearer_token", []);

if (tokenString) {
headerParameters["Authorization"] = `Bearer ${tokenString}`;
}
}
const response = await this.request({
path: `/deepfence/settings/email/test`,
method: 'POST',
headers: headerParameters,
query: queryParameters,
}, initOverrides);

return new runtime.JSONApiResponse(response, (jsonValue) => ModelMessageResponseFromJSON(jsonValue));
}

/**
* Test Configured Email
* Test Configured Email
*/
async testConfiguredEmail(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ModelMessageResponse> {
const response = await this.testConfiguredEmailRaw(initOverrides);
return await response.value();
}

/**
* Test Unconfigured Email
* Test Unconfigured Email
*/
async testUnconfiguredEmailRaw(requestParameters: TestUnconfiguredEmailRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ModelMessageResponse>> {
const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};

headerParameters['Content-Type'] = 'application/json';

if (this.configuration && this.configuration.accessToken) {
const token = this.configuration.accessToken;
const tokenString = await token("bearer_token", []);

if (tokenString) {
headerParameters["Authorization"] = `Bearer ${tokenString}`;
}
}
const response = await this.request({
path: `/deepfence/settings/email/test-unconfigured`,
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: ModelEmailConfigurationAddToJSON(requestParameters.modelEmailConfigurationAdd),
}, initOverrides);

return new runtime.JSONApiResponse(response, (jsonValue) => ModelMessageResponseFromJSON(jsonValue));
}

/**
* Test Unconfigured Email
* Test Unconfigured Email
*/
async testUnconfiguredEmail(requestParameters: TestUnconfiguredEmailRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ModelMessageResponse> {
const response = await this.testUnconfiguredEmailRaw(requestParameters, initOverrides);
return await response.value();
}

/**
* Update scheduled task
* Update scheduled task
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ export interface ModelEmailConfigurationAdd {
* @memberof ModelEmailConfigurationAdd
*/
amazon_secret_key?: string;
/**
*
* @type {string}
* @memberof ModelEmailConfigurationAdd
*/
apikey?: string;
/**
*
* @type {number}
Expand Down Expand Up @@ -96,6 +102,7 @@ export function ModelEmailConfigurationAddFromJSONTyped(json: any, ignoreDiscrim

'amazon_access_key': !exists(json, 'amazon_access_key') ? undefined : json['amazon_access_key'],
'amazon_secret_key': !exists(json, 'amazon_secret_key') ? undefined : json['amazon_secret_key'],
'apikey': !exists(json, 'apikey') ? undefined : json['apikey'],
'created_by_user_id': !exists(json, 'created_by_user_id') ? undefined : json['created_by_user_id'],
'email_id': !exists(json, 'email_id') ? undefined : json['email_id'],
'email_provider': !exists(json, 'email_provider') ? undefined : json['email_provider'],
Expand All @@ -117,6 +124,7 @@ export function ModelEmailConfigurationAddToJSON(value?: ModelEmailConfiguration

'amazon_access_key': value.amazon_access_key,
'amazon_secret_key': value.amazon_secret_key,
'apikey': value.apikey,
'created_by_user_id': value.created_by_user_id,
'email_id': value.email_id,
'email_provider': value.email_provider,
Expand Down
Loading
Loading