Skip to content

Commit

Permalink
Merge pull request #1921 from deepfence/ui-feat-2101
Browse files Browse the repository at this point in the history
Bulk delete of integrations
  • Loading branch information
milan-deepfence authored Jan 31, 2024
2 parents 07c9cb1 + 79a3691 commit 1a8c54e
Show file tree
Hide file tree
Showing 10 changed files with 326 additions and 33 deletions.
61 changes: 59 additions & 2 deletions deepfence_frontend/apps/dashboard/api-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -3639,11 +3639,56 @@
"security": [{ "bearer_token": [] }]
}
},
"/deepfence/integration/delete": {
"patch": {
"tags": ["Integration"],
"summary": "Delete Integrations",
"description": "Delete integrations",
"operationId": "deleteIntegrations",
"requestBody": {
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/ModelDeleteIntegrationReq" }
}
}
},
"responses": {
"204": { "description": "No Content" },
"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/integration/{integration_id}": {
"delete": {
"tags": ["Integration"],
"summary": "Delete Integration",
"description": "Delete integration",
"summary": "Delete Single Integration",
"description": "Delete single integration",
"operationId": "deleteIntegration",
"parameters": [
{
Expand Down Expand Up @@ -13066,6 +13111,17 @@
"vulnerability_scan_status": { "type": "string" }
}
},
"ModelDeleteIntegrationReq": {
"required": ["integration_ids"],
"type": "object",
"properties": {
"integration_ids": {
"type": "array",
"items": { "type": "integer" },
"nullable": true
}
}
},
"ModelDeleteRegistryBulkReq": {
"required": ["registry_ids"],
"type": "object",
Expand Down Expand Up @@ -13439,6 +13495,7 @@
}
},
"ModelIntegrationAddReq": {
"required": ["integration_type", "notification_type"],
"type": "object",
"properties": {
"config": { "type": "object", "additionalProperties": {}, "nullable": true },
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 @@ -309,6 +309,7 @@ export function getIntegrationApiClient() {
updateIntegration: integrationApi.updateIntegration.bind(integrationApi),
listIntegration: integrationApi.listIntegration.bind(integrationApi),
deleteIntegration: integrationApi.deleteIntegration.bind(integrationApi),
bulkDeleteIntegration: integrationApi.deleteIntegrations.bind(integrationApi),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ models/ModelComplianceScanTriggerReq.ts
models/ModelConnection.ts
models/ModelContainer.ts
models/ModelContainerImage.ts
models/ModelDeleteIntegrationReq.ts
models/ModelDeleteRegistryBulkReq.ts
models/ModelDownloadReportResponse.ts
models/ModelDownloadScanResultsResponse.ts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import * as runtime from '../runtime';
import type {
ApiDocsBadRequestResponse,
ApiDocsFailureResponse,
ModelDeleteIntegrationReq,
ModelIntegrationAddReq,
ModelIntegrationListResp,
ModelIntegrationUpdateReq,
Expand All @@ -27,6 +28,8 @@ import {
ApiDocsBadRequestResponseToJSON,
ApiDocsFailureResponseFromJSON,
ApiDocsFailureResponseToJSON,
ModelDeleteIntegrationReqFromJSON,
ModelDeleteIntegrationReqToJSON,
ModelIntegrationAddReqFromJSON,
ModelIntegrationAddReqToJSON,
ModelIntegrationListRespFromJSON,
Expand All @@ -45,6 +48,10 @@ export interface DeleteIntegrationRequest {
integrationId: string;
}

export interface DeleteIntegrationsRequest {
modelDeleteIntegrationReq?: ModelDeleteIntegrationReq;
}

export interface UpdateIntegrationRequest {
integrationId: string;
modelIntegrationUpdateReq?: ModelIntegrationUpdateReq;
Expand Down Expand Up @@ -74,8 +81,8 @@ export interface IntegrationApiInterface {
addIntegration(requestParameters: AddIntegrationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ModelMessageResponse>;

/**
* Delete integration
* @summary Delete Integration
* Delete single integration
* @summary Delete Single Integration
* @param {string} integrationId
* @param {*} [options] Override http request option.
* @throws {RequiredError}
Expand All @@ -84,11 +91,27 @@ export interface IntegrationApiInterface {
deleteIntegrationRaw(requestParameters: DeleteIntegrationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>>;

/**
* Delete integration
* Delete Integration
* Delete single integration
* Delete Single Integration
*/
deleteIntegration(requestParameters: DeleteIntegrationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void>;

/**
* Delete integrations
* @summary Delete Integrations
* @param {ModelDeleteIntegrationReq} [modelDeleteIntegrationReq]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof IntegrationApiInterface
*/
deleteIntegrationsRaw(requestParameters: DeleteIntegrationsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>>;

/**
* Delete integrations
* Delete Integrations
*/
deleteIntegrations(requestParameters: DeleteIntegrationsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void>;

/**
* List all the added Integrations
* @summary List Integrations
Expand Down Expand Up @@ -168,8 +191,8 @@ export class IntegrationApi extends runtime.BaseAPI implements IntegrationApiInt
}

/**
* Delete integration
* Delete Integration
* Delete single integration
* Delete Single Integration
*/
async deleteIntegrationRaw(requestParameters: DeleteIntegrationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
if (requestParameters.integrationId === null || requestParameters.integrationId === undefined) {
Expand Down Expand Up @@ -199,13 +222,51 @@ export class IntegrationApi extends runtime.BaseAPI implements IntegrationApiInt
}

/**
* Delete integration
* Delete Integration
* Delete single integration
* Delete Single Integration
*/
async deleteIntegration(requestParameters: DeleteIntegrationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
await this.deleteIntegrationRaw(requestParameters, initOverrides);
}

/**
* Delete integrations
* Delete Integrations
*/
async deleteIntegrationsRaw(requestParameters: DeleteIntegrationsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
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/integration/delete`,
method: 'PATCH',
headers: headerParameters,
query: queryParameters,
body: ModelDeleteIntegrationReqToJSON(requestParameters.modelDeleteIntegrationReq),
}, initOverrides);

return new runtime.VoidApiResponse(response);
}

/**
* Delete integrations
* Delete Integrations
*/
async deleteIntegrations(requestParameters: DeleteIntegrationsRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
await this.deleteIntegrationsRaw(requestParameters, initOverrides);
}

/**
* List all the added Integrations
* List Integrations
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/* tslint:disable */
/* eslint-disable */
/**
* Deepfence ThreatMapper
* Deepfence Runtime API provides programmatic control over Deepfence microservice securing your container, kubernetes and cloud deployments. The API abstracts away underlying infrastructure details like cloud provider, container distros, container orchestrator and type of deployment. This is one uniform API to manage and control security alerts, policies and response to alerts for microservices running anywhere i.e. managed pure greenfield container deployments or a mix of containers, VMs and serverless paradigms like AWS Fargate.
*
* The version of the OpenAPI document: 2.0.0
* Contact: community@deepfence.io
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

import { exists, mapValues } from '../runtime';
/**
*
* @export
* @interface ModelDeleteIntegrationReq
*/
export interface ModelDeleteIntegrationReq {
/**
*
* @type {Array<number>}
* @memberof ModelDeleteIntegrationReq
*/
integration_ids: Array<number> | null;
}

/**
* Check if a given object implements the ModelDeleteIntegrationReq interface.
*/
export function instanceOfModelDeleteIntegrationReq(value: object): boolean {
let isInstance = true;
isInstance = isInstance && "integration_ids" in value;

return isInstance;
}

export function ModelDeleteIntegrationReqFromJSON(json: any): ModelDeleteIntegrationReq {
return ModelDeleteIntegrationReqFromJSONTyped(json, false);
}

export function ModelDeleteIntegrationReqFromJSONTyped(json: any, ignoreDiscriminator: boolean): ModelDeleteIntegrationReq {
if ((json === undefined) || (json === null)) {
return json;
}
return {

'integration_ids': json['integration_ids'],
};
}

export function ModelDeleteIntegrationReqToJSON(value?: ModelDeleteIntegrationReq | null): any {
if (value === undefined) {
return undefined;
}
if (value === null) {
return null;
}
return {

'integration_ids': value.integration_ids,
};
}

Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,22 @@ export interface ModelIntegrationAddReq {
* @type {string}
* @memberof ModelIntegrationAddReq
*/
integration_type?: string;
integration_type: string;
/**
*
* @type {string}
* @memberof ModelIntegrationAddReq
*/
notification_type?: string;
notification_type: string;
}

/**
* Check if a given object implements the ModelIntegrationAddReq interface.
*/
export function instanceOfModelIntegrationAddReq(value: object): boolean {
let isInstance = true;
isInstance = isInstance && "integration_type" in value;
isInstance = isInstance && "notification_type" in value;

return isInstance;
}
Expand All @@ -73,8 +75,8 @@ export function ModelIntegrationAddReqFromJSONTyped(json: any, ignoreDiscriminat

'config': !exists(json, 'config') ? undefined : json['config'],
'filters': !exists(json, 'filters') ? undefined : ModelIntegrationFiltersFromJSON(json['filters']),
'integration_type': !exists(json, 'integration_type') ? undefined : json['integration_type'],
'notification_type': !exists(json, 'notification_type') ? undefined : json['notification_type'],
'integration_type': json['integration_type'],
'notification_type': json['notification_type'],
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export * from './ModelComplianceScanTriggerReq';
export * from './ModelConnection';
export * from './ModelContainer';
export * from './ModelContainerImage';
export * from './ModelDeleteIntegrationReq';
export * from './ModelDeleteRegistryBulkReq';
export * from './ModelDownloadReportResponse';
export * from './ModelDownloadScanResultsResponse';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState } from 'react';
import { useParams } from 'react-router-dom';
import { Table, TableNoDataElement } from 'ui-components';
import { RowSelectionState, Table, TableNoDataElement } from 'ui-components';

import { ModelIntegrationListResp } from '@/api/generated';
import {
Expand All @@ -14,8 +14,12 @@ const DEFAULT_PAGE_SIZE = 10;

export const IntegrationTable = ({
onTableAction,
rowSelectionState,
setRowSelectionState,
}: {
onTableAction: (row: ModelIntegrationListResp, actionType: ActionEnumType) => void;
rowSelectionState: RowSelectionState;
setRowSelectionState: React.Dispatch<React.SetStateAction<RowSelectionState>>;
}) => {
const columns = useIntegrationTableColumn(onTableAction);
const { data: list } = useListIntegrations();
Expand Down Expand Up @@ -44,6 +48,10 @@ export const IntegrationTable = ({
onPageResize={(newSize) => {
setPageSize(newSize);
}}
enableRowSelection
rowSelectionState={rowSelectionState}
onRowSelectionChange={setRowSelectionState}
getRowId={(row) => `${row.id}`}
noDataElement={
<TableNoDataElement text="No integrations found, please add new integration" />
}
Expand Down
Loading

0 comments on commit 1a8c54e

Please sign in to comment.