Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add area get support and test (#381) #392

Merged
Merged
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
16 changes: 16 additions & 0 deletions Consul.Test/OperatorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
2 changes: 2 additions & 0 deletions Consul/Interfaces/IOperatorEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,7 @@ public interface IOperatorEndpoint
Task<QueryResult<List<Area>>> AreaList(QueryOptions q, CancellationToken cancellationToken = default);
Task<WriteResult<string>> AreaUpdate(AreaRequest area, string areaId, CancellationToken cancellationToken = default);
Task<WriteResult<string>> AreaUpdate(AreaRequest area, string areaId, WriteOptions q, CancellationToken cancellationToken = default);
Task<QueryResult<Area[]>> AreaGet(string areaId, CancellationToken cancellationToken = default);
Task<QueryResult<Area[]>> AreaGet(string areaId, QueryOptions q, CancellationToken cancellationToken = default);
}
}
14 changes: 14 additions & 0 deletions Consul/Operator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,20 @@ public async Task<WriteResult<string>> AreaUpdate(AreaRequest area, string areaI
var req = await _client.Put<AreaRequest, Area>($"/v1/operator/area/{areaId}", area, q).Execute(ct).ConfigureAwait(false);
return new WriteResult<string>(req, req.Response.ID);
}
/// <summary>
/// AreaGet returns a single network area
/// </summary>
public Task<QueryResult<Area[]>> AreaGet(string areaId, CancellationToken ct = default)
{
return AreaGet(areaId, QueryOptions.Default, ct);
}
/// <summary>
/// AreaGet returns a single network area
/// </summary>
public Task<QueryResult<Area[]>> AreaGet(string areaId, QueryOptions q, CancellationToken ct = default)
{
return _client.Get<Area[]>($"/v1/operator/area/{areaId}", q).Execute(ct);
}
}

public class ConsulLicense
Expand Down