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
valuestringThe string value representing the token status.
Exceptions
- ArgumentNullException
Thrown when
valueis 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
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
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
Value
Gets the underlying string value of this token status.
public string Value { get; }
Property Value
Methods
Create(string)
Creates a new instance of the extensible enum from the specified string value.
public static TokenStatus Create(string value)
Parameters
valuestringThe 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
otherTokenStatusAn object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand 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
leftTokenStatusrightTokenStatus
Returns
implicit operator string(TokenStatus)
Implicitly converts a TokenStatus to its string value.
public static implicit operator string(TokenStatus status)
Parameters
statusTokenStatusThe token status to convert.
Returns
implicit operator TokenStatus(string)
Implicitly converts a string to a TokenStatus.
public static implicit operator TokenStatus(string value)
Parameters
valuestringThe string value to convert.
Returns
operator !=(TokenStatus, TokenStatus)
Determines whether two TokenStatus values are not equal.
public static bool operator !=(TokenStatus left, TokenStatus right)
Parameters
leftTokenStatusrightTokenStatus