Bunnyx.Shield (Bunnyx v0.3.1)

Copy Markdown View Source

Bunny Shield — WAF, rate limiting, bot detection, and access control for pull zones. A Shield zone wraps a pull zone with security configuration.

Uses the main API client created with Bunnyx.new/1. The Shield API lives under /shield/... on the same base URL.

Usage

client = Bunnyx.new(api_key: "sk-...")

{:ok, zone} = Bunnyx.Shield.create(client, 12345)
{:ok, zones} = Bunnyx.Shield.list(client)
{:ok, zone} = Bunnyx.Shield.get(client, zone.shield_zone_id)
{:ok, zone} = Bunnyx.Shield.get_by_pull_zone(client, 12345)
{:ok, zone} = Bunnyx.Shield.update(client, zone.shield_zone_id, waf_enabled: true)

Summary

Functions

Creates a Shield zone for a pull zone.

Creates a custom WAF rule.

Creates a rate limit for a Shield zone.

Deletes a custom WAF rule.

Returns security event logs for a Shield zone on a given date.

Fetches a Shield zone by ID.

Gets a specific custom access list.

Gets the API Guardian configuration and endpoints for a Shield zone.

Gets the bot detection configuration for a Shield zone.

Fetches a Shield zone by its associated pull zone ID.

Gets a specific custom WAF rule by ID.

Returns the default WAF engine configuration.

Gets the current promotion state for your account.

Gets the upload scanning configuration for a Shield zone.

Gets an AI recommendation for a triggered WAF rule.

Lists all Shield zones.

Lists access list enum types and their values.

Lists all access lists for a Shield zone.

Lists active Shield zones with pull zone mapping.

Lists custom WAF rules for a Shield zone.

Lists all DDoS enum mappings.

Lists rate limits for a Shield zone.

Lists all triggered WAF rules for a Shield zone.

Lists all WAF enum mappings.

Lists available WAF profiles.

Lists all WAF rules available for a Shield zone.

Lists WAF rules segmented by subscription plan.

Returns bot detection metrics for a Shield zone.

Returns detailed metrics for a Shield zone within a time range.

Returns a metrics overview for a Shield zone.

Returns detailed metrics for a specific rate limit.

Returns aggregated rate limit metrics for a Shield zone.

Returns upload scanning metrics for a Shield zone.

Returns metrics for a specific WAF rule within a Shield zone.

Updates a Shield zone's configuration.

Updates access list configuration (enable/disable and action).

Updates an API Guardian endpoint configuration.

Updates the bot detection configuration for a Shield zone.

Updates an existing OpenAPI specification on API Guardian.

Updates the action for a triggered WAF rule.

Updates the upload scanning configuration for a Shield zone.

Uploads an OpenAPI specification to API Guardian.

Functions

create(client, pull_zone_id, opts \\ [])

@spec create(Bunnyx.t() | keyword(), pos_integer(), Bunnyx.Params.attrs()) ::
  {:ok, Bunnyx.Shield.Zone.t()} | {:error, Bunnyx.Error.t()}

Creates a Shield zone for a pull zone.

create_access_list(client, shield_zone_id, attrs)

@spec create_access_list(Bunnyx.t() | keyword(), pos_integer(), Bunnyx.Params.attrs()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Creates a custom access list.

Attributes

  • :name (required) — display name
  • :type (required) — access list type (integer enum)
  • :content (required) — entries separated by newlines
  • :description — optional description
  • :checksum — SHA-256 checksum for integrity

create_custom_waf_rule(client, attrs)

@spec create_custom_waf_rule(Bunnyx.t() | keyword(), Bunnyx.Params.attrs()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Creates a custom WAF rule.

Attributes

  • :shield_zone_id (required) — Shield zone ID
  • :rule_name — rule name
  • :rule_description — rule description
  • :rule_configuration — rule config map (passed through as-is)

create_rate_limit(client, attrs)

@spec create_rate_limit(Bunnyx.t() | keyword(), Bunnyx.Params.attrs()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Creates a rate limit for a Shield zone.

delete_access_list(client, shield_zone_id, access_list_id)

@spec delete_access_list(Bunnyx.t() | keyword(), pos_integer(), pos_integer()) ::
  {:ok, nil} | {:error, Bunnyx.Error.t()}

Deletes a custom access list.

delete_custom_waf_rule(client, rule_id)

@spec delete_custom_waf_rule(Bunnyx.t() | keyword(), pos_integer()) ::
  {:ok, nil} | {:error, Bunnyx.Error.t()}

Deletes a custom WAF rule.

delete_rate_limit(client, rate_limit_id)

@spec delete_rate_limit(Bunnyx.t() | keyword(), pos_integer()) ::
  {:ok, nil} | {:error, Bunnyx.Error.t()}

Deletes a rate limit.

event_logs(client, shield_zone_id, date, continuation_token \\ "")

@spec event_logs(
  Bunnyx.t() | keyword(),
  pos_integer(),
  Date.t() | String.t(),
  String.t()
) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Returns security event logs for a Shield zone on a given date.

The date can be a Date struct or a string in "MM-dd-yyyy" format. Pass a continuation token for pagination.

get(client, shield_zone_id)

@spec get(Bunnyx.t() | keyword(), pos_integer()) ::
  {:ok, Bunnyx.Shield.Zone.t()} | {:error, Bunnyx.Error.t()}

Fetches a Shield zone by ID.

get_access_list(client, shield_zone_id, access_list_id)

@spec get_access_list(Bunnyx.t() | keyword(), pos_integer(), pos_integer()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Gets a specific custom access list.

get_api_guardian(client, shield_zone_id)

@spec get_api_guardian(Bunnyx.t() | keyword(), pos_integer()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Gets the API Guardian configuration and endpoints for a Shield zone.

get_bot_detection(client, shield_zone_id)

@spec get_bot_detection(Bunnyx.t() | keyword(), pos_integer()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Gets the bot detection configuration for a Shield zone.

get_by_pull_zone(client, pull_zone_id)

@spec get_by_pull_zone(Bunnyx.t() | keyword(), pos_integer()) ::
  {:ok, Bunnyx.Shield.Zone.t()} | {:error, Bunnyx.Error.t()}

Fetches a Shield zone by its associated pull zone ID.

get_custom_waf_rule(client, rule_id)

@spec get_custom_waf_rule(Bunnyx.t() | keyword(), pos_integer()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Gets a specific custom WAF rule by ID.

get_default_waf_config(client)

@spec get_default_waf_config(Bunnyx.t() | keyword()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Returns the default WAF engine configuration.

get_promotions(client)

@spec get_promotions(Bunnyx.t() | keyword()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Gets the current promotion state for your account.

get_rate_limit(client, shield_zone_id, rate_limit_id)

@spec get_rate_limit(Bunnyx.t() | keyword(), pos_integer(), pos_integer()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Gets an individual rate limit.

get_upload_scanning(client, shield_zone_id)

@spec get_upload_scanning(Bunnyx.t() | keyword(), pos_integer()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Gets the upload scanning configuration for a Shield zone.

get_waf_ai_recommendation(client, shield_zone_id, rule_id)

@spec get_waf_ai_recommendation(Bunnyx.t() | keyword(), pos_integer(), String.t()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Gets an AI recommendation for a triggered WAF rule.

list(client, opts \\ [])

@spec list(
  Bunnyx.t() | keyword(),
  keyword()
) ::
  {:ok, %{items: [Bunnyx.Shield.Zone.t()], page: map()}}
  | {:error, Bunnyx.Error.t()}

Lists all Shield zones.

Options

  • :page — page number
  • :per_page — items per page

list_access_list_enums(client, shield_zone_id)

@spec list_access_list_enums(Bunnyx.t() | keyword(), pos_integer()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Lists access list enum types and their values.

list_access_lists(client, shield_zone_id)

@spec list_access_lists(Bunnyx.t() | keyword(), pos_integer()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Lists all access lists for a Shield zone.

list_active(client, opts \\ [])

@spec list_active(
  Bunnyx.t() | keyword(),
  keyword()
) ::
  {:ok, %{items: [Bunnyx.Shield.Zone.t()], page: map()}}
  | {:error, Bunnyx.Error.t()}

Lists active Shield zones with pull zone mapping.

list_custom_waf_rules(client, shield_zone_id)

@spec list_custom_waf_rules(Bunnyx.t() | keyword(), pos_integer()) ::
  {:ok, %{items: [map()], page: map()}} | {:error, Bunnyx.Error.t()}

Lists custom WAF rules for a Shield zone.

list_ddos_enums(client)

@spec list_ddos_enums(Bunnyx.t() | keyword()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Lists all DDoS enum mappings.

list_rate_limits(client, shield_zone_id)

@spec list_rate_limits(Bunnyx.t() | keyword(), pos_integer()) ::
  {:ok, %{items: [map()], page: map()}} | {:error, Bunnyx.Error.t()}

Lists rate limits for a Shield zone.

list_triggered_waf_rules(client, shield_zone_id)

@spec list_triggered_waf_rules(Bunnyx.t() | keyword(), pos_integer()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Lists all triggered WAF rules for a Shield zone.

list_waf_enums(client)

@spec list_waf_enums(Bunnyx.t() | keyword()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Lists all WAF enum mappings.

list_waf_profiles(client)

@spec list_waf_profiles(Bunnyx.t() | keyword()) ::
  {:ok, [map()]} | {:error, Bunnyx.Error.t()}

Lists available WAF profiles.

list_waf_rules(client, shield_zone_id)

@spec list_waf_rules(Bunnyx.t() | keyword(), pos_integer()) ::
  {:ok, list()} | {:error, Bunnyx.Error.t()}

Lists all WAF rules available for a Shield zone.

list_waf_rules_by_plan(client)

@spec list_waf_rules_by_plan(Bunnyx.t() | keyword()) ::
  {:ok, list()} | {:error, Bunnyx.Error.t()}

Lists WAF rules segmented by subscription plan.

metrics_bot_detection(client, shield_zone_id)

@spec metrics_bot_detection(Bunnyx.t() | keyword(), pos_integer()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Returns bot detection metrics for a Shield zone.

metrics_detailed(client, shield_zone_id, opts \\ [])

@spec metrics_detailed(Bunnyx.t() | keyword(), pos_integer(), keyword()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Returns detailed metrics for a Shield zone within a time range.

Options

  • :start_date — start date (ISO 8601 string)
  • :end_date — end date (ISO 8601 string)
  • :resolution — time resolution (0-6)

metrics_overview(client, shield_zone_id)

@spec metrics_overview(Bunnyx.t() | keyword(), pos_integer()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Returns a metrics overview for a Shield zone.

metrics_rate_limit(client, rate_limit_id)

@spec metrics_rate_limit(Bunnyx.t() | keyword(), pos_integer()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Returns detailed metrics for a specific rate limit.

metrics_rate_limits(client, shield_zone_id)

@spec metrics_rate_limits(Bunnyx.t() | keyword(), pos_integer()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Returns aggregated rate limit metrics for a Shield zone.

metrics_upload_scanning(client, shield_zone_id)

@spec metrics_upload_scanning(Bunnyx.t() | keyword(), pos_integer()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Returns upload scanning metrics for a Shield zone.

metrics_waf_rule(client, shield_zone_id, rule_id)

@spec metrics_waf_rule(Bunnyx.t() | keyword(), pos_integer(), String.t()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Returns metrics for a specific WAF rule within a Shield zone.

update(client, shield_zone_id, attrs)

@spec update(Bunnyx.t() | keyword(), pos_integer(), Bunnyx.Params.attrs()) ::
  {:ok, Bunnyx.Shield.Zone.t()} | {:error, Bunnyx.Error.t()}

Updates a Shield zone's configuration.

update_access_list(client, shield_zone_id, access_list_id, attrs)

@spec update_access_list(
  Bunnyx.t() | keyword(),
  pos_integer(),
  pos_integer(),
  Bunnyx.Params.attrs()
) :: {:ok, map()} | {:error, Bunnyx.Error.t()}

Updates a custom access list.

update_access_list_config(client, shield_zone_id, config_id, attrs)

@spec update_access_list_config(
  Bunnyx.t() | keyword(),
  pos_integer(),
  pos_integer(),
  keyword()
) :: {:ok, map()} | {:error, Bunnyx.Error.t()}

Updates access list configuration (enable/disable and action).

update_api_guardian_endpoint(client, shield_zone_id, endpoint_id, attrs)

@spec update_api_guardian_endpoint(
  Bunnyx.t() | keyword(),
  pos_integer(),
  pos_integer(),
  keyword()
) :: {:ok, map()} | {:error, Bunnyx.Error.t()}

Updates an API Guardian endpoint configuration.

update_bot_detection(client, shield_zone_id, config)

@spec update_bot_detection(Bunnyx.t() | keyword(), pos_integer(), map()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Updates the bot detection configuration for a Shield zone.

Accepts a map with the full config structure (passed through as JSON).

update_custom_waf_rule(client, rule_id, attrs)

@spec update_custom_waf_rule(
  Bunnyx.t() | keyword(),
  pos_integer(),
  Bunnyx.Params.attrs()
) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Updates a custom WAF rule.

update_openapi_spec(client, shield_zone_id, content, opts \\ [])

@spec update_openapi_spec(
  Bunnyx.t() | keyword(),
  pos_integer(),
  String.t(),
  keyword()
) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Updates an existing OpenAPI specification on API Guardian.

update_rate_limit(client, rate_limit_id, attrs)

@spec update_rate_limit(Bunnyx.t() | keyword(), pos_integer(), Bunnyx.Params.attrs()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Updates a rate limit.

update_triggered_waf_rule(client, shield_zone_id, rule_id, action)

@spec update_triggered_waf_rule(
  Bunnyx.t() | keyword(),
  pos_integer(),
  String.t(),
  integer()
) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Updates the action for a triggered WAF rule.

update_upload_scanning(client, shield_zone_id, config)

@spec update_upload_scanning(Bunnyx.t() | keyword(), pos_integer(), map()) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Updates the upload scanning configuration for a Shield zone.

upload_openapi_spec(client, shield_zone_id, content, opts \\ [])

@spec upload_openapi_spec(
  Bunnyx.t() | keyword(),
  pos_integer(),
  String.t(),
  keyword()
) ::
  {:ok, map()} | {:error, Bunnyx.Error.t()}

Uploads an OpenAPI specification to API Guardian.