Skip to content

Latest commit

 

History

67 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

IBM Cloud Secrets Manager Management Java SDK

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

Overview

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

Prerequisites

Installation

Maven
<dependency>
    <groupId>com.ibm.cloud</groupId>
    <artifactId>secrets-manager-instance-management</artifactId>
    <version>2.0.3</version>
</dependency>
Gradle
'com.ibm.cloud:secrets-manager-instance-management:2.0.3'

Authentication

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.

Examples

Programmatic credentials

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.

Using the SDK

Basic usage

  • Use the setServiceUrl method 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.

Examples

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.

Issues

If you encounter an issue with the project, you're welcome to submit a bug report to help us improve.

Contributing

For general contribution guidelines, see CONTRIBUTING.

License

This SDK project is released under the Apache 2.0 license. The license's full text can be found in LICENSE.

About

Java SDK for IBM Cloud Secrets Manager instance management

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages