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
httpClientHttpClientloggerFactoryILoggerFactory
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
zoneIdstringThe ID of the zone.
requestCreateUaRuleRequestThe request containing the details of the rule to create.
cancellationTokenCancellationTokenA cancellation token.
Returns
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
zoneIdstringThe ID of the zone.
ruleIdstringThe ID of the rule to delete.
cancellationTokenCancellationTokenA cancellation token.
Returns
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
zoneIdstringThe ID of the zone.
ruleIdstringThe ID of the rule.
cancellationTokenCancellationTokenA cancellation token.
Returns
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
zoneIdstringThe ID of the zone.
perPageint?The number of results to fetch per API page.
cancellationTokenCancellationTokenA 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
zoneIdstringThe ID of the zone.
filtersListUaRulesFiltersOptional pagination filters.
cancellationTokenCancellationTokenA 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
zoneIdstringThe ID of the zone.
ruleIdstringThe ID of the rule to update.
requestUpdateUaRuleRequestThe request containing the fields to update.
cancellationTokenCancellationTokenA cancellation token.