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 support for list network area and test (#381) #387

Merged
merged 12 commits into from
Oct 31, 2024
6 changes: 6 additions & 0 deletions Consul.Test/OperatorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,11 @@ public async Task Operator_CreateArea()
var response = await _client.Operator.CreateArea(check);
Assert.NotNull(response.Response);
}
[EnterpriseOnlyFact]
public async Task Operator_AreaList()
{
var req = await _client.Operator.AreaList();
Assert.NotNull(req.Response);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make this test more exhaustive, it would be nice to create an area first and then assert that the query result is non-empty (instead of not null).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done ✅

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pleas also updated the test condition, from not null to non-empty. Please inspect also a result fields if they are filled in.

}
}
}
3 changes: 2 additions & 1 deletion Consul/Interfaces/IOperatorEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public interface IOperatorEndpoint
Task<QueryResult<string[]>> SegmentList(CancellationToken cancellationToken = default);
Task<WriteResult<string>> CreateArea(AreaRequest area, WriteOptions q, CancellationToken ct = default);
Task<WriteResult<string>> CreateArea(AreaRequest area, CancellationToken ct = default);

Task<QueryResult<List<Area>>> AreaList(CancellationToken cancellationToken = default);
larrytamnjong marked this conversation as resolved.
Show resolved Hide resolved
Task<QueryResult<List<Area>>> AreaList(QueryOptions q, CancellationToken cancellationToken = default);
}
}
16 changes: 16 additions & 0 deletions Consul/Operator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,22 @@ public async Task<WriteResult<string>> CreateArea(AreaRequest area, WriteOptions
var req = await _client.Post<AreaRequest, Area>("/v1/operator/area", area, q).Execute(ct).ConfigureAwait(false);
return new WriteResult<string>(req, req.Response.ID);
}

/// <summary>
/// AreaList returns all the available network areas
/// </summary>
public Task<QueryResult<List<Area>>> AreaList(CancellationToken ct = default)
{
return AreaList(QueryOptions.Default, ct);
}

/// <summary>
/// AreaList returns all the available network areas
/// </summary>
public Task<QueryResult<List<Area>>> AreaList(QueryOptions q, CancellationToken ct = default)
{
return _client.Get<List<Area>>("/v1/operator/area", q).Execute(ct);
}
}

public class ConsulLicense
Expand Down