-
Notifications
You must be signed in to change notification settings - Fork 377
CSB-8935: Add blob index tags routes and test #218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
azure/camel-example-spring-boot-azure-storage-blob/README.adoc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| == Camel Azure Storage Blob Example | ||
|
|
||
| === Introduction | ||
|
|
||
| This example demonstrates how to use the Apache Camel Azure Storage Blob component with Spring Boot to: | ||
|
|
||
| * Upload block blobs | ||
| * Set and get blob index tags | ||
| * Find blobs by tag filter expressions | ||
| * Create and read blob snapshots | ||
|
|
||
| === Running Tests (Azurite) | ||
|
|
||
| Tests run automatically against https://github.com/Azure/Azurite[Azurite] (Azure Storage emulator) via Testcontainers. Docker must be running. | ||
|
|
||
| mvn verify | ||
|
|
||
| === Running with Azure | ||
|
|
||
| To run against a real Azure Storage account: | ||
|
|
||
| 1. Create a General-purpose v2 Storage Account in the Azure portal | ||
| 2. Enable blob versioning under Data management > Data protection (optional, for version operations) | ||
| 3. Get your account name and access key from Security + networking > Access keys | ||
|
|
||
| export AZURE_STORAGE_ACCOUNT_NAME=youraccount | ||
| export AZURE_STORAGE_ACCESS_KEY=yourkey | ||
| export AZURE_STORAGE_CONTAINER_NAME=yourcontainer | ||
| mvn spring-boot:run | ||
|
|
||
| === Help and Contributions | ||
|
|
||
| If you hit any problems please let us know on the https://camel.apache.org/community/mailing-list/[Camel Forums]. | ||
|
|
||
| Please help us make Apache Camel better - we appreciate any feedback you may have. | ||
|
|
||
| https://camel.apache.org/community/contributing/[Contributing] |
102 changes: 102 additions & 0 deletions
102
azure/camel-example-spring-boot-azure-storage-blob/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| <?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.springboot.example</groupId> | ||
| <artifactId>camel-example-spring-boot-azure</artifactId> | ||
| <version>4.23.0-SNAPSHOT</version> | ||
| </parent> | ||
|
|
||
| <artifactId>camel-example-spring-boot-azure-storage-blob</artifactId> | ||
| <name>Camel SB Examples :: Azure Storage Blob</name> | ||
| <description>An example showing how to work with Camel, Azure Storage Blob and Spring Boot</description> | ||
|
|
||
| <properties> | ||
| <category>Cloud</category> | ||
| </properties> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-starter</artifactId> | ||
| </dependency> | ||
|
|
||
| <!-- Camel --> | ||
| <dependency> | ||
| <groupId>org.apache.camel.springboot</groupId> | ||
| <artifactId>camel-spring-boot-starter</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.apache.camel.springboot</groupId> | ||
| <artifactId>camel-azure-storage-blob-starter</artifactId> | ||
| </dependency> | ||
|
|
||
| <!-- Test --> | ||
| <dependency> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-starter-test</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.apache.camel</groupId> | ||
| <artifactId>camel-test-spring-junit6</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-testcontainers</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.testcontainers</groupId> | ||
| <artifactId>testcontainers</artifactId> | ||
| <version>${testcontainers-version}</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.testcontainers</groupId> | ||
| <artifactId>testcontainers-junit-jupiter</artifactId> | ||
| <version>${testcontainers-version}</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-maven-plugin</artifactId> | ||
| <version>${spring-boot-version}</version> | ||
| <executions> | ||
| <execution> | ||
| <goals> | ||
| <goal>repackage</goal> | ||
| </goals> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
|
|
||
| </project> |
44 changes: 44 additions & 0 deletions
44
...-example-spring-boot-azure-storage-blob/src/main/java/camel/sample/BlobConfiguration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /* | ||
| * 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 camel.sample; | ||
|
|
||
| import com.azure.storage.blob.BlobServiceClient; | ||
| import com.azure.storage.blob.BlobServiceClientBuilder; | ||
| import com.azure.storage.common.StorageSharedKeyCredential; | ||
|
|
||
| import org.springframework.beans.factory.annotation.Value; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
|
|
||
| @Configuration | ||
| public class BlobConfiguration { | ||
|
|
||
| @Value("${azure.storage.account-name}") | ||
| private String accountName; | ||
|
|
||
| @Value("${azure.storage.access-key}") | ||
| private String accessKey; | ||
|
|
||
| @Bean | ||
| BlobServiceClient serviceClient() { | ||
| String endpoint = String.format("https://%s.blob.core.windows.net", accountName); | ||
| return new BlobServiceClientBuilder() | ||
| .endpoint(endpoint) | ||
| .credential(new StorageSharedKeyCredential(accountName, accessKey)) | ||
| .buildClient(); | ||
| } | ||
| } |
38 changes: 38 additions & 0 deletions
38
...l-example-spring-boot-azure-storage-blob/src/main/java/camel/sample/BlobRouteBuilder.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /* | ||
| * 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 camel.sample; | ||
|
|
||
| import org.apache.camel.builder.RouteBuilder; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| @Component | ||
| public class BlobRouteBuilder extends RouteBuilder { | ||
|
|
||
| @Override | ||
| public void configure() { | ||
| from("direct:uploadBlob") | ||
| .to("azure-storage-blob://{{azure.storage.account-name}}/{{azure.storage.container-name}}" | ||
| + "?operation=uploadBlockBlob" | ||
| + "&serviceClient=#serviceClient"); | ||
|
|
||
| from("direct:getBlob") | ||
| .to("azure-storage-blob://{{azure.storage.account-name}}/{{azure.storage.container-name}}" | ||
| + "?operation=getBlob" | ||
| + "&serviceClient=#serviceClient") | ||
| .convertBodyTo(byte[].class); | ||
| } | ||
| } | ||
32 changes: 32 additions & 0 deletions
32
...e-spring-boot-azure-storage-blob/src/main/java/camel/sample/BlobSnapshotRouteBuilder.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /* | ||
| * 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 camel.sample; | ||
|
|
||
| import org.apache.camel.builder.RouteBuilder; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| @Component | ||
| public class BlobSnapshotRouteBuilder extends RouteBuilder { | ||
|
|
||
| @Override | ||
| public void configure() { | ||
| from("direct:createSnapshot") | ||
| .to("azure-storage-blob://{{azure.storage.account-name}}/{{azure.storage.container-name}}" | ||
| + "?operation=createBlobSnapshot" | ||
| + "&serviceClient=#serviceClient"); | ||
| } | ||
| } |
28 changes: 28 additions & 0 deletions
28
...ple-spring-boot-azure-storage-blob/src/main/java/camel/sample/BlobStorageApplication.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /* | ||
| * 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 camel.sample; | ||
|
|
||
| import org.springframework.boot.SpringApplication; | ||
| import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
|
||
| @SpringBootApplication | ||
| public class BlobStorageApplication { | ||
|
|
||
| public static void main(String[] args) { | ||
| SpringApplication.run(BlobStorageApplication.class, args); | ||
| } | ||
| } |
42 changes: 42 additions & 0 deletions
42
...ample-spring-boot-azure-storage-blob/src/main/java/camel/sample/BlobTagsRouteBuilder.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| /* | ||
| * 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 camel.sample; | ||
|
|
||
| import org.apache.camel.builder.RouteBuilder; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| @Component | ||
| public class BlobTagsRouteBuilder extends RouteBuilder { | ||
|
|
||
| @Override | ||
| public void configure() { | ||
| from("direct:setBlobTags") | ||
| .to("azure-storage-blob://{{azure.storage.account-name}}/{{azure.storage.container-name}}" | ||
| + "?operation=setBlobTags" | ||
| + "&serviceClient=#serviceClient"); | ||
|
|
||
| from("direct:getBlobTags") | ||
| .to("azure-storage-blob://{{azure.storage.account-name}}/{{azure.storage.container-name}}" | ||
| + "?operation=getBlobTags" | ||
| + "&serviceClient=#serviceClient"); | ||
|
|
||
| from("direct:findBlobsByTags") | ||
| .to("azure-storage-blob://{{azure.storage.account-name}}/{{azure.storage.container-name}}" | ||
| + "?operation=findBlobsByTags" | ||
| + "&serviceClient=#serviceClient"); | ||
| } | ||
| } |
29 changes: 29 additions & 0 deletions
29
azure/camel-example-spring-boot-azure-storage-blob/src/main/resources/application.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # | ||
| # 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. | ||
| # | ||
|
|
||
| azure: | ||
|
tdiesler marked this conversation as resolved.
|
||
| storage: | ||
| account-name: ${AZURE_STORAGE_ACCOUNT_NAME:devstoreaccount1} | ||
| access-key: ${AZURE_STORAGE_ACCESS_KEY} | ||
| container-name: ${AZURE_STORAGE_CONTAINER_NAME:testcontainer} | ||
|
|
||
| camel: | ||
| component: | ||
| azure-storage-blob: | ||
| credential-type: SHARED_KEY_CREDENTIAL | ||
|
tdiesler marked this conversation as resolved.
|
||
| springboot: | ||
| main-run-controller: true | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.