Page History
Sv translation | ||
---|---|---|
| ||
When to create API endpointThere are several situations, where you need a specific endpoint for your application:
SpecificationAn API Endpoint is Groovy/Java class compiled and executed on the server at runtime. It may use 3rd party JAR libraries provided as JAR resource inside the extension. On the source code level, it's possible to use variety of classes and methods, including access to basic BellaDati objects and data - Data sets, Reports, Machine Learning. |
...
API Endpoint is exposed to the outter world using HTTP server and is accepting HTTP GET, POST, DELETE and PUT requests.
|
Code Block | ||||
---|---|---|---|---|
| ||||
package com.belladati;
import com.belladati.extension.BaseExtensionEndpoint;
import org.apache.tapestry5.StreamResponse;
public class MyEndpoint extends BaseExtensionEndpoint {
@Override
public StreamResponse doGet() {
String text = "GET method called with parameter: " + getParameter("say")
return createStreamResponse(text, "text/plain", 200)
}
@Override
public StreamResponse doPost() {
String text = "POST method called with parameter: " + getParameter("say")
return createStreamResponse(text, "text/plain", 200)
}
} |
Types whitelist
Beside types and packages below, all types and packages from provided JAR library are on white list too.
Code Block | ||
---|---|---|
| ||
DecimalFormat.class, NumberFormat.class, LocalDate.class, LocalTime.class, DateTime.class, Arrays.class, ArrayUtils.class, SystemOutputInterceptor.class, Integer.class, Long.class, Double.class, Float.class, BigDecimal.class, String.class, StringUtils.class, JSON.class, JSONObject.class, JSONArray.class, Filter.class, OperationType.class, Map.class |
Package name |
---|
java.util |
java.util.regex |
org.apache.commons.logging |
com.belladati.json |
Sv translation | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||||
APIエンドポイントを作成するタイミングアプリケーションに特定のエンドポイントが必要な状況はいくつかあります: クライアントAPIが目的の機能を提供しない
仕様APIエンドポイントは、実行時にサーバー上でコンパイルおよび実行されるGroovy/Javaクラスです。拡張機能内のJARリソースとして提供されるサードパーティのJARライブラリを使用する場合があります。 ソースコードレベルでは、基本的なBellaDatiオブジェクトとデータ (データセット、レポート、機械学習) へのアクセスなど、様々なクラスとメソッドを使用できます。 APIエンドポイントは、HTTPサーバーを使用して外部に公開され、HTTP GET、POST、DELETE、およびPUTリクエストを受け入れます。
|
Code Block | ||||
---|---|---|---|---|
| ||||
package com.belladati;
import com.belladati.extension.BaseExtensionEndpoint;
import org.apache.tapestry5.StreamResponse;
public class MyEndpoint extends BaseExtensionEndpoint {
@Override
public StreamResponse doGet() {
String text = "GET method called with parameter: " + getParameter("say")
return createStreamResponse(text, "text/plain", 200)
}
@Override
public StreamResponse doPost() {
String text = "POST method called with parameter: " + getParameter("say")
return createStreamResponse(text, "text/plain", 200)
}
} |
ホワイトリストのタイプ
以下のタイプとパッケージに加えて、提供されているJARライブラリのすべてのタイプとパッケージもホワイトリストに含まれています。
Code Block | ||
---|---|---|
| ||
DecimalFormat.class, NumberFormat.class, LocalDate.class, LocalTime.class, DateTime.class, Arrays.class, ArrayUtils.class, SystemOutputInterceptor.class, Integer.class, Long.class, Double.class, Float.class, BigDecimal.class, String.class, StringUtils.class, JSON.class, JSONObject.class, JSONArray.class, Filter.class, OperationType.class, Map.class |
パッケージ名 |
---|
java.util |
java.util.regex |
org.apache.commons.logging |
com.belladati.json |