Class Policy
Namespace: Consul
Assembly: Consul.dll
Policy is used to interact with ACL Policies in Consul through the API
public class Policy : IPolicyEndpoint
Inheritance
Implements
Inherited Members
object.Equals(object) , object.Equals(object, object) , object.GetHashCode() , object.GetType() , object.MemberwiseClone() , object.ReferenceEquals(object, object) , object.ToString()
Methods
Create(PolicyEntry, CancellationToken)
Creates a new ACL Policy in Consul
public Task<WriteResult<PolicyEntry>> Create(PolicyEntry policy, CancellationToken ct = default)
Parameters
policy
PolicyEntry
The new ACL PolicyEntry
Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing
Returns
Task <WriteResult <PolicyEntry >>
A write result containing the created ACL Policy
Create(PolicyEntry, WriteOptions, CancellationToken)
Creates a new ACL Policy in Consul
public Task<WriteResult<PolicyEntry>> Create(PolicyEntry policy, WriteOptions writeOptions, CancellationToken ct = default)
Parameters
policy
PolicyEntry
The new ACL PolicyEntry
writeOptions
WriteOptions
Customised write options
Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing
Returns
Task <WriteResult <PolicyEntry >>
A write result containing the created ACL Policy
Delete(string, CancellationToken)
Deletes an existing ACL Policy in Consul
public Task<WriteResult<bool>> Delete(string id, CancellationToken ct = default)
Parameters
id
string
The ID of the ACL Policy to delete
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, WriteOptions, CancellationToken)
Deletes an existing ACL Policy in Consul
public Task<WriteResult<bool>> Delete(string id, WriteOptions writeOptions, CancellationToken ct = default)
Parameters
id
string
The ID of the ACL Policy to delete
writeOptions
WriteOptions
Customised write options
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 Policies in Consul
public Task<QueryResult<PolicyEntry[]>> List(CancellationToken ct = default)
Parameters
Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing
Returns
Task <QueryResult <PolicyEntry []>>
A query result containing an array of ACL Policies
List(QueryOptions, CancellationToken)
Lists the existing ACL Policies in Consul
public Task<QueryResult<PolicyEntry[]>> List(QueryOptions queryOptions, CancellationToken ct = default)
Parameters
queryOptions
QueryOptions
Customised query options
Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing
Returns
Task <QueryResult <PolicyEntry []>>
A query result containing an array of ACL Policies
Read(string, CancellationToken)
Gets the requested ACL Policy from Consul
public Task<QueryResult<PolicyEntry>> Read(string id, CancellationToken ct = default)
Parameters
id
string
The ID of the ACL Policy to get
Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing
Returns
Task <QueryResult <PolicyEntry >>
A query result containing the requested ACL Policy
Read(string, QueryOptions, CancellationToken)
Gets the requested ACL Policy from Consul
public Task<QueryResult<PolicyEntry>> Read(string id, QueryOptions queryOptions, CancellationToken ct = default)
Parameters
id
string
The ID of the ACL Policy to get
queryOptions
QueryOptions
Customised query options
Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing
Returns
Task <QueryResult <PolicyEntry >>
A query result containing the requested ACL Policy
Update(PolicyEntry, CancellationToken)
Updates an existing ACL Policy in Consul
public Task<WriteResult<PolicyEntry>> Update(PolicyEntry policy, CancellationToken ct = default)
Parameters
policy
PolicyEntry
The modified ACL Policy
Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing
Returns
Task <WriteResult <PolicyEntry >>
A write result containing the updated ACL Policy
Update(PolicyEntry, WriteOptions, CancellationToken)
Updates an existing ACL Policy in Consul
public Task<WriteResult<PolicyEntry>> Update(PolicyEntry policy, WriteOptions writeOptions, CancellationToken ct = default)
Parameters
policy
PolicyEntry
The modified ACL Policy
writeOptions
WriteOptions
Customised write options
Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing
Returns
Task <WriteResult <PolicyEntry >>
A write result containing the updated ACL policy