/// <summary> /// 支付订单 /// </summary> /// <param name="q"></param> /// <param name="r"></param> /// <param name="ownerUin">订单拥有者uin</param> /// <param name="agentPay">代付标志,1:代付;0:自付</param> /// <param name="dealNames">订单号数组</param> /// <returns></returns> public static PayOrderReturn PayOrder( QCloudHelper q, Region r, int ownerUin, int agentPay, List <string> dealNames) { var baseParams = new SortedDictionary <string, object>(StringComparer.Ordinal) { { "ownerUin", ownerUin }, { "agentPay", agentPay } }; if (dealNames != null) { for (int i = 0; i < dealNames.Count; i++) { baseParams.Add($"dealNames.{i}", dealNames[i]); } } var returnJson = q.RequestAPi("PayDealsNew", baseParams, APIUrl.Pay, r); return(JsonConvert.DeserializeObject <PayOrderReturn>(returnJson)); }
/// <summary> /// 重置 CVM 实例密码 /// </summary> /// <param name="q"></param> /// <param name="region"></param> /// <param name="instanceIds"></param> /// <param name="password"></param> /// <returns></returns> public static BaseCvmOperationResponseType ResetCVMPassword(QCloudHelper q, Region region, List <string> instanceIds, string password, string username = null, bool forceStop = false) { var baseParams = new SortedDictionary <string, object>(StringComparer.Ordinal) { { "Version", "2017-03-12" }, { "password", password }, { "ForceStop", forceStop } }; if (!string.IsNullOrWhiteSpace(username)) { baseParams.Add("UserName", username); } if (instanceIds != null) { for (int i = 0; i < instanceIds.Count; i++) { baseParams.Add($"instanceIds.{i}", instanceIds[i]); } } var returnJson = q.RequestAPi("ResetInstancePassword", baseParams, APIUrl.Cvm, region); return(JsonConvert.DeserializeObject <BaseCvmOperationResponseType>(returnJson)); }
/// <summary> /// CVM 启动/关闭/重启 基础调用方法 /// </summary> /// <param name="q"></param> /// <param name="actionList"></param> /// <param name="cvmList"></param> /// <param name="region"></param> /// <returns></returns> public static BaseCvmOperationReturnType BaseCvmOperation(QCloudHelper q, string actionList, List <string> cvmList, Region region, SortedDictionary <string, object> orderParams = null) { var baseParams = new SortedDictionary <string, object>(StringComparer.Ordinal) { { "Version", "2017-03-12" } }; if (cvmList != null) { for (int i = 0; i < cvmList.Count; i++) { baseParams.Add($"InstanceIds.{i}", cvmList[i]); } } // 添加其他参数,用于传递强制重启或强制关机 if (orderParams != null && orderParams.Count > 0) { foreach (var item in orderParams) { if (baseParams.ContainsKey(item.Key)) { baseParams[item.Key] = item.Value; } else { baseParams.Add(item.Key, item.Value); } } } var returnJson = q.RequestAPi(actionList, baseParams, APIUrl.Cvm, region); return(JsonConvert.DeserializeObject <BaseCvmOperationReturnType>(returnJson)); }
/// <summary> /// 获取订单信息 /// </summary> /// <param name="q"></param> /// <param name="r"></param> /// <param name="startTime">开始时间</param> /// <param name="endTime">结束时间</param> /// <param name="page">第多少页,从0开始,默认是0</param> /// <param name="pageSize">一页多少条数据,默认是20条</param> /// <param name="status"></param> /// <param name="dealId">订单ID</param> /// <returns></returns> public static PayOrderDescribeDealsByCondRetrunType PayOrderDescribeDealsByCond( QCloudHelper q, Region r, string startTime, string endTime, int page = 0, int pageSize = 20, PayOrderDescribeDealsByCondStatus status = PayOrderDescribeDealsByCondStatus.已发货, int?dealId = null) { var baseParams = new SortedDictionary <string, object>(StringComparer.Ordinal) { { "startTime", startTime }, { "endTime", endTime }, { "page", page }, { "pageSize", pageSize }, { "status", (int)status } }; if (dealId != null) { baseParams.Add("dealId", dealId); } var returnJson = q.RequestAPi("DescribeDealsByCond", baseParams, APIUrl.Trade, r); return(JsonConvert.DeserializeObject <PayOrderDescribeDealsByCondRetrunType>(returnJson)); }
/// <summary> /// 查询客户订单 /// https://cloud.tencent.com/document/product/563/8070 /// </summary> /// <param name="q"></param> /// <param name="r"></param> /// <param name="creatTimeRangeStart">下单时间范围起始,格式为2016-11-11 00:00:00</param> /// <param name="creatTimeRangeEnd">下单时间范围结束,格式为2016-11-11 00:00:00</param> /// <param name="page">分页号,从0开始</param> /// <param name="rows">页码大小,最大值为30</param> /// <param name="order">页码大小,最大值为30</param> /// <param name="status">订单的状态</param> /// <param name="ownerUin">下单人uin</param> /// <param name="payerMode">支付方式,0:自付;1:代付</param> /// <returns></returns> public static PayOrderQueryReturnType PayOrderQuery( QCloudHelper q, Region r, string creatTimeRangeStart = null, string creatTimeRangeEnd = null, int?page = null, int?rows = null, int?order = null, PayStatus?status = null, int?ownerUin = null, int?payerMode = null ) { var baseParams = new SortedDictionary <string, object>(StringComparer.Ordinal); if (creatTimeRangeStart != null) { baseParams.Add("creatTimeRangeStart", creatTimeRangeStart); } if (creatTimeRangeEnd != null) { baseParams.Add("creatTimeRangeEnd", creatTimeRangeEnd); } if (page != null) { baseParams.Add("page", page); } if (rows != null) { baseParams.Add("rows", rows); } if (status != null) { baseParams.Add("status", status.Value); } if (ownerUin != null) { baseParams.Add("ownerUin", ownerUin); } if (payerMode != null) { baseParams.Add("payerMode", payerMode); } var returnJson = q.RequestAPi("QueryClientDeals", baseParams, APIUrl.Pay, r); return(JsonConvert.DeserializeObject <PayOrderQueryReturnType>(returnJson)); }
/// <summary> /// 查询CDB实例初始化状态 /// </summary> /// <param name="q"></param> /// <param name="r"></param> /// <param name="jobId">任务ID</param> /// <returns></returns> public static CDBInitInfoRetrunType CDBInitialization(QCloudHelper q, Region r, int jobId) { var baseParams = new SortedDictionary <string, object>(StringComparer.Ordinal) { { "jobId", jobId } }; var returnJson = q.RequestAPi("GetCdbInitInfo", baseParams, APIUrl.Cdb, r); return(JsonConvert.DeserializeObject <CDBInitInfoRetrunType>(returnJson)); }
/// <summary> /// CDB续费 /// </summary> /// <param name="q"></param> /// <param name="r"></param> /// <param name="cdbInstanceId">实例ID</param> /// <param name="period">续费时长,单位:月,最小值1,最大值为36</param> /// <returns></returns> public static CDBDealReturnType CDBRenew(QCloudHelper q, Region r, string cdbInstanceId, int period) { var baseParams = new SortedDictionary <string, object>(StringComparer.Ordinal) { { "cdbInstanceId", cdbInstanceId }, { "period", period } }; var returnJson = q.RequestAPi("RenewCdb", baseParams, APIUrl.Cdb, r); return(JsonConvert.DeserializeObject <CDBDealReturnType>(returnJson)); }
/// <summary> /// 升级数据库引擎版本 /// </summary> /// <param name="q"></param> /// <param name="r"></param> /// <param name="cdbInstanceId">实例ID,格式如:cdb-c1nl9rpv。与云数据库控制台页面中显示的实例ID相同,可使用查询实例列表 接口获取,其值为输出参数中字段 uInstanceId 的值。</param> /// <param name="engineVersion">MySQL版本,值包括:5.5和5.6</param> /// <returns></returns> public static CDBUpgradeReturnType CDBUpgradeEngineVersion(QCloudHelper q, Region r, string cdbInstanceId, string engineVersion) { var baseParams = new SortedDictionary <string, object>(StringComparer.Ordinal) { { "cdbInstanceId", cdbInstanceId }, { "engineVersion", engineVersion } }; var returnJson = q.RequestAPi("UpgradeCdbEngineVersion", baseParams, APIUrl.Cdb, r); return(JsonConvert.DeserializeObject <CDBUpgradeReturnType>(returnJson)); }
/// <summary> /// 监控请求基础类 /// </summary> /// <param name="q"></param> /// <param name="qCloudNamespace"></param> /// <param name="metricName"></param> /// <param name="dimensions"></param> /// <param name="c"></param> /// <param name="startTime"></param> /// <param name="endTime"></param> /// <param name="p"></param> /// <param name="multiObjectPull"></param> /// <param name="dimensionsMulti"></param> /// <returns></returns> public static dynamic BaseMonitor(QCloudHelper q, string qCloudNamespace, string metricName, Dictionary <string, string> dimensions, Region c, DateTime startTime, DateTime endTime, Period p = Period.FiveMinute, bool multiObjectPull = false, List <Dictionary <string, string> > dimensionsMulti = null) { var baseParams = new SortedDictionary <string, object>(StringComparer.Ordinal) { ["namespace"] = qCloudNamespace, ["metricName"] = metricName, ["period"] = (int)p, ["startTime"] = startTime.DateTimeConvertQCloudFormat(), ["endTime"] = endTime.DateTimeConvertQCloudFormat() }; // 拉取单个对象 if (multiObjectPull == false && dimensions != null && dimensions.Count > 0) { int count = 0; foreach (var dimensionsKey in dimensions.Keys) { baseParams.Add($"dimensions.{count}.name", dimensionsKey); baseParams.Add($"dimensions.{count}.value", dimensions[dimensionsKey]); count++; } } // 批量拉取多个对象 else if (multiObjectPull && dimensionsMulti != null && dimensionsMulti.Count > 0) { int batchCount = 0; foreach (var dimensionsDict in dimensionsMulti) { int count = 0; foreach (var dimensionsKey in dimensionsDict.Keys) { baseParams.Add($"batch.{batchCount}.dimensions.{count}.name", dimensionsKey); baseParams.Add($"batch.{batchCount}.dimensions.{count}.value", dimensionsDict[dimensionsKey]); count++; } batchCount++; } } var returnJson = q.RequestAPi("GetMonitorData", baseParams, APIUrl.Monitor, c); if (multiObjectPull) { return(JsonConvert.DeserializeObject <MultiMonitorType>(returnJson)); } else { return(JsonConvert.DeserializeObject <MonitorType>(returnJson)); } }
/// <summary> /// 查询实例列表 输入参数 /// </summary> /// <param name="q"></param> /// <param name="projectId">项目ID,请使用查询项目列表接口查询项目ID</param> /// <param name="status">实例状态,默认值为1,一个或者多个状态值,n表示从0开始的数组下标,值包括: 0-创建中 1-运行中 4-删除中 5-隔离中</param> /// <param name="cdbInstanceIds">一个或者多个实例ID,格式如:cdb-c1nl9rpv。与云数据库控制台页面中显示的实例ID相同,可使用查询实例列表 接口获取,其值为输出参数中字段 uInstanceId 的值。</param> /// <param name="cdbInstanceVips">一个或者多个实例访问地址,n表示从0开始的数组下标。请使用查询实例列表接口查询云数据库实例访问地址</param> /// <param name="offset">记录偏移量,默认值为0</param> /// <param name="limit">单次请求返回的数量,默认值为20,最大值为100</param> /// <returns></returns> public static CDBListRetrunType CDBInstanceList( QCloudHelper q, Region r, int?projectId = null, List <int> status = null, List <string> cdbInstanceIds = null, List <string> cdbInstanceVips = null, int offset = 0, int limit = 20 ) { var baseParams = new SortedDictionary <string, object>(StringComparer.Ordinal) { { "offset", offset }, { "limit", limit } }; if (projectId != null) { baseParams.Add("projectId", projectId); } if (cdbInstanceIds != null) { for (int i = 0; i < cdbInstanceIds.Count; i++) { baseParams.Add($"cdbInstanceIds.{i}", cdbInstanceIds[i]); } } if (cdbInstanceVips != null) { for (int i = 0; i < cdbInstanceVips.Count; i++) { baseParams.Add($"cdbInstanceVips.{i}", cdbInstanceVips[i]); } } if (status != null) { for (int i = 0; i < status.Count; i++) { baseParams.Add($"status.{i}", status[i]); } } var returnJson = q.RequestAPi("DescribeCdbInstances", baseParams, APIUrl.Cdb, r); return(JsonConvert.DeserializeObject <CDBListRetrunType>(returnJson)); }
/// <summary> /// 升级CDB 实例 /// </summary> /// <param name="q"></param> /// <param name="r"></param> /// <param name="cdbInstanceId">实例ID,格式如:cdb-c1nl9rpv。与云数据库控制台页面中显示的实例ID相同,可使用查询实例列表 接口获取,其值为输出参数中字段 uInstanceId 的值。</param> /// <param name="memory">升级后的内存大小,单位:MB,为保证传入 memory 值有效,请使用查询可创建规格(支持可用区、配置自定义)接口获取可升级的内存规格。</param> /// <param name="volume">升级后的硬盘大小,单位:GB,为保证传入 volume 值有效,请使用查询可创建规格(支持可用区、配置自定义)接口获取可升级的硬盘范围。</param> /// <param name="instanceRole">实例类型,默认为master,支持值包括:master-表示主实例、灾备实例和ro-表示只读实例。</param> /// <param name="protectMode">数据复制方式,默认为0,支持值包括:0-表示异步复制,1-表示半同步复制,2-表示强同步复制,升级主实例时可指定该参数,升级只读实例或者灾备实例时指定该参数无意义</param> /// <param name="deployMode">多可用区域,默认为0,支持值包括:0-表示单可用区,1-表示多可用区,升级主实例时可指定该参数,升级只读实例或者灾备实例时指定该参数无意义</param> /// <param name="slaveZoneFirst">备库1的可用区ID,默认为zoneId的值,升级主实例时可指定该参数,升级只读实例或者灾备实例时指定该参数无意义</param> /// <param name="slaveZoneSecond">备库2的可用区ID,默认为0,升级主实例时可指定该参数,升级只读实例或者灾备实例时指定该参数无意义</param> /// <returns></returns> public static CDBUpgradeReturnType CDBUpgrade( QCloudHelper q, Region r, string cdbInstanceId, int memory, int volume, string instanceRole = "master", int protectMode = 0, int deployMode = 0, int?slaveZoneFirst = null, int slaveZoneSecond = 0 ) { var baseParams = new SortedDictionary <string, object>(StringComparer.Ordinal) { { "cdbInstanceId", cdbInstanceId }, { "memory", memory }, { "volume", volume } }; if (instanceRole != "master" && !string.IsNullOrWhiteSpace(instanceRole)) { baseParams.Add("instanceRole", instanceRole); } if (protectMode != 0) { baseParams.Add("protectMode", protectMode); } if (deployMode != 0) { baseParams.Add("deployMode", deployMode); } if (slaveZoneFirst != null) { baseParams.Add("slaveZoneFirst", slaveZoneFirst); } if (slaveZoneSecond != 0) { baseParams.Add("slaveZoneSecond", slaveZoneSecond); } var returnJson = q.RequestAPi("UpgradeCdb", baseParams, APIUrl.Cdb, r); return(JsonConvert.DeserializeObject <CDBUpgradeReturnType>(returnJson)); }
/// <summary> /// 重装CVM /// </summary> /// <param name="q"></param> /// <param name="instanceId"></param> /// <param name="region">区域</param> /// <param name="imageType">镜像类型。1:私有镜像2:公有镜像3:镜像市场4:共享镜像。默认为2。需与imageId同时指定。</param> /// <param name="imageId">镜像ID。</param> /// <param name="password">实例密码</param> /// <param name="needSecurityAgent">安装安全Agent,0:不安装,1:安装,默认安装</param> /// <param name="needMonitorAgent">安装监控Agent,0:不安装,1:安装,默认安装</param> /// <param name="rootSize">系统盘大小(GB)。rootSize默认保持不变</param> /// <returns></returns> public static BaseCvmOperationResponseType ReInstallCVM( QCloudHelper q, string instanceId, Region region, int imageType = 2, string imageId = null, CVMDiskType SystemDisk = null, CVMLoginSettingsType LoginSettings = null, CVMEnhancedServiceType EnhancedService = null) { var baseParams = new SortedDictionary <string, object>(StringComparer.Ordinal) { { "Version", "2017-03-12" }, { "InstanceId", instanceId } }; if (imageType != 2) { baseParams.Add("imageType", imageType); } if (!string.IsNullOrWhiteSpace(imageId)) { baseParams.Add("imageId", imageId); } // 实例系统盘配置 if (SystemDisk != null) { baseParams.Add("SystemDisk", SystemDisk); } // 实例登录设置 if (LoginSettings != null) { baseParams.Add("LoginSettings", LoginSettings); } // 增强服务 if (EnhancedService != null) { baseParams.Add("EnhancedService", EnhancedService); } var returnJson = q.RequestAPi("ResetInstances", baseParams, APIUrl.Cvm, region); return(JsonConvert.DeserializeObject <BaseCvmOperationResponseType>(returnJson)); }
/// <summary> /// 获取高防 IP 转发规则 /// </summary> /// <param name="q"></param> /// <param name="r"></param> /// <param name="paging_index">页面索引,0表示第一页</param> /// <param name="paging_count">每页返回详情数</param> /// <param name="bgpId">BGP高防IP的资源ID</param> /// <returns></returns> public static BGPIPGetTransRulesReturnType BGPIPGetTransRules( QCloudHelper q, Region r, int paging_index, int paging_count, string bgpId) { var baseParams = new SortedDictionary <string, object>(StringComparer.Ordinal) { { "paging.index", paging_index }, { "paging.count", paging_count }, { "bgpId", bgpId } }; var returnJson = q.RequestAPi("NS.BGPIP.ServicePack.GetTransRules", baseParams, APIUrl.Sec, r); return(JsonConvert.DeserializeObject <BGPIPGetTransRulesReturnType>(returnJson)); }
/// <summary> /// 退还实例 /// </summary> /// <param name="q"></param> /// <param name="region"></param> /// <param name="instanceId"></param> /// <returns></returns> public static BaseCvmOperationResponseType TerminateCVM(QCloudHelper q, Region region, List <string> instanceId) { var baseParams = new SortedDictionary <string, object>(StringComparer.Ordinal) { { "Version", "2017-03-12" } }; if (instanceId != null) { for (int i = 0; i < instanceId.Count; i++) { baseParams.Add($"InstanceIds.{i}", instanceId[i]); } } var returnJson = q.RequestAPi("TerminateInstances", baseParams, APIUrl.Cvm, region); return(JsonConvert.DeserializeObject <BaseCvmOperationResponseType>(returnJson)); }
/// <summary> /// 获取高防 IP 列表 /// </summary> /// <param name="q"></param> /// <param name="r"></param> /// <param name="paging_index">页面索引,0表示第一页</param> /// <param name="paging_count">每页返回详情数</param> /// <param name="region">高防IP的地域,目前有三个地区 gz:广州 sh:上海 bj:北京</param> /// <param name="filtering_name">以高防IP的名称进行关键字查询,支持模糊搜索</param> /// <param name="filtering_ip"> 以高防IP进行关键字查询,支持模糊搜索</param> /// <param name="sorting_field">取值范围: bandwidth/ overloadCount,bandwidth表示以带宽进行排序, overloadCount表示以超峰次数进行排序</param> /// <param name="sorting_order">取值范围:asc / desc,asc表示升序排列,desc表示降序排列</param> /// <returns></returns> public static BGPIPGetListReturnType BGPIPGetList( QCloudHelper q, Region r, int paging_index, int paging_count, string region, string filtering_name = null, string filtering_ip = null, string sorting_field = null, string sorting_order = null) { var baseParams = new SortedDictionary <string, object>(StringComparer.Ordinal) { { "paging.index", paging_index }, { "paging.count", paging_count }, { "region", region } }; if (filtering_name != null) { baseParams.Add("filtering.name", filtering_name); } if (filtering_ip != null) { baseParams.Add("filtering.ip", filtering_ip); } if (sorting_field != null) { baseParams.Add("sorting.field", sorting_field); } if (sorting_order != null) { baseParams.Add("sorting.order", sorting_order); } var returnJson = q.RequestAPi("NS.BGPIP.GetServicePacks", baseParams, APIUrl.Sec, r); return(JsonConvert.DeserializeObject <BGPIPGetListReturnType>(returnJson)); }
/// <summary> /// 查询账单详情 /// </summary> /// <param name="q"></param> /// <param name="r"></param> /// <param name="billId">账单ID</param> /// <param name="startDate">账单的开始时间,可以填写账单的创建时间</param> /// <param name="endDate">账单的结束时间</param> /// <param name="billType">账单的类型</param> /// <returns></returns> public static PayDescribeBillDetailRetrunType PayOrderDescribeBillDetailQuery( QCloudHelper q, Region r, string billId, string startDate, string endDate, int billType) { var baseParams = new SortedDictionary <string, object>(StringComparer.Ordinal) { { "billId", billId }, { "startDate", startDate }, { "endDate", endDate }, { "billType", billType } }; var returnJson = q.RequestAPi("DescribeBillDetail", baseParams, APIUrl.Bill, r); return(JsonConvert.DeserializeObject <PayDescribeBillDetailRetrunType>(returnJson)); }
/// <summary> /// 查看CVM实例状态列表 /// </summary> /// <param name="q"></param> /// <param name="region"></param> /// <param name="instanceId"></param> /// <returns></returns> public static CVMStatusReturnType StatusOfCVM(QCloudHelper q, Region region, List <string> instanceId, int Offset = 0, int Limit = 20) { var baseParams = new SortedDictionary <string, object>(StringComparer.Ordinal) { { "Version", "2017-03-12" }, { "Offset", Offset }, { "Limit", Limit } }; if (instanceId != null) { for (int i = 0; i < instanceId.Count; i++) { baseParams.Add($"InstanceIds.{i}", instanceId[i]); } } var returnJson = q.RequestAPi("DescribeInstancesStatus", baseParams, APIUrl.Cvm, region); return(JsonConvert.DeserializeObject <CVMStatusReturnType>(returnJson)); }
/// <summary> /// CDB 实例初始化 /// </summary> /// <param name="q"></param> /// <param name="r"></param> /// <param name="cdbInstanceId">实例ID,格式如:cdb-c1nl9rpv。与云数据库控制台页面中显示的实例ID相同,可使用查询实例列表 接口获取,其值为输出参数中字段 uInstanceId 的值。</param> /// <param name="charset">字符集,支持字符集:[ latin1、utf8、gbk、utf8mb4 ]</param> /// <param name="port">自定义端口,端口支持范围:[ 1024-65535 ]</param> /// <param name="lowerCaseTableNames">表名是否只存储为小写,可能返回值:1-表名存储为小写; 0-表名大小写敏感</param> /// <param name="password">设置root帐号密码,密码规则:8-16个字符,至少包含字母、数字、字符(支持的字符:!@#$%^*())中的两种</param> /// <returns></returns> public static CDBInitializationReturnType CDBInitialization( QCloudHelper q, Region r, string cdbInstanceId, string charset, int port, int lowerCaseTableNames, string password ) { var baseParams = new SortedDictionary <string, object>(StringComparer.Ordinal) { { "cdbInstanceId", cdbInstanceId }, { "charset", charset }, { "port", port }, { "lowerCaseTableNames", lowerCaseTableNames }, { "password", password } }; var returnJson = q.RequestAPi("CdbMysqlInit", baseParams, APIUrl.Cdb, r); return(JsonConvert.DeserializeObject <CDBInitializationReturnType>(returnJson)); }
/// <summary> /// 查询账单列表 /// </summary> /// <param name="q"></param> /// <param name="r"></param> /// <param name="startDate">开始时间,默认为今天</param> /// <param name="endDate">结束时间时间,默认为今天</param> /// <param name="offset">偏移量,默认为0</param> /// <param name="limit">默认为20,最大100</param> /// <param name="projectId">项目ID,默认为0表示默认项目</param> /// <param name="orderType">0为正序,1为倒序</param> /// <returns></returns> public static PayDescribBillsRetrunType PayOrderDescribeBillsQuery( QCloudHelper q, Region r, string startDate = null, string endDate = null, int offset = 0, int limit = 20, int projectId = 0, int?orderType = null) { var baseParams = new SortedDictionary <string, object>(StringComparer.Ordinal) { { "offset", offset }, { "limit", limit }, { "projectId", projectId } }; if (startDate != null) { baseParams.Add("startDate", startDate); } if (endDate != null) { baseParams.Add("endDate", endDate); } if (orderType != null) { baseParams.Add("orderType", orderType); } var returnJson = q.RequestAPi("DescribeBills", baseParams, APIUrl.Bill, r); return(JsonConvert.DeserializeObject <PayDescribBillsRetrunType>(returnJson)); }
/// <summary> /// Redis 实例获取 /// </summary> /// <param name="q"></param> /// <param name="limit">分页大小</param> /// <param name="offset">当前页码</param> /// <param name="redisId">实例Id</param> /// <param name="redisName">实例名称</param> /// <param name="orderBy">枚举范围redisId,projectId,createtime</param> /// <param name="orderType">1倒序,0顺序,默认倒序</param> /// <param name="vpcIds">历史原因,仍保留该参数,推荐使用下面参数unVpcIds。 私有网络ID数组,数组下标从0开始,如果不传则默认选择基础网络。</param> /// <param name="unVpcIds">私有网络ID数组,数组下标从0开始,如果不传则默认选择基础网络。请使用私有网络列表 查询返回的unVpcId为准,如:vpc-kd7d06of</param> /// <param name="subnetIds">历史原因,仍保留该参数,推荐使用下面参数unSubnetIds。私有网络下的子网ID数组,数组下标从0开始</param> /// <param name="unSubnetIds">子网ID数组,数组下标从0开始。 vpc子网下,取值以查询查询子网列表 返回的unSubnetId为准,如:subnet-3lzrkspo</param> /// <param name="projectIds">项目ID 组成的数组,数组下标从0开始</param> /// <returns></returns> public static RedisListRetrunType RedisInstanceList( QCloudHelper q, int limit, int offset, string redisId = null, string redisName = null, string orderBy = null, int?orderType = null, List <int?> vpcIds = null, List <int?> unVpcIds = null, List <int?> subnetIds = null, List <int?> unSubnetIds = null, List <int?> projectIds = null) { var baseParams = new SortedDictionary <string, object>(StringComparer.Ordinal) { { "offset", offset }, { "limit", limit } }; if (redisId != null) { baseParams.Add("redisId", redisId); } if (redisName != null) { baseParams.Add("redisName", redisName); } if (orderBy != null) { baseParams.Add("orderBy", orderBy); } if (orderType != null) { baseParams.Add("orderType", orderType); } if (vpcIds != null) { for (int i = 0; i < vpcIds.Count; i++) { baseParams.Add($"vpcIds.{i}", vpcIds[i]); } } if (unVpcIds != null) { for (int i = 0; i < unVpcIds.Count; i++) { baseParams.Add($"unVpcIds.{i}", unVpcIds[i]); } } if (subnetIds != null) { for (int i = 0; i < subnetIds.Count; i++) { baseParams.Add($"subnetIds.{i}", subnetIds[i]); } } if (unSubnetIds != null) { for (int i = 0; i < unSubnetIds.Count; i++) { baseParams.Add($"unSubnetIds.{i}", unSubnetIds[i]); } } if (projectIds != null) { for (int i = 0; i < projectIds.Count; i++) { baseParams.Add($"projectIds.{i}", projectIds[i]); } } var returnJson = q.RequestAPi("DescribeRedis", baseParams, APIUrl.Redis); return(JsonConvert.DeserializeObject <RedisListRetrunType>(returnJson)); }
/// <summary> /// 创建实例 (包年包月) /// </summary> /// <param name="q"></param> /// <param name="r"></param> /// <param name="cdbType">实例规格,支持固定规格和自定义规格/传 CUSTOM 代表自定义规格固定规格类型将会下线,推荐使用自定义规格</param> /// <param name="engineVersion">MySQL版本 默认5.5</param> /// <param name="period">实例时长,单位:月,最小值1,最大值为36</param> /// <param name="goodsNum">实例数量,默认值为1, 最小值1,最大值为10</param> /// <param name="vpcId">私有网络ID,如果不传则默认选择基础网络</param> /// <param name="subnetId">私有网络下的子网ID,如果设置了 vpcId,则 subnetId 必填</param> /// <param name="projectId">项目ID,不填为默认项目</param> /// <param name="memory">实例内存大小,单位:MB,当 cdbType 值为 CUSTOM 时, memory 为必填</param> /// <param name="volume">实例硬盘大小,单位:GB,当 cdbType 值为 CUSTOM 时, volume 为必填</param> /// <param name="zoneId">可用区ID,该参数缺省时,系统会自动选择一个可用区</param> /// <param name="port">自定义端口,端口支持范围:[ 1024-65535 ]</param> /// <param name="password">设置root帐号密码,密码规则:8-16个字符,至少包含字母、数字、字符(支持的字符:!@#$%^*())中的两种,购买主实例时可指定该参数,购买只读实例或者灾备实例时指定该参数无意义</param> /// <param name="instanceRole">实例类型,默认为 master,支持值包括:master-表示主实例,ro-表示只读实例</param> /// <param name="cdbInstanceId">实例ID,购买只读实例时必填,该字段表示只读实例的主实例ID,请使用查询实例列表接口查询云数据库实例ID</param> /// <param name="protectMode">数据复制方式,默认为0,支持值包括:0-表示异步复制,1-表示半同步复制,2-表示强同步复制</param> /// <param name="deployMode">多可用区域,默认为0,支持值包括:0-表示单可用区,1-表示多可用区</param> /// <param name="slaveZoneFirst">备库1的可用区ID,默认为zoneId的值</param> /// <param name="slaveZoneSecond">备库2的可用区ID,默认为0</param> /// <param name="paramList">其中paramList为修改实例的参数列表.其中 Key 为待修改参数的名,value 为待修改参数的值</param> /// <returns></returns> public static CDBDealReturnType CDBCreate( QCloudHelper q, Region r, string cdbType = "CUSTOM", string engineVersion = "5.5", int?period = null, int?goodsNum = null, string vpcId = null, string subnetId = null, int?projectId = null, int?memory = null, int?volume = null, int?zoneId = null, int?port = null, string password = null, string instanceRole = null, string cdbInstanceId = null, int protectMode = 0, int deployMode = 0, int?slaveZoneFirst = null, int slaveZoneSecond = 0, Dictionary <string, string> paramList = null ) { var baseParams = new SortedDictionary <string, object>(StringComparer.Ordinal) { { "cdbType", cdbType }, { "engineVersion", engineVersion } }; if (period != null) { baseParams.Add("period", period); } if (goodsNum != null) { baseParams.Add("goodsNum", goodsNum); } if (vpcId != null) { baseParams.Add("vpcId", vpcId); } if (subnetId != null) { baseParams.Add("subnetId", subnetId); } if (projectId != null) { baseParams.Add("projectId", projectId); } if (memory != null) { baseParams.Add("memory", memory); } if (volume != null) { baseParams.Add("volume", volume); } if (zoneId != null) { baseParams.Add("zoneId", zoneId); } if (port != null) { baseParams.Add("port", port); } if (password != null) { baseParams.Add("password", password); } if (instanceRole != null) { baseParams.Add("instanceRole", instanceRole); } if (cdbInstanceId != null) { baseParams.Add("cdbInstanceId", cdbInstanceId); } if (protectMode != 0) { baseParams.Add("protectMode", protectMode); } if (deployMode != 0) { baseParams.Add("deployMode", deployMode); } if (slaveZoneFirst != null) { baseParams.Add("slaveZoneFirst", slaveZoneFirst); } if (slaveZoneSecond != 0) { baseParams.Add("slaveZoneSecond", slaveZoneSecond); } if (paramList != null) { int count = 0; foreach (var paramListKey in paramList.Keys) { baseParams.Add($"paramList.{count}.name", paramListKey); baseParams.Add($"paramList.{count}.value", paramList[paramListKey]); } } var returnJson = q.RequestAPi("RenewCdb", baseParams, APIUrl.Cdb, r); return(JsonConvert.DeserializeObject <CDBDealReturnType>(returnJson)); }
/// <summary> /// 获取CVM列表 /// </summary> /// <param name="q"></param> /// <param name="r">区域 默认为上海区域(兼容以前程序)</param> /// <param name="cvmList">(过滤条件)按照一个或者多个实例ID过滤</param> /// <param name="lanIpsList">(过滤条件)按照一个或者多个实例的内网IP或公网IP(包括实例创建时自动分配的IP和弹性IP)过滤(此接口支持同时传入多个IP。此参数的具体格式可参考API简介的id.n一节)。</param> /// <param name="searchWord">(过滤条件)按照实例名称过滤,支持模糊查询。</param> /// <param name="status">(过滤条件)实例的状态,状态的列举见上。</param> /// <param name="projectId">(过滤条件)项目ID。</param> /// <param name="zoneId">(过滤条件)可用区ID。</param> /// <param name="offset">偏移量,默认为0</param> /// <param name="limit">返回数量默认 20,最大值 100</param> /// <returns></returns> public static CvmListReturnType GetCVMList( QCloudHelper q, Region r, List <string> zone = null, List <string> project_id = null, List <string> host_id = null, List <string> instance_id = null, List <string> instance_name = null, string instance_charge_type = null, List <string> private_ip_address = null, List <string> public_ip_address = null, int offset = 0, int limit = 20) { int filterCount = 1; var baseParams = new SortedDictionary <string, object>(StringComparer.Ordinal) { ["Version"] = "2017-03-12" }; // 按照可用区过滤。 if (zone != null && zone.Count > 0) { baseParams.Add($"Filters.{filterCount}.Name", "zone"); for (int i = 0; i < zone.Count; i++) { baseParams.Add($"Filters.{filterCount}.Values.{i}", zone[i]); } filterCount++; } // 按照项目ID过滤。 if (project_id != null && project_id.Count > 0) { baseParams.Add($"Filters.{filterCount}.Name", "project-id"); for (int i = 0; i < project_id.Count; i++) { baseParams.Add($"Filters.{filterCount}.Values.{i}", project_id[i]); } filterCount++; } // 按照CDH ID过滤。CDH ID形如:host-11112222。 if (host_id != null && host_id.Count > 0) { baseParams.Add($"Filters.{filterCount}.Name", "host-id"); for (int i = 0; i < host_id.Count; i++) { baseParams.Add($"Filters.{filterCount}.Values.{i}", host_id[i]); } filterCount++; } // 按照实例ID过滤。实例ID形如:ins-11112222。 if (instance_id != null && instance_id.Count > 0) { baseParams.Add($"Filters.{filterCount}.Name", "instance-id"); for (int i = 0; i < instance_id.Count; i++) { baseParams.Add($"Filters.{filterCount}.Values.{i}", instance_id[i]); } filterCount++; } // 按照实例名称过滤。 if (instance_name != null && instance_name.Count > 0) { baseParams.Add($"Filters.{filterCount}.Name", "instance-name"); for (int i = 0; i < instance_name.Count; i++) { baseParams.Add($"Filters.{filterCount}.Values.{i}", instance_name[i]); } filterCount++; } // 按照实例计费模式过滤。 if (!string.IsNullOrWhiteSpace(instance_charge_type)) { baseParams.Add($"Filters.{filterCount}.Name", "instance-charge-type"); baseParams.Add($"Filters.{filterCount}.Values.1", instance_charge_type); filterCount++; } // 按照实例主网卡的内网IP过滤。 if (private_ip_address != null && private_ip_address.Count > 0) { baseParams.Add($"Filters.{filterCount}.Name", "private-ip-address"); for (int i = 0; i < private_ip_address.Count; i++) { baseParams.Add($"Filters.{filterCount}.Values.{i}", private_ip_address[i]); } filterCount++; } // 按照实例主网卡的公网IP过滤,包含实例创建时自动分配的IP和实例创建后手动绑定的弹性IP。 if (public_ip_address != null && public_ip_address.Count > 0) { baseParams.Add($"Filters.{filterCount}.Name", "public-ip-address"); for (int i = 0; i < public_ip_address.Count; i++) { baseParams.Add($"Filters.{filterCount}.Values.{i}", public_ip_address[i]); } filterCount++; } var returnJson = q.RequestAPi("DescribeInstances", baseParams, APIUrl.Cvm, r); var d = JsonConvert.DeserializeObject <CvmListReturnType>(returnJson); return(d); }