-
Notifications
You must be signed in to change notification settings - Fork 17
/
API.java
executable file
·42 lines (32 loc) · 1.29 KB
/
API.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// camel-k: language=java dependency=camel-quarkus-openapi-java
import org.apache.camel.builder.AggregationStrategies;
import org.apache.camel.builder.RouteBuilder;
public class API extends RouteBuilder {
@Override
public void configure() throws Exception {
// All endpoints starting from "direct:..." reference an operationId defined
// in the "openapi.yaml" file.
// List the object names available in the S3 bucket
from("direct:list")
.to("aws2-s3://{{api.bucket}}?operation=listObjects")
.split(simple("${body}"), AggregationStrategies.groupedBody())
.transform().simple("${body.key}")
.end()
.marshal().json();
// Get an object from the S3 bucket
from("direct:get")
.setHeader("CamelAwsS3Key", simple("${header.name}"))
.to("aws2-s3://{{api.bucket}}?operation=getObject")
.convertBodyTo(String.class);
// Upload a new object into the S3 bucket
from("direct:create")
.setHeader("CamelAwsS3Key", simple("${header.name}"))
.to("aws2-s3://{{api.bucket}}")
.setBody().constant("");
// Delete an object from the S3 bucket
from("direct:delete")
.setHeader("CamelAwsS3Key", simple("${header.name}"))
.to("aws2-s3://{{api.bucket}}?operation=deleteObject")
.setBody().constant("");
}
}