Skip to content

Commit 2a8c7df

Browse files
authored
Rename customAction to customFunction
1 parent d7d6ed8 commit 2a8c7df

File tree

4 files changed

+39
-40
lines changed

4 files changed

+39
-40
lines changed

cloudinary-core/src/main/java/com/cloudinary/CustomAction.java

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.cloudinary;
2+
3+
import com.cloudinary.utils.Base64Coder;
4+
5+
/**
6+
* Helper class to generate a custom function params to be used in {@link Transformation#customFunction(CustomFunction)}.
7+
*/
8+
public class CustomFunction extends BaseParam{
9+
10+
private CustomFunction(String... components) {
11+
super(components);
12+
}
13+
14+
/**
15+
* Generate a web-assembly custom action param to send to {@link Transformation#customFunction(CustomFunction)}
16+
* @param publicId The public id of the web-assembly file
17+
* @return A new instance of custom action param
18+
*/
19+
public static CustomFunction wasm(String publicId){
20+
return new CustomFunction("wasm", publicId);
21+
}
22+
23+
/**
24+
* Generate a remote lambda custom action param to send to {@link Transformation#customFunction(CustomFunction)}
25+
* @param url The public url of the aws lambda function
26+
* @return A new instance of custom action param
27+
*/
28+
public static CustomFunction remote(String url){
29+
return new CustomFunction("remote", Base64Coder.encodeURLSafeString(url));
30+
}
31+
}

cloudinary-core/src/main/java/com/cloudinary/Transformation.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -863,10 +863,10 @@ public T variables(Expression... variables) {
863863

864864
/**
865865
* Set a custom action, such as a call to a lambda function or a web-assembly function.
866-
* @param action The custom action to perform, see {@link CustomAction}.
866+
* @param action The custom action to perform, see {@link CustomFunction}.
867867
* @return The transformation for chaining
868868
*/
869-
public T customAction(CustomAction action) {
869+
public T customFunction(CustomFunction action) {
870870
return param("custom_action", action.toString());
871871
}
872872
}

cloudinary-core/src/test/java/com/cloudinary/test/CloudinaryTest.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import com.cloudinary.Cloudinary;
44
import com.cloudinary.ResponsiveBreakpoint;
55
import com.cloudinary.Transformation;
6-
import com.cloudinary.Url;
76
import com.cloudinary.transformation.*;
87
import com.cloudinary.utils.ObjectUtils;
98
import junitparams.JUnitParamsRunner;
@@ -23,8 +22,8 @@
2322
import java.util.regex.Matcher;
2423
import java.util.regex.Pattern;
2524

26-
import static com.cloudinary.CustomAction.remote;
27-
import static com.cloudinary.CustomAction.wasm;
25+
import static com.cloudinary.CustomFunction.remote;
26+
import static com.cloudinary.CustomFunction.wasm;
2827
import static com.cloudinary.utils.ObjectUtils.asMap;
2928
import static com.cloudinary.utils.ObjectUtils.emptyMap;
3029
import static org.junit.Assert.*;
@@ -1137,10 +1136,10 @@ public void testKeyframeInterval() {
11371136
}
11381137

11391138
@Test
1140-
public void testCustomAction(){
1141-
assertEquals("fn_wasm:blur_wasm", new Transformation().customAction(wasm("blur_wasm")).generate());
1142-
assertEquals("fn_remote:aHR0cHM6Ly9kZjM0cmE0YS5leGVjdXRlLWFwaS51cy13ZXN0LTIuYW1hem9uYXdzLmNvbS9kZWZhdWx0L2Nsb3VkaW5hcnlBY3Rpb24=",
1143-
new Transformation().customAction(remote("https://df34ra4a.execute-api.us-west-2.amazonaws.com/default/cloudinaryAction")).generate());
1139+
public void testCustomFunction(){
1140+
assertEquals("fn_wasm:blur_wasm", new Transformation().customFunction(wasm("blur_wasm")).generate());
1141+
assertEquals("fn_remote:aHR0cHM6Ly9kZjM0cmE0YS5leGVjdXRlLWFwaS51cy13ZXN0LTIuYW1hem9uYXdzLmNvbS9kZWZhdWx0L2Nsb3VkaW5hcnlGdW5jdGlvbg==",
1142+
new Transformation().customFunction(remote("https://df34ra4a.execute-api.us-west-2.amazonaws.com/default/cloudinaryFunction")).generate());
11441143
}
11451144

11461145
public static Map<String, String> getUrlParameters(URI uri) throws UnsupportedEncodingException {

0 commit comments

Comments
 (0)