Use Lindorm SDK for Java
Use Alibaba Cloud SDK for Java to call the GetInstanceIpWhiteList operation of Lindorm to query the IP whitelists of a Lindorm instance.
View API documentation
Before you call an API operation, read the documentation to learn about the required parameters and permissions. For more information, see API overview.
Create a RAM user and grant permissions
If you have created a Resource Access Management (RAM) user and granted permissions to the RAM user, skip this step.
-
Create a RAM user.
-
Go to the Users page on the RAM console and click Create User.
-
Set Logon Name to hitsdb-openapi-operator. For Access Mode, select Programmatic access.
-
Click Determine to create the RAM user, and then save the displayed AccessKey ID and AccessKey Secret.
-
-
Authorization completed.
-
Go to the RAM user list and click Add Permission for the target RAM user.
-
In the search box, enter
AliyunLindormand select the AliyunLindormReadOnlyAccess policy.NoteThe AliyunLindormReadOnlyAccess policy can grant the RAM user permissions to query Lindorm instances. You can also select the AliyunLindormFullAccess policy to grant the RAM user full permissions to query and modify Lindorm instances or select a custom policy. For more information, see RAM authorization.
-
Click Grant permissions.
-
Call the API
The following example calls an API operation by using Alibaba Cloud SDK for Java. SDKs for other languages work similarly. For more information, see Lindorm SDKs.
Prerequisites
Download and install JDK 8. If Java is already installed, run the java -version command to check your Java version.
Configure environment variables
Configure the ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variables.
-
For Linux and macOS: Replace
<access_key_id>and<access_key_secret>with your AccessKey ID and AccessKey Secret, and then run the following commands in your terminal:export ALIBABA_CLOUD_ACCESS_KEY_ID=<access_key_id> export ALIBABA_CLOUD_ACCESS_KEY_SECRET=<access_key_secret> -
For Windows: Create the
ALIBABA_CLOUD_ACCESS_KEY_IDandALIBABA_CLOUD_ACCESS_KEY_SECRETsystem environment variables and set them to your AccessKey ID and AccessKey Secret. Then, restart Windows.
Install dependencies
Add the following dependency to the pom.xml file of your Maven project.
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>hitsdb20200615</artifactId>
<version>3.0.6</version>
</dependency>
Download the sample code
-
Visit GetInstanceIpWhiteList in OpenAPI Explorer where you can debug APIs.
-
On the Parameter Configurations tab on the left, set the InstanceId parameter to your instance ID. Example:
ld-bp1kq0x9jogz6****. -
On the SDK Sample Code tab on the right, select Java and click Download Project to download the sample code package.
-
Decompress the package to a local path and import the sample code to your IDE.
Run the sample code
Run the Sample.java file in the sample directory.
The following sample result is returned:
{
"InstanceId":"ld-bp1kq0x9jogz6****",
"IpList":["192.***.*.0"],
"RequestId":"D0E46BB4-FA32-5B19-A537-6B1B72451807"}
}