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

Features/automatic update #10

Merged
merged 9 commits into from
Nov 9, 2022
36 changes: 18 additions & 18 deletions Client/Com/Cumulocity/Client/Api/AlarmsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public AlarmsApi(HttpClient httpClient) : base(httpClient)
}

/// <inheritdoc />
public async Task<AlarmCollection?> GetAlarms(System.DateTime? createdFrom = null, System.DateTime? createdTo = null, int? currentPage = null, System.DateTime? dateFrom = null, System.DateTime? dateTo = null, System.DateTime? lastUpdatedFrom = null, System.DateTime? lastUpdatedTo = null, int? pageSize = null, bool? resolved = null, string? severity = null, string? source = null, string? status = null, List<string>? type = null, bool? withSourceAssets = null, bool? withSourceDevices = null, bool? withTotalElements = null, bool? withTotalPages = null)
public async Task<AlarmCollection<TAlarm>?> GetAlarms<TAlarm>(System.DateTime? createdFrom = null, System.DateTime? createdTo = null, int? currentPage = null, System.DateTime? dateFrom = null, System.DateTime? dateTo = null, System.DateTime? lastUpdatedFrom = null, System.DateTime? lastUpdatedTo = null, int? pageSize = null, bool? resolved = null, string? severity = null, string? source = null, string? status = null, List<string>? type = null, bool? withSourceAssets = null, bool? withSourceDevices = null, bool? withTotalElements = null, bool? withTotalPages = null) where TAlarm : Alarm
{
var client = HttpClient;
var resourcePath = $"/alarm/alarms";
Expand Down Expand Up @@ -62,7 +62,7 @@ public AlarmsApi(HttpClient httpClient) : base(httpClient)
{"withTotalPages", withTotalPages}
#pragma warning restore CS8604 // Possible null reference argument.
};
allQueryParameter.Where(p => p.Value != null).AsParallel().ForAll(e => queryString.Add(e.Key, $"{e.Value}"));
allQueryParameter.Where(p => p.Value != null).ToList().ForEach(e => queryString.Add(e.Key, $"{e.Value}"));
uriBuilder.Query = queryString.ToString();
var request = new HttpRequestMessage
{
Expand All @@ -73,13 +73,13 @@ public AlarmsApi(HttpClient httpClient) : base(httpClient)
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
using var responseStream = await response.Content.ReadAsStreamAsync();
return await JsonSerializer.DeserializeAsync<AlarmCollection?>(responseStream);
return await JsonSerializer.DeserializeAsync<AlarmCollection<TAlarm>?>(responseStream);
}

/// <inheritdoc />
public async Task<System.IO.Stream> UpdateAlarms(Alarm body, System.DateTime? createdFrom = null, System.DateTime? createdTo = null, System.DateTime? dateFrom = null, System.DateTime? dateTo = null, bool? resolved = null, string? severity = null, string? source = null, string? status = null, bool? withSourceAssets = null, bool? withSourceDevices = null)
public async Task<System.IO.Stream> UpdateAlarms<TAlarm>(TAlarm body, System.DateTime? createdFrom = null, System.DateTime? createdTo = null, System.DateTime? dateFrom = null, System.DateTime? dateTo = null, bool? resolved = null, string? severity = null, string? source = null, string? status = null, bool? withSourceAssets = null, bool? withSourceDevices = null) where TAlarm : Alarm
{
var jsonNode = ToJsonNode<Alarm>(body);
var jsonNode = ToJsonNode<TAlarm>(body);
jsonNode?.RemoveFromNode("firstOccurrenceTime");
jsonNode?.RemoveFromNode("severity");
jsonNode?.RemoveFromNode("lastUpdated");
Expand Down Expand Up @@ -110,7 +110,7 @@ public AlarmsApi(HttpClient httpClient) : base(httpClient)
{"withSourceDevices", withSourceDevices}
#pragma warning restore CS8604 // Possible null reference argument.
};
allQueryParameter.Where(p => p.Value != null).AsParallel().ForAll(e => queryString.Add(e.Key, $"{e.Value}"));
allQueryParameter.Where(p => p.Value != null).ToList().ForEach(e => queryString.Add(e.Key, $"{e.Value}"));
uriBuilder.Query = queryString.ToString();
var request = new HttpRequestMessage
{
Expand All @@ -127,9 +127,9 @@ public AlarmsApi(HttpClient httpClient) : base(httpClient)
}

/// <inheritdoc />
public async Task<Alarm?> CreateAlarm(Alarm body)
public async Task<TAlarm?> CreateAlarm<TAlarm>(TAlarm body) where TAlarm : Alarm
{
var jsonNode = ToJsonNode<Alarm>(body);
var jsonNode = ToJsonNode<TAlarm>(body);
jsonNode?.RemoveFromNode("firstOccurrenceTime");
jsonNode?.RemoveFromNode("lastUpdated");
jsonNode?.RemoveFromNode("creationTime");
Expand All @@ -151,11 +151,11 @@ public AlarmsApi(HttpClient httpClient) : base(httpClient)
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
using var responseStream = await response.Content.ReadAsStreamAsync();
return await JsonSerializer.DeserializeAsync<Alarm?>(responseStream);
return await JsonSerializer.DeserializeAsync<TAlarm?>(responseStream);
}

/// <inheritdoc />
public async Task<System.IO.Stream> DeleteAlarms(System.DateTime? createdFrom = null, System.DateTime? createdTo = null, System.DateTime? dateFrom = null, System.DateTime? dateTo = null, bool? resolved = null, string? severity = null, string? source = null, string? status = null, List<string>? type = null, bool? withSourceAssets = null, bool? withSourceDevices = null)
public async Task<System.IO.Stream> DeleteAlarms(System.DateTime? createdFrom = null, System.DateTime? createdTo = null, System.DateTime? dateFrom = null, System.DateTime? dateTo = null, bool? resolved = null, string? severity = null, string? source = null, string? status = null, List<string>? type = null, bool? withSourceAssets = null, bool? withSourceDevices = null)
{
var client = HttpClient;
var resourcePath = $"/alarm/alarms";
Expand All @@ -177,7 +177,7 @@ public AlarmsApi(HttpClient httpClient) : base(httpClient)
{"withSourceDevices", withSourceDevices}
#pragma warning restore CS8604 // Possible null reference argument.
};
allQueryParameter.Where(p => p.Value != null).AsParallel().ForAll(e => queryString.Add(e.Key, $"{e.Value}"));
allQueryParameter.Where(p => p.Value != null).ToList().ForEach(e => queryString.Add(e.Key, $"{e.Value}"));
uriBuilder.Query = queryString.ToString();
var request = new HttpRequestMessage
{
Expand All @@ -192,7 +192,7 @@ public AlarmsApi(HttpClient httpClient) : base(httpClient)
}

/// <inheritdoc />
public async Task<Alarm?> GetAlarm(string id)
public async Task<TAlarm?> GetAlarm<TAlarm>(string id) where TAlarm : Alarm
{
var client = HttpClient;
var resourcePath = $"/alarm/alarms/{id}";
Expand All @@ -206,13 +206,13 @@ public AlarmsApi(HttpClient httpClient) : base(httpClient)
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
using var responseStream = await response.Content.ReadAsStreamAsync();
return await JsonSerializer.DeserializeAsync<Alarm?>(responseStream);
return await JsonSerializer.DeserializeAsync<TAlarm?>(responseStream);
}

/// <inheritdoc />
public async Task<Alarm?> UpdateAlarm(Alarm body, string id)
public async Task<TAlarm?> UpdateAlarm<TAlarm>(TAlarm body, string id) where TAlarm : Alarm
{
var jsonNode = ToJsonNode<Alarm>(body);
var jsonNode = ToJsonNode<TAlarm>(body);
jsonNode?.RemoveFromNode("firstOccurrenceTime");
jsonNode?.RemoveFromNode("lastUpdated");
jsonNode?.RemoveFromNode("creationTime");
Expand All @@ -236,11 +236,11 @@ public AlarmsApi(HttpClient httpClient) : base(httpClient)
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
using var responseStream = await response.Content.ReadAsStreamAsync();
return await JsonSerializer.DeserializeAsync<Alarm?>(responseStream);
return await JsonSerializer.DeserializeAsync<TAlarm?>(responseStream);
}

/// <inheritdoc />
public async Task<int> GetNumberOfAlarms(System.DateTime? dateFrom = null, System.DateTime? dateTo = null, bool? resolved = null, string? severity = null, string? source = null, string? status = null, List<string>? type = null, bool? withSourceAssets = null, bool? withSourceDevices = null)
public async Task<int> GetNumberOfAlarms(System.DateTime? dateFrom = null, System.DateTime? dateTo = null, bool? resolved = null, string? severity = null, string? source = null, string? status = null, List<string>? type = null, bool? withSourceAssets = null, bool? withSourceDevices = null)
{
var client = HttpClient;
var resourcePath = $"/alarm/alarms/count";
Expand All @@ -260,7 +260,7 @@ public async Task<int> GetNumberOfAlarms(System.DateTime? dateFrom = null, Syste
{"withSourceDevices", withSourceDevices}
#pragma warning restore CS8604 // Possible null reference argument.
};
allQueryParameter.Where(p => p.Value != null).AsParallel().ForAll(e => queryString.Add(e.Key, $"{e.Value}"));
allQueryParameter.Where(p => p.Value != null).ToList().ForEach(e => queryString.Add(e.Key, $"{e.Value}"));
uriBuilder.Query = queryString.ToString();
var request = new HttpRequestMessage
{
Expand Down
8 changes: 4 additions & 4 deletions Client/Com/Cumulocity/Client/Api/ApplicationBinariesApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public ApplicationBinariesApi(HttpClient httpClient) : base(httpClient)
}

/// <inheritdoc />
public async Task<ApplicationBinaries?> GetApplicationAttachments(string id)
public async Task<ApplicationBinaries?> GetApplicationAttachments(string id)
{
var client = HttpClient;
var resourcePath = $"/application/applications/{id}/binaries";
Expand All @@ -49,7 +49,7 @@ public ApplicationBinariesApi(HttpClient httpClient) : base(httpClient)
}

/// <inheritdoc />
public async Task<Application?> UploadApplicationAttachment(byte[] file, string id)
public async Task<Application?> UploadApplicationAttachment(byte[] file, string id)
{
var client = HttpClient;
var resourcePath = $"/application/applications/{id}/binaries";
Expand All @@ -73,7 +73,7 @@ public ApplicationBinariesApi(HttpClient httpClient) : base(httpClient)
}

/// <inheritdoc />
public async Task<System.IO.Stream> GetApplicationAttachment(string id, string binaryId)
public async Task<System.IO.Stream> GetApplicationAttachment(string id, string binaryId)
{
var client = HttpClient;
var resourcePath = $"/application/applications/{id}/binaries/{binaryId}";
Expand All @@ -91,7 +91,7 @@ public ApplicationBinariesApi(HttpClient httpClient) : base(httpClient)
}

/// <inheritdoc />
public async Task<System.IO.Stream> DeleteApplicationAttachment(string id, string binaryId)
public async Task<System.IO.Stream> DeleteApplicationAttachment(string id, string binaryId)
{
var client = HttpClient;
var resourcePath = $"/application/applications/{id}/binaries/{binaryId}";
Expand Down
28 changes: 14 additions & 14 deletions Client/Com/Cumulocity/Client/Api/ApplicationsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public ApplicationsApi(HttpClient httpClient) : base(httpClient)
}

/// <inheritdoc />
public async Task<ApplicationCollection?> GetApplications(int? currentPage = null, string? name = null, string? owner = null, int? pageSize = null, string? providedFor = null, string? subscriber = null, string? tenant = null, string? type = null, string? user = null, bool? withTotalElements = null, bool? withTotalPages = null)
public async Task<ApplicationCollection?> GetApplications(int? currentPage = null, string? name = null, string? owner = null, int? pageSize = null, string? providedFor = null, string? subscriber = null, string? tenant = null, string? type = null, string? user = null, bool? withTotalElements = null, bool? withTotalPages = null)
{
var client = HttpClient;
var resourcePath = $"/application/applications";
Expand All @@ -63,7 +63,7 @@ public ApplicationsApi(HttpClient httpClient) : base(httpClient)
{"withTotalPages", withTotalPages}
#pragma warning restore CS8604 // Possible null reference argument.
};
allQueryParameter.Where(p => p.Value != null).AsParallel().ForAll(e => queryString.Add(e.Key, $"{e.Value}"));
allQueryParameter.Where(p => p.Value != null).ToList().ForEach(e => queryString.Add(e.Key, $"{e.Value}"));
uriBuilder.Query = queryString.ToString();
var request = new HttpRequestMessage
{
Expand All @@ -78,7 +78,7 @@ public ApplicationsApi(HttpClient httpClient) : base(httpClient)
}

/// <inheritdoc />
public async Task<Application?> CreateApplication(Application body)
public async Task<Application?> CreateApplication(Application body)
{
var jsonNode = ToJsonNode<Application>(body);
jsonNode?.RemoveFromNode("owner");
Expand All @@ -104,7 +104,7 @@ public ApplicationsApi(HttpClient httpClient) : base(httpClient)
}

/// <inheritdoc />
public async Task<Application?> GetApplication(string id)
public async Task<Application?> GetApplication(string id)
{
var client = HttpClient;
var resourcePath = $"/application/applications/{id}";
Expand All @@ -122,7 +122,7 @@ public ApplicationsApi(HttpClient httpClient) : base(httpClient)
}

/// <inheritdoc />
public async Task<Application?> UpdateApplication(Application body, string id)
public async Task<Application?> UpdateApplication(Application body, string id)
{
var jsonNode = ToJsonNode<Application>(body);
jsonNode?.RemoveFromNode("owner");
Expand All @@ -149,7 +149,7 @@ public ApplicationsApi(HttpClient httpClient) : base(httpClient)
}

/// <inheritdoc />
public async Task<System.IO.Stream> DeleteApplication(string id, bool? force = null)
public async Task<System.IO.Stream> DeleteApplication(string id, bool? force = null)
{
var client = HttpClient;
var resourcePath = $"/application/applications/{id}";
Expand All @@ -161,7 +161,7 @@ public ApplicationsApi(HttpClient httpClient) : base(httpClient)
{"force", force}
#pragma warning restore CS8604 // Possible null reference argument.
};
allQueryParameter.Where(p => p.Value != null).AsParallel().ForAll(e => queryString.Add(e.Key, $"{e.Value}"));
allQueryParameter.Where(p => p.Value != null).ToList().ForEach(e => queryString.Add(e.Key, $"{e.Value}"));
uriBuilder.Query = queryString.ToString();
var request = new HttpRequestMessage
{
Expand All @@ -176,7 +176,7 @@ public ApplicationsApi(HttpClient httpClient) : base(httpClient)
}

/// <inheritdoc />
public async Task<Application?> CopyApplication(string id)
public async Task<Application?> CopyApplication(string id)
{
var client = HttpClient;
var resourcePath = $"/application/applications/{id}/clone";
Expand All @@ -194,7 +194,7 @@ public ApplicationsApi(HttpClient httpClient) : base(httpClient)
}

/// <inheritdoc />
public async Task<ApplicationCollection?> GetApplicationsByName(string name)
public async Task<ApplicationCollection?> GetApplicationsByName(string name)
{
var client = HttpClient;
var resourcePath = $"/application/applicationsByName/{name}";
Expand All @@ -212,7 +212,7 @@ public ApplicationsApi(HttpClient httpClient) : base(httpClient)
}

/// <inheritdoc />
public async Task<ApplicationCollection?> GetApplicationsByTenant(string tenantId)
public async Task<ApplicationCollection?> GetApplicationsByTenant(string tenantId)
{
var client = HttpClient;
var resourcePath = $"/application/applicationsByTenant/{tenantId}";
Expand All @@ -230,7 +230,7 @@ public ApplicationsApi(HttpClient httpClient) : base(httpClient)
}

/// <inheritdoc />
public async Task<ApplicationCollection?> GetApplicationsByOwner(string tenantId, int? currentPage = null, int? pageSize = null, bool? withTotalElements = null, bool? withTotalPages = null)
public async Task<ApplicationCollection?> GetApplicationsByOwner(string tenantId, int? currentPage = null, int? pageSize = null, bool? withTotalElements = null, bool? withTotalPages = null)
{
var client = HttpClient;
var resourcePath = $"/application/applicationsByOwner/{tenantId}";
Expand All @@ -245,7 +245,7 @@ public ApplicationsApi(HttpClient httpClient) : base(httpClient)
{"withTotalPages", withTotalPages}
#pragma warning restore CS8604 // Possible null reference argument.
};
allQueryParameter.Where(p => p.Value != null).AsParallel().ForAll(e => queryString.Add(e.Key, $"{e.Value}"));
allQueryParameter.Where(p => p.Value != null).ToList().ForEach(e => queryString.Add(e.Key, $"{e.Value}"));
uriBuilder.Query = queryString.ToString();
var request = new HttpRequestMessage
{
Expand All @@ -260,7 +260,7 @@ public ApplicationsApi(HttpClient httpClient) : base(httpClient)
}

/// <inheritdoc />
public async Task<ApplicationCollection?> GetApplicationsByUser(string username, int? currentPage = null, int? pageSize = null, bool? withTotalElements = null, bool? withTotalPages = null)
public async Task<ApplicationCollection?> GetApplicationsByUser(string username, int? currentPage = null, int? pageSize = null, bool? withTotalElements = null, bool? withTotalPages = null)
{
var client = HttpClient;
var resourcePath = $"/application/applicationsByUser/{username}";
Expand All @@ -275,7 +275,7 @@ public ApplicationsApi(HttpClient httpClient) : base(httpClient)
{"withTotalPages", withTotalPages}
#pragma warning restore CS8604 // Possible null reference argument.
};
allQueryParameter.Where(p => p.Value != null).AsParallel().ForAll(e => queryString.Add(e.Key, $"{e.Value}"));
allQueryParameter.Where(p => p.Value != null).ToList().ForEach(e => queryString.Add(e.Key, $"{e.Value}"));
uriBuilder.Query = queryString.ToString();
var request = new HttpRequestMessage
{
Expand Down
10 changes: 5 additions & 5 deletions Client/Com/Cumulocity/Client/Api/AttachmentsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public AttachmentsApi(HttpClient httpClient) : base(httpClient)
}

/// <inheritdoc />
public async Task<System.IO.Stream> GetEventAttachment(string id)
public async Task<System.IO.Stream> GetEventAttachment(string id)
{
var client = HttpClient;
var resourcePath = $"/event/events/{id}/binaries";
Expand All @@ -49,7 +49,7 @@ public AttachmentsApi(HttpClient httpClient) : base(httpClient)
}

/// <inheritdoc />
public async Task<EventBinary?> ReplaceEventAttachment(byte[] body, string id)
public async Task<EventBinary?> ReplaceEventAttachment(byte[] body, string id)
{
var client = HttpClient;
var resourcePath = $"/event/events/{id}/binaries";
Expand All @@ -69,7 +69,7 @@ public AttachmentsApi(HttpClient httpClient) : base(httpClient)
}

/// <inheritdoc />
public async Task<EventBinary?> UploadEventAttachment(byte[] body, string id)
public async Task<EventBinary?> UploadEventAttachment(byte[] body, string id)
{
var client = HttpClient;
var resourcePath = $"/event/events/{id}/binaries";
Expand All @@ -89,7 +89,7 @@ public AttachmentsApi(HttpClient httpClient) : base(httpClient)
}

/// <inheritdoc />
public async Task<EventBinary?> UploadEventAttachment(BinaryInfo pObject, byte[] file, string id)
public async Task<EventBinary?> UploadEventAttachment(BinaryInfo pObject, byte[] file, string id)
{
var client = HttpClient;
var resourcePath = $"/event/events/{id}/binaries";
Expand All @@ -116,7 +116,7 @@ public AttachmentsApi(HttpClient httpClient) : base(httpClient)
}

/// <inheritdoc />
public async Task<System.IO.Stream> DeleteEventAttachment(string id)
public async Task<System.IO.Stream> DeleteEventAttachment(string id)
{
var client = HttpClient;
var resourcePath = $"/event/events/{id}/binaries";
Expand Down
Loading