A Java client library to interact with the IBM Cloud® Secrets Manager Instance Management APIs.
Important: This SDK is for use with instances of the IBM Cloud Secrets Manager Vault Enterprise plan only. It is not compatible with other Secrets Manager plans.
Table of Contents
The IBM Cloud Secrets Manager Management Java SDK allows developers to programmatically interact with the following IBM Cloud services:
| Service name | Imported class name |
|---|---|
| Secrets Manager Management | SecretsManagerInstanceManagement |
- An IBM Cloud account.
- A Secrets Manager service instance with the Vault Enterprise plan.
- An IBM Cloud API key that allows the SDK to access your account.
- Java 11
<dependency>
<groupId>com.ibm.cloud</groupId>
<artifactId>secrets-manager-instance-management</artifactId>
<version>2.0.3</version>
</dependency>'com.ibm.cloud:secrets-manager-instance-management:2.0.3'Secrets Manager uses token-based Identity and Access Management (IAM) authentication.
With IAM authentication, you supply an API key that is used to generate an access token. Then, the access token is included in each API request to Secrets Manager. Access tokens are valid for a limited amount of time and must be regenerated.
Authentication for this SDK is accomplished by using IAM authenticators. Import authenticators from com.ibm.cloud.sdk.core.security.
import com.ibm.cloud.sdk.core.security.IamAuthenticator;
...
IamAuthenticator iamAuthenticator = new IamAuthenticator.Builder()
.apikey("<IBM_CLOUD_API_KEY>")
.build();To learn more about IAM authenticators and how to use them in your Java application, see the IBM Java SDK Core documentation.
- Use the
setServiceUrlmethod to set the endpoint URL that is specific to your Secrets Manager service instance. To find your endpoint URL, you can copy it from the Endpoints section on the Overview page in the Secrets Manager UI.
Construct a service client and use it to generate an admin token and get instance details.
Here's an example main.java class file:
import com.ibm.cloud.secrets_manager_sdk_instance_management.secrets_manager_instance_management.v2.SecretsManagerInstanceManagement;
import com.ibm.cloud.secrets_manager_sdk_instance_management.secrets_manager_instance_management.v2.model.*;
import com.ibm.cloud.sdk.core.http.Response;
import com.ibm.cloud.sdk.core.security.IamAuthenticator;
public class main {
protected static SecretsManagerInstanceManagement smim;
protected static IamAuthenticator iamAuthenticator;
public static void main(String[] args) {
iamAuthenticator = new IamAuthenticator.Builder()
.apikey("<IBM_CLOUD_API_KEY>")
.build();
smim = new SecretsManagerInstanceManagement("Secrets Manager Instance Management", iamAuthenticator);
smim.setServiceUrl("<SERVICE_URL>");
// Generate admin token
AdminTokenGenerateOptions adminTokenGenerateOptions = new AdminTokenGenerateOptions.Builder()
.instanceCrn("<INSTANCE_CRN>")
.build();
Response<AdminToken> tokenResp = smim.adminTokenGenerate(adminTokenGenerateOptions).execute();
System.out.println("Admin token generated!");
// Get instance details
InstanceDetailsOptions instanceDetailsOptions = new InstanceDetailsOptions.Builder()
.instanceCrn("<INSTANCE_CRN>")
.build();
Response<Instance> instanceResp = smim.instanceDetails(instanceDetailsOptions).execute();
System.out.println("Instance details: " + instanceResp.getResult());
}
}Replace the IBM_CLOUD_API_KEY, SERVICE_URL, and INSTANCE_CRN values. Then run your application.
For more information and IBM Cloud SDK usage examples for Java, see the IBM Cloud SDK Common documentation.
If you encounter an issue with the project, you're welcome to submit a bug report to help us improve.
For general contribution guidelines, see CONTRIBUTING.
This SDK project is released under the Apache 2.0 license. The license's full text can be found in LICENSE.