https://github.com/akayeshmantha/apache-apisix-java-sdk
Java SDK for Apache APISIX
https://github.com/akayeshmantha/apache-apisix-java-sdk
Last synced: about 2 months ago
JSON representation
Java SDK for Apache APISIX
- Host: GitHub
- URL: https://github.com/akayeshmantha/apache-apisix-java-sdk
- Owner: Akayeshmantha
- License: apache-2.0
- Created: 2020-04-25T18:21:11.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-30T01:51:21.000Z (about 5 years ago)
- Last Synced: 2025-02-12T07:55:14.658Z (4 months ago)
- Size: 36.1 KB
- Stars: 2
- Watchers: 2
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Java SDK for Apache APISIX
More detailed documentation please refer to:
- https://github.com/apache/incubator-apisix/blob/master/doc/admin-api-cn.md- https://github.com/apache/incubator-apisix/blob/master/doc/architecture-design-cn.md
# Example
```java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;import org.apache.apisix.admin.AdminClient;
import org.apache.apisix.admin.model.Route;
import org.apache.apisix.admin.model.Upstream;
import org.apache.apisix.common.profile.Credential;
import org.apache.apisix.common.profile.DefaultCredential;
import org.apache.apisix.common.profile.DefaultProfile;
import org.apache.apisix.common.profile.Profile;String endpoint = "127.0.0.1:9080";
String version = "1.1";
Credential credential = new DefaultCredential("edd1c9f034335f136f87ad84b625c8f1");
Profile profile = DefaultProfile.getProfile(endpoint, version, credential);
AdminClient adminClient = new AdminClient(profile);String id = "1";
Route route = new Route();
Upstream upstream = new Upstream();
Map nodes = new HashMap<>();
List methods = new ArrayList<>();nodes.put("127.0.0.1:8080", 1);
methods.add("GET");
upstream.setType("roundrobin");
upstream.setNodes(nodes);route.setUri("/helloworld");
route.setDesc("route added by java sdk");
route.setMethods(methods);
route.setUpstream(upstream);Route res = adminClient.putRote(id, route);
```