Class ZoneAccessRulesApi
- Namespace
- Cloudflare.NET.Zones.AccessRules
- Assembly
- Cloudflare.NET.dll
Implements the API for managing IP Access Rules at the zone level.
public class ZoneAccessRulesApi : ApiResource, IZoneAccessRulesApi
- Inheritance
-
ZoneAccessRulesApi
- Implements
- Inherited Members
Constructors
ZoneAccessRulesApi(HttpClient, ILoggerFactory)
Implements the API for managing IP Access Rules at the zone level.
public ZoneAccessRulesApi(HttpClient httpClient, ILoggerFactory loggerFactory)
Parameters
httpClientHttpClientloggerFactoryILoggerFactory
Methods
CreateAsync(string, CreateAccessRuleRequest, CancellationToken)
Creates a new IP Access Rule for the specified zone.
public Task<AccessRule> CreateAsync(string zoneId, CreateAccessRuleRequest request, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
requestCreateAccessRuleRequestThe request containing the details of the rule to create.
cancellationTokenCancellationTokenA cancellation token.
Returns
- Task<AccessRule>
The created access rule.
DeleteAsync(string, string, CancellationToken)
Deletes an IP Access Rule from the specified zone.
public Task 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 IP Access Rule for a zone by its ID.
public Task<AccessRule> GetAsync(string zoneId, string ruleId, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
ruleIdstringThe ID of the rule to retrieve.
cancellationTokenCancellationTokenA cancellation token.
Returns
- Task<AccessRule>
The requested access rule.
ListAllAsync(string, ListAccessRulesFilters?, CancellationToken)
Lists all IP Access Rules for the specified zone, automatically handling pagination.
public IAsyncEnumerable<AccessRule> ListAllAsync(string zoneId, ListAccessRulesFilters? filters = null, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
filtersListAccessRulesFiltersOptional filters to apply to the list operation. Pagination parameters (Page, PerPage) will be ignored.
cancellationTokenCancellationTokenA cancellation token.
Returns
- IAsyncEnumerable<AccessRule>
An asynchronous stream of all access rules matching the criteria.
ListAsync(string, ListAccessRulesFilters?, CancellationToken)
Lists all IP Access Rules for the specified zone, allowing for manual pagination control.
public Task<PagePaginatedResult<AccessRule>> ListAsync(string zoneId, ListAccessRulesFilters? filters = null, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
filtersListAccessRulesFiltersOptional filters to apply to the list operation, including pagination parameters.
cancellationTokenCancellationTokenA cancellation token.
Returns
- Task<PagePaginatedResult<AccessRule>>
A single page of access 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, UpdateAccessRuleRequest, CancellationToken)
Updates an existing IP Access Rule for the specified zone.
public Task<AccessRule> UpdateAsync(string zoneId, string ruleId, UpdateAccessRuleRequest request, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
ruleIdstringThe ID of the rule to update.
requestUpdateAccessRuleRequestThe request containing the fields to update.
cancellationTokenCancellationTokenA cancellation token.
Returns
- Task<AccessRule>
The updated access rule.