Skip to content

Commit

Permalink
Google Storage support apache#2421
Browse files Browse the repository at this point in the history
  • Loading branch information
JiriOndrusek committed Apr 27, 2021
1 parent 59adea0 commit 6ef9109
Show file tree
Hide file tree
Showing 24 changed files with 1,220 additions and 1 deletion.
13 changes: 13 additions & 0 deletions catalog/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,19 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-google-storage</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-graphql</artifactId>
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
*** xref:reference/extensions/google-mail.adoc[Google Mail]
*** xref:reference/extensions/google-pubsub.adoc[Google Pubsub]
*** xref:reference/extensions/google-sheets.adoc[Google Sheets]
*** xref:reference/extensions/google-storage.adoc[Google Storage]
*** xref:reference/extensions/graphql.adoc[GraphQL]
*** xref:reference/extensions/grok.adoc[Grok]
*** xref:reference/extensions/groovy.adoc[Groovy]
Expand Down
60 changes: 60 additions & 0 deletions docs/modules/ROOT/pages/reference/extensions/google-storage.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Do not edit directly!
// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
= Google Storage
:linkattrs:
:cq-artifact-id: camel-quarkus-google-storage
:cq-native-supported: true
:cq-status: Stable
:cq-status-deprecation: Stable
:cq-description: Store and retrieve objects from Google Cloud Storage Service using the google-cloud-storage library.
:cq-deprecated: false
:cq-jvm-since: 1.9.0
:cq-native-since: 1.9.0

[.badges]
[.badge-key]##JVM since##[.badge-supported]##1.9.0## [.badge-key]##Native since##[.badge-supported]##1.9.0##

Store and retrieve objects from Google Cloud Storage Service using the google-cloud-storage library.

== What's inside

* xref:{cq-camel-components}::google-storage-component.adoc[Google Storage component], URI syntax: `google-storage:bucketName`

Please refer to the above link for usage and configuration details.

== Maven coordinates

https://code.quarkus.io/?extension-search=camel-quarkus-google-storage[Create a new project with this extension on code.quarkus.io, window="_blank"]

Or add the coordinates to your existing project:

[source,xml]
----
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-google-storage</artifactId>
</dependency>
----

Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.

== SSL in native mode

This extension auto-enables SSL support in native mode. Hence you do not need to add
`quarkus.ssl.native=true` to your `application.properties` yourself. See also
https://quarkus.io/guides/native-and-ssl[Quarkus SSL guide].

== Additional Camel Quarkus configuration

There are two different configuration approaches:

* Google storage client can be defined via quarkus properties leveraging the Quarkiverse - Google Cloud Services - Storage (see https://github.com/quarkiverse/quarkus-google-cloud-services/blob/main/storage[extension git page]).
Camel will autowire client into the Google-storage component.
This configuration allows definition of only one storage client, therefore it isn't possible to define several different endpoints, which run together.

* Provide client/clients for camel registry (e.g. CDI producer/bean) and reference them from endpoint.
[source,properties]
----
google-storage://bucket?storageClient=#my_client
----

Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
// Empty partial for a Camel bit unsupported by Camel Quarkus to avoid warnings when this file is included from a Camel page
// Do not edit directly!
// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
:cq-artifact-id: camel-quarkus-google-storage
:cq-artifact-id-base: google-storage
:cq-native-supported: true
:cq-status: Stable
:cq-deprecated: false
:cq-jvm-since: 1.9.0
:cq-native-since: 1.9.0
:cq-camel-part-name: google-storage
:cq-camel-part-title: Google Storage
:cq-camel-part-description: Store and retrieve objects from Google Cloud Storage Service using the google-cloud-storage library.
:cq-extension-page-title: Google Storage
68 changes: 68 additions & 0 deletions extensions/google-storage/deployment/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-google-storage-parent</artifactId>
<version>1.9.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>camel-quarkus-google-storage-deployment</artifactId>
<name>Camel Quarkus :: Google Storage :: Deployment</name>

<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-core-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-google-storage</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.googlecloudservices</groupId>
<artifactId>quarkus-google-cloud-storage-deployment</artifactId>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${quarkus.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* 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.quarkus.component.google.storage.deployment;

import com.google.api.client.googleapis.json.GoogleJsonError;
import com.google.api.client.http.HttpHeaders;
import com.google.api.client.json.GenericJson;
import com.google.api.client.json.webtoken.JsonWebSignature;
import com.google.api.client.json.webtoken.JsonWebToken;
import com.google.api.client.util.GenericData;
import com.google.api.services.storage.Storage;
import com.google.api.services.storage.StorageRequest;
import com.google.cloud.storage.Bucket;
import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.builditem.IndexDependencyBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import org.apache.camel.quarkus.component.google.storage.GoogleStorageEnforcer;
import org.jboss.jandex.DotName;
import org.jboss.jandex.IndexView;

class GoogleStorageProcessor {

private static final String FEATURE = "camel-google-storage";

@BuildStep
FeatureBuildItem feature() {
return new FeatureBuildItem(FEATURE);
}

@BuildStep
ExtensionSslNativeSupportBuildItem activateSslNativeSupport() {
return new ExtensionSslNativeSupportBuildItem(FEATURE);
}

@BuildStep
public AdditionalBeanBuildItem storageEnforcer() {
return new AdditionalBeanBuildItem(GoogleStorageEnforcer.class);
}

@BuildStep
void registerForReflection(CombinedIndexBuildItem combinedIndex,
BuildProducer<ReflectiveClassBuildItem> reflectiveClasses) {
IndexView index = combinedIndex.getIndex();

reflectiveClasses.produce(new ReflectiveClassBuildItem(false, true, Bucket.class.getName(),
Storage.Objects.Insert.class.getName(),
StorageRequest.class.getName(), GenericJson.class.getName(), GenericData.class.getName(),
GoogleJsonError.class.getName(), HttpHeaders.class.getName(), JsonWebToken.Payload.class.getName(),
JsonWebSignature.Header.class.getName(), GoogleJsonError.ErrorInfo.class.getName(), byte[].class.getName()));

String[] dtos = index.getAllKnownSubclasses(DotName.createSimple(StorageRequest.class.getName())).stream()
.map(ci -> ci.name().toString())
.toArray(String[]::new);

reflectiveClasses.produce(new ReflectiveClassBuildItem(false, true, dtos));

dtos = index.getAllKnownSubclasses(DotName.createSimple(GenericJson.class.getName())).stream()
.map(ci -> ci.name().toString())
.toArray(String[]::new);

reflectiveClasses.produce(new ReflectiveClassBuildItem(false, true, dtos));
}

@BuildStep
IndexDependencyBuildItem registerDependencyForIndex() {
return new IndexDependencyBuildItem("com.google.apis", "google-api-services-storage");
}
}
39 changes: 39 additions & 0 deletions extensions/google-storage/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-build-parent</artifactId>
<version>1.9.0-SNAPSHOT</version>
<relativePath>../../poms/build-parent/pom.xml</relativePath>
</parent>

<artifactId>camel-quarkus-google-storage-parent</artifactId>
<name>Camel Quarkus :: Google Storage</name>
<packaging>pom</packaging>

<modules>
<module>deployment</module>
<module>runtime</module>
</modules>
</project>

0 comments on commit 6ef9109

Please sign in to comment.