Table of Contents

Struct TokenStatus

Namespace
Cloudflare.NET.ApiTokens.Models
Assembly
Cloudflare.NET.dll

Represents the status of an API token.

Token status indicates whether the token is currently usable for API operations.

  • ActiveToken is active and can be used for API requests
  • DisabledToken has been manually disabled
  • ExpiredToken has passed its expiration date
[JsonConverter(typeof(ExtensibleEnumConverter<TokenStatus>))]
public readonly struct TokenStatus : IExtensibleEnum<TokenStatus>, IEquatable<TokenStatus>
Implements
Inherited Members

Examples

// Using a known status with IntelliSense
var status = TokenStatus.Active;

// Checking token status
if (token.Status == TokenStatus.Disabled) { ... }

// Using implicit conversion from string
TokenStatus customStatus = "pending";

Remarks

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

Constructors

TokenStatus(string)

Creates a new TokenStatus with the specified value.

public TokenStatus(string value)

Parameters

value string

The string value representing the token status.

Exceptions

ArgumentNullException

Thrown when value is null.

Properties

Active

Token is active and can be used for API requests.

This is the default status for newly created tokens. Active tokens will successfully authenticate API requests.

public static TokenStatus Active { get; }

Property Value

TokenStatus

Disabled

Token has been manually disabled.

Disabled tokens cannot be used for API requests until re-enabled. Use the update endpoint to change the status back to active.

public static TokenStatus Disabled { get; }

Property Value

TokenStatus

Expired

Token has passed its expiration date.

Expired tokens cannot be used for API requests. Create a new token or update the expiration date to restore access.

public static TokenStatus Expired { get; }

Property Value

TokenStatus

Value

Gets the underlying string value of this token status.

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 TokenStatus Create(string value)

Parameters

value string

The string value to wrap.

Returns

TokenStatus

A new instance of TokenStatus containing the specified value.

Equals(TokenStatus)

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

public bool Equals(TokenStatus other)

Parameters

other TokenStatus

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 ==(TokenStatus, TokenStatus)

Determines whether two TokenStatus values are equal.

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

Parameters

left TokenStatus
right TokenStatus

Returns

bool

implicit operator string(TokenStatus)

Implicitly converts a TokenStatus to its string value.

public static implicit operator string(TokenStatus status)

Parameters

status TokenStatus

The token status to convert.

Returns

string

implicit operator TokenStatus(string)

Implicitly converts a string to a TokenStatus.

public static implicit operator TokenStatus(string value)

Parameters

value string

The string value to convert.

Returns

TokenStatus

operator !=(TokenStatus, TokenStatus)

Determines whether two TokenStatus values are not equal.

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

Parameters

left TokenStatus
right TokenStatus

Returns

bool