Class ZoneLockdownApi
- Namespace
- Cloudflare.NET.Zones.Firewall
- Assembly
- Cloudflare.NET.dll
Implements the API for managing Zone Lockdown rules.
public class ZoneLockdownApi : ApiResource, IZoneLockdownApi
- Inheritance
-
ZoneLockdownApi
- Implements
- Inherited Members
Constructors
ZoneLockdownApi(HttpClient, ILoggerFactory)
Implements the API for managing Zone Lockdown rules.
public ZoneLockdownApi(HttpClient httpClient, ILoggerFactory loggerFactory)
Parameters
httpClientHttpClientloggerFactoryILoggerFactory
Methods
CreateAsync(string, CreateLockdownRequest, CancellationToken)
Creates a new Lockdown rule for a zone.
public Task<Lockdown> CreateAsync(string zoneId, CreateLockdownRequest request, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
requestCreateLockdownRequestThe request containing the details of the rule to create.
cancellationTokenCancellationTokenA cancellation token.
Returns
DeleteAsync(string, string, CancellationToken)
Deletes a Lockdown rule from a zone.
public Task<string> DeleteAsync(string zoneId, string lockdownId, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
lockdownIdstringThe ID of the rule to delete.
cancellationTokenCancellationTokenA cancellation token.
Returns
GetAsync(string, string, CancellationToken)
Gets a single Lockdown rule by its ID.
public Task<Lockdown> GetAsync(string zoneId, string lockdownId, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
lockdownIdstringThe ID of the Lockdown rule.
cancellationTokenCancellationTokenA cancellation token.
Returns
ListAllAsync(string, int?, CancellationToken)
Lists all Lockdown rules for a zone, automatically handling pagination.
public IAsyncEnumerable<Lockdown> 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<Lockdown>
An asynchronous stream of all Lockdown rules for the zone.
Remarks
This method simplifies fetching all rules by abstracting away the pagination logic.
ListAsync(string, ListLockdownFilters?, CancellationToken)
Lists all Lockdown rules for a zone, allowing for manual pagination.
public Task<PagePaginatedResult<Lockdown>> ListAsync(string zoneId, ListLockdownFilters? filters = null, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
filtersListLockdownFiltersOptional pagination filters.
cancellationTokenCancellationTokenA cancellation token.
Returns
- Task<PagePaginatedResult<Lockdown>>
A single page of Lockdown 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, UpdateLockdownRequest, CancellationToken)
Updates an existing Lockdown rule.
public Task<Lockdown> UpdateAsync(string zoneId, string lockdownId, UpdateLockdownRequest request, CancellationToken cancellationToken = default)
Parameters
zoneIdstringThe ID of the zone.
lockdownIdstringThe ID of the rule to update.
requestUpdateLockdownRequestThe request containing the fields to update.
cancellationTokenCancellationTokenA cancellation token.