Skip to content
This repository has been archived by the owner on Apr 27, 2019. It is now read-only.

Feature/port 0.9 #102

Open
wants to merge 6 commits into
base: feature/port_0.9
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 130 additions & 0 deletions Consul/Agent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,9 @@ private class CheckUpdate
public string Output { get; set; }
}

/// <summary>
/// AgentToken is used when updating ACL tokens for an agent.
/// </summary>
private class AgentToken
{
[JsonProperty]
Expand Down Expand Up @@ -665,6 +668,133 @@ internal Agent(ConsulClient c)
var res = await req.ExecuteStreaming(ct).ConfigureAwait(false);
return new LogStream(res.Response);
}

/// <summary>
/// UpdateACLToken updates the agent's "acl_token".
/// <see cref="UpdateToken"/> for more details.
/// </summary>
/// <param name="token"></param>
/// <param name="q"></param>
/// <param name="ct"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public Task<WriteResult> UpdateACLToken(string token, WriteOptions q, CancellationToken ct = default(CancellationToken))
{
return UpdateToken("acl_token", token, q, ct);
}

/// <summary>
/// UpdateACLToken updates the agent's "acl_token".
/// <see cref="UpdateToken"/> for more details.
/// </summary>
/// <param name="token"></param>
/// <param name="ct"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public Task<WriteResult> UpdateACLToken(string token, CancellationToken ct = default(CancellationToken))
{
return UpdateACLToken(token, WriteOptions.Default, ct);
}

/// <summary>
/// UpdateACLAgentToken updates the agent's "acl_agent_token".
/// <see cref="UpdateToken"/> for more details.
/// </summary>
/// <param name="token"></param>
/// <param name="q"></param>
/// <param name="ct"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public Task<WriteResult> UpdateACLAgentToken(string token, WriteOptions q, CancellationToken ct = default(CancellationToken))
{
return UpdateToken("acl_agent_token", token, q, ct);
}

/// <summary>
/// UpdateACLAgentToken updates the agent's "acl_agent_token".
/// <see cref="UpdateToken"/> for more details.
/// </summary>
/// <param name="token"></param>
/// <param name="ct"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public Task<WriteResult> UpdateACLAgentToken(string token, CancellationToken ct = default(CancellationToken))
{
return UpdateACLAgentToken(token, WriteOptions.Default, ct);
}

/// <summary>
/// UpdateACLAgentMasterToken updates the agent's "acl_agent_master_token".
/// <see cref="UpdateToken"/> for more details.
/// </summary>
/// <param name="token"></param>
/// <param name="q"></param>
/// <param name="ct"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public Task<WriteResult> UpdateACLAgentMasterToken(string token, WriteOptions q, CancellationToken ct = default(CancellationToken))
{
return UpdateToken("acl_agent_master_token", token, q, ct);
}

/// <summary>
/// UpdateACLAgentMasterToken updates the agent's "acl_agent_master_token".
/// <see cref="UpdateToken"/> for more details.
/// </summary>
/// <param name="token"></param>
/// <param name="ct"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public Task<WriteResult> UpdateACLAgentMasterToken(string token, CancellationToken ct = default(CancellationToken))
{
return UpdateACLAgentMasterToken(token, WriteOptions.Default, ct);
}

/// <summary>
/// UpdateACLReplicationToken updates the agent's "acl_replication_token".
/// <see cref="UpdateToken"/> for more details.
/// </summary>
/// <param name="token"></param>
/// <param name="q"></param>
/// <param name="ct"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public Task<WriteResult> UpdateACLReplicationToken(string token, WriteOptions q, CancellationToken ct = default(CancellationToken))
{
return UpdateToken("acl_replication_token", token, q, ct);
}

/// <summary>
/// UpdateACLReplicationToken updates the agent's "acl_replication_token".
/// <see cref="UpdateToken"/> for more details.
/// </summary>
/// <param name="token"></param>
/// <param name="ct"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
/// <see cref="UpdateToken"/>
public Task<WriteResult> UpdateACLReplicationToken(string token, CancellationToken ct = default(CancellationToken))
{
return UpdateACLReplicationToken(token, WriteOptions.Default, ct);
}

/// <summary>
/// UpdateToken can be used to update an agent's ACL token after the agent has
/// started. The tokens are not persisted, so will need to be updated again if
/// the agent is restarted.
/// </summary>
/// <param name="target"></param>
/// <param name="token"></param>
/// <param name="q"></param>
/// <param name="ct"></param>
/// <returns></returns>
private Task<WriteResult> UpdateToken(string target, string token, WriteOptions q, CancellationToken ct)
{
var req = _client.Put(string.Format("/v1/agent/token/{0}", target),
new AgentToken {Token = token}, q);

return req.Execute(ct);
}

public class LogStream : IEnumerable<Task<string>>, IDisposable
{
Expand Down
8 changes: 8 additions & 0 deletions Consul/Interfaces/IAgentEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,13 @@ public interface IAgentEndpoint
Task<WriteResult> Leave(string node, CancellationToken ct = default(CancellationToken));
Task<WriteResult> Reload(CancellationToken ct = default(CancellationToken));
Task<QueryResult<MetricsInfo>> Metrics(CancellationToken ct = default(CancellationToken));
Task<WriteResult> UpdateACLToken(string token, WriteOptions q, CancellationToken ct = default(CancellationToken));
Task<WriteResult> UpdateACLToken(string token, CancellationToken ct = default(CancellationToken));
Task<WriteResult> UpdateACLAgentToken(string token, WriteOptions q, CancellationToken ct = default(CancellationToken));
Task<WriteResult> UpdateACLAgentToken(string token, CancellationToken ct = default(CancellationToken));
Task<WriteResult> UpdateACLAgentMasterToken(string token, WriteOptions q, CancellationToken ct = default(CancellationToken));
Task<WriteResult> UpdateACLAgentMasterToken(string token, CancellationToken ct = default(CancellationToken));
Task<WriteResult> UpdateACLReplicationToken(string token, WriteOptions q, CancellationToken ct = default(CancellationToken));
Task<WriteResult> UpdateACLReplicationToken(string token, CancellationToken ct = default(CancellationToken));
}
}
24 changes: 24 additions & 0 deletions Consul/Interfaces/IOperatorEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,29 @@ public interface IOperatorEndpoint
Task<WriteResult> KeyringRemove(string key, WriteOptions q, CancellationToken ct = default(CancellationToken));
Task<WriteResult> KeyringUse(string key, CancellationToken ct = default(CancellationToken));
Task<WriteResult> KeyringUse(string key, WriteOptions q, CancellationToken ct = default(CancellationToken));
Task<WriteResult<string>> AreaCreate(Area area, WriteOptions q, CancellationToken ct = default(CancellationToken));
Task<WriteResult<string>> AreaCreate(Area area, CancellationToken ct = default(CancellationToken));
Task<WriteResult> AreaDelete(string areaID, WriteOptions q, CancellationToken ct = default(CancellationToken));
Task<WriteResult> AreaDelete(string areaID, CancellationToken ct = default(CancellationToken));
Task<QueryResult<Area[]>> AreaGet(string areaID, QueryOptions q, CancellationToken ct = default(CancellationToken));
Task<QueryResult<Area[]>> AreaGet(string areaID, CancellationToken ct = default(CancellationToken));
Task<WriteResult<AreaJoinResponse[]>> AreaJoin(string areaID, string[] addresses, WriteOptions q, CancellationToken ct = default(CancellationToken));
Task<WriteResult<AreaJoinResponse[]>> AreaJoin(string areaID, string[] addresses, CancellationToken ct = default(CancellationToken));
Task<QueryResult<Area[]>> AreaList(QueryOptions q, CancellationToken ct = default(CancellationToken));
Task<QueryResult<Area[]>> AreaList(CancellationToken ct = default(CancellationToken));
Task<QueryResult<SerfMember[]>> AreaMembers(string areaID, QueryOptions q, CancellationToken ct = default(CancellationToken));
Task<QueryResult<SerfMember[]>> AreaMembers(string areaID, CancellationToken ct = default(CancellationToken));
Task<WriteResult<string>> AreaUpdate(string areaID, Area area, WriteOptions q, CancellationToken ct = default (CancellationToken));
Task<WriteResult<string>> AreaUpdate(string areaID, Area area, CancellationToken ct = default (CancellationToken));
Task<QueryResult<string[]>> SegmentList(QueryOptions q, CancellationToken ct = default(CancellationToken));
Task<QueryResult<string[]>> SegmentList(CancellationToken ct = default(CancellationToken));
Task<bool> AutopilotCASConfiguration(AutopilotConfiguration conf, WriteOptions q, CancellationToken ct = default(CancellationToken));
Task<bool> AutopilotCASConfiguration(AutopilotConfiguration conf, CancellationToken ct = default(CancellationToken));
Task<AutopilotConfiguration> AutopilotGetConfiguration(QueryOptions q, CancellationToken ct = default(CancellationToken));
Task<AutopilotConfiguration> AutopilotGetConfiguration(CancellationToken ct = default(CancellationToken));
Task AutopilotSetConfiguration(AutopilotConfiguration conf, WriteOptions q, CancellationToken ct = default(CancellationToken));
Task AutopilotSetConfiguration(AutopilotConfiguration conf, CancellationToken ct = default(CancellationToken));
Task<OperatorHealthReply> AutopilotServerHealth(QueryOptions q, CancellationToken ct = default(CancellationToken));
Task<OperatorHealthReply> AutopilotServerHealth(CancellationToken ct = default(CancellationToken));
}
}
Loading