10.4新建分支

dev.repair.protocol
ywt 2024-10-04 09:33:54 +08:00
parent d1440fb706
commit 5bb0737c82
7 changed files with 265 additions and 125 deletions

View File

@ -115,6 +115,11 @@
<artifactId>tea-util</artifactId> <artifactId>tea-util</artifactId>
<version>0.2.21</version> <version>0.2.21</version>
</dependency> </dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>darabonba-env</artifactId>
<version>0.1.1</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -0,0 +1,17 @@
package com.muyu.cloud.vehicle.gateway.aliyun.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Instance {
private String instanceId;
private String ipAddress;
private String status;
}

View File

@ -1,23 +1,36 @@
// This file is auto-generated, don't edit it. Thanks. // This file is auto-generated, don't edit it. Thanks.
package com.muyu.cloud.vehicle.gateway.test.example; package com.muyu.cloud.vehicle.gateway.aliyun.ecs;
import com.aliyun.ecs20140526.Client;
import com.aliyun.ecs20140526.models.DeleteInstancesRequest;
import com.aliyun.ecs20140526.models.DescribeInstancesRequest; import com.aliyun.ecs20140526.models.DescribeInstancesRequest;
import com.aliyun.ecs20140526.models.DescribeInstancesResponse; import com.aliyun.ecs20140526.models.DescribeInstancesResponse;
import com.aliyun.ecs20140526.models.DescribeInstancesResponseBody; import com.aliyun.ecs20140526.models.DescribeInstancesResponseBody;
import com.aliyun.tea.*; import com.aliyun.tea.*;
import com.aliyun.teaopenapi.models.Config;
import com.aliyun.teautil.Common;
import com.aliyun.teautil.models.RuntimeOptions; import com.aliyun.teautil.models.RuntimeOptions;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
/** /**
* *
*/ */
@Log4j2 @Log4j2
@Component @Component
public class DelInstance implements DisposableBean{ public class DelInstance implements ApplicationListener<ContextClosedEvent> {
@Autowired
private StringRedisTemplate redisTemplate;
/** /**
* <b>description</b> : * <b>description</b> :
@ -26,46 +39,48 @@ public class DelInstance implements DisposableBean{
* *
* @throws Exception * @throws Exception
*/ */
public static com.aliyun.ecs20140526.Client createClient() throws Exception { public static Client createClient() throws Exception {
// 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。 // 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
// 建议使用更安全的 STS 方式更多鉴权访问方式请参见https://help.aliyun.com/document_detail/378657.html。 // 建议使用更安全的 STS 方式更多鉴权访问方式请参见https://help.aliyun.com/document_detail/378657.html。
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config() Config config = new Config()
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。 // 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
.setAccessKeyId("LTAI5t7Fnx2QLTYLSu9357wP") .setAccessKeyId("LTAI5t7Fnx2QLTYLSu9357wP")
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。 // 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
.setAccessKeySecret("3LOnydNZ25ytsTGczuSygElx0HJ6nN"); .setAccessKeySecret("3LOnydNZ25ytsTGczuSygElx0HJ6nN");
// Endpoint 请参考 https://api.aliyun.com/product/Ecs // Endpoint 请参考 https://api.aliyun.com/product/Ecs
config.endpoint = "ecs.cn-shanghai.aliyuncs.com"; config.endpoint = "ecs.cn-shanghai.aliyuncs.com";
return new com.aliyun.ecs20140526.Client(config); return new Client(config);
} }
public static void delInstance() throws Exception{ public void delInstance() throws Exception{
//创建ECS客户端对象用于后续调用ECS相关API //创建ECS客户端对象用于后续调用ECS相关API
com.aliyun.ecs20140526.Client client = DelInstance.createClient(); Client client = DelInstance.createClient();
DescribeInstancesRequest describeInstancesRequest = new DescribeInstancesRequest() List<String> list = redisTemplate.opsForList().range("instanceIds",0,-1);
.setRegionId("cn-shanghai");
//创建运行时选择对象,用于配置运行时的选项参数 // DescribeInstancesRequest describeInstancesRequest = new DescribeInstancesRequest()
RuntimeOptions runtimeOptions = new RuntimeOptions(); // .setRegionId("cn-shanghai");
//获取实例列表 // //创建运行时选择对象,用于配置运行时的选项参数
DescribeInstancesResponse describeInstancesResponse = client.describeInstancesWithOptions(describeInstancesRequest, runtimeOptions); // RuntimeOptions runtimeOptions = new RuntimeOptions();
//
//提取实例ID集合 // //获取实例列表
ArrayList<String> list = new ArrayList<>(); // DescribeInstancesResponse describeInstancesResponse = client.describeInstancesWithOptions(describeInstancesRequest, runtimeOptions);
DescribeInstancesResponseBody body = describeInstancesResponse.getBody(); //
// //提取实例ID集合
for (DescribeInstancesResponseBody.DescribeInstancesResponseBodyInstancesInstance instance : body.getInstances().getInstance()) { // ArrayList<String> list = new ArrayList<>();
list.add(instance.getInstanceId()); // DescribeInstancesResponseBody body = describeInstancesResponse.getBody();
} //
// for (DescribeInstancesResponseBody.DescribeInstancesResponseBodyInstancesInstance instance : body.getInstances().getInstance()) {
System.out.println("Instance IDs"+list); // list.add(instance.getInstanceId());
// }
//
// System.out.println("Instance IDs"+list);
// 创建删除实例请求对象,并设置请求参数 // 创建删除实例请求对象,并设置请求参数
com.aliyun.ecs20140526.models.DeleteInstancesRequest deleteInstancesRequest = new com.aliyun.ecs20140526.models.DeleteInstancesRequest() DeleteInstancesRequest deleteInstancesRequest = new DeleteInstancesRequest()
// 设置地域ID指定要删除的实例所属的地域ID。 // 设置地域ID指定要删除的实例所属的地域ID。
.setRegionId("cn-shanghai") .setRegionId("cn-shanghai")
//设置DryRun为True用于验证请求是否可以成功但不实际执行删除操作 //设置DryRun为True用于验证请求是否可以成功但不实际执行删除操作
@ -77,32 +92,44 @@ public class DelInstance implements DisposableBean{
// 设置实例ID列表使用参数名称 instanceId参数类型为数组。 // 设置实例ID列表使用参数名称 instanceId参数类型为数组。
.setInstanceId(list); .setInstanceId(list);
// 创建运行时选项对象,用于配置运行时的选项参数 // 创建运行时选项对象,用于配置运行时的选项参数
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions(); RuntimeOptions runtime = new RuntimeOptions();
try{ try{
//复制代码运行请自行打印 API 的返回值 //复制代码运行请自行打印 API 的返回值
client.deleteInstancesWithOptions(deleteInstancesRequest,runtime); client.deleteInstancesWithOptions(deleteInstancesRequest,runtime);
} catch (TeaException error) { } catch (TeaException error) {
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。 // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
// 错误 message // 错误 message
System.out.println(error.getMessage()); log.error(error.getMessage());
// 诊断地址 // 诊断地址
System.out.println(error.getData().get("Recommend")); log.error(error.getData().get("Recommend"));
com.aliyun.teautil.Common.assertAsString(error.message); Common.assertAsString(error.message);
} catch (Exception _error){ } catch (Exception _error){
TeaException error = new TeaException(_error.getMessage(), _error); TeaException error = new TeaException(_error.getMessage(), _error);
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。 // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
// 错误 message // 错误 message
System.out.println(error.getMessage()); log.error(error.getMessage());
// 诊断地址 // 诊断地址
System.out.println(error.getData().get("Recommend")); log.error(error.getData().get("Recommend"));
com.aliyun.teautil.Common.assertAsString(error.message); Common.assertAsString(error.message);
} }
} }
// @Override
// public void destroy() throws Exception {
// log.info("===============>开始执行删除实例方法");
// delInstance();
// }
@Override @Override
public void destroy() throws Exception { public void onApplicationEvent(ContextClosedEvent event) {
log.info("===============>开始执行删除实例方法"); try{
log.info("=======>删除实例");
delInstance(); delInstance();
redisTemplate.delete("instanceIds");
redisTemplate.delete("instanceList");
} catch (Exception e) {
throw new RuntimeException(e);
}
} }
} }

View File

@ -0,0 +1,59 @@
package com.muyu.cloud.vehicle.gateway.aliyun.ecs;
import com.aliyun.ecs20140526.Client;
import com.aliyun.ecs20140526.models.DescribeInstancesRequest;
import com.aliyun.ecs20140526.models.DescribeInstancesResponse;
import com.aliyun.teaopenapi.models.Config;
import com.aliyun.darabonba.env.EnvClient;
import com.aliyun.teautil.Common;
import com.aliyun.teautil.models.RuntimeOptions;
import java.util.Arrays;
import java.util.List;
/**
*
*/
public class QueryInstance {
/**
* <b>description</b> :
* <p>使AK&amp;SKClient</p>
* @return Client
*
* @throws Exception
*/
public static Client createClient(String alibabaCloudAccessKeyId, String alibabaCloudAccessKeySecret) throws Exception{
Config config = new Config()
.setAccessKeyId("LTAI5t7Fnx2QLTYLSu9357wP")
.setAccessKeySecret("3LOnydNZ25ytsTGczuSygElx0HJ6nN");
config.endpoint = "ecs-cn-hangzhou.aliyuncs.com";
return new Client(config);
}
public static Client createClientWithSTS() throws Exception {
Config config = new Config()
.setAccessKeyId("LTAI5t7Fnx2QLTYLSu9357wP")
.setAccessKeySecret("3LOnydNZ25ytsTGczuSygElx0HJ6nN")
.setSecurityToken("token")
.setType("sts");
config.endpoint = "ecs-cn-hangzhou.aliyuncs.com";
return new Client(config);
}
public static void main(String[] args_) throws Exception{
List<String> list = Arrays.asList(args_);
Client client = QueryInstance.createClient(EnvClient.getEnv("LTAI5t7Fnx2QLTYLSu9357wP"), EnvClient.getEnv("3LOnydNZ25ytsTGczuSygElx0HJ6nN"));
DescribeInstancesRequest describeInstancesRequest = new DescribeInstancesRequest()
.setRegionId("cn-shanghai")
.setInternetChargeType("PayByTraffic")
.setInstanceChargeType("PostPaid");
RuntimeOptions runtime = new RuntimeOptions();
DescribeInstancesResponse resp = client.describeInstancesWithOptions(describeInstancesRequest, runtime);
com.aliyun.teaconsole.Client.log(Common.toJSONString(resp));
}
}

View File

@ -1,12 +1,25 @@
package com.muyu.cloud.vehicle.gateway.test.example; package com.muyu.cloud.vehicle.gateway.aliyun.ecs;
import com.aliyun.ecs20140526.Client;
import com.aliyun.ecs20140526.models.*;
import com.aliyun.tea.*; import com.aliyun.tea.*;
import com.aliyun.teaopenapi.models.Config;
import com.aliyun.teautil.models.RuntimeOptions;
import com.muyu.cloud.vehicle.gateway.aliyun.domain.Instance;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.apache.logging.log4j.CloseableThreadContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner; import org.springframework.boot.ApplicationRunner;
import org.springframework.data.redis.core.ListOperations;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/** /**
* ECS * ECS
*/ */
@ -14,6 +27,11 @@ import org.springframework.stereotype.Component;
@Component @Component
public class Sample implements ApplicationRunner { public class Sample implements ApplicationRunner {
@Autowired
private StringRedisTemplate redisTemplate;
/** /**
* <b>description</b> : * <b>description</b> :
* <p>使AK&amp;SKClient</p> * <p>使AK&amp;SKClient</p>
@ -21,44 +39,51 @@ public class Sample implements ApplicationRunner {
* *
* @throws Exception * @throws Exception
*/ */
public static com.aliyun.ecs20140526.Client createClient() throws Exception { public static Client createClient() throws Exception {
// 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。 // 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config() Config config = new Config()
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。 // 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
.setAccessKeyId("LTAI5t7Fnx2QLTYLSu9357wP") .setAccessKeyId("LTAI5t7Fnx2QLTYLSu9357wP")
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。 // 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
.setAccessKeySecret("3LOnydNZ25ytsTGczuSygElx0HJ6nN"); .setAccessKeySecret("3LOnydNZ25ytsTGczuSygElx0HJ6nN");
// Endpoint 请参考 https://api.aliyun.com/product/Ecs // Endpoint 请参考 https://api.aliyun.com/product/Ecs
config.endpoint = "ecs-cn-hangzhou.aliyuncs.com"; config.endpoint = "ecs-cn-hangzhou.aliyuncs.com";
return new com.aliyun.ecs20140526.Client(config); return new Client(config);
} }
public static void creatInstance() throws Exception { public void creatInstance() throws Exception {
// 将命令行参数转换为字符串列表 // 将命令行参数转换为字符串列表
java.util.List<String> args = java.util.Arrays.asList(); List<String> args = Arrays.asList();
// 创建阿里云ECS客户端 // 创建阿里云ECS客户端
com.aliyun.ecs20140526.Client client = Sample.createClient(); Client client = Sample.createClient();
// 配置系统盘参数 // 配置系统盘参数
com.aliyun.ecs20140526.models.RunInstancesRequest.RunInstancesRequestSystemDisk systemDisk = new com.aliyun.ecs20140526.models.RunInstancesRequest.RunInstancesRequestSystemDisk() RunInstancesRequest.RunInstancesRequestSystemDisk systemDisk = new RunInstancesRequest.RunInstancesRequestSystemDisk()
.setSize("20")// 设置系统盘大小为40GB .setSize("20")// 设置系统盘大小为40GB
.setCategory("cloud_essd");// 设置系统盘类型为cloud_essd .setCategory("cloud_essd");// 设置系统盘类型为cloud_essd
// 创建创建实例请求对象并设置参数 // 创建创建实例请求对象并设置参数
com.aliyun.ecs20140526.models.RunInstancesRequest runInstancesRequest = new com.aliyun.ecs20140526.models.RunInstancesRequest() RunInstancesRequest runInstancesRequest = new RunInstancesRequest()
.setRegionId("cn-shanghai") // 设置地域ID .setRegionId("cn-shanghai") // 设置地域ID
.setImageId("m-uf66taa8r57hvow8cxlj")// 设置镜像ID .setImageId("m-uf63dnbv4od71jlezdne")// 设置镜像ID
.setInstanceType("ecs.e-c1m1.large")// 设置实例类型 .setInstanceType("ecs.e-c1m1.large")// 设置实例类型
.setSecurityGroupId("sg-uf6hyictocodexptlgiv")// 设置安全组ID .setSecurityGroupId("sg-uf6hyictocodexptlgiv")// 设置安全组ID
.setVSwitchId("vsw-uf6ags5luz17qd6ckn2tb")// 设置虚拟交换机ID .setVSwitchId("vsw-uf6ags5luz17qd6ckn2tb")// 设置虚拟交换机ID
.setInstanceName("launch-advisor-20240928")// 设置实例名称 .setInstanceName("launch-advisor-20240929")// 设置实例名称
.setInstanceChargeType("PostPaid")// 设置实例付费类型为后付费按量付费 .setInstanceChargeType("PostPaid")// 设置实例付费类型为后付费按量付费
.setSystemDisk(systemDisk)// 设置系统盘配置 .setSystemDisk(systemDisk)// 设置系统盘配置
.setHostName("root")// 设置主机名 .setHostName("root")// 设置主机名
.setPassword("@ywt021900")// 设置实例密码 .setPassword("@ywt021900")// 设置实例密码
.setAmount(2);// 设置创建实例的数量 .setAmount(1)// 设置创建实例的数量
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions(); .setInternetChargeType("PayByTraffic")// 设置互联网计费类型为按流量计费
.setInternetMaxBandwidthOut(1);// 设置互联网最大出带宽为1 Mbps
RuntimeOptions runtime = new RuntimeOptions();
try { try {
// 复制代码运行请自行打印 API 的返回值 // 复制代码运行请自行打印 API 的返回值
client.runInstancesWithOptions(runInstancesRequest, runtime); RunInstancesResponse runInstancesResponse = client.runInstancesWithOptions(runInstancesRequest, runtime);
RunInstancesResponseBody body = runInstancesResponse.getBody();
ArrayList<String> list = new ArrayList<>(body.getInstanceIdSets().getInstanceIdSet());
log.info("实例ID{}", list);
} catch (TeaException error) { } catch (TeaException error) {
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。 // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
// 错误 message // 错误 message
@ -77,6 +102,13 @@ public class Sample implements ApplicationRunner {
} }
} }
// private static DescribeInstancesResponse queryInstanceDetails(Client client) {
//
// //创建查询实例请求对象并设置参数
// DescribeInstancesRequest describeInstancesRequest = new DescribeInstancesRequest();
// return null;
// }
@Override @Override
public void run(ApplicationArguments args) throws Exception { public void run(ApplicationArguments args) throws Exception {
log.info("===============>开始批量创建实例"); log.info("===============>开始批量创建实例");

View File

@ -0,0 +1,56 @@
package com.muyu.cloud.vehicle.gateway.aliyun.ecs;//// This file is auto-generated, don't edit it. Thanks.
//package com.muyu.cloud.vehicle.gateway.aliyun.ecs;
//
//import com.aliyun.tea.*;
//
///**
// * 启动一台实例
// */
//public class StartInstance {
//
// /**
// * <b>description</b> :
// * <p>使用AK&amp;SK初始化账号Client</p>
// * @return Client
// *
// * @throws Exception
// */
// public static com.aliyun.ecs20140526.Client createClient() throws Exception {
// // 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
// // 建议使用更安全的 STS 方式更多鉴权访问方式请参见https://help.aliyun.com/document_detail/378657.html。
// com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
// // 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
// .setAccessKeyId("LTAI5t7Fnx2QLTYLSu9357wP")
// // 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
// .setAccessKeySecret("3LOnydNZ25ytsTGczuSygElx0HJ6nN");
// // Endpoint 请参考 https://api.aliyun.com/product/Ecs
// config.endpoint = "ecs.cn-shanghai.aliyuncs.com";
// return new com.aliyun.ecs20140526.Client(config);
// }
//
// public static void main(String[] args_) throws Exception {
// java.util.List<String> args = java.util.Arrays.asList(args_);
// com.aliyun.ecs20140526.Client client = StartInstance.createClient();
// com.aliyun.ecs20140526.models.StartInstanceRequest startInstanceRequest = new com.aliyun.ecs20140526.models.StartInstanceRequest();
// com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
// try {
// // 复制代码运行请自行打印 API 的返回值
// client.startInstanceWithOptions(startInstanceRequest, runtime);
// } catch (TeaException error) {
// // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
// // 错误 message
// System.out.println(error.getMessage());
// // 诊断地址
// System.out.println(error.getData().get("Recommend"));
// com.aliyun.teautil.Common.assertAsString(error.message);
// } catch (Exception _error) {
// TeaException error = new TeaException(_error.getMessage(), _error);
// // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
// // 错误 message
// System.out.println(error.getMessage());
// // 诊断地址
// System.out.println(error.getData().get("Recommend"));
// com.aliyun.teautil.Common.assertAsString(error.message);
// }
// }
//}

View File

@ -1,56 +0,0 @@
// This file is auto-generated, don't edit it. Thanks.
package com.muyu.cloud.vehicle.gateway.test.example;
import com.aliyun.tea.*;
/**
*
*/
public class StartInstance {
/**
* <b>description</b> :
* <p>使AK&amp;SKClient</p>
* @return Client
*
* @throws Exception
*/
public static com.aliyun.ecs20140526.Client createClient() throws Exception {
// 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
// 建议使用更安全的 STS 方式更多鉴权访问方式请参见https://help.aliyun.com/document_detail/378657.html。
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
.setAccessKeyId("LTAI5t7Fnx2QLTYLSu9357wP")
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
.setAccessKeySecret("3LOnydNZ25ytsTGczuSygElx0HJ6nN");
// Endpoint 请参考 https://api.aliyun.com/product/Ecs
config.endpoint = "ecs.cn-shanghai.aliyuncs.com";
return new com.aliyun.ecs20140526.Client(config);
}
public static void main(String[] args_) throws Exception {
java.util.List<String> args = java.util.Arrays.asList(args_);
com.aliyun.ecs20140526.Client client = StartInstance.createClient();
com.aliyun.ecs20140526.models.StartInstanceRequest startInstanceRequest = new com.aliyun.ecs20140526.models.StartInstanceRequest();
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
try {
// 复制代码运行请自行打印 API 的返回值
client.startInstanceWithOptions(startInstanceRequest, runtime);
} catch (TeaException error) {
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
// 错误 message
System.out.println(error.getMessage());
// 诊断地址
System.out.println(error.getData().get("Recommend"));
com.aliyun.teautil.Common.assertAsString(error.message);
} catch (Exception _error) {
TeaException error = new TeaException(_error.getMessage(), _error);
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
// 错误 message
System.out.println(error.getMessage());
// 诊断地址
System.out.println(error.getData().get("Recommend"));
com.aliyun.teautil.Common.assertAsString(error.message);
}
}
}