Table of Contents

Interface IZoneLockdownApi

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

Defines the contract for managing Zone Lockdown rules.

Lockdown rules specify a list of IP addresses that are the only ones allowed to access a given URL or set of URLs.

public interface IZoneLockdownApi

Methods

CreateAsync(string, CreateLockdownRequest, CancellationToken)

Creates a new Lockdown rule for a zone.

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.

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.

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.

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.

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.

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.