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

refactor: reuse already implemented methods in Namespaces #238

Merged
merged 3 commits into from
Sep 4, 2023
Merged
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
30 changes: 14 additions & 16 deletions Consul/Namespace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ public async Task<WriteResult<NamespaceResponse>> Create(Namespace ns, WriteOpti

public async Task<WriteResult<NamespaceResponse>> Create(Namespace ns, CancellationToken ct = default)
{
var res = await _client.Put<Namespace, NamespaceResponse>("v1/namespace", ns, WriteOptions.Default).Execute(ct).ConfigureAwait(false);
return new WriteResult<NamespaceResponse>(res, res.Response);
return await Create(ns, WriteOptions.Default, ct).ConfigureAwait(false);
}

public async Task<WriteResult<NamespaceResponse>> Update(Namespace ns, WriteOptions q, CancellationToken ct = default)
Expand All @@ -61,38 +60,37 @@ public async Task<WriteResult<NamespaceResponse>> Update(Namespace ns, WriteOpti

public async Task<WriteResult<NamespaceResponse>> Update(Namespace ns, CancellationToken ct = default)
{
var res = await _client.Put<Namespace, NamespaceResponse>($"v1/namespace/{ns.Name}", ns, WriteOptions.Default).Execute(ct).ConfigureAwait(false);
return new WriteResult<NamespaceResponse>(res, res.Response);
return await Update(ns, WriteOptions.Default, ct).ConfigureAwait(false);
}

public Task<QueryResult<NamespaceResponse>> Read(string name, QueryOptions q, CancellationToken ct = default)
public async Task<QueryResult<NamespaceResponse>> Read(string name, QueryOptions q, CancellationToken ct = default)
{
return _client.Get<NamespaceResponse>($"v1/namespace/{name}", q).Execute(ct);
return await _client.Get<NamespaceResponse>($"v1/namespace/{name}", q).Execute(ct).ConfigureAwait(false);
}

public Task<QueryResult<NamespaceResponse>> Read(string name, CancellationToken ct = default)
public async Task<QueryResult<NamespaceResponse>> Read(string name, CancellationToken ct = default)
{
return _client.Get<NamespaceResponse>($"v1/namespace/{name}", QueryOptions.Default).Execute(ct);
return await Read(name, QueryOptions.Default, ct).ConfigureAwait(false);
}

public Task<QueryResult<NamespaceResponse[]>> List(QueryOptions q, CancellationToken ct = default)
public async Task<QueryResult<NamespaceResponse[]>> List(QueryOptions q, CancellationToken ct = default)
{
return _client.Get<NamespaceResponse[]>($"v1/namespaces", q).Execute(ct);
return await _client.Get<NamespaceResponse[]>($"v1/namespaces", q).Execute(ct).ConfigureAwait(false);
}

public Task<QueryResult<NamespaceResponse[]>> List(CancellationToken ct = default)
public async Task<QueryResult<NamespaceResponse[]>> List(CancellationToken ct = default)
{
return _client.Get<NamespaceResponse[]>($"v1/namespaces", QueryOptions.Default).Execute(ct);
return await List(QueryOptions.Default, ct).ConfigureAwait(false);
}

public Task<WriteResult> Delete(string name, WriteOptions q, CancellationToken ct = default)
public async Task<WriteResult> Delete(string name, WriteOptions q, CancellationToken ct = default)
{
return _client.Delete($"v1/namespace/{name}", q).Execute(ct);
return await _client.Delete($"v1/namespace/{name}", q).Execute(ct).ConfigureAwait(false);
}

public Task<WriteResult> Delete(string name, CancellationToken ct = default)
public async Task<WriteResult> Delete(string name, CancellationToken ct = default)
{
return _client.Delete($"v1/namespace/{name}", WriteOptions.Default).Execute(ct);
return await Delete(name, WriteOptions.Default, ct).ConfigureAwait(false);
}
}

Expand Down