private void QueryInstanceCvm() { try { Credential cred = new Credential { SecretId = SecretIDBox.Text, SecretKey = SecretKeyBox.Text }; ClientProfile clientProfile = new ClientProfile(); HttpProfile httpProfile = new HttpProfile(); httpProfile.Endpoint = ("cvm.tencentcloudapi.com"); clientProfile.HttpProfile = httpProfile; TencentCloud.Cvm.V20170312.CvmClient client = new TencentCloud.Cvm.V20170312.CvmClient(cred, RegionList[RegionBox.SelectedIndex].Region, clientProfile); TencentCloud.Cvm.V20170312.Models.DescribeInstancesRequest req = new TencentCloud.Cvm.V20170312.Models.DescribeInstancesRequest(); TencentCloud.Cvm.V20170312.Models.DescribeInstancesResponse resp = client.DescribeInstancesSync(req); foreach (TencentCloud.Cvm.V20170312.Models.Instance i in resp.InstanceSet) { CvmInstanceList.Add(i); } } catch (Exception e) { SOLMain.WriteLogline("查询Cvm实例时抛出异常:" + e.Message, SOLMain.LogLevel.Error); } }
private void QueryRegion() { try { Credential cred = new Credential { SecretId = PrimaryKey.SecretID, SecretKey = PrimaryKey.SecretKey }; ClientProfile clientProfile = new ClientProfile(); HttpProfile httpProfile = new HttpProfile(); httpProfile.Endpoint = ("cvm.tencentcloudapi.com"); clientProfile.HttpProfile = httpProfile; TencentCloud.Cvm.V20170312.CvmClient client = new TencentCloud.Cvm.V20170312.CvmClient(cred, "", clientProfile); TencentCloud.Cvm.V20170312.Models.DescribeRegionsRequest req = new TencentCloud.Cvm.V20170312.Models.DescribeRegionsRequest(); TencentCloud.Cvm.V20170312.Models.DescribeRegionsResponse resp = client.DescribeRegionsSync(req); RegionList.Clear(); foreach (TencentCloud.Cvm.V20170312.Models.RegionInfo i in resp.RegionSet) { RegionList.Add(i); } RegionInfoWrite(); UpdateRegionBox(); } catch (Exception e) { SOLMain.WriteLogline(e.Message, SOLMain.LogLevel.Error); } }