/// <summary> /// Get is used to lookup a single key /// </summary> /// <param name="key">The key name</param> /// <param name="q">Customized query options</param> /// <param name="ct">Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing</param> /// <returns>A query result containing the requested key/value pair, or a query result with a null response if the key does not exist</returns> public async Task <QueryResult <KVPair> > Get(string key, QueryOptions q, CancellationToken ct = default(CancellationToken)) { var req = _client.Get <KVPair[]>(string.Format("/v1/kv/{0}", key.TrimStart('/')), q); var res = await req.Execute(ct).ConfigureAwait(false); return(new QueryResult <KVPair>(res, res.Response != null && res.Response.Length > 0 ? res.Response[0] : null)); }
/// <summary> /// List is used to get the most recent events an agent has received. This list can be optionally filtered by the name. This endpoint supports quasi-blocking queries. The index is not monotonic, nor does it provide provide LastContact or KnownLeader. /// </summary> /// <param name="name">The name of the event to filter for</param> /// <param name="q">Customized query options</param> /// <param name="ct">Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing</param> /// <returns>An array of events</returns> public Task <QueryResult <UserEvent[]> > List(string name, QueryOptions q, CancellationToken ct) { var req = _client.Get <UserEvent[]>("/v1/event/list", q); if (!string.IsNullOrEmpty(name)) { req.Params["name"] = name; } return(req.Execute(ct)); }
/// <summary> /// Datacenters is used to query for all the known datacenters /// </summary> /// <returns>A list of datacenter names</returns> public Task <QueryResult <string[]> > Datacenters(CancellationToken ct = default(CancellationToken)) { return(_client.Get <string[]>("/v1/catalog/datacenters").Execute(ct)); }
/// <summary> /// Get the current status of ACL Replication in Consul /// </summary> /// <param name="queryOptions">Any query options for the request</param> /// <param name="ct">Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing</param> /// <returns>A query result with details of the ACL Replication system in Consul</returns> public async Task <QueryResult <ACLReplicationEntry> > Status(QueryOptions queryOptions, CancellationToken ct = default(CancellationToken)) { var res = await _client.Get <ACLReplicationEntry>("/v1/acl/replication", queryOptions).Execute(ct).ConfigureAwait(false); return(new QueryResult <ACLReplicationEntry>(res, res.Response)); }
/// <summary> /// Gets an existing ACL AuthMethod from Consul /// </summary> /// <param name="name">The Name of the ACL AuthMethod to get</param> /// <param name="queryOptions">Customized query options</param> /// <param name="ct">Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing</param> /// <returns>A query result containing the requested ACL AuthMethod</returns> public async Task <QueryResult <AuthMethodEntry> > Read(string name, QueryOptions queryOptions, CancellationToken ct = default(CancellationToken)) { var res = await _client.Get <AuthMethodActionResult>($"/v1/acl/auth-method/{name}", queryOptions).Execute(ct).ConfigureAwait(false); return(new QueryResult <AuthMethodEntry>(res, res.Response)); }
/// <summary> /// Self is used to query the agent we are speaking to for information about itself /// </summary> /// <returns>A somewhat dynamic object representing the various data elements in Self</returns> public Task <QueryResult <Dictionary <string, Dictionary <string, dynamic> > > > Self(CancellationToken ct = default(CancellationToken)) { return(_client.Get <Dictionary <string, Dictionary <string, dynamic> > >("/v1/agent/self").Execute(ct)); }
public Task <QueryResult <Stream> > Save(QueryOptions q, CancellationToken ct = default(CancellationToken)) { return(_client.Get <Stream>("/v1/snapshot", q).ExecuteStreaming(ct)); }
/// <summary> /// Lists the existing ACL Policies in Consul /// </summary> /// <param name="queryOptions">Customised query options</param> /// <param name="ct">Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing</param> /// <returns>A query result containing an array of ACL Policies</returns> public async Task <QueryResult <PolicyEntry[]> > List(QueryOptions queryOptions, CancellationToken ct = default(CancellationToken)) { var res = await _client.Get <PolicyEntry[]>("/v1/acl/policies", queryOptions).Execute(ct).ConfigureAwait(false); return(new QueryResult <PolicyEntry[]>(res, res.Response)); }
public Task <QueryResult <PreparedQueryExecuteResponse> > Execute(string queryIDOrName, QueryOptions q, CancellationToken ct = default(CancellationToken)) { return(_client.Get <PreparedQueryExecuteResponse>(string.Format("/v1/query/{0}/execute", queryIDOrName), q).Execute(ct)); }
/// <summary> /// Query is used to do a GET request against an endpoint and deserialize the response into an interface using standard Consul conventions. /// </summary> /// <param name="endpoint">The URL endpoint to access</param> /// <param name="q">Custom query options</param> /// <param name="ct">Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing</param> /// <returns>The data returned by the custom endpoint</returns> public Task <QueryResult <dynamic> > Query(string endpoint, QueryOptions q, CancellationToken ct = default(CancellationToken)) { return(_client.Get <dynamic>(endpoint, q).Execute(ct)); }
/// <summary> /// Datacenters is used to query for all the known datacenters /// </summary> /// <returns>A list of datacenter names</returns> public Task <QueryResult <string[]> > Datacenters() { return(_client.Get <string[]>("/v1/catalog/datacenters").Execute()); }
/// <summary> /// Datacenters is used to return the coordinates of all the servers in the WAN pool. /// </summary> /// <returns>A query result containing a map of datacenters, each with a list of coordinates of all the servers in the WAN pool</returns> public Task <QueryResult <CoordinateDatacenterMap[]> > Datacenters() { return(_client.Get <CoordinateDatacenterMap[]>(string.Format("/v1/coordinate/datacenters")).Execute()); }
/// <summary> /// RaftGetConfiguration is used to query the current Raft peer set. /// </summary> public Task <QueryResult <RaftConfiguration> > RaftGetConfiguration(QueryOptions q, CancellationToken ct = default(CancellationToken)) { return(_client.Get <RaftConfiguration>("/v1/operator/raft/configuration", q).Execute(ct)); }
/// <summary> /// Leader is used to query for a known leader /// </summary> /// <returns>A write result containing the leader node name</returns> public async Task <string> Leader() { var res = await _client.Get <string>("/v1/status/leader").Execute().ConfigureAwait(false); return(res.Response); }
/// <summary> /// Gets an existing ACL Token from Consul /// </summary> /// <param name="id">The Accessor ID of the ACL Token to get</param> /// <param name="queryOptions">Customized query options</param> /// <param name="ct">Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing</param> /// <returns>A query result containing the requested ACL Token</returns> public async Task <QueryResult <TokenEntry> > Read(string id, QueryOptions queryOptions, CancellationToken ct = default(CancellationToken)) { var res = await _client.Get <TokenActionResult>($"/v1/acl/token/{id}", queryOptions).Execute(ct).ConfigureAwait(false); return(new QueryResult <TokenEntry>(res, res.Response)); }
/// <summary> /// Leader is used to query for a known leader /// </summary> /// <returns>A write result containing the leader node name</returns> public async Task <string> Leader(CancellationToken ct = default(CancellationToken)) { var res = await _client.Get <string>("/v1/status/leader").Execute(ct).ConfigureAwait(false); return(res.Response); }
/// <summary> /// Datacenters is used to return the coordinates of all the servers in the WAN pool. /// </summary> /// <returns>A query result containing a map of datacenters, each with a list of coordinates of all the servers in the WAN pool</returns> public Task <QueryResult <CoordinateDatacenterMap[]> > Datacenters(CancellationToken ct = default(CancellationToken)) { return(_client.Get <CoordinateDatacenterMap[]>(string.Format("/v1/coordinate/datacenters")).Execute(ct)); }
/// <summary> /// Self is used to query the agent we are speaking to for information about itself /// </summary> /// <returns>A somewhat dynamic object representing the various data elements in Self</returns> public Task <QueryResult <Dictionary <string, Dictionary <string, dynamic> > > > Self() { return(_client.Get <Dictionary <string, Dictionary <string, dynamic> > >("/v1/agent/self").Execute()); }
/// <summary> /// Info looks up a single session /// </summary> /// <param name="id">The session ID to look up</param> /// <param name="q">Customized query options</param> /// <returns>A query result containing the session information, or an empty query result if the session entry does not exist</returns> public async Task <QueryResult <SessionEntry> > Info(string id, QueryOptions q, CancellationToken ct = default(CancellationToken)) { var res = await _client.Get <SessionEntry[]>(string.Format("/v1/session/info/{0}", id), q).Execute(ct).ConfigureAwait(false); return(new QueryResult <SessionEntry>(res, res.Response != null && res.Response.Length > 0 ? res.Response[0] : null)); }
public Task <QueryResult <PreparedQueryExecuteResponse> > Execute(string queryIDOrName, QueryOptions q) { return(_client.Get <PreparedQueryExecuteResponse>(string.Format("/v1/query/{0}/execute", queryIDOrName), q).Execute()); }
/// <summary> /// Checks is used to return the checks associated with a service /// </summary> /// <param name="service">The service ID</param> /// <param name="q">Customized query options</param> /// <param name="ct">Cancellation token for long poll request. If set, OperationCanceledException will be thrown if the request is cancelled before completing</param> /// <returns>A query result containing the health checks matching the provided service ID, or a query result with a null response if no service matched the provided ID</returns> public Task <QueryResult <HealthCheck[]> > Checks(string service, QueryOptions q, CancellationToken ct = default(CancellationToken)) { return(_client.Get <HealthCheck[]>(string.Format("/v1/health/checks/{0}", service), q).Execute(ct)); }
/// <summary> /// Replication returns the status of the ACL replication process in the datacenter /// </summary> /// <param name="q"></param> /// <param name="ct"></param> /// <returns></returns> /// <exception cref="NotImplementedException"></exception> public Task <QueryResult <ACLReplicationStatus> > Replication(QueryOptions q, CancellationToken ct = default(CancellationToken)) { return(_client.Get <ACLReplicationStatus>("/v1/acl/replication", q).Execute(ct)); }