mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Added Java BETA SDK
This commit is contained in:
@@ -0,0 +1,149 @@
|
||||
package ;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.CookieJar;
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.FormBody;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.util.Map.entry;
|
||||
|
||||
public class Client {
|
||||
private final OkHttpClient http;
|
||||
private final Map<String, String> headers;
|
||||
private final Map<String, String> config;
|
||||
private String endPoint;
|
||||
private boolean selfSigned;
|
||||
private CookieJar cookieJar = CookieJar.NO_COOKIES;
|
||||
|
||||
public Client() {
|
||||
this("https://appwrite.io/v1", false, new OkHttpClient());
|
||||
}
|
||||
|
||||
public Client(String endPoint, boolean selfSigned, OkHttpClient http) {
|
||||
this.endPoint = endPoint;
|
||||
this.selfSigned = selfSigned;
|
||||
this.headers = new HashMap<>(Map.ofEntries(
|
||||
entry("content-type", "application/json"),
|
||||
entry("x-sdk-version", "appwrite:java:0.0.1")
|
||||
));
|
||||
this.config = new HashMap<>();
|
||||
this.http = http.newBuilder()
|
||||
.cookieJar(cookieJar)
|
||||
.build();
|
||||
}
|
||||
|
||||
public String getEndPoint(){
|
||||
return endPoint;
|
||||
}
|
||||
|
||||
public Map<String, String> getConfig(){
|
||||
return config;
|
||||
}
|
||||
|
||||
// private Future<Directory> getCookiePath() {
|
||||
// final directory = getApplicationDocumentsDirectory();
|
||||
// final path = directory.path;
|
||||
// final Directory dir = new Directory("$path/cookies");
|
||||
// dir.create();
|
||||
// return dir;
|
||||
// }
|
||||
|
||||
/// Your project ID
|
||||
public Client setProject(String value) {
|
||||
config.put("project", value);
|
||||
addHeader("X-Appwrite-Project", value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// Your secret API key
|
||||
public Client setKey(String value) {
|
||||
config.put("key", value);
|
||||
addHeader("X-Appwrite-Key", value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Client setLocale(String value) {
|
||||
config.put("locale", value);
|
||||
addHeader("X-Appwrite-Locale", value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Client setMode(String value) {
|
||||
config.put("mode", value);
|
||||
addHeader("X-Appwrite-Mode", value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Client setSelfSigned(boolean status) {
|
||||
selfSigned = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Client setEndpoint(String endPoint) {
|
||||
this.endPoint = endPoint;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Client addHeader(String key, String value) {
|
||||
headers.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Call call(String method, String path, Map<String, String> headers, Map<String, Object> params) {
|
||||
if(selfSigned) {
|
||||
// Allow self signed requests
|
||||
|
||||
}
|
||||
|
||||
Headers requestHeaders = Headers.of(this.headers).newBuilder()
|
||||
.addAll(Headers.of(headers))
|
||||
.build();
|
||||
|
||||
HttpUrl.Builder httpBuilder = HttpUrl.get(endPoint + path).newBuilder();
|
||||
if("GET".equals(method)) {
|
||||
params.forEach((k, v) -> {
|
||||
if(v instanceof List){
|
||||
httpBuilder.addQueryParameter(k+"[]", v.toString());
|
||||
}else{
|
||||
httpBuilder.addQueryParameter(k, v.toString());
|
||||
}
|
||||
});
|
||||
Request request = new Request.Builder()
|
||||
.url(httpBuilder.build())
|
||||
.headers(requestHeaders)
|
||||
.get()
|
||||
.build();
|
||||
|
||||
return http.newCall(request);
|
||||
}
|
||||
|
||||
RequestBody body;
|
||||
if("multipart/form-data".equals(headers.get("content-type"))) {
|
||||
FormBody.Builder builder = new FormBody.Builder();
|
||||
params.forEach((k, v) -> builder.add(k, v.toString()));
|
||||
body = builder.build();
|
||||
} else {
|
||||
Gson gson = new Gson();
|
||||
String json = gson.toJson(params);
|
||||
body = RequestBody.create(json, MediaType.get("application/json"));
|
||||
}
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(httpBuilder.build())
|
||||
.headers(requestHeaders)
|
||||
.method(method, body)
|
||||
.build();
|
||||
|
||||
return http.newCall(request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package .enums;
|
||||
|
||||
public enum OrderType {
|
||||
ASC, DESC
|
||||
}
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
package .services;
|
||||
|
||||
|
||||
|
||||
import okhttp3.Call;
|
||||
import .Client;
|
||||
import .enums.OrderType;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.util.Map.entry;
|
||||
|
||||
public class Avatars extends Service {
|
||||
public Avatars(Client client){
|
||||
super(client);
|
||||
}
|
||||
|
||||
/// Get Browser Icon
|
||||
/*
|
||||
* You can use this endpoint to show different browser icons to your users.
|
||||
* The code argument receives the browser code as it appears in your user
|
||||
* /account/sessions endpoint. Use width, height and quality arguments to
|
||||
* change the output settings.
|
||||
*/
|
||||
public Call getBrowser(String code, int width, int height, int quality) {
|
||||
final String path = "/avatars/browsers/{code}".replace("{code}", code);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
entry("width", width),
|
||||
entry("height", height),
|
||||
entry("quality", quality)
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// Get Credit Card Icon
|
||||
/*
|
||||
* Need to display your users with your billing method or their payment
|
||||
* methods? The credit card endpoint will return you the icon of the credit
|
||||
* card provider you need. Use width, height and quality arguments to change
|
||||
* the output settings.
|
||||
*/
|
||||
public Call getCreditCard(String code, int width, int height, int quality) {
|
||||
final String path = "/avatars/credit-cards/{code}".replace("{code}", code);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
entry("width", width),
|
||||
entry("height", height),
|
||||
entry("quality", quality)
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// Get Favicon
|
||||
/*
|
||||
* Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote
|
||||
* website URL.
|
||||
*/
|
||||
public Call getFavicon(String url) {
|
||||
final String path = "/avatars/favicon";
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
entry("url", url)
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// Get Country Flag
|
||||
/*
|
||||
* You can use this endpoint to show different country flags icons to your
|
||||
* users. The code argument receives the 2 letter country code. Use width,
|
||||
* height and quality arguments to change the output settings.
|
||||
*/
|
||||
public Call getFlag(String code, int width, int height, int quality) {
|
||||
final String path = "/avatars/flags/{code}".replace("{code}", code);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
entry("width", width),
|
||||
entry("height", height),
|
||||
entry("quality", quality)
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// Get Image from URL
|
||||
/*
|
||||
* Use this endpoint to fetch a remote image URL and crop it to any image size
|
||||
* you want. This endpoint is very useful if you need to crop and display
|
||||
* remote images in your app or in case you want to make sure a 3rd party
|
||||
* image is properly served using a TLS protocol.
|
||||
*/
|
||||
public Call getImage(String url, int width, int height) {
|
||||
final String path = "/avatars/image";
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
entry("url", url),
|
||||
entry("width", width),
|
||||
entry("height", height)
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// Get QR Code
|
||||
/*
|
||||
* Converts a given plain text to a QR code image. You can use the query
|
||||
* parameters to change the size and style of the resulting image.
|
||||
*/
|
||||
public Call getQR(String text, int size, int margin, int download) {
|
||||
final String path = "/avatars/qr";
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
entry("text", text),
|
||||
entry("size", size),
|
||||
entry("margin", margin),
|
||||
entry("download", download)
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,264 @@
|
||||
package .services;
|
||||
|
||||
|
||||
|
||||
import okhttp3.Call;
|
||||
import .Client;
|
||||
import .enums.OrderType;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.util.Map.entry;
|
||||
|
||||
public class Database extends Service {
|
||||
public Database(Client client){
|
||||
super(client);
|
||||
}
|
||||
|
||||
/// List Collections
|
||||
/*
|
||||
* Get a list of all the user collections. You can use the query params to
|
||||
* filter your results. On admin mode, this endpoint will return a list of all
|
||||
* of the project collections. [Learn more about different API
|
||||
* modes](/docs/admin).
|
||||
*/
|
||||
public Call listCollections(String search, int limit, int offset, OrderType orderType) {
|
||||
final String path = "/database/collections";
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
entry("search", search),
|
||||
entry("limit", limit),
|
||||
entry("offset", offset),
|
||||
entry("orderType", orderType.name())
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// Create Collection
|
||||
/*
|
||||
* Create a new Collection.
|
||||
*/
|
||||
public Call createCollection(String name, List read, List write, List rules) {
|
||||
final String path = "/database/collections";
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
entry("name", name),
|
||||
entry("read", read),
|
||||
entry("write", write),
|
||||
entry("rules", rules)
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("POST", path, headers, params);
|
||||
}
|
||||
|
||||
/// Get Collection
|
||||
/*
|
||||
* Get collection by its unique ID. This endpoint response returns a JSON
|
||||
* object with the collection metadata.
|
||||
*/
|
||||
public Call getCollection(String collectionId) {
|
||||
final String path = "/database/collections/{collectionId}".replace("{collectionId}", collectionId);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// Update Collection
|
||||
/*
|
||||
* Update collection by its unique ID.
|
||||
*/
|
||||
public Call updateCollection(String collectionId, String name, List read, List write, List rules) {
|
||||
final String path = "/database/collections/{collectionId}".replace("{collectionId}", collectionId);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
entry("name", name),
|
||||
entry("read", read),
|
||||
entry("write", write),
|
||||
entry("rules", rules)
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("PUT", path, headers, params);
|
||||
}
|
||||
|
||||
/// Delete Collection
|
||||
/*
|
||||
* Delete a collection by its unique ID. Only users with write permissions
|
||||
* have access to delete this resource.
|
||||
*/
|
||||
public Call deleteCollection(String collectionId) {
|
||||
final String path = "/database/collections/{collectionId}".replace("{collectionId}", collectionId);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("DELETE", path, headers, params);
|
||||
}
|
||||
|
||||
/// List Documents
|
||||
/*
|
||||
* Get a list of all the user documents. You can use the query params to
|
||||
* filter your results. On admin mode, this endpoint will return a list of all
|
||||
* of the project documents. [Learn more about different API
|
||||
* modes](/docs/admin).
|
||||
*/
|
||||
public Call listDocuments(String collectionId, List filters, int offset, int limit, String orderField, OrderType orderType, String orderCast, String search, int first, int last) {
|
||||
final String path = "/database/collections/{collectionId}/documents".replace("{collectionId}", collectionId);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
entry("filters", filters),
|
||||
entry("offset", offset),
|
||||
entry("limit", limit),
|
||||
entry("orderField", orderField),
|
||||
entry("orderType", orderType.name()),
|
||||
entry("orderCast", orderCast),
|
||||
entry("search", search),
|
||||
entry("first", first),
|
||||
entry("last", last)
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// Create Document
|
||||
/*
|
||||
* Create a new Document.
|
||||
*/
|
||||
public Call createDocument(String collectionId, Object data, List read, List write, String parentDocument, String parentProperty, String parentPropertyType) {
|
||||
final String path = "/database/collections/{collectionId}/documents".replace("{collectionId}", collectionId);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
entry("data", data),
|
||||
entry("read", read),
|
||||
entry("write", write),
|
||||
entry("parentDocument", parentDocument),
|
||||
entry("parentProperty", parentProperty),
|
||||
entry("parentPropertyType", parentPropertyType)
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("POST", path, headers, params);
|
||||
}
|
||||
|
||||
/// Get Document
|
||||
/*
|
||||
* Get document by its unique ID. This endpoint response returns a JSON object
|
||||
* with the document data.
|
||||
*/
|
||||
public Call getDocument(String collectionId, String documentId) {
|
||||
final String path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// Update Document
|
||||
public Call updateDocument(String collectionId, String documentId, Object data, List read, List write) {
|
||||
final String path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
entry("data", data),
|
||||
entry("read", read),
|
||||
entry("write", write)
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("PATCH", path, headers, params);
|
||||
}
|
||||
|
||||
/// Delete Document
|
||||
/*
|
||||
* Delete document by its unique ID. This endpoint deletes only the parent
|
||||
* documents, his attributes and relations to other documents. Child documents
|
||||
* **will not** be deleted.
|
||||
*/
|
||||
public Call deleteDocument(String collectionId, String documentId) {
|
||||
final String path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("DELETE", path, headers, params);
|
||||
}
|
||||
|
||||
/// Get Collection Logs
|
||||
public Call getCollectionLogs(String collectionId) {
|
||||
final String path = "/database/collections/{collectionId}/logs".replace("{collectionId}", collectionId);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
package .services;
|
||||
|
||||
|
||||
|
||||
import okhttp3.Call;
|
||||
import .Client;
|
||||
import .enums.OrderType;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.util.Map.entry;
|
||||
|
||||
public class Health extends Service {
|
||||
public Health(Client client){
|
||||
super(client);
|
||||
}
|
||||
|
||||
/// Check API HTTP Health
|
||||
/*
|
||||
* Check the Appwrite HTTP server is up and responsive.
|
||||
*/
|
||||
public Call get() {
|
||||
final String path = "/health";
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// Check Cache Health
|
||||
/*
|
||||
* Check the Appwrite in-memory cache server is up and connection is
|
||||
* successful.
|
||||
*/
|
||||
public Call getCache() {
|
||||
final String path = "/health/cache";
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// Check DB Health
|
||||
/*
|
||||
* Check the Appwrite database server is up and connection is successful.
|
||||
*/
|
||||
public Call getDB() {
|
||||
final String path = "/health/db";
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// Check the number of pending certificate messages
|
||||
/*
|
||||
* Get the number of certificates that are waiting to be issued against
|
||||
* [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue
|
||||
* server.
|
||||
*/
|
||||
public Call getQueueCertificates() {
|
||||
final String path = "/health/queue/certificates";
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// Check the number of pending log messages
|
||||
/*
|
||||
* Get the number of logs that are waiting to be processed in the Appwrite
|
||||
* internal queue server.
|
||||
*/
|
||||
public Call getQueueLogs() {
|
||||
final String path = "/health/queue/logs";
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// Check the number of pending task messages
|
||||
/*
|
||||
* Get the number of tasks that are waiting to be processed in the Appwrite
|
||||
* internal queue server.
|
||||
*/
|
||||
public Call getQueueTasks() {
|
||||
final String path = "/health/queue/tasks";
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// Check the number of pending usage messages
|
||||
/*
|
||||
* Get the number of usage stats that are waiting to be processed in the
|
||||
* Appwrite internal queue server.
|
||||
*/
|
||||
public Call getQueueUsage() {
|
||||
final String path = "/health/queue/usage";
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// Check number of pending webhook messages
|
||||
/*
|
||||
* Get the number of webhooks that are waiting to be processed in the Appwrite
|
||||
* internal queue server.
|
||||
*/
|
||||
public Call getQueueWebhooks() {
|
||||
final String path = "/health/queue/webhooks";
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// Check Anti virus Health
|
||||
/*
|
||||
* Check the Appwrite Anti Virus server is up and connection is successful.
|
||||
*/
|
||||
public Call getStorageAntiVirus() {
|
||||
final String path = "/health/storage/anti-virus";
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// Check File System Health
|
||||
/*
|
||||
* Check the Appwrite local storage device is up and connection is successful.
|
||||
*/
|
||||
public Call getStorageLocal() {
|
||||
final String path = "/health/storage/local";
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// Check Time Health
|
||||
/*
|
||||
* Check the Appwrite server time is synced with Google remote NTP server. We
|
||||
* use this technology to smoothly handle leap seconds with no disruptive
|
||||
* events. The [Network Time
|
||||
* Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is
|
||||
* used by hundreds of millions of computers and devices to synchronize their
|
||||
* clocks over the Internet. If your computer sets its own clock, it likely
|
||||
* uses NTP.
|
||||
*/
|
||||
public Call getTime() {
|
||||
final String path = "/health/time";
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
package .services;
|
||||
|
||||
|
||||
|
||||
import okhttp3.Call;
|
||||
import .Client;
|
||||
import .enums.OrderType;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.util.Map.entry;
|
||||
|
||||
public class Locale extends Service {
|
||||
public Locale(Client client){
|
||||
super(client);
|
||||
}
|
||||
|
||||
/// Get User Locale
|
||||
/*
|
||||
* Get the current user location based on IP. Returns an object with user
|
||||
* country code, country name, continent name, continent code, ip address and
|
||||
* suggested currency. You can use the locale header to get the data in a
|
||||
* supported language.
|
||||
*
|
||||
* ([IP Geolocation by DB-IP](https://db-ip.com))
|
||||
*/
|
||||
public Call get() {
|
||||
final String path = "/locale";
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// List Continents
|
||||
/*
|
||||
* List of all continents. You can use the locale header to get the data in a
|
||||
* supported language.
|
||||
*/
|
||||
public Call getContinents() {
|
||||
final String path = "/locale/continents";
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// List Countries
|
||||
/*
|
||||
* List of all countries. You can use the locale header to get the data in a
|
||||
* supported language.
|
||||
*/
|
||||
public Call getCountries() {
|
||||
final String path = "/locale/countries";
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// List EU Countries
|
||||
/*
|
||||
* List of all countries that are currently members of the EU. You can use the
|
||||
* locale header to get the data in a supported language.
|
||||
*/
|
||||
public Call getCountriesEU() {
|
||||
final String path = "/locale/countries/eu";
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// List Countries Phone Codes
|
||||
/*
|
||||
* List of all countries phone codes. You can use the locale header to get the
|
||||
* data in a supported language.
|
||||
*/
|
||||
public Call getCountriesPhones() {
|
||||
final String path = "/locale/countries/phones";
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// List Currencies
|
||||
/*
|
||||
* List of all currencies, including currency symol, name, plural, and decimal
|
||||
* digits for all major and minor currencies. You can use the locale header to
|
||||
* get the data in a supported language.
|
||||
*/
|
||||
public Call getCurrencies() {
|
||||
final String path = "/locale/currencies";
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package .services;
|
||||
|
||||
import .Client;
|
||||
|
||||
abstract class Service {
|
||||
final Client client;
|
||||
|
||||
Service(Client client) {
|
||||
this.client = client;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
package .services;
|
||||
|
||||
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.HttpUrl;
|
||||
import .Client;
|
||||
import .enums.OrderType;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.util.Map.entry;
|
||||
|
||||
public class Storage extends Service {
|
||||
public Storage(Client client){
|
||||
super(client);
|
||||
}
|
||||
|
||||
/// List Files
|
||||
/*
|
||||
* Get a list of all the user files. You can use the query params to filter
|
||||
* your results. On admin mode, this endpoint will return a list of all of the
|
||||
* project files. [Learn more about different API modes](/docs/admin).
|
||||
*/
|
||||
public Call listFiles(String search, int limit, int offset, OrderType orderType) {
|
||||
final String path = "/storage/files";
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
entry("search", search),
|
||||
entry("limit", limit),
|
||||
entry("offset", offset),
|
||||
entry("orderType", orderType.name())
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// Create File
|
||||
/*
|
||||
* Create a new file. The user who creates the file will automatically be
|
||||
* assigned to read and write access unless he has passed custom values for
|
||||
* read and write arguments.
|
||||
*/
|
||||
public Call createFile(File file, List read, List write) {
|
||||
final String path = "/storage/files";
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
entry("file", file),
|
||||
entry("read", read),
|
||||
entry("write", write)
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "multipart/form-data")
|
||||
);
|
||||
|
||||
return client.call("POST", path, headers, params);
|
||||
}
|
||||
|
||||
/// Get File
|
||||
/*
|
||||
* Get file by its unique ID. This endpoint response returns a JSON object
|
||||
* with the file metadata.
|
||||
*/
|
||||
public Call getFile(String fileId) {
|
||||
final String path = "/storage/files/{fileId}".replace("{fileId}", fileId);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// Update File
|
||||
/*
|
||||
* Update file by its unique ID. Only users with write permissions have access
|
||||
* to update this resource.
|
||||
*/
|
||||
public Call updateFile(String fileId, List read, List write) {
|
||||
final String path = "/storage/files/{fileId}".replace("{fileId}", fileId);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
entry("read", read),
|
||||
entry("write", write)
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("PUT", path, headers, params);
|
||||
}
|
||||
|
||||
/// Delete File
|
||||
/*
|
||||
* Delete a file by its unique ID. Only users with write permissions have
|
||||
* access to delete this resource.
|
||||
*/
|
||||
public Call deleteFile(String fileId) {
|
||||
final String path = "/storage/files/{fileId}".replace("{fileId}", fileId);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("DELETE", path, headers, params);
|
||||
}
|
||||
|
||||
/// Get File for Download
|
||||
/*
|
||||
* Get file content by its unique ID. The endpoint response return with a
|
||||
* 'Content-Disposition: attachment' header that tells the browser to start
|
||||
* downloading the file to user downloads directory.
|
||||
*/
|
||||
public String getFileDownload(String fileId) {
|
||||
final String path = "/storage/files/{fileId}/download".replace("{fileId}", fileId);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
entry("project", client.getConfig().get("project")),
|
||||
entry("key", client.getConfig().get("key"))
|
||||
);
|
||||
|
||||
|
||||
|
||||
HttpUrl.Builder httpBuilder = new HttpUrl.Builder().build().newBuilder(client.getEndPoint() + path);
|
||||
params.forEach((k, v) -> httpBuilder.addQueryParameter(k, v.toString()));
|
||||
|
||||
return httpBuilder.build().toString();
|
||||
}
|
||||
|
||||
/// Get File Preview
|
||||
/*
|
||||
* Get a file preview image. Currently, this method supports preview for image
|
||||
* files (jpg, png, and gif), other supported formats, like pdf, docs, slides,
|
||||
* and spreadsheets, will return the file icon image. You can also pass query
|
||||
* string arguments for cutting and resizing your preview image.
|
||||
*/
|
||||
public String getFilePreview(String fileId, int width, int height, int quality, String background, String output) {
|
||||
final String path = "/storage/files/{fileId}/preview".replace("{fileId}", fileId);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
entry("width", width),
|
||||
entry("height", height),
|
||||
entry("quality", quality),
|
||||
entry("background", background),
|
||||
entry("output", output),
|
||||
entry("project", client.getConfig().get("project")),
|
||||
entry("key", client.getConfig().get("key"))
|
||||
);
|
||||
|
||||
|
||||
|
||||
HttpUrl.Builder httpBuilder = new HttpUrl.Builder().build().newBuilder(client.getEndPoint() + path);
|
||||
params.forEach((k, v) -> httpBuilder.addQueryParameter(k, v.toString()));
|
||||
|
||||
return httpBuilder.build().toString();
|
||||
}
|
||||
|
||||
/// Get File for View
|
||||
/*
|
||||
* Get file content by its unique ID. This endpoint is similar to the download
|
||||
* method but returns with no 'Content-Disposition: attachment' header.
|
||||
*/
|
||||
public String getFileView(String fileId, String as) {
|
||||
final String path = "/storage/files/{fileId}/view".replace("{fileId}", fileId);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
entry("as", as),
|
||||
entry("project", client.getConfig().get("project")),
|
||||
entry("key", client.getConfig().get("key"))
|
||||
);
|
||||
|
||||
|
||||
|
||||
HttpUrl.Builder httpBuilder = new HttpUrl.Builder().build().newBuilder(client.getEndPoint() + path);
|
||||
params.forEach((k, v) -> httpBuilder.addQueryParameter(k, v.toString()));
|
||||
|
||||
return httpBuilder.build().toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
package .services;
|
||||
|
||||
|
||||
|
||||
import okhttp3.Call;
|
||||
import .Client;
|
||||
import .enums.OrderType;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.util.Map.entry;
|
||||
|
||||
public class Teams extends Service {
|
||||
public Teams(Client client){
|
||||
super(client);
|
||||
}
|
||||
|
||||
/// List Teams
|
||||
/*
|
||||
* Get a list of all the current user teams. You can use the query params to
|
||||
* filter your results. On admin mode, this endpoint will return a list of all
|
||||
* of the project teams. [Learn more about different API modes](/docs/admin).
|
||||
*/
|
||||
public Call list(String search, int limit, int offset, OrderType orderType) {
|
||||
final String path = "/teams";
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
entry("search", search),
|
||||
entry("limit", limit),
|
||||
entry("offset", offset),
|
||||
entry("orderType", orderType.name())
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// Create Team
|
||||
/*
|
||||
* Create a new team. The user who creates the team will automatically be
|
||||
* assigned as the owner of the team. The team owner can invite new members,
|
||||
* who will be able add new owners and update or delete the team from your
|
||||
* project.
|
||||
*/
|
||||
public Call create(String name, List roles) {
|
||||
final String path = "/teams";
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
entry("name", name),
|
||||
entry("roles", roles)
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("POST", path, headers, params);
|
||||
}
|
||||
|
||||
/// Get Team
|
||||
/*
|
||||
* Get team by its unique ID. All team members have read access for this
|
||||
* resource.
|
||||
*/
|
||||
public Call get(String teamId) {
|
||||
final String path = "/teams/{teamId}".replace("{teamId}", teamId);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// Update Team
|
||||
/*
|
||||
* Update team by its unique ID. Only team owners have write access for this
|
||||
* resource.
|
||||
*/
|
||||
public Call update(String teamId, String name) {
|
||||
final String path = "/teams/{teamId}".replace("{teamId}", teamId);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
entry("name", name)
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("PUT", path, headers, params);
|
||||
}
|
||||
|
||||
/// Delete Team
|
||||
/*
|
||||
* Delete team by its unique ID. Only team owners have write access for this
|
||||
* resource.
|
||||
*/
|
||||
public Call delete(String teamId) {
|
||||
final String path = "/teams/{teamId}".replace("{teamId}", teamId);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("DELETE", path, headers, params);
|
||||
}
|
||||
|
||||
/// Get Team Memberships
|
||||
/*
|
||||
* Get team members by the team unique ID. All team members have read access
|
||||
* for this list of resources.
|
||||
*/
|
||||
public Call getMemberships(String teamId) {
|
||||
final String path = "/teams/{teamId}/memberships".replace("{teamId}", teamId);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// Create Team Membership
|
||||
/*
|
||||
* Use this endpoint to invite a new member to join your team. An email with a
|
||||
* link to join the team will be sent to the new member email address if the
|
||||
* member doesn't exist in the project it will be created automatically.
|
||||
*
|
||||
* Use the 'URL' parameter to redirect the user from the invitation email back
|
||||
* to your app. When the user is redirected, use the [Update Team Membership
|
||||
* Status](/docs/teams#updateMembershipStatus) endpoint to allow the user to
|
||||
* accept the invitation to the team.
|
||||
*
|
||||
* Please note that in order to avoid a [Redirect
|
||||
* Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
|
||||
* the only valid redirect URL's are the once from domains you have set when
|
||||
* added your platforms in the console interface.
|
||||
*/
|
||||
public Call createMembership(String teamId, String email, List roles, String url, String name) {
|
||||
final String path = "/teams/{teamId}/memberships".replace("{teamId}", teamId);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
entry("email", email),
|
||||
entry("name", name),
|
||||
entry("roles", roles),
|
||||
entry("url", url)
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("POST", path, headers, params);
|
||||
}
|
||||
|
||||
/// Delete Team Membership
|
||||
/*
|
||||
* This endpoint allows a user to leave a team or for a team owner to delete
|
||||
* the membership of any other team member. You can also use this endpoint to
|
||||
* delete a user membership even if he didn't accept it.
|
||||
*/
|
||||
public Call deleteMembership(String teamId, String inviteId) {
|
||||
final String path = "/teams/{teamId}/memberships/{inviteId}".replace("{teamId}", teamId).replace("{inviteId}", inviteId);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("DELETE", path, headers, params);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
package .services;
|
||||
|
||||
|
||||
|
||||
import okhttp3.Call;
|
||||
import .Client;
|
||||
import .enums.OrderType;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.util.Map.entry;
|
||||
|
||||
public class Users extends Service {
|
||||
public Users(Client client){
|
||||
super(client);
|
||||
}
|
||||
|
||||
/// List Users
|
||||
/*
|
||||
* Get a list of all the project users. You can use the query params to filter
|
||||
* your results.
|
||||
*/
|
||||
public Call list(String search, int limit, int offset, OrderType orderType) {
|
||||
final String path = "/users";
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
entry("search", search),
|
||||
entry("limit", limit),
|
||||
entry("offset", offset),
|
||||
entry("orderType", orderType.name())
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// Create User
|
||||
/*
|
||||
* Create a new user.
|
||||
*/
|
||||
public Call create(String email, String password, String name) {
|
||||
final String path = "/users";
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
entry("email", email),
|
||||
entry("password", password),
|
||||
entry("name", name)
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("POST", path, headers, params);
|
||||
}
|
||||
|
||||
/// Get User
|
||||
/*
|
||||
* Get user by its unique ID.
|
||||
*/
|
||||
public Call get(String userId) {
|
||||
final String path = "/users/{userId}".replace("{userId}", userId);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// Get User Logs
|
||||
/*
|
||||
* Get user activity logs list by its unique ID.
|
||||
*/
|
||||
public Call getLogs(String userId) {
|
||||
final String path = "/users/{userId}/logs".replace("{userId}", userId);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// Get User Preferences
|
||||
/*
|
||||
* Get user preferences by its unique ID.
|
||||
*/
|
||||
public Call getPrefs(String userId) {
|
||||
final String path = "/users/{userId}/prefs".replace("{userId}", userId);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// Update User Preferences
|
||||
/*
|
||||
* Update user preferences by its unique ID. You can pass only the specific
|
||||
* settings you wish to update.
|
||||
*/
|
||||
public Call updatePrefs(String userId, Object prefs) {
|
||||
final String path = "/users/{userId}/prefs".replace("{userId}", userId);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
entry("prefs", prefs)
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("PATCH", path, headers, params);
|
||||
}
|
||||
|
||||
/// Get User Sessions
|
||||
/*
|
||||
* Get user sessions list by its unique ID.
|
||||
*/
|
||||
public Call getSessions(String userId) {
|
||||
final String path = "/users/{userId}/sessions".replace("{userId}", userId);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("GET", path, headers, params);
|
||||
}
|
||||
|
||||
/// Delete User Sessions
|
||||
/*
|
||||
* Delete all user sessions by its unique ID.
|
||||
*/
|
||||
public Call deleteSessions(String userId) {
|
||||
final String path = "/users/{userId}/sessions".replace("{userId}", userId);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("DELETE", path, headers, params);
|
||||
}
|
||||
|
||||
/// Delete User Session
|
||||
/*
|
||||
* Delete user sessions by its unique ID.
|
||||
*/
|
||||
public Call deleteSession(String userId, String sessionId) {
|
||||
final String path = "/users/{userId}/sessions/{sessionId}".replace("{userId}", userId).replace("{sessionId}", sessionId);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("DELETE", path, headers, params);
|
||||
}
|
||||
|
||||
/// Update User Status
|
||||
/*
|
||||
* Update user status by its unique ID.
|
||||
*/
|
||||
public Call updateStatus(String userId, String status) {
|
||||
final String path = "/users/{userId}/status".replace("{userId}", userId);
|
||||
|
||||
final Map<String, Object> params = Map.ofEntries(
|
||||
entry("status", status)
|
||||
);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> headers = Map.ofEntries(
|
||||
entry("content-type", "application/json")
|
||||
);
|
||||
|
||||
return client.call("PATCH", path, headers, params);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user