This topic describes how to use the Alibaba Cloud SDK for Java to call the Lindorm GetInstanceIpWhiteList operation to retrieve the access whitelist for an instance.
View the OpenAPI document
Before you call an OpenAPI operation, read the corresponding API document to learn about the required parameters and permissions. For more information, see API overview.
Create a RAM user and grant permissions
If you have already created a Resource Access Management (RAM) user and granted the required permissions, skip this step.
Create a RAM user:
Go to the RAM User List and click Create User.
Set Logon Name to hitsdb-openapi-operator and Access Mode to Programmatic Access.
Click OK. The RAM user is created. Save the AccessKey ID and AccessKey secret.
Grant permissions:
Go to the RAM User List page. For the target RAM user, click Add Permissions.
In the text box, search for
AliyunLindormand select the AliyunLindormReadOnlyAccess policy.NoteThe AliyunLindormReadOnlyAccess policy grants permissions to query Lindorm instances. You can also select the AliyunLindormFullAccess policy, which grants full control to query and modify Lindorm instances, or create a custom policy as needed. For more information, see Authorization.
Click OK to complete the authorization.
Call an OpenAPI operation
This topic describes how to use the Alibaba Cloud SDK for Java to call an OpenAPI operation. The usage of SDKs for other languages is similar. For more information, see Lindorm SDK.
Prepare the environment
Download and install JDK 8. If Java is already installed, you can run the following command to check the version: 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>in the following commands with your AccessKey ID and AccessKey secret. Then, run the 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_SECRETenvironment variables and set them to your AccessKey ID and AccessKey secret. Then, restart your computer.
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
Go to GetInstanceIpWhiteList to open the debug page for this operation in OpenAPI Portal.
On the Parameter Settings tab on the left, enter the required parameter values. For this example, enter an instance ID for the InstanceId parameter, such as
ld-bp1kq0x9jogz6****.On the SDK Sample tab on the right, select Java. Click the Download Complete Project button to download the sample code.
Decompress the downloaded package and import the project into your Java integrated development environment (IDE).
Run the code
Run the Sample.java file in the sample folder.
The following example shows a sample response.
{
"InstanceId":"ld-bp1kq0x9jogz6****",
"IpList":["192.***.*.0"],
"RequestId":"D0E46BB4-FA32-5B19-A537-6B1B72451807"}
}