Skip to content

Commit 286d40e

Browse files
Merge pull request #29 from oracle/topic_sync_newmodules
sync up github with new modules
2 parents 3ceee19 + f04bb68 commit 286d40e

File tree

96 files changed

+4057
-217
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+4057
-217
lines changed

docs/src/main/asciidoc/function.adoc

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright (c) 2023, Oracle and/or its affiliates.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
3+
4+
[#cloud-function]
5+
== Cloud Functions
6+
7+
https://docs.oracle.com/en-us/iaas/Content/Functions/Concepts/functionsoverview.htm[OCI Functions] is a fully managed, multi-tenant, highly scalable, on-demand, Functions-as-a-Service platform. It is built on enterprise-grade Oracle Cloud Infrastructure and powered by the Fn Project open source engine. Use OCI Functions when you want to focus on writing code to meet business needs. The Spring Cloud module for OCI Functions allows to invoke an OCI Function.
8+
A Spring Boot starter is provided to auto-configure the Function component.
9+
10+
Maven coordinates, using <<getting-started.adoc#bill-of-materials, Spring Cloud OCI BOM>>:
11+
12+
[source,xml]
13+
----
14+
<dependency>
15+
<groupId>com.oracle.cloud.spring</groupId>
16+
<artifactId>spring-cloud-oci-starter-function</artifactId>
17+
</dependency>
18+
----
19+
20+
Gradle coordinates:
21+
22+
[source,subs="normal"]
23+
----
24+
dependencies {
25+
implementation("com.oracle.cloud.spring:spring-cloud-oci-starter-function")
26+
}
27+
----
28+
29+
=== Using Cloud Functions
30+
31+
The starter automatically configures and registers a `Function` bean in the Spring application context.
32+
The `Function` bean (link[Javadoc]) can be used to invoke a function with parameter inputs 'functionOcid' and 'endpoint'
33+
34+
[source,java]
35+
----
36+
@Autowired
37+
private Function function;
38+
39+
public void invoke() {
40+
41+
InvokeFunctionResponse invokeFunctionResponse = function.invokeFunction(functionOcid, endpoint, mode, requestBody);
42+
}
43+
----
44+
45+
46+
=== Configuration
47+
48+
The Spring Boot Starter for Oracle Cloud Function provides the following configuration options:
49+
50+
|===
51+
^| Name ^| Description ^| Required ^| Default value
52+
| `spring.cloud.oci.function.enabled` | Enables the OCI Functions APIs. | No | `true`
53+
|===
54+
55+
56+
=== Sample
57+
58+
A sample application provided https://github.com/oracle/spring-cloud-oci/tree/main/spring-cloud-oci-samples/spring-cloud-oci-function-sample[here] contains the examples to demonstrates the usage of OCI Spring Cloud Function module.

docs/src/main/asciidoc/getting-started.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ The following table highlights several samples of the most used integrations in
6767
| Cloud Logging
6868
| https://github.com/oracle/spring-cloud-oci/tree/main/spring-cloud-oci-samples/spring-cloud-oci-logging-sample[spring-cloud-oci-logging-sample]
6969

70+
| Cloud Streaming
71+
| https://github.com/oracle/spring-cloud-oci/tree/main/spring-cloud-oci-samples/spring-cloud-oci-streaming-sample[spring-cloud-oci-streaming-sample]
72+
73+
| Cloud Function
74+
| https://github.com/oracle/spring-cloud-oci/tree/main/spring-cloud-oci-samples/spring-cloud-oci-function-sample[spring-cloud-oci-function-sample]
75+
76+
| Cloud Queue
77+
| https://github.com/oracle/spring-cloud-oci/tree/main/spring-cloud-oci-samples/spring-cloud-oci-queue-sample[spring-cloud-oci-queue-sample]
7078
|===
7179

7280
Each sample application demonstrates how to use Spring Cloud OCI libraries in context and how to setup the dependencies for the project.

docs/src/main/asciidoc/index.adoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ include::notifications.adoc[]
2424

2525
include::logging.adoc[]
2626

27+
include::function.adoc[]
28+
29+
include::streaming.adoc[]
30+
31+
include::queues.adoc[]
32+
2733
== Configuration properties
2834

2935
To see the list of all OCI-related configuration properties see the link:appendix.html[Appendix page].

docs/src/main/asciidoc/logging.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[#cloud-logging]
55
== Cloud Logging
66

7-
https://docs.oracle.com/en-us/iaas/Content/Logging/home.htm/[OCI Logging] service is a highly scalable and fully managed single pane of glass for all the logs in your tenancy. Logging provides access to logs from OCI resources. These logs include critical diagnostic information that describes how resources are performing and being accessed. Use Logging to enable, manage, and search Audit, Service, and Custom logs. The Spring Cloud module for OCI Logging allows ingesting logs associated with a logId.
7+
https://docs.oracle.com/en-us/iaas/Content/Logging/home.htm[OCI Logging] service is a highly scalable and fully managed single pane of glass for all the logs in your tenancy. Logging provides access to logs from OCI resources. These logs include critical diagnostic information that describes how resources are performing and being accessed. Use Logging to enable, manage, and search Audit, Service, and Custom logs. The Spring Cloud module for OCI Logging allows ingesting logs associated with a logId.
88
A Spring Boot starter is provided to auto-configure the Logging component.
99

1010
Maven coordinates, using <<getting-started.adoc#bill-of-materials, Spring Cloud OCI BOM>>:

docs/src/main/asciidoc/queues.adoc

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright (c) 2023, Oracle and/or its affiliates.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
3+
4+
[#cloud-queues]
5+
== Cloud Queues
6+
7+
https://docs.oracle.com/en-us/iaas/Content/queue/home.htm[OCI Queues] is a highly available, low latency publish/subscribe (pub/sub) service, handles high volume transactional data that requires independently processed messages without loss or duplication. Spring Cloud module for Oracle Cloud Queues allows you to create a queue, get a queue, list queues, delete a queue, put messages, get messages, update messages and delete a message.
8+
A Spring Boot starter is provided to auto-configure the various Queue components.
9+
10+
Maven coordinates, using <<getting-started.adoc#bill-of-materials, Spring Cloud OCI BOM>>:
11+
12+
[source,xml]
13+
----
14+
<dependency>
15+
<groupId>com.oracle.cloud.spring</groupId>
16+
<artifactId>spring-cloud-oci-starter-queue</artifactId>
17+
</dependency>
18+
----
19+
20+
Gradle coordinates:
21+
22+
[source,subs="normal"]
23+
----
24+
dependencies {
25+
implementation("com.oracle.cloud.spring:spring-cloud-oci-starter-queue")
26+
}
27+
----
28+
29+
=== Using Cloud Queues
30+
31+
The starter automatically configures and registers a `Queue` bean in the Spring application context.
32+
The `Queue` bean (link[Javadoc]) can be used to create a queue, get a queue, list queues, delete a queue, put messages, get messages, update messages and delete a message.
33+
34+
[source,java]
35+
----
36+
@Autowired
37+
private Queue queue;
38+
39+
public void createQueue() {
40+
41+
String queueId = queue.createQueue("my-queue", <<compartmentId>>, <<deadLetterQueueDeliveryCount>>, <<retentionInSeconds>>);
42+
}
43+
----
44+
45+
46+
=== Configuration
47+
48+
The Spring Boot Starter for Oracle Cloud Queues provides the following configuration options:
49+
50+
|===
51+
^| Name ^| Description ^| Required ^| Default value
52+
| `spring.cloud.oci.queue.enabled` | Enables the OCI Queue APIs. | No | `true`
53+
|===
54+
55+
56+
=== Sample
57+
58+
A sample application provided https://github.com/oracle/spring-cloud-oci/tree/main/spring-cloud-oci-samples/spring-cloud-oci-queue-sample[here] contains the examples to demonstrates the usage of OCI Spring Cloud Queue module.

docs/src/main/asciidoc/streaming.adoc

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Copyright (c) 2023, Oracle and/or its affiliates.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
3+
4+
[#cloud-stream]
5+
== Cloud Stream
6+
7+
https://docs.oracle.com/en-us/iaas/Content/Streaming/home.htm[OCI Streaming] service provides a fully managed, scalable, and durable solution for ingesting and consuming high-volume data streams in real time.
8+
A Spring Boot starter is provided to auto-configure the Streaming component.
9+
10+
Maven coordinates, using <<getting-started.adoc#bill-of-materials, Spring Cloud OCI BOM>>:
11+
12+
[source,xml]
13+
----
14+
<dependency>
15+
<groupId>com.oracle.cloud.spring</groupId>
16+
<artifactId>spring-cloud-oci-starter-streaming</artifactId>
17+
</dependency>
18+
----
19+
20+
Gradle coordinates:
21+
22+
[source,subs="normal"]
23+
----
24+
dependencies {
25+
implementation("com.oracle.cloud.spring:spring-cloud-oci-starter-streaming")
26+
}
27+
----
28+
29+
=== Using Cloud Streaming
30+
31+
The starter automatically configures and registers a `Streaming` bean in the Spring application context.
32+
The `Streaming` bean (link[Javadoc]) can be used to create streamPool, stream in OCI and ingest and consume high-volume data streams with a streamId
33+
34+
[source,java]
35+
----
36+
@Autowired
37+
private Streaming streaming;
38+
39+
public void putMessages() {
40+
41+
PutMessagesResponse response = streaming.putMessages(streamId, "key".getBytes(), "value"..getBytes());
42+
}
43+
44+
public void getMessages() {
45+
46+
GetMessagesResponse response = streaming.getMessages(streamId, "cursor");
47+
}
48+
----
49+
50+
51+
=== Configuration
52+
53+
The Spring Boot Starter for Oracle Cloud Stream provides the following configuration options:
54+
55+
|===
56+
^| Name ^| Description ^| Required ^| Default value
57+
| `spring.cloud.oci.stream.enabled` | Enables the OCI Streaming APIs. | No | `true`
58+
|===
59+
60+
61+
=== Sample
62+
63+
A sample application provided https://github.com/oracle/spring-cloud-oci/tree/main/spring-cloud-oci-samples/spring-cloud-oci-streaming-sample[here] contains the examples to demonstrates the usage of OCI Spring Cloud Streaming module.

pom.xml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ Licensed under the Universal Permissive License v 1.0 as shown at https://oss.or
5454
<module>spring-cloud-oci-storage</module>
5555
<module>spring-cloud-oci-notification</module>
5656
<module>spring-cloud-oci-logging</module>
57+
<module>spring-cloud-oci-function</module>
58+
<module>spring-cloud-oci-streaming</module>
59+
<module>spring-cloud-oci-queue</module>
5760
<module>docs</module>
5861
</modules>
5962

@@ -77,8 +80,9 @@ Licensed under the Universal Permissive License v 1.0 as shown at https://oss.or
7780
<flatten-maven-plugin.version>1.5.0</flatten-maven-plugin.version>
7881
<checksum-maven-plugin.version>1.11</checksum-maven-plugin.version>
7982
<jacoco-maven-plugin.version>0.8.10</jacoco-maven-plugin.version>
80-
<cc.code-coverage-ratio>0.00</cc.code-coverage-ratio>
81-
<!--<dependency-check-maven.version>8.4.0</dependency-check-maven.version> -->
83+
<cc.code-coverage-ratio>0.90</cc.code-coverage-ratio>
84+
<!--<dependency-check-maven.version>8.4.0</dependency-check-maven.version>
85+
<failBuildOnCVSS.score>8</failBuildOnCVSS.score> -->
8286
</properties>
8387

8488
<dependencyManagement>
@@ -100,6 +104,7 @@ Licensed under the Universal Permissive License v 1.0 as shown at https://oss.or
100104
<artifactId>springdoc-openapi-ui</artifactId>
101105
<version>${springdoc-openapi-ui.version}</version>
102106
</dependency>
107+
103108
<dependency>
104109
<groupId>org.apache.commons</groupId>
105110
<artifactId>commons-lang3</artifactId>
@@ -152,6 +157,12 @@ Licensed under the Universal Permissive License v 1.0 as shown at https://oss.or
152157
<groupId>org.springframework.boot</groupId>
153158
<artifactId>spring-boot-starter-test</artifactId>
154159
<scope>test</scope>
160+
<exclusions>
161+
<exclusion>
162+
<groupId>org.yaml</groupId>
163+
<artifactId>snakeyaml</artifactId>
164+
</exclusion>
165+
</exclusions>
155166
</dependency>
156167
</dependencies>
157168

@@ -325,7 +336,7 @@ Licensed under the Universal Permissive License v 1.0 as shown at https://oss.or
325336
<artifactId>dependency-check-maven</artifactId>
326337
<version>${dependency-check-maven.version}</version>
327338
<configuration>
328-
<failBuildOnCVSS>8</failBuildOnCVSS>
339+
<failBuildOnCVSS>${failBuildOnCVSS.score}</failBuildOnCVSS>
329340
<skipProvidedScope>true</skipProvidedScope>
330341
</configuration>
331342
<executions>

spring-cloud-oci-autoconfigure/pom.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,21 @@ Licensed under the Universal Permissive License v 1.0 as shown at https://oss.or
8484
<artifactId>spring-cloud-oci-logging</artifactId>
8585
<optional>true</optional>
8686
</dependency>
87+
<dependency>
88+
<groupId>com.oracle.cloud.spring</groupId>
89+
<artifactId>spring-cloud-oci-function</artifactId>
90+
<optional>true</optional>
91+
</dependency>
92+
<dependency>
93+
<groupId>com.oracle.cloud.spring</groupId>
94+
<artifactId>spring-cloud-oci-streaming</artifactId>
95+
<optional>true</optional>
96+
</dependency>
97+
<dependency>
98+
<groupId>com.oracle.cloud.spring</groupId>
99+
<artifactId>spring-cloud-oci-queue</artifactId>
100+
<optional>true</optional>
101+
</dependency>
87102
<dependency>
88103
<groupId>com.oracle.oci.sdk</groupId>
89104
<artifactId>oci-java-sdk-common-httpclient-jersey3</artifactId>

spring-cloud-oci-autoconfigure/src/main/java/com/oracle/cloud/spring/autoconfigure/core/CompartmentProviderAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public CompartmentProvider compartmentProvider() {
3636
return createCompartmentProvider(properties);
3737
}
3838

39-
public static CompartmentProvider createCompartmentProvider(CompartmentProperties properties) {
39+
private static CompartmentProvider createCompartmentProvider(CompartmentProperties properties) {
4040
if (properties.getStatic() != null && properties.isStatic()) {
4141
return new StaticCompartmentProvider(properties.getStatic().trim());
4242
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
** Copyright (c) 2023, Oracle and/or its affiliates.
3+
** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
4+
*/
5+
6+
package com.oracle.cloud.spring.autoconfigure.core;
7+
8+
import com.oracle.bmc.ClientRuntime;
9+
import com.oracle.bmc.Region;
10+
import com.oracle.bmc.auth.*;
11+
12+
import java.io.IOException;
13+
14+
/**
15+
* Provider to wrap AuthenticationDetailsProvider for beans initialization
16+
*/
17+
public class CredentialsProvider {
18+
19+
private static final String PROFILE_DEFAULT = "DEFAULT";
20+
public static final String USER_AGENT_SPRING_CLOUD = "Oracle-SpringCloud";
21+
22+
private BasicAuthenticationDetailsProvider authenticationDetailsProvider;
23+
24+
public CredentialsProvider(CredentialsProperties properties) throws IOException {
25+
this.authenticationDetailsProvider = createCredentialsProvider(properties);
26+
}
27+
28+
/**
29+
* Initializes an Authentication provider based on {@link CredentialsProperties.ConfigType} type
30+
* @return BasicAuthenticationDetailsProvider
31+
* @throws IOException
32+
*/
33+
private static BasicAuthenticationDetailsProvider createCredentialsProvider(CredentialsProperties properties)
34+
throws IOException {
35+
BasicAuthenticationDetailsProvider authenticationDetailsProvider;
36+
37+
switch (properties.getType()) {
38+
case RESOURCE_PRINCIPAL:
39+
authenticationDetailsProvider = ResourcePrincipalAuthenticationDetailsProvider.builder().build();
40+
break;
41+
case INSTANCE_PRINCIPAL:
42+
authenticationDetailsProvider = InstancePrincipalsAuthenticationDetailsProvider.builder().build();
43+
break;
44+
case SIMPLE:
45+
SimpleAuthenticationDetailsProvider.SimpleAuthenticationDetailsProviderBuilder builder = SimpleAuthenticationDetailsProvider.builder()
46+
.userId(properties.getUserId())
47+
.tenantId(properties.getTenantId())
48+
.fingerprint(properties.getFingerprint())
49+
.privateKeySupplier(new SimplePrivateKeySupplier(properties.getPrivateKey()))
50+
.passPhrase(properties.getPassPhrase());
51+
if (properties.getRegion() != null) {
52+
builder.region(Region.valueOf(properties.getRegion()));
53+
}
54+
authenticationDetailsProvider = builder.build();
55+
break;
56+
case SESSION_TOKEN:
57+
String configProfile = properties.hasProfile() ? properties.getProfile() : PROFILE_DEFAULT;
58+
59+
if (properties.hasFile()) {
60+
authenticationDetailsProvider = new SessionTokenAuthenticationDetailsProvider(properties.getFile(), configProfile);
61+
} else {
62+
authenticationDetailsProvider = new SessionTokenAuthenticationDetailsProvider(configProfile);
63+
}
64+
break;
65+
default:
66+
String profile = properties.hasProfile() ? properties.getProfile() : PROFILE_DEFAULT;
67+
68+
if (properties.hasFile()) {
69+
authenticationDetailsProvider = new ConfigFileAuthenticationDetailsProvider(properties.getFile(), profile);
70+
} else {
71+
authenticationDetailsProvider = new ConfigFileAuthenticationDetailsProvider(profile);
72+
}
73+
74+
break;
75+
}
76+
ClientRuntime.setClientUserAgent(USER_AGENT_SPRING_CLOUD);
77+
return authenticationDetailsProvider;
78+
}
79+
80+
public BasicAuthenticationDetailsProvider getAuthenticationDetailsProvider() {
81+
return authenticationDetailsProvider;
82+
}
83+
}

0 commit comments

Comments
 (0)