Get a WAF rule group

Fetches the details of a WAF rule group. **Note:** Applies only to the [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/).

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
 * Get a WAF rule group
8
 * Fetches the details of a WAF rule group.
9

10
**Note:** Applies only to the [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/).
11
 */
12
export async function main(
13
  auth: Cloudflare,
14
  identifier: string,
15
  package_identifier: string,
16
  zone_identifier: string
17
) {
18
  const url = new URL(
19
    `https://api.cloudflare.com/client/v4/zones/${zone_identifier}/firewall/waf/packages/${package_identifier}/groups/${identifier}`
20
  );
21

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