Contents
Overview
Helidon MP OCI Integration provides easy access to Oracle Cloud Infrastructure using the OCI Java SDK.`
Maven Coordinates
To enable OCI Integration add the following dependency to your project’s pom.xml (see Managing Dependencies).
<dependency>
<groupId>io.helidon.integrations.oci.sdk</groupId>
<artifactId>helidon-integrations-oci-sdk-cdi</artifactId>
</dependency>Usage
When added to your application Helidon OCI SDK CDI portable extension provides support for injecting Oracle Cloud Infrastructure SDK Clients in your Helidon MicroProfile application.
The extension also handles authenticating with OCI by automatically picking up OCI credentials from your environment.
Configuring the Helidon OCI SDK Extension
When you inject an OCI SDK Client object, the Helidon OCI SDK extension configures and constructs the object for you. The configuration primarily consists of initializing an OCI AuthenticationDetailsProvider. By default, the extension will examine your environment and select the best AuthenticationDetailsProvider and configure it for you.
This means if your environment is already set up to work with the OCI SDK or the OCI command line, then it is very likely you do not need to do any additional configuration of the extension. Just add it as a dependency, and it will self-configure.
If for some reason you require full control over the OCI configuration you have that as well. For more information concerning the extension and its configuration and authentication options see the OciExtension javadocs. In particular the oci.auth-strategies property lets you control which AuthenticationDetailsProvider will be used.
Accessing OCI Services
Since the Helidon OCI SDK extension supports injecting any OCI client from the OCI SDK, you can use it to access any OCI service supported by the OCI SDK. In addition to adding the Helidon OCI SDK Extension dependency (as described above) you will need to add dependencies for the specific ODI SDK clients you will use.
You will also need to configure your environment to authenticate with OCI. It is recommended that you do this first, and verify your configuration by using the OCI CLI to access the service.
Examples
This example describes how to use Helidon OCI SDK Extension to access OCI Object Storage.
As mentioned above in , you need to add a dependency on the OCI SDK Object Storage API:
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-objectstorage</artifactId>
</dependency>Injecting an Object Storage Client
Now you can inject OCI SDK Clients.
@Inject
private ObjectStorage client;public class MyClass {
private final ObjectStorage client;
@Inject
public YourConstructor(@Named("orders") ObjectStorage client) {
this.client = client;
}
}The extension implements this injection point by creating an Object Storage client object in the singleton scope.
Using the Object Storage Client
Once you have injected an ObjectStorage client you can use it as described in:
References
OciExtension Javadocs