Table of Contents

Interface IAccountRulesetsApi

Namespace
Cloudflare.NET.Accounts.Rulesets
Assembly
Cloudflare.NET.dll

Defines the contract for managing Rulesets at the account level.

This includes WAF Custom Rules, Rate Limiting Rules, and other advanced configurations that apply across all zones in an account.

public interface IAccountRulesetsApi

Methods

AddRuleAsync(string, CreateRuleRequest, CancellationToken)

Adds a new rule to a specific account-level ruleset.

Task<Ruleset> AddRuleAsync(string rulesetId, CreateRuleRequest rule, CancellationToken cancellationToken = default)

Parameters

rulesetId string

The ID of the ruleset.

rule CreateRuleRequest

The rule to add.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<Ruleset>

The updated parent ruleset.

CreateAsync(CreateRulesetRequest, CancellationToken)

Creates a new ruleset for the account.

Task<Ruleset> CreateAsync(CreateRulesetRequest request, CancellationToken cancellationToken = default)

Parameters

request CreateRulesetRequest

The request containing the details of the ruleset to create.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<Ruleset>

The created ruleset.

DeleteAsync(string, CancellationToken)

Deletes a ruleset from the account.

Task DeleteAsync(string rulesetId, CancellationToken cancellationToken = default)

Parameters

rulesetId string

The ID of the ruleset to delete.

cancellationToken CancellationToken

A cancellation token.

Returns

Task

DeleteRuleAsync(string, string, CancellationToken)

Deletes a rule from an account-level ruleset.

Task<Ruleset> DeleteRuleAsync(string rulesetId, string ruleId, CancellationToken cancellationToken = default)

Parameters

rulesetId string

The ID of the ruleset.

ruleId string

The ID of the rule to delete.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<Ruleset>

The updated parent ruleset.

GetAsync(string, CancellationToken)

Gets a single ruleset by its ID.

Task<Ruleset> GetAsync(string rulesetId, CancellationToken cancellationToken = default)

Parameters

rulesetId string

The ID of the ruleset to retrieve.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<Ruleset>

The requested ruleset.

GetPhaseEntrypointAsync(string, CancellationToken)

Gets the entrypoint ruleset for a specific phase at the account level.

Task<Ruleset> GetPhaseEntrypointAsync(string phase, CancellationToken cancellationToken = default)

Parameters

phase string

The phase of the entrypoint (e.g., "http_request_firewall_managed").

cancellationToken CancellationToken

A cancellation token.

Returns

Task<Ruleset>

The entrypoint ruleset.

GetPhaseEntrypointVersionAsync(string, string, CancellationToken)

Gets a specific version of a phase entrypoint ruleset.

Task<Ruleset> GetPhaseEntrypointVersionAsync(string phase, string version, CancellationToken cancellationToken = default)

Parameters

phase string

The phase of the entrypoint.

version string

The version number to retrieve.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<Ruleset>

The specified version of the ruleset.

ListAllAsync(int?, CancellationToken)

Lists all rulesets for the account, automatically handling cursor-based pagination.

IAsyncEnumerable<Ruleset> ListAllAsync(int? perPage = null, CancellationToken cancellationToken = default)

Parameters

perPage int?

The number of results to fetch per API page.

cancellationToken CancellationToken

A cancellation token.

Returns

IAsyncEnumerable<Ruleset>

An asynchronous stream of all rulesets for the account.

Remarks

This method simplifies fetching all rulesets by abstracting away the pagination logic.

ListAsync(ListRulesetsFilters?, CancellationToken)

Lists all rulesets for the account, allowing for manual pagination control.

Task<CursorPaginatedResult<Ruleset>> ListAsync(ListRulesetsFilters? filters = null, CancellationToken cancellationToken = default)

Parameters

filters ListRulesetsFilters

Optional pagination filters, including the cursor from a previous response.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<CursorPaginatedResult<Ruleset>>

A single page of rulesets along with pagination information.

Remarks

This method is intended for developers who need to control the pagination process manually. To fetch the next page of results, use the Cursor from the CursorInfo property of the returned CursorPaginatedResult<T> in your next call.

ListPhaseEntrypointVersionsAsync(string, ListRulesetVersionsFilters?, CancellationToken)

Lists the version history for a specific phase entrypoint, allowing for manual pagination.

Task<PagePaginatedResult<Ruleset>> ListPhaseEntrypointVersionsAsync(string phase, ListRulesetVersionsFilters? filters = null, CancellationToken cancellationToken = default)

Parameters

phase string

The phase of the entrypoint.

filters ListRulesetVersionsFilters

Optional pagination filters.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<PagePaginatedResult<Ruleset>>

A single page of ruleset versions along with pagination information.

UpdateAsync(string, UpdateRulesetRequest, CancellationToken)

Updates an existing ruleset.

Task<Ruleset> UpdateAsync(string rulesetId, UpdateRulesetRequest request, CancellationToken cancellationToken = default)

Parameters

rulesetId string

The ID of the ruleset to update.

request UpdateRulesetRequest

The request containing the fields to update.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<Ruleset>

The updated ruleset.

UpdatePhaseEntrypointAsync(string, IEnumerable<CreateRuleRequest>, CancellationToken)

Updates the entrypoint ruleset for a specific phase at the account level.

Task<Ruleset> UpdatePhaseEntrypointAsync(string phase, IEnumerable<CreateRuleRequest> rules, CancellationToken cancellationToken = default)

Parameters

phase string

The phase of the entrypoint.

rules IEnumerable<CreateRuleRequest>

The list of rules to set for the ruleset.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<Ruleset>

The updated ruleset.

UpdateRuleAsync(string, string, object, CancellationToken)

Updates an existing rule within an account-level ruleset.

Task<Ruleset> UpdateRuleAsync(string rulesetId, string ruleId, object rule, CancellationToken cancellationToken = default)

Parameters

rulesetId string

The ID of the ruleset containing the rule.

ruleId string

The ID of the rule to update.

rule object

The partial rule object with fields to update.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<Ruleset>

The updated parent ruleset.