You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This folder contains an example for WebAPI client in Java. Client library would be pulled from [GitHub Packages](https://github.com/orgs/Green-Software-Foundation/packages?repo_name=carbon-aware-sdk).
7
4
8
-
Javadoc is [here](apidocs).
9
-
10
-
openapi-generator-maven-plugin generates Maven/Gradle project when it kicks,
11
-
however this example uses generated codes directly. So you don't need to
12
-
run/modify project files in it.
5
+
Javadoc is [here](https://carbon-aware-sdk.greensoftware.foundation/client-apidocs/1.0.0/java).
13
6
14
7
## Requirements
15
8
16
-
- OpenAPI spec file
17
-
- Both online and offline file are available.
18
-
- See [WebAPI document](../../docs/carbon-aware-webapi.md#autogenerate-webapi)
19
-
for details.
20
9
- WebAPI instance
21
-
- See the [Overview](../../docs/overview.md#publish-webapi-with-container)
22
-
if you'd like to start it on container.
10
+
- See the [Overview](../../docs/overview.md#publish-webapi-with-container) if you'd like to start it on container.
is an example program to call WebAPI endpoint. It calls all of endpoints, and
30
-
shows the result.
16
+
[WebApiClient.java](src/main/java/example/foundation/greensoftware/carbonawaresdk/WebApiClient.java) is an example program to call WebAPI endpoint. It calls all of endpoints, and shows the result.
31
17
32
18
Following methods are available:
33
19
@@ -53,19 +39,14 @@ Following methods are available:
is used for parameters in each APIs. However the error occurs if nano sec is set
58
-
to it in case of WattTime. So it is highly recommended that clears nanosec field
59
-
like `withNano(0)`.
42
+
[OffsetDateTime](https://docs.oracle.com/javase/8/docs/api/java/time/OffsetDateTime.html) is used for parameters in each APIs. However the error occurs if nano sec is set to it in case of WattTime. So it is highly recommended that clears nanosec field like `withNano(0)`.
60
43
61
44
## How it works
62
45
63
46
### 1. Set up for [POM](pom.xml)
64
47
65
48
You need to change following properties:
66
49
67
-
-`openapi.spec`
68
-
- OpenAPI spec file
69
50
-`webapi.endpoint`
70
51
- WebAPI base URL
71
52
@@ -83,27 +64,23 @@ $ mvn exec:java
83
64
84
65
### Running in container
85
66
86
-
This example also can run in container. You can use
87
-
[Maven official image](https://hub.docker.com/_/maven).
67
+
This example also can run in container. You can use [Maven official image](https://hub.docker.com/_/maven).
88
68
89
-
If you want to run both WebAPI and build process in container, you need to join
90
-
2 containers to same network.
69
+
If you want to run both WebAPI and build process in container, you need to join 2 containers to same network.
91
70
92
71
Following instructions are for Podman.
93
72
94
73
#### 1. Create pod
95
74
96
-
This pod publishes port 80 in the pod to 8080 on the host, then you can access
97
-
WebAPI in the pod. The pod is named to `carbon-aware-sdk`.
75
+
This pod publishes port 80 in the pod to 8080 on the host, then you can access WebAPI in the pod. The pod is named to `carbon-aware-sdk`.
98
76
99
77
```sh
100
78
podman pod create -p 8080:80 --name carbon-aware-sdk
101
79
```
102
80
103
81
#### 2. Start WebAPI container
104
82
105
-
Start WebAPI container in `carbon-aware-sdk` pod. It is specified at `--pod`
106
-
option.
83
+
Start WebAPI container in `carbon-aware-sdk` pod. It is specified at `--pod` option.
107
84
108
85
See [Overview](../../docs/overview.md) document to build container image.
Run `mvn` command in Maven container in `catbon-aware-sdk` pod. You need to
121
-
mount Carbon Aware SDK source directory to the container. It mounts to `/src` in
122
-
the container in following case.
97
+
Run `mvn` command in Maven container in `catbon-aware-sdk` pod. You need to mount Carbon Aware SDK source directory to the container. It mounts to `/src` in the container in following case.
123
98
124
-
In following command, you can rebuild java-client, and can run the artifact. You
125
-
can get artifacts from `samples/java-client/target` on the container host of
126
-
course.
99
+
In following command, you can rebuild java-client, and can run the artifact. You can get artifacts from `samples/java-client/target` on the container host of course.
Maven will download many dependencies in each `mvn` call. You can avoid it when
136
-
you mount `.m2` like `-v $HOME/.m2:/root/.m2` because it shares Maven cache
137
-
between the host and the container.
108
+
Maven will download many dependencies in each `mvn` call. You can avoid it when you mount `.m2` like `-v $HOME/.m2:/root/.m2` because it shares Maven cache between the host and the container.
0 commit comments