Table of Contents

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

httpClient HttpClient
loggerFactory ILoggerFactory

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

zoneId string

The ID of the zone.

request CreateLockdownRequest

The request containing the details of the rule to create.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<Lockdown>

The created Lockdown rule.

DeleteAsync(string, string, CancellationToken)

Deletes a Lockdown rule from a zone.

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

Parameters

zoneId string

The ID of the zone.

lockdownId 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 Lockdown rule by its ID.

public Task<Lockdown> GetAsync(string zoneId, string lockdownId, CancellationToken cancellationToken = default)

Parameters

zoneId string

The ID of the zone.

lockdownId string

The ID of the Lockdown rule.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<Lockdown>

The requested Lockdown rule.

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

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

zoneId string

The ID of the zone.

filters ListLockdownFilters

Optional pagination filters.

cancellationToken CancellationToken

A 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

zoneId string

The ID of the zone.

lockdownId string

The ID of the rule to update.

request UpdateLockdownRequest

The request containing the fields to update.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<Lockdown>

The updated Lockdown rule.