Skip to content

Commit

Permalink
Features/automatic update (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
joerghartmann authored Sep 27, 2024
1 parent 383ed42 commit 0ba3a7c
Show file tree
Hide file tree
Showing 77 changed files with 1,823 additions and 303 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Those classes allow to add an arbitrary number of additional properties as a lis
C8yAlarm.registerAdditionalProperty<C: Codable>(typeName: String, for type: C.Type)
```

Each of the extensible objects contains a dictionary object holding instances of custom fragments. Use the custom fragment's key to access it's value.
Each of the extensible objects contains a dictionary object holding instances of custom fragments. Use the custom fragment's key to access its value.

### Working with errors

Expand Down
18 changes: 9 additions & 9 deletions Sources/CumulocityCoreLibrary/Api/AlarmsApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ public class AlarmsApi: AdaptableApi {
/// - pageSize:
/// Indicates how many entries of the collection shall be returned. The upper limit for one page is 2,000 objects.
/// - resolved:
/// When set to `true` only alarms with status CLEARED will be fetched, whereas `false` will fetch all alarms with status ACTIVE or ACKNOWLEDGED.
/// When set to `true` only alarms with status CLEARED will be fetched, whereas `false` will fetch all alarms with status ACTIVE or ACKNOWLEDGED. Takes precedence over the `status` parameter.
/// - severity:
/// The severity of the alarm to search for.
///
/// **ⓘ Note** If you query for multiple alarm severities at once, comma-separate the values.
/// - source:
/// The managed object ID to which the alarm is associated.
/// - status:
/// The status of the alarm to search for.
/// The status of the alarm to search for. Should not be used when `resolved` parameter is provided.
///
/// **ⓘ Note** If you query for multiple alarm statuses at once, comma-separate the values.
/// - type:
Expand Down Expand Up @@ -142,15 +142,15 @@ public class AlarmsApi: AdaptableApi {
/// - dateTo:
/// End date or date and time of the alarm occurrence.
/// - resolved:
/// When set to `true` only alarms with status CLEARED will be fetched, whereas `false` will fetch all alarms with status ACTIVE or ACKNOWLEDGED.
/// When set to `true` only alarms with status CLEARED will be fetched, whereas `false` will fetch all alarms with status ACTIVE or ACKNOWLEDGED. Takes precedence over the `status` parameter.
/// - severity:
/// The severity of the alarm to search for.
///
/// **ⓘ Note** If you query for multiple alarm severities at once, comma-separate the values.
/// - source:
/// The managed object ID to which the alarm is associated.
/// - status:
/// The status of the alarm to search for.
/// The status of the alarm to search for. Should not be used when `resolved` parameter is provided.
///
/// **ⓘ Note** If you query for multiple alarm statuses at once, comma-separate the values.
/// - withSourceAssets:
Expand Down Expand Up @@ -285,7 +285,7 @@ public class AlarmsApi: AdaptableApi {
///
/// Remove alarm collections specified by query parameters.
///
/// > **⚠️ 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.
/// > **⚠️ Important:** DELETE requires at least one of the following parameters: `source`, `dateFrom`, `dateTo`, `createdFrom`, `createdTo`.Also note that DELETE requests are not synchronous. The response could be returned before the delete request has been completed.
///
/// > Tip: Required roles
/// ROLE_ALARM_ADMIN
Expand All @@ -309,15 +309,15 @@ public class AlarmsApi: AdaptableApi {
/// - dateTo:
/// End date or date and time of the alarm occurrence.
/// - resolved:
/// When set to `true` only alarms with status CLEARED will be fetched, whereas `false` will fetch all alarms with status ACTIVE or ACKNOWLEDGED.
/// When set to `true` only alarms with status CLEARED will be fetched, whereas `false` will fetch all alarms with status ACTIVE or ACKNOWLEDGED. Takes precedence over the `status` parameter.
/// - severity:
/// The severity of the alarm to search for.
///
/// **ⓘ Note** If you query for multiple alarm severities at once, comma-separate the values.
/// - source:
/// The managed object ID to which the alarm is associated.
/// - status:
/// The status of the alarm to search for.
/// The status of the alarm to search for. Should not be used when `resolved` parameter is provided.
///
/// **ⓘ Note** If you query for multiple alarm statuses at once, comma-separate the values.
/// - type:
Expand Down Expand Up @@ -483,15 +483,15 @@ public class AlarmsApi: AdaptableApi {
/// - dateTo:
/// End date or date and time of the alarm occurrence.
/// - resolved:
/// When set to `true` only alarms with status CLEARED will be fetched, whereas `false` will fetch all alarms with status ACTIVE or ACKNOWLEDGED.
/// When set to `true` only alarms with status CLEARED will be fetched, whereas `false` will fetch all alarms with status ACTIVE or ACKNOWLEDGED. Takes precedence over the `status` parameter.
/// - severity:
/// The severity of the alarm to search for.
///
/// **ⓘ Note** If you query for multiple alarm severities at once, comma-separate the values.
/// - source:
/// The managed object ID to which the alarm is associated.
/// - status:
/// The status of the alarm to search for.
/// The status of the alarm to search for. Should not be used when `resolved` parameter is provided.
///
/// **ⓘ Note** If you query for multiple alarm statuses at once, comma-separate the values.
/// - type:
Expand Down
16 changes: 12 additions & 4 deletions Sources/CumulocityCoreLibrary/Api/ApplicationsApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Combine
///
/// For each tenant, Cumulocity IoT manages the subscribed applications and provides a number of applications of various types.In case you want to subscribe a tenant to an application using an API, you must use the application name in the argument (as name).
///
/// Refer to the tables in [Administration > Managing applications](https://cumulocity.com/guides/10.7.0/users-guide/administration#managing-applications) in the User guide for the respective application name to be used.
/// Refer to the tables in [Platform administration > Standard tenant administration > Managing the ecosystem > Managing applications](https://cumulocity.com/docs/standard-tenant/ecosystem/#managing-applications) in the Cumulocity IoT user documentation for the respective application name to be used.
///
/// > **ⓘ Note** The Accept header should be provided in all POST/PUT requests, otherwise an empty response body will be returned.
public class ApplicationsApi: AdaptableApi {
Expand Down Expand Up @@ -263,10 +263,10 @@ public class ApplicationsApi: AdaptableApi {
/// - Parameters:
/// - id:
/// Unique identifier of the application.
/// - force:
/// Force deletion by unsubscribing all tenants from the application first and then deleting the application itself.
/// - xCumulocityProcessingMode:
/// Used to explicitly control the processing mode of the request. See [Processing mode](#processing-mode) for more details.
/// - force:
/// Force deletion by unsubscribing all tenants from the application first and then deleting the application itself.
public func deleteApplication(id: String, force: Bool? = nil, xCumulocityProcessingMode: String? = nil) -> AnyPublisher<Data, Error> {
let builder = URLRequestBuilder()
.set(resourcePath: "/application/applications/\(id)")
Expand Down Expand Up @@ -301,6 +301,8 @@ public class ApplicationsApi: AdaptableApi {
///
/// If the target application is hosted and has an active version, the new application will have the active version with the same content.
///
/// If the original application is hosted with versions, then only one binary version is cloned. By default it is a version with the "latest" tag. You can also specify a target version directly by using exactly one of the query parameters `version` or `tag`.
///
///
/// > Tip: Required roles
/// ROLE_APPLICATION_MANAGEMENT_ADMIN
Expand All @@ -317,12 +319,18 @@ public class ApplicationsApi: AdaptableApi {
/// Unique identifier of the application.
/// - xCumulocityProcessingMode:
/// Used to explicitly control the processing mode of the request. See [Processing mode](#processing-mode) for more details.
public func copyApplication(id: String, xCumulocityProcessingMode: String? = nil) -> AnyPublisher<C8yApplication, Error> {
/// - version:
/// The version field of the application version.
/// - tag:
/// The tag of the application version.
public func copyApplication(id: String, version: String? = nil, tag: String? = nil, xCumulocityProcessingMode: String? = nil) -> AnyPublisher<C8yApplication, Error> {
let builder = URLRequestBuilder()
.set(resourcePath: "/application/applications/\(id)/clone")
.set(httpMethod: "post")
.add(header: "X-Cumulocity-Processing-Mode", value: xCumulocityProcessingMode)
.add(header: "Accept", value: "application/vnd.com.nsn.cumulocity.error+json, application/vnd.com.nsn.cumulocity.application+json")
.add(queryItem: "version", value: version)
.add(queryItem: "tag", value: tag)
return self.session.dataTaskPublisher(for: adapt(builder: builder).build()).tryMap({ element -> Data in
guard let httpResponse = element.response as? HTTPURLResponse else {
throw URLError(.badServerResponse)
Expand Down
24 changes: 12 additions & 12 deletions Sources/CumulocityCoreLibrary/Api/AttachmentsApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation
import Combine

/// It is possible to store, retrieve and delete binaries for events. Each event can have one binary attached.
/// It is possible to store, retrieve and delete binaries for events. Each event can have only one binary attached.
public class AttachmentsApi: AdaptableApi {

/// Retrieve the attached file of a specific event
Expand Down Expand Up @@ -76,7 +76,7 @@ public class AttachmentsApi: AdaptableApi {
.set(resourcePath: "/event/events/\(id)/binaries")
.set(httpMethod: "put")
.add(header: "Content-Type", value: "text/plain")
.add(header: "Accept", value: "application/vnd.com.nsn.cumulocity.error+json, application/vnd.com.nsn.cumulocity.event+json")
.add(header: "Accept", value: "application/vnd.com.nsn.cumulocity.error+json, application/json")
.set(httpBody: body)
return self.session.dataTaskPublisher(for: adapt(builder: builder).build()).tryMap({ element -> Data in
guard let httpResponse = element.response as? HTTPURLResponse else {
Expand All @@ -95,10 +95,10 @@ public class AttachmentsApi: AdaptableApi {

/// Attach a file to a specific event
///
/// 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.
/// 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.
///
/// After the file has been uploaded, the corresponding event will contain the fragment `c8y_IsBinary` similar to:
/// > **ⓘ Note** If there is a binary already attached to the event, the POST request results in a 409 error.
/// When the file has been uploaded, the corresponding event contains the fragment `c8y_IsBinary` similar to:
///
/// ```json
/// "c8y_IsBinary": {
Expand All @@ -107,7 +107,7 @@ public class AttachmentsApi: AdaptableApi {
/// "type": "text/plain"
/// }
/// ```
/// When using `multipart/form-data` each value is sent as a block of data (body part), with a user agent-defined delimiter (`boundary`) separating each part. The keys are given in the `Content-Disposition` header of each part.
/// There are two request body schemas you can use for your POST requests.`text/plain` is preselected (see below).If you set it to `multipart/form-data` each value is sent as a block of data (body part), with a user agent-defined delimiter (`boundary`) separating each part.The keys are given in the `Content-Disposition` header of each part.
///
/// ```http
/// POST /event/events/{id}/binaries
Expand Down Expand Up @@ -149,7 +149,7 @@ public class AttachmentsApi: AdaptableApi {
.set(resourcePath: "/event/events/\(id)/binaries")
.set(httpMethod: "post")
.add(header: "Content-Type", value: "text/plain")
.add(header: "Accept", value: "application/vnd.com.nsn.cumulocity.error+json, application/vnd.com.nsn.cumulocity.event+json")
.add(header: "Accept", value: "application/vnd.com.nsn.cumulocity.error+json, application/json")
.set(httpBody: body)
return self.session.dataTaskPublisher(for: adapt(builder: builder).build()).tryMap({ element -> Data in
guard let httpResponse = element.response as? HTTPURLResponse else {
Expand All @@ -168,10 +168,10 @@ public class AttachmentsApi: AdaptableApi {

/// Attach a file to a specific event
///
/// 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.
/// 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.
///
/// After the file has been uploaded, the corresponding event will contain the fragment `c8y_IsBinary` similar to:
/// > **ⓘ Note** If there is a binary already attached to the event, the POST request results in a 409 error.
/// When the file has been uploaded, the corresponding event contains the fragment `c8y_IsBinary` similar to:
///
/// ```json
/// "c8y_IsBinary": {
Expand All @@ -180,7 +180,7 @@ public class AttachmentsApi: AdaptableApi {
/// "type": "text/plain"
/// }
/// ```
/// When using `multipart/form-data` each value is sent as a block of data (body part), with a user agent-defined delimiter (`boundary`) separating each part. The keys are given in the `Content-Disposition` header of each part.
/// There are two request body schemas you can use for your POST requests.`text/plain` is preselected (see below).If you set it to `multipart/form-data` each value is sent as a block of data (body part), with a user agent-defined delimiter (`boundary`) separating each part.The keys are given in the `Content-Disposition` header of each part.
///
/// ```http
/// POST /event/events/{id}/binaries
Expand Down Expand Up @@ -235,7 +235,7 @@ public class AttachmentsApi: AdaptableApi {
.set(resourcePath: "/event/events/\(id)/binaries")
.set(httpMethod: "post")
.add(header: "Content-Type", value: "multipart/form-data")
.add(header: "Accept", value: "application/vnd.com.nsn.cumulocity.error+json, application/vnd.com.nsn.cumulocity.event+json")
.add(header: "Accept", value: "application/vnd.com.nsn.cumulocity.error+json, application/json")
.add(header: "Content-Type", value: multipartBuilder.contentType)
.set(httpBody: multipartBuilder.build())
return self.session.dataTaskPublisher(for: adapt(builder: builder).build()).tryMap({ element -> Data in
Expand Down
4 changes: 2 additions & 2 deletions Sources/CumulocityCoreLibrary/Api/AuditsApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public class AuditsApi: AdaptableApi {
/// - currentPage:
/// The current page of the paginated results.
/// - dateFrom:
/// Start date or date and time of the audit record.
/// Start date or date and time of the audit record (device time).
/// - dateTo:
/// End date or date and time of the audit record.
/// End date or date and time of the audit record (device time).
/// - pageSize:
/// Indicates how many entries of the collection shall be returned. The upper limit for one page is 2,000 objects.
/// - source:
Expand Down
18 changes: 9 additions & 9 deletions Sources/CumulocityCoreLibrary/Api/BinariesApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import Combine

/// 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.
///
/// > **ⓘ Note** The Accept header should be provided in all POST/PUT requests, otherwise an empty response body will be returned.
/// > **ⓘ Note** Supports only HTTP 1.1 clients.**ⓘ Note** The Accept header should be provided in all POST/PUT requests, otherwise an empty response body will be returned.
public class BinariesApi: AdaptableApi {

/// Retrieve the stored files
/// Search for stored files
///
/// Retrieve the stored files as a collections of managed objects.
/// Retrieve metadata information about stored files. Search for files by query parameters. This will not download the files.
///
/// > Tip: Response Codes
/// The following table gives an overview of the possible response codes and their meanings:
Expand All @@ -42,7 +42,7 @@ public class BinariesApi: AdaptableApi {
/// - pageSize:
/// Indicates how many entries of the collection shall be returned. The upper limit for one page is 2,000 objects.
/// - text:
/// Search for managed objects where any property value is equal to the given one. Only string values are supported.
/// Search for managed objects where a property value is equal to the given one.The following properties are examined: `id, type, name, owner, externalIds`.
/// - type:
/// The type of managed object to search for.
/// - withTotalPages:
Expand Down Expand Up @@ -88,7 +88,7 @@ public class BinariesApi: AdaptableApi {
///
///
/// > Tip: Required roles
/// ROLE_INVENTORY_ADMIN *OR* ROLE_INVENTORY_CREATE
/// ROLE_INVENTORY_ADMIN *OR* ROLE_INVENTORY_CREATE *OR* ROLE_BINARY_ADMIN *OR* ROLE_BINARY_CREATE
///
/// > Tip: Response Codes
/// The following table gives an overview of the possible response codes and their meanings:
Expand Down Expand Up @@ -139,11 +139,11 @@ public class BinariesApi: AdaptableApi {

/// Retrieve a stored file
///
/// Retrieve a stored file (managed object) by a given ID.
/// Retrieve a stored file (managed object) by a given ID.Supports chunk download and resuming an interrupted download using the [`Range` header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range).
///
///
/// > Tip: Required roles
/// ROLE_INVENTORY_READ *OR* owner of the resource *OR* MANAGE_OBJECT_READ permission on the resource
/// ROLE_INVENTORY_READ *OR* ROLE_BINARY_READ *OR* owner of the resource *OR* MANAGE_OBJECT_READ permission on the resource
///
/// > Tip: Response Codes
/// The following table gives an overview of the possible response codes and their meanings:
Expand Down Expand Up @@ -180,7 +180,7 @@ public class BinariesApi: AdaptableApi {
///
///
/// > Tip: Required roles
/// ROLE_INVENTORY_ADMIN *OR* owner of the resource *OR* MANAGE_OBJECT_ADMIN permission on the resource
/// ROLE_INVENTORY_ADMIN *OR* ROLE_BINARY_ADMIN *OR* owner of the resource *OR* MANAGE_OBJECT_ADMIN permission on the resource
///
/// > Tip: Response Codes
/// The following table gives an overview of the possible response codes and their meanings:
Expand Down Expand Up @@ -221,7 +221,7 @@ public class BinariesApi: AdaptableApi {
///
///
/// > Tip: Required roles
/// ROLE_INVENTORY_ADMIN *OR* owner of the resource *OR* MANAGE_OBJECT_ADMIN permission on the resource
/// ROLE_INVENTORY_ADMIN *OR* ROLE_BINARY_ADMIN *OR* owner of the resource *OR* MANAGE_OBJECT_ADMIN permission on the resource
///
/// > Tip: Response Codes
/// The following table gives an overview of the possible response codes and their meanings:
Expand Down
Loading

0 comments on commit 0ba3a7c

Please sign in to comment.