This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit bf3cc4329536ff707eaf42f7eb4f7d56b0b1ac8c Author: Raffaele Marcello <marcelloraffa...@gmail.com> AuthorDate: Tue Mar 9 20:29:38 2021 +0100 CAMEL-15963 Create a Google Cloud Functions component --- .../catalog/docs/google-functions-component.adoc | 71 +++++++++++----------- .../google/functions/google-functions.json | 10 +-- .../src/main/docs/google-functions-component.adoc | 20 +++--- .../GoogleCloudFunctionsConfiguration.java | 11 ++-- .../functions/mock/MockCloudFunctionsService.java | 44 +++++++------- .../unit/GoogleCloudFunctionsBaseTest.java | 16 +++++ .../unit/GoogleCloudFunctionsComponentTest.java | 20 +++--- .../src/generated/resources/metadata.json | 2 +- .../builder/endpoint/StaticEndpointBuilders.java | 4 +- ...GoogleCloudFunctionsEndpointBuilderFactory.java | 12 ++-- .../ROOT/pages/google-functions-component.adoc | 71 +++++++++++----------- 11 files changed, 145 insertions(+), 136 deletions(-) diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/google-functions-component.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/google-functions-component.adoc index 1ed9b9e..956c8b9 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/google-functions-component.adoc +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/google-functions-component.adoc @@ -14,8 +14,8 @@ include::{cq-version}@camel-quarkus:ROOT:partial$reference/components/google-fun *{component-header}* -The Google Storage component provides access to https://cloud.google.com/storage/[Google Cloud Storage] via -the https://github.com/googleapis/java-storage[google java storage library]. +The Google Functions component provides access to https://cloud.google.com/functions/[Google Cloud Functions] via +the https://github.com/googleapis/java-functions[Google Cloud Functions Client for Java]. Maven users will need to add the following dependency to their pom.xml for this component: @@ -35,19 +35,17 @@ for this component: == Authentication Configuration -Google Storage component authentication is targeted for use with the GCP Service Accounts. -For more information please refer to https://cloud.google.com/storage/docs/reference/libraries#setting_up_authentication[Google Storage Auth Guide]. +Google Functions component authentication is targeted for use with the GCP Service Accounts. +For more information please refer to https://github.com/googleapis/google-cloud-java#authentication[Google Cloud Authentication]. When you have the **service account key** you can provide authentication credentials to your application code. Google security credentials can be set through the component endpoint: [source,text] -------------------------------------------------------- -String endpoint = "google-storage://myCamelBucket?serviceAccountKey=/home/user/Downloads/my-key.json"; +String endpoint = "google-functions://myCamelFunction?serviceAccountKey=/home/user/Downloads/my-key.json"; -------------------------------------------------------- -Or by providing the path to the GCP credentials file location: - -Provide authentication credentials to your application code by setting the environment variable `GOOGLE_APPLICATION_CREDENTIALS` : +Or by setting the environment variable `GOOGLE_APPLICATION_CREDENTIALS` : [source,text] -------------------------------------------------------- @@ -59,19 +57,18 @@ export GOOGLE_APPLICATION_CREDENTIALS="/home/user/Downloads/my-key.json" [source,text] -------------------------------------------------------- -google-storage://bucketNameOrArn?[options] +google-functions://functionName?[options] -------------------------------------------------------- -By default the bucket will be created if it don't already exists. + You can append query options to the URI in the following format, ?options=value&option2=value&... -For example in order to read file `hello.txt` from bucket `myCamelBucket`, use the following snippet: +For example in order to call the function `myCamelFunction` from the project `myProject` and location `us-central1`, use the following snippet: [source,java] -------------------------------------------------------------------------------- -from("google-storage://myCamelBucket?serviceAccountKey=/home/user/Downloads/my-key.json&objectName=hello.txt") - .to("file:/var/downloaded"); +from("google-functions://myCamelFunction?project=myProject&location=us-central1&operation=callFunction&serviceAccountKey=/home/user/Downloads/my-key.json") + .to("direct:test"); -------------------------------------------------------------------------------- @@ -94,7 +91,7 @@ The GoogleCloudFunctions component supports 2 options, which are listed below. The GoogleCloudFunctions endpoint is configured using URI syntax: ---- -google-functions:name +google-functions:functionName ---- with the following path and query parameters: @@ -105,7 +102,7 @@ with the following path and query parameters: [width="100%",cols="2,5,^1,2",options="header"] |=== | Name | Description | Default | Type -| *functionName* | *Required* Function name | | String +| *functionName* | *Required* The user-defined name of the function | | String |=== @@ -117,10 +114,10 @@ with the following path and query parameters: | Name | Description | Default | Type | *serviceAccountKey* (common) | Service account key to authenticate an application as a service account | | String | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...] -| *location* (producer) | location | | String -| *operation* (producer) | The operation to perform on the producer. There are 3 enums and the value can be one of: listFunctions, getFunction, callFunction | | GoogleCloudFunctionsOperations -| *pojoRequest* (producer) | Configure the input type. If true the message will be POJO type. | false | boolean -| *project* (producer) | Project | | String +| *location* (producer) | The Google Cloud Location (Region) where the Function is located | | String +| *operation* (producer) | The operation to perform on the producer. There are 8 enums and the value can be one of: listFunctions, getFunction, callFunction, generateDownloadUrl, generateUploadUrl, createFunction, updateFunction, deleteFunction | | GoogleCloudFunctionsOperations +| *pojoRequest* (producer) | Specifies if the request is a pojo request | false | boolean +| *project* (producer) | The Google Cloud Project name where the Function is located | | String | *client* (advanced) | *Autowired* The client to use during service invocation. | | CloudFunctionsServiceClient |=== // endpoint options: END @@ -128,7 +125,7 @@ with the following path and query parameters: == Usage -=== Message headers evaluated by the Google Storage Producer +=== Message headers evaluated by the Google Functions Producer [width="100%",cols="10%,10%,80%",options="header",] |======================================================================= @@ -159,7 +156,7 @@ with the following path and query parameters: |======================================================================= -=== Message headers set by the Google Storage Producer +=== Message headers set by the Google Functions Producer [width="100%",cols="10%,10%,80%",options="header",] |======================================================================= @@ -192,14 +189,14 @@ with the following path and query parameters: | `CamelGoogleCloudStorageMediaLink` |`String` | The media link | `CamelGoogleCloudStorageMetageneration` | `String` | The metageneration of the object | `CamelGoogleCloudStorageContentLength` |`Long` |The content length of this object. -| `CamelGoogleCloudStorageStorageClass` | `String` | The storage class of the object +| `CamelGoogleCloudStorageStorageClass` | `String` | The functions class of the object | `CamelGoogleCloudStorageCreateTime` |`String` | The creation time of the object | `CamelGoogleCloudStorageLastUpdate` |`String` | The last update of the object |======================================================================= -=== Google Storage Producer operations +=== Google Functions Producer operations -Google Storage component provides the following operation on the producer side: +Google Functions component provides the following operation on the producer side: - copyObject - listObjects @@ -213,17 +210,17 @@ If you don't specify an operation explicitly the producer will a file upload. === Advanced component configuration -If you need to have more control over the `storageClient` instance configuration, you can create your own instance and refer to it in your Camel google-storage component configuration: +If you need to have more control over the `functionsClient` instance configuration, you can create your own instance and refer to it in your Camel google-functions component configuration: [source,java] -------------------------------------------------------------------------------- -from("google-storage://myCamelBucket?storageClient=#client") +from("google-functions://myCamelFunction?functionsClient=#client") .to("mock:result"); -------------------------------------------------------------------------------- -=== Google Storage Producer Operation examples +=== Google Functions Producer Operation examples -- File Upload: This operation will upload a file to the Google Storage based on the body content +- File Upload: This operation will upload a file to the Google Functions based on the body content [source,java] -------------------------------------------------------------------------------- @@ -235,7 +232,7 @@ from("direct:start") exchange.getIn().setHeader(GoogleCloudStorageConstants.OBJECT_NAME, "camel.txt"); exchange.getIn().setBody(bais); }) -.to("google-storage://myCamelBucket?serviceAccountKey=/home/user/Downloads/my-key.json") +.to("google-functions://myCamelFunction?serviceAccountKey=/home/user/Downloads/my-key.json") .log("uploaded file object:${header.CamelGoogleCloudStorageObjectName}, body:${body}"); -------------------------------------------------------------------------------- @@ -251,7 +248,7 @@ This operation will upload the file camel.txt with the content "Camel rocks!" in exchange.getIn().setHeader(GoogleCloudStorageConstants.DESTINATION_BUCKET_NAME, "myCamelBucket_dest"); exchange.getIn().setHeader(GoogleCloudStorageConstants.DESTINATION_OBJECT_NAME, "camel_copy.txt"); }) - .to("google-storage://myCamelBucket?serviceAccountKey=/home/user/Downloads/my-key.json") + .to("google-functions://myCamelFunction?serviceAccountKey=/home/user/Downloads/my-key.json") .to("mock:result"); -------------------------------------------------------------------------------- @@ -265,7 +262,7 @@ This operation will copy the object with the name expressed in the header DESTIN exchange.getIn().setHeader(GoogleCloudStorageConstants.OPERATION, GoogleCloudStorageOperations.deleteObject); exchange.getIn().setHeader(GoogleCloudStorageConstants.OBJECT_NAME, "camel.txt" ); }) - .to("google-storage://myCamelBucket?serviceAccountKey=/home/user/Downloads/my-key.json") + .to("google-functions://myCamelFunction?serviceAccountKey=/home/user/Downloads/my-key.json") .to("mock:result"); -------------------------------------------------------------------------------- @@ -276,7 +273,7 @@ This operation will delete the object from the bucket myCamelBucket. [source,java] -------------------------------------------------------------------------------- from("direct:start") -.to("google-storage://myCamelBucket?serviceAccountKey=/home/user/Downloads/my-key.json&operation=listBuckets") +.to("google-functions://myCamelFunction?serviceAccountKey=/home/user/Downloads/my-key.json&operation=listBuckets") .to("mock:result"); -------------------------------------------------------------------------------- @@ -287,7 +284,7 @@ This operation will list the buckets for this account. [source,java] -------------------------------------------------------------------------------- from("direct:start") -.to("google-storage://myCamelBucket?serviceAccountKey=/home/user/Downloads/my-key.json&operation=deleteBucket") +.to("google-functions://myCamelFunction?serviceAccountKey=/home/user/Downloads/my-key.json&operation=deleteBucket") .to("mock:result"); -------------------------------------------------------------------------------- @@ -298,7 +295,7 @@ This operation will delete the bucket myCamelBucket. [source,java] -------------------------------------------------------------------------------- from("direct:start") -.to("google-storage://myCamelBucket?serviceAccountKey=/home/user/Downloads/my-key.json&operation=listObjects") +.to("google-functions://myCamelFunction?serviceAccountKey=/home/user/Downloads/my-key.json&operation=listObjects") .to("mock:result"); -------------------------------------------------------------------------------- @@ -312,7 +309,7 @@ from("direct:start") .process( exchange -> { exchange.getIn().setHeader(GoogleCloudStorageConstants.OBJECT_NAME, "camel.txt"); }) -.to("google-storage://myCamelBucket?serviceAccountKey=/home/user/Downloads/my-key.json&operation=getObject") +.to("google-functions://myCamelFunction?serviceAccountKey=/home/user/Downloads/my-key.json&operation=getObject") .to("mock:result"); -------------------------------------------------------------------------------- @@ -327,7 +324,7 @@ from("direct:start") exchange.getIn().setHeader(GoogleCloudStorageConstants.OBJECT_NAME, "camel.txt" ); exchange.getIn().setHeader(GoogleCloudStorageConstants.DOWNLOAD_LINK_EXPIRATION_TIME, 86400000L); //1 day }) -.to("google-storage://myCamelBucket?serviceAccountKey=/home/user/Downloads/my-key.json&operation=createDownloadLink") +.to("google-functions://myCamelFunction?serviceAccountKey=/home/user/Downloads/my-key.json&operation=createDownloadLink") .to("mock:result"); -------------------------------------------------------------------------------- @@ -345,7 +342,7 @@ This will require specifying the destinationBucket option. As example: [source,java] -------------------------------------------------------------------------------- - from("google-storage://myCamelBucket?serviceAccountKey=/home/user/Downloads/my-key.json" + from("google-functions://myCamelFunction?serviceAccountKey=/home/user/Downloads/my-key.json" + "&autoCreateBucket=true" + "&destinationBucket=myCamelProcessedBucket" + "&moveAfterRead=true" diff --git a/components/camel-google-functions/src/generated/resources/org/apache/camel/component/google/functions/google-functions.json b/components/camel-google-functions/src/generated/resources/org/apache/camel/component/google/functions/google-functions.json index 43eaa11..21a6075 100644 --- a/components/camel-google-functions/src/generated/resources/org/apache/camel/component/google/functions/google-functions.json +++ b/components/camel-google-functions/src/generated/resources/org/apache/camel/component/google/functions/google-functions.json @@ -26,13 +26,13 @@ "autowiredEnabled": { "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which t [...] }, "properties": { - "functionName": { "kind": "path", "displayName": "Function Name", "group": "common", "label": "common", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.google.functions.GoogleCloudFunctionsConfiguration", "configurationField": "configuration", "description": "Function name" }, + "functionName": { "kind": "path", "displayName": "Function Name", "group": "common", "label": "common", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.google.functions.GoogleCloudFunctionsConfiguration", "configurationField": "configuration", "description": "The user-defined name of the function" }, "serviceAccountKey": { "kind": "parameter", "displayName": "Service Account Key", "group": "common", "label": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.google.functions.GoogleCloudFunctionsConfiguration", "configurationField": "configuration", "description": "Service account key to authenticate an application as a service account" }, "lazyStartProducer": { "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during sta [...] - "location": { "kind": "parameter", "displayName": "Location", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.google.functions.GoogleCloudFunctionsConfiguration", "configurationField": "configuration", "description": "location" }, - "operation": { "kind": "parameter", "displayName": "Operation", "group": "producer", "label": "producer", "required": false, "type": "object", "javaType": "org.apache.camel.component.google.functions.GoogleCloudFunctionsOperations", "enum": [ "listFunctions", "getFunction", "callFunction" ], "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.google.functions.GoogleCloudFunctionsConfiguration", "configurationField": "configurati [...] - "pojoRequest": { "kind": "parameter", "displayName": "Pojo Request", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.google.functions.GoogleCloudFunctionsConfiguration", "configurationField": "configuration", "description": "Configure the input type. If true the message will be POJO type." }, - "project": { "kind": "parameter", "displayName": "Project", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.google.functions.GoogleCloudFunctionsConfiguration", "configurationField": "configuration", "description": "Project" }, + "location": { "kind": "parameter", "displayName": "Location", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.google.functions.GoogleCloudFunctionsConfiguration", "configurationField": "configuration", "description": "The Google Cloud Location (Region) where the Function is located" }, + "operation": { "kind": "parameter", "displayName": "Operation", "group": "producer", "label": "producer", "required": false, "type": "object", "javaType": "org.apache.camel.component.google.functions.GoogleCloudFunctionsOperations", "enum": [ "listFunctions", "getFunction", "callFunction", "generateDownloadUrl", "generateUploadUrl", "createFunction", "updateFunction", "deleteFunction" ], "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel [...] + "pojoRequest": { "kind": "parameter", "displayName": "Pojo Request", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.google.functions.GoogleCloudFunctionsConfiguration", "configurationField": "configuration", "description": "Specifies if the request is a pojo request" }, + "project": { "kind": "parameter", "displayName": "Project", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.google.functions.GoogleCloudFunctionsConfiguration", "configurationField": "configuration", "description": "The Google Cloud Project name where the Function is located" }, "client": { "kind": "parameter", "displayName": "Client", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "com.google.cloud.functions.v1.CloudFunctionsServiceClient", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "configurationClass": "org.apache.camel.component.google.functions.GoogleCloudFunctionsConfiguration", "configurationField": "configuration", "description": "The client to use during service invocation." } } } diff --git a/components/camel-google-functions/src/main/docs/google-functions-component.adoc b/components/camel-google-functions/src/main/docs/google-functions-component.adoc index 530a4cd..956c8b9 100644 --- a/components/camel-google-functions/src/main/docs/google-functions-component.adoc +++ b/components/camel-google-functions/src/main/docs/google-functions-component.adoc @@ -2,7 +2,7 @@ = GoogleCloudFunctions Component :docTitle: GoogleCloudFunctions :artifactId: camel-google-functions -:description: Store and retrieve objects from Google Cloud Functions Service using the google-cloud-functions library. +:description: Store and retrieve objects from Google Cloud Functions Service using the google-cloud-storage library. :since: 3.9 :supportLevel: Preview :component-header: Only producer is supported @@ -15,7 +15,7 @@ include::{cq-version}@camel-quarkus:ROOT:partial$reference/components/google-fun *{component-header}* The Google Functions component provides access to https://cloud.google.com/functions/[Google Cloud Functions] via -the https://github.com/googleapis/java-functions[google java functions library]. +the https://github.com/googleapis/java-functions[Google Cloud Functions Client for Java]. Maven users will need to add the following dependency to their pom.xml for this component: @@ -45,9 +45,7 @@ Google security credentials can be set through the component endpoint: String endpoint = "google-functions://myCamelFunction?serviceAccountKey=/home/user/Downloads/my-key.json"; -------------------------------------------------------- -Or by providing the path to the GCP credentials file location: - -Provide authentication credentials to your application code by setting the environment variable `GOOGLE_APPLICATION_CREDENTIALS` : +Or by setting the environment variable `GOOGLE_APPLICATION_CREDENTIALS` : [source,text] -------------------------------------------------------- @@ -93,7 +91,7 @@ The GoogleCloudFunctions component supports 2 options, which are listed below. The GoogleCloudFunctions endpoint is configured using URI syntax: ---- -google-functions:name +google-functions:functionName ---- with the following path and query parameters: @@ -104,7 +102,7 @@ with the following path and query parameters: [width="100%",cols="2,5,^1,2",options="header"] |=== | Name | Description | Default | Type -| *functionName* | *Required* Function name | | String +| *functionName* | *Required* The user-defined name of the function | | String |=== @@ -116,10 +114,10 @@ with the following path and query parameters: | Name | Description | Default | Type | *serviceAccountKey* (common) | Service account key to authenticate an application as a service account | | String | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...] -| *location* (producer) | location | | String -| *operation* (producer) | The operation to perform on the producer. There are 3 enums and the value can be one of: listFunctions, getFunction, callFunction | | GoogleCloudFunctionsOperations -| *pojoRequest* (producer) | Configure the input type. If true the message will be POJO type. | false | boolean -| *project* (producer) | Project | | String +| *location* (producer) | The Google Cloud Location (Region) where the Function is located | | String +| *operation* (producer) | The operation to perform on the producer. There are 8 enums and the value can be one of: listFunctions, getFunction, callFunction, generateDownloadUrl, generateUploadUrl, createFunction, updateFunction, deleteFunction | | GoogleCloudFunctionsOperations +| *pojoRequest* (producer) | Specifies if the request is a pojo request | false | boolean +| *project* (producer) | The Google Cloud Project name where the Function is located | | String | *client* (advanced) | *Autowired* The client to use during service invocation. | | CloudFunctionsServiceClient |=== // endpoint options: END diff --git a/components/camel-google-functions/src/main/java/org/apache/camel/component/google/functions/GoogleCloudFunctionsConfiguration.java b/components/camel-google-functions/src/main/java/org/apache/camel/component/google/functions/GoogleCloudFunctionsConfiguration.java index 3b65664..92dcdc8 100644 --- a/components/camel-google-functions/src/main/java/org/apache/camel/component/google/functions/GoogleCloudFunctionsConfiguration.java +++ b/components/camel-google-functions/src/main/java/org/apache/camel/component/google/functions/GoogleCloudFunctionsConfiguration.java @@ -26,23 +26,24 @@ import org.apache.camel.spi.UriPath; @UriParams public class GoogleCloudFunctionsConfiguration implements Cloneable { - @UriPath(label = "common", description = "Function name") + @UriPath(label = "common", description = "The user-defined name of the function") @Metadata(required = true) private String functionName; @UriParam(label = "common", description = "Service account key to authenticate an application as a service account") private String serviceAccountKey; - @UriParam(label = "producer", description = "Project") + @UriParam(label = "producer", description = "The Google Cloud Project name where the Function is located") private String project; - @UriParam(label = "producer", description = "location") + @UriParam(label = "producer", description = "The Google Cloud Location (Region) where the Function is located") private String location; - @UriParam(label = "producer", enums = "listFunctions,getFunction,callFunction") + @UriParam(label = "producer", + enums = "listFunctions,getFunction,callFunction,generateDownloadUrl,generateUploadUrl,createFunction,updateFunction,deleteFunction") private GoogleCloudFunctionsOperations operation; - @UriParam(defaultValue = "false") + @UriParam(defaultValue = "false", description = "Specifies if the request is a pojo request") private boolean pojoRequest; @UriParam(label = "advanced") diff --git a/components/camel-google-functions/src/test/java/org/apache/camel/component/google/functions/mock/MockCloudFunctionsService.java b/components/camel-google-functions/src/test/java/org/apache/camel/component/google/functions/mock/MockCloudFunctionsService.java index 757ae18..9f815c8 100644 --- a/components/camel-google-functions/src/test/java/org/apache/camel/component/google/functions/mock/MockCloudFunctionsService.java +++ b/components/camel-google-functions/src/test/java/org/apache/camel/component/google/functions/mock/MockCloudFunctionsService.java @@ -81,10 +81,10 @@ public class MockCloudFunctionsService extends CloudFunctionsServiceImplBase imp Object response = responses.remove(); if (response instanceof ListFunctionsResponse) { requests.add(request); - responseObserver.onNext(((ListFunctionsResponse) response)); + responseObserver.onNext((ListFunctionsResponse) response); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); + responseObserver.onError((Exception) response); } else { responseObserver.onError(new IllegalArgumentException( String.format("Unrecognized response type %s for method ListFunctions, expected %s or %s", @@ -97,10 +97,10 @@ public class MockCloudFunctionsService extends CloudFunctionsServiceImplBase imp Object response = responses.remove(); if (response instanceof CloudFunction) { requests.add(request); - responseObserver.onNext(((CloudFunction) response)); + responseObserver.onNext((CloudFunction) response); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); + responseObserver.onError((Exception) response); } else { responseObserver.onError(new IllegalArgumentException( String.format("Unrecognized response type %s for method GetFunction, expected %s or %s", @@ -113,10 +113,10 @@ public class MockCloudFunctionsService extends CloudFunctionsServiceImplBase imp Object response = responses.remove(); if (response instanceof Operation) { requests.add(request); - responseObserver.onNext(((Operation) response)); + responseObserver.onNext((Operation) response); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); + responseObserver.onError((Exception) response); } else { responseObserver.onError(new IllegalArgumentException( String.format("Unrecognized response type %s for method CreateFunction, expected %s or %s", @@ -129,10 +129,10 @@ public class MockCloudFunctionsService extends CloudFunctionsServiceImplBase imp Object response = responses.remove(); if (response instanceof Operation) { requests.add(request); - responseObserver.onNext(((Operation) response)); + responseObserver.onNext((Operation) response); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); + responseObserver.onError((Exception) response); } else { responseObserver.onError(new IllegalArgumentException( String.format("Unrecognized response type %s for method UpdateFunction, expected %s or %s", @@ -145,10 +145,10 @@ public class MockCloudFunctionsService extends CloudFunctionsServiceImplBase imp Object response = responses.remove(); if (response instanceof Operation) { requests.add(request); - responseObserver.onNext(((Operation) response)); + responseObserver.onNext((Operation) response); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); + responseObserver.onError((Exception) response); } else { responseObserver.onError(new IllegalArgumentException( String.format("Unrecognized response type %s for method DeleteFunction, expected %s or %s", @@ -161,10 +161,10 @@ public class MockCloudFunctionsService extends CloudFunctionsServiceImplBase imp Object response = responses.remove(); if (response instanceof CallFunctionResponse) { requests.add(request); - responseObserver.onNext(((CallFunctionResponse) response)); + responseObserver.onNext((CallFunctionResponse) response); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); + responseObserver.onError((Exception) response); } else { responseObserver.onError(new IllegalArgumentException( String.format("Unrecognized response type %s for method CallFunction, expected %s or %s", @@ -179,10 +179,10 @@ public class MockCloudFunctionsService extends CloudFunctionsServiceImplBase imp Object response = responses.remove(); if (response instanceof GenerateUploadUrlResponse) { requests.add(request); - responseObserver.onNext(((GenerateUploadUrlResponse) response)); + responseObserver.onNext((GenerateUploadUrlResponse) response); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); + responseObserver.onError((Exception) response); } else { responseObserver.onError(new IllegalArgumentException( String.format("Unrecognized response type %s for method GenerateUploadUrl, expected %s or %s", @@ -198,10 +198,10 @@ public class MockCloudFunctionsService extends CloudFunctionsServiceImplBase imp Object response = responses.remove(); if (response instanceof GenerateDownloadUrlResponse) { requests.add(request); - responseObserver.onNext(((GenerateDownloadUrlResponse) response)); + responseObserver.onNext((GenerateDownloadUrlResponse) response); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); + responseObserver.onError((Exception) response); } else { responseObserver.onError(new IllegalArgumentException( String.format("Unrecognized response type %s for method GenerateDownloadUrl, expected %s or %s", @@ -215,10 +215,10 @@ public class MockCloudFunctionsService extends CloudFunctionsServiceImplBase imp Object response = responses.remove(); if (response instanceof Policy) { requests.add(request); - responseObserver.onNext(((Policy) response)); + responseObserver.onNext((Policy) response); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); + responseObserver.onError((Exception) response); } else { responseObserver.onError(new IllegalArgumentException( String.format("Unrecognized response type %s for method SetIamPolicy, expected %s or %s", @@ -231,10 +231,10 @@ public class MockCloudFunctionsService extends CloudFunctionsServiceImplBase imp Object response = responses.remove(); if (response instanceof Policy) { requests.add(request); - responseObserver.onNext(((Policy) response)); + responseObserver.onNext((Policy) response); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); + responseObserver.onError((Exception) response); } else { responseObserver.onError(new IllegalArgumentException( String.format("Unrecognized response type %s for method GetIamPolicy, expected %s or %s", @@ -249,10 +249,10 @@ public class MockCloudFunctionsService extends CloudFunctionsServiceImplBase imp Object response = responses.remove(); if (response instanceof TestIamPermissionsResponse) { requests.add(request); - responseObserver.onNext(((TestIamPermissionsResponse) response)); + responseObserver.onNext((TestIamPermissionsResponse) response); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); + responseObserver.onError((Exception) response); } else { responseObserver.onError(new IllegalArgumentException( String.format("Unrecognized response type %s for method TestIamPermissions, expected %s or %s", diff --git a/components/camel-google-functions/src/test/java/org/apache/camel/component/google/functions/unit/GoogleCloudFunctionsBaseTest.java b/components/camel-google-functions/src/test/java/org/apache/camel/component/google/functions/unit/GoogleCloudFunctionsBaseTest.java index 47ceac0..8366f7f 100644 --- a/components/camel-google-functions/src/test/java/org/apache/camel/component/google/functions/unit/GoogleCloudFunctionsBaseTest.java +++ b/components/camel-google-functions/src/test/java/org/apache/camel/component/google/functions/unit/GoogleCloudFunctionsBaseTest.java @@ -1,3 +1,19 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.camel.component.google.functions.unit; import java.util.Arrays; diff --git a/components/camel-google-functions/src/test/java/org/apache/camel/component/google/functions/unit/GoogleCloudFunctionsComponentTest.java b/components/camel-google-functions/src/test/java/org/apache/camel/component/google/functions/unit/GoogleCloudFunctionsComponentTest.java index d9e94f9..7e0e4ba 100644 --- a/components/camel-google-functions/src/test/java/org/apache/camel/component/google/functions/unit/GoogleCloudFunctionsComponentTest.java +++ b/components/camel-google-functions/src/test/java/org/apache/camel/component/google/functions/unit/GoogleCloudFunctionsComponentTest.java @@ -222,7 +222,7 @@ public class GoogleCloudFunctionsComponentTest extends GoogleCloudFunctionsBaseT List<AbstractMessage> actualRequests = mockCloudFunctionsService.getRequests(); assertEquals(1, actualRequests.size()); - GetFunctionRequest actualRequest = ((GetFunctionRequest) actualRequests.get(0)); + GetFunctionRequest actualRequest = (GetFunctionRequest) actualRequests.get(0); assertEquals(cfName.toString(), actualRequest.getName()); assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -252,7 +252,7 @@ public class GoogleCloudFunctionsComponentTest extends GoogleCloudFunctionsBaseT List<AbstractMessage> actualRequests = mockCloudFunctionsService.getRequests(); assertEquals(1, actualRequests.size()); - GetFunctionRequest actualRequest = ((GetFunctionRequest) actualRequests.get(0)); + GetFunctionRequest actualRequest = (GetFunctionRequest) actualRequests.get(0); assertEquals(cfName.toString(), actualRequest.getName()); assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -277,7 +277,7 @@ public class GoogleCloudFunctionsComponentTest extends GoogleCloudFunctionsBaseT List<AbstractMessage> actualRequests = mockCloudFunctionsService.getRequests(); assertEquals(1, actualRequests.size()); - CallFunctionRequest actualRequest = ((CallFunctionRequest) actualRequests.get(0)); + CallFunctionRequest actualRequest = (CallFunctionRequest) actualRequests.get(0); assertEquals(name.toString(), actualRequest.getName()); assertEquals(data, actualRequest.getData()); @@ -305,7 +305,7 @@ public class GoogleCloudFunctionsComponentTest extends GoogleCloudFunctionsBaseT List<AbstractMessage> actualRequests = mockCloudFunctionsService.getRequests(); assertEquals(1, actualRequests.size()); - CallFunctionRequest actualRequest = ((CallFunctionRequest) actualRequests.get(0)); + CallFunctionRequest actualRequest = (CallFunctionRequest) actualRequests.get(0); assertEquals(cfName.toString(), actualRequest.getName()); assertEquals(data, actualRequest.getData()); @@ -329,7 +329,7 @@ public class GoogleCloudFunctionsComponentTest extends GoogleCloudFunctionsBaseT List<AbstractMessage> actualRequests = mockCloudFunctionsService.getRequests(); assertEquals(1, actualRequests.size()); - GenerateDownloadUrlRequest actualRequest = ((GenerateDownloadUrlRequest) actualRequests.get(0)); + GenerateDownloadUrlRequest actualRequest = (GenerateDownloadUrlRequest) actualRequests.get(0); assertEquals(cfName.toString(), actualRequest.getName()); } @@ -354,7 +354,7 @@ public class GoogleCloudFunctionsComponentTest extends GoogleCloudFunctionsBaseT List<AbstractMessage> actualRequests = mockCloudFunctionsService.getRequests(); assertEquals(1, actualRequests.size()); - GenerateDownloadUrlRequest actualRequest = ((GenerateDownloadUrlRequest) actualRequests.get(0)); + GenerateDownloadUrlRequest actualRequest = (GenerateDownloadUrlRequest) actualRequests.get(0); assertEquals(cfName.toString(), actualRequest.getName()); } @@ -373,7 +373,7 @@ public class GoogleCloudFunctionsComponentTest extends GoogleCloudFunctionsBaseT List<AbstractMessage> actualRequests = mockCloudFunctionsService.getRequests(); assertEquals(1, actualRequests.size()); - GenerateUploadUrlRequest actualRequest = ((GenerateUploadUrlRequest) actualRequests.get(0)); + GenerateUploadUrlRequest actualRequest = (GenerateUploadUrlRequest) actualRequests.get(0); assertEquals(locationName.toString(), actualRequest.getParent()); } @@ -395,7 +395,7 @@ public class GoogleCloudFunctionsComponentTest extends GoogleCloudFunctionsBaseT List<AbstractMessage> actualRequests = mockCloudFunctionsService.getRequests(); assertEquals(1, actualRequests.size()); - GenerateUploadUrlRequest actualRequest = ((GenerateUploadUrlRequest) actualRequests.get(0)); + GenerateUploadUrlRequest actualRequest = (GenerateUploadUrlRequest) actualRequests.get(0); assertEquals(locationName.toString(), actualRequest.getParent()); } @@ -525,7 +525,7 @@ public class GoogleCloudFunctionsComponentTest extends GoogleCloudFunctionsBaseT assertNotNull(actualResponse); List<AbstractMessage> actualRequests = mockCloudFunctionsService.getRequests(); assertEquals(1, actualRequests.size()); - DeleteFunctionRequest actualRequest = ((DeleteFunctionRequest) actualRequests.get(0)); + DeleteFunctionRequest actualRequest = (DeleteFunctionRequest) actualRequests.get(0); assertEquals(cfName.toString(), actualRequest.getName()); } @@ -544,7 +544,7 @@ public class GoogleCloudFunctionsComponentTest extends GoogleCloudFunctionsBaseT assertNotNull(actualResponse); List<AbstractMessage> actualRequests = mockCloudFunctionsService.getRequests(); assertEquals(1, actualRequests.size()); - DeleteFunctionRequest actualRequest = ((DeleteFunctionRequest) actualRequests.get(0)); + DeleteFunctionRequest actualRequest = (DeleteFunctionRequest) actualRequests.get(0); assertEquals(cfName.toString(), actualRequest.getName()); } } diff --git a/core/camel-componentdsl/src/generated/resources/metadata.json b/core/camel-componentdsl/src/generated/resources/metadata.json index 9e4b060..d25894f 100644 --- a/core/camel-componentdsl/src/generated/resources/metadata.json +++ b/core/camel-componentdsl/src/generated/resources/metadata.json @@ -2700,7 +2700,7 @@ "version": "3.9.0-SNAPSHOT", "scheme": "google-functions", "extendsScheme": "", - "syntax": "google-functions:name", + "syntax": "google-functions:functionName", "async": false, "api": false, "consumerOnly": false, diff --git a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java index af7104a..719e0419 100644 --- a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java +++ b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java @@ -5599,7 +5599,7 @@ public class StaticEndpointBuilders { * Syntax: <code>google-functions:functionName</code> * * Path parameter: functionName (required) - * Function name + * The user-defined name of the function * * @param path functionName * @return the dsl builder @@ -5620,7 +5620,7 @@ public class StaticEndpointBuilders { * Syntax: <code>google-functions:functionName</code> * * Path parameter: functionName (required) - * Function name + * The user-defined name of the function * * @param componentName to use a custom component name for the endpoint * instead of the default name diff --git a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/GoogleCloudFunctionsEndpointBuilderFactory.java b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/GoogleCloudFunctionsEndpointBuilderFactory.java index 3a574ab..6322dbd 100644 --- a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/GoogleCloudFunctionsEndpointBuilderFactory.java +++ b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/GoogleCloudFunctionsEndpointBuilderFactory.java @@ -106,7 +106,7 @@ public interface GoogleCloudFunctionsEndpointBuilderFactory { return this; } /** - * location. + * The Google Cloud Location (Region) where the Function is located. * * The option is a: <code>java.lang.String</code> type. * @@ -151,7 +151,7 @@ public interface GoogleCloudFunctionsEndpointBuilderFactory { return this; } /** - * Configure the input type. If true the message will be POJO type. + * Specifies if the request is a pojo request. * * The option is a: <code>boolean</code> type. * @@ -167,7 +167,7 @@ public interface GoogleCloudFunctionsEndpointBuilderFactory { return this; } /** - * Configure the input type. If true the message will be POJO type. + * Specifies if the request is a pojo request. * * The option will be converted to a <code>boolean</code> * type. @@ -184,7 +184,7 @@ public interface GoogleCloudFunctionsEndpointBuilderFactory { return this; } /** - * Project. + * The Google Cloud Project name where the Function is located. * * The option is a: <code>java.lang.String</code> type. * @@ -268,7 +268,7 @@ public interface GoogleCloudFunctionsEndpointBuilderFactory { * Syntax: <code>google-functions:functionName</code> * * Path parameter: functionName (required) - * Function name + * The user-defined name of the function * * @param path functionName * @return the dsl builder @@ -288,7 +288,7 @@ public interface GoogleCloudFunctionsEndpointBuilderFactory { * Syntax: <code>google-functions:functionName</code> * * Path parameter: functionName (required) - * Function name + * The user-defined name of the function * * @param componentName to use a custom component name for the endpoint * instead of the default name diff --git a/docs/components/modules/ROOT/pages/google-functions-component.adoc b/docs/components/modules/ROOT/pages/google-functions-component.adoc index 1cb25d9..2ed67bd 100644 --- a/docs/components/modules/ROOT/pages/google-functions-component.adoc +++ b/docs/components/modules/ROOT/pages/google-functions-component.adoc @@ -16,8 +16,8 @@ include::{cq-version}@camel-quarkus:ROOT:partial$reference/components/google-fun *{component-header}* -The Google Storage component provides access to https://cloud.google.com/storage/[Google Cloud Storage] via -the https://github.com/googleapis/java-storage[google java storage library]. +The Google Functions component provides access to https://cloud.google.com/functions/[Google Cloud Functions] via +the https://github.com/googleapis/java-functions[Google Cloud Functions Client for Java]. Maven users will need to add the following dependency to their pom.xml for this component: @@ -37,19 +37,17 @@ for this component: == Authentication Configuration -Google Storage component authentication is targeted for use with the GCP Service Accounts. -For more information please refer to https://cloud.google.com/storage/docs/reference/libraries#setting_up_authentication[Google Storage Auth Guide]. +Google Functions component authentication is targeted for use with the GCP Service Accounts. +For more information please refer to https://github.com/googleapis/google-cloud-java#authentication[Google Cloud Authentication]. When you have the **service account key** you can provide authentication credentials to your application code. Google security credentials can be set through the component endpoint: [source,text] -------------------------------------------------------- -String endpoint = "google-storage://myCamelBucket?serviceAccountKey=/home/user/Downloads/my-key.json"; +String endpoint = "google-functions://myCamelFunction?serviceAccountKey=/home/user/Downloads/my-key.json"; -------------------------------------------------------- -Or by providing the path to the GCP credentials file location: - -Provide authentication credentials to your application code by setting the environment variable `GOOGLE_APPLICATION_CREDENTIALS` : +Or by setting the environment variable `GOOGLE_APPLICATION_CREDENTIALS` : [source,text] -------------------------------------------------------- @@ -61,19 +59,18 @@ export GOOGLE_APPLICATION_CREDENTIALS="/home/user/Downloads/my-key.json" [source,text] -------------------------------------------------------- -google-storage://bucketNameOrArn?[options] +google-functions://functionName?[options] -------------------------------------------------------- -By default the bucket will be created if it don't already exists. + You can append query options to the URI in the following format, ?options=value&option2=value&... -For example in order to read file `hello.txt` from bucket `myCamelBucket`, use the following snippet: +For example in order to call the function `myCamelFunction` from the project `myProject` and location `us-central1`, use the following snippet: [source,java] -------------------------------------------------------------------------------- -from("google-storage://myCamelBucket?serviceAccountKey=/home/user/Downloads/my-key.json&objectName=hello.txt") - .to("file:/var/downloaded"); +from("google-functions://myCamelFunction?project=myProject&location=us-central1&operation=callFunction&serviceAccountKey=/home/user/Downloads/my-key.json") + .to("direct:test"); -------------------------------------------------------------------------------- @@ -96,7 +93,7 @@ The GoogleCloudFunctions component supports 2 options, which are listed below. The GoogleCloudFunctions endpoint is configured using URI syntax: ---- -google-functions:name +google-functions:functionName ---- with the following path and query parameters: @@ -107,7 +104,7 @@ with the following path and query parameters: [width="100%",cols="2,5,^1,2",options="header"] |=== | Name | Description | Default | Type -| *functionName* | *Required* Function name | | String +| *functionName* | *Required* The user-defined name of the function | | String |=== @@ -119,10 +116,10 @@ with the following path and query parameters: | Name | Description | Default | Type | *serviceAccountKey* (common) | Service account key to authenticate an application as a service account | | String | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...] -| *location* (producer) | location | | String -| *operation* (producer) | The operation to perform on the producer. There are 3 enums and the value can be one of: listFunctions, getFunction, callFunction | | GoogleCloudFunctionsOperations -| *pojoRequest* (producer) | Configure the input type. If true the message will be POJO type. | false | boolean -| *project* (producer) | Project | | String +| *location* (producer) | The Google Cloud Location (Region) where the Function is located | | String +| *operation* (producer) | The operation to perform on the producer. There are 8 enums and the value can be one of: listFunctions, getFunction, callFunction, generateDownloadUrl, generateUploadUrl, createFunction, updateFunction, deleteFunction | | GoogleCloudFunctionsOperations +| *pojoRequest* (producer) | Specifies if the request is a pojo request | false | boolean +| *project* (producer) | The Google Cloud Project name where the Function is located | | String | *client* (advanced) | *Autowired* The client to use during service invocation. | | CloudFunctionsServiceClient |=== // endpoint options: END @@ -130,7 +127,7 @@ with the following path and query parameters: == Usage -=== Message headers evaluated by the Google Storage Producer +=== Message headers evaluated by the Google Functions Producer [width="100%",cols="10%,10%,80%",options="header",] |======================================================================= @@ -161,7 +158,7 @@ with the following path and query parameters: |======================================================================= -=== Message headers set by the Google Storage Producer +=== Message headers set by the Google Functions Producer [width="100%",cols="10%,10%,80%",options="header",] |======================================================================= @@ -194,14 +191,14 @@ with the following path and query parameters: | `CamelGoogleCloudStorageMediaLink` |`String` | The media link | `CamelGoogleCloudStorageMetageneration` | `String` | The metageneration of the object | `CamelGoogleCloudStorageContentLength` |`Long` |The content length of this object. -| `CamelGoogleCloudStorageStorageClass` | `String` | The storage class of the object +| `CamelGoogleCloudStorageStorageClass` | `String` | The functions class of the object | `CamelGoogleCloudStorageCreateTime` |`String` | The creation time of the object | `CamelGoogleCloudStorageLastUpdate` |`String` | The last update of the object |======================================================================= -=== Google Storage Producer operations +=== Google Functions Producer operations -Google Storage component provides the following operation on the producer side: +Google Functions component provides the following operation on the producer side: - copyObject - listObjects @@ -215,17 +212,17 @@ If you don't specify an operation explicitly the producer will a file upload. === Advanced component configuration -If you need to have more control over the `storageClient` instance configuration, you can create your own instance and refer to it in your Camel google-storage component configuration: +If you need to have more control over the `functionsClient` instance configuration, you can create your own instance and refer to it in your Camel google-functions component configuration: [source,java] -------------------------------------------------------------------------------- -from("google-storage://myCamelBucket?storageClient=#client") +from("google-functions://myCamelFunction?functionsClient=#client") .to("mock:result"); -------------------------------------------------------------------------------- -=== Google Storage Producer Operation examples +=== Google Functions Producer Operation examples -- File Upload: This operation will upload a file to the Google Storage based on the body content +- File Upload: This operation will upload a file to the Google Functions based on the body content [source,java] -------------------------------------------------------------------------------- @@ -237,7 +234,7 @@ from("direct:start") exchange.getIn().setHeader(GoogleCloudStorageConstants.OBJECT_NAME, "camel.txt"); exchange.getIn().setBody(bais); }) -.to("google-storage://myCamelBucket?serviceAccountKey=/home/user/Downloads/my-key.json") +.to("google-functions://myCamelFunction?serviceAccountKey=/home/user/Downloads/my-key.json") .log("uploaded file object:${header.CamelGoogleCloudStorageObjectName}, body:${body}"); -------------------------------------------------------------------------------- @@ -253,7 +250,7 @@ This operation will upload the file camel.txt with the content "Camel rocks!" in exchange.getIn().setHeader(GoogleCloudStorageConstants.DESTINATION_BUCKET_NAME, "myCamelBucket_dest"); exchange.getIn().setHeader(GoogleCloudStorageConstants.DESTINATION_OBJECT_NAME, "camel_copy.txt"); }) - .to("google-storage://myCamelBucket?serviceAccountKey=/home/user/Downloads/my-key.json") + .to("google-functions://myCamelFunction?serviceAccountKey=/home/user/Downloads/my-key.json") .to("mock:result"); -------------------------------------------------------------------------------- @@ -267,7 +264,7 @@ This operation will copy the object with the name expressed in the header DESTIN exchange.getIn().setHeader(GoogleCloudStorageConstants.OPERATION, GoogleCloudStorageOperations.deleteObject); exchange.getIn().setHeader(GoogleCloudStorageConstants.OBJECT_NAME, "camel.txt" ); }) - .to("google-storage://myCamelBucket?serviceAccountKey=/home/user/Downloads/my-key.json") + .to("google-functions://myCamelFunction?serviceAccountKey=/home/user/Downloads/my-key.json") .to("mock:result"); -------------------------------------------------------------------------------- @@ -278,7 +275,7 @@ This operation will delete the object from the bucket myCamelBucket. [source,java] -------------------------------------------------------------------------------- from("direct:start") -.to("google-storage://myCamelBucket?serviceAccountKey=/home/user/Downloads/my-key.json&operation=listBuckets") +.to("google-functions://myCamelFunction?serviceAccountKey=/home/user/Downloads/my-key.json&operation=listBuckets") .to("mock:result"); -------------------------------------------------------------------------------- @@ -289,7 +286,7 @@ This operation will list the buckets for this account. [source,java] -------------------------------------------------------------------------------- from("direct:start") -.to("google-storage://myCamelBucket?serviceAccountKey=/home/user/Downloads/my-key.json&operation=deleteBucket") +.to("google-functions://myCamelFunction?serviceAccountKey=/home/user/Downloads/my-key.json&operation=deleteBucket") .to("mock:result"); -------------------------------------------------------------------------------- @@ -300,7 +297,7 @@ This operation will delete the bucket myCamelBucket. [source,java] -------------------------------------------------------------------------------- from("direct:start") -.to("google-storage://myCamelBucket?serviceAccountKey=/home/user/Downloads/my-key.json&operation=listObjects") +.to("google-functions://myCamelFunction?serviceAccountKey=/home/user/Downloads/my-key.json&operation=listObjects") .to("mock:result"); -------------------------------------------------------------------------------- @@ -314,7 +311,7 @@ from("direct:start") .process( exchange -> { exchange.getIn().setHeader(GoogleCloudStorageConstants.OBJECT_NAME, "camel.txt"); }) -.to("google-storage://myCamelBucket?serviceAccountKey=/home/user/Downloads/my-key.json&operation=getObject") +.to("google-functions://myCamelFunction?serviceAccountKey=/home/user/Downloads/my-key.json&operation=getObject") .to("mock:result"); -------------------------------------------------------------------------------- @@ -329,7 +326,7 @@ from("direct:start") exchange.getIn().setHeader(GoogleCloudStorageConstants.OBJECT_NAME, "camel.txt" ); exchange.getIn().setHeader(GoogleCloudStorageConstants.DOWNLOAD_LINK_EXPIRATION_TIME, 86400000L); //1 day }) -.to("google-storage://myCamelBucket?serviceAccountKey=/home/user/Downloads/my-key.json&operation=createDownloadLink") +.to("google-functions://myCamelFunction?serviceAccountKey=/home/user/Downloads/my-key.json&operation=createDownloadLink") .to("mock:result"); -------------------------------------------------------------------------------- @@ -347,7 +344,7 @@ This will require specifying the destinationBucket option. As example: [source,java] -------------------------------------------------------------------------------- - from("google-storage://myCamelBucket?serviceAccountKey=/home/user/Downloads/my-key.json" + from("google-functions://myCamelFunction?serviceAccountKey=/home/user/Downloads/my-key.json" + "&autoCreateBucket=true" + "&destinationBucket=myCamelProcessedBucket" + "&moveAfterRead=true"