Class ZoneRulesetsApi
- Namespace
- Cloudflare.NET.Zones.Rulesets
- Assembly
- Cloudflare.NET.dll
Implements the API for managing Rulesets at the zone level.
public class ZoneRulesetsApi : ApiResource, IZoneRulesetsApi
- Inheritance
-
ZoneRulesetsApi
- Implements
- Inherited Members
Constructors
ZoneRulesetsApi(HttpClient, ILoggerFactory)
Implements the API for managing Rulesets at the zone level.
public ZoneRulesetsApi(HttpClient httpClient, ILoggerFactory loggerFactory)
Parameters
httpClientHttpClientloggerFactoryILoggerFactory
Methods
AddRuleAsync(string, string, CreateRuleRequest, CancellationToken)
Adds a new rule to a specific zone-level ruleset.
public Task<Ruleset> AddRuleAsync(string zoneId, string rulesetId, CreateRuleRequest rule, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
rulesetIdstringThe ID of the ruleset.
ruleCreateRuleRequestThe rule to add.
cancellationTokenCancellationTokenA cancellation token.
Returns
CreateAsync(string, CreateRulesetRequest, CancellationToken)
Creates a new ruleset for a zone.
public Task<Ruleset> CreateAsync(string zoneId, CreateRulesetRequest request, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
requestCreateRulesetRequestThe request containing the details of the ruleset to create.
cancellationTokenCancellationTokenA cancellation token.
Returns
DeleteAsync(string, string, CancellationToken)
Deletes a ruleset from a zone.
public Task DeleteAsync(string zoneId, string rulesetId, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
rulesetIdstringThe ID of the ruleset to delete.
cancellationTokenCancellationTokenA cancellation token.
Returns
DeleteRuleAsync(string, string, string, CancellationToken)
Deletes a rule from a zone-level ruleset.
public Task<Ruleset> DeleteRuleAsync(string zoneId, string rulesetId, string ruleId, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
rulesetIdstringThe ID of the ruleset.
ruleIdstringThe ID of the rule to delete.
cancellationTokenCancellationTokenA cancellation token.
Returns
GetAsync(string, string, CancellationToken)
Gets a single ruleset by its ID within a zone.
public Task<Ruleset> GetAsync(string zoneId, string rulesetId, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
rulesetIdstringThe ID of the ruleset to retrieve.
cancellationTokenCancellationTokenA cancellation token.
Returns
GetPhaseEntrypointAsync(string, string, CancellationToken)
Gets the entrypoint ruleset for a specific phase at the zone level.
public Task<Ruleset> GetPhaseEntrypointAsync(string zoneId, string phase, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
phasestringThe phase of the entrypoint (e.g., "http_request_firewall_managed").
cancellationTokenCancellationTokenA cancellation token.
Returns
GetPhaseEntrypointVersionAsync(string, string, string, CancellationToken)
Gets a specific version of a phase entrypoint ruleset at the zone level.
public Task<Ruleset> GetPhaseEntrypointVersionAsync(string zoneId, string phase, string version, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
phasestringThe phase of the entrypoint.
versionstringThe version number to retrieve.
cancellationTokenCancellationTokenA cancellation token.
Returns
ListAllAsync(string, int?, CancellationToken)
Lists all rulesets for a zone, automatically handling cursor-based pagination.
public IAsyncEnumerable<Ruleset> ListAllAsync(string zoneId, int? perPage = null, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
perPageint?The number of results to fetch per API page.
cancellationTokenCancellationTokenA cancellation token.
Returns
- IAsyncEnumerable<Ruleset>
An asynchronous stream of all rulesets for the zone.
Remarks
This method simplifies fetching all rulesets by abstracting away the pagination logic.
ListAsync(string, ListRulesetsFilters?, CancellationToken)
Lists all rulesets for a zone, allowing for manual pagination control.
public Task<CursorPaginatedResult<Ruleset>> ListAsync(string zoneId, ListRulesetsFilters? filters = null, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
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, string, ListRulesetVersionsFilters?, CancellationToken)
Lists the version history for a specific phase entrypoint at the zone level, allowing for manual pagination.
public Task<PagePaginatedResult<Ruleset>> ListPhaseEntrypointVersionsAsync(string zoneId, string phase, ListRulesetVersionsFilters? filters = null, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
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, string, UpdateRulesetRequest, CancellationToken)
Updates an existing ruleset in a zone.
public Task<Ruleset> UpdateAsync(string zoneId, string rulesetId, UpdateRulesetRequest request, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
rulesetIdstringThe ID of the ruleset to update.
requestUpdateRulesetRequestThe request containing the fields to update.
cancellationTokenCancellationTokenA cancellation token.
Returns
UpdatePhaseEntrypointAsync(string, string, IEnumerable<CreateRuleRequest>, CancellationToken)
Updates the entrypoint ruleset for a specific phase at the zone level.
public Task<Ruleset> UpdatePhaseEntrypointAsync(string zoneId, string phase, IEnumerable<CreateRuleRequest> rules, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
phasestringThe phase of the entrypoint.
rulesIEnumerable<CreateRuleRequest>The list of rules to set for the ruleset.
cancellationTokenCancellationTokenA cancellation token.
Returns
UpdateRuleAsync(string, string, string, object, CancellationToken)
Updates an existing rule within a zone-level ruleset.
public Task<Ruleset> UpdateRuleAsync(string zoneId, string rulesetId, string ruleId, object rule, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
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.