Skip to main content

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

objectPolicy

Implements

IPolicyEndpoint

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

ct CancellationToken

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

ct CancellationToken

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

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, 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

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 Policies in Consul

public Task<QueryResult<PolicyEntry[]>> List(CancellationToken ct = default)

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 <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

ct CancellationToken

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

ct CancellationToken

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

ct CancellationToken

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

ct CancellationToken

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

ct CancellationToken

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

  • Methods
    • Create(PolicyEntry, CancellationToken)
    • Create(PolicyEntry, WriteOptions, CancellationToken)
    • Delete(string, CancellationToken)
    • Delete(string, WriteOptions, CancellationToken)
    • List(CancellationToken)
    • List(QueryOptions, CancellationToken)
    • Read(string, CancellationToken)
    • Read(string, QueryOptions, CancellationToken)
    • Update(PolicyEntry, CancellationToken)
    • Update(PolicyEntry, WriteOptions, CancellationToken)