Skip to content

Commit

Permalink
migrate foundry-js to the new Alerts API
Browse files Browse the repository at this point in the history
  • Loading branch information
cs-ade-adesokan committed Dec 2, 2024
1 parent 47b9090 commit 58bbb62
Show file tree
Hide file tree
Showing 3 changed files with 486 additions and 219 deletions.
10 changes: 10 additions & 0 deletions .changeset/loud-lies-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@crowdstrike/foundry-js': minor
---

Added upgraded alerts api methods
- deprecated `getQueriesAlertsV1` and added `getQueriesAlertsV2`to be used in its place.
- deprecated `patchCombinedAlertsV2` and added `patchCombinedAlertsV3`to be used in its place.
- deprecated `patchEntitiesAlertsV2` and added `patchEntitiesAlertsV3`to be used in its place.
- deprecated `postAggregatesAlertsV1` and added `postAggregatesAlertsV2`to be used in its place.
- deprecated `postEntitiesAlertsV1` and added `postEntitiesAlertsV2`to be used in its place.
237 changes: 237 additions & 0 deletions src/apis/alerts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,29 @@ export interface GetQueriesAlertsV1RequestMessage
method: 'getQueriesAlertsV1';
}

// types for getQueriesAlertsV2

export interface GetQueriesAlertsV2QueryParams extends BaseUrlParams {
filter?: string;
limit?: QueryParam;
offset?: QueryParam;
q?: QueryParam;
sort?: QueryParam;
msspRouteCid?: QueryParam;
includeHidden?: QueryParam;
}

export type GetQueriesAlertsV2ApiResponse = ApiResponsePayload;

export type GetQueriesAlertsV2ResponseMessage =
BaseApiResponseMessage<GetQueriesAlertsV2ApiResponse>;

export interface GetQueriesAlertsV2RequestMessage
extends BaseApiRequestMessage<GetQueriesAlertsV2QueryParams> {
api: AlertsRequestApi;
method: 'getQueriesAlertsV2';
}

// types for patchCombinedAlertsV2

export type PatchCombinedAlertsV2QueryParams = BaseUrlParams;
Expand All @@ -85,6 +108,29 @@ export interface PatchCombinedAlertsV2RequestMessage
method: 'patchCombinedAlertsV2';
}

// types for patchCombinedAlertsV3

export interface PatchCombinedAlertsV3QueryParams extends BaseUrlParams {
msspRouteCid?: QueryParam;
includeHidden?: QueryParam;
}

export type PatchCombinedAlertsV3ApiResponse = ApiResponsePayload;

export interface PatchCombinedAlertsV3PostData {}

export type PatchCombinedAlertsV3ResponseMessage =
BaseApiResponseMessage<PatchCombinedAlertsV3ApiResponse>;

export interface PatchCombinedAlertsV3RequestMessage
extends BaseApiRequestMessage<
PatchCombinedAlertsV3QueryParams,
PatchCombinedAlertsV3PostData
> {
api: AlertsRequestApi;
method: 'patchCombinedAlertsV3';
}

// types for patchEntitiesAlertsV2

export type PatchEntitiesAlertsV2QueryParams = BaseUrlParams;
Expand All @@ -105,6 +151,28 @@ export interface PatchEntitiesAlertsV2RequestMessage
method: 'patchEntitiesAlertsV2';
}

// types for patchEntitiesAlertsV3

export interface PatchEntitiesAlertsV3QueryParams extends BaseUrlParams {
msspRouteCid?: QueryParam;
}

export type PatchEntitiesAlertsV3ApiResponse = ApiResponsePayload;

export interface PatchEntitiesAlertsV3PostData {}

export type PatchEntitiesAlertsV3ResponseMessage =
BaseApiResponseMessage<PatchEntitiesAlertsV3ApiResponse>;

export interface PatchEntitiesAlertsV3RequestMessage
extends BaseApiRequestMessage<
PatchEntitiesAlertsV3QueryParams,
PatchEntitiesAlertsV3PostData
> {
api: AlertsRequestApi;
method: 'patchEntitiesAlertsV3';
}

// types for patchEntitiesSuppressedDevicesV1

export interface PatchEntitiesSuppressedDevicesV1QueryParams
Expand Down Expand Up @@ -165,6 +233,45 @@ export interface PostAggregatesAlertsV1RequestMessage
method: 'postAggregatesAlertsV1';
}

// types for postAggregatesAlertsV2

export interface PostAggregatesAlertsV2QueryParams extends BaseUrlParams {
dateRanges?: QueryParam;
field?: QueryParam;
filter?: string;
from?: QueryParam;
include?: QueryParam;
interval?: QueryParam;
minDocCount?: QueryParam;
missing?: QueryParam;
msspRouteCid?: QueryParam;
name?: QueryParam;
q?: QueryParam;
ranges?: QueryParam;
size?: QueryParam;
sort?: QueryParam;
subAggregates?: QueryParam;
timeZone?: QueryParam;
type?: QueryParam;
includeHidden?: QueryParam;
}

export type PostAggregatesAlertsV2ApiResponse = ApiResponsePayload;

export interface PostAggregatesAlertsV2PostData {}

export type PostAggregatesAlertsV2ResponseMessage =
BaseApiResponseMessage<PostAggregatesAlertsV2ApiResponse>;

export interface PostAggregatesAlertsV2RequestMessage
extends BaseApiRequestMessage<
PostAggregatesAlertsV2QueryParams,
PostAggregatesAlertsV2PostData
> {
api: AlertsRequestApi;
method: 'postAggregatesAlertsV2';
}

// types for postEntitiesAlertsV1

export interface PostEntitiesAlertsV1QueryParams extends BaseUrlParams {
Expand All @@ -187,6 +294,28 @@ export interface PostEntitiesAlertsV1RequestMessage
method: 'postEntitiesAlertsV1';
}

// types for postEntitiesAlertsV2

export interface PostEntitiesAlertsV2QueryParams extends BaseUrlParams {
compositeIds?: QueryParam;
}

export type PostEntitiesAlertsV2ApiResponse = ApiResponsePayload;

export interface PostEntitiesAlertsV2PostData {}

export type PostEntitiesAlertsV2ResponseMessage =
BaseApiResponseMessage<PostEntitiesAlertsV2ApiResponse>;

export interface PostEntitiesAlertsV2RequestMessage
extends BaseApiRequestMessage<
PostEntitiesAlertsV2QueryParams,
PostEntitiesAlertsV2PostData
> {
api: AlertsRequestApi;
method: 'postEntitiesAlertsV2';
}

// types for postEntitiesSuppressedDevicesV1

export type PostEntitiesSuppressedDevicesV1QueryParams = BaseUrlParams;
Expand All @@ -212,21 +341,31 @@ export interface PostEntitiesSuppressedDevicesV1RequestMessage
export type AlertsApiRequestMessage =
| DeleteEntitiesSuppressedDevicesV1RequestMessage
| GetQueriesAlertsV1RequestMessage
| GetQueriesAlertsV2RequestMessage
| PatchCombinedAlertsV2RequestMessage
| PatchCombinedAlertsV3RequestMessage
| PatchEntitiesAlertsV2RequestMessage
| PatchEntitiesAlertsV3RequestMessage
| PatchEntitiesSuppressedDevicesV1RequestMessage
| PostAggregatesAlertsV1RequestMessage
| PostAggregatesAlertsV2RequestMessage
| PostEntitiesAlertsV1RequestMessage
| PostEntitiesAlertsV2RequestMessage
| PostEntitiesSuppressedDevicesV1RequestMessage;

export type AlertsApiResponseMessage =
| DeleteEntitiesSuppressedDevicesV1ResponseMessage
| GetQueriesAlertsV1ResponseMessage
| GetQueriesAlertsV2ResponseMessage
| PatchCombinedAlertsV2ResponseMessage
| PatchCombinedAlertsV3ResponseMessage
| PatchEntitiesAlertsV2ResponseMessage
| PatchEntitiesAlertsV3ResponseMessage
| PatchEntitiesSuppressedDevicesV1ResponseMessage
| PostAggregatesAlertsV1ResponseMessage
| PostAggregatesAlertsV2ResponseMessage
| PostEntitiesAlertsV1ResponseMessage
| PostEntitiesAlertsV2ResponseMessage
| PostEntitiesSuppressedDevicesV1ResponseMessage;

export class AlertsApiBridge {
Expand Down Expand Up @@ -255,6 +394,9 @@ export class AlertsApiBridge {
return this.bridge.postMessage(message);
}

/**
* @deprecated This method is deprecated. Use getQueriesAlertsV2 instead.
*/
async getQueriesAlertsV1(
urlParams: GetQueriesAlertsV1QueryParams = {},
): Promise<GetQueriesAlertsV1ApiResponse> {
Expand All @@ -270,6 +412,24 @@ export class AlertsApiBridge {
return this.bridge.postMessage(message);
}

async getQueriesAlertsV2(
urlParams: GetQueriesAlertsV2QueryParams = {},
): Promise<GetQueriesAlertsV2ApiResponse> {
const message: GetQueriesAlertsV2RequestMessage = {
type: 'api',
api: 'alerts',
method: 'getQueriesAlertsV2',
payload: {
params: urlParams,
},
};

return this.bridge.postMessage(message);
}

/**
* @deprecated This method is deprecated. Use patchCombinedAlertsV3 instead.
*/
async patchCombinedAlertsV2(
postBody: PatchCombinedAlertsV2PostData,
urlParams: PatchCombinedAlertsV2QueryParams = {},
Expand All @@ -287,6 +447,26 @@ export class AlertsApiBridge {
return this.bridge.postMessage(message);
}

async patchCombinedAlertsV3(
postBody: PatchCombinedAlertsV3PostData,
urlParams: PatchCombinedAlertsV3QueryParams = {},
): Promise<PatchCombinedAlertsV3ApiResponse> {
const message: PatchCombinedAlertsV3RequestMessage = {
type: 'api',
api: 'alerts',
method: 'patchCombinedAlertsV3',
payload: {
body: postBody,
params: urlParams,
},
};

return this.bridge.postMessage(message);
}

/**
* @deprecated This method is deprecated. Use patchEntitiesAlertsV3 instead.
*/
async patchEntitiesAlertsV2(
postBody: PatchEntitiesAlertsV2PostData,
urlParams: PatchEntitiesAlertsV2QueryParams = {},
Expand All @@ -304,6 +484,23 @@ export class AlertsApiBridge {
return this.bridge.postMessage(message);
}

async patchEntitiesAlertsV3(
postBody: PatchEntitiesAlertsV3PostData,
urlParams: PatchEntitiesAlertsV3QueryParams = {},
): Promise<PatchEntitiesAlertsV3ApiResponse> {
const message: PatchEntitiesAlertsV3RequestMessage = {
type: 'api',
api: 'alerts',
method: 'patchEntitiesAlertsV3',
payload: {
body: postBody,
params: urlParams,
},
};

return this.bridge.postMessage(message);
}

async patchEntitiesSuppressedDevicesV1(
postBody: PatchEntitiesSuppressedDevicesV1PostData,
urlParams: PatchEntitiesSuppressedDevicesV1QueryParams = {},
Expand All @@ -321,6 +518,9 @@ export class AlertsApiBridge {
return this.bridge.postMessage(message);
}

/**
* @deprecated This method is deprecated. Use postAggregatesAlertsV2 instead.
*/
async postAggregatesAlertsV1(
postBody: PostAggregatesAlertsV1PostData,
urlParams: PostAggregatesAlertsV1QueryParams = {},
Expand All @@ -338,6 +538,26 @@ export class AlertsApiBridge {
return this.bridge.postMessage(message);
}

async postAggregatesAlertsV2(
postBody: PostAggregatesAlertsV2PostData,
urlParams: PostAggregatesAlertsV2QueryParams = {},
): Promise<PostAggregatesAlertsV2ApiResponse> {
const message: PostAggregatesAlertsV2RequestMessage = {
type: 'api',
api: 'alerts',
method: 'postAggregatesAlertsV2',
payload: {
body: postBody,
params: urlParams,
},
};

return this.bridge.postMessage(message);
}

/**
* @deprecated This method is deprecated. Use postEntitiesAlertsV2 instead.
*/
async postEntitiesAlertsV1(
postBody: PostEntitiesAlertsV1PostData,
urlParams: PostEntitiesAlertsV1QueryParams = {},
Expand All @@ -355,6 +575,23 @@ export class AlertsApiBridge {
return this.bridge.postMessage(message);
}

async postEntitiesAlertsV2(
postBody: PostEntitiesAlertsV2PostData,
urlParams: PostEntitiesAlertsV2QueryParams = {},
): Promise<PostEntitiesAlertsV2ApiResponse> {
const message: PostEntitiesAlertsV2RequestMessage = {
type: 'api',
api: 'alerts',
method: 'postEntitiesAlertsV2',
payload: {
body: postBody,
params: urlParams,
},
};

return this.bridge.postMessage(message);
}

async postEntitiesSuppressedDevicesV1(
postBody: PostEntitiesSuppressedDevicesV1PostData,
urlParams: PostEntitiesSuppressedDevicesV1QueryParams = {},
Expand Down
Loading

0 comments on commit 58bbb62

Please sign in to comment.