You can use Alibaba Cloud SDK for Java to manage Lindorm instances without complex programming. This topic describes how to install and use Alibaba Cloud SDK for Java tool and provides examples.

Prerequisites

  • An AccessKey pair is created.
  • The installation package of Lindorm OpenAPI SDK for Java is downloaded. For more information, see Download Lindorm OpenAPI SDKs.

Procedure

  1. Install Lindorm OpenAPI SDK for Java.
  2. Specify the region ID, AccessKey ID, and AccessKey secret. The following table describes the parameters that you can configure.
    IClientProfile profile = DefaultProfile.getProfile("<RegionId>","<accessKeyId>","<accessSecret>");
    Parameter Description
    RegionId The ID of the region in which your Lindorm instance is located.
    accessKeyId The AccessKey ID used to connect to your Lindorm instance.
    accessSecret The AccessKey secret used to connect to your Lindorm instance.
    The following code provides an example on how to specify the parameters described in the preceding table:
    IClientProfile profile = DefaultProfile.getProfile("cn-shanghai","LTAI4FnvzUftE****","PxPzgelK1XCkWBXW****");
  3. Specify the endpoint of Lindorm. The following table describes the parameters that you can configure.
    Note An endpoint is the address from which an Alibaba Cloud service provide API operations. Each service may have different endpoints in different regions. An Alibaba Cloud SDK provides a built-in endpoint addressing module. When you call the SDK to initiate a request to a service, the SDK automatically identifies the endpoint based on the specified region ID and service ID. For more information about the endpoints of different regions, see Endpoints.
    DefaultProfile.addEndpoint("<RegionId>", "hitsdb", "<domain>");
    Parameter Description
    RegionId The ID of the region in which your Lindorm instance is located.
    hitsdb The product code of Lindorm. Set this parameter to hitsdb.
    domain The endpoint of Lindorm in the specified region.
    The following code provides an example on how to specify the parameters described in the preceding table:
    DefaultProfile.addEndpoint("cn-shanghai", "hitsdb", "hitsdb.cn-shanghai.aliyuncs.com");
  4. Initialize the client.
    IAcsClient client = new DefaultAcsClient(profile);
  5. Create the request object.
    GetLindormInstanceRequest request = new GetLindormInstanceRequest();        
    request.setInstanceId("ld-****");
  6. Call the API operation to initiate the request.
    GetLindormInstanceResponse response;
    try {
          response = client.getAcsResponse(request);
          System.out.println(new Gson().toJson(response));
    } catch (ClientException e) {
          e.printStackTrace();
    }

Sample requests

DefaultProfile profile = DefaultProfile.getProfile("cn-shanghai",
        "ak****", "akSecret****");
DefaultProfile.addEndpoint(
        "cn-shanghai",
        "hitsdb",
        "hitsdb.cn-shanghai.aliyuncs.com"
);
IAcsClient client = new DefaultAcsClient(profile);
GetLindormInstanceRequest request = new 
    GetLindormInstanceRequest();
request.setInstanceId("ld-****");
GetLindormInstanceResponse response;
try {
    response = client.getAcsResponse(request);
    System.out.println(new Gson().toJson(response));
} catch (ClientException e) {
    e.printStackTrace();
}

Sample responses

{
  "InstanceStorage": "480",
  "EngineList": [
    {
      "MemorySize": "8",
      "CpuCount": "4",
      "Version": "2.2.3",
      "IsLastVersion": "false",
      "Engine": "lindorm",
      "CoreCount": "2"
    }
  ],
  "ZoneId": "cn-shanghai-f",
  "RequestId": "1986EB6C-B50B-4F41-B365-38A1095DA5C2",
  "InstanceId": "ld-****",
  "ColdStorage": "800",
  "AutoRenew": "false",
  "CreateTime": "2021-01-12 20:40:20",
  "DiskCategory": "cloud_efficiency",
  "DeletionProtection": "false",
  "PayType": "POSTPAY",
  "VswitchId": "vsw-****",
  "VpcId": "vpc-****",
  "ServiceType": "lindorm",
  "NetworkType": "vpc",
  "InstanceStatus": "ACTIVATION",
  "InstanceAlias": "lindorm_test",
  "EngineType": "4",
  "RegionId": "cn-shanghai",
  "ExpireTime": "2020-12-17 00:00:00",
  "AliUid": "100000000000****"
}