Skip to content

Commit

Permalink
Update to newly built .Net Client from GH Run 252 (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
joerghartmann authored Sep 20, 2023
1 parent fc85aec commit 0155dda
Show file tree
Hide file tree
Showing 28 changed files with 271 additions and 401 deletions.
8 changes: 4 additions & 4 deletions Client/Com/Cumulocity/Client/Api/AttachmentsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
namespace Client.Com.Cumulocity.Client.Api;

/// <summary>
/// It is possible to store, retrieve and delete binaries for events. Each event can have one binary attached. <br />
/// It is possible to store, retrieve and delete binaries for events. Each event can have only one binary attached. <br />
/// </summary>
///
public sealed class AttachmentsApi : IAttachmentsApi
Expand Down Expand Up @@ -63,7 +63,7 @@ public AttachmentsApi(HttpClient httpClient)
RequestUri = new Uri(uriBuilder.ToString())
};
request.Headers.TryAddWithoutValidation("Content-Type", "text/plain");
request.Headers.TryAddWithoutValidation("Accept", "application/vnd.com.nsn.cumulocity.error+json, application/vnd.com.nsn.cumulocity.event+json");
request.Headers.TryAddWithoutValidation("Accept", "application/vnd.com.nsn.cumulocity.error+json, application/json");
using var response = await _httpClient.SendAsync(request: request, cancellationToken: cToken).ConfigureAwait(false);
await response.EnsureSuccessStatusCodeWithContentInfo().ConfigureAwait(false);
await using var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
Expand All @@ -82,7 +82,7 @@ public AttachmentsApi(HttpClient httpClient)
RequestUri = new Uri(uriBuilder.ToString())
};
request.Headers.TryAddWithoutValidation("Content-Type", "text/plain");
request.Headers.TryAddWithoutValidation("Accept", "application/vnd.com.nsn.cumulocity.error+json, application/vnd.com.nsn.cumulocity.event+json");
request.Headers.TryAddWithoutValidation("Accept", "application/vnd.com.nsn.cumulocity.error+json, application/json");
using var response = await _httpClient.SendAsync(request: request, cancellationToken: cToken).ConfigureAwait(false);
await response.EnsureSuccessStatusCodeWithContentInfo().ConfigureAwait(false);
await using var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
Expand All @@ -108,7 +108,7 @@ public AttachmentsApi(HttpClient httpClient)
RequestUri = new Uri(uriBuilder.ToString())
};
request.Headers.TryAddWithoutValidation("Content-Type", "multipart/form-data");
request.Headers.TryAddWithoutValidation("Accept", "application/vnd.com.nsn.cumulocity.error+json, application/vnd.com.nsn.cumulocity.event+json");
request.Headers.TryAddWithoutValidation("Accept", "application/vnd.com.nsn.cumulocity.error+json, application/json");
using var response = await _httpClient.SendAsync(request: request, cancellationToken: cToken).ConfigureAwait(false);
await response.EnsureSuccessStatusCodeWithContentInfo().ConfigureAwait(false);
await using var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
Expand Down
2 changes: 1 addition & 1 deletion Client/Com/Cumulocity/Client/Api/BinariesApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Client.Com.Cumulocity.Client.Api;

/// <summary>
/// Managed objects can perform operations to store, retrieve and delete binaries. One binary can store only one file. Together with the binary, a managed object is created which acts as a metadata information for the binary. <br />
/// ⓘ Info: The Accept header should be provided in all POST/PUT requests, otherwise an empty response body will be returned. <br />
/// ⓘ Info: Supports only HTTP 1.1 clients.ⓘ Info: The Accept header should be provided in all POST/PUT requests, otherwise an empty response body will be returned. <br />
/// </summary>
///
public sealed class BinariesApi : IBinariesApi
Expand Down
1 change: 0 additions & 1 deletion Client/Com/Cumulocity/Client/Api/CurrentUserApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public CurrentUserApi(HttpClient httpClient)
jsonNode?.RemoveFromNode("id");
jsonNode?.RemoveFromNode("lastPasswordChange");
jsonNode?.RemoveFromNode("twoFactorAuthenticationEnabled");
jsonNode?.RemoveFromNode("devicePermissions");
const string resourcePath = "/user/currentUser";
var uriBuilder = new UriBuilder(new Uri(_httpClient.BaseAddress ?? new Uri(resourcePath), resourcePath));
using var request = new HttpRequestMessage
Expand Down
8 changes: 4 additions & 4 deletions Client/Com/Cumulocity/Client/Api/DevicePermissionsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public DevicePermissionsApi(HttpClient httpClient)
}

/// <inheritdoc />
public async Task<DevicePermissions<TCustomProperties>?> GetDevicePermissionAssignments<TCustomProperties>(string id, CancellationToken cToken = default) where TCustomProperties : CustomProperties
public async Task<DevicePermissionOwners<TCustomProperties>?> GetDevicePermissionAssignments<TCustomProperties>(string id, CancellationToken cToken = default) where TCustomProperties : CustomProperties
{
string resourcePath = $"/user/devicePermissions/{HttpUtility.UrlEncode(id.GetStringValue())}";
var uriBuilder = new UriBuilder(new Uri(_httpClient.BaseAddress ?? new Uri(resourcePath), resourcePath));
Expand All @@ -77,13 +77,13 @@ public DevicePermissionsApi(HttpClient httpClient)
using var response = await _httpClient.SendAsync(request: request, cancellationToken: cToken).ConfigureAwait(false);
await response.EnsureSuccessStatusCodeWithContentInfo().ConfigureAwait(false);
await using var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
return await JsonSerializerWrapper.DeserializeAsync<DevicePermissions<TCustomProperties>?>(responseStream, cancellationToken: cToken).ConfigureAwait(false);;
return await JsonSerializerWrapper.DeserializeAsync<DevicePermissionOwners<TCustomProperties>?>(responseStream, cancellationToken: cToken).ConfigureAwait(false);;
}

/// <inheritdoc />
public async Task<string?> UpdateDevicePermissionAssignments<TCustomProperties>(DevicePermissions<TCustomProperties> body, string id, CancellationToken cToken = default) where TCustomProperties : CustomProperties
public async Task<string?> UpdateDevicePermissionAssignments(UpdatedDevicePermissions body, string id, CancellationToken cToken = default)
{
var jsonNode = body.ToJsonNode<DevicePermissions<TCustomProperties>>();
var jsonNode = body.ToJsonNode<UpdatedDevicePermissions>();
string resourcePath = $"/user/devicePermissions/{HttpUtility.UrlEncode(id.GetStringValue())}";
var uriBuilder = new UriBuilder(new Uri(_httpClient.BaseAddress ?? new Uri(resourcePath), resourcePath));
using var request = new HttpRequestMessage
Expand Down
2 changes: 1 addition & 1 deletion Client/Com/Cumulocity/Client/Api/IAlarmsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public interface IAlarmsApi
/// <summary>
/// Remove alarm collections <br />
/// Remove alarm collections specified by query parameters. <br />
/// ⚠️ Important: DELETE requires at least one of the following parameters: <c>source</c>, <c>dateFrom</c>, <c>dateTo</c>, <c>createdFrom</c>, <c>createdTo</c>.Also note that DELETE requests are not synchronous. The response could be returned before the delete request has been completed. <br />
/// ⚠️ Important: Note that it is possible to call this endpoint without providing any parameter - it will result in deleting all alarms and it is not recommended.Also note that DELETE requests are not synchronous. The response could be returned before the delete request has been completed. <br />
///
/// <br /> Required roles <br />
/// ROLE_ALARM_ADMIN
Expand Down
18 changes: 9 additions & 9 deletions Client/Com/Cumulocity/Client/Api/IAttachmentsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace Client.Com.Cumulocity.Client.Api;

/// <summary>
/// It is possible to store, retrieve and delete binaries for events. Each event can have one binary attached. <br />
/// It is possible to store, retrieve and delete binaries for events. Each event can have only one binary attached. <br />
/// </summary>
///
public interface IAttachmentsApi
Expand Down Expand Up @@ -83,17 +83,17 @@ public interface IAttachmentsApi

/// <summary>
/// Attach a file to a specific event <br />
/// Upload a file (binary) as an attachment of a specific event by a given ID.<br />
/// The size of the attachment is configurable, and the default size is 50 MiB. The default chunk size is 5MiB. <br />
/// After the file has been uploaded, the corresponding event will contain the fragment <c>c8y_IsBinary</c> similar to: <br />
/// Upload a file (binary) as an attachment of a specific event by a given ID.The size of the attachment is configurable, and the default size is 50 MiB. The default chunk size is 5MiB. <br />
/// ⓘ Info: If there is a binary already attached to the event, the POST request results in a 409 error. <br />
/// When the file has been uploaded, the corresponding event contains the fragment <c>c8y_IsBinary</c> similar to: <br />
/// <![CDATA[
/// "c8y_IsBinary": {
/// "name": "hello.txt",
/// "length": 365,
/// "type": "text/plain"
/// }
/// ]]>
/// When using <c>multipart/form-data</c> each value is sent as a block of data (body part), with a user agent-defined delimiter (<c>boundary</c>) separating each part. The keys are given in the <c>Content-Disposition</c> header of each part. <br />
/// There are two request body schemas you can use for your POST requests.<c>text/plain</c> is preselected (see below).If you set it to <c>multipart/form-data</c> each value is sent as a block of data (body part), with a user agent-defined delimiter (<c>boundary</c>) separating each part.The keys are given in the <c>Content-Disposition</c> header of each part. <br />
/// <![CDATA[
/// POST /event/events/{id}/binaries
/// Host: https://<TENANT_DOMAIN>
Expand Down Expand Up @@ -145,17 +145,17 @@ public interface IAttachmentsApi

/// <summary>
/// Attach a file to a specific event <br />
/// Upload a file (binary) as an attachment of a specific event by a given ID.<br />
/// The size of the attachment is configurable, and the default size is 50 MiB. The default chunk size is 5MiB. <br />
/// After the file has been uploaded, the corresponding event will contain the fragment <c>c8y_IsBinary</c> similar to: <br />
/// Upload a file (binary) as an attachment of a specific event by a given ID.The size of the attachment is configurable, and the default size is 50 MiB. The default chunk size is 5MiB. <br />
/// ⓘ Info: If there is a binary already attached to the event, the POST request results in a 409 error. <br />
/// When the file has been uploaded, the corresponding event contains the fragment <c>c8y_IsBinary</c> similar to: <br />
/// <![CDATA[
/// "c8y_IsBinary": {
/// "name": "hello.txt",
/// "length": 365,
/// "type": "text/plain"
/// }
/// ]]>
/// When using <c>multipart/form-data</c> each value is sent as a block of data (body part), with a user agent-defined delimiter (<c>boundary</c>) separating each part. The keys are given in the <c>Content-Disposition</c> header of each part. <br />
/// There are two request body schemas you can use for your POST requests.<c>text/plain</c> is preselected (see below).If you set it to <c>multipart/form-data</c> each value is sent as a block of data (body part), with a user agent-defined delimiter (<c>boundary</c>) separating each part.The keys are given in the <c>Content-Disposition</c> header of each part. <br />
/// <![CDATA[
/// POST /event/events/{id}/binaries
/// Host: https://<TENANT_DOMAIN>
Expand Down
2 changes: 1 addition & 1 deletion Client/Com/Cumulocity/Client/Api/IBinariesApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Client.Com.Cumulocity.Client.Api;

/// <summary>
/// Managed objects can perform operations to store, retrieve and delete binaries. One binary can store only one file. Together with the binary, a managed object is created which acts as a metadata information for the binary. <br />
/// ⓘ Info: The Accept header should be provided in all POST/PUT requests, otherwise an empty response body will be returned. <br />
/// ⓘ Info: Supports only HTTP 1.1 clients.ⓘ Info: The Accept header should be provided in all POST/PUT requests, otherwise an empty response body will be returned. <br />
/// </summary>
///
public interface IBinariesApi
Expand Down
4 changes: 2 additions & 2 deletions Client/Com/Cumulocity/Client/Api/IDevicePermissionsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public interface IDevicePermissionsApi
/// <param name="id">Unique identifier of the managed object. <br /></param>
/// <param name="cToken">Propagates notification that operations should be canceled. <br /></param>
///
Task<DevicePermissions<TCustomProperties>?> GetDevicePermissionAssignments<TCustomProperties>(string id, CancellationToken cToken = default) where TCustomProperties : CustomProperties;
Task<DevicePermissionOwners<TCustomProperties>?> GetDevicePermissionAssignments<TCustomProperties>(string id, CancellationToken cToken = default) where TCustomProperties : CustomProperties;

/// <summary>
/// Updates the device permissions assignments <br />
Expand Down Expand Up @@ -107,5 +107,5 @@ public interface IDevicePermissionsApi
/// <param name="id">Unique identifier of the managed object. <br /></param>
/// <param name="cToken">Propagates notification that operations should be canceled. <br /></param>
///
Task<string?> UpdateDevicePermissionAssignments<TCustomProperties>(DevicePermissions<TCustomProperties> body, string id, CancellationToken cToken = default) where TCustomProperties : CustomProperties;
Task<string?> UpdateDevicePermissionAssignments(UpdatedDevicePermissions body, string id, CancellationToken cToken = default) ;
}
2 changes: 1 addition & 1 deletion Client/Com/Cumulocity/Client/Api/IEventsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public interface IEventsApi
/// Remove event collections <br />
/// Remove event collections specified by query parameters. <br />
/// DELETE requests are not synchronous. The response could be returned before the delete request has been completed. This may happen especially when the deleted event has a lot of associated data. After sending the request, the platform starts deleting the associated data in an asynchronous way. Finally, the requested event is deleted after all associated data has been deleted. <br />
/// ⚠️ Important: DELETE requires at least one of the following parameters: <c>source</c>, <c>dateFrom</c>, <c>dateTo</c>, <c>createdFrom</c>, <c>createdTo</c>. <br />
/// ⚠️ Important: Note that it is possible to call this endpoint without providing any parameter - it will result in deleting all events and it is not recommended. <br />
///
/// <br /> Required roles <br />
/// ROLE_EVENT_ADMIN
Expand Down
33 changes: 1 addition & 32 deletions Client/Com/Cumulocity/Client/Api/IManagedObjectsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,38 +125,6 @@ public interface IManagedObjectsApi
///
Task<TManagedObject?> CreateManagedObject<TManagedObject>(TManagedObject body, string? xCumulocityProcessingMode = null, CancellationToken cToken = default) where TManagedObject : ManagedObject;

/// <summary>
/// Retrieve the total number of managed objects <br />
/// Retrieve the total number of managed objects (for example, devices, assets, etc.) registered in your tenant, or a subset based on queries. <br />
///
/// <br /> Required roles <br />
/// ROLE_INVENTORY_READ is not required, but if the current user doesn't have this role, the response will contain the number of inventory objects accessible for the user.
///
/// <br /> Response Codes <br />
/// The following table gives an overview of the possible response codes and their meanings: <br />
/// <list type="bullet">
/// <item>
/// <description>HTTP 200 The request has succeeded and the number of managed objects is sent in the response. <br /> <br />
/// </description>
/// </item>
/// <item>
/// <description>HTTP 401 Authentication information is missing or invalid. <br /> <br />
/// </description>
/// </item>
/// </list>
/// </summary>
/// <param name="cToken">Propagates notification that operations should be canceled. <br /></param>
/// <param name="childAdditionId">Search for a specific child addition and list all the groups to which it belongs. <br /></param>
/// <param name="childAssetId">Search for a specific child asset and list all the groups to which it belongs. <br /></param>
/// <param name="childDeviceId">Search for a specific child device and list all the groups to which it belongs. <br /></param>
/// <param name="fragmentType">A characteristic which identifies a managed object or event, for example, geolocation, electricity sensor, relay state. <br /></param>
/// <param name="ids">The managed object IDs to search for. <br />ⓘ Info: If you query for multiple IDs at once, comma-separate the values. <br /></param>
/// <param name="owner">Username of the owner of the managed objects. <br /></param>
/// <param name="text">Search for managed objects where any property value is equal to the given one. Only string values are supported. <br /></param>
/// <param name="type">The type of managed object to search for. <br /></param>
///
Task<int> GetNumberOfManagedObjects(string? childAdditionId = null, string? childAssetId = null, string? childDeviceId = null, string? fragmentType = null, List<string>? ids = null, string? owner = null, string? text = null, string? type = null, CancellationToken cToken = default) ;

/// <summary>
/// Retrieve a specific managed object <br />
/// Retrieve a specific managed object (for example, device, group, template) by a given ID. <br />
Expand Down Expand Up @@ -227,6 +195,7 @@ public interface IManagedObjectsApi
/// Remove a specific managed object <br />
/// Remove a specific managed object (for example, device) by a given ID. <br />
/// ⓘ Info: Inventory DELETE requests are not synchronous. The response could be returned before the delete request has been completed. This may happen especially when the deleted managed object has a lot of associated data. After sending the request, the platform starts deleting the associated data in an asynchronous way. Finally, the requested managed object is deleted after all associated data has been deleted. <br />
/// ⓘ Info: By default, the delete operation is always propagated to the subgroups, but only if the deleted object is a group. <br />
///
/// <br /> Required roles <br />
/// ROLE_INVENTORY_ADMIN OR owner of the source OR MANAGE_OBJECT_ADMIN permission on the source
Expand Down
2 changes: 1 addition & 1 deletion Client/Com/Cumulocity/Client/Api/IMeasurementsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public interface IMeasurementsApi
/// Remove measurement collections <br />
/// Remove measurement collections specified by query parameters. <br />
/// DELETE requests are not synchronous. The response could be returned before the delete request has been completed. This may happen especially when there are a lot of measurements to be deleted. <br />
/// ⚠️ Important: DELETE requires at least one of the following parameters: <c>source</c>, <c>dateFrom</c>, <c>dateTo</c>. <br />
/// ⚠️ Important: Note that it is possible to call this endpoint without providing any parameter - it may result in deleting all measurements and it is not recommended. <br />
/// In case of enhanced time series measurements, both <c>dateFrom</c> and <c>dateTo</c> parameters must be truncated to full hours (for example, 2022-08-19T14:00:00.000Z), otherwise an error will be returned.The <c>fragmentType</c> parameter allows to delete measurements only by a measurement fragment when enhanced time series measurements are used.It's not possible to delete by a custom (non-measurement) fragment. <br />
/// Example for a valid measurement value fragment: <br />
/// <![CDATA[
Expand Down
Loading

0 comments on commit 0155dda

Please sign in to comment.