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
rulesetIdstringThe ID of the ruleset.
ruleCreateRuleRequestThe rule to add.
cancellationTokenCancellationTokenA cancellation token.
Returns
CreateAsync(CreateRulesetRequest, CancellationToken)
Creates a new ruleset for the account.
Task<Ruleset> CreateAsync(CreateRulesetRequest request, CancellationToken cancellationToken = default)
Parameters
requestCreateRulesetRequestThe request containing the details of the ruleset to create.
cancellationTokenCancellationTokenA cancellation token.
Returns
DeleteAsync(string, CancellationToken)
Deletes a ruleset from the account.
Task DeleteAsync(string rulesetId, CancellationToken cancellationToken = default)
Parameters
rulesetIdstringThe ID of the ruleset to delete.
cancellationTokenCancellationTokenA cancellation token.
Returns
DeleteRuleAsync(string, string, CancellationToken)
Deletes a rule from an account-level ruleset.
Task<Ruleset> DeleteRuleAsync(string rulesetId, string ruleId, CancellationToken cancellationToken = default)
Parameters
rulesetIdstringThe ID of the ruleset.
ruleIdstringThe ID of the rule to delete.
cancellationTokenCancellationTokenA cancellation token.
Returns
GetAsync(string, CancellationToken)
Gets a single ruleset by its ID.
Task<Ruleset> GetAsync(string rulesetId, CancellationToken cancellationToken = default)
Parameters
rulesetIdstringThe ID of the ruleset to retrieve.
cancellationTokenCancellationTokenA cancellation token.
Returns
GetPhaseEntrypointAsync(string, CancellationToken)
Gets the entrypoint ruleset for a specific phase at the account level.
Task<Ruleset> GetPhaseEntrypointAsync(string phase, CancellationToken cancellationToken = default)
Parameters
phasestringThe phase of the entrypoint (e.g., "http_request_firewall_managed").
cancellationTokenCancellationTokenA cancellation token.
Returns
GetPhaseEntrypointVersionAsync(string, string, CancellationToken)
Gets a specific version of a phase entrypoint ruleset.
Task<Ruleset> GetPhaseEntrypointVersionAsync(string phase, string version, CancellationToken cancellationToken = default)
Parameters
phasestringThe phase of the entrypoint.
versionstringThe version number to retrieve.
cancellationTokenCancellationTokenA cancellation token.
Returns
ListAllAsync(int?, CancellationToken)
Lists all rulesets for the account, automatically handling cursor-based pagination.
IAsyncEnumerable<Ruleset> ListAllAsync(int? perPage = null, CancellationToken cancellationToken = default)
Parameters
perPageint?The number of results to fetch per API page.
cancellationTokenCancellationTokenA 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
filtersListRulesetsFiltersOptional pagination filters, including the cursor from a previous response.
cancellationTokenCancellationTokenA 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
phasestringThe phase of the entrypoint.
filtersListRulesetVersionsFiltersOptional pagination filters.
cancellationTokenCancellationTokenA 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
rulesetIdstringThe ID of the ruleset to update.
requestUpdateRulesetRequestThe request containing the fields to update.
cancellationTokenCancellationTokenA cancellation token.
Returns
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
phasestringThe phase of the entrypoint.
rulesIEnumerable<CreateRuleRequest>The list of rules to set for the ruleset.
cancellationTokenCancellationTokenA cancellation token.
Returns
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
rulesetIdstringThe ID of the ruleset containing the rule.
ruleIdstringThe ID of the rule to update.
ruleobjectThe partial rule object with fields to update.
cancellationTokenCancellationTokenA cancellation token.