Skip to content

Commit

Permalink
Updated to new OpenAPI version. Allowed building the client as a Jar.
Browse files Browse the repository at this point in the history
  • Loading branch information
joerghartmann authored Feb 15, 2024
1 parent 5d52161 commit 388ab4a
Show file tree
Hide file tree
Showing 271 changed files with 1,302 additions and 484 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Those classes allow to add an arbitrary number of additional properties as a lis
Alarm.Serialization.registerAdditionalProperty(typeName: String, type: Class<*>)
```

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 Expand Up @@ -84,7 +84,7 @@ clientBuilder.addInterceptor(headerAuthorizationInterceptor)
The customised `clientBuilder` can than be passed to any service instance using it's `companion` `Factory` object, i.e.:
```kotlin
SystemOptionsApi.Factory.create("endpoint", clientBuilder)
CurrentUserApi.Factory.create("endpoint", clientBuilder)
```
## Contribution
Expand Down
23 changes: 23 additions & 0 deletions build-jar.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
plugins {
id 'java'
id "org.jetbrains.kotlin.jvm" version "$kotlinVersion"
}

jar {
archiveBaseName = 'cumulocitycorelibrary'
archiveVersion = '10.18.0-263'
}

repositories {
mavenCentral()
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
api "com.squareup.retrofit2:retrofit:$retrofitVersion"
api "com.squareup.retrofit2:converter-gson:$retrofitVersion"
api "com.squareup.retrofit2:converter-scalars:$retrofitVersion"

testImplementation 'junit:junit:$junitVersion'
}
51 changes: 33 additions & 18 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
buildscript {
repositories {
mavenCentral()
google()
}
dependencies {
classpath "com.android.tools.build:gradle:$androidVersion"
}
}

android {
compileSdkVersion 33
plugins {
id 'org.jetbrains.kotlin.android' version "$kotlinVersion"
id 'com.android.library' version "$androidVersion"
}

repositories {
google()
mavenCentral()
}

java.toolchain.languageVersion.set(JavaLanguageVersion.of(20))

android {
compileSdk 33
namespace "com.cumulocity.client"
defaultConfig {
minSdkVersion 19
targetSdkVersion 33
versionCode 214
versionName "10.15.0"
versionCode 263
versionName "10.18.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Expand All @@ -22,15 +41,11 @@ android {
}

dependencies {
implementation 'androidx.core:core-ktx:1.9.0'
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.7.10'
implementation 'org.jetbrains.kotlin:kotlin-reflect:1.7.10'
api 'com.squareup.retrofit2:retrofit:2.9.0'
api 'com.squareup.retrofit2:converter-gson:2.4.0'
api 'com.squareup.retrofit2:converter-scalars:2.4.0'

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
api "com.squareup.retrofit2:retrofit:$retrofitVersion"
api "com.squareup.retrofit2:converter-gson:$retrofitVersion"
api "com.squareup.retrofit2:converter-scalars:$retrofitVersion"

testImplementation "junit:junit:$junitVersion"
}
4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
kotlinVersion=1.9.22
retrofitVersion=2.9.0
androidVersion=8.2.2
junitVersion=4.13.2
8 changes: 8 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
pluginManagement {
repositories {
maven { url "https://plugins.gradle.org/m2/" }
gradlePluginPortal()
google()
mavenCentral()
}
}
18 changes: 9 additions & 9 deletions src/main/java/com/cumulocity/client/api/AlarmsApi.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2014-2023 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.
// Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.
// Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.

package com.cumulocity.client.api
import retrofit2.converter.scalars.ScalarsConverterFactory
Expand Down Expand Up @@ -87,15 +87,15 @@ interface AlarmsApi {
* @param pageSize
* Indicates how many entries of the collection shall be returned. The upper limit for one page is 2,000 objects.
* @param 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.
* @param severity
* The severity of the alarm to search for.
*
* **ⓘ Info:** If you query for multiple alarm severities at once, comma-separate the values.
* @param source
* The managed object ID to which the alarm is associated.
* @param 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.
*
* **ⓘ Info:** If you query for multiple alarm statuses at once, comma-separate the values.
* @param type
Expand Down Expand Up @@ -167,15 +167,15 @@ interface AlarmsApi {
* @param dateTo
* End date or date and time of the alarm occurrence.
* @param 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.
* @param severity
* The severity of the alarm to search for.
*
* **ⓘ Info:** If you query for multiple alarm severities at once, comma-separate the values.
* @param source
* The managed object ID to which the alarm is associated.
* @param 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.
*
* **ⓘ Info:** If you query for multiple alarm statuses at once, comma-separate the values.
* @param withSourceAssets
Expand Down Expand Up @@ -279,15 +279,15 @@ interface AlarmsApi {
* @param dateTo
* End date or date and time of the alarm occurrence.
* @param 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.
* @param severity
* The severity of the alarm to search for.
*
* **ⓘ Info:** If you query for multiple alarm severities at once, comma-separate the values.
* @param source
* The managed object ID to which the alarm is associated.
* @param 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.
*
* **ⓘ Info:** If you query for multiple alarm statuses at once, comma-separate the values.
* @param type
Expand Down Expand Up @@ -402,15 +402,15 @@ interface AlarmsApi {
* @param dateTo
* End date or date and time of the alarm occurrence.
* @param 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.
* @param severity
* The severity of the alarm to search for.
*
* **ⓘ Info:** If you query for multiple alarm severities at once, comma-separate the values.
* @param source
* The managed object ID to which the alarm is associated.
* @param 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.
*
* **ⓘ Info:** If you query for multiple alarm statuses at once, comma-separate the values.
* @param type
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2014-2023 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.
// Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.
// Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.

package com.cumulocity.client.api
import retrofit2.converter.scalars.ScalarsConverterFactory
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2014-2023 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.
// Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.
// Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.

package com.cumulocity.client.api
import retrofit2.converter.scalars.ScalarsConverterFactory
Expand Down
16 changes: 12 additions & 4 deletions src/main/java/com/cumulocity/client/api/ApplicationsApi.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2014-2023 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.
// Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.
// Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.

package com.cumulocity.client.api
import retrofit2.converter.scalars.ScalarsConverterFactory
Expand Down Expand Up @@ -28,7 +28,7 @@ import com.cumulocity.client.model.ApplicationCollection
*
* 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 [Administration > Managing applications](https://cumulocity.com/guides/users-guide/administration#managing-applications) in the *User guide* for the respective application name to be used.
*
* > **ⓘ Info:** The Accept header should be provided in all POST/PUT requests, otherwise an empty response body will be returned.
*/
Expand Down Expand Up @@ -226,10 +226,10 @@ interface ApplicationsApi {
*
* @param id
* Unique identifier of the application.
* @param force
* Force deletion by unsubscribing all tenants from the application first and then deleting the application itself.
* @param xCumulocityProcessingMode
* Used to explicitly control the processing mode of the request. See [Processing mode](#processing-mode) for more details.
* @param force
* Force deletion by unsubscribing all tenants from the application first and then deleting the application itself.
*/
@Headers("Accept:application/json")
@DELETE("/application/applications/{id}")
Expand All @@ -252,6 +252,8 @@ interface ApplicationsApi {
*
* 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`.
*
*
* ##### Required roles
*
Expand All @@ -269,11 +271,17 @@ interface ApplicationsApi {
* Unique identifier of the application.
* @param xCumulocityProcessingMode
* Used to explicitly control the processing mode of the request. See [Processing mode](#processing-mode) for more details.
* @param version
* The version field of the application version.
* @param tag
* The tag of the application version.
*/
@Headers("Accept:application/vnd.com.nsn.cumulocity.error+json, application/vnd.com.nsn.cumulocity.application+json")
@POST("/application/applications/{id}/clone")
fun copyApplication(
@Path("id") id: String,
@Query("version") version: String? = null,
@Query("tag") tag: String? = null,
@Header("X-Cumulocity-Processing-Mode") xCumulocityProcessingMode: String? = null
): Call<Application>

Expand Down
26 changes: 13 additions & 13 deletions src/main/java/com/cumulocity/client/api/AttachmentsApi.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2014-2023 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.
// Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.
// Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.

package com.cumulocity.client.api
import retrofit2.converter.scalars.ScalarsConverterFactory
Expand All @@ -22,7 +22,7 @@ import com.cumulocity.client.model.BinaryInfo
import com.cumulocity.client.model.EventBinary

/**
* 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.
*/
interface AttachmentsApi {

Expand Down Expand Up @@ -96,7 +96,7 @@ interface AttachmentsApi {
* @param id
* Unique identifier of the event.
*/
@Headers(*["Content-Type:text/plain", "Accept:application/vnd.com.nsn.cumulocity.error+json, application/vnd.com.nsn.cumulocity.event+json"])
@Headers(*["Content-Type:text/plain", "Accept:application/vnd.com.nsn.cumulocity.error+json, application/json"])
@PUT("/event/events/{id}/binaries")
fun replaceEventAttachment(
@Body body: UByteArray,
Expand All @@ -106,10 +106,10 @@ interface AttachmentsApi {
/**
* 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:
* > **ⓘ Info:** 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 @@ -118,7 +118,7 @@ interface AttachmentsApi {
* "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 @@ -156,7 +156,7 @@ interface AttachmentsApi {
* @param id
* Unique identifier of the event.
*/
@Headers(*["Content-Type:text/plain", "Accept:application/vnd.com.nsn.cumulocity.error+json, application/vnd.com.nsn.cumulocity.event+json"])
@Headers(*["Content-Type:text/plain", "Accept:application/vnd.com.nsn.cumulocity.error+json, application/json"])
@POST("/event/events/{id}/binaries")
fun uploadEventAttachment(
@Body body: UByteArray,
Expand All @@ -166,10 +166,10 @@ interface AttachmentsApi {
/**
* 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:
* > **ⓘ Info:** 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 @@ -178,7 +178,7 @@ interface AttachmentsApi {
* "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 @@ -218,7 +218,7 @@ interface AttachmentsApi {
* @param id
* Unique identifier of the event.
*/
@Headers(*["Content-Type:multipart/form-data", "Accept:application/vnd.com.nsn.cumulocity.error+json, application/vnd.com.nsn.cumulocity.event+json"])
@Headers(*["Content-Type:multipart/form-data", "Accept:application/vnd.com.nsn.cumulocity.error+json, application/json"])
@POST("/event/events/{id}/binaries")
@Multipart
fun uploadEventAttachment(
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/cumulocity/client/api/AuditsApi.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2014-2023 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.
// Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.
// Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.

package com.cumulocity.client.api
import retrofit2.converter.scalars.ScalarsConverterFactory
Expand Down
Loading

0 comments on commit 388ab4a

Please sign in to comment.