Table of Contents

Class ZoneUaRulesApi

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

Implements the API for managing User-Agent blocking rules.

public class ZoneUaRulesApi : ApiResource, IZoneUaRulesApi
Inheritance
ZoneUaRulesApi
Implements
Inherited Members

Constructors

ZoneUaRulesApi(HttpClient, ILoggerFactory)

Implements the API for managing User-Agent blocking rules.

public ZoneUaRulesApi(HttpClient httpClient, ILoggerFactory loggerFactory)

Parameters

httpClient HttpClient
loggerFactory ILoggerFactory

Methods

CreateAsync(string, CreateUaRuleRequest, CancellationToken)

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

public 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.

public 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.

public 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.

public 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.

public 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.

public 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.