Skip to main content

Class Token

Namespace: Consul
Assembly: Consul.dll

Token is used to interact with ACL Tokens in Consul through the API

public class Token : ITokenEndpoint

Inheritance​

object ← Token

Implements​

ITokenEndpoint

Inherited Members​

object.Equals(object) , object.Equals(object, object) , object.GetHashCode() , object.GetType() , object.MemberwiseClone() , object.ReferenceEquals(object, object) , object.ToString()

Methods​

Bootstrap(CancellationToken)​

Creates the initial Management ACL Token in Consul

public Task<WriteResult<TokenEntry>> Bootstrap(CancellationToken ct)

Parameters​

ct CancellationToken

Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing

Returns​

Task <WriteResult <TokenEntry >>

A write result containing the created ACL Token

Bootstrap()​

public Task<WriteResult<TokenEntry>> Bootstrap()

Returns​

Task <WriteResult <TokenEntry >>

Bootstrap(WriteOptions, CancellationToken)​

Creates the initial Management ACL Token in Consul

public Task<WriteResult<TokenEntry>> Bootstrap(WriteOptions writeOptions, CancellationToken ct = default)

Parameters​

writeOptions WriteOptions

Customized write options

ct CancellationToken

Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing

Returns​

Task <WriteResult <TokenEntry >>

A write result containing the created ACL Token

Clone(string, CancellationToken)​

Clones an existing ACL Token in Consul

public Task<WriteResult<TokenEntry>> Clone(string id, CancellationToken ct)

Parameters​

id string

The Accessor ID of the ACL Token to clone

ct CancellationToken

Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing

Returns​

Task <WriteResult <TokenEntry >>

A write result containing the created ACL token

Clone(string)​

public Task<WriteResult<TokenEntry>> Clone(string id)

Parameters​

id string

Returns​

Task <WriteResult <TokenEntry >>

Clone(string, WriteOptions, CancellationToken)​

Clones an existing ACL Token in Consul

public Task<WriteResult<TokenEntry>> Clone(string id, WriteOptions writeOptions, CancellationToken ct)

Parameters​

id string

The Accessor ID of the ACL Token to clone

writeOptions WriteOptions

Customized write options

ct CancellationToken

Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing

Returns​

Task <WriteResult <TokenEntry >>

A write result containing the created ACL token

Clone(string, WriteOptions)​

public Task<WriteResult<TokenEntry>> Clone(string id, WriteOptions writeOptions)

Parameters​

id string

writeOptions WriteOptions

Returns​

Task <WriteResult <TokenEntry >>

Clone(string, string, WriteOptions, CancellationToken)​

Clones an existing ACL Token in Consul

public Task<WriteResult<TokenEntry>> Clone(string id, string description, WriteOptions writeOptions, CancellationToken ct = default)

Parameters​

id string

The Accessor ID of the ACL Token to clone

description string

The description for the cloned ACL Token

writeOptions WriteOptions

Customized write options

ct CancellationToken

Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing

Returns​

Task <WriteResult <TokenEntry >>

A write result containing the created ACL token

Create(TokenEntry, CancellationToken)​

Creates a new ACL Token in Consul

public Task<WriteResult<TokenEntry>> Create(TokenEntry token, CancellationToken ct)

Parameters​

token TokenEntry

The new ACL Token

ct CancellationToken

Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing

Returns​

Task <WriteResult <TokenEntry >>

A write result containing the created ACL Token

Create(TokenEntry)​

public Task<WriteResult<TokenEntry>> Create(TokenEntry token)

Parameters​

token TokenEntry

Returns​

Task <WriteResult <TokenEntry >>

Create(TokenEntry, WriteOptions, CancellationToken)​

Creates a new ACL Token in Consul

public Task<WriteResult<TokenEntry>> Create(TokenEntry token, WriteOptions writeOptions, CancellationToken ct = default)

Parameters​

token TokenEntry

The new ACL Token

writeOptions WriteOptions

Customized write options

ct CancellationToken

Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing

Returns​

Task <WriteResult <TokenEntry >>

A write result containing the created ACL Token

Delete(string, CancellationToken)​

Deletes an existing ACL Token from Consul

public Task<WriteResult<bool>> Delete(string id, CancellationToken ct)

Parameters​

id string

The Accessor ID of the ACL Token to delete

ct CancellationToken

Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing

Returns​

Task <WriteResult <bool >>

Success (true) or failure (false)

Delete(string)​

public Task<WriteResult<bool>> Delete(string id)

Parameters​

id string

Returns​

Task <WriteResult <bool >>

Delete(string, WriteOptions, CancellationToken)​

Deletes an existing ACL Token from Consul

public Task<WriteResult<bool>> Delete(string id, WriteOptions writeOptions, CancellationToken ct = default)

Parameters​

id string

The Accessor ID of the ACL Token to delete

writeOptions WriteOptions

Customized write options

ct CancellationToken

Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing

Returns​

Task <WriteResult <bool >>

Success (true) or failure (false)

List(CancellationToken)​

Lists the existing ACL Tokens in Consul

public Task<QueryResult<TokenEntry[]>> List(CancellationToken ct)

Parameters​

ct CancellationToken

Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing

Returns​

Task <QueryResult <TokenEntry []>>

A query result containing an array of ACL Tokens

List()​

public Task<QueryResult<TokenEntry[]>> List()

Returns​

Task <QueryResult <TokenEntry []>>

List(QueryOptions, CancellationToken)​

public Task<QueryResult<TokenEntry[]>> List(QueryOptions q, CancellationToken ct)

Parameters​

q QueryOptions

ct CancellationToken

Returns​

Task <QueryResult <TokenEntry []>>

List(QueryOptions)​

public Task<QueryResult<TokenEntry[]>> List(QueryOptions q)

Parameters​

q QueryOptions

Returns​

Task <QueryResult <TokenEntry []>>

List(string, string, string, string, QueryOptions, CancellationToken)​

Lists the existing ACL Tokens in Consul

public Task<QueryResult<TokenEntry[]>> List(string policy, string role, string serviceName, string authMethod, QueryOptions queryOptions = null, CancellationToken ct = default)

Parameters​

policy string

Filters the token list to those tokens that are linked with this specific policy ID

role string

Filters the token list to those tokens that are linked with this specific role ID

serviceName string

Filters the token list to those tokens that are linked with this specific service name in their service identity

authMethod string

Filters the token list to those tokens that are linked with this specific named auth method

queryOptions QueryOptions

Customized query options

ct CancellationToken

Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing

Returns​

Task <QueryResult <TokenEntry []>>

A query result containing an array of ACL Tokens

Read(string, CancellationToken)​

Gets an existing ACL Token from Consul

public Task<QueryResult<TokenEntry>> Read(string id, CancellationToken ct)

Parameters​

id string

The Accessor ID of the ACL Token to get

ct CancellationToken

Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing

Returns​

Task <QueryResult <TokenEntry >>

A query result containing the requested ACL Token

Read(string)​

public Task<QueryResult<TokenEntry>> Read(string id)

Parameters​

id string

Returns​

Task <QueryResult <TokenEntry >>

Read(string, QueryOptions)​

public Task<QueryResult<TokenEntry>> Read(string id, QueryOptions q)

Parameters​

id string

q QueryOptions

Returns​

Task <QueryResult <TokenEntry >>

Read(string, QueryOptions, CancellationToken)​

public Task<QueryResult<TokenEntry>> Read(string id, QueryOptions q, CancellationToken ct)

Parameters​

id string

q QueryOptions

ct CancellationToken

Returns​

Task <QueryResult <TokenEntry >>

Read(string, bool, QueryOptions, CancellationToken)​

Gets an existing ACL Token from Consul

public Task<QueryResult<TokenEntry>> Read(string id, bool expanded, QueryOptions queryOptions, CancellationToken ct = default)

Parameters​

id string

The Accessor ID of the ACL Token to get

expanded bool

If true, the contents of all policies and roles affecting the token will also be returned

queryOptions QueryOptions

Customized query options

ct CancellationToken

Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing

Returns​

Task <QueryResult <TokenEntry >>

A query result containing the requested ACL Token

ReadSelfToken(string, CancellationToken)​

Gets the ACL token that matches the secret ID specified with the X-Consul-Token header or the token query parameter.

public Task<QueryResult<TokenEntry>> ReadSelfToken(string token, CancellationToken ct)

Parameters​

token string

ct CancellationToken

Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing

Returns​

Task <QueryResult <TokenEntry >>

A query result containing the requested ACL Token

ReadSelfToken(string)​

public Task<QueryResult<TokenEntry>> ReadSelfToken(string token)

Parameters​

token string

Returns​

Task <QueryResult <TokenEntry >>

ReadSelfToken(string, QueryOptions, CancellationToken)​

Gets the ACL token that matches the secret ID specified with the X-Consul-Token header or the token query parameter.

public Task<QueryResult<TokenEntry>> ReadSelfToken(string token, QueryOptions queryOptions, CancellationToken ct = default)

Parameters​

token string

queryOptions QueryOptions

Customized query options

ct CancellationToken

Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing

Returns​

Task <QueryResult <TokenEntry >>

A query result containing the requested ACL Token

Update(TokenEntry, CancellationToken)​

Updates an existing ACL Token in Consul

public Task<WriteResult<TokenEntry>> Update(TokenEntry token, CancellationToken ct)

Parameters​

token TokenEntry

The modified ACL Token

ct CancellationToken

Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing

Returns​

Task <WriteResult <TokenEntry >>

A write result containing the updated ACL Token

Update(TokenEntry)​

public Task<WriteResult<TokenEntry>> Update(TokenEntry token)

Parameters​

token TokenEntry

Returns​

Task <WriteResult <TokenEntry >>

Update(TokenEntry, WriteOptions, CancellationToken)​

Updates an existing ACL Token in Consul

public Task<WriteResult<TokenEntry>> Update(TokenEntry token, WriteOptions writeOptions, CancellationToken ct = default)

Parameters​

token TokenEntry

The modified ACL Token

writeOptions WriteOptions

Customized write options

ct CancellationToken

Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing

Returns​

Task <WriteResult <TokenEntry >>

A write result containing the updated ACL Token

  • Methods
    • Bootstrap(CancellationToken)
    • Bootstrap()
    • Bootstrap(WriteOptions, CancellationToken)
    • Clone(string, CancellationToken)
    • Clone(string)
    • Clone(string, WriteOptions, CancellationToken)
    • Clone(string, WriteOptions)
    • Clone(string, string, WriteOptions, CancellationToken)
    • Create(TokenEntry, CancellationToken)
    • Create(TokenEntry)
    • Create(TokenEntry, WriteOptions, CancellationToken)
    • Delete(string, CancellationToken)
    • Delete(string)
    • Delete(string, WriteOptions, CancellationToken)
    • List(CancellationToken)
    • List()
    • List(QueryOptions, CancellationToken)
    • List(QueryOptions)
    • List(string, string, string, string, QueryOptions, CancellationToken)
    • Read(string, CancellationToken)
    • Read(string)
    • Read(string, QueryOptions)
    • Read(string, QueryOptions, CancellationToken)
    • Read(string, bool, QueryOptions, CancellationToken)
    • ReadSelfToken(string, CancellationToken)
    • ReadSelfToken(string)
    • ReadSelfToken(string, QueryOptions, CancellationToken)
    • Update(TokenEntry, CancellationToken)
    • Update(TokenEntry)
    • Update(TokenEntry, WriteOptions, CancellationToken)