Skip to content

Commit 12f5d9d

Browse files
authored
Merge pull request #28 from polyapi/develop
Delete function feature (#27)
2 parents b8a6275 + 43a4e36 commit 12f5d9d

File tree

24 files changed

+217
-24
lines changed

24 files changed

+217
-24
lines changed

.github/workflows/maven-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ jobs:
2727
with:
2828
servers: '[{"id": "ossrh", "username": "${{ secrets.DISTRIBUTION_REPOSITORY_RELEASE_USERNAME }}", "password": "${{ secrets.DISTRIBUTION_REPOSITORY_RELEASE_PASSWORD }}"}]'
2929
- name: Release to production
30-
run: mvn clean release:clean release:prepare release:perform -B -DaltDeploymentRepository=ossrh::https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/
30+
run: mvn clean release:clean release:prepare release:perform -B -DaltDeploymentRepository=ossrh::https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/

README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Java Client Library (beta)
22

3-
* Latest released version 0.9.3
4-
* Latest snapshot version 0.10.0-SNAPSHOT
3+
* Latest released version 0.10.1
4+
* Latest snapshot version 0.11.0-SNAPSHOT
55

66
## Introduction
77
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
5555
2. **Update the project.** Add the following to your project's `pom.xml`:
5656
```xml
5757
<properties>
58-
<poly.version>0.9.3</poly.version>
58+
<poly.version>0.10.1</poly.version>
5959
</properties>
6060
<dependencies>
6161
<dependency>
@@ -227,6 +227,22 @@ Here's the list of parameters:
227227
- **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.
228228
- **dry-run:** Flag that when added makes the MOJO prepare everything for a deployment but not do it. This is for debugging purposes.
229229

230+
#### delete-function
231+
This MOJO doesn't require a project to run.
232+
233+
It deletes a server/client/api/auth function, webhook or variable from the Poly server. It can take 2 types of inputs:
234+
- **id**: Deletes the entity with the matching ID.
235+
- **contxt/function name**: Deletes the entity that matches the context and function name. It's case insensitive, but will fall back to be case sensitive in case that there are 2 or more matches with different cases. If none of those cases match exactly, it will throw an error.
236+
237+
##### Parameters
238+
Here's the list of parameters:
239+
- **host (required):** The host where the Poly API instance is hosted.
240+
- **port:** The port that the Poly API instance is listening to. Default value is 443.
241+
- **apiKey (required):** The API key required to authenticate to Poly.
242+
- **id:** ID of the entity to delete. Cannot coexist with either `functionName` nor `context` arguments.
243+
- **functionName:** Name of the function to delete. Cannot coexist with `id` argument. Mandatory unless `id` is set.
244+
- **context:** Context of the function to delete. Cannot coexist with `id` argument. Mandatory unless `id` is set.
245+
230246
<a name="project-usage"></a>
231247
## Usage
232248

commons/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>io.polyapi</groupId>
66
<artifactId>parent-pom</artifactId>
7-
<version>0.10.2-SNAPSHOT</version>
7+
<version>0.11.0-SNAPSHOT</version>
88
<relativePath>../parent-pom</relativePath>
99
</parent>
1010

commons/src/main/java/io/polyapi/commons/api/service/PolyApiService.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ public <I> void patch(String relativePath, Map<String, List<String>> headers, Ma
6060
parsedCall(PATCH, relativePath, headers, queryParams, body, Void.TYPE);
6161
}
6262

63+
public void delete(String relativePath) {
64+
delete(relativePath, new HashMap<>(), new HashMap<>(), null);
65+
}
66+
67+
68+
public <I> void delete(String relativePath, Map<String, List<String>> headers, Map<String, List<String>> queryParams, I body) {
69+
parsedCall(DELETE, relativePath, headers, queryParams, body, Void.TYPE);
70+
}
71+
6372
private <I, O> O parsedCall(HttpMethod method, String relativePath, Map<String, List<String>> headers, Map<String, List<String>> queryParams, I body, Type expectedResponseType) {
6473
Map<String, List<String>> allHeaders = new HashMap<>();
6574
allHeaders.put("Accept", List.of("application/json"));

library/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>io.polyapi</groupId>
66
<artifactId>parent-pom</artifactId>
7-
<version>0.10.2-SNAPSHOT</version>
7+
<version>0.11.0-SNAPSHOT</version>
88
<relativePath>../parent-pom</relativePath>
99
</parent>
1010
<artifactId>library</artifactId>

parent-pom/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>io.polyapi</groupId>
55
<artifactId>parent-pom</artifactId>
6-
<version>0.10.2-SNAPSHOT</version>
6+
<version>0.11.0-SNAPSHOT</version>
77
<packaging>pom</packaging>
88
<name>Poly API Java parent POM</name>
99
<url>https://polyapi.io</url>

polyapi-maven-plugin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>io.polyapi</groupId>
66
<artifactId>parent-pom</artifactId>
7-
<version>0.10.2-SNAPSHOT</version>
7+
<version>0.11.0-SNAPSHOT</version>
88
<relativePath>../parent-pom</relativePath>
99
</parent>
1010
<artifactId>polyapi-maven-plugin</artifactId>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package io.polyapi.plugin.error.function;
2+
3+
import io.polyapi.plugin.error.PolyApiMavenPluginException;
4+
5+
import java.util.List;
6+
7+
import static java.lang.String.format;
8+
import static java.lang.String.join;
9+
10+
public class UnclearFunctionReferenceException extends PolyApiMavenPluginException {
11+
12+
public UnclearFunctionReferenceException(String expectedReference, List<String> retrievedReferences) {
13+
super(format("Unclear function reference. Expected '%s', but found '%s'. Please retry with a specific case sensitive one.", expectedReference, join(", ", retrievedReferences)));
14+
}
15+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package io.polyapi.plugin.error.validation;
2+
3+
import static java.lang.String.format;
4+
5+
public class BadExclusionException extends ValidationException {
6+
public BadExclusionException(String propertyName, String excludedPropertyName) {
7+
super(propertyName, format("Property '%s' cannot be set at the same time as property '%s'.", "%s", excludedPropertyName));
8+
}
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package io.polyapi.plugin.error.validation;
2+
3+
import static java.lang.String.format;
4+
5+
public class InvalidUUIDException extends ValidationException {
6+
public InvalidUUIDException(String propertyName, String propertyValue, Throwable cause) {
7+
super(propertyName, format("Property '%s' with value '%s' doesn't match UUID format.", propertyName, propertyValue), cause);
8+
}
9+
}

0 commit comments

Comments
 (0)