Table of Contents

Struct LockdownTarget

Namespace
Cloudflare.NET.Security.Firewall.Models
Assembly
Cloudflare.NET.dll

Represents the target type for a Zone Lockdown rule's configuration.

Zone Lockdown targets define what type of IP entity the rule applies to, such as a single IP address or IP range.

[JsonConverter(typeof(ExtensibleEnumConverter<LockdownTarget>))]
public readonly struct LockdownTarget : IExtensibleEnum<LockdownTarget>, IEquatable<LockdownTarget>
Implements
Inherited Members

Examples

// Using a known target with IntelliSense
var target = LockdownTarget.Ip;

// Creating a configuration with a specific target
var config = new LockdownConfiguration(LockdownTarget.IpRange, "192.0.2.0/24");

// Using implicit conversion from string
LockdownTarget customTarget = "new-target-type";

Remarks

This is an extensible enum that provides IntelliSense for known values while allowing custom values for new target types that may be added to the Cloudflare API in the future.

Use the static properties for known targets (e.g., Ip, IpRange) or create custom values using the constructor or implicit string conversion.

Constructors

LockdownTarget(string)

Creates a new LockdownTarget with the specified value.

public LockdownTarget(string value)

Parameters

value string

The string value representing the target.

Exceptions

ArgumentNullException

Thrown when value is null.

Properties

Ip

Targets an IPv4 or IPv6 address.

public static LockdownTarget Ip { get; }

Property Value

LockdownTarget

Remarks

Used to allow a single IP address through the zone lockdown. Example value: "192.0.2.1" or "2001:db8::1"

IpRange

Targets an IP range in CIDR notation.

public static LockdownTarget IpRange { get; }

Property Value

LockdownTarget

Remarks

Used to allow a range of IP addresses through the zone lockdown. Example value: "192.0.2.0/24" or "2001:db8::/32"

Value

Gets the underlying string value of this target.

public string Value { get; }

Property Value

string

Methods

Create(string)

Creates a new instance of the extensible enum from the specified string value.

public static LockdownTarget Create(string value)

Parameters

value string

The string value to wrap.

Returns

LockdownTarget

A new instance of LockdownTarget containing the specified value.

Equals(LockdownTarget)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(LockdownTarget other)

Parameters

other LockdownTarget

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

ToString()

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string

The fully qualified type name.

Operators

operator ==(LockdownTarget, LockdownTarget)

Determines whether two LockdownTarget values are equal.

public static bool operator ==(LockdownTarget left, LockdownTarget right)

Parameters

left LockdownTarget
right LockdownTarget

Returns

bool

implicit operator string(LockdownTarget)

Implicitly converts a LockdownTarget to its string value.

public static implicit operator string(LockdownTarget target)

Parameters

target LockdownTarget

The target to convert.

Returns

string

implicit operator LockdownTarget(string)

Implicitly converts a string to a LockdownTarget.

public static implicit operator LockdownTarget(string value)

Parameters

value string

The string value to convert.

Returns

LockdownTarget

operator !=(LockdownTarget, LockdownTarget)

Determines whether two LockdownTarget values are not equal.

public static bool operator !=(LockdownTarget left, LockdownTarget right)

Parameters

left LockdownTarget
right LockdownTarget

Returns

bool

See Also