diff --git a/Consul.Test/OperatorTest.cs b/Consul.Test/OperatorTest.cs index 6803623f5..346352c79 100644 --- a/Consul.Test/OperatorTest.cs +++ b/Consul.Test/OperatorTest.cs @@ -142,5 +142,21 @@ public async Task Operator_AreaUpdate() Assert.Equal(area.RetryJoin, updatedArea.RetryJoin); Assert.Equal(area.PeerDatacenter, updatedArea.PeerDatacenter); } + [EnterpriseOnlyFact] + public async Task Operator_AreaGet() + { + var peerDataCenter = KVTest.GenerateTestKeyName(); + var area = new AreaRequest { PeerDatacenter = peerDataCenter, UseTLS = true, RetryJoin = new string[] { "10.1.2.7", "10.1.2.0" } }; + var createResult = await _client.Operator.AreaCreate(area); + var areaId = createResult.Response; + + var req = await _client.Operator.AreaGet(areaId); + var result = req.Response.Single(x => x.ID == areaId); + + Assert.Equal(areaId, result.ID); + Assert.Equal(area.UseTLS, result.UseTLS); + Assert.Equal(area.RetryJoin, result.RetryJoin); + Assert.Equal(area.PeerDatacenter, result.PeerDatacenter); + } } } diff --git a/Consul/Interfaces/IOperatorEndpoint.cs b/Consul/Interfaces/IOperatorEndpoint.cs index a91688ab9..3e1fa7215 100644 --- a/Consul/Interfaces/IOperatorEndpoint.cs +++ b/Consul/Interfaces/IOperatorEndpoint.cs @@ -51,5 +51,7 @@ public interface IOperatorEndpoint Task>> AreaList(QueryOptions q, CancellationToken cancellationToken = default); Task> AreaUpdate(AreaRequest area, string areaId, CancellationToken cancellationToken = default); Task> AreaUpdate(AreaRequest area, string areaId, WriteOptions q, CancellationToken cancellationToken = default); + Task> AreaGet(string areaId, CancellationToken cancellationToken = default); + Task> AreaGet(string areaId, QueryOptions q, CancellationToken cancellationToken = default); } } diff --git a/Consul/Operator.cs b/Consul/Operator.cs index 7eb11ec10..e7286e892 100644 --- a/Consul/Operator.cs +++ b/Consul/Operator.cs @@ -327,6 +327,20 @@ public async Task> AreaUpdate(AreaRequest area, string areaI var req = await _client.Put($"/v1/operator/area/{areaId}", area, q).Execute(ct).ConfigureAwait(false); return new WriteResult(req, req.Response.ID); } + /// + /// AreaGet returns a single network area + /// + public Task> AreaGet(string areaId, CancellationToken ct = default) + { + return AreaGet(areaId, QueryOptions.Default, ct); + } + /// + /// AreaGet returns a single network area + /// + public Task> AreaGet(string areaId, QueryOptions q, CancellationToken ct = default) + { + return _client.Get($"/v1/operator/area/{areaId}", q).Execute(ct); + } } public class ConsulLicense