OUTSCALE Java SDK
The OUTSCALE Java SDK allows you to interact with OUTSCALE Cloud services using Java. It provides a simple way to configure authentication, create a client, and call OUTSCALE APIs.
Installation
Before you begin: To build the API client library, make sure you have Java 1.8+ and Maven 3.8.3+ installed. |
Installing the OUTSCALE Java SDK Using Maven
To install the API client library to your local Maven repository, run the following command:
$ mvn clean install
To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:
$ mvn clean deploy
For more information, see the OSSRH Guide.
Once deployed, add the following dependency to your project object model (POM):
<dependency>
<groupId>io.github.outscale</groupId>
<artifactId>osc-sdk-java</artifactId>
<version>0.8.0</version>
<scope>compile</scope>
</dependency>
Installing the OUTSCALE Java SDK Using Gradle
Before you begin: Make sure you have Gradle 7.2+ installed. |
For Gradle users, add the following dependency to your project’s build file:
repositories {
mavenCentral() // Needed if the 'osc-sdk-java' jar has been published to maven central.
mavenLocal() // Needed if the 'osc-sdk-java' jar has been published to the local maven repo.
}
dependencies {
implementation "io.github.outscale:osc-sdk-java:0.8.0"
}
Getting Started
Once the installation is complete, execute the following Java code:
// Import classes:
import io.github.outscale.osc_sdk_java.client.ApiClient;
import io.github.outscale.osc_sdk_java.client.ApiException;
import io.github.outscale.osc_sdk_java.client.Configuration;
import io.github.outscale.osc_sdk_java.client.auth.*;
import io.github.outscale.osc_sdk_java.client.models.*;
import io.github.outscale.osc_sdk_java.client.api.AccessKeyApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.eu-west-2.outscale.com/api/v1");
// Configure API key authorization: ApiKeyAuthSec
ApiKeyAuth ApiKeyAuthSec = (ApiKeyAuth) defaultClient.getAuthentication("ApiKeyAuthSec");
ApiKeyAuthSec.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//ApiKeyAuthSec.setApiKeyPrefix("Token");
// Configure HTTP basic authorization: BasicAuth
HttpBasicAuth BasicAuth = (HttpBasicAuth) defaultClient.getAuthentication("BasicAuth");
BasicAuth.setUsername("YOUR USERNAME");
BasicAuth.setPassword("YOUR PASSWORD");
AccessKeyApi apiInstance = new AccessKeyApi(defaultClient);
CreateAccessKeyRequest createAccessKeyRequest = new CreateAccessKeyRequest(); // CreateAccessKeyRequest |
try {
CreateAccessKeyResponse result = apiInstance.createAccessKey(createAccessKeyRequest);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling AccessKeyApi#createAccessKey");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
For more information, see the OUTSCALE Java SDK GitHub repository.
Related Pages
AWS™ and Amazon Web Services™ are trademarks of Amazon Technologies, Inc or its affiliates in the United States and/or other countries.