Table of Contents

Interface IZoneUaRulesApi

Namespace
Cloudflare.NET.Zones.Firewall
Assembly
Cloudflare.NET.dll

Defines the contract for managing User-Agent blocking rules.

These rules allow you to block or challenge requests based on their User-Agent header.

public interface IZoneUaRulesApi

Methods

CreateAsync(string, CreateUaRuleRequest, CancellationToken)

Creates a new User-Agent blocking rule for a zone.

Task<UaRule> CreateAsync(string zoneId, CreateUaRuleRequest request, CancellationToken cancellationToken = default)

Parameters

zoneId string

The ID of the zone.

request CreateUaRuleRequest

The request containing the details of the rule to create.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<UaRule>

The created User-Agent blocking rule.

DeleteAsync(string, string, CancellationToken)

Deletes a User-Agent blocking rule from a zone.

Task<string> DeleteAsync(string zoneId, string ruleId, CancellationToken cancellationToken = default)

Parameters

zoneId string

The ID of the zone.

ruleId string

The ID of the rule to delete.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<string>

The ID of the deleted rule.

GetAsync(string, string, CancellationToken)

Gets a single User-Agent blocking rule by its ID.

Task<UaRule> GetAsync(string zoneId, string ruleId, CancellationToken cancellationToken = default)

Parameters

zoneId string

The ID of the zone.

ruleId string

The ID of the rule.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<UaRule>

The requested User-Agent blocking rule.

ListAllAsync(string, int?, CancellationToken)

Lists all User-Agent blocking rules for a zone, automatically handling pagination.

IAsyncEnumerable<UaRule> ListAllAsync(string zoneId, int? perPage = null, CancellationToken cancellationToken = default)

Parameters

zoneId string

The ID of the zone.

perPage int?

The number of results to fetch per API page.

cancellationToken CancellationToken

A cancellation token.

Returns

IAsyncEnumerable<UaRule>

An asynchronous stream of all User-Agent blocking rules for the zone.

Remarks

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

ListAsync(string, ListUaRulesFilters?, CancellationToken)

Lists all User-Agent blocking rules for a zone, allowing for manual pagination control.

Task<PagePaginatedResult<UaRule>> ListAsync(string zoneId, ListUaRulesFilters? filters = null, CancellationToken cancellationToken = default)

Parameters

zoneId string

The ID of the zone.

filters ListUaRulesFilters

Optional pagination filters.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<PagePaginatedResult<UaRule>>

A single page of User-Agent blocking rules along with pagination information.

Remarks

This method is intended for developers who need to control the pagination process manually. Use the properties of the returned PagePaginatedResult<T> to determine if there are more pages and to construct the filter for the next call.

UpdateAsync(string, string, UpdateUaRuleRequest, CancellationToken)

Updates an existing User-Agent blocking rule.

Task<UaRule> UpdateAsync(string zoneId, string ruleId, UpdateUaRuleRequest request, CancellationToken cancellationToken = default)

Parameters

zoneId string

The ID of the zone.

ruleId string

The ID of the rule to update.

request UpdateUaRuleRequest

The request containing the fields to update.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<UaRule>

The updated User-Agent blocking rule.