Ecs.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. using Tea;
  2. using AlibabaCloud.SDK.Ecs20140526.Models;
  3. namespace molilian.core
  4. {
  5. public partial class AliyunPlus
  6. {
  7. public DescribeNetworkInterfaceAttributeResponse DescribeNetworkInterfaceAttribute(string region, string networkInterfaceId)
  8. {
  9. AlibabaCloud.OpenApiClient.Models.Config config = new()
  10. {
  11. AccessKeyId = _app_key,
  12. AccessKeySecret = _app_secret,
  13. Endpoint = $"ecs.{region}.aliyuncs.com"
  14. };
  15. AlibabaCloud.SDK.Ecs20140526.Client client = new(config);
  16. DescribeNetworkInterfaceAttributeRequest describeNetworkInterfaceAttributeRequest = new()
  17. {
  18. RegionId = region,
  19. NetworkInterfaceId = networkInterfaceId,
  20. };
  21. AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new();
  22. try
  23. {
  24. var response = client.DescribeNetworkInterfaceAttributeWithOptions(describeNetworkInterfaceAttributeRequest, runtime);
  25. return response;
  26. }
  27. catch (TeaException error)
  28. {
  29. // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
  30. // 错误 message
  31. Console.WriteLine(error.Message);
  32. // 诊断地址
  33. Console.WriteLine(error.Data["Recommend"]);
  34. AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
  35. }
  36. catch (Exception _error)
  37. {
  38. TeaException error = new TeaException(new Dictionary<string, object>
  39. {
  40. { "message", _error.Message }
  41. });
  42. // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
  43. // 错误 message
  44. Console.WriteLine(error.Message);
  45. // 诊断地址
  46. Console.WriteLine(error.Data["Recommend"]);
  47. AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
  48. }
  49. return null;
  50. }
  51. /// <summary>
  52. /// 可以指定ResourceGroupId、VSwitchId、InstanceId等参数,查询一个或多个弹性网卡(ENI)的详细信息
  53. /// </summary>
  54. /// <param name="region"></param>
  55. /// <param name="networkInterfaceId"></param>
  56. /// <param name="count"></param>
  57. /// <returns></returns>
  58. public DescribeNetworkInterfacesResponse DescribeNetworkInterfaces(string region, string instanceId)
  59. {
  60. AlibabaCloud.OpenApiClient.Models.Config config = new()
  61. {
  62. AccessKeyId = _app_key,
  63. AccessKeySecret = _app_secret,
  64. Endpoint = $"ecs.{region}.aliyuncs.com"
  65. };
  66. AlibabaCloud.SDK.Ecs20140526.Client client = new(config);
  67. DescribeNetworkInterfacesRequest describeNetworkInterfacesRequest = new()
  68. {
  69. RegionId = region,
  70. InstanceId = instanceId,
  71. };
  72. AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new();
  73. try
  74. {
  75. var response = client.DescribeNetworkInterfacesWithOptions(describeNetworkInterfacesRequest, runtime);
  76. return response;
  77. }
  78. catch (TeaException error)
  79. {
  80. // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
  81. // 错误 message
  82. Console.WriteLine(error.Message);
  83. // 诊断地址
  84. Console.WriteLine(error.Data["Recommend"]);
  85. AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
  86. }
  87. catch (Exception _error)
  88. {
  89. TeaException error = new TeaException(new Dictionary<string, object>
  90. {
  91. { "message", _error.Message }
  92. });
  93. // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
  94. // 错误 message
  95. Console.WriteLine(error.Message);
  96. // 诊断地址
  97. Console.WriteLine(error.Data["Recommend"]);
  98. AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
  99. }
  100. return null;
  101. }
  102. /// <summary>
  103. /// 为一块弹性网卡分配一个或多个辅助私网IP地址。可以为网卡指定在所属交换机(vSwitch)的空闲私网IP地址,或者通过指定私网地址数量自动分配私网IP地址
  104. /// </summary>
  105. /// <param name="region"></param>
  106. /// <param name="networkInterfaceId"></param>
  107. /// <param name="count"></param>
  108. /// <returns></returns>
  109. public AssignPrivateIpAddressesResponse AssignPrivateIpAddresses(string region, string networkInterfaceId, int count)
  110. {
  111. AlibabaCloud.OpenApiClient.Models.Config config = new()
  112. {
  113. AccessKeyId = _app_key,
  114. AccessKeySecret = _app_secret,
  115. Endpoint = $"ecs.{region}.aliyuncs.com"
  116. };
  117. AlibabaCloud.SDK.Ecs20140526.Client client = new(config);
  118. AssignPrivateIpAddressesRequest assignPrivateIpAddressesRequest = new()
  119. {
  120. RegionId = region,
  121. NetworkInterfaceId = networkInterfaceId,
  122. SecondaryPrivateIpAddressCount = count,
  123. };
  124. AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new();
  125. try
  126. {
  127. var response = client.AssignPrivateIpAddressesWithOptions(assignPrivateIpAddressesRequest, runtime);
  128. return response;
  129. }
  130. catch (TeaException error)
  131. {
  132. // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
  133. // 错误 message
  134. Console.WriteLine(error.Message);
  135. // 诊断地址
  136. Console.WriteLine(error.Data["Recommend"]);
  137. AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
  138. }
  139. catch (Exception _error)
  140. {
  141. TeaException error = new TeaException(new Dictionary<string, object>
  142. {
  143. { "message", _error.Message }
  144. });
  145. // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
  146. // 错误 message
  147. Console.WriteLine(error.Message);
  148. // 诊断地址
  149. Console.WriteLine(error.Data["Recommend"]);
  150. AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
  151. }
  152. return null;
  153. }
  154. /// <summary>
  155. /// 从一块弹性网卡删除一个或多个辅助私有IP地址
  156. /// </summary>
  157. /// <param name="region"></param>
  158. /// <param name="networkInterfaceId"></param>
  159. /// <param name="privateIpAddress"></param>
  160. /// <returns></returns>
  161. public UnassignPrivateIpAddressesResponse UnassignPrivateIpAddresses(string region, string networkInterfaceId, params string[] privateIpAddress)
  162. {
  163. AlibabaCloud.OpenApiClient.Models.Config config = new()
  164. {
  165. AccessKeyId = _app_key,
  166. AccessKeySecret = _app_secret,
  167. Endpoint = $"ecs.{region}.aliyuncs.com"
  168. };
  169. AlibabaCloud.SDK.Ecs20140526.Client client = new(config);
  170. UnassignPrivateIpAddressesRequest unassignPrivateIpAddressesRequest = new()
  171. {
  172. RegionId = region,
  173. NetworkInterfaceId = networkInterfaceId,
  174. PrivateIpAddress = privateIpAddress.ToList(),
  175. };
  176. AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new();
  177. try
  178. {
  179. var response = client.UnassignPrivateIpAddressesWithOptions(unassignPrivateIpAddressesRequest, runtime);
  180. return response;
  181. }
  182. catch (TeaException error)
  183. {
  184. // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
  185. // 错误 message
  186. Console.WriteLine(error.Message);
  187. // 诊断地址
  188. Console.WriteLine(error.Data["Recommend"]);
  189. AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
  190. }
  191. catch (Exception _error)
  192. {
  193. TeaException error = new TeaException(new Dictionary<string, object>
  194. {
  195. { "message", _error.Message }
  196. });
  197. // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
  198. // 错误 message
  199. Console.WriteLine(error.Message);
  200. // 诊断地址
  201. Console.WriteLine(error.Data["Recommend"]);
  202. AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
  203. }
  204. return null;
  205. }
  206. /// <summary>
  207. /// 本接口用于查询一台指定ECS实例的属性信息
  208. /// </summary>
  209. /// <param name="region"></param>
  210. /// <param name="instanceId"></param>
  211. /// <returns></returns>
  212. public DescribeInstanceAttributeResponse DescribeInstanceAttribute(string region, string instanceId)
  213. {
  214. AlibabaCloud.OpenApiClient.Models.Config config = new()
  215. {
  216. AccessKeyId = _app_key,
  217. AccessKeySecret = _app_secret,
  218. Endpoint = $"ecs.{region}.aliyuncs.com"
  219. };
  220. AlibabaCloud.SDK.Ecs20140526.Client client = new(config);
  221. DescribeInstanceAttributeRequest describeInstanceAttributeRequest = new()
  222. {
  223. InstanceId = instanceId
  224. };
  225. AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new();
  226. try
  227. {
  228. var response = client.DescribeInstanceAttributeWithOptions(describeInstanceAttributeRequest, runtime);
  229. return response;
  230. }
  231. catch (TeaException error)
  232. {
  233. // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
  234. // 错误 message
  235. Console.WriteLine(error.Message);
  236. // 诊断地址
  237. Console.WriteLine(error.Data["Recommend"]);
  238. AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
  239. }
  240. catch (Exception _error)
  241. {
  242. TeaException error = new TeaException(new Dictionary<string, object>
  243. {
  244. { "message", _error.Message }
  245. });
  246. // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
  247. // 错误 message
  248. Console.WriteLine(error.Message);
  249. // 诊断地址
  250. Console.WriteLine(error.Data["Recommend"]);
  251. AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
  252. }
  253. return null;
  254. /*
  255. */
  256. }
  257. /// <summary>
  258. /// 创建一张弹性网卡(ENI),支持指定主私网IP地址
  259. /// </summary>
  260. /// <param name="region"></param>
  261. /// <param name="vswitchId"></param>
  262. /// <returns></returns>
  263. public CreateNetworkInterfaceResponse CreateNetworkInterface(string region, string vswitchId, List<string> securityGroupId)
  264. {
  265. AlibabaCloud.OpenApiClient.Models.Config config = new()
  266. {
  267. AccessKeyId = _app_key,
  268. AccessKeySecret = _app_secret,
  269. Endpoint = $"ecs.{region}.aliyuncs.com"
  270. };
  271. AlibabaCloud.SDK.Ecs20140526.Client client = new(config);
  272. CreateNetworkInterfaceRequest createNetworkInterfaceRequest = new()
  273. {
  274. RegionId = region,
  275. VSwitchId = vswitchId,
  276. SecurityGroupIds = securityGroupId
  277. };
  278. AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new();
  279. try
  280. {
  281. var response = client.CreateNetworkInterfaceWithOptions(createNetworkInterfaceRequest, runtime);
  282. return response;
  283. }
  284. catch (TeaException error)
  285. {
  286. // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
  287. // 错误 message
  288. Console.WriteLine(error.Message);
  289. // 诊断地址
  290. Console.WriteLine(error.Data["Recommend"]);
  291. AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
  292. }
  293. catch (Exception _error)
  294. {
  295. TeaException error = new TeaException(new Dictionary<string, object>
  296. {
  297. { "message", _error.Message }
  298. });
  299. // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
  300. // 错误 message
  301. Console.WriteLine(error.Message);
  302. // 诊断地址
  303. Console.WriteLine(error.Data["Recommend"]);
  304. AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
  305. }
  306. return null;
  307. /*
  308. */
  309. }
  310. /// <summary>
  311. /// 附加一个弹性网卡(ENI)到一台专有网络VPC类型ECS实例上
  312. /// </summary>
  313. /// <param name="region"></param>
  314. /// <param name="instanceId"></param>
  315. /// <param name="networkInterfaceId"></param>
  316. /// <returns></returns>
  317. public AttachNetworkInterfaceResponse AttachNetworkInterface(string region, string instanceId, string networkInterfaceId)
  318. {
  319. AlibabaCloud.OpenApiClient.Models.Config config = new()
  320. {
  321. AccessKeyId = _app_key,
  322. AccessKeySecret = _app_secret,
  323. Endpoint = $"ecs.{region}.aliyuncs.com"
  324. };
  325. AlibabaCloud.SDK.Ecs20140526.Client client = new(config);
  326. AttachNetworkInterfaceRequest AttachNetworkInterfaceRequest = new()
  327. {
  328. RegionId = region,
  329. NetworkInterfaceId = networkInterfaceId,
  330. InstanceId = instanceId
  331. };
  332. AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new();
  333. try
  334. {
  335. var response = client.AttachNetworkInterfaceWithOptions(AttachNetworkInterfaceRequest, runtime);
  336. return response;
  337. }
  338. catch (TeaException error)
  339. {
  340. // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
  341. // 错误 message
  342. Console.WriteLine(error.Message);
  343. // 诊断地址
  344. Console.WriteLine(error.Data["Recommend"]);
  345. AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
  346. throw;
  347. }
  348. catch (Exception _error)
  349. {
  350. TeaException error = new TeaException(new Dictionary<string, object>
  351. {
  352. { "message", _error.Message }
  353. });
  354. // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
  355. // 错误 message
  356. Console.WriteLine(error.Message);
  357. // 诊断地址
  358. Console.WriteLine(error.Data["Recommend"]);
  359. AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
  360. throw;
  361. }
  362. return null;
  363. /*
  364. */
  365. }
  366. /// <summary>
  367. /// 查询实例的详细信息列表
  368. /// </summary>
  369. /// <param name="region"></param>
  370. /// <returns></returns>
  371. public DescribeInstancesResponse DescribeInstances(string region)
  372. {
  373. AlibabaCloud.OpenApiClient.Models.Config config = new()
  374. {
  375. AccessKeyId = _app_key,
  376. AccessKeySecret = _app_secret,
  377. Endpoint = $"ecs.{region}.aliyuncs.com"
  378. };
  379. AlibabaCloud.SDK.Ecs20140526.Client client = new(config);
  380. DescribeInstancesRequest describeInstancesRequest = new()
  381. {
  382. RegionId = region,
  383. };
  384. AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new();
  385. try
  386. {
  387. var response = client.DescribeInstancesWithOptions(describeInstancesRequest, runtime);
  388. return response;
  389. }
  390. catch (TeaException error)
  391. {
  392. // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
  393. // 错误 message
  394. Console.WriteLine(error.Message);
  395. // 诊断地址
  396. Console.WriteLine(error.Data["Recommend"]);
  397. AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
  398. }
  399. catch (Exception _error)
  400. {
  401. TeaException error = new TeaException(new Dictionary<string, object>
  402. {
  403. { "message", _error.Message }
  404. });
  405. // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
  406. // 错误 message
  407. Console.WriteLine(error.Message);
  408. // 诊断地址
  409. Console.WriteLine(error.Data["Recommend"]);
  410. AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
  411. }
  412. return null;
  413. /*
  414. {
  415. "Instances": {
  416. "Instance": [
  417. {
  418. "ResourceGroupId": "",
  419. "Memory": 4096,
  420. "InstanceChargeType": "PrePaid",
  421. "Cpu": 2,
  422. "OSName": "Alibaba Cloud Linux 3.2104 LTS 64位",
  423. "InstanceNetworkType": "vpc",
  424. "InnerIpAddress": {
  425. "IpAddress": []
  426. },
  427. "ExpiredTime": "2025-04-09T16:00Z",
  428. "ImageId": "aliyun_3_x64_20G_alibase_20240819.vhd",
  429. "EipAddress": {
  430. "Bandwidth": 200,
  431. "AllocationId": "eip-2ze092o8df3jkykhjt5uw",
  432. "IpAddress": "47.93.249.227",
  433. "IsSupportUnassociate": true,
  434. "InternetChargeType": "PayByTraffic"
  435. },
  436. "ImageOptions": {},
  437. "HostName": "iZ2ze58hz63abqwi97eql5Z",
  438. "VlanId": "",
  439. "Status": "Running",
  440. "HibernationOptions": {
  441. "Configured": false
  442. },
  443. "MetadataOptions": {
  444. "HttpTokens": "",
  445. "HttpEndpoint": ""
  446. },
  447. "InstanceId": "i-2ze58hz63abqwi97eql5",
  448. "StoppedMode": "Not-applicable",
  449. "CpuOptions": {
  450. "ThreadsPerCore": 2,
  451. "Numa": "ON",
  452. "CoreCount": 1
  453. },
  454. "StartTime": "2024-11-11T18:55Z",
  455. "PrivateDnsNameOptions": {},
  456. "DeletionProtection": false,
  457. "SecurityGroupIds": {
  458. "SecurityGroupId": [
  459. "sg-2ze3ks3fd85brhe9c48x"
  460. ]
  461. },
  462. "VpcAttributes": {
  463. "PrivateIpAddress": {
  464. "IpAddress": [
  465. "172.26.246.235"
  466. ]
  467. },
  468. "VpcId": "vpc-2zef23dd2ah5byvaampoh",
  469. "VSwitchId": "vsw-2ze1l2p0nwulsib3baj22",
  470. "NatIpAddress": ""
  471. },
  472. "InternetChargeType": "",
  473. "InstanceName": "iZ2ze58hz63abqwi97eql5Z",
  474. "DeploymentSetId": "",
  475. "InternetMaxBandwidthOut": 0,
  476. "SerialNumber": "a784fa00-704d-4061-958d-956e60ec37b6",
  477. "OSType": "linux",
  478. "CreationTime": "2024-04-09T04:28Z",
  479. "AutoReleaseTime": "",
  480. "Description": "",
  481. "InstanceTypeFamily": "ecs.u1",
  482. "DedicatedInstanceAttribute": {
  483. "Tenancy": "",
  484. "Affinity": ""
  485. },
  486. "PublicIpAddress": {
  487. "IpAddress": []
  488. },
  489. "GPUSpec": "",
  490. "NetworkInterfaces": {
  491. "NetworkInterface": [
  492. {
  493. "Type": "Primary",
  494. "PrimaryIpAddress": "172.26.246.235",
  495. "MacAddress": "00:16:3e:37:f1:5e",
  496. "NetworkInterfaceId": "eni-2ze3ks3fd85brff1j4av",
  497. "PrivateIpSets": {
  498. "PrivateIpSet": [
  499. {
  500. "PrivateIpAddress": "172.26.246.235",
  501. "Primary": true
  502. }
  503. ]
  504. }
  505. },
  506. {
  507. "Type": "Secondary",
  508. "PrimaryIpAddress": "172.26.246.236",
  509. "MacAddress": "00:16:3e:3b:8e:f9",
  510. "NetworkInterfaceId": "eni-2ze2bgtgn8187kti5xlk",
  511. "PrivateIpSets": {
  512. "PrivateIpSet": [
  513. {
  514. "PrivateIpAddress": "172.26.246.236",
  515. "Primary": true
  516. }
  517. ]
  518. }
  519. }
  520. ]
  521. },
  522. "SpotPriceLimit": 0,
  523. "DeviceAvailable": true,
  524. "SaleCycle": "",
  525. "InstanceType": "ecs.u1-c1m2.large",
  526. "SpotStrategy": "NoSpot",
  527. "OSNameEn": "Alibaba Cloud Linux 3.2104 LTS 64 bit",
  528. "IoOptimized": true,
  529. "ZoneId": "cn-beijing-g",
  530. "ClusterId": "",
  531. "EcsCapacityReservationAttr": {
  532. "CapacityReservationPreference": "",
  533. "CapacityReservationId": ""
  534. },
  535. "DedicatedHostAttribute": {
  536. "DedicatedHostId": "",
  537. "DedicatedHostName": "",
  538. "DedicatedHostClusterId": ""
  539. },
  540. "GPUAmount": 0,
  541. "OperationLocks": {
  542. "LockReason": []
  543. },
  544. "InternetMaxBandwidthIn": 100,
  545. "Recyclable": false,
  546. "RegionId": "cn-beijing",
  547. "CreditSpecification": ""
  548. }
  549. ]
  550. },
  551. "TotalCount": 1,
  552. "NextToken": "",
  553. "PageSize": 10,
  554. "RequestId": "EE630391-023A-511F-8368-09B48CA876CA",
  555. "PageNumber": 1
  556. } */
  557. }
  558. /// <summary>
  559. /// 查询一个或多个弹性网卡(ENI)的详细信息
  560. /// </summary>
  561. /// <param name="region"></param>
  562. /// <returns></returns>
  563. public DescribeNetworkInterfacesResponse DescribeNetworkInterfaces(string region = "cn-beijing")
  564. {
  565. AlibabaCloud.OpenApiClient.Models.Config config = new()
  566. {
  567. AccessKeyId = _app_key,
  568. AccessKeySecret = _app_secret,
  569. Endpoint = $"ecs.{region}.aliyuncs.com"
  570. };
  571. AlibabaCloud.SDK.Ecs20140526.Client client = new(config);
  572. DescribeNetworkInterfacesRequest describeNetworkInterfacesRequest = new()
  573. {
  574. RegionId = region,
  575. };
  576. AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
  577. try
  578. {
  579. // 复制代码运行请自行打印 API 的返回值
  580. var response = client.DescribeNetworkInterfacesWithOptions(describeNetworkInterfacesRequest, runtime);
  581. return response;
  582. }
  583. catch (Exception _error)
  584. {
  585. TeaException error = new TeaException(new Dictionary<string, object>
  586. {
  587. { "message", _error.Message }
  588. });
  589. // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
  590. // 错误 message
  591. Console.WriteLine(error.Message);
  592. // 诊断地址
  593. Console.WriteLine(error.Data["Recommend"]);
  594. AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
  595. }
  596. return null;
  597. }
  598. }
  599. }