mirror of
https://github.com/certd/certd.git
synced 2026-07-07 04:47:34 +08:00
4457 lines
140 KiB
JavaScript
4457 lines
140 KiB
JavaScript
/*
|
||
* Copyright 2018 JDCLOUD.COM
|
||
*
|
||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||
* you may not use this file except in compliance with the License.
|
||
* You may obtain a copy of the License at
|
||
*
|
||
* http:#www.apache.org/licenses/LICENSE-2.0
|
||
*
|
||
* Unless required by applicable law or agreed to in writing, software
|
||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
* See the License for the specific language governing permissions and
|
||
* limitations under the License.
|
||
*
|
||
* yunding-user
|
||
* 云鼎-用户操作相关接口
|
||
*
|
||
* OpenAPI spec version: v2
|
||
* Contact:
|
||
*
|
||
* NOTE: This class is auto generated by the jdcloud code generator program.
|
||
*/
|
||
|
||
require('../../../lib/node_loader')
|
||
var JDCloud = require('../../../lib/core')
|
||
var Service = JDCloud.Service
|
||
var serviceId = 'yunding'
|
||
Service._services[serviceId] = true
|
||
|
||
/**
|
||
* yunding service.
|
||
* @version 2.0.8
|
||
*/
|
||
|
||
class YUNDING extends Service {
|
||
constructor (options = {}) {
|
||
options._defaultEndpoint = {}
|
||
options._defaultEndpoint.protocol =
|
||
options._defaultEndpoint.protocol || 'https'
|
||
options._defaultEndpoint.host =
|
||
options._defaultEndpoint.host || 'yunding.jdcloud-api.com'
|
||
options.basePath = '/v2' // 默认要设为空""
|
||
super(serviceId, options)
|
||
}
|
||
|
||
/**
|
||
* 云拔测-可用性agent任务查询接口
|
||
* @param {Object} opts - parameters
|
||
* @param {string} opts.instanceId - 实例 Id
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
* @param tasksInfo tasks
|
||
*/
|
||
|
||
describeTasks (opts, callback) {
|
||
opts = opts || {}
|
||
|
||
if (opts.instanceId === undefined || opts.instanceId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.instanceId' when calling describeTasks"
|
||
)
|
||
}
|
||
|
||
let postBody = null
|
||
let queryParams = {}
|
||
|
||
let pathParams = {
|
||
regionId: 'jdcloud',
|
||
instanceId: opts.instanceId
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call describeTasks with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/agentTasks/{instanceId}',
|
||
'GET',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 监控数据上报。
|
||
* @param {Object} opts - parameters
|
||
* @param {string} opts.appCode - 目前统一用jcloud
|
||
* @param {string} opts.serviceCode - 资源的类型,取值vm,ip,database,storage,disk,cdn,redis,balance,nat_gw,db_ro,vpn,ddos等,新接入的产品要求与opentapi命名的产品线名称一致
|
||
* @param {string} opts.region - 地域信息,如 cn-north-1 等
|
||
* @param {string} opts.resourceId - 资源的唯一表示,一般为uuid
|
||
* @param {array} [opts.dataPoints] - 监控数据点 optional
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
* @param integer failed 失败数量
|
||
* @param integer success 成功数量
|
||
*/
|
||
|
||
put (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling put"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
if (opts.appCode === undefined || opts.appCode === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.appCode' when calling put"
|
||
)
|
||
}
|
||
if (opts.serviceCode === undefined || opts.serviceCode === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.serviceCode' when calling put"
|
||
)
|
||
}
|
||
if (opts.region === undefined || opts.region === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.region' when calling put"
|
||
)
|
||
}
|
||
if (opts.resourceId === undefined || opts.resourceId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.resourceId' when calling put"
|
||
)
|
||
}
|
||
|
||
let postBody = {}
|
||
if (opts.appCode !== undefined && opts.appCode !== null) {
|
||
postBody['appCode'] = opts.appCode
|
||
}
|
||
if (opts.serviceCode !== undefined && opts.serviceCode !== null) {
|
||
postBody['serviceCode'] = opts.serviceCode
|
||
}
|
||
if (opts.region !== undefined && opts.region !== null) {
|
||
postBody['region'] = opts.region
|
||
}
|
||
if (opts.resourceId !== undefined && opts.resourceId !== null) {
|
||
postBody['resourceId'] = opts.resourceId
|
||
}
|
||
if (opts.dataPoints !== undefined && opts.dataPoints !== null) {
|
||
postBody['dataPoints'] = opts.dataPoints
|
||
}
|
||
|
||
let queryParams = {}
|
||
|
||
let pathParams = {
|
||
regionId: regionId
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call put with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/put',
|
||
'POST',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 监控数据上报。
|
||
* @param {Object} opts - parameters
|
||
* @param {string} opts.appCode - 目前统一用jcloud
|
||
* @param {string} opts.serviceCode - 资源的类型,取值vm,ip,database,storage,disk,cdn,redis,balance,nat_gw,db_ro,vpn,ddos等,新接入的产品要求与opentapi命名的产品线名称一致
|
||
* @param {string} opts.region - 地域信息,如 cn-north-1 等
|
||
* @param {string} opts.resourceId - 资源的唯一表示,一般为uuid
|
||
* @param {array} [opts.dataPoints] - 监控数据点 optional
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
* @param integer failed 失败数量
|
||
* @param integer success 成功数量
|
||
*/
|
||
|
||
putProductMetricData (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling putProductMetricData"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
if (opts.appCode === undefined || opts.appCode === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.appCode' when calling putProductMetricData"
|
||
)
|
||
}
|
||
if (opts.serviceCode === undefined || opts.serviceCode === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.serviceCode' when calling putProductMetricData"
|
||
)
|
||
}
|
||
if (opts.region === undefined || opts.region === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.region' when calling putProductMetricData"
|
||
)
|
||
}
|
||
if (opts.resourceId === undefined || opts.resourceId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.resourceId' when calling putProductMetricData"
|
||
)
|
||
}
|
||
|
||
let postBody = {}
|
||
if (opts.appCode !== undefined && opts.appCode !== null) {
|
||
postBody['appCode'] = opts.appCode
|
||
}
|
||
if (opts.serviceCode !== undefined && opts.serviceCode !== null) {
|
||
postBody['serviceCode'] = opts.serviceCode
|
||
}
|
||
if (opts.region !== undefined && opts.region !== null) {
|
||
postBody['region'] = opts.region
|
||
}
|
||
if (opts.resourceId !== undefined && opts.resourceId !== null) {
|
||
postBody['resourceId'] = opts.resourceId
|
||
}
|
||
if (opts.dataPoints !== undefined && opts.dataPoints !== null) {
|
||
postBody['dataPoints'] = opts.dataPoints
|
||
}
|
||
|
||
let queryParams = {}
|
||
|
||
let pathParams = {
|
||
regionId: regionId
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call putProductMetricData with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/put',
|
||
'POST',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 查询监控图可用的产品线列表
|
||
* @param {Object} opts - parameters
|
||
* @param {integer} [opts.productType] - 要查询的产品线类型 0:all 1:资源监控 2:其它 默认:1。若指定了查询的serviceCode,则忽略该参数 optional
|
||
* @param {filter} [opts.filters] - 服务码列表
|
||
filter name 为serviceCodes表示查询多个产品线的规则 optional
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
* @param serviceInfoV2 services
|
||
*/
|
||
|
||
describeServices (opts, callback) {
|
||
opts = opts || {}
|
||
|
||
let postBody = null
|
||
let queryParams = {}
|
||
if (opts.productType !== undefined && opts.productType !== null) {
|
||
queryParams['productType'] = opts.productType
|
||
}
|
||
Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters'))
|
||
|
||
let pathParams = {
|
||
regionId: 'jdcloud'
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call describeServices with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/ydServices',
|
||
'GET',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 根据不同的聚合方式将metric的数据聚合为一个点。downAggrType:last(最后一个点)、max(最大值)、min(最小值)、avg(平均值)。该接口返回值为上报metric的原始值,没有做单位转换。metric介绍:<a href="https://docs.jdcloud.com/cn/monitoring/metrics">Metrics</a>
|
||
* @param {Object} opts - parameters
|
||
* @param {string} opts.metric - 监控项英文标识(id)
|
||
* @param {string} opts.serviceCode - 资源的类型,取值vm, lb, ip, database 等。可用的serviceCode请使用describeServices接口查询
|
||
* @param {string} [opts.dimension] - 资源的维度。serviceCode下可用的dimension请使用describeServices接口查询 optional
|
||
* @param {string} opts.resourceId - 资源的uuid,支持多个resourceId批量查询,每个id用竖线分隔。 如:id1|id2|id3|id4
|
||
* @param {string} [opts.startTime] - 查询时间范围的开始时间, UTC时间,格式:2016-12-11T00:00:00+0800(早于30d时,将被重置为30d)(注意在url中+要转译为%2B故url中为2016-12-11T00:00:00%2B0800) optional
|
||
* @param {string} [opts.endTime] - 查询时间范围的结束时间, UTC时间,格式:2016-12-11T00:00:00+0800(为空时,将由startTime与timeInterval计算得出)(注意在url中+要转译为%2B故url中为2016-12-11T00:00:00%2B0800) optional
|
||
* @param {string} [opts.timeInterval] - 查询的时间间隔,最大不超过30天,支持分钟级别,小时级别,天级别,例如:1m、1h、1d optional
|
||
* @param {string} [opts.aggrType] - 聚合方式:max avg min等,用于不同维度之间聚合 optional
|
||
* @param {string} [opts.downAggrType] - 聚合方式:max avg min等,用于将维度内一个周期数据聚合为一个点的聚合方式,默认last optional
|
||
* @param {tagFilter} [opts.tags] - 自定义标签 optional
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
* @param lastDownsampleRespItem items
|
||
*/
|
||
|
||
lastDownsample (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling lastDownsample"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
if (opts.metric === undefined || opts.metric === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.metric' when calling lastDownsample"
|
||
)
|
||
}
|
||
if (opts.serviceCode === undefined || opts.serviceCode === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.serviceCode' when calling lastDownsample"
|
||
)
|
||
}
|
||
if (opts.resourceId === undefined || opts.resourceId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.resourceId' when calling lastDownsample"
|
||
)
|
||
}
|
||
|
||
let postBody = null
|
||
let queryParams = {}
|
||
if (opts.serviceCode !== undefined && opts.serviceCode !== null) {
|
||
queryParams['serviceCode'] = opts.serviceCode
|
||
}
|
||
if (opts.dimension !== undefined && opts.dimension !== null) {
|
||
queryParams['dimension'] = opts.dimension
|
||
}
|
||
if (opts.resourceId !== undefined && opts.resourceId !== null) {
|
||
queryParams['resourceId'] = opts.resourceId
|
||
}
|
||
if (opts.startTime !== undefined && opts.startTime !== null) {
|
||
queryParams['startTime'] = opts.startTime
|
||
}
|
||
if (opts.endTime !== undefined && opts.endTime !== null) {
|
||
queryParams['endTime'] = opts.endTime
|
||
}
|
||
if (opts.timeInterval !== undefined && opts.timeInterval !== null) {
|
||
queryParams['timeInterval'] = opts.timeInterval
|
||
}
|
||
if (opts.aggrType !== undefined && opts.aggrType !== null) {
|
||
queryParams['aggrType'] = opts.aggrType
|
||
}
|
||
if (opts.downAggrType !== undefined && opts.downAggrType !== null) {
|
||
queryParams['downAggrType'] = opts.downAggrType
|
||
}
|
||
Object.assign(queryParams, super.buildTagFilterParam(opts.tags, 'tags'))
|
||
|
||
let pathParams = {
|
||
regionId: regionId,
|
||
metric: opts.metric
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call lastDownsample with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/ydMetrics/{metric}/lastDownsample',
|
||
'GET',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 查看某资源单个监控项数据,metric介绍:<a href="https://docs.jdcloud.com/cn/monitoring/metrics">Metrics</a>,可以使用接口<a href="https://docs.jdcloud.com/cn/monitoring/metrics">describeMetrics</a>:查询产品线可用的metric列表。
|
||
* @param {Object} opts - parameters
|
||
* @param {string} opts.metric - 监控项英文标识(id)
|
||
* @param {string} [opts.aggrType] - 聚合方式,用于不同时间轴上的聚合。如balance产品同一个resourceId下存在port=80和port=8080等多种维度。可选值参考:sum、avg、min、max optional
|
||
* @param {string} [opts.downSampleType] - 采样方式,用于在时间轴维度上将聚合周期内的数据聚合为一个点。可选值参考:sum(聚合周期内的数据求和)、avg(求平均)、last(最新值)、min(最小值)、max(最大值) optional
|
||
* @param {string} [opts.startTime] - 查询时间范围的开始时间, UTC时间,格式:2016-12-11T00:00:00+0800(注意在url中+要转译为%2B故url中为2016-12-11T00:00:00%2B0800) optional
|
||
* @param {string} [opts.endTime] - 查询时间范围的结束时间, UTC时间,格式:2016-12-11T00:00:00+0800(为空时,将由startTime与timeInterval计算得出)(注意在url中+要转译为%2B故url中为2016-12-11T00:00:00%2B0800) optional
|
||
* @param {string} [opts.timeInterval] - 时间间隔:1h,6h,12h,1d,3d,7d,14d,固定时间间隔,timeInterval默认为1h,当前时间往 前1h optional
|
||
* @param {boolean} [opts.groupBy] - 是否对查询的tags分组 optional
|
||
* @param {boolean} [opts.rate] - 是否求速率 optional
|
||
* @param {string} [opts.serviceCode] - 资源的类型,取值vm, lb, ip, database 等,<a href="https://docs.jdcloud.com/cn/monitoring/api/describeservices?content=API&SOP=JDCloud">describeServices</a>:查询己接入云监控的产品线列表 optional
|
||
* @param {string} [opts.dimension] - 资源的维度。查询serviceCode下可用的维度请使用describeServices接口 optional
|
||
* @param {string} opts.resourceId - 资源的uuid
|
||
* @param {tagFilter} [opts.tags] - 监控指标数据的维度信息,根据tags来筛选指标数据不同的维度 optional
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
* @param metricData metricDatas
|
||
*/
|
||
|
||
describeMetricData (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling describeMetricData"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
if (opts.metric === undefined || opts.metric === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.metric' when calling describeMetricData"
|
||
)
|
||
}
|
||
if (opts.resourceId === undefined || opts.resourceId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.resourceId' when calling describeMetricData"
|
||
)
|
||
}
|
||
|
||
let postBody = null
|
||
let queryParams = {}
|
||
if (opts.aggrType !== undefined && opts.aggrType !== null) {
|
||
queryParams['aggrType'] = opts.aggrType
|
||
}
|
||
if (opts.downSampleType !== undefined && opts.downSampleType !== null) {
|
||
queryParams['downSampleType'] = opts.downSampleType
|
||
}
|
||
if (opts.startTime !== undefined && opts.startTime !== null) {
|
||
queryParams['startTime'] = opts.startTime
|
||
}
|
||
if (opts.endTime !== undefined && opts.endTime !== null) {
|
||
queryParams['endTime'] = opts.endTime
|
||
}
|
||
if (opts.timeInterval !== undefined && opts.timeInterval !== null) {
|
||
queryParams['timeInterval'] = opts.timeInterval
|
||
}
|
||
if (opts.groupBy !== undefined && opts.groupBy !== null) {
|
||
queryParams['groupBy'] = opts.groupBy
|
||
}
|
||
if (opts.rate !== undefined && opts.rate !== null) {
|
||
queryParams['rate'] = opts.rate
|
||
}
|
||
if (opts.serviceCode !== undefined && opts.serviceCode !== null) {
|
||
queryParams['serviceCode'] = opts.serviceCode
|
||
}
|
||
if (opts.dimension !== undefined && opts.dimension !== null) {
|
||
queryParams['dimension'] = opts.dimension
|
||
}
|
||
if (opts.resourceId !== undefined && opts.resourceId !== null) {
|
||
queryParams['resourceId'] = opts.resourceId
|
||
}
|
||
Object.assign(queryParams, super.buildTagFilterParam(opts.tags, 'tags'))
|
||
|
||
let pathParams = {
|
||
regionId: regionId,
|
||
metric: opts.metric
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call describeMetricData with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/ydMetrics/{metric}/metricData',
|
||
'GET',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 查看某资源多个监控项数据,metric介绍:<a href="https://docs.jdcloud.com/cn/monitoring/metrics">Metrics</a>,可以使用接口<a href="https://docs.jdcloud.com/cn/monitoring/metrics">describeMetrics</a>:查询产品线可用的metric列表。
|
||
* @param {Object} opts - parameters
|
||
* @param {string} [opts.aggrType] - 聚合方式,用于不同时间轴上的聚合。如balance产品同一个resourceId下存在port=80和port=8080等多种维度。可选值参考:sum、avg、min、max optional
|
||
* @param {string} [opts.downSampleType] - 采样方式,用于在时间轴维度上将聚合周期内的数据聚合为一个点。可选值参考:sum(聚合周期内的数据求和)、avg(求平均)、last(最新值)、min(最小值)、max(最大值) optional
|
||
* @param {string} [opts.startTime] - 查询时间范围的开始时间, UTC时间,格式:2016-12-11T00:00:00+0800(注意在url中+要转译为%2B故url中为2016-12-11T00:00:00%2B0800) optional
|
||
* @param {string} [opts.endTime] - 查询时间范围的结束时间, UTC时间,格式:2016-12-11T00:00:00+0800(为空时,将由startTime与timeInterval计算得出)(注意在url中+要转译为%2B故url中为2016-12-11T00:00:00%2B0800) optional
|
||
* @param {string} [opts.timeInterval] - 时间间隔:1h,6h,12h,1d,3d,7d,14d,固定时间间隔,timeInterval默认为1h,当前时间往 前1h optional
|
||
* @param {boolean} [opts.groupBy] - 是否对查询的tags分组 optional
|
||
* @param {boolean} [opts.rate] - 是否求速率 optional
|
||
* @param {string} [opts.serviceCode] - 资源的类型,取值vm, lb, ip, database 等,<a href="https://docs.jdcloud.com/cn/monitoring/api/describeservices?content=API&SOP=JDCloud">describeServices</a>:查询己接入云监控的产品线列表 optional
|
||
* @param {string} [opts.dimension] - 资源的维度。查询serviceCode下可用的维度请使用describeServices接口 optional
|
||
* @param {string} opts.resourceId - 资源的uuid
|
||
* @param {boolean} [opts.multiResources] - 是否跨资源查询,默认为false。当该字段为false时,取resourceId字段进行查询;当该子弹为true时,忽略resourceId字段,从tags中取resourceId作为实际的多资源id处理。 optional
|
||
* @param {filter} [opts.filters] - 自定义过滤标签,查询时必须在filters中指定要查询的metric,支持多个metric。如: name='metric',values=["metric1","metric2"] optional
|
||
* @param {tagFilter} [opts.tags] - 监控指标数据的维度信息,根据tags来筛选指标数据不同的维度 optional
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
* @param metricData metricDatas
|
||
*/
|
||
|
||
batchDescribeMetricData (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling batchDescribeMetricData"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
if (opts.resourceId === undefined || opts.resourceId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.resourceId' when calling batchDescribeMetricData"
|
||
)
|
||
}
|
||
|
||
let postBody = null
|
||
let queryParams = {}
|
||
if (opts.aggrType !== undefined && opts.aggrType !== null) {
|
||
queryParams['aggrType'] = opts.aggrType
|
||
}
|
||
if (opts.downSampleType !== undefined && opts.downSampleType !== null) {
|
||
queryParams['downSampleType'] = opts.downSampleType
|
||
}
|
||
if (opts.startTime !== undefined && opts.startTime !== null) {
|
||
queryParams['startTime'] = opts.startTime
|
||
}
|
||
if (opts.endTime !== undefined && opts.endTime !== null) {
|
||
queryParams['endTime'] = opts.endTime
|
||
}
|
||
if (opts.timeInterval !== undefined && opts.timeInterval !== null) {
|
||
queryParams['timeInterval'] = opts.timeInterval
|
||
}
|
||
if (opts.groupBy !== undefined && opts.groupBy !== null) {
|
||
queryParams['groupBy'] = opts.groupBy
|
||
}
|
||
if (opts.rate !== undefined && opts.rate !== null) {
|
||
queryParams['rate'] = opts.rate
|
||
}
|
||
if (opts.serviceCode !== undefined && opts.serviceCode !== null) {
|
||
queryParams['serviceCode'] = opts.serviceCode
|
||
}
|
||
if (opts.dimension !== undefined && opts.dimension !== null) {
|
||
queryParams['dimension'] = opts.dimension
|
||
}
|
||
if (opts.resourceId !== undefined && opts.resourceId !== null) {
|
||
queryParams['resourceId'] = opts.resourceId
|
||
}
|
||
if (opts.multiResources !== undefined && opts.multiResources !== null) {
|
||
queryParams['multiResources'] = opts.multiResources
|
||
}
|
||
Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters'))
|
||
Object.assign(queryParams, super.buildTagFilterParam(opts.tags, 'tags'))
|
||
|
||
let pathParams = {
|
||
regionId: regionId
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call batchDescribeMetricData with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/ydMetricsData',
|
||
'GET',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 给网卡分配secondaryIp接口
|
||
* @param {Object} opts - parameters
|
||
* @param {string} opts.networkInterfaceId - networkInterface ID
|
||
* @param {boolean} [opts.force] - secondary ip被其他接口占用时,是否抢占。false:非抢占重分配,true:抢占重分配;按网段分配时,默认非抢占重分配,指定IP或者个数时,默认抢占重分配。 optional
|
||
* @param {array} [opts.secondaryIps] - 指定分配的secondaryIp地址 optional
|
||
* @param {number} [opts.secondaryIpCount] - 指定自动分配的secondaryIp个数 optional
|
||
* @param {integer} [opts.secondaryIpMaskLen] - 指定分配的网段掩码长度, 支持24-28位掩码长度,不能与secondaryIpCount或secondaryIps同时指定,不支持抢占重分配 optional
|
||
* @param {string} [opts.secondaryIpAddress] - 指定分配的网段中第一个secondaryIp地址,不能与secondaryIpCount或secondaryIps同时指定,secondaryIpAddress与secondaryIpMaskLen需要保持一致,否则无法创建 optional
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
*/
|
||
|
||
assignSecondaryIps (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling assignSecondaryIps"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
if (
|
||
opts.networkInterfaceId === undefined ||
|
||
opts.networkInterfaceId === null
|
||
) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.networkInterfaceId' when calling assignSecondaryIps"
|
||
)
|
||
}
|
||
|
||
let postBody = {}
|
||
if (opts.force !== undefined && opts.force !== null) {
|
||
postBody['force'] = opts.force
|
||
}
|
||
if (opts.secondaryIps !== undefined && opts.secondaryIps !== null) {
|
||
postBody['secondaryIps'] = opts.secondaryIps
|
||
}
|
||
if (opts.secondaryIpCount !== undefined && opts.secondaryIpCount !== null) {
|
||
postBody['secondaryIpCount'] = opts.secondaryIpCount
|
||
}
|
||
if (
|
||
opts.secondaryIpMaskLen !== undefined &&
|
||
opts.secondaryIpMaskLen !== null
|
||
) {
|
||
postBody['secondaryIpMaskLen'] = opts.secondaryIpMaskLen
|
||
}
|
||
if (
|
||
opts.secondaryIpAddress !== undefined &&
|
||
opts.secondaryIpAddress !== null
|
||
) {
|
||
postBody['secondaryIpAddress'] = opts.secondaryIpAddress
|
||
}
|
||
|
||
let queryParams = {}
|
||
|
||
let pathParams = {
|
||
regionId: regionId,
|
||
networkInterfaceId: opts.networkInterfaceId
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call assignSecondaryIps with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/ydNetworkInterfaces/{networkInterfaceId}:assignSecondaryIps',
|
||
'POST',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 给网卡删除secondaryIp接口
|
||
* @param {Object} opts - parameters
|
||
* @param {string} opts.networkInterfaceId - networkInterface ID
|
||
* @param {array} [opts.secondaryIps] - 指定删除的secondaryIp地址 optional
|
||
* @param {array} [opts.secondaryCidrs] - 指定删除的secondaryIp网段 optional
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
*/
|
||
|
||
unassignSecondaryIps (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling unassignSecondaryIps"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
if (
|
||
opts.networkInterfaceId === undefined ||
|
||
opts.networkInterfaceId === null
|
||
) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.networkInterfaceId' when calling unassignSecondaryIps"
|
||
)
|
||
}
|
||
|
||
let postBody = {}
|
||
if (opts.secondaryIps !== undefined && opts.secondaryIps !== null) {
|
||
postBody['secondaryIps'] = opts.secondaryIps
|
||
}
|
||
if (opts.secondaryCidrs !== undefined && opts.secondaryCidrs !== null) {
|
||
postBody['secondaryCidrs'] = opts.secondaryCidrs
|
||
}
|
||
|
||
let queryParams = {}
|
||
|
||
let pathParams = {
|
||
regionId: regionId,
|
||
networkInterfaceId: opts.networkInterfaceId
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call unassignSecondaryIps with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/ydNetworkInterfaces/{networkInterfaceId}:unassignSecondaryIps',
|
||
'POST',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 查询弹性网卡信息详情
|
||
* @param {Object} opts - parameters
|
||
* @param {string} opts.networkInterfaceId - networkInterface ID
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
* @param networkInterface networkInterface networkInterface资源信息
|
||
*/
|
||
|
||
describeNetworkInterface (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling describeNetworkInterface"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
if (
|
||
opts.networkInterfaceId === undefined ||
|
||
opts.networkInterfaceId === null
|
||
) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.networkInterfaceId' when calling describeNetworkInterface"
|
||
)
|
||
}
|
||
|
||
let postBody = null
|
||
let queryParams = {}
|
||
|
||
let pathParams = {
|
||
regionId: regionId,
|
||
networkInterfaceId: opts.networkInterfaceId
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call describeNetworkInterface with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/ydNetworkInterfaces/{networkInterfaceId}',
|
||
'GET',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 删除弹性网卡接口
|
||
* @param {Object} opts - parameters
|
||
* @param {string} opts.networkInterfaceId - networkInterface ID
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
*/
|
||
|
||
deleteNetworkInterface (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling deleteNetworkInterface"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
if (
|
||
opts.networkInterfaceId === undefined ||
|
||
opts.networkInterfaceId === null
|
||
) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.networkInterfaceId' when calling deleteNetworkInterface"
|
||
)
|
||
}
|
||
|
||
let postBody = null
|
||
let queryParams = {}
|
||
|
||
let pathParams = {
|
||
regionId: regionId,
|
||
networkInterfaceId: opts.networkInterfaceId
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call deleteNetworkInterface with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/ydNetworkInterfaces/{networkInterfaceId}',
|
||
'DELETE',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 查询弹性网卡列表
|
||
* @param {Object} opts - parameters
|
||
* @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞), 页码超过总页数时, 显示最后一页 optional
|
||
* @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional
|
||
* @param {filter} [opts.filters] - networkInterfaceIds - 弹性网卡ID列表,支持多个
|
||
networkInterfaceNames - 弹性网卡名称列表,支持多个
|
||
vpcId - 弹性网卡所属vpc Id,支持单个
|
||
subnetId - 弹性网卡所属子网Id,支持单个
|
||
role - 网卡角色,取值范围:Primary(主网卡)、Secondary(辅助网卡)、Managed (受管网卡),支持单个
|
||
optional
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
* @param networkInterface networkInterfaces
|
||
* @param number totalCount 总数量
|
||
*/
|
||
|
||
describeNetworkInterfaces (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling describeNetworkInterfaces"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
let postBody = null
|
||
let queryParams = {}
|
||
if (opts.pageNumber !== undefined && opts.pageNumber !== null) {
|
||
queryParams['pageNumber'] = opts.pageNumber
|
||
}
|
||
if (opts.pageSize !== undefined && opts.pageSize !== null) {
|
||
queryParams['pageSize'] = opts.pageSize
|
||
}
|
||
Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters'))
|
||
|
||
let pathParams = {
|
||
regionId: regionId
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call describeNetworkInterfaces with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/ydNetworkInterfaces',
|
||
'GET',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 创建网卡接口,只能创建辅助网卡
|
||
* @param {Object} opts - parameters
|
||
* @param {string} opts.subnetId - 子网ID
|
||
* @param {string} [opts.az] - 可用区,用户的默认可用区,该参数无效,不建议使用 optional
|
||
* @param {string} [opts.networkInterfaceName] - 网卡名称,只允许输入中文、数字、大小写字母、英文下划线“_”及中划线“-”,不允许为空且不超过32字符。 optional
|
||
* @param {string} [opts.primaryIpAddress] - 网卡主IP,如果不指定,会自动从子网中分配 optional
|
||
* @param {array} [opts.secondaryIpAddresses] - SecondaryIp列表 optional
|
||
* @param {integer} [opts.secondaryIpCount] - 自动分配的SecondaryIp数量 optional
|
||
* @param {array} [opts.securityGroups] - 要绑定的安全组ID列表,最多指定5个安全组 optional
|
||
* @param {integer} [opts.sanityCheck] - 源和目标IP地址校验,取值为0或者1,默认为1 optional
|
||
* @param {string} [opts.description] - 描述, 允许输入UTF-8编码下的全部字符,不超过256字符 optional
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
* @param string networkInterfaceId 弹性网卡Id
|
||
*/
|
||
|
||
createNetworkInterface (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling createNetworkInterface"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
if (opts.subnetId === undefined || opts.subnetId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.subnetId' when calling createNetworkInterface"
|
||
)
|
||
}
|
||
|
||
let postBody = {}
|
||
if (opts.subnetId !== undefined && opts.subnetId !== null) {
|
||
postBody['subnetId'] = opts.subnetId
|
||
}
|
||
if (opts.az !== undefined && opts.az !== null) {
|
||
postBody['az'] = opts.az
|
||
}
|
||
if (
|
||
opts.networkInterfaceName !== undefined &&
|
||
opts.networkInterfaceName !== null
|
||
) {
|
||
postBody['networkInterfaceName'] = opts.networkInterfaceName
|
||
}
|
||
if (opts.primaryIpAddress !== undefined && opts.primaryIpAddress !== null) {
|
||
postBody['primaryIpAddress'] = opts.primaryIpAddress
|
||
}
|
||
if (
|
||
opts.secondaryIpAddresses !== undefined &&
|
||
opts.secondaryIpAddresses !== null
|
||
) {
|
||
postBody['secondaryIpAddresses'] = opts.secondaryIpAddresses
|
||
}
|
||
if (opts.secondaryIpCount !== undefined && opts.secondaryIpCount !== null) {
|
||
postBody['secondaryIpCount'] = opts.secondaryIpCount
|
||
}
|
||
if (opts.securityGroups !== undefined && opts.securityGroups !== null) {
|
||
postBody['securityGroups'] = opts.securityGroups
|
||
}
|
||
if (opts.sanityCheck !== undefined && opts.sanityCheck !== null) {
|
||
postBody['sanityCheck'] = opts.sanityCheck
|
||
}
|
||
if (opts.description !== undefined && opts.description !== null) {
|
||
postBody['description'] = opts.description
|
||
}
|
||
|
||
let queryParams = {}
|
||
|
||
let pathParams = {
|
||
regionId: regionId
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call createNetworkInterface with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/ydNetworkInterfaces',
|
||
'POST',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 批量查询云数据库实例列表信息<br>此接口支持分页查询,默认每页20条。
|
||
* @param {Object} opts - parameters
|
||
* @param {integer} [opts.pageNumber] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageNumber为-1时,返回所有数据页码;超过总页数时,显示最后一页; optional
|
||
* @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为100,取值范围:[10,100],用于查询列表的接口 optional
|
||
* @param {integer} [opts.type] - 资源类型,MySQL:1,SqlServer:2 optional
|
||
* @param {filter} [opts.filters] - 过滤参数,多个过滤参数之间的关系为“与”(and)
|
||
支持以下属性的过滤:
|
||
instanceId, 支持operator选项:eq
|
||
instanceName, 支持operator选项:eq
|
||
engine, 支持operator选项:eq
|
||
engineVersion, 支持operator选项:eq
|
||
instanceStatus, 支持operator选项:eq
|
||
chargeMode, 支持operator选项:eq
|
||
vpcId, 支持operator选项:eq
|
||
optional
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
* @param dBInstance dbInstances
|
||
* @param integer totalCount
|
||
*/
|
||
|
||
describeRdsInstances (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling describeRdsInstances"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
let postBody = null
|
||
let queryParams = {}
|
||
if (opts.pageNumber !== undefined && opts.pageNumber !== null) {
|
||
queryParams['pageNumber'] = opts.pageNumber
|
||
}
|
||
if (opts.pageSize !== undefined && opts.pageSize !== null) {
|
||
queryParams['pageSize'] = opts.pageSize
|
||
}
|
||
if (opts.type !== undefined && opts.type !== null) {
|
||
queryParams['type'] = opts.type
|
||
}
|
||
Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters'))
|
||
|
||
let pathParams = {
|
||
regionId: regionId
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call describeRdsInstances with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/ydRdsInstances',
|
||
'GET',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 查询RDS实例(MySQL、SQL Server等)的详细信息以及MySQL只读实例详细信息
|
||
* @param {Object} opts - parameters
|
||
* @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
* @param dBInstanceAttribute dbInstanceAttributes
|
||
*/
|
||
|
||
describeRdsInstance (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling describeRdsInstance"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
if (opts.instanceId === undefined || opts.instanceId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.instanceId' when calling describeRdsInstance"
|
||
)
|
||
}
|
||
|
||
let postBody = null
|
||
let queryParams = {}
|
||
|
||
let pathParams = {
|
||
regionId: regionId,
|
||
instanceId: opts.instanceId
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call describeRdsInstance with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/ydRdsInstances/{instanceId}',
|
||
'GET',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 查询RDS实例(MySQL、SQL Server等)的真实状态
|
||
* @param {Object} opts - parameters
|
||
* @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
* @param string instanceStatus 实例状态,参见[枚举参数定义](../Enum-Definitions/Enum-Definitions.md)
|
||
* @param string internalDns 内部floatIP的DNS,目前主要给云鼎使用,支持MySQL,SQL Server
|
||
*/
|
||
|
||
describeInstanceInfo (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling describeInstanceInfo"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
if (opts.instanceId === undefined || opts.instanceId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.instanceId' when calling describeInstanceInfo"
|
||
)
|
||
}
|
||
|
||
let postBody = null
|
||
let queryParams = {}
|
||
|
||
let pathParams = {
|
||
regionId: regionId,
|
||
instanceId: opts.instanceId
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call describeInstanceInfo with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/ydRdsInstances/{instanceId}:describeInstanceInfo',
|
||
'GET',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 查看RDS实例当前白名单。白名单是允许访问当前实例的IP/IP段列表,缺省情况下,白名单对本VPC开放。如果用户开启了外网访问的功能,还需要对外网的IP配置白名单。
|
||
* @param {Object} opts - parameters
|
||
* @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
* @param whiteList whiteLists
|
||
*/
|
||
|
||
describeRdsWhiteList (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling describeRdsWhiteList"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
if (opts.instanceId === undefined || opts.instanceId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.instanceId' when calling describeRdsWhiteList"
|
||
)
|
||
}
|
||
|
||
let postBody = null
|
||
let queryParams = {}
|
||
|
||
let pathParams = {
|
||
regionId: regionId,
|
||
instanceId: opts.instanceId
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call describeRdsWhiteList with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/ydRdsInstances/{instanceId}/whiteList',
|
||
'GET',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 修改允许访问实例的IP白名单。白名单是允许访问当前实例的IP/IP段列表,缺省情况下,白名单对本VPC开放。如果用户开启了外网访问的功能,还需要对外网的IP配置白名单。
|
||
* @param {Object} opts - parameters
|
||
* @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例
|
||
* @param {string} opts.ips - IP或IP段,不同的IP/IP段之间用英文逗号分隔,例如0.0.0.0/0,192.168.0.10
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
*/
|
||
|
||
modifyRdsWhiteList (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling modifyRdsWhiteList"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
if (opts.instanceId === undefined || opts.instanceId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.instanceId' when calling modifyRdsWhiteList"
|
||
)
|
||
}
|
||
if (opts.ips === undefined || opts.ips === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.ips' when calling modifyRdsWhiteList"
|
||
)
|
||
}
|
||
|
||
let postBody = {}
|
||
if (opts.ips !== undefined && opts.ips !== null) {
|
||
postBody['ips'] = opts.ips
|
||
}
|
||
|
||
let queryParams = {}
|
||
|
||
let pathParams = {
|
||
regionId: regionId,
|
||
instanceId: opts.instanceId
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call modifyRdsWhiteList with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/ydRdsInstances/{instanceId}/whiteList',
|
||
'PUT',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 查看某个RDS实例下所有账号信息,包括账号名称、对各个数据库的访问权限信息等
|
||
* @param {Object} opts - parameters
|
||
* @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例
|
||
* @param {integer} [opts.pageNumber] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageNumber为-1时,返回所有数据页码;超过总页数时,显示最后一页; optional
|
||
* @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为100,取值范围:[10,100],用于查询列表的接口 optional
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
* @param account accounts
|
||
* @param integer totalCount
|
||
*/
|
||
|
||
describeRdsAccounts (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling describeRdsAccounts"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
if (opts.instanceId === undefined || opts.instanceId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.instanceId' when calling describeRdsAccounts"
|
||
)
|
||
}
|
||
|
||
let postBody = null
|
||
let queryParams = {}
|
||
if (opts.pageNumber !== undefined && opts.pageNumber !== null) {
|
||
queryParams['pageNumber'] = opts.pageNumber
|
||
}
|
||
if (opts.pageSize !== undefined && opts.pageSize !== null) {
|
||
queryParams['pageSize'] = opts.pageSize
|
||
}
|
||
|
||
let pathParams = {
|
||
regionId: regionId,
|
||
instanceId: opts.instanceId
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call describeRdsAccounts with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/ydRdsInstances/{instanceId}/accounts',
|
||
'GET',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 创建数据库账号,用户可以使用客户端,应用程序等通过该账号和密码登录RDS数据库实例。<br>为便于管理和恢复,RDS对账号进行了限制,数据库账号只能通过控制台或者OpenAPI进行创建、删除账号以及对账号授权等,用户不能通过SQL语句对账号进行相关操作。
|
||
* @param {Object} opts - parameters
|
||
* @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例
|
||
* @param {} opts.accountName - 账号名,在同一个RDS实例中,账号名不能重复。账号名的具体规则可参见帮助中心文档:[名称及密码限制](../../../documentation/Database-and-Cache-Service/RDS/Introduction/Restrictions/SQLServer-Restrictions.md)
|
||
* @param {} opts.accountPassword - 密码,密码的具体规则可参见帮助中心文档:[名称及密码限制](../../../documentation/Database-and-Cache-Service/RDS/Introduction/Restrictions/SQLServer-Restrictions.md)
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
*/
|
||
|
||
createRdsAccount (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling createRdsAccount"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
if (opts.instanceId === undefined || opts.instanceId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.instanceId' when calling createRdsAccount"
|
||
)
|
||
}
|
||
if (opts.accountName === undefined || opts.accountName === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.accountName' when calling createRdsAccount"
|
||
)
|
||
}
|
||
if (opts.accountPassword === undefined || opts.accountPassword === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.accountPassword' when calling createRdsAccount"
|
||
)
|
||
}
|
||
|
||
let postBody = {}
|
||
if (opts.accountName !== undefined && opts.accountName !== null) {
|
||
postBody['accountName'] = opts.accountName
|
||
}
|
||
if (opts.accountPassword !== undefined && opts.accountPassword !== null) {
|
||
postBody['accountPassword'] = opts.accountPassword
|
||
}
|
||
|
||
let queryParams = {}
|
||
|
||
let pathParams = {
|
||
regionId: regionId,
|
||
instanceId: opts.instanceId
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call createRdsAccount with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/ydRdsInstances/{instanceId}/accounts',
|
||
'POST',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 删除数据库账号,账号删除后不可恢复,用户无法再使用该账号登录RDS实例
|
||
* @param {Object} opts - parameters
|
||
* @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例
|
||
* @param {string} opts.accountName - 账号名,在同一个实例中账号名不能重复
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
*/
|
||
|
||
deleteRdsAccount (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling deleteRdsAccount"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
if (opts.instanceId === undefined || opts.instanceId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.instanceId' when calling deleteRdsAccount"
|
||
)
|
||
}
|
||
if (opts.accountName === undefined || opts.accountName === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.accountName' when calling deleteRdsAccount"
|
||
)
|
||
}
|
||
|
||
let postBody = null
|
||
let queryParams = {}
|
||
|
||
let pathParams = {
|
||
regionId: regionId,
|
||
instanceId: opts.instanceId,
|
||
accountName: opts.accountName
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call deleteRdsAccount with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/ydRdsInstances/{instanceId}/accounts/{accountName}',
|
||
'DELETE',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 授予账号的数据库访问权限,即该账号对数据库拥有什么权限。一个账号可以对多个数据库具有访问权限。<br>为便于管理,RDS对权限进行了归类,目前提供以下两种权限<br>- ro:只读权限,用户只能读取数据库中的数据,不能进行创建、插入、删除、更改等操作。<br>- rw:读写权限,用户可以对数据库进行增删改查等操作
|
||
* @param {Object} opts - parameters
|
||
* @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例
|
||
* @param {string} opts.accountName - 账号名,在同一个实例中账号名不能重复
|
||
* @param {array} opts.accountPrivileges - 账号的访问权限
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
*/
|
||
|
||
grantRdsPrivilege (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling grantRdsPrivilege"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
if (opts.instanceId === undefined || opts.instanceId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.instanceId' when calling grantRdsPrivilege"
|
||
)
|
||
}
|
||
if (opts.accountName === undefined || opts.accountName === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.accountName' when calling grantRdsPrivilege"
|
||
)
|
||
}
|
||
if (
|
||
opts.accountPrivileges === undefined ||
|
||
opts.accountPrivileges === null
|
||
) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.accountPrivileges' when calling grantRdsPrivilege"
|
||
)
|
||
}
|
||
|
||
let postBody = {}
|
||
if (
|
||
opts.accountPrivileges !== undefined &&
|
||
opts.accountPrivileges !== null
|
||
) {
|
||
postBody['accountPrivileges'] = opts.accountPrivileges
|
||
}
|
||
|
||
let queryParams = {}
|
||
|
||
let pathParams = {
|
||
regionId: regionId,
|
||
instanceId: opts.instanceId,
|
||
accountName: opts.accountName
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call grantRdsPrivilege with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/ydRdsInstances/{instanceId}/accounts/{accountName}:grantPrivilege',
|
||
'POST',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 取消该账号对某个数据库的所有权限。权限取消后,该账号将不能访问此数据库。取消账号对某个数据库的访问权限,不影响该账号对其他数据库的访问权限
|
||
* @param {Object} opts - parameters
|
||
* @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例
|
||
* @param {string} opts.accountName - 账号名,在同一个实例中账号名不能重复
|
||
* @param {array} [opts.dbNames] - 需要取消授权的数据库的名称。权限取消后,该账号将不能访问此数据库 optional
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
*/
|
||
|
||
revokePrivilege (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling revokePrivilege"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
if (opts.instanceId === undefined || opts.instanceId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.instanceId' when calling revokePrivilege"
|
||
)
|
||
}
|
||
if (opts.accountName === undefined || opts.accountName === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.accountName' when calling revokePrivilege"
|
||
)
|
||
}
|
||
|
||
let postBody = {}
|
||
if (opts.dbNames !== undefined && opts.dbNames !== null) {
|
||
postBody['dbNames'] = opts.dbNames
|
||
}
|
||
|
||
let queryParams = {}
|
||
|
||
let pathParams = {
|
||
regionId: regionId,
|
||
instanceId: opts.instanceId,
|
||
accountName: opts.accountName
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call revokePrivilege with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/ydRdsInstances/{instanceId}/accounts/{accountName}:revokePrivilege',
|
||
'POST',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 获取当前实例的所有数据库详细信息的列表
|
||
* @param {Object} opts - parameters
|
||
* @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例
|
||
* @param {string} [opts.dbName] - 数据库名。如果不指定数据库名,则返回所有数据库列表<br>- **MySQL:不支持该字段**<br>- **SQL Server:支持该字段** optional
|
||
* @param {integer} [opts.pageNumber] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageNumber为-1时,返回所有数据页码;超过总页数时,显示最后一页; optional
|
||
* @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为100,取值范围:[10,100],用于查询列表的接口 optional
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
* @param database databases
|
||
* @param integer totalCount
|
||
*/
|
||
|
||
describeRdsDatabases (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling describeRdsDatabases"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
if (opts.instanceId === undefined || opts.instanceId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.instanceId' when calling describeRdsDatabases"
|
||
)
|
||
}
|
||
|
||
let postBody = null
|
||
let queryParams = {}
|
||
if (opts.dbName !== undefined && opts.dbName !== null) {
|
||
queryParams['dbName'] = opts.dbName
|
||
}
|
||
if (opts.pageNumber !== undefined && opts.pageNumber !== null) {
|
||
queryParams['pageNumber'] = opts.pageNumber
|
||
}
|
||
if (opts.pageSize !== undefined && opts.pageSize !== null) {
|
||
queryParams['pageSize'] = opts.pageSize
|
||
}
|
||
|
||
let pathParams = {
|
||
regionId: regionId,
|
||
instanceId: opts.instanceId
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call describeRdsDatabases with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/ydRdsInstances/{instanceId}/databases',
|
||
'GET',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 创建一个数据库。 为了实例的管理和数据恢复,RDS对用户权限进行了限制,用户仅能通过控制台或本接口创建数据库
|
||
* @param {Object} opts - parameters
|
||
* @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例
|
||
* @param {} opts.dbName - 数据库名,数据库名称的限制请参考[帮助中心文档](../../../documentation/Database-and-Cache-Service/RDS/Introduction/Restrictions/SQLServer-Restrictions.md)
|
||
* @param {} opts.characterSetName - 数据库的字符集名,当前支持的字符集请查看[枚举参数定义](../Enum-Definitions/Enum-Definitions.md)
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
*/
|
||
|
||
createRdsDatabase (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling createRdsDatabase"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
if (opts.instanceId === undefined || opts.instanceId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.instanceId' when calling createRdsDatabase"
|
||
)
|
||
}
|
||
if (opts.dbName === undefined || opts.dbName === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.dbName' when calling createRdsDatabase"
|
||
)
|
||
}
|
||
if (opts.characterSetName === undefined || opts.characterSetName === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.characterSetName' when calling createRdsDatabase"
|
||
)
|
||
}
|
||
|
||
let postBody = {}
|
||
if (opts.dbName !== undefined && opts.dbName !== null) {
|
||
postBody['dbName'] = opts.dbName
|
||
}
|
||
if (opts.characterSetName !== undefined && opts.characterSetName !== null) {
|
||
postBody['characterSetName'] = opts.characterSetName
|
||
}
|
||
|
||
let queryParams = {}
|
||
|
||
let pathParams = {
|
||
regionId: regionId,
|
||
instanceId: opts.instanceId
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call createRdsDatabase with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/ydRdsInstances/{instanceId}/databases',
|
||
'POST',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 从RDS实例中删除数据库。为便于管理和数据恢复,RDS对用户权限进行了控制,用户仅能通过控制台或本接口删除数据库 [MFA enabled]
|
||
* @param {Object} opts - parameters
|
||
* @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例
|
||
* @param {string} opts.dbName - 库名称
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
*/
|
||
|
||
deleteRdsDatabase (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling deleteRdsDatabase"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
if (opts.instanceId === undefined || opts.instanceId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.instanceId' when calling deleteRdsDatabase"
|
||
)
|
||
}
|
||
if (opts.dbName === undefined || opts.dbName === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.dbName' when calling deleteRdsDatabase"
|
||
)
|
||
}
|
||
|
||
let postBody = null
|
||
let queryParams = {}
|
||
|
||
let pathParams = {
|
||
regionId: regionId,
|
||
instanceId: opts.instanceId,
|
||
dbName: opts.dbName
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call deleteRdsDatabase with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/ydRdsInstances/{instanceId}/databases/{dbName}',
|
||
'DELETE',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 查询云鼎数据库实例列表
|
||
|
||
* @param {Object} opts - parameters
|
||
* @param {string} opts.appKey - 应用appKey;
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
* @param rdsInstance clusters
|
||
* @param integer totalCount
|
||
*/
|
||
|
||
describeYdRdsInstances (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling describeYdRdsInstances"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
if (opts.appKey === undefined || opts.appKey === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.appKey' when calling describeYdRdsInstances"
|
||
)
|
||
}
|
||
|
||
let postBody = null
|
||
let queryParams = {}
|
||
if (opts.appKey !== undefined && opts.appKey !== null) {
|
||
queryParams['appKey'] = opts.appKey
|
||
}
|
||
|
||
let pathParams = {
|
||
regionId: regionId
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call describeYdRdsInstances with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/rdsInstances',
|
||
'GET',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 查询子网列表
|
||
* @param {Object} opts - parameters
|
||
* @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞), 页码超过总页数时, 显示最后一页 optional
|
||
* @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional
|
||
* @param {integer} [opts.type] - 子网类型,主机等资源子网:1;LB子网:2;数据库子网:3 optional
|
||
* @param {filter} [opts.filters] - subnetIds - subnet ID列表,支持多个
|
||
subnetNames - subnet名称列表,支持多个
|
||
routeTableId - 子网关联路由表Id,支持单个
|
||
aclId - 子网关联acl Id,支持单个
|
||
vpcId - 子网所属VPC Id,支持单个
|
||
optional
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
* @param subnet subnets
|
||
* @param number totalCount 总数量
|
||
*/
|
||
|
||
describeSubnets (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling describeSubnets"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
let postBody = null
|
||
let queryParams = {}
|
||
if (opts.pageNumber !== undefined && opts.pageNumber !== null) {
|
||
queryParams['pageNumber'] = opts.pageNumber
|
||
}
|
||
if (opts.pageSize !== undefined && opts.pageSize !== null) {
|
||
queryParams['pageSize'] = opts.pageSize
|
||
}
|
||
if (opts.type !== undefined && opts.type !== null) {
|
||
queryParams['type'] = opts.type
|
||
}
|
||
Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters'))
|
||
|
||
let pathParams = {
|
||
regionId: regionId
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call describeSubnets with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/ydSubnets/',
|
||
'GET',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 创建子网
|
||
* @param {Object} opts - parameters
|
||
* @param {string} opts.vpcId - 子网所属vpc的Id
|
||
* @param {string} opts.subnetName - 子网名称,只允许输入中文、数字、大小写字母、英文下划线“_”及中划线“-”,不允许为空且不超过32字符。
|
||
* @param {string} opts.addressPrefix - 子网网段,vpc内子网网段不能重叠,cidr的取值范围:10.0.0.0/8、172.16.0.0/12和192.168.0.0/16及它们包含的子网,且子网掩码长度为16-28之间,如果vpc含有cidr,则必须为vpc所在cidr的子网
|
||
* @param {string} [opts.routeTableId] - 子网关联的路由表Id, 默认为vpc的默认路由表,子网关联路由表需检查路由表中已绑定的子网与本子网类型是否一致(一致标准为:或者都为标准子网,或者都为相同边缘可用区的边缘子网) optional
|
||
* @param {string} [opts.description] - 子网描述信息,允许输入UTF-8编码下的全部字符,不超过256字符。 optional
|
||
* @param {integer} [opts.ipMaskLen] - 子网内预留网段掩码长度,此网段IP地址按照单个申请,子网内其余部分IP地址以网段形式分配。此参数非必选,缺省值为0,代表子网内所有IP地址都按照单个申请 optional
|
||
* @param {array} [opts.domainNames] - 域名后缀,不限制个数。总长度最长254个字符,仅支持字母,数字,中划线,下划线和点。 optional
|
||
* @param {array} [opts.domainNameServers] - 域名服务器地址。最多支持5个IPv4地址,不同IPv4地址使用逗号分隔。如不输入或输入空数组,默认使用京东云默认DNS域名服务器地址。如不添加默认DNS域名服务器,可能会导致您无法访问京东云云上基础服务,请谨慎操作 optional
|
||
* @param {boolean} [opts.dryRun] - 是否只预检此次请求。true:不会创建子网,只会对参数进行校验;false:正常的创建请求。默认为false。 optional
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
* @param string subnetId 子网ID
|
||
*/
|
||
|
||
createSubnet (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling createSubnet"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
if (opts.vpcId === undefined || opts.vpcId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.vpcId' when calling createSubnet"
|
||
)
|
||
}
|
||
if (opts.subnetName === undefined || opts.subnetName === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.subnetName' when calling createSubnet"
|
||
)
|
||
}
|
||
if (opts.addressPrefix === undefined || opts.addressPrefix === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.addressPrefix' when calling createSubnet"
|
||
)
|
||
}
|
||
|
||
let postBody = {}
|
||
if (opts.vpcId !== undefined && opts.vpcId !== null) {
|
||
postBody['vpcId'] = opts.vpcId
|
||
}
|
||
if (opts.subnetName !== undefined && opts.subnetName !== null) {
|
||
postBody['subnetName'] = opts.subnetName
|
||
}
|
||
if (opts.addressPrefix !== undefined && opts.addressPrefix !== null) {
|
||
postBody['addressPrefix'] = opts.addressPrefix
|
||
}
|
||
if (opts.routeTableId !== undefined && opts.routeTableId !== null) {
|
||
postBody['routeTableId'] = opts.routeTableId
|
||
}
|
||
if (opts.description !== undefined && opts.description !== null) {
|
||
postBody['description'] = opts.description
|
||
}
|
||
if (opts.ipMaskLen !== undefined && opts.ipMaskLen !== null) {
|
||
postBody['ipMaskLen'] = opts.ipMaskLen
|
||
}
|
||
if (opts.domainNames !== undefined && opts.domainNames !== null) {
|
||
postBody['domainNames'] = opts.domainNames
|
||
}
|
||
if (
|
||
opts.domainNameServers !== undefined &&
|
||
opts.domainNameServers !== null
|
||
) {
|
||
postBody['domainNameServers'] = opts.domainNameServers
|
||
}
|
||
if (opts.dryRun !== undefined && opts.dryRun !== null) {
|
||
postBody['dryRun'] = opts.dryRun
|
||
}
|
||
|
||
let queryParams = {}
|
||
|
||
let pathParams = {
|
||
regionId: regionId
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call createSubnet with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/ydSubnets/',
|
||
'POST',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 查询子网信息详情
|
||
* @param {Object} opts - parameters
|
||
* @param {string} opts.subnetId - Subnet ID
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
* @param subnet subnet 子网资源信息
|
||
*/
|
||
|
||
describeSubnet (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling describeSubnet"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
if (opts.subnetId === undefined || opts.subnetId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.subnetId' when calling describeSubnet"
|
||
)
|
||
}
|
||
|
||
let postBody = null
|
||
let queryParams = {}
|
||
|
||
let pathParams = {
|
||
regionId: regionId,
|
||
subnetId: opts.subnetId
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call describeSubnet with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/ydSubnets/{subnetId}',
|
||
'GET',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 删除子网
|
||
* @param {Object} opts - parameters
|
||
* @param {string} opts.subnetId - Subnet ID
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
*/
|
||
|
||
deleteSubnet (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling deleteSubnet"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
if (opts.subnetId === undefined || opts.subnetId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.subnetId' when calling deleteSubnet"
|
||
)
|
||
}
|
||
|
||
let postBody = null
|
||
let queryParams = {}
|
||
|
||
let pathParams = {
|
||
regionId: regionId,
|
||
subnetId: opts.subnetId
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call deleteSubnet with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/ydSubnets/{subnetId}',
|
||
'DELETE',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 批量查询云主机列表信息<br>此接口支持分页查询,默认每页20条。
|
||
* @param {Object} opts - parameters
|
||
* @param {integer} [opts.pageNumber] - 页码;默认为1 optional
|
||
* @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 100] optional
|
||
* @param {filter} [opts.filters] - instanceId - 云主机ID,精确匹配,支持多个
|
||
privateIpAddress - 主网卡内网主IP地址,模糊匹配,支持多个
|
||
az - 可用区,精确匹配,支持多个
|
||
vpcId - 私有网络ID,精确匹配,支持多个
|
||
status - 云主机状态,精确匹配,支持多个,<a href="http://docs.jdcloud.com/virtual-machines/api/vm_status">参考云主机状态</a>
|
||
name - 云主机名称,模糊匹配,支持单个
|
||
imageId - 镜像ID,精确匹配,支持多个
|
||
networkInterfaceId - 弹性网卡ID,精确匹配,支持多个
|
||
subnetId - 子网ID,精确匹配,支持多个
|
||
agId - 使用可用组id,支持单个
|
||
faultDomain - 错误域,支持多个
|
||
optional
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
* @param instance instances
|
||
* @param number totalCount
|
||
*/
|
||
|
||
describeVmInstances (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling describeVmInstances"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
let postBody = null
|
||
let queryParams = {}
|
||
if (opts.pageNumber !== undefined && opts.pageNumber !== null) {
|
||
queryParams['pageNumber'] = opts.pageNumber
|
||
}
|
||
if (opts.pageSize !== undefined && opts.pageSize !== null) {
|
||
queryParams['pageSize'] = opts.pageSize
|
||
}
|
||
Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters'))
|
||
|
||
let pathParams = {
|
||
regionId: regionId
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call describeVmInstances with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/ydVmInstances',
|
||
'GET',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 查询一台云主机的详细信息
|
||
* @param {Object} opts - parameters
|
||
* @param {string} opts.instanceId - 云主机ID
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
* @param instance instance
|
||
*/
|
||
|
||
describeVmInstance (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling describeVmInstance"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
if (opts.instanceId === undefined || opts.instanceId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.instanceId' when calling describeVmInstance"
|
||
)
|
||
}
|
||
|
||
let postBody = null
|
||
let queryParams = {}
|
||
|
||
let pathParams = {
|
||
regionId: regionId,
|
||
instanceId: opts.instanceId
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call describeVmInstance with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/ydVmInstances/{instanceId}',
|
||
'GET',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 云主机绑定一块弹性网卡。<br>
|
||
云主机状态必须为<b>running</b>或<b>stopped</b>状态,并且没有正在进行中的任务才可操作。<br>
|
||
弹性网卡上如果绑定了弹性公网IP,那么其所在az需要与云主机的az保持一致,或者为全可用区型弹性公网IP,才可挂载该网卡。<br>
|
||
云主机挂载弹性网卡的数量,不能超过实例规格的限制。可查询<a href="http://docs.jdcloud.com/virtual-machines/api/describeinstancetypes">DescribeInstanceTypes</a>接口获得指定规格可挂载弹性网卡的数量上限。<br>
|
||
弹性网卡与云主机必须在相同vpc下。
|
||
|
||
* @param {Object} opts - parameters
|
||
* @param {string} opts.instanceId - 云主机ID
|
||
* @param {string} opts.networkInterfaceId - 弹性网卡ID
|
||
* @param {boolean} [opts.autoDelete] - 随云主机删除而自动删除,默认为False optional
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
*/
|
||
|
||
attachNetworkInterface (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling attachNetworkInterface"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
if (opts.instanceId === undefined || opts.instanceId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.instanceId' when calling attachNetworkInterface"
|
||
)
|
||
}
|
||
if (
|
||
opts.networkInterfaceId === undefined ||
|
||
opts.networkInterfaceId === null
|
||
) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.networkInterfaceId' when calling attachNetworkInterface"
|
||
)
|
||
}
|
||
|
||
let postBody = {}
|
||
if (
|
||
opts.networkInterfaceId !== undefined &&
|
||
opts.networkInterfaceId !== null
|
||
) {
|
||
postBody['networkInterfaceId'] = opts.networkInterfaceId
|
||
}
|
||
if (opts.autoDelete !== undefined && opts.autoDelete !== null) {
|
||
postBody['autoDelete'] = opts.autoDelete
|
||
}
|
||
|
||
let queryParams = {}
|
||
|
||
let pathParams = {
|
||
regionId: regionId,
|
||
instanceId: opts.instanceId
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call attachNetworkInterface with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/ydVmInstances/{instanceId}:attachNetworkInterface',
|
||
'POST',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
|
||
/**
|
||
* 云主机缷载一块弹性网卡。<br>
|
||
云主机状态必须为<b>running</b>或<b>stopped</b>状态,并且没有正在进行中的任务才可操作。<br>
|
||
不能缷载主网卡。
|
||
|
||
* @param {Object} opts - parameters
|
||
* @param {string} opts.instanceId - 云主机ID
|
||
* @param {string} opts.networkInterfaceId - 弹性网卡ID
|
||
* @param {string} regionId - ID of the region
|
||
* @param {string} callback - callback
|
||
@return {Object} result
|
||
*/
|
||
|
||
detachNetworkInterface (opts, regionId = this.config.regionId, callback) {
|
||
if (typeof regionId === 'function') {
|
||
callback = regionId
|
||
regionId = this.config.regionId
|
||
}
|
||
|
||
if (regionId === undefined || regionId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'regionId' when calling detachNetworkInterface"
|
||
)
|
||
}
|
||
|
||
opts = opts || {}
|
||
|
||
if (opts.instanceId === undefined || opts.instanceId === null) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.instanceId' when calling detachNetworkInterface"
|
||
)
|
||
}
|
||
if (
|
||
opts.networkInterfaceId === undefined ||
|
||
opts.networkInterfaceId === null
|
||
) {
|
||
throw new Error(
|
||
"Missing the required parameter 'opts.networkInterfaceId' when calling detachNetworkInterface"
|
||
)
|
||
}
|
||
|
||
let postBody = {}
|
||
if (
|
||
opts.networkInterfaceId !== undefined &&
|
||
opts.networkInterfaceId !== null
|
||
) {
|
||
postBody['networkInterfaceId'] = opts.networkInterfaceId
|
||
}
|
||
|
||
let queryParams = {}
|
||
|
||
let pathParams = {
|
||
regionId: regionId,
|
||
instanceId: opts.instanceId
|
||
}
|
||
|
||
let headerParams = {
|
||
'User-Agent': 'JdcloudSdkNode/1.0.0 yunding/2.0.8'
|
||
}
|
||
|
||
let contentTypes = ['application/json']
|
||
let accepts = ['application/json']
|
||
|
||
// 扩展自定义头
|
||
if (opts['x-extra-header']) {
|
||
for (let extraHeader in opts['x-extra-header']) {
|
||
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['content-type'])) {
|
||
contentTypes = opts['x-extra-header']['content-type']
|
||
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
|
||
contentTypes = opts['x-extra-header']['content-type'].split(',')
|
||
}
|
||
|
||
if (Array.isArray(opts['x-extra-header']['accept'])) {
|
||
accepts = opts['x-extra-header']['accept']
|
||
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
|
||
accepts = opts['x-extra-header']['accept'].split(',')
|
||
}
|
||
}
|
||
|
||
let formParams = {}
|
||
|
||
let returnType = null
|
||
|
||
this.config.logger(
|
||
`call detachNetworkInterface with params:\npathParams:${JSON.stringify(
|
||
pathParams
|
||
)},\nqueryParams:${JSON.stringify(
|
||
queryParams
|
||
)}, \nheaderParams:${JSON.stringify(
|
||
headerParams
|
||
)}, \nformParams:${JSON.stringify(
|
||
formParams
|
||
)}, \npostBody:${JSON.stringify(postBody)}`,
|
||
'DEBUG'
|
||
)
|
||
|
||
let request = super.makeRequest(
|
||
'/regions/{regionId}/ydVmInstances/{instanceId}:detachNetworkInterface',
|
||
'POST',
|
||
pathParams,
|
||
queryParams,
|
||
headerParams,
|
||
formParams,
|
||
postBody,
|
||
contentTypes,
|
||
accepts,
|
||
returnType,
|
||
callback
|
||
)
|
||
|
||
return request.then(
|
||
function (result) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(null, result)
|
||
}
|
||
return result
|
||
},
|
||
function (error) {
|
||
if (callback && typeof callback === 'function') {
|
||
return callback(error)
|
||
}
|
||
return Promise.reject(error)
|
||
}
|
||
)
|
||
}
|
||
}
|
||
module.exports = YUNDING
|