swagger-java-client
Requirements
Building the API client library requires Maven to be installed.
Installation
To install the API client library to your local Maven repository, simply execute:
mvn install
To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:
mvn deploy
Refer to the official documentation for more information.
Maven users
Add this dependency to your project's POM:
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-java-client</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
Gradle users
Add this dependency to your project's build file:
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 instruction and execute the following Java code:
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 | POST /message | Create a message. |
| MessageApi | deleteAppMessages | DELETE /application/{id}/message | Delete all messages from a specific application. |
| MessageApi | deleteMessage | DELETE /message/{id} | Deletes a message with an id. |
| MessageApi | deleteMessages | DELETE /message | Delete all messages. |
| MessageApi | getAppMessages | GET /application/{id}/message | Return all messages from a specific application. |
| MessageApi | getMessages | GET /message | Return all messages. |
| MessageApi | streamMessages | GET /stream | Websocket, return newly created messages. |
| TokenApi | createApp | POST /application | Create an application. |
| TokenApi | createClient | POST /client | Create a client. |
| TokenApi | deleteApp | DELETE /application/{id} | Delete an application. |
| TokenApi | deleteClient | DELETE /client/{id} | Delete a client. |
| TokenApi | getApps | GET /application | Return all applications. |
| TokenApi | getClients | GET /client | Return all clients. |
| TokenApi | uploadAppImage | POST /application/{id}/image | |
| UserApi | createUser | POST /user | Create a user. |
| UserApi | currentUser | GET /current/user | Return the current user. |
| UserApi | deleteUser | DELETE /user/{id} | Deletes a user. |
| UserApi | getUser | GET /user/{id} | Get a user. |
| UserApi | getUsers | GET /user | Return all users. |
| UserApi | updateCurrentUser | POST /current/user/password | Update the password of the current user. |
| UserApi | updateUser | POST /user/{id} | Update a user. |
| VersionApi | getVersion | GET /version | Get version information. |
Documentation for Models
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.