Skip to content

Commit

Permalink
Fixed an issue causing paths to be wrongly concatenated. Also fixed R…
Browse files Browse the repository at this point in the history
…EADME.
  • Loading branch information
joerghartmann authored Feb 14, 2023
1 parent 279000e commit fd6203c
Show file tree
Hide file tree
Showing 31 changed files with 140 additions and 140 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Error handling can be simplified by calling the following extension method:
```swift
sink(receiveCompletion: { completion in
/// access the error message
let error = completion.error()
let error = try? completion.error()
/// access HTTP response
error?.httpResponse
/// access HTTP status code via the HttpResponse
Expand Down
4 changes: 2 additions & 2 deletions Sources/CumulocityCoreLibrary/Api/AlarmsApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ public class AlarmsApi: AdaptableApi {
/// Unique identifier of the alarm.
public func getAlarm(id: String) -> AnyPublisher<C8yAlarm, Error> {
let builder = URLRequestBuilder()
.set(resourcePath: "/alarm/alarms\\(id)")
.set(resourcePath: "/alarm/alarms/\(id)")
.set(httpMethod: "get")
.add(header: "Accept", value: "application/vnd.com.nsn.cumulocity.error+json, application/vnd.com.nsn.cumulocity.alarm+json")
return self.session.dataTaskPublisher(for: adapt(builder: builder).build()).tryMap({ element -> Data in
Expand Down Expand Up @@ -441,7 +441,7 @@ public class AlarmsApi: AdaptableApi {
return Fail<C8yAlarm, Error>(error: error).eraseToAnyPublisher()
}
let builder = URLRequestBuilder()
.set(resourcePath: "/alarm/alarms\\(id)")
.set(resourcePath: "/alarm/alarms/\(id)")
.set(httpMethod: "put")
.add(header: "X-Cumulocity-Processing-Mode", value: xCumulocityProcessingMode)
.add(header: "Content-Type", value: "application/vnd.com.nsn.cumulocity.alarm+json")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class ApplicationBinariesApi: AdaptableApi {
/// Unique identifier of the application.
public func getApplicationAttachments(id: String) -> AnyPublisher<C8yApplicationBinaries, Error> {
let builder = URLRequestBuilder()
.set(resourcePath: "/application/applications\\(id)/binaries")
.set(resourcePath: "/application/applications/\(id)/binaries")
.set(httpMethod: "get")
.add(header: "Accept", value: "application/vnd.com.nsn.cumulocity.applicationbinaries+json, application/vnd.com.nsn.cumulocity.error+json")
return self.session.dataTaskPublisher(for: adapt(builder: builder).build()).tryMap({ element -> Data in
Expand Down Expand Up @@ -82,7 +82,7 @@ public class ApplicationBinariesApi: AdaptableApi {
let multipartBuilder = MultipartFormDataBuilder()
multipartBuilder.addBodyPart(named: "file", data: file, mimeType: "application/zip");
let builder = URLRequestBuilder()
.set(resourcePath: "/application/applications\\(id)/binaries")
.set(resourcePath: "/application/applications/\(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.application+json")
Expand Down Expand Up @@ -124,7 +124,7 @@ public class ApplicationBinariesApi: AdaptableApi {
/// Unique identifier of the binary.
public func getApplicationAttachment(id: String, binaryId: String) -> AnyPublisher<Data, Error> {
let builder = URLRequestBuilder()
.set(resourcePath: "/application/applications\\(id)/binaries\\(binaryId)")
.set(resourcePath: "/application/applications/\(id)/binaries/\(binaryId)")
.set(httpMethod: "get")
.add(header: "Accept", value: "application/vnd.com.nsn.cumulocity.error+json, application/zip")
return self.session.dataTaskPublisher(for: adapt(builder: builder).build()).tryMap({ element -> Data in
Expand Down Expand Up @@ -165,7 +165,7 @@ public class ApplicationBinariesApi: AdaptableApi {
/// Unique identifier of the binary.
public func deleteApplicationAttachment(id: String, binaryId: String) -> AnyPublisher<Data, Error> {
let builder = URLRequestBuilder()
.set(resourcePath: "/application/applications\\(id)/binaries\\(binaryId)")
.set(resourcePath: "/application/applications/\(id)/binaries/\(binaryId)")
.set(httpMethod: "delete")
.add(header: "Accept", value: "application/json")
return self.session.dataTaskPublisher(for: adapt(builder: builder).build()).tryMap({ element -> Data in
Expand Down
10 changes: 5 additions & 5 deletions Sources/CumulocityCoreLibrary/Api/ApplicationVersionsApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class ApplicationVersionsApi: AdaptableApi {
/// The tag of the application version.
public func getApplicationVersion(id: String, version: String? = nil, tag: String? = nil) -> AnyPublisher<C8yApplicationVersion, Error> {
let builder = URLRequestBuilder()
.set(resourcePath: "/application/applications\\(id)/versions?version=1.0")
.set(resourcePath: "/application/applications/\(id)/versions?version=1.0")
.set(httpMethod: "get")
.add(header: "Accept", value: "application/vnd.com.nsn.cumulocity.error+json, application/vnd.com.nsn.cumulocity.applicationVersion+json")
.add(queryItem: "version", value: version)
Expand Down Expand Up @@ -76,7 +76,7 @@ public class ApplicationVersionsApi: AdaptableApi {
/// Unique identifier of the application.
public func getApplicationVersions(id: String) -> AnyPublisher<C8yApplicationVersionCollection, Error> {
let builder = URLRequestBuilder()
.set(resourcePath: "/application/applications\\(id)/versions")
.set(resourcePath: "/application/applications/\(id)/versions")
.set(httpMethod: "get")
.add(header: "Accept", value: "application/vnd.com.nsn.cumulocity.error+json, application/vnd.com.nsn.cumulocity.applicationVersionCollection+json")
return self.session.dataTaskPublisher(for: adapt(builder: builder).build()).tryMap({ element -> Data in
Expand Down Expand Up @@ -131,7 +131,7 @@ public class ApplicationVersionsApi: AdaptableApi {
return Fail<C8yApplicationVersion, Error>(error: error).eraseToAnyPublisher()
}
let builder = URLRequestBuilder()
.set(resourcePath: "/application/applications\\(id)/versions")
.set(resourcePath: "/application/applications/\(id)/versions")
.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.applicationVersion+json")
Expand Down Expand Up @@ -180,7 +180,7 @@ public class ApplicationVersionsApi: AdaptableApi {
/// The tag of the application version.
public func deleteApplicationVersion(id: String, version: String? = nil, tag: String? = nil) -> AnyPublisher<Data, Error> {
let builder = URLRequestBuilder()
.set(resourcePath: "/application/applications\\(id)/versions")
.set(resourcePath: "/application/applications/\(id)/versions")
.set(httpMethod: "delete")
.add(header: "Accept", value: "application/json")
.add(queryItem: "version", value: version)
Expand Down Expand Up @@ -234,7 +234,7 @@ public class ApplicationVersionsApi: AdaptableApi {
return Fail<C8yApplicationVersion, Error>(error: error).eraseToAnyPublisher()
}
let builder = URLRequestBuilder()
.set(resourcePath: "/application/applications\\(id)/versions\\(version)")
.set(resourcePath: "/application/applications/\(id)/versions/\(version)")
.set(httpMethod: "put")
.add(header: "Content-Type", value: "application/json")
.add(header: "Accept", value: "application/vnd.com.nsn.cumulocity.error+json, application/vnd.com.nsn.cumulocity.applicationVersion+json")
Expand Down
16 changes: 8 additions & 8 deletions Sources/CumulocityCoreLibrary/Api/ApplicationsApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public class ApplicationsApi: AdaptableApi {
/// Unique identifier of the application.
public func getApplication(id: String) -> AnyPublisher<C8yApplication, Error> {
let builder = URLRequestBuilder()
.set(resourcePath: "/application/applications\\(id)")
.set(resourcePath: "/application/applications/\(id)")
.set(httpMethod: "get")
.add(header: "Accept", value: "application/vnd.com.nsn.cumulocity.error+json, application/vnd.com.nsn.cumulocity.application+json")
return self.session.dataTaskPublisher(for: adapt(builder: builder).build()).tryMap({ element -> Data in
Expand Down Expand Up @@ -222,7 +222,7 @@ public class ApplicationsApi: AdaptableApi {
return Fail<C8yApplication, Error>(error: error).eraseToAnyPublisher()
}
let builder = URLRequestBuilder()
.set(resourcePath: "/application/applications\\(id)")
.set(resourcePath: "/application/applications/\(id)")
.set(httpMethod: "put")
.add(header: "X-Cumulocity-Processing-Mode", value: xCumulocityProcessingMode)
.add(header: "Content-Type", value: "application/vnd.com.nsn.cumulocity.application+json")
Expand Down Expand Up @@ -272,7 +272,7 @@ public class ApplicationsApi: AdaptableApi {
/// Used to explicitly control the processing mode of the request. See [Processing mode](#processing-mode) for more details.
public func deleteApplication(id: String, force: Bool? = nil, xCumulocityProcessingMode: String? = nil) -> AnyPublisher<Data, Error> {
let builder = URLRequestBuilder()
.set(resourcePath: "/application/applications\\(id)")
.set(resourcePath: "/application/applications/\(id)")
.set(httpMethod: "delete")
.add(header: "X-Cumulocity-Processing-Mode", value: xCumulocityProcessingMode)
.add(header: "Accept", value: "application/json")
Expand Down Expand Up @@ -321,7 +321,7 @@ public class ApplicationsApi: AdaptableApi {
/// 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> {
let builder = URLRequestBuilder()
.set(resourcePath: "/application/applications\\(id)/clone")
.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")
Expand Down Expand Up @@ -358,7 +358,7 @@ public class ApplicationsApi: AdaptableApi {
/// The name of the application.
public func getApplicationsByName(name: String) -> AnyPublisher<C8yApplicationCollection, Error> {
let builder = URLRequestBuilder()
.set(resourcePath: "/application/applicationsByName\\(name)")
.set(resourcePath: "/application/applicationsByName/\(name)")
.set(httpMethod: "get")
.add(header: "Accept", value: "application/vnd.com.nsn.cumulocity.error+json, application/vnd.com.nsn.cumulocity.applicationcollection+json")
return self.session.dataTaskPublisher(for: adapt(builder: builder).build()).tryMap({ element -> Data in
Expand Down Expand Up @@ -394,7 +394,7 @@ public class ApplicationsApi: AdaptableApi {
/// Unique identifier of a Cumulocity IoT tenant.
public func getApplicationsByTenant(tenantId: String) -> AnyPublisher<C8yApplicationCollection, Error> {
let builder = URLRequestBuilder()
.set(resourcePath: "/application/applicationsByTenant\\(tenantId)")
.set(resourcePath: "/application/applicationsByTenant/\(tenantId)")
.set(httpMethod: "get")
.add(header: "Accept", value: "application/vnd.com.nsn.cumulocity.error+json, application/vnd.com.nsn.cumulocity.applicationcollection+json")
return self.session.dataTaskPublisher(for: adapt(builder: builder).build()).tryMap({ element -> Data in
Expand Down Expand Up @@ -438,7 +438,7 @@ public class ApplicationsApi: AdaptableApi {
/// When set to `true`, the returned result will contain in the statistics object the total number of pages. Only applicable on [range queries](https://en.wikipedia.org/wiki/Range_query_(database)).
public func getApplicationsByOwner(tenantId: String, currentPage: Int? = nil, pageSize: Int? = nil, withTotalElements: Bool? = nil, withTotalPages: Bool? = nil) -> AnyPublisher<C8yApplicationCollection, Error> {
let builder = URLRequestBuilder()
.set(resourcePath: "/application/applicationsByOwner\\(tenantId)")
.set(resourcePath: "/application/applicationsByOwner/\(tenantId)")
.set(httpMethod: "get")
.add(header: "Accept", value: "application/vnd.com.nsn.cumulocity.error+json, application/vnd.com.nsn.cumulocity.applicationcollection+json")
.add(queryItem: "currentPage", value: currentPage)
Expand Down Expand Up @@ -486,7 +486,7 @@ public class ApplicationsApi: AdaptableApi {
/// When set to `true`, the returned result will contain in the statistics object the total number of pages. Only applicable on [range queries](https://en.wikipedia.org/wiki/Range_query_(database)).
public func getApplicationsByUser(username: String, currentPage: Int? = nil, pageSize: Int? = nil, withTotalElements: Bool? = nil, withTotalPages: Bool? = nil) -> AnyPublisher<C8yApplicationCollection, Error> {
let builder = URLRequestBuilder()
.set(resourcePath: "/application/applicationsByUser\\(username)")
.set(resourcePath: "/application/applicationsByUser/\(username)")
.set(httpMethod: "get")
.add(header: "Accept", value: "application/vnd.com.nsn.cumulocity.error+json, application/vnd.com.nsn.cumulocity.applicationcollection+json")
.add(queryItem: "currentPage", value: currentPage)
Expand Down
10 changes: 5 additions & 5 deletions Sources/CumulocityCoreLibrary/Api/AttachmentsApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class AttachmentsApi: AdaptableApi {
/// Unique identifier of the event.
public func getEventAttachment(id: String) -> AnyPublisher<Data, Error> {
let builder = URLRequestBuilder()
.set(resourcePath: "/event/events\\(id)/binaries")
.set(resourcePath: "/event/events/\(id)/binaries")
.set(httpMethod: "get")
.add(header: "Accept", value: "application/vnd.com.nsn.cumulocity.error+json, application/octet-stream")
return self.session.dataTaskPublisher(for: adapt(builder: builder).build()).tryMap({ element -> Data in
Expand Down Expand Up @@ -72,7 +72,7 @@ public class AttachmentsApi: AdaptableApi {
/// Unique identifier of the event.
public func replaceEventAttachment(body: Data, id: String) -> AnyPublisher<C8yEventBinary, Error> {
let builder = URLRequestBuilder()
.set(resourcePath: "/event/events\\(id)/binaries")
.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")
Expand Down Expand Up @@ -147,7 +147,7 @@ public class AttachmentsApi: AdaptableApi {
/// Unique identifier of the event.
public func uploadEventAttachment(body: Data, id: String) -> AnyPublisher<C8yEventBinary, Error> {
let builder = URLRequestBuilder()
.set(resourcePath: "/event/events\\(id)/binaries")
.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")
Expand Down Expand Up @@ -235,7 +235,7 @@ public class AttachmentsApi: AdaptableApi {
return Fail<C8yEventBinary, Error>(error: error).eraseToAnyPublisher()
}
let builder = URLRequestBuilder()
.set(resourcePath: "/event/events\\(id)/binaries")
.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")
Expand Down Expand Up @@ -276,7 +276,7 @@ public class AttachmentsApi: AdaptableApi {
/// Unique identifier of the event.
public func deleteEventAttachment(id: String) -> AnyPublisher<Data, Error> {
let builder = URLRequestBuilder()
.set(resourcePath: "/event/events\\(id)/binaries")
.set(resourcePath: "/event/events/\(id)/binaries")
.set(httpMethod: "delete")
.add(header: "Accept", value: "application/json")
return self.session.dataTaskPublisher(for: adapt(builder: builder).build()).tryMap({ element -> Data in
Expand Down
2 changes: 1 addition & 1 deletion Sources/CumulocityCoreLibrary/Api/AuditsApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public class AuditsApi: AdaptableApi {
/// Unique identifier of the audit record.
public func getAuditRecord(id: String) -> AnyPublisher<C8yAuditRecord, Error> {
let builder = URLRequestBuilder()
.set(resourcePath: "/audit/auditRecords\\(id)")
.set(resourcePath: "/audit/auditRecords/\(id)")
.set(httpMethod: "get")
.add(header: "Accept", value: "application/vnd.com.nsn.cumulocity.error+json, application/vnd.com.nsn.cumulocity.auditrecord+json")
return self.session.dataTaskPublisher(for: adapt(builder: builder).build()).tryMap({ element -> Data in
Expand Down
6 changes: 3 additions & 3 deletions Sources/CumulocityCoreLibrary/Api/BinariesApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public class BinariesApi: AdaptableApi {
/// Unique identifier of the managed object.
public func getBinary(id: String) -> AnyPublisher<Data, Error> {
let builder = URLRequestBuilder()
.set(resourcePath: "/inventory/binaries\\(id)")
.set(resourcePath: "/inventory/binaries/\(id)")
.set(httpMethod: "get")
.add(header: "Accept", value: "application/vnd.com.nsn.cumulocity.error+json, application/octet-stream")
return self.session.dataTaskPublisher(for: adapt(builder: builder).build()).tryMap({ element -> Data in
Expand Down Expand Up @@ -190,7 +190,7 @@ public class BinariesApi: AdaptableApi {
/// Unique identifier of the managed object.
public func replaceBinary(body: Data, id: String) -> AnyPublisher<C8yBinary, Error> {
let builder = URLRequestBuilder()
.set(resourcePath: "/inventory/binaries\\(id)")
.set(resourcePath: "/inventory/binaries/\(id)")
.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.managedobject+json")
Expand Down Expand Up @@ -228,7 +228,7 @@ public class BinariesApi: AdaptableApi {
/// Unique identifier of the managed object.
public func removeBinary(id: String) -> AnyPublisher<Data, Error> {
let builder = URLRequestBuilder()
.set(resourcePath: "/inventory/binaries\\(id)")
.set(resourcePath: "/inventory/binaries/\(id)")
.set(httpMethod: "delete")
.add(header: "Accept", value: "application/json")
return self.session.dataTaskPublisher(for: adapt(builder: builder).build()).tryMap({ element -> Data in
Expand Down
2 changes: 1 addition & 1 deletion Sources/CumulocityCoreLibrary/Api/BootstrapUserApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class BootstrapUserApi: AdaptableApi {
/// Unique identifier of the application.
public func getBootstrapUser(id: String) -> AnyPublisher<C8yBootstrapUser, Error> {
let builder = URLRequestBuilder()
.set(resourcePath: "/application/applications\\(id)/bootstrapUser")
.set(resourcePath: "/application/applications/\(id)/bootstrapUser")
.set(httpMethod: "get")
.add(header: "Accept", value: "application/vnd.com.nsn.cumulocity.error+json, application/vnd.com.nsn.cumulocity.user+json")
return self.session.dataTaskPublisher(for: adapt(builder: builder).build()).tryMap({ element -> Data in
Expand Down
6 changes: 3 additions & 3 deletions Sources/CumulocityCoreLibrary/Api/BulkOperationsApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public class BulkOperationsApi: AdaptableApi {
/// Unique identifier of the bulk operation.
public func getBulkOperation(id: String) -> AnyPublisher<C8yBulkOperation, Error> {
let builder = URLRequestBuilder()
.set(resourcePath: "/devicecontrol/bulkoperations\\(id)")
.set(resourcePath: "/devicecontrol/bulkoperations/\(id)")
.set(httpMethod: "get")
.add(header: "Accept", value: "application/vnd.com.nsn.cumulocity.error+json, application/vnd.com.nsn.cumulocity.bulkoperation+json")
return self.session.dataTaskPublisher(for: adapt(builder: builder).build()).tryMap({ element -> Data in
Expand Down Expand Up @@ -196,7 +196,7 @@ public class BulkOperationsApi: AdaptableApi {
return Fail<C8yBulkOperation, Error>(error: error).eraseToAnyPublisher()
}
let builder = URLRequestBuilder()
.set(resourcePath: "/devicecontrol/bulkoperations\\(id)")
.set(resourcePath: "/devicecontrol/bulkoperations/\(id)")
.set(httpMethod: "put")
.add(header: "X-Cumulocity-Processing-Mode", value: xCumulocityProcessingMode)
.add(header: "Content-Type", value: "application/vnd.com.nsn.cumulocity.bulkoperation+json")
Expand Down Expand Up @@ -241,7 +241,7 @@ public class BulkOperationsApi: AdaptableApi {
/// Used to explicitly control the processing mode of the request. See [Processing mode](#processing-mode) for more details.
public func deleteBulkOperation(id: String, xCumulocityProcessingMode: String? = nil) -> AnyPublisher<Data, Error> {
let builder = URLRequestBuilder()
.set(resourcePath: "/devicecontrol/bulkoperations\\(id)")
.set(resourcePath: "/devicecontrol/bulkoperations/\(id)")
.set(httpMethod: "delete")
.add(header: "X-Cumulocity-Processing-Mode", value: xCumulocityProcessingMode)
.add(header: "Accept", value: "application/json")
Expand Down
Loading

0 comments on commit fd6203c

Please sign in to comment.