Skip to content

Commit

Permalink
Merge pull request #6 from enclave-networks/feature/systems-client
Browse files Browse the repository at this point in the history
Added Enrolled Systems Client and Logs Client
  • Loading branch information
Tom Soulard authored Dec 14, 2021
2 parents d2e5d19 + 7e97936 commit bdf06ba
Show file tree
Hide file tree
Showing 66 changed files with 1,719 additions and 243 deletions.
14 changes: 0 additions & 14 deletions src/Enclave.Sdk/Clients/AuthorityClient.cs

This file was deleted.

4 changes: 2 additions & 2 deletions src/Enclave.Sdk/Clients/ClientBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected ClientBase(HttpClient httpClient)
/// <param name="data">the object to encode.</param>
/// <returns>String content of object.</returns>
/// <exception cref="ArgumentNullException">throws if data provided is null.</exception>
protected StringContent CreateJsonContent<TModel>(TModel data)
protected static StringContent CreateJsonContent<TModel>(TModel data)
{
if (data is null)
{
Expand All @@ -51,7 +51,7 @@ protected StringContent CreateJsonContent<TModel>(TModel data)
/// <typeparam name="TModel">the object type to deserialise to.</typeparam>
/// <param name="httpContent">httpContent from the API call.</param>
/// <returns>the object of type specified.</returns>
protected async Task<TModel?> DeserialiseAsync<TModel>(HttpContent httpContent)
protected static async Task<TModel?> DeserialiseAsync<TModel>(HttpContent httpContent)
{
if (httpContent is null)
{
Expand Down
40 changes: 20 additions & 20 deletions src/Enclave.Sdk/Clients/DNSClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ public async Task<DnsSummary> GetPropertiesSummaryAsync()
}

/// <inheritdoc/>
public async Task<PaginatedResponseModel<BasicDnsZone>> GetZonesAsync(int? pageNumber = null, int? perPage = null)
public async Task<PaginatedResponseModel<DnsZoneSummary>> GetZonesAsync(int? pageNumber = null, int? perPage = null)
{
var queryString = BuildQueryString(null, null, pageNumber, perPage);

var model = await HttpClient.GetFromJsonAsync<PaginatedResponseModel<BasicDnsZone>>($"{_orgRoute}/dns/zones?{queryString}");
var model = await HttpClient.GetFromJsonAsync<PaginatedResponseModel<DnsZoneSummary>>($"{_orgRoute}/dns/zones?{queryString}");

EnsureNotNull(model);

return model;
}

/// <inheritdoc/>
public async Task<FullDnsZone> CreateZoneAsync(DnsZoneCreate createModel)
public async Task<DnsZone> CreateZoneAsync(DnsZoneCreate createModel)
{
if (createModel is null)
{
Expand All @@ -56,25 +56,25 @@ public async Task<FullDnsZone> CreateZoneAsync(DnsZoneCreate createModel)

var result = await HttpClient.PostAsJsonAsync($"{_orgRoute}/dns/zones", createModel, Constants.JsonSerializerOptions);

var model = await DeserialiseAsync<FullDnsZone>(result.Content);
var model = await DeserialiseAsync<DnsZone>(result.Content);

EnsureNotNull(model);

return model;
}

/// <inheritdoc/>
public async Task<FullDnsZone> GetZoneAsync(DnsZoneId dnsZoneId)
public async Task<DnsZone> GetZoneAsync(DnsZoneId dnsZoneId)
{
var model = await HttpClient.GetFromJsonAsync<FullDnsZone>($"{_orgRoute}/dns/zones/{dnsZoneId}", Constants.JsonSerializerOptions);
var model = await HttpClient.GetFromJsonAsync<DnsZone>($"{_orgRoute}/dns/zones/{dnsZoneId}", Constants.JsonSerializerOptions);

EnsureNotNull(model);

return model;
}

/// <inheritdoc/>
public async Task<FullDnsZone> UpdateZoneAsync(DnsZoneId dnsZoneId, PatchBuilder<DnsZonePatch> builder)
public async Task<DnsZone> UpdateZoneAsync(DnsZoneId dnsZoneId, PatchBuilder<DnsZonePatch> builder)
{
if (builder is null)
{
Expand All @@ -86,45 +86,45 @@ public async Task<FullDnsZone> UpdateZoneAsync(DnsZoneId dnsZoneId, PatchBuilder

result.EnsureSuccessStatusCode();

var model = await DeserialiseAsync<FullDnsZone>(result.Content);
var model = await DeserialiseAsync<DnsZone>(result.Content);

EnsureNotNull(model);

return model;
}

/// <inheritdoc/>
public async Task<FullDnsZone> DeleteZoneAsync(DnsZoneId dnsZoneId)
public async Task<DnsZone> DeleteZoneAsync(DnsZoneId dnsZoneId)
{
var result = await HttpClient.DeleteAsync($"{_orgRoute}/dns/zones/{dnsZoneId}");

result.EnsureSuccessStatusCode();

var model = await DeserialiseAsync<FullDnsZone>(result.Content);
var model = await DeserialiseAsync<DnsZone>(result.Content);

EnsureNotNull(model);

return model;
}

/// <inheritdoc/>
public async Task<PaginatedResponseModel<BasicDnsRecord>> GetRecordsAsync(
public async Task<PaginatedResponseModel<DnsRecordSummary>> GetRecordsAsync(
DnsZoneId? dnsZoneId = null,
string? hostname = null,
int? pageNumber = null,
int? perPage = null)
{
var queryString = BuildQueryString(dnsZoneId, hostname, pageNumber, perPage);

var model = await HttpClient.GetFromJsonAsync<PaginatedResponseModel<BasicDnsRecord>>($"{_orgRoute}/dns/records?{queryString}");
var model = await HttpClient.GetFromJsonAsync<PaginatedResponseModel<DnsRecordSummary>>($"{_orgRoute}/dns/records?{queryString}");

EnsureNotNull(model);

return model;
}

/// <inheritdoc/>
public async Task<FullDnsRecord> CreateRecordAsync(DnsRecordCreate createModel)
public async Task<DnsRecord> CreateRecordAsync(DnsRecordCreate createModel)
{
if (createModel is null)
{
Expand All @@ -133,7 +133,7 @@ public async Task<FullDnsRecord> CreateRecordAsync(DnsRecordCreate createModel)

var result = await HttpClient.PostAsJsonAsync($"{_orgRoute}/dns/records", createModel, Constants.JsonSerializerOptions);

var model = await DeserialiseAsync<FullDnsRecord>(result.Content);
var model = await DeserialiseAsync<DnsRecord>(result.Content);

EnsureNotNull(model);

Expand Down Expand Up @@ -178,17 +178,17 @@ public async Task<int> DeleteRecordsAsync(IEnumerable<DnsRecordId> records)
}

/// <inheritdoc/>
public async Task<FullDnsRecord> GetRecordAsync(DnsRecordId dnsRecordId)
public async Task<DnsRecord> GetRecordAsync(DnsRecordId dnsRecordId)
{
var model = await HttpClient.GetFromJsonAsync<FullDnsRecord>($"{_orgRoute}/dns/records/{dnsRecordId}", Constants.JsonSerializerOptions);
var model = await HttpClient.GetFromJsonAsync<DnsRecord>($"{_orgRoute}/dns/records/{dnsRecordId}", Constants.JsonSerializerOptions);

EnsureNotNull(model);

return model;
}

/// <inheritdoc/>
public async Task<FullDnsRecord> UpdateRecordAsync(DnsRecordId dnsRecordId, PatchBuilder<DnsRecordPatch> builder)
public async Task<DnsRecord> UpdateRecordAsync(DnsRecordId dnsRecordId, PatchBuilder<DnsRecordPatch> builder)
{
if (builder is null)
{
Expand All @@ -200,21 +200,21 @@ public async Task<FullDnsRecord> UpdateRecordAsync(DnsRecordId dnsRecordId, Patc

result.EnsureSuccessStatusCode();

var model = await DeserialiseAsync<FullDnsRecord>(result.Content);
var model = await DeserialiseAsync<DnsRecord>(result.Content);

EnsureNotNull(model);

return model;
}

/// <inheritdoc/>
public async Task<FullDnsRecord> DeleteRecordAsync(DnsRecordId dnsRecordId)
public async Task<DnsRecord> DeleteRecordAsync(DnsRecordId dnsRecordId)
{
var result = await HttpClient.DeleteAsync($"{_orgRoute}/dns/records/{dnsRecordId}");

result.EnsureSuccessStatusCode();

var model = await DeserialiseAsync<FullDnsRecord>(result.Content);
var model = await DeserialiseAsync<DnsRecord>(result.Content);

EnsureNotNull(model);

Expand Down
Loading

0 comments on commit bdf06ba

Please sign in to comment.