using AlibabaCloud.SDK.Ecs20140526.Models; using AlibabaCloud.SDK.Vpc20160428.Models; using Tea; using TencentCloud.Vpc.V20170312.Models; namespace molilian.core { public partial class AliyunPlus { public AlibabaCloud.SDK.Vpc20160428.Models.DescribeEipAddressesResponse DescribeEipAddresses(string region, string eipAddress) { AlibabaCloud.OpenApiClient.Models.Config config = new() { AccessKeyId = _app_key, AccessKeySecret = _app_secret, Endpoint = $"vpc.{region}.aliyuncs.com" }; AlibabaCloud.SDK.Vpc20160428.Client client = new(config); AlibabaCloud.SDK.Vpc20160428.Models.DescribeEipAddressesRequest describeEipAddressesRequest = new AlibabaCloud.SDK.Vpc20160428.Models.DescribeEipAddressesRequest { PageSize = 100, RegionId = region, EipAddress = eipAddress }; AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions(); try { // 复制代码运行请自行打印 API 的返回值 var response = client.DescribeEipAddressesWithOptions(describeEipAddressesRequest, runtime); return response; } catch (TeaException error) { // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。 // 错误 message Console.WriteLine(error.Message); // 诊断地址 Console.WriteLine(error.Data["Recommend"]); AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message); } catch (Exception _error) { TeaException error = new TeaException(new Dictionary { { "message", _error.Message } }); // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。 // 错误 message Console.WriteLine(error.Message); // 诊断地址 Console.WriteLine(error.Data["Recommend"]); AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message); } return null; } /// /// 申请弹性公网IP /// /// public AlibabaCloud.SDK.Vpc20160428.Models.AllocateEipAddressResponse AllocateEipAddress(string region = "cn-beijing") { AlibabaCloud.OpenApiClient.Models.Config config = new() { AccessKeyId = _app_key, AccessKeySecret = _app_secret, Endpoint = $"vpc.{region}.aliyuncs.com" }; AlibabaCloud.SDK.Vpc20160428.Client client = new(config); AlibabaCloud.SDK.Vpc20160428.Models.AllocateEipAddressRequest allocateEipAddressRequest = new() { RegionId = region, Bandwidth = "200", InternetChargeType = "PayByTraffic" }; AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions(); try { // 复制代码运行请自行打印 API 的返回值 var response = client.AllocateEipAddressWithOptions(allocateEipAddressRequest, runtime); return response; } catch (TeaException error) { // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。 // 错误 message Console.WriteLine(error.Message); // 诊断地址 Console.WriteLine(error.Data["Recommend"]); AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message); } catch (Exception _error) { TeaException error = new TeaException(new Dictionary { { "message", _error.Message } }); // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。 // 错误 message Console.WriteLine(error.Message); // 诊断地址 Console.WriteLine(error.Data["Recommend"]); AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message); } return null; /* { "RequestId": "FB50AF88-3265-5703-82D9-873E4AF09E2C", "ResourceGroupId": "rg-acfm3zsatrtrfmi", "AllocationId": "eip-7xvvmzhi1o193bn52zbag", "EipAddress": "8.134.223.157" } */ } /// /// 将弹性公网IP(EIP)绑定到同地域的云产品实例上 /// /// cn-beijing /// 公网ip的id /// 绑定的对象id,实体id是i-**,弹性网卡是eni-** /// /// 弹性网卡的时候要求私网ip /// public AlibabaCloud.SDK.Vpc20160428.Models.AssociateEipAddressResponse AssociateEipAddress (string region, string allocationId, string instanceId, EIPInstanceType instanceType, string privateIpAddress = "") { AlibabaCloud.OpenApiClient.Models.Config config = new() { AccessKeyId = _app_key, AccessKeySecret = _app_secret, Endpoint = $"vpc.{region}.aliyuncs.com" }; AlibabaCloud.SDK.Vpc20160428.Client client = new(config); AlibabaCloud.SDK.Vpc20160428.Models.AssociateEipAddressRequest associateEipAddressRequest = new() { RegionId = region, AllocationId = allocationId, InstanceId = instanceId, InstanceType = instanceType.ToString(), PrivateIpAddress = privateIpAddress }; AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions(); try { var response = client.AssociateEipAddressWithOptions(associateEipAddressRequest, runtime); return response; } catch (TeaException error) { // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。 // 错误 message Console.WriteLine(error.Message); // 诊断地址 Console.WriteLine(error.Data["Recommend"]); AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message); } catch (Exception _error) { TeaException error = new TeaException(new Dictionary { { "message", _error.Message } }); // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。 // 错误 message Console.WriteLine(error.Message); // 诊断地址 Console.WriteLine(error.Data["Recommend"]); AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message); } return null; /* { "RequestId": "9109C976-D26D-5856-8440-DC42E8820399" } */ } /// /// 将弹性公网IP(EIP)从绑定的云产品上解绑 /// /// /// /// public AlibabaCloud.SDK.Vpc20160428.Models.UnassociateEipAddressResponse UnassociateEipAddress(string region, string allocationId) { AlibabaCloud.OpenApiClient.Models.Config config = new() { AccessKeyId = _app_key, AccessKeySecret = _app_secret, Endpoint = $"vpc.{region}.aliyuncs.com" }; AlibabaCloud.SDK.Vpc20160428.Client client = new(config); AlibabaCloud.SDK.Vpc20160428.Models.UnassociateEipAddressRequest unassociateEipAddressRequest = new() { RegionId = region, AllocationId = allocationId, }; AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions(); try { var response = client.UnassociateEipAddressWithOptions(unassociateEipAddressRequest, runtime); return response; } catch (TeaException error) { // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。 // 错误 message Console.WriteLine(error.Message); // 诊断地址 Console.WriteLine(error.Data["Recommend"]); AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message); } catch (Exception _error) { TeaException error = new TeaException(new Dictionary { { "message", _error.Message } }); // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。 // 错误 message Console.WriteLine(error.Message); // 诊断地址 Console.WriteLine(error.Data["Recommend"]); AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message); } return null; /* { "RequestId": "9109C976-D26D-5856-8440-DC42E8820399" } */ } /// /// 释放指定的弹性公网IP(EIP) /// /// /// /// public AlibabaCloud.SDK.Vpc20160428.Models.ReleaseEipAddressResponse ReleaseEipAddress(string region, string allocationId) { AlibabaCloud.OpenApiClient.Models.Config config = new() { AccessKeyId = _app_key, AccessKeySecret = _app_secret, Endpoint = $"vpc.{region}.aliyuncs.com" }; AlibabaCloud.SDK.Vpc20160428.Client client = new(config); AlibabaCloud.SDK.Vpc20160428.Models.ReleaseEipAddressRequest releaseEipAddressRequest = new() { RegionId = region, AllocationId = allocationId, }; AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions(); try { var response = client.ReleaseEipAddressWithOptions(releaseEipAddressRequest, runtime); return response; } catch (TeaException error) { // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。 // 错误 message Console.WriteLine(error.Message); // 诊断地址 Console.WriteLine(error.Data["Recommend"]); AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message); } catch (Exception _error) { TeaException error = new TeaException(new Dictionary { { "message", _error.Message } }); // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。 // 错误 message Console.WriteLine(error.Message); // 诊断地址 Console.WriteLine(error.Data["Recommend"]); AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message); } return null; /* { "RequestId": "9109C976-D26D-5856-8440-DC42E8820399" } */ } } }