|
| 1 | +--- |
| 2 | +title: "REST API" |
| 3 | +weight: 1 |
| 4 | +type: docs |
| 5 | +aliases: |
| 6 | +- /api/rest-api.html |
| 7 | +--- |
| 8 | +<!-- |
| 9 | +Licensed to the Apache Software Foundation (ASF) under one |
| 10 | +or more contributor license agreements. See the NOTICE file |
| 11 | +distributed with this work for additional information |
| 12 | +regarding copyright ownership. The ASF licenses this file |
| 13 | +to you under the Apache License, Version 2.0 (the |
| 14 | +"License"); you may not use this file except in compliance |
| 15 | +with the License. You may obtain a copy of the License at |
| 16 | +
|
| 17 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 18 | +
|
| 19 | +Unless required by applicable law or agreed to in writing, |
| 20 | +software distributed under the License is distributed on an |
| 21 | +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 22 | +KIND, either express or implied. See the License for the |
| 23 | +specific language governing permissions and limitations |
| 24 | +under the License. |
| 25 | +--> |
| 26 | + |
| 27 | +# REST API |
| 28 | + |
| 29 | +This is Java API for [REST]({{< ref "concepts/rest/overview" >}}). |
| 30 | + |
| 31 | +## Dependency |
| 32 | + |
| 33 | +Maven dependency: |
| 34 | + |
| 35 | +```xml |
| 36 | +<dependency> |
| 37 | + <groupId>org.apache.paimon</groupId> |
| 38 | + <artifactId>paimon-api</artifactId> |
| 39 | + <version>{{< version >}}</version> |
| 40 | +</dependency> |
| 41 | +``` |
| 42 | + |
| 43 | +Or download the jar file: |
| 44 | +{{< stable >}}[Paimon API](https://repo.maven.apache.org/maven2/org/apache/paimon/paimon-api/{{< version >}}/paimon-api-{{< version >}}.jar).{{< /stable >}} |
| 45 | +{{< unstable >}}[Paimon API](https://repository.apache.org/snapshots/org/apache/paimon/paimon-api/{{< version >}}/).{{< /unstable >}} |
| 46 | + |
| 47 | +## RESTApi |
| 48 | + |
| 49 | +```java |
| 50 | +import org.apache.paimon.options.Options; |
| 51 | +import org.apache.paimon.rest.RESTApi; |
| 52 | + |
| 53 | +import java.util.List; |
| 54 | + |
| 55 | +import static org.apache.paimon.options.CatalogOptions.WAREHOUSE; |
| 56 | +import static org.apache.paimon.rest.RESTCatalogOptions.DLF_ACCESS_KEY_ID; |
| 57 | +import static org.apache.paimon.rest.RESTCatalogOptions.DLF_ACCESS_KEY_SECRET; |
| 58 | +import static org.apache.paimon.rest.RESTCatalogOptions.TOKEN_PROVIDER; |
| 59 | +import static org.apache.paimon.rest.RESTCatalogOptions.URI; |
| 60 | + |
| 61 | +public class RESTApiExample { |
| 62 | + |
| 63 | + public static void main(String[] args) { |
| 64 | + Options options = new Options(); |
| 65 | + options.set(URI, "<catalog server url>"); |
| 66 | + options.set(WAREHOUSE, "my_instance_name"); |
| 67 | + options.set(TOKEN_PROVIDER, "dlf"); |
| 68 | + options.set(DLF_ACCESS_KEY_ID, "<access-key-id>"); |
| 69 | + options.set(DLF_ACCESS_KEY_SECRET, "<access-key-secret>"); |
| 70 | + |
| 71 | + RESTApi api = new RESTApi(options); |
| 72 | + List<String> tables = api.listTables("my_database"); |
| 73 | + System.out.println(tables); |
| 74 | + } |
| 75 | +} |
| 76 | +``` |
| 77 | + |
| 78 | +See more methods in `'RESTApi'`. |
0 commit comments