Change client to retrofit2
This commit is contained in:
@@ -27,6 +27,9 @@ android {
|
||||
lintOptions {
|
||||
disable 'GoogleAppIndexingWarning'
|
||||
}
|
||||
packagingOptions {
|
||||
exclude 'META-INF/DEPENDENCIES'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -1,75 +1,4 @@
|
||||
package com.github.gotify.api;
|
||||
|
||||
import android.app.Activity;
|
||||
import com.github.gotify.client.ApiCallback;
|
||||
import com.github.gotify.client.ApiException;
|
||||
import com.github.gotify.log.Log;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Api {
|
||||
public static <T> CallExecutor<T> withLogging(ApiCall<T> call) {
|
||||
return new CallExecutor<T>(call);
|
||||
}
|
||||
|
||||
private static <T> Callback<T> loggingCallback() {
|
||||
return Callback.call(
|
||||
(data) -> {},
|
||||
(exception) ->
|
||||
Log.e("Error while api call: " + exception.getResponseBody(), exception));
|
||||
}
|
||||
|
||||
public interface ApiCall<T> {
|
||||
void call(ApiCallback<T> callback) throws ApiException;
|
||||
}
|
||||
|
||||
public static class CallExecutor<T> {
|
||||
private ApiCall<T> call;
|
||||
|
||||
private CallExecutor(ApiCall<T> call) {
|
||||
this.call = call;
|
||||
}
|
||||
|
||||
public void handle(Callback<T> callback) {
|
||||
Callback<T> merged = Callback.merge(callback, loggingCallback());
|
||||
try {
|
||||
call.call(fromCallback(merged));
|
||||
} catch (ApiException e) {
|
||||
merged.onError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void handleInUIThread(
|
||||
Activity activity,
|
||||
Callback.SuccessCallback<T> onSuccess,
|
||||
Callback.ErrorCallback onError) {
|
||||
handle(Callback.runInUIThread(activity, Callback.call(onSuccess, onError)));
|
||||
}
|
||||
|
||||
public void handle(Callback.SuccessCallback<T> onSuccess, Callback.ErrorCallback onError) {
|
||||
handle(Callback.call(onSuccess, onError));
|
||||
}
|
||||
}
|
||||
|
||||
private static <T> ApiCallback<T> fromCallback(Callback<T> callback) {
|
||||
return new ApiCallback<T>() {
|
||||
@Override
|
||||
public void onFailure(
|
||||
ApiException e, int statusCode, Map<String, List<String>> responseHeaders) {
|
||||
callback.onError(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(
|
||||
T result, int statusCode, Map<String, List<String>> responseHeaders) {
|
||||
callback.onSuccess(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUploadProgress(long bytesWritten, long contentLength, boolean done) {}
|
||||
|
||||
@Override
|
||||
public void onDownloadProgress(long bytesRead, long contentLength, boolean done) {}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.github.gotify.api;
|
||||
|
||||
class ApiException {
|
||||
}
|
||||
150
client/README.md
150
client/README.md
@@ -4,7 +4,7 @@
|
||||
|
||||
Building the API client library requires [Maven](https://maven.apache.org/) to be installed.
|
||||
|
||||
## Installation
|
||||
## Installation & Usage
|
||||
|
||||
To install the API client library to your local Maven repository, simply execute:
|
||||
|
||||
@@ -20,9 +20,7 @@ mvn deploy
|
||||
|
||||
Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information.
|
||||
|
||||
### Maven users
|
||||
|
||||
Add this dependency to your project's POM:
|
||||
After the client library is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*:
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
@@ -31,153 +29,11 @@ Add this dependency to your project's POM:
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
### Gradle users
|
||||
|
||||
Add this dependency to your project's build file:
|
||||
|
||||
```groovy
|
||||
compile "io.swagger:swagger-java-client:1.0.0"
|
||||
```
|
||||
|
||||
### Others
|
||||
|
||||
At first generate the JAR by executing:
|
||||
|
||||
mvn package
|
||||
|
||||
Then manually install the following JARs:
|
||||
|
||||
* target/swagger-java-client-1.0.0.jar
|
||||
* target/lib/*.jar
|
||||
|
||||
## Getting Started
|
||||
|
||||
Please follow the [installation](#installation) instruction and execute the following Java code:
|
||||
|
||||
```java
|
||||
|
||||
import com.github.gotify.client.*;
|
||||
import com.github.gotify.client.auth.*;
|
||||
import com.github.gotify.client.model.*;
|
||||
import com.github.gotify.client.api.MessageApi;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
public class MessageApiExample {
|
||||
|
||||
public static void main(String[] args) {
|
||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||
|
||||
// Configure API key authorization: appTokenHeader
|
||||
ApiKeyAuth appTokenHeader = (ApiKeyAuth) defaultClient.getAuthentication("appTokenHeader");
|
||||
appTokenHeader.setApiKey("YOUR API KEY");
|
||||
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
|
||||
//appTokenHeader.setApiKeyPrefix("Token");
|
||||
|
||||
// Configure API key authorization: appTokenQuery
|
||||
ApiKeyAuth appTokenQuery = (ApiKeyAuth) defaultClient.getAuthentication("appTokenQuery");
|
||||
appTokenQuery.setApiKey("YOUR API KEY");
|
||||
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
|
||||
//appTokenQuery.setApiKeyPrefix("Token");
|
||||
|
||||
MessageApi apiInstance = new MessageApi();
|
||||
Message body = new Message(); // Message | the message to add
|
||||
try {
|
||||
Message result = apiInstance.createMessage(body);
|
||||
System.out.println(result);
|
||||
} catch (ApiException e) {
|
||||
System.err.println("Exception when calling MessageApi#createMessage");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Documentation for API Endpoints
|
||||
|
||||
All URIs are relative to *http://localhost*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
*MessageApi* | [**createMessage**](docs/MessageApi.md#createMessage) | **POST** /message | Create a message.
|
||||
*MessageApi* | [**deleteAppMessages**](docs/MessageApi.md#deleteAppMessages) | **DELETE** /application/{id}/message | Delete all messages from a specific application.
|
||||
*MessageApi* | [**deleteMessage**](docs/MessageApi.md#deleteMessage) | **DELETE** /message/{id} | Deletes a message with an id.
|
||||
*MessageApi* | [**deleteMessages**](docs/MessageApi.md#deleteMessages) | **DELETE** /message | Delete all messages.
|
||||
*MessageApi* | [**getAppMessages**](docs/MessageApi.md#getAppMessages) | **GET** /application/{id}/message | Return all messages from a specific application.
|
||||
*MessageApi* | [**getMessages**](docs/MessageApi.md#getMessages) | **GET** /message | Return all messages.
|
||||
*MessageApi* | [**streamMessages**](docs/MessageApi.md#streamMessages) | **GET** /stream | Websocket, return newly created messages.
|
||||
*TokenApi* | [**createApp**](docs/TokenApi.md#createApp) | **POST** /application | Create an application.
|
||||
*TokenApi* | [**createClient**](docs/TokenApi.md#createClient) | **POST** /client | Create a client.
|
||||
*TokenApi* | [**deleteApp**](docs/TokenApi.md#deleteApp) | **DELETE** /application/{id} | Delete an application.
|
||||
*TokenApi* | [**deleteClient**](docs/TokenApi.md#deleteClient) | **DELETE** /client/{id} | Delete a client.
|
||||
*TokenApi* | [**getApps**](docs/TokenApi.md#getApps) | **GET** /application | Return all applications.
|
||||
*TokenApi* | [**getClients**](docs/TokenApi.md#getClients) | **GET** /client | Return all clients.
|
||||
*TokenApi* | [**uploadAppImage**](docs/TokenApi.md#uploadAppImage) | **POST** /application/{id}/image |
|
||||
*UserApi* | [**createUser**](docs/UserApi.md#createUser) | **POST** /user | Create a user.
|
||||
*UserApi* | [**currentUser**](docs/UserApi.md#currentUser) | **GET** /current/user | Return the current user.
|
||||
*UserApi* | [**deleteUser**](docs/UserApi.md#deleteUser) | **DELETE** /user/{id} | Deletes a user.
|
||||
*UserApi* | [**getUser**](docs/UserApi.md#getUser) | **GET** /user/{id} | Get a user.
|
||||
*UserApi* | [**getUsers**](docs/UserApi.md#getUsers) | **GET** /user | Return all users.
|
||||
*UserApi* | [**updateCurrentUser**](docs/UserApi.md#updateCurrentUser) | **POST** /current/user/password | Update the password of the current user.
|
||||
*UserApi* | [**updateUser**](docs/UserApi.md#updateUser) | **POST** /user/{id} | Update a user.
|
||||
*VersionApi* | [**getVersion**](docs/VersionApi.md#getVersion) | **GET** /version | Get version information.
|
||||
|
||||
|
||||
## Documentation for Models
|
||||
|
||||
- [Application](docs/Application.md)
|
||||
- [Client](docs/Client.md)
|
||||
- [Error](docs/Error.md)
|
||||
- [Message](docs/Message.md)
|
||||
- [PagedMessages](docs/PagedMessages.md)
|
||||
- [Paging](docs/Paging.md)
|
||||
- [User](docs/User.md)
|
||||
- [UserPass](docs/UserPass.md)
|
||||
- [UserWithPass](docs/UserWithPass.md)
|
||||
- [VersionInfo](docs/VersionInfo.md)
|
||||
|
||||
|
||||
## Documentation for Authorization
|
||||
|
||||
Authentication schemes defined for the API:
|
||||
### appTokenHeader
|
||||
|
||||
- **Type**: API key
|
||||
- **API key parameter name**: X-Gotify-Key
|
||||
- **Location**: HTTP header
|
||||
|
||||
### appTokenQuery
|
||||
|
||||
- **Type**: API key
|
||||
- **API key parameter name**: token
|
||||
- **Location**: URL query string
|
||||
|
||||
### basicAuth
|
||||
|
||||
- **Type**: HTTP basic authentication
|
||||
|
||||
### clientTokenHeader
|
||||
|
||||
- **Type**: API key
|
||||
- **API key parameter name**: X-Gotify-Key
|
||||
- **Location**: HTTP header
|
||||
|
||||
### clientTokenQuery
|
||||
|
||||
- **Type**: API key
|
||||
- **API key parameter name**: token
|
||||
- **Location**: URL query string
|
||||
|
||||
|
||||
## Recommendation
|
||||
|
||||
It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues.
|
||||
|
||||
## Author
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -25,11 +25,10 @@ if(hasProperty('target') && target == 'android') {
|
||||
apply plugin: 'com.github.dcendents.android-maven'
|
||||
|
||||
android {
|
||||
compileSdkVersion 25
|
||||
buildToolsVersion '25.0.2'
|
||||
compileSdkVersion 28
|
||||
defaultConfig {
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 25
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 28
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_7
|
||||
@@ -93,12 +92,22 @@ if(hasProperty('target') && target == 'android') {
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'io.swagger:swagger-annotations:1.5.15'
|
||||
compile 'com.squareup.okhttp:okhttp:2.7.5'
|
||||
compile 'com.squareup.okhttp:logging-interceptor:2.7.5'
|
||||
compile 'com.google.code.gson:gson:2.8.1'
|
||||
compile 'io.gsonfire:gson-fire:1.8.0'
|
||||
compile 'org.threeten:threetenbp:1.3.5'
|
||||
testCompile 'junit:junit:4.12'
|
||||
ext {
|
||||
oltu_version = "1.0.0"
|
||||
retrofit_version = "2.3.0"
|
||||
swagger_annotations_version = "1.5.15"
|
||||
junit_version = "4.12"
|
||||
threetenbp_version = "1.3.5"
|
||||
json_fire_version = "1.8.0"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "com.squareup.retrofit2:retrofit:$retrofit_version"
|
||||
compile "com.squareup.retrofit2:converter-scalars:$retrofit_version"
|
||||
compile "com.squareup.retrofit2:converter-gson:$retrofit_version"
|
||||
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
|
||||
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version"
|
||||
compile "io.gsonfire:gson-fire:$json_fire_version"
|
||||
compile "org.threeten:threetenbp:$threetenbp_version"
|
||||
testCompile "junit:junit:$junit_version"
|
||||
}
|
||||
|
||||
@@ -9,13 +9,14 @@ lazy val root = (project in file(".")).
|
||||
publishArtifact in (Compile, packageDoc) := false,
|
||||
resolvers += Resolver.mavenLocal,
|
||||
libraryDependencies ++= Seq(
|
||||
"io.swagger" % "swagger-annotations" % "1.5.15",
|
||||
"com.squareup.okhttp" % "okhttp" % "2.7.5",
|
||||
"com.squareup.okhttp" % "logging-interceptor" % "2.7.5",
|
||||
"com.google.code.gson" % "gson" % "2.8.1",
|
||||
"com.squareup.retrofit2" % "retrofit" % "2.3.0" % "compile",
|
||||
"com.squareup.retrofit2" % "converter-scalars" % "2.3.0" % "compile",
|
||||
"com.squareup.retrofit2" % "converter-gson" % "2.3.0" % "compile",
|
||||
"io.swagger" % "swagger-annotations" % "1.5.15" % "compile",
|
||||
"org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.1" % "compile",
|
||||
"org.threeten" % "threetenbp" % "1.3.5" % "compile",
|
||||
"io.gsonfire" % "gson-fire" % "1.8.0" % "compile",
|
||||
"junit" % "junit" % "4.12" % "test",
|
||||
"com.novocode" % "junit-interface" % "0.10" % "test"
|
||||
"com.novocode" % "junit-interface" % "0.11" % "test"
|
||||
)
|
||||
)
|
||||
|
||||
@@ -4,13 +4,13 @@ All URIs are relative to *http://localhost*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**createMessage**](MessageApi.md#createMessage) | **POST** /message | Create a message.
|
||||
[**deleteAppMessages**](MessageApi.md#deleteAppMessages) | **DELETE** /application/{id}/message | Delete all messages from a specific application.
|
||||
[**deleteMessage**](MessageApi.md#deleteMessage) | **DELETE** /message/{id} | Deletes a message with an id.
|
||||
[**deleteMessages**](MessageApi.md#deleteMessages) | **DELETE** /message | Delete all messages.
|
||||
[**getAppMessages**](MessageApi.md#getAppMessages) | **GET** /application/{id}/message | Return all messages from a specific application.
|
||||
[**getMessages**](MessageApi.md#getMessages) | **GET** /message | Return all messages.
|
||||
[**streamMessages**](MessageApi.md#streamMessages) | **GET** /stream | Websocket, return newly created messages.
|
||||
[**createMessage**](MessageApi.md#createMessage) | **POST** message | Create a message.
|
||||
[**deleteAppMessages**](MessageApi.md#deleteAppMessages) | **DELETE** application/{id}/message | Delete all messages from a specific application.
|
||||
[**deleteMessage**](MessageApi.md#deleteMessage) | **DELETE** message/{id} | Deletes a message with an id.
|
||||
[**deleteMessages**](MessageApi.md#deleteMessages) | **DELETE** message | Delete all messages.
|
||||
[**getAppMessages**](MessageApi.md#getAppMessages) | **GET** application/{id}/message | Return all messages from a specific application.
|
||||
[**getMessages**](MessageApi.md#getMessages) | **GET** message | Return all messages.
|
||||
[**streamMessages**](MessageApi.md#streamMessages) | **GET** stream | Websocket, return newly created messages.
|
||||
|
||||
|
||||
<a name="createMessage"></a>
|
||||
@@ -76,7 +76,7 @@ Name | Type | Description | Notes
|
||||
|
||||
<a name="deleteAppMessages"></a>
|
||||
# **deleteAppMessages**
|
||||
> deleteAppMessages(id)
|
||||
> Void deleteAppMessages(id)
|
||||
|
||||
Delete all messages from a specific application.
|
||||
|
||||
@@ -111,7 +111,8 @@ clientTokenQuery.setApiKey("YOUR API KEY");
|
||||
MessageApi apiInstance = new MessageApi();
|
||||
Integer id = 56; // Integer | the application id
|
||||
try {
|
||||
apiInstance.deleteAppMessages(id);
|
||||
Void result = apiInstance.deleteAppMessages(id);
|
||||
System.out.println(result);
|
||||
} catch (ApiException e) {
|
||||
System.err.println("Exception when calling MessageApi#deleteAppMessages");
|
||||
e.printStackTrace();
|
||||
@@ -126,7 +127,7 @@ Name | Type | Description | Notes
|
||||
|
||||
### Return type
|
||||
|
||||
null (empty response body)
|
||||
[**Void**](.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
@@ -139,7 +140,7 @@ null (empty response body)
|
||||
|
||||
<a name="deleteMessage"></a>
|
||||
# **deleteMessage**
|
||||
> deleteMessage(id)
|
||||
> Void deleteMessage(id)
|
||||
|
||||
Deletes a message with an id.
|
||||
|
||||
@@ -174,7 +175,8 @@ clientTokenQuery.setApiKey("YOUR API KEY");
|
||||
MessageApi apiInstance = new MessageApi();
|
||||
Integer id = 56; // Integer | the message id
|
||||
try {
|
||||
apiInstance.deleteMessage(id);
|
||||
Void result = apiInstance.deleteMessage(id);
|
||||
System.out.println(result);
|
||||
} catch (ApiException e) {
|
||||
System.err.println("Exception when calling MessageApi#deleteMessage");
|
||||
e.printStackTrace();
|
||||
@@ -189,7 +191,7 @@ Name | Type | Description | Notes
|
||||
|
||||
### Return type
|
||||
|
||||
null (empty response body)
|
||||
[**Void**](.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
@@ -202,7 +204,7 @@ null (empty response body)
|
||||
|
||||
<a name="deleteMessages"></a>
|
||||
# **deleteMessages**
|
||||
> deleteMessages()
|
||||
> Void deleteMessages()
|
||||
|
||||
Delete all messages.
|
||||
|
||||
@@ -236,7 +238,8 @@ clientTokenQuery.setApiKey("YOUR API KEY");
|
||||
|
||||
MessageApi apiInstance = new MessageApi();
|
||||
try {
|
||||
apiInstance.deleteMessages();
|
||||
Void result = apiInstance.deleteMessages();
|
||||
System.out.println(result);
|
||||
} catch (ApiException e) {
|
||||
System.err.println("Exception when calling MessageApi#deleteMessages");
|
||||
e.printStackTrace();
|
||||
@@ -248,7 +251,7 @@ This endpoint does not need any parameter.
|
||||
|
||||
### Return type
|
||||
|
||||
null (empty response body)
|
||||
[**Void**](.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
|
||||
@@ -4,13 +4,13 @@ All URIs are relative to *http://localhost*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**createApp**](TokenApi.md#createApp) | **POST** /application | Create an application.
|
||||
[**createClient**](TokenApi.md#createClient) | **POST** /client | Create a client.
|
||||
[**deleteApp**](TokenApi.md#deleteApp) | **DELETE** /application/{id} | Delete an application.
|
||||
[**deleteClient**](TokenApi.md#deleteClient) | **DELETE** /client/{id} | Delete a client.
|
||||
[**getApps**](TokenApi.md#getApps) | **GET** /application | Return all applications.
|
||||
[**getClients**](TokenApi.md#getClients) | **GET** /client | Return all clients.
|
||||
[**uploadAppImage**](TokenApi.md#uploadAppImage) | **POST** /application/{id}/image |
|
||||
[**createApp**](TokenApi.md#createApp) | **POST** application | Create an application.
|
||||
[**createClient**](TokenApi.md#createClient) | **POST** client | Create a client.
|
||||
[**deleteApp**](TokenApi.md#deleteApp) | **DELETE** application/{id} | Delete an application.
|
||||
[**deleteClient**](TokenApi.md#deleteClient) | **DELETE** client/{id} | Delete a client.
|
||||
[**getApps**](TokenApi.md#getApps) | **GET** application | Return all applications.
|
||||
[**getClients**](TokenApi.md#getClients) | **GET** client | Return all clients.
|
||||
[**uploadAppImage**](TokenApi.md#uploadAppImage) | **POST** application/{id}/image |
|
||||
|
||||
|
||||
<a name="createApp"></a>
|
||||
@@ -143,7 +143,7 @@ Name | Type | Description | Notes
|
||||
|
||||
<a name="deleteApp"></a>
|
||||
# **deleteApp**
|
||||
> deleteApp(id)
|
||||
> Void deleteApp(id)
|
||||
|
||||
Delete an application.
|
||||
|
||||
@@ -178,7 +178,8 @@ clientTokenQuery.setApiKey("YOUR API KEY");
|
||||
TokenApi apiInstance = new TokenApi();
|
||||
Integer id = 56; // Integer | the application id
|
||||
try {
|
||||
apiInstance.deleteApp(id);
|
||||
Void result = apiInstance.deleteApp(id);
|
||||
System.out.println(result);
|
||||
} catch (ApiException e) {
|
||||
System.err.println("Exception when calling TokenApi#deleteApp");
|
||||
e.printStackTrace();
|
||||
@@ -193,7 +194,7 @@ Name | Type | Description | Notes
|
||||
|
||||
### Return type
|
||||
|
||||
null (empty response body)
|
||||
[**Void**](.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
@@ -206,7 +207,7 @@ null (empty response body)
|
||||
|
||||
<a name="deleteClient"></a>
|
||||
# **deleteClient**
|
||||
> deleteClient(id)
|
||||
> Void deleteClient(id)
|
||||
|
||||
Delete a client.
|
||||
|
||||
@@ -241,7 +242,8 @@ clientTokenQuery.setApiKey("YOUR API KEY");
|
||||
TokenApi apiInstance = new TokenApi();
|
||||
Integer id = 56; // Integer | the client id
|
||||
try {
|
||||
apiInstance.deleteClient(id);
|
||||
Void result = apiInstance.deleteClient(id);
|
||||
System.out.println(result);
|
||||
} catch (ApiException e) {
|
||||
System.err.println("Exception when calling TokenApi#deleteClient");
|
||||
e.printStackTrace();
|
||||
@@ -256,7 +258,7 @@ Name | Type | Description | Notes
|
||||
|
||||
### Return type
|
||||
|
||||
null (empty response body)
|
||||
[**Void**](.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
|
||||
@@ -4,13 +4,13 @@ All URIs are relative to *http://localhost*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**createUser**](UserApi.md#createUser) | **POST** /user | Create a user.
|
||||
[**currentUser**](UserApi.md#currentUser) | **GET** /current/user | Return the current user.
|
||||
[**deleteUser**](UserApi.md#deleteUser) | **DELETE** /user/{id} | Deletes a user.
|
||||
[**getUser**](UserApi.md#getUser) | **GET** /user/{id} | Get a user.
|
||||
[**getUsers**](UserApi.md#getUsers) | **GET** /user | Return all users.
|
||||
[**updateCurrentUser**](UserApi.md#updateCurrentUser) | **POST** /current/user/password | Update the password of the current user.
|
||||
[**updateUser**](UserApi.md#updateUser) | **POST** /user/{id} | Update a user.
|
||||
[**createUser**](UserApi.md#createUser) | **POST** user | Create a user.
|
||||
[**currentUser**](UserApi.md#currentUser) | **GET** current/user | Return the current user.
|
||||
[**deleteUser**](UserApi.md#deleteUser) | **DELETE** user/{id} | Deletes a user.
|
||||
[**getUser**](UserApi.md#getUser) | **GET** user/{id} | Get a user.
|
||||
[**getUsers**](UserApi.md#getUsers) | **GET** user | Return all users.
|
||||
[**updateCurrentUser**](UserApi.md#updateCurrentUser) | **POST** current/user/password | Update the password of the current user.
|
||||
[**updateUser**](UserApi.md#updateUser) | **POST** user/{id} | Update a user.
|
||||
|
||||
|
||||
<a name="createUser"></a>
|
||||
@@ -139,7 +139,7 @@ This endpoint does not need any parameter.
|
||||
|
||||
<a name="deleteUser"></a>
|
||||
# **deleteUser**
|
||||
> deleteUser(id)
|
||||
> Void deleteUser(id)
|
||||
|
||||
Deletes a user.
|
||||
|
||||
@@ -174,7 +174,8 @@ clientTokenQuery.setApiKey("YOUR API KEY");
|
||||
UserApi apiInstance = new UserApi();
|
||||
Integer id = 56; // Integer | the user id
|
||||
try {
|
||||
apiInstance.deleteUser(id);
|
||||
Void result = apiInstance.deleteUser(id);
|
||||
System.out.println(result);
|
||||
} catch (ApiException e) {
|
||||
System.err.println("Exception when calling UserApi#deleteUser");
|
||||
e.printStackTrace();
|
||||
@@ -189,7 +190,7 @@ Name | Type | Description | Notes
|
||||
|
||||
### Return type
|
||||
|
||||
null (empty response body)
|
||||
[**Void**](.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
@@ -326,7 +327,7 @@ This endpoint does not need any parameter.
|
||||
|
||||
<a name="updateCurrentUser"></a>
|
||||
# **updateCurrentUser**
|
||||
> updateCurrentUser(body)
|
||||
> Void updateCurrentUser(body)
|
||||
|
||||
Update the password of the current user.
|
||||
|
||||
@@ -361,7 +362,8 @@ clientTokenQuery.setApiKey("YOUR API KEY");
|
||||
UserApi apiInstance = new UserApi();
|
||||
UserPass body = new UserPass(); // UserPass | the user
|
||||
try {
|
||||
apiInstance.updateCurrentUser(body);
|
||||
Void result = apiInstance.updateCurrentUser(body);
|
||||
System.out.println(result);
|
||||
} catch (ApiException e) {
|
||||
System.err.println("Exception when calling UserApi#updateCurrentUser");
|
||||
e.printStackTrace();
|
||||
@@ -376,7 +378,7 @@ Name | Type | Description | Notes
|
||||
|
||||
### Return type
|
||||
|
||||
null (empty response body)
|
||||
[**Void**](.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ All URIs are relative to *http://localhost*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**getVersion**](VersionApi.md#getVersion) | **GET** /version | Get version information.
|
||||
[**getVersion**](VersionApi.md#getVersion) | **GET** version | Get version information.
|
||||
|
||||
|
||||
<a name="getVersion"></a>
|
||||
|
||||
@@ -194,19 +194,24 @@
|
||||
<version>${swagger-core-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>${okhttp-version}</version>
|
||||
<groupId>com.squareup.retrofit2</groupId>
|
||||
<artifactId>converter-gson</artifactId>
|
||||
<version>${retrofit-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp</groupId>
|
||||
<artifactId>logging-interceptor</artifactId>
|
||||
<version>${okhttp-version}</version>
|
||||
<groupId>com.squareup.retrofit2</groupId>
|
||||
<artifactId>retrofit</artifactId>
|
||||
<version>${retrofit-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>${gson-version}</version>
|
||||
<groupId>com.squareup.retrofit2</groupId>
|
||||
<artifactId>converter-scalars</artifactId>
|
||||
<version>${retrofit-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.oltu.oauth2</groupId>
|
||||
<artifactId>org.apache.oltu.oauth2.client</artifactId>
|
||||
<version>${oltu-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.gsonfire</groupId>
|
||||
@@ -218,6 +223,9 @@
|
||||
<artifactId>threetenbp</artifactId>
|
||||
<version>${threetenbp-version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- test dependencies -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
@@ -227,16 +235,15 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>1.7</java.version>
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||
<gson-fire-version>1.8.0</gson-fire-version>
|
||||
<swagger-core-version>1.5.15</swagger-core-version>
|
||||
<okhttp-version>2.7.5</okhttp-version>
|
||||
<gson-version>2.8.1</gson-version>
|
||||
<retrofit-version>2.3.0</retrofit-version>
|
||||
<threetenbp-version>1.3.5</threetenbp-version>
|
||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||
<oltu-version>1.0.1</oltu-version>
|
||||
<junit-version>4.12</junit-version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
</project>
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
rootProject.name = "swagger-java-client"
|
||||
@@ -1,3 +0,0 @@
|
||||
<manifest package="com.github.gotify.client" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<application />
|
||||
</manifest>
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Gotify REST-API.
|
||||
* This is the documentation of the Gotify REST-API. # Authentication In Gotify there are two token types: __clientToken__: a client is something that receives message and manages stuff like creating new tokens or delete messages. (f.ex this token should be used for an android app) __appToken__: an application is something that sends messages (f.ex. this token should be used for a shell script) The token can be either transmitted through a header named `X-Gotify-Key` or a query parameter named `token`. There is also the possibility to authenticate through basic auth, this should only be used for creating a clientToken. \\--- Found a bug or have some questions? [Create an issue on GitHub](https://github.com/gotify/server/issues)
|
||||
*
|
||||
* OpenAPI spec version: 1.0.4
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package com.github.gotify.client;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Callback for asynchronous API call.
|
||||
*
|
||||
* @param <T> The return type
|
||||
*/
|
||||
public interface ApiCallback<T> {
|
||||
/**
|
||||
* This is called when the API call fails.
|
||||
*
|
||||
* @param e The exception causing the failure
|
||||
* @param statusCode Status code of the response if available, otherwise it would be 0
|
||||
* @param responseHeaders Headers of the response if available, otherwise it would be null
|
||||
*/
|
||||
void onFailure(ApiException e, int statusCode, Map<String, List<String>> responseHeaders);
|
||||
|
||||
/**
|
||||
* This is called when the API call succeeded.
|
||||
*
|
||||
* @param result The result deserialized from response
|
||||
* @param statusCode Status code of the response
|
||||
* @param responseHeaders Headers of the response
|
||||
*/
|
||||
void onSuccess(T result, int statusCode, Map<String, List<String>> responseHeaders);
|
||||
|
||||
/**
|
||||
* This is called when the API upload processing.
|
||||
*
|
||||
* @param bytesWritten bytes Written
|
||||
* @param contentLength content length of request body
|
||||
* @param done write end
|
||||
*/
|
||||
void onUploadProgress(long bytesWritten, long contentLength, boolean done);
|
||||
|
||||
/**
|
||||
* This is called when the API downlond processing.
|
||||
*
|
||||
* @param bytesRead bytes Read
|
||||
* @param contentLength content lenngth of the response
|
||||
* @param done Read end
|
||||
*/
|
||||
void onDownloadProgress(long bytesRead, long contentLength, boolean done);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
* Gotify REST-API.
|
||||
* This is the documentation of the Gotify REST-API. # Authentication In Gotify there are two token types: __clientToken__: a client is something that receives message and manages stuff like creating new tokens or delete messages. (f.ex this token should be used for an android app) __appToken__: an application is something that sends messages (f.ex. this token should be used for a shell script) The token can be either transmitted through a header named `X-Gotify-Key` or a query parameter named `token`. There is also the possibility to authenticate through basic auth, this should only be used for creating a clientToken. \\--- Found a bug or have some questions? [Create an issue on GitHub](https://github.com/gotify/server/issues)
|
||||
*
|
||||
* OpenAPI spec version: 1.0.4
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package com.github.gotify.client;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-10-27T16:51:12.097+02:00")
|
||||
public class ApiException extends Exception {
|
||||
private int code = 0;
|
||||
private Map<String, List<String>> responseHeaders = null;
|
||||
private String responseBody = null;
|
||||
|
||||
public ApiException() {}
|
||||
|
||||
public ApiException(Throwable throwable) {
|
||||
super(throwable);
|
||||
}
|
||||
|
||||
public ApiException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ApiException(String message, Throwable throwable, int code, Map<String, List<String>> responseHeaders, String responseBody) {
|
||||
super(message, throwable);
|
||||
this.code = code;
|
||||
this.responseHeaders = responseHeaders;
|
||||
this.responseBody = responseBody;
|
||||
}
|
||||
|
||||
public ApiException(String message, int code, Map<String, List<String>> responseHeaders, String responseBody) {
|
||||
this(message, (Throwable) null, code, responseHeaders, responseBody);
|
||||
}
|
||||
|
||||
public ApiException(String message, Throwable throwable, int code, Map<String, List<String>> responseHeaders) {
|
||||
this(message, throwable, code, responseHeaders, null);
|
||||
}
|
||||
|
||||
public ApiException(int code, Map<String, List<String>> responseHeaders, String responseBody) {
|
||||
this((String) null, (Throwable) null, code, responseHeaders, responseBody);
|
||||
}
|
||||
|
||||
public ApiException(int code, String message) {
|
||||
super(message);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public ApiException(int code, String message, Map<String, List<String>> responseHeaders, String responseBody) {
|
||||
this(code, message);
|
||||
this.responseHeaders = responseHeaders;
|
||||
this.responseBody = responseBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTTP status code.
|
||||
*
|
||||
* @return HTTP status code
|
||||
*/
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTTP response headers.
|
||||
*
|
||||
* @return A map of list of string
|
||||
*/
|
||||
public Map<String, List<String>> getResponseHeaders() {
|
||||
return responseHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTTP response body.
|
||||
*
|
||||
* @return Response body in the form of string
|
||||
*/
|
||||
public String getResponseBody() {
|
||||
return responseBody;
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Gotify REST-API.
|
||||
* This is the documentation of the Gotify REST-API. # Authentication In Gotify there are two token types: __clientToken__: a client is something that receives message and manages stuff like creating new tokens or delete messages. (f.ex this token should be used for an android app) __appToken__: an application is something that sends messages (f.ex. this token should be used for a shell script) The token can be either transmitted through a header named `X-Gotify-Key` or a query parameter named `token`. There is also the possibility to authenticate through basic auth, this should only be used for creating a clientToken. \\--- Found a bug or have some questions? [Create an issue on GitHub](https://github.com/gotify/server/issues)
|
||||
*
|
||||
* OpenAPI spec version: 1.0.4
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package com.github.gotify.client;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* API response returned by API call.
|
||||
*
|
||||
* @param <T> The type of data that is deserialized from response body
|
||||
*/
|
||||
public class ApiResponse<T> {
|
||||
final private int statusCode;
|
||||
final private Map<String, List<String>> headers;
|
||||
final private T data;
|
||||
|
||||
/**
|
||||
* @param statusCode The status code of HTTP response
|
||||
* @param headers The headers of HTTP response
|
||||
*/
|
||||
public ApiResponse(int statusCode, Map<String, List<String>> headers) {
|
||||
this(statusCode, headers, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param statusCode The status code of HTTP response
|
||||
* @param headers The headers of HTTP response
|
||||
* @param data The object deserialized from response bod
|
||||
*/
|
||||
public ApiResponse(int statusCode, Map<String, List<String>> headers, T data) {
|
||||
this.statusCode = statusCode;
|
||||
this.headers = headers;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public int getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getHeaders() {
|
||||
return headers;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.github.gotify.client;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class CollectionFormats {
|
||||
|
||||
public static class CSVParams {
|
||||
|
||||
protected List<String> params;
|
||||
|
||||
public CSVParams() {
|
||||
}
|
||||
|
||||
public CSVParams(List<String> params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
public CSVParams(String... params) {
|
||||
this.params = Arrays.asList(params);
|
||||
}
|
||||
|
||||
public List<String> getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public void setParams(List<String> params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return StringUtil.join(params.toArray(new String[0]), ",");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class SSVParams extends CSVParams {
|
||||
|
||||
public SSVParams() {
|
||||
}
|
||||
|
||||
public SSVParams(List<String> params) {
|
||||
super(params);
|
||||
}
|
||||
|
||||
public SSVParams(String... params) {
|
||||
super(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return StringUtil.join(params.toArray(new String[0]), " ");
|
||||
}
|
||||
}
|
||||
|
||||
public static class TSVParams extends CSVParams {
|
||||
|
||||
public TSVParams() {
|
||||
}
|
||||
|
||||
public TSVParams(List<String> params) {
|
||||
super(params);
|
||||
}
|
||||
|
||||
public TSVParams(String... params) {
|
||||
super(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return StringUtil.join( params.toArray(new String[0]), "\t");
|
||||
}
|
||||
}
|
||||
|
||||
public static class PIPESParams extends CSVParams {
|
||||
|
||||
public PIPESParams() {
|
||||
}
|
||||
|
||||
public PIPESParams(List<String> params) {
|
||||
super(params);
|
||||
}
|
||||
|
||||
public PIPESParams(String... params) {
|
||||
super(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return StringUtil.join(params.toArray(new String[0]), "|");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Gotify REST-API.
|
||||
* This is the documentation of the Gotify REST-API. # Authentication In Gotify there are two token types: __clientToken__: a client is something that receives message and manages stuff like creating new tokens or delete messages. (f.ex this token should be used for an android app) __appToken__: an application is something that sends messages (f.ex. this token should be used for a shell script) The token can be either transmitted through a header named `X-Gotify-Key` or a query parameter named `token`. There is also the possibility to authenticate through basic auth, this should only be used for creating a clientToken. \\--- Found a bug or have some questions? [Create an issue on GitHub](https://github.com/gotify/server/issues)
|
||||
*
|
||||
* OpenAPI spec version: 1.0.4
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package com.github.gotify.client;
|
||||
|
||||
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-10-27T16:51:12.097+02:00")
|
||||
public class Configuration {
|
||||
private static ApiClient defaultApiClient = new ApiClient();
|
||||
|
||||
/**
|
||||
* Get the default API client, which would be used when creating API
|
||||
* instances without providing an API client.
|
||||
*
|
||||
* @return Default API client
|
||||
*/
|
||||
public static ApiClient getDefaultApiClient() {
|
||||
return defaultApiClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default API client, which would be used when creating API
|
||||
* instances without providing an API client.
|
||||
*
|
||||
* @param apiClient API client
|
||||
*/
|
||||
public static void setDefaultApiClient(ApiClient apiClient) {
|
||||
defaultApiClient = apiClient;
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
* Gotify REST-API.
|
||||
* This is the documentation of the Gotify REST-API. # Authentication In Gotify there are two token types: __clientToken__: a client is something that receives message and manages stuff like creating new tokens or delete messages. (f.ex this token should be used for an android app) __appToken__: an application is something that sends messages (f.ex. this token should be used for a shell script) The token can be either transmitted through a header named `X-Gotify-Key` or a query parameter named `token`. There is also the possibility to authenticate through basic auth, this should only be used for creating a clientToken. \\--- Found a bug or have some questions? [Create an issue on GitHub](https://github.com/gotify/server/issues)
|
||||
*
|
||||
* OpenAPI spec version: 1.0.4
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package com.github.gotify.client;
|
||||
|
||||
import com.squareup.okhttp.*;
|
||||
import okio.Buffer;
|
||||
import okio.BufferedSink;
|
||||
import okio.GzipSink;
|
||||
import okio.Okio;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Encodes request bodies using gzip.
|
||||
*
|
||||
* Taken from https://github.com/square/okhttp/issues/350
|
||||
*/
|
||||
class GzipRequestInterceptor implements Interceptor {
|
||||
@Override public Response intercept(Chain chain) throws IOException {
|
||||
Request originalRequest = chain.request();
|
||||
if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) {
|
||||
return chain.proceed(originalRequest);
|
||||
}
|
||||
|
||||
Request compressedRequest = originalRequest.newBuilder()
|
||||
.header("Content-Encoding", "gzip")
|
||||
.method(originalRequest.method(), forceContentLength(gzip(originalRequest.body())))
|
||||
.build();
|
||||
return chain.proceed(compressedRequest);
|
||||
}
|
||||
|
||||
private RequestBody forceContentLength(final RequestBody requestBody) throws IOException {
|
||||
final Buffer buffer = new Buffer();
|
||||
requestBody.writeTo(buffer);
|
||||
return new RequestBody() {
|
||||
@Override
|
||||
public MediaType contentType() {
|
||||
return requestBody.contentType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long contentLength() {
|
||||
return buffer.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(BufferedSink sink) throws IOException {
|
||||
sink.write(buffer.snapshot());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private RequestBody gzip(final RequestBody body) {
|
||||
return new RequestBody() {
|
||||
@Override public MediaType contentType() {
|
||||
return body.contentType();
|
||||
}
|
||||
|
||||
@Override public long contentLength() {
|
||||
return -1; // We don't know the compressed length in advance!
|
||||
}
|
||||
|
||||
@Override public void writeTo(BufferedSink sink) throws IOException {
|
||||
BufferedSink gzipSink = Okio.buffer(new GzipSink(sink));
|
||||
body.writeTo(gzipSink);
|
||||
gzipSink.close();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,6 @@ import java.util.HashMap;
|
||||
|
||||
public class JSON {
|
||||
private Gson gson;
|
||||
private boolean isLenientOnJson = false;
|
||||
private DateTypeAdapter dateTypeAdapter = new DateTypeAdapter();
|
||||
private SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter();
|
||||
private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter();
|
||||
@@ -98,49 +97,6 @@ public class JSON {
|
||||
return this;
|
||||
}
|
||||
|
||||
public JSON setLenientOnJson(boolean lenientOnJson) {
|
||||
isLenientOnJson = lenientOnJson;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the given Java object into JSON string.
|
||||
*
|
||||
* @param obj Object
|
||||
* @return String representation of the JSON
|
||||
*/
|
||||
public String serialize(Object obj) {
|
||||
return gson.toJson(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserialize the given JSON string to Java object.
|
||||
*
|
||||
* @param <T> Type
|
||||
* @param body The JSON string
|
||||
* @param returnType The type to deserialize into
|
||||
* @return The deserialized Java object
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T deserialize(String body, Type returnType) {
|
||||
try {
|
||||
if (isLenientOnJson) {
|
||||
JsonReader jsonReader = new JsonReader(new StringReader(body));
|
||||
// see https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/stream/JsonReader.html#setLenient(boolean)
|
||||
jsonReader.setLenient(true);
|
||||
return gson.fromJson(jsonReader, returnType);
|
||||
} else {
|
||||
return gson.fromJson(body, returnType);
|
||||
}
|
||||
} catch (JsonParseException e) {
|
||||
// Fallback processing when failed to parse JSON form response body:
|
||||
// return the response body string directly for the String return type;
|
||||
if (returnType.equals(String.class))
|
||||
return (T) body;
|
||||
else throw (e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gson TypeAdapter for JSR310 OffsetDateTime type
|
||||
*/
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Gotify REST-API.
|
||||
* This is the documentation of the Gotify REST-API. # Authentication In Gotify there are two token types: __clientToken__: a client is something that receives message and manages stuff like creating new tokens or delete messages. (f.ex this token should be used for an android app) __appToken__: an application is something that sends messages (f.ex. this token should be used for a shell script) The token can be either transmitted through a header named `X-Gotify-Key` or a query parameter named `token`. There is also the possibility to authenticate through basic auth, this should only be used for creating a clientToken. \\--- Found a bug or have some questions? [Create an issue on GitHub](https://github.com/gotify/server/issues)
|
||||
*
|
||||
* OpenAPI spec version: 1.0.4
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package com.github.gotify.client;
|
||||
|
||||
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-10-27T16:51:12.097+02:00")
|
||||
public class Pair {
|
||||
private String name = "";
|
||||
private String value = "";
|
||||
|
||||
public Pair (String name, String value) {
|
||||
setName(name);
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
private void setName(String name) {
|
||||
if (!isValidString(name)) return;
|
||||
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
private void setValue(String value) {
|
||||
if (!isValidString(value)) return;
|
||||
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
private boolean isValidString(String arg) {
|
||||
if (arg == null) return false;
|
||||
if (arg.trim().isEmpty()) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
* Gotify REST-API.
|
||||
* This is the documentation of the Gotify REST-API. # Authentication In Gotify there are two token types: __clientToken__: a client is something that receives message and manages stuff like creating new tokens or delete messages. (f.ex this token should be used for an android app) __appToken__: an application is something that sends messages (f.ex. this token should be used for a shell script) The token can be either transmitted through a header named `X-Gotify-Key` or a query parameter named `token`. There is also the possibility to authenticate through basic auth, this should only be used for creating a clientToken. \\--- Found a bug or have some questions? [Create an issue on GitHub](https://github.com/gotify/server/issues)
|
||||
*
|
||||
* OpenAPI spec version: 1.0.4
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package com.github.gotify.client;
|
||||
|
||||
import com.squareup.okhttp.MediaType;
|
||||
import com.squareup.okhttp.RequestBody;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import okio.Buffer;
|
||||
import okio.BufferedSink;
|
||||
import okio.ForwardingSink;
|
||||
import okio.Okio;
|
||||
import okio.Sink;
|
||||
|
||||
public class ProgressRequestBody extends RequestBody {
|
||||
|
||||
public interface ProgressRequestListener {
|
||||
void onRequestProgress(long bytesWritten, long contentLength, boolean done);
|
||||
}
|
||||
|
||||
private final RequestBody requestBody;
|
||||
|
||||
private final ProgressRequestListener progressListener;
|
||||
|
||||
public ProgressRequestBody(RequestBody requestBody, ProgressRequestListener progressListener) {
|
||||
this.requestBody = requestBody;
|
||||
this.progressListener = progressListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MediaType contentType() {
|
||||
return requestBody.contentType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long contentLength() throws IOException {
|
||||
return requestBody.contentLength();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(BufferedSink sink) throws IOException {
|
||||
BufferedSink bufferedSink = Okio.buffer(sink(sink));
|
||||
requestBody.writeTo(bufferedSink);
|
||||
bufferedSink.flush();
|
||||
}
|
||||
|
||||
private Sink sink(Sink sink) {
|
||||
return new ForwardingSink(sink) {
|
||||
|
||||
long bytesWritten = 0L;
|
||||
long contentLength = 0L;
|
||||
|
||||
@Override
|
||||
public void write(Buffer source, long byteCount) throws IOException {
|
||||
super.write(source, byteCount);
|
||||
if (contentLength == 0) {
|
||||
contentLength = contentLength();
|
||||
}
|
||||
|
||||
bytesWritten += byteCount;
|
||||
progressListener.onRequestProgress(bytesWritten, contentLength, bytesWritten == contentLength);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Gotify REST-API.
|
||||
* This is the documentation of the Gotify REST-API. # Authentication In Gotify there are two token types: __clientToken__: a client is something that receives message and manages stuff like creating new tokens or delete messages. (f.ex this token should be used for an android app) __appToken__: an application is something that sends messages (f.ex. this token should be used for a shell script) The token can be either transmitted through a header named `X-Gotify-Key` or a query parameter named `token`. There is also the possibility to authenticate through basic auth, this should only be used for creating a clientToken. \\--- Found a bug or have some questions? [Create an issue on GitHub](https://github.com/gotify/server/issues)
|
||||
*
|
||||
* OpenAPI spec version: 1.0.4
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package com.github.gotify.client;
|
||||
|
||||
import com.squareup.okhttp.MediaType;
|
||||
import com.squareup.okhttp.ResponseBody;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import okio.Buffer;
|
||||
import okio.BufferedSource;
|
||||
import okio.ForwardingSource;
|
||||
import okio.Okio;
|
||||
import okio.Source;
|
||||
|
||||
public class ProgressResponseBody extends ResponseBody {
|
||||
|
||||
public interface ProgressListener {
|
||||
void update(long bytesRead, long contentLength, boolean done);
|
||||
}
|
||||
|
||||
private final ResponseBody responseBody;
|
||||
private final ProgressListener progressListener;
|
||||
private BufferedSource bufferedSource;
|
||||
|
||||
public ProgressResponseBody(ResponseBody responseBody, ProgressListener progressListener) {
|
||||
this.responseBody = responseBody;
|
||||
this.progressListener = progressListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MediaType contentType() {
|
||||
return responseBody.contentType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long contentLength() throws IOException {
|
||||
return responseBody.contentLength();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BufferedSource source() throws IOException {
|
||||
if (bufferedSource == null) {
|
||||
bufferedSource = Okio.buffer(source(responseBody.source()));
|
||||
}
|
||||
return bufferedSource;
|
||||
}
|
||||
|
||||
private Source source(Source source) {
|
||||
return new ForwardingSource(source) {
|
||||
long totalBytesRead = 0L;
|
||||
|
||||
@Override
|
||||
public long read(Buffer sink, long byteCount) throws IOException {
|
||||
long bytesRead = super.read(sink, byteCount);
|
||||
// read() returns the number of bytes read, or -1 if this source is exhausted.
|
||||
totalBytesRead += bytesRead != -1 ? bytesRead : 0;
|
||||
progressListener.update(totalBytesRead, responseBody.contentLength(), bytesRead == -1);
|
||||
return bytesRead;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
package com.github.gotify.client;
|
||||
|
||||
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-10-27T16:51:12.097+02:00")
|
||||
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-11-12T21:00:23.670+01:00")
|
||||
public class StringUtil {
|
||||
/**
|
||||
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,170 +1,31 @@
|
||||
/*
|
||||
* Gotify REST-API.
|
||||
* This is the documentation of the Gotify REST-API. # Authentication In Gotify there are two token types: __clientToken__: a client is something that receives message and manages stuff like creating new tokens or delete messages. (f.ex this token should be used for an android app) __appToken__: an application is something that sends messages (f.ex. this token should be used for a shell script) The token can be either transmitted through a header named `X-Gotify-Key` or a query parameter named `token`. There is also the possibility to authenticate through basic auth, this should only be used for creating a clientToken. \\--- Found a bug or have some questions? [Create an issue on GitHub](https://github.com/gotify/server/issues)
|
||||
*
|
||||
* OpenAPI spec version: 1.0.4
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package com.github.gotify.client.api;
|
||||
|
||||
import com.github.gotify.client.ApiCallback;
|
||||
import com.github.gotify.client.ApiClient;
|
||||
import com.github.gotify.client.ApiException;
|
||||
import com.github.gotify.client.ApiResponse;
|
||||
import com.github.gotify.client.Configuration;
|
||||
import com.github.gotify.client.Pair;
|
||||
import com.github.gotify.client.ProgressRequestBody;
|
||||
import com.github.gotify.client.ProgressResponseBody;
|
||||
import com.github.gotify.client.CollectionFormats.*;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.io.IOException;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.*;
|
||||
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.ResponseBody;
|
||||
|
||||
import com.github.gotify.client.model.VersionInfo;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class VersionApi {
|
||||
private ApiClient apiClient;
|
||||
public interface VersionApi {
|
||||
/**
|
||||
* Get version information.
|
||||
*
|
||||
* @return Call<VersionInfo>
|
||||
*/
|
||||
@Headers({
|
||||
"Content-Type:application/json"
|
||||
})
|
||||
@GET("version")
|
||||
Call<VersionInfo> getVersion();
|
||||
|
||||
|
||||
public VersionApi() {
|
||||
this(Configuration.getDefaultApiClient());
|
||||
}
|
||||
|
||||
public VersionApi(ApiClient apiClient) {
|
||||
this.apiClient = apiClient;
|
||||
}
|
||||
|
||||
public ApiClient getApiClient() {
|
||||
return apiClient;
|
||||
}
|
||||
|
||||
public void setApiClient(ApiClient apiClient) {
|
||||
this.apiClient = apiClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build call for getVersion
|
||||
* @param progressListener Progress listener
|
||||
* @param progressRequestListener Progress request listener
|
||||
* @return Call to execute
|
||||
* @throws ApiException If fail to serialize the request body object
|
||||
*/
|
||||
public com.squareup.okhttp.Call getVersionCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
Object localVarPostBody = null;
|
||||
|
||||
// create path and map variables
|
||||
String localVarPath = "/version";
|
||||
|
||||
List<Pair> localVarQueryParams = new ArrayList<Pair>();
|
||||
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
|
||||
|
||||
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
|
||||
|
||||
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
|
||||
|
||||
final String[] localVarAccepts = {
|
||||
"application/json"
|
||||
};
|
||||
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
|
||||
if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);
|
||||
|
||||
final String[] localVarContentTypes = {
|
||||
"application/json"
|
||||
};
|
||||
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
|
||||
localVarHeaderParams.put("Content-Type", localVarContentType);
|
||||
|
||||
if(progressListener != null) {
|
||||
apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
|
||||
@Override
|
||||
public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException {
|
||||
com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
|
||||
return originalResponse.newBuilder()
|
||||
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
|
||||
.build();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String[] localVarAuthNames = new String[] { };
|
||||
return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private com.squareup.okhttp.Call getVersionValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
|
||||
|
||||
|
||||
com.squareup.okhttp.Call call = getVersionCall(progressListener, progressRequestListener);
|
||||
return call;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get version information.
|
||||
*
|
||||
* @return VersionInfo
|
||||
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
|
||||
*/
|
||||
public VersionInfo getVersion() throws ApiException {
|
||||
ApiResponse<VersionInfo> resp = getVersionWithHttpInfo();
|
||||
return resp.getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get version information.
|
||||
*
|
||||
* @return ApiResponse<VersionInfo>
|
||||
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
|
||||
*/
|
||||
public ApiResponse<VersionInfo> getVersionWithHttpInfo() throws ApiException {
|
||||
com.squareup.okhttp.Call call = getVersionValidateBeforeCall(null, null);
|
||||
Type localVarReturnType = new TypeToken<VersionInfo>(){}.getType();
|
||||
return apiClient.execute(call, localVarReturnType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get version information. (asynchronously)
|
||||
*
|
||||
* @param callback The callback to be executed when the API call finishes
|
||||
* @return The request call
|
||||
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
|
||||
*/
|
||||
public com.squareup.okhttp.Call getVersionAsync(final ApiCallback<VersionInfo> callback) throws ApiException {
|
||||
|
||||
ProgressResponseBody.ProgressListener progressListener = null;
|
||||
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
|
||||
|
||||
if (callback != null) {
|
||||
progressListener = new ProgressResponseBody.ProgressListener() {
|
||||
@Override
|
||||
public void update(long bytesRead, long contentLength, boolean done) {
|
||||
callback.onDownloadProgress(bytesRead, contentLength, done);
|
||||
}
|
||||
};
|
||||
|
||||
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
|
||||
@Override
|
||||
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
|
||||
callback.onUploadProgress(bytesWritten, contentLength, done);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
com.squareup.okhttp.Call call = getVersionValidateBeforeCall(progressListener, progressRequestListener);
|
||||
Type localVarReturnType = new TypeToken<VersionInfo>(){}.getType();
|
||||
apiClient.executeAsync(call, localVarReturnType, callback);
|
||||
return call;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,75 +1,68 @@
|
||||
/*
|
||||
* Gotify REST-API.
|
||||
* This is the documentation of the Gotify REST-API. # Authentication In Gotify there are two token types: __clientToken__: a client is something that receives message and manages stuff like creating new tokens or delete messages. (f.ex this token should be used for an android app) __appToken__: an application is something that sends messages (f.ex. this token should be used for a shell script) The token can be either transmitted through a header named `X-Gotify-Key` or a query parameter named `token`. There is also the possibility to authenticate through basic auth, this should only be used for creating a clientToken. \\--- Found a bug or have some questions? [Create an issue on GitHub](https://github.com/gotify/server/issues)
|
||||
*
|
||||
* OpenAPI spec version: 1.0.4
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package com.github.gotify.client.auth;
|
||||
|
||||
import com.github.gotify.client.Pair;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-10-27T16:51:12.097+02:00")
|
||||
public class ApiKeyAuth implements Authentication {
|
||||
private final String location;
|
||||
private final String paramName;
|
||||
public class ApiKeyAuth implements Interceptor {
|
||||
private final String location;
|
||||
private final String paramName;
|
||||
|
||||
private String apiKey;
|
||||
private String apiKeyPrefix;
|
||||
private String apiKey;
|
||||
|
||||
public ApiKeyAuth(String location, String paramName) {
|
||||
this.location = location;
|
||||
this.paramName = paramName;
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public String getParamName() {
|
||||
return paramName;
|
||||
}
|
||||
|
||||
public String getApiKey() {
|
||||
return apiKey;
|
||||
}
|
||||
|
||||
public void setApiKey(String apiKey) {
|
||||
this.apiKey = apiKey;
|
||||
}
|
||||
|
||||
public String getApiKeyPrefix() {
|
||||
return apiKeyPrefix;
|
||||
}
|
||||
|
||||
public void setApiKeyPrefix(String apiKeyPrefix) {
|
||||
this.apiKeyPrefix = apiKeyPrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
|
||||
if (apiKey == null) {
|
||||
return;
|
||||
public ApiKeyAuth(String location, String paramName) {
|
||||
this.location = location;
|
||||
this.paramName = paramName;
|
||||
}
|
||||
String value;
|
||||
if (apiKeyPrefix != null) {
|
||||
value = apiKeyPrefix + " " + apiKey;
|
||||
} else {
|
||||
value = apiKey;
|
||||
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
if ("query".equals(location)) {
|
||||
queryParams.add(new Pair(paramName, value));
|
||||
} else if ("header".equals(location)) {
|
||||
headerParams.put(paramName, value);
|
||||
|
||||
public String getParamName() {
|
||||
return paramName;
|
||||
}
|
||||
|
||||
public String getApiKey() {
|
||||
return apiKey;
|
||||
}
|
||||
|
||||
public void setApiKey(String apiKey) {
|
||||
this.apiKey = apiKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response intercept(Chain chain) throws IOException {
|
||||
String paramValue;
|
||||
Request request = chain.request();
|
||||
|
||||
if ("query".equals(location)) {
|
||||
String newQuery = request.url().uri().getQuery();
|
||||
paramValue = paramName + "=" + apiKey;
|
||||
if (newQuery == null) {
|
||||
newQuery = paramValue;
|
||||
} else {
|
||||
newQuery += "&" + paramValue;
|
||||
}
|
||||
|
||||
URI newUri;
|
||||
try {
|
||||
newUri = new URI(request.url().uri().getScheme(), request.url().uri().getAuthority(),
|
||||
request.url().uri().getPath(), newQuery, request.url().uri().getFragment());
|
||||
} catch (URISyntaxException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
|
||||
request = request.newBuilder().url(newUri.toURL()).build();
|
||||
} else if ("header".equals(location)) {
|
||||
request = request.newBuilder()
|
||||
.addHeader(paramName, apiKey)
|
||||
.build();
|
||||
}
|
||||
return chain.proceed(request);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Gotify REST-API.
|
||||
* This is the documentation of the Gotify REST-API. # Authentication In Gotify there are two token types: __clientToken__: a client is something that receives message and manages stuff like creating new tokens or delete messages. (f.ex this token should be used for an android app) __appToken__: an application is something that sends messages (f.ex. this token should be used for a shell script) The token can be either transmitted through a header named `X-Gotify-Key` or a query parameter named `token`. There is also the possibility to authenticate through basic auth, this should only be used for creating a clientToken. \\--- Found a bug or have some questions? [Create an issue on GitHub](https://github.com/gotify/server/issues)
|
||||
*
|
||||
* OpenAPI spec version: 1.0.4
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package com.github.gotify.client.auth;
|
||||
|
||||
import com.github.gotify.client.Pair;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
public interface Authentication {
|
||||
/**
|
||||
* Apply authentication settings to header and query params.
|
||||
*
|
||||
* @param queryParams List of query parameters
|
||||
* @param headerParams Map of header parameters
|
||||
*/
|
||||
void applyToParams(List<Pair> queryParams, Map<String, String> headerParams);
|
||||
}
|
||||
@@ -1,31 +1,18 @@
|
||||
/*
|
||||
* Gotify REST-API.
|
||||
* This is the documentation of the Gotify REST-API. # Authentication In Gotify there are two token types: __clientToken__: a client is something that receives message and manages stuff like creating new tokens or delete messages. (f.ex this token should be used for an android app) __appToken__: an application is something that sends messages (f.ex. this token should be used for a shell script) The token can be either transmitted through a header named `X-Gotify-Key` or a query parameter named `token`. There is also the possibility to authenticate through basic auth, this should only be used for creating a clientToken. \\--- Found a bug or have some questions? [Create an issue on GitHub](https://github.com/gotify/server/issues)
|
||||
*
|
||||
* OpenAPI spec version: 1.0.4
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package com.github.gotify.client.auth;
|
||||
|
||||
import com.github.gotify.client.Pair;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.squareup.okhttp.Credentials;
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.Credentials;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
public class HttpBasicAuth implements Interceptor {
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
public class HttpBasicAuth implements Authentication {
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
@@ -42,13 +29,22 @@ public class HttpBasicAuth implements Authentication {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public void setCredentials(String username, String password) {
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
|
||||
if (username == null && password == null) {
|
||||
return;
|
||||
public Response intercept(Chain chain) throws IOException {
|
||||
Request request = chain.request();
|
||||
|
||||
// If the request already have an authorization (eg. Basic auth), do nothing
|
||||
if (request.header("Authorization") == null) {
|
||||
String credentials = Credentials.basic(username, password);
|
||||
request = request.newBuilder()
|
||||
.addHeader("Authorization", credentials)
|
||||
.build();
|
||||
}
|
||||
headerParams.put("Authorization", Credentials.basic(
|
||||
username == null ? "" : username,
|
||||
password == null ? "" : password));
|
||||
return chain.proceed(request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,39 +1,179 @@
|
||||
/*
|
||||
* Gotify REST-API.
|
||||
* This is the documentation of the Gotify REST-API. # Authentication In Gotify there are two token types: __clientToken__: a client is something that receives message and manages stuff like creating new tokens or delete messages. (f.ex this token should be used for an android app) __appToken__: an application is something that sends messages (f.ex. this token should be used for a shell script) The token can be either transmitted through a header named `X-Gotify-Key` or a query parameter named `token`. There is also the possibility to authenticate through basic auth, this should only be used for creating a clientToken. \\--- Found a bug or have some questions? [Create an issue on GitHub](https://github.com/gotify/server/issues)
|
||||
*
|
||||
* OpenAPI spec version: 1.0.4
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package com.github.gotify.client.auth;
|
||||
|
||||
import com.github.gotify.client.Pair;
|
||||
import static java.net.HttpURLConnection.HTTP_UNAUTHORIZED;
|
||||
import static java.net.HttpURLConnection.HTTP_FORBIDDEN;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-10-27T16:51:12.097+02:00")
|
||||
public class OAuth implements Authentication {
|
||||
private String accessToken;
|
||||
import org.apache.oltu.oauth2.client.OAuthClient;
|
||||
import org.apache.oltu.oauth2.client.request.OAuthBearerClientRequest;
|
||||
import org.apache.oltu.oauth2.client.request.OAuthClientRequest;
|
||||
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder;
|
||||
import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder;
|
||||
import org.apache.oltu.oauth2.client.response.OAuthJSONAccessTokenResponse;
|
||||
import org.apache.oltu.oauth2.common.exception.OAuthProblemException;
|
||||
import org.apache.oltu.oauth2.common.exception.OAuthSystemException;
|
||||
import org.apache.oltu.oauth2.common.message.types.GrantType;
|
||||
import org.apache.oltu.oauth2.common.token.BasicOAuthToken;
|
||||
|
||||
public String getAccessToken() {
|
||||
return accessToken;
|
||||
}
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Request.Builder;
|
||||
import okhttp3.Response;
|
||||
|
||||
public void setAccessToken(String accessToken) {
|
||||
this.accessToken = accessToken;
|
||||
}
|
||||
public class OAuth implements Interceptor {
|
||||
|
||||
@Override
|
||||
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) {
|
||||
if (accessToken != null) {
|
||||
headerParams.put("Authorization", "Bearer " + accessToken);
|
||||
public interface AccessTokenListener {
|
||||
public void notify(BasicOAuthToken token);
|
||||
}
|
||||
}
|
||||
|
||||
private volatile String accessToken;
|
||||
private OAuthClient oauthClient;
|
||||
|
||||
private TokenRequestBuilder tokenRequestBuilder;
|
||||
private AuthenticationRequestBuilder authenticationRequestBuilder;
|
||||
|
||||
private AccessTokenListener accessTokenListener;
|
||||
|
||||
public OAuth( OkHttpClient client, TokenRequestBuilder requestBuilder ) {
|
||||
this.oauthClient = new OAuthClient(new OAuthOkHttpClient(client));
|
||||
this.tokenRequestBuilder = requestBuilder;
|
||||
}
|
||||
|
||||
public OAuth(TokenRequestBuilder requestBuilder ) {
|
||||
this(new OkHttpClient(), requestBuilder);
|
||||
}
|
||||
|
||||
public OAuth(OAuthFlow flow, String authorizationUrl, String tokenUrl, String scopes) {
|
||||
this(OAuthClientRequest.tokenLocation(tokenUrl).setScope(scopes));
|
||||
setFlow(flow);
|
||||
authenticationRequestBuilder = OAuthClientRequest.authorizationLocation(authorizationUrl);
|
||||
}
|
||||
|
||||
public void setFlow(OAuthFlow flow) {
|
||||
switch(flow) {
|
||||
case accessCode:
|
||||
case implicit:
|
||||
tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE);
|
||||
break;
|
||||
case password:
|
||||
tokenRequestBuilder.setGrantType(GrantType.PASSWORD);
|
||||
break;
|
||||
case application:
|
||||
tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response intercept(Chain chain)
|
||||
throws IOException {
|
||||
|
||||
return retryingIntercept(chain, true);
|
||||
}
|
||||
|
||||
private Response retryingIntercept(Chain chain, boolean updateTokenAndRetryOnAuthorizationFailure) throws IOException {
|
||||
Request request = chain.request();
|
||||
|
||||
// If the request already have an authorization (eg. Basic auth), do nothing
|
||||
if (request.header("Authorization") != null) {
|
||||
return chain.proceed(request);
|
||||
}
|
||||
|
||||
// If first time, get the token
|
||||
OAuthClientRequest oAuthRequest;
|
||||
if (getAccessToken() == null) {
|
||||
updateAccessToken(null);
|
||||
}
|
||||
|
||||
if (getAccessToken() != null) {
|
||||
// Build the request
|
||||
Builder rb = request.newBuilder();
|
||||
|
||||
String requestAccessToken = new String(getAccessToken());
|
||||
try {
|
||||
oAuthRequest = new OAuthBearerClientRequest(request.url().toString())
|
||||
.setAccessToken(requestAccessToken)
|
||||
.buildHeaderMessage();
|
||||
} catch (OAuthSystemException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
|
||||
for ( Map.Entry<String, String> header : oAuthRequest.getHeaders().entrySet() ) {
|
||||
rb.addHeader(header.getKey(), header.getValue());
|
||||
}
|
||||
rb.url( oAuthRequest.getLocationUri());
|
||||
|
||||
//Execute the request
|
||||
Response response = chain.proceed(rb.build());
|
||||
|
||||
// 401/403 most likely indicates that access token has expired. Unless it happens two times in a row.
|
||||
if ( response != null && (response.code() == HTTP_UNAUTHORIZED || response.code() == HTTP_FORBIDDEN) && updateTokenAndRetryOnAuthorizationFailure ) {
|
||||
if (updateAccessToken(requestAccessToken)) {
|
||||
return retryingIntercept( chain, false );
|
||||
}
|
||||
}
|
||||
return response;
|
||||
} else {
|
||||
return chain.proceed(chain.request());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns true if the access token has been updated
|
||||
*/
|
||||
public synchronized boolean updateAccessToken(String requestAccessToken) throws IOException {
|
||||
if (getAccessToken() == null || getAccessToken().equals(requestAccessToken)) {
|
||||
try {
|
||||
OAuthJSONAccessTokenResponse accessTokenResponse = oauthClient.accessToken(this.tokenRequestBuilder.buildBodyMessage());
|
||||
if (accessTokenResponse != null && accessTokenResponse.getAccessToken() != null) {
|
||||
setAccessToken(accessTokenResponse.getAccessToken());
|
||||
if (accessTokenListener != null) {
|
||||
accessTokenListener.notify((BasicOAuthToken) accessTokenResponse.getOAuthToken());
|
||||
}
|
||||
return !getAccessToken().equals(requestAccessToken);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (OAuthSystemException e) {
|
||||
throw new IOException(e);
|
||||
} catch (OAuthProblemException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void registerAccessTokenListener(AccessTokenListener accessTokenListener) {
|
||||
this.accessTokenListener = accessTokenListener;
|
||||
}
|
||||
|
||||
public synchronized String getAccessToken() {
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
public synchronized void setAccessToken(String accessToken) {
|
||||
this.accessToken = accessToken;
|
||||
}
|
||||
|
||||
public TokenRequestBuilder getTokenRequestBuilder() {
|
||||
return tokenRequestBuilder;
|
||||
}
|
||||
|
||||
public void setTokenRequestBuilder(TokenRequestBuilder tokenRequestBuilder) {
|
||||
this.tokenRequestBuilder = tokenRequestBuilder;
|
||||
}
|
||||
|
||||
public AuthenticationRequestBuilder getAuthenticationRequestBuilder() {
|
||||
return authenticationRequestBuilder;
|
||||
}
|
||||
|
||||
public void setAuthenticationRequestBuilder(AuthenticationRequestBuilder authenticationRequestBuilder) {
|
||||
this.authenticationRequestBuilder = authenticationRequestBuilder;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.github.gotify.client.auth;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.oltu.oauth2.client.HttpClient;
|
||||
import org.apache.oltu.oauth2.client.request.OAuthClientRequest;
|
||||
import org.apache.oltu.oauth2.client.response.OAuthClientResponse;
|
||||
import org.apache.oltu.oauth2.client.response.OAuthClientResponseFactory;
|
||||
import org.apache.oltu.oauth2.common.exception.OAuthProblemException;
|
||||
import org.apache.oltu.oauth2.common.exception.OAuthSystemException;
|
||||
|
||||
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Request.Builder;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
|
||||
public class OAuthOkHttpClient implements HttpClient {
|
||||
|
||||
private OkHttpClient client;
|
||||
|
||||
public OAuthOkHttpClient() {
|
||||
this.client = new OkHttpClient();
|
||||
}
|
||||
|
||||
public OAuthOkHttpClient(OkHttpClient client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
public <T extends OAuthClientResponse> T execute(OAuthClientRequest request, Map<String, String> headers,
|
||||
String requestMethod, Class<T> responseClass)
|
||||
throws OAuthSystemException, OAuthProblemException {
|
||||
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
Request.Builder requestBuilder = new Request.Builder().url(request.getLocationUri());
|
||||
|
||||
if(headers != null) {
|
||||
for (Entry<String, String> entry : headers.entrySet()) {
|
||||
if (entry.getKey().equalsIgnoreCase("Content-Type")) {
|
||||
mediaType = MediaType.parse(entry.getValue());
|
||||
} else {
|
||||
requestBuilder.addHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RequestBody body = request.getBody() != null ? RequestBody.create(mediaType, request.getBody()) : null;
|
||||
requestBuilder.method(requestMethod, body);
|
||||
|
||||
try {
|
||||
Response response = client.newCall(requestBuilder.build()).execute();
|
||||
return OAuthClientResponseFactory.createCustomResponse(
|
||||
response.body().string(),
|
||||
response.body().contentType().toString(),
|
||||
response.code(),
|
||||
responseClass);
|
||||
} catch (IOException e) {
|
||||
throw new OAuthSystemException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
// Nothing to do here
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,7 +27,7 @@ import java.io.IOException;
|
||||
* The Application holds information about an app which can send notifications.
|
||||
*/
|
||||
@ApiModel(description = "The Application holds information about an app which can send notifications.")
|
||||
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-10-27T16:51:12.097+02:00")
|
||||
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-11-12T21:00:23.670+01:00")
|
||||
public class Application {
|
||||
@SerializedName("description")
|
||||
private String description = null;
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.io.IOException;
|
||||
* The Client holds information about a device which can receive notifications (and other stuff).
|
||||
*/
|
||||
@ApiModel(description = "The Client holds information about a device which can receive notifications (and other stuff).")
|
||||
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-10-27T16:51:12.097+02:00")
|
||||
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-11-12T21:00:23.670+01:00")
|
||||
public class Client {
|
||||
@SerializedName("id")
|
||||
private Integer id = null;
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.io.IOException;
|
||||
* The Error contains error relevant information.
|
||||
*/
|
||||
@ApiModel(description = "The Error contains error relevant information.")
|
||||
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-10-27T16:51:12.097+02:00")
|
||||
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-11-12T21:00:23.670+01:00")
|
||||
public class Error {
|
||||
@SerializedName("error")
|
||||
private String error = null;
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.threeten.bp.OffsetDateTime;
|
||||
* The Message holds information about a message which was sent by an Application.
|
||||
*/
|
||||
@ApiModel(description = "The Message holds information about a message which was sent by an Application.")
|
||||
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-10-27T16:51:12.097+02:00")
|
||||
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-11-12T21:00:23.670+01:00")
|
||||
public class Message {
|
||||
@SerializedName("appid")
|
||||
private Integer appid = null;
|
||||
|
||||
@@ -31,7 +31,7 @@ import java.util.List;
|
||||
* Wrapper for the paging and the messages
|
||||
*/
|
||||
@ApiModel(description = "Wrapper for the paging and the messages")
|
||||
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-10-27T16:51:12.097+02:00")
|
||||
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-11-12T21:00:23.670+01:00")
|
||||
public class PagedMessages {
|
||||
@SerializedName("messages")
|
||||
private List<Message> messages = new ArrayList<Message>();
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.io.IOException;
|
||||
* The Paging holds holds information about the limit and making requests to the next page.
|
||||
*/
|
||||
@ApiModel(description = "The Paging holds holds information about the limit and making requests to the next page.")
|
||||
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-10-27T16:51:12.097+02:00")
|
||||
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-11-12T21:00:23.670+01:00")
|
||||
public class Paging {
|
||||
@SerializedName("limit")
|
||||
private Long limit = null;
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.io.IOException;
|
||||
* The User holds information about permission and other stuff.
|
||||
*/
|
||||
@ApiModel(description = "The User holds information about permission and other stuff.")
|
||||
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-10-27T16:51:12.097+02:00")
|
||||
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-11-12T21:00:23.670+01:00")
|
||||
public class User {
|
||||
@SerializedName("admin")
|
||||
private Boolean admin = null;
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.io.IOException;
|
||||
* The Password for updating the user.
|
||||
*/
|
||||
@ApiModel(description = "The Password for updating the user.")
|
||||
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-10-27T16:51:12.097+02:00")
|
||||
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-11-12T21:00:23.670+01:00")
|
||||
public class UserPass {
|
||||
@SerializedName("pass")
|
||||
private String pass = null;
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.io.IOException;
|
||||
* The UserWithPass holds information about the credentials and other stuff.
|
||||
*/
|
||||
@ApiModel(description = "The UserWithPass holds information about the credentials and other stuff.")
|
||||
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-10-27T16:51:12.097+02:00")
|
||||
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-11-12T21:00:23.670+01:00")
|
||||
public class UserWithPass {
|
||||
@SerializedName("admin")
|
||||
private Boolean admin = null;
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.io.IOException;
|
||||
* VersionInfo Model
|
||||
*/
|
||||
@ApiModel(description = "VersionInfo Model")
|
||||
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-10-27T16:51:12.097+02:00")
|
||||
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-11-12T21:00:23.670+01:00")
|
||||
public class VersionInfo {
|
||||
@SerializedName("buildDate")
|
||||
private String buildDate = null;
|
||||
|
||||
@@ -1,24 +1,11 @@
|
||||
/*
|
||||
* Gotify REST-API.
|
||||
* This is the documentation of the Gotify REST-API. # Authentication In Gotify there are two token types: __clientToken__: a client is something that receives message and manages stuff like creating new tokens or delete messages. (f.ex this token should be used for an android app) __appToken__: an application is something that sends messages (f.ex. this token should be used for a shell script) The token can be either transmitted through a header named `X-Gotify-Key` or a query parameter named `token`. There is also the possibility to authenticate through basic auth, this should only be used for creating a clientToken. \\--- Found a bug or have some questions? [Create an issue on GitHub](https://github.com/gotify/server/issues)
|
||||
*
|
||||
* OpenAPI spec version: 1.0.4
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package com.github.gotify.client.api;
|
||||
|
||||
import com.github.gotify.client.ApiException;
|
||||
import com.github.gotify.client.ApiClient;
|
||||
import com.github.gotify.client.model.Error;
|
||||
import com.github.gotify.client.model.Message;
|
||||
import com.github.gotify.client.model.PagedMessages;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -28,123 +15,98 @@ import java.util.Map;
|
||||
/**
|
||||
* API tests for MessageApi
|
||||
*/
|
||||
@Ignore
|
||||
public class MessageApiTest {
|
||||
|
||||
private final MessageApi api = new MessageApi();
|
||||
private MessageApi api;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
api = new ApiClient().createService(MessageApi.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a message.
|
||||
*
|
||||
* __NOTE__: This API ONLY accepts an application token as authentication.
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void createMessageTest() throws ApiException {
|
||||
public void createMessageTest() {
|
||||
Message body = null;
|
||||
Message response = api.createMessage(body);
|
||||
// Message response = api.createMessage(body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all messages from a specific application.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void deleteAppMessagesTest() throws ApiException {
|
||||
public void deleteAppMessagesTest() {
|
||||
Integer id = null;
|
||||
api.deleteAppMessages(id);
|
||||
// Void response = api.deleteAppMessages(id);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a message with an id.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void deleteMessageTest() throws ApiException {
|
||||
public void deleteMessageTest() {
|
||||
Integer id = null;
|
||||
api.deleteMessage(id);
|
||||
// Void response = api.deleteMessage(id);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all messages.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void deleteMessagesTest() throws ApiException {
|
||||
api.deleteMessages();
|
||||
public void deleteMessagesTest() {
|
||||
// Void response = api.deleteMessages();
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all messages from a specific application.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void getAppMessagesTest() throws ApiException {
|
||||
public void getAppMessagesTest() {
|
||||
Integer id = null;
|
||||
Integer limit = null;
|
||||
Integer since = null;
|
||||
PagedMessages response = api.getAppMessages(id, limit, since);
|
||||
// PagedMessages response = api.getAppMessages(id, limit, since);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all messages.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void getMessagesTest() throws ApiException {
|
||||
public void getMessagesTest() {
|
||||
Integer limit = null;
|
||||
Integer since = null;
|
||||
PagedMessages response = api.getMessages(limit, since);
|
||||
// PagedMessages response = api.getMessages(limit, since);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Websocket, return newly created messages.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void streamMessagesTest() throws ApiException {
|
||||
Message response = api.streamMessages();
|
||||
public void streamMessagesTest() {
|
||||
// Message response = api.streamMessages();
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,25 +1,12 @@
|
||||
/*
|
||||
* Gotify REST-API.
|
||||
* This is the documentation of the Gotify REST-API. # Authentication In Gotify there are two token types: __clientToken__: a client is something that receives message and manages stuff like creating new tokens or delete messages. (f.ex this token should be used for an android app) __appToken__: an application is something that sends messages (f.ex. this token should be used for a shell script) The token can be either transmitted through a header named `X-Gotify-Key` or a query parameter named `token`. There is also the possibility to authenticate through basic auth, this should only be used for creating a clientToken. \\--- Found a bug or have some questions? [Create an issue on GitHub](https://github.com/gotify/server/issues)
|
||||
*
|
||||
* OpenAPI spec version: 1.0.4
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package com.github.gotify.client.api;
|
||||
|
||||
import com.github.gotify.client.ApiException;
|
||||
import com.github.gotify.client.ApiClient;
|
||||
import com.github.gotify.client.model.Application;
|
||||
import com.github.gotify.client.model.Client;
|
||||
import com.github.gotify.client.model.Error;
|
||||
import java.io.File;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -29,121 +16,96 @@ import java.util.Map;
|
||||
/**
|
||||
* API tests for TokenApi
|
||||
*/
|
||||
@Ignore
|
||||
public class TokenApiTest {
|
||||
|
||||
private final TokenApi api = new TokenApi();
|
||||
private TokenApi api;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
api = new ApiClient().createService(TokenApi.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create an application.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void createAppTest() throws ApiException {
|
||||
public void createAppTest() {
|
||||
Application body = null;
|
||||
Application response = api.createApp(body);
|
||||
// Application response = api.createApp(body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a client.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void createClientTest() throws ApiException {
|
||||
public void createClientTest() {
|
||||
Client body = null;
|
||||
Client response = api.createClient(body);
|
||||
// Client response = api.createClient(body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an application.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void deleteAppTest() throws ApiException {
|
||||
public void deleteAppTest() {
|
||||
Integer id = null;
|
||||
api.deleteApp(id);
|
||||
// Void response = api.deleteApp(id);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a client.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void deleteClientTest() throws ApiException {
|
||||
public void deleteClientTest() {
|
||||
Integer id = null;
|
||||
api.deleteClient(id);
|
||||
// Void response = api.deleteClient(id);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all applications.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void getAppsTest() throws ApiException {
|
||||
List<Application> response = api.getApps();
|
||||
public void getAppsTest() {
|
||||
// List<Application> response = api.getApps();
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all clients.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void getClientsTest() throws ApiException {
|
||||
List<Client> response = api.getClients();
|
||||
public void getClientsTest() {
|
||||
// List<Client> response = api.getClients();
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Upload an image for an application
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void uploadAppImageTest() throws ApiException {
|
||||
public void uploadAppImageTest() {
|
||||
File file = null;
|
||||
Integer id = null;
|
||||
Application response = api.uploadAppImage(file, id);
|
||||
// Application response = api.uploadAppImage(file, id);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,25 +1,12 @@
|
||||
/*
|
||||
* Gotify REST-API.
|
||||
* This is the documentation of the Gotify REST-API. # Authentication In Gotify there are two token types: __clientToken__: a client is something that receives message and manages stuff like creating new tokens or delete messages. (f.ex this token should be used for an android app) __appToken__: an application is something that sends messages (f.ex. this token should be used for a shell script) The token can be either transmitted through a header named `X-Gotify-Key` or a query parameter named `token`. There is also the possibility to authenticate through basic auth, this should only be used for creating a clientToken. \\--- Found a bug or have some questions? [Create an issue on GitHub](https://github.com/gotify/server/issues)
|
||||
*
|
||||
* OpenAPI spec version: 1.0.4
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package com.github.gotify.client.api;
|
||||
|
||||
import com.github.gotify.client.ApiException;
|
||||
import com.github.gotify.client.ApiClient;
|
||||
import com.github.gotify.client.model.Error;
|
||||
import com.github.gotify.client.model.User;
|
||||
import com.github.gotify.client.model.UserPass;
|
||||
import com.github.gotify.client.model.UserWithPass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -29,121 +16,96 @@ import java.util.Map;
|
||||
/**
|
||||
* API tests for UserApi
|
||||
*/
|
||||
@Ignore
|
||||
public class UserApiTest {
|
||||
|
||||
private final UserApi api = new UserApi();
|
||||
private UserApi api;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
api = new ApiClient().createService(UserApi.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a user.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void createUserTest() throws ApiException {
|
||||
public void createUserTest() {
|
||||
UserWithPass body = null;
|
||||
User response = api.createUser(body);
|
||||
// User response = api.createUser(body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current user.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void currentUserTest() throws ApiException {
|
||||
User response = api.currentUser();
|
||||
public void currentUserTest() {
|
||||
// User response = api.currentUser();
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a user.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void deleteUserTest() throws ApiException {
|
||||
public void deleteUserTest() {
|
||||
Integer id = null;
|
||||
api.deleteUser(id);
|
||||
// Void response = api.deleteUser(id);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a user.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void getUserTest() throws ApiException {
|
||||
public void getUserTest() {
|
||||
Integer id = null;
|
||||
User response = api.getUser(id);
|
||||
// User response = api.getUser(id);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all users.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void getUsersTest() throws ApiException {
|
||||
List<User> response = api.getUsers();
|
||||
public void getUsersTest() {
|
||||
// List<User> response = api.getUsers();
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the password of the current user.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void updateCurrentUserTest() throws ApiException {
|
||||
public void updateCurrentUserTest() {
|
||||
UserPass body = null;
|
||||
api.updateCurrentUser(body);
|
||||
// Void response = api.updateCurrentUser(body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a user.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void updateUserTest() throws ApiException {
|
||||
public void updateUserTest() {
|
||||
Integer id = null;
|
||||
UserWithPass body = null;
|
||||
User response = api.updateUser(id, body);
|
||||
// User response = api.updateUser(id, body);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,22 +1,9 @@
|
||||
/*
|
||||
* Gotify REST-API.
|
||||
* This is the documentation of the Gotify REST-API. # Authentication In Gotify there are two token types: __clientToken__: a client is something that receives message and manages stuff like creating new tokens or delete messages. (f.ex this token should be used for an android app) __appToken__: an application is something that sends messages (f.ex. this token should be used for a shell script) The token can be either transmitted through a header named `X-Gotify-Key` or a query parameter named `token`. There is also the possibility to authenticate through basic auth, this should only be used for creating a clientToken. \\--- Found a bug or have some questions? [Create an issue on GitHub](https://github.com/gotify/server/issues)
|
||||
*
|
||||
* OpenAPI spec version: 1.0.4
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package com.github.gotify.client.api;
|
||||
|
||||
import com.github.gotify.client.ApiException;
|
||||
import com.github.gotify.client.ApiClient;
|
||||
import com.github.gotify.client.model.VersionInfo;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -26,25 +13,24 @@ import java.util.Map;
|
||||
/**
|
||||
* API tests for VersionApi
|
||||
*/
|
||||
@Ignore
|
||||
public class VersionApiTest {
|
||||
|
||||
private final VersionApi api = new VersionApi();
|
||||
private VersionApi api;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
api = new ApiClient().createService(VersionApi.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get version information.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
public void getVersionTest() throws ApiException {
|
||||
VersionInfo response = api.getVersion();
|
||||
public void getVersionTest() {
|
||||
// VersionInfo response = api.getVersion();
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"apiPackage": "com.github.gotify.client.api",
|
||||
"modelPackage": "com.github.gotify.client.model"
|
||||
"modelPackage": "com.github.gotify.client.model",
|
||||
"library": "retrofit2"
|
||||
}
|
||||
Reference in New Issue
Block a user