Skip to content

Commit 4067f03

Browse files
authored
Delete function feature (#27)
* Added delete-function functionality.
1 parent c364b86 commit 4067f03

File tree

24 files changed

+258
-23
lines changed

24 files changed

+258
-23
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
8+
jobs:
9+
build:
10+
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
packages: write
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Set up JDK 17
19+
uses: actions/setup-java@v3
20+
with:
21+
java-version: '17'
22+
distribution: 'temurin'
23+
server-id: github
24+
settings-path: ${{ github.workspace }}
25+
26+
- uses: s4u/[email protected]
27+
with:
28+
servers: '[{"id": "ossrh", "username": "${{ secrets.DISTRIBUTION_REPOSITORY_RELEASE_USERNAME }}", "password": "${{ secrets.DISTRIBUTION_REPOSITORY_RELEASE_PASSWORD }}"}]'
29+
- 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/
31+
32+
- name: Delete sample post-production verification function
33+
run: mvn clean polyapi:delete-function -Dcontext=io.polyapi.deploy.verification -Dname=verification-function
34+
35+
- name: Deploy sample post-production verification function
36+
run: mvn polyapi:deploy-functions // Complete this
37+
38+
- name: Generate sources for sample post-production verification function
39+
run: mvn clean compile // Fix this
40+
41+
- name: Execute post-production verification function
42+
run: mvn clean verify

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)