以下の例では、 Subscription インスタンスの自動更新ステータスを問い合わせるために DescribeInstanceAutoRenewAttribute API を呼び出して、 Alibaba Cloud Java SDK を使用する方法を紹介します。

コード例

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.ecs.model.v20140526.DescribeInstanceAutoRenewAttributeRequest;
import com.aliyuncs.ecs.model.v20140526.DescribeInstanceAutoRenewAttributeResponse;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.profile.DefaultProfile;

public class ECSOperate {
	private static final String ACCESS_KEY = "";
	private static final String ACCESS_SECRET = "";
	private static IAcsClient client = null;

	static {
		//Create profile
		IClientProfile profile = DefaultProfile.getProfile("cn-shenzhen", ACCESS_KEY, ACCESS_SECRET);
		//Create client
		client = new DefaultAcsClient(profile);
	}

	public static String describeInstanceAutoRenewAttribute(FormatType formatType) {
		//Create request
		DescribeInstanceAutoRenewAttributeRequest request = new DescribeInstanceAutoRenewAttributeRequest();
		request.setInstanceId("Instance ID");
		request.setAcceptFormat(formatType);
                request.setRegionId("<region-id>");
		try {
			// Get response
			return client.doAction(request).getHttpContentString();
			//Get object
			//return client.getAcsResponse(request);
		} catch (ServerException e) {
			System.out.println("Server Error " + e);
			e.printStackTrace();
			return null;
		} catch (ClientException e) {
			System.out.println("Invalid Parameter" + e);
			e.printStackTrace();
			return null;
		}
	}
	public static void main(String[] args) {
	System.out.println(describeInstanceAutoRenewAttribute(FormatType.JSON));
	}
}