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
Copy file name to clipboardExpand all lines: README.md
+22-73Lines changed: 22 additions & 73 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
# Java Client Library (beta)
2
2
3
-
### Latest snapshot version v0.5.0-SNAPSHOT
4
-
### Latest released version v0.4.2
3
+
### Latest snapshot version v0.6.0-SNAPSHOT
4
+
### Latest released version v0.5.0
5
5
6
6
## Introduction
7
7
Welcome my friends! This is the Poly API Java client GitHub page. If you are here, then it means you're familiar with what we do at Poly. If you aren't, you can always check [here](https://github.com/polyapi/poly-alpha).
@@ -55,7 +55,7 @@ Nice to have some customers looking around here! So, you'll need to run the foll
55
55
2.**Update the project.** Add the following to your project's `pom.xml`:
56
56
```xml
57
57
<properties>
58
-
<poly.version>0.3.3</poly.version>
58
+
<poly.version>0.5.0</poly.version>
59
59
</properties>
60
60
<dependencies>
61
61
<dependency>
@@ -76,16 +76,16 @@ Nice to have some customers looking around here! So, you'll need to run the foll
76
76
<artifactId>polyapi-maven-plugin</artifactId>
77
77
<version>${poly.version}</version>
78
78
<executions>
79
-
<configuration>
80
-
<host>https://develop-k8s.polyapi.io</host>
81
-
<port>443</port>
82
-
<apiKey>{API_KEY}</apiKey>
83
-
</configuration>
84
79
<execution>
85
80
<phase>generate-sources</phase>
86
81
<goals>
87
82
<goal>generate-sources</goal>
88
83
</goals>
84
+
<configuration>
85
+
<host>https://develop-k8s.polyapi.io</host>
86
+
<port>443</port>
87
+
<apiKey>{API_KEY}</apiKey>
88
+
</configuration>
89
89
</execution>
90
90
</executions>
91
91
</plugin>
@@ -184,32 +184,6 @@ One of the key classes in this library is the proxy factory. As most of the gene
184
184
### Maven plugin
185
185
This maven plugin provides the following MOJOs:
186
186
187
-
#### add-server-function
188
-
This MOJO adds a server function to the Poly Server. Poly Server functions are functions that are run in the Poly server.
189
-
190
-
##### Parameters
191
-
Here's the list of parameters:
192
-
-**host (required):** The host where the Poly API instance is hosted.
193
-
-**port:** The port that the Poly API instance is listening to. Default value is 443.
194
-
-**apiKey (required):** The API key required to authenticate to Poly.
195
-
-**file (required):** The relative path to the file that contains the function to be uploaded.
196
-
-**functionName (required):** The name of the method to be converted into the function to be uploaded.
197
-
-**context:** The context where the function will be hosted. When generating the function interface, this will influence the package name.
198
-
-**description:** The description of the function.
199
-
200
-
#### add-client-function
201
-
This MOJO adds a client function to the Poly Server. Poly Client functions are functions that, although are stored in the Server, are ultimately executed in the client.
202
-
203
-
##### Parameters
204
-
Here's the list of parameters:
205
-
-**host (required):** The host where the Poly API instance is hosted.
206
-
-**port:** The port that the Poly API instance is listening to. Default value is 443.
207
-
-**apiKey (required):** The API key required to authenticate to Poly.
208
-
-**file (required):** The relative path to the file that contains the function to be uploaded.
209
-
-**functionName (required):** The name of the method to be converted into the function to be uploaded.
210
-
-**context:** The context where the function will be hosted. When generating the function interface, this will influence the package name.
211
-
-**description:** The description of the function.
212
-
213
187
#### generate-sources
214
188
This MOJO generates all the sources for a determined API key into the `target/generated-sources` folder.
215
189
@@ -250,6 +224,7 @@ Here's the list of parameters:
250
224
-**host (required):** The host where the Poly API instance is hosted.
251
225
-**port:** The port that the Poly API instance is listening to. Default value is 443.
252
226
-**apiKey (required):** The API key required to authenticate to Poly.
227
+
-**functions:** Comma separated value containing the names of the functions to deploy. The functions must be annotated with the `@PolyFunction` annotation as it is described. This parameter triggers a filter by function name and/or context + function name in the `[context].[functionName]` format. Each comma separated value will be taken independently and deployed.
It is possible to create custom functions that can be used in Poly. To do so, you need to create a class with desired function. For example:
283
+
### Poly server functions
284
+
It is possible to deploy server functions that can be used in Poly. To do so, you need to create a class with desired function. For example:
310
285
```java
311
286
publicclassCustomFunction {
312
287
publicStringsayHello(Stringname) {
313
288
return"Hello "+ name;
314
289
}
315
290
}
316
291
```
317
-
318
-
Then there are 2 approaches:
319
-
320
-
#### Manual approach
321
-
In this approach, you will use the `add-client-function` goals of the PolyAPI maven plugin.
322
-
323
-
Just run:
324
-
```bash
325
-
mvn polyapi:add-client-function -Dname=sayHello -Dfile="src/main/java/custom/CustomFunction.java" -Dcontext="test.client" -Dclient -Ddescription="This says hello to you"
326
-
```
327
-
This will add the function with specified name and context to Poly, so it can be used in code:
328
-
329
-
```java
330
-
var result =Poly.test.client.sayHello("John");
331
-
System.out.println(result);
332
-
```
333
-
334
-
#### Annotation approach
335
-
This approach requires that you have a setup project. In this project, you need to have the PolyAPI commons library installed as a dependency.
292
+
Then, it is required that you have a setup project. In this project, you need to have the PolyAPI commons library installed as a dependency.
336
293
```xml
337
294
<dependency>
338
295
<groupId>io.polyapi</groupId>
339
296
<artifactId>commons</artifactId>
340
297
<version>${poly.version}</version>
341
298
</dependency>
342
299
```
343
-
Then annotate the function you want to upload with `@PolyFunction`. Have in mind that to mark this as a custom function (or client function) you need to set the property `polyType` in the annotation to `CLIENT`, leaving the annotation something like:
344
-
```java
345
-
@PolyFunction(polyType=FunctionType.CLIENT)
346
-
```
347
-
Then, just run:
300
+
Then, annotate the function you want to upload with `@PolyFunction`.
301
+
And finally, just run:
348
302
```bash
349
303
mvn polyapi:deploy-functions
350
304
```
351
-
### Server Functions
352
-
Similar to Custom Functions, you can create Server Functions. To do so, you need to create a class with desired function same as with Custom Functions.
353
-
Then to add it to Poly, there are the same 2 approaches:
354
-
355
-
#### Manual approach
356
-
In here instead of using the `add-client-function` goal, you use the `add-server-function` one:
357
-
```bash
358
-
mvn polyapi:add-server-function -Dname=sayHello -Dfile="src/main/java/custom/CustomFunction.java" -Dcontext="test.server" -Ddescription="This says hello to you from server"
305
+
### Poly client functions
306
+
To create a Poly client Function you need to follow the same steps as with a server function, but when adding the `@PolyFunction` annotation, you need to set the property `polyType` in the annotation to `CLIENT`, leaving the annotation something like:
307
+
```java
308
+
@PolyFunction(polyType=FunctionType.CLIENT)
359
309
```
360
-
Otherwise it's the same as in the client functions.
361
-
362
-
#### Annotation approach
363
-
This is the same as the client functions, but you don't need to set the `polyType` property in the annotation. By default it will assume its a server function.
364
-
365
310
## Limitations
366
311
Comparing to its Typescript counterpart, the Java library is still missing the following features:
367
312
- Error handlers
@@ -370,6 +315,10 @@ Comparing to its Typescript counterpart, the Java library is still missing the f
370
315
These features will be added in the future releases.
371
316
372
317
## Changelog
318
+
### v0.6.0
319
+
- Removed add-server-function MOJO. Now only deploy-functions is allowed.
320
+
- Removed add-client-function MOJO. Now only deploy-functions is allowed.
321
+
- Added functions parameter to deploy-functions.
373
322
### v0.5.0
374
323
- Changed packages of generated classes to avoid classes with the same name and package but different attributes to override each other.
375
324
- Changed names of schema generated classes to use the schema title.
0 commit comments