Delete a dataset.

Delete a dataset. This deletes all versions of the dataset.

Script cloudflare Verified

by hugo697 ยท 11/16/2023

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 383 days ago
1
type Cloudflare = {
2
  token: string;
3
  email: string;
4
  key: string;
5
};
6
/**
7
 * Delete a dataset.
8
 * Delete a dataset.
9

10
This deletes all versions of the dataset.
11
 */
12
export async function main(
13
  auth: Cloudflare,
14
  account_identifier: string,
15
  dataset_id: string
16
) {
17
  const url = new URL(
18
    `https://api.cloudflare.com/client/v4/accounts/${account_identifier}/dlp/datasets/${dataset_id}`
19
  );
20

21
  const response = await fetch(url, {
22
    method: "DELETE",
23
    headers: {
24
      "X-AUTH-EMAIL": auth.email,
25
      "X-AUTH-KEY": auth.key,
26
      Authorization: "Bearer " + auth.token,
27
    },
28
    body: undefined,
29
  });
30
  if (!response.ok) {
31
    const text = await response.text();
32
    throw new Error(`${response.status} ${text}`);
33
  }
34
  return await response.text();
35
}
36