mirror of
https://github.com/certd/certd.git
synced 2026-07-10 23:27:34 +08:00
2313 lines
67 KiB
JavaScript
2313 lines
67 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.
|
|
*
|
|
* GPU-Computing-Service
|
|
* GPU算力服务网盘相关的接口
|
|
*
|
|
* OpenAPI spec version: v1
|
|
* 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 = 'gcs'
|
|
Service._services[serviceId] = true
|
|
|
|
/**
|
|
* gcs service.
|
|
* @version 1.0.1
|
|
*/
|
|
|
|
class GCS extends Service {
|
|
constructor (options = {}) {
|
|
options._defaultEndpoint = {}
|
|
options._defaultEndpoint.protocol =
|
|
options._defaultEndpoint.protocol || 'https'
|
|
options._defaultEndpoint.host =
|
|
options._defaultEndpoint.host || 'gcs.jdcloud-api.com'
|
|
options.basePath = '/v1' // 默认要设为空""
|
|
super(serviceId, options)
|
|
}
|
|
|
|
/**
|
|
* 查询作品列表
|
|
* @param {Object} opts - parameters
|
|
* @param {integer} [opts.pageNumber] - 页码;默认为1 optional
|
|
* @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[20, 100] optional
|
|
* @param {filter} [opts.filters] - artId 作品ID,精确匹配,支持多个
|
|
optional
|
|
* @param {string} callback - callback
|
|
@return {Object} result
|
|
* @param art arts
|
|
* @param integer pageNumber 页码;默认为1
|
|
* @param integer pageSize 分页大小;默认为20;取值范围[20, 100]
|
|
* @param integer totalCount 查询结果总数
|
|
*/
|
|
|
|
describeArts (opts, callback) {
|
|
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: 'jdcloud'
|
|
}
|
|
|
|
let headerParams = {
|
|
'User-Agent': 'JdcloudSdkNode/1.0.0 gcs/1.0.1'
|
|
}
|
|
|
|
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 describeArts 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(
|
|
'/arts',
|
|
'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.artId - 作品ID
|
|
* @param {string} callback - callback
|
|
@return {Object} result
|
|
* @param art art 作品详细信息
|
|
*/
|
|
|
|
describeArt (opts, callback) {
|
|
opts = opts || {}
|
|
|
|
if (opts.artId === undefined || opts.artId === null) {
|
|
throw new Error(
|
|
"Missing the required parameter 'opts.artId' when calling describeArt"
|
|
)
|
|
}
|
|
|
|
let postBody = null
|
|
let queryParams = {}
|
|
|
|
let pathParams = {
|
|
regionId: 'jdcloud',
|
|
artId: opts.artId
|
|
}
|
|
|
|
let headerParams = {
|
|
'User-Agent': 'JdcloudSdkNode/1.0.0 gcs/1.0.1'
|
|
}
|
|
|
|
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 describeArt 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(
|
|
'/arts/{artId}',
|
|
'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.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/>
|
|
如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/>
|
|
optional
|
|
* @param {string} opts.instanceId - 实例ID
|
|
* @param {string} opts.instanceName - nick name,用户自定义
|
|
* @param {string} regionId - ID of the region
|
|
* @param {string} callback - callback
|
|
@return {Object} result
|
|
* @param boolean success 操作是否成功
|
|
*/
|
|
|
|
modifyInstance (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 modifyInstance"
|
|
)
|
|
}
|
|
|
|
opts = opts || {}
|
|
|
|
if (opts.instanceId === undefined || opts.instanceId === null) {
|
|
throw new Error(
|
|
"Missing the required parameter 'opts.instanceId' when calling modifyInstance"
|
|
)
|
|
}
|
|
if (opts.instanceName === undefined || opts.instanceName === null) {
|
|
throw new Error(
|
|
"Missing the required parameter 'opts.instanceName' when calling modifyInstance"
|
|
)
|
|
}
|
|
|
|
let postBody = {}
|
|
if (opts.clientToken !== undefined && opts.clientToken !== null) {
|
|
postBody['clientToken'] = opts.clientToken
|
|
}
|
|
if (opts.instanceId !== undefined && opts.instanceId !== null) {
|
|
postBody['instanceId'] = opts.instanceId
|
|
}
|
|
if (opts.instanceName !== undefined && opts.instanceName !== null) {
|
|
postBody['instanceName'] = opts.instanceName
|
|
}
|
|
|
|
let queryParams = {}
|
|
|
|
let pathParams = {
|
|
regionId: regionId
|
|
}
|
|
|
|
let headerParams = {
|
|
'User-Agent': 'JdcloudSdkNode/1.0.0 gcs/1.0.1'
|
|
}
|
|
|
|
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 modifyInstance 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}/modifyInstance',
|
|
'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)
|
|
}
|
|
)
|
|
}
|
|
|
|
/**
|
|
* 创建多个GPU容器实例
|
|
* @param {Object} opts - parameters
|
|
* @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/>
|
|
如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/>
|
|
optional
|
|
* @param {instanceSpec} opts.instanceSpec - GPU容器实例配置
|
|
* @param {string} regionId - ID of the region
|
|
* @param {string} callback - callback
|
|
@return {Object} result
|
|
* @param string instanceIds
|
|
* @param string buyId 和instanceIds不会同时有值
|
|
*/
|
|
|
|
createInstances (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 createInstances"
|
|
)
|
|
}
|
|
|
|
opts = opts || {}
|
|
|
|
if (opts.instanceSpec === undefined || opts.instanceSpec === null) {
|
|
throw new Error(
|
|
"Missing the required parameter 'opts.instanceSpec' when calling createInstances"
|
|
)
|
|
}
|
|
|
|
let postBody = {}
|
|
if (opts.clientToken !== undefined && opts.clientToken !== null) {
|
|
postBody['clientToken'] = opts.clientToken
|
|
}
|
|
if (opts.instanceSpec !== undefined && opts.instanceSpec !== null) {
|
|
postBody['instanceSpec'] = opts.instanceSpec
|
|
}
|
|
|
|
let queryParams = {}
|
|
|
|
let pathParams = {
|
|
regionId: regionId
|
|
}
|
|
|
|
let headerParams = {
|
|
'User-Agent': 'JdcloudSdkNode/1.0.0 gcs/1.0.1'
|
|
}
|
|
|
|
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 createInstances 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}/createInstances',
|
|
'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)
|
|
}
|
|
)
|
|
}
|
|
|
|
/**
|
|
* 查询GPU容器实例列表
|
|
* @param {Object} opts - parameters
|
|
* @param {integer} [opts.pageNumber] - 页码;默认为1 optional
|
|
* @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[20, 100] optional
|
|
* @param {string} [opts.az] - 可用区 optional
|
|
* @param {string} [opts.namespace] - 名称空间 optional
|
|
* @param {string} [opts.instanceId] - gcs uuid optional
|
|
* @param {string} [opts.instanceName] - 实例名称 optional
|
|
* @param {string} [opts.status] - 运行状态:running|stopped|creating optional
|
|
* @param {string} [opts.channel] - 订单渠道:aidc(默认)|yunding optional
|
|
* @param {string} [opts.ids] - instance id list 逗号分隔 optional
|
|
* @param {filter} [opts.filters] - 容器实例ID,精确匹配,支持多个
|
|
optional
|
|
* @param {string} regionId - ID of the region
|
|
* @param {string} callback - callback
|
|
@return {Object} result
|
|
* @param instance list
|
|
* @param integer pageNumber 页码;默认为1
|
|
* @param integer pageSize 分页大小;默认为20;取值范围[20, 100]
|
|
* @param integer totalCount 查询结果总数
|
|
*/
|
|
|
|
describeInstances (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 describeInstances"
|
|
)
|
|
}
|
|
|
|
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.az !== undefined && opts.az !== null) {
|
|
queryParams['az'] = opts.az
|
|
}
|
|
if (opts.namespace !== undefined && opts.namespace !== null) {
|
|
queryParams['namespace'] = opts.namespace
|
|
}
|
|
if (opts.instanceId !== undefined && opts.instanceId !== null) {
|
|
queryParams['instanceId'] = opts.instanceId
|
|
}
|
|
if (opts.instanceName !== undefined && opts.instanceName !== null) {
|
|
queryParams['instanceName'] = opts.instanceName
|
|
}
|
|
if (opts.status !== undefined && opts.status !== null) {
|
|
queryParams['status'] = opts.status
|
|
}
|
|
if (opts.channel !== undefined && opts.channel !== null) {
|
|
queryParams['channel'] = opts.channel
|
|
}
|
|
if (opts.ids !== undefined && opts.ids !== null) {
|
|
queryParams['ids'] = opts.ids
|
|
}
|
|
Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters'))
|
|
|
|
let pathParams = {
|
|
regionId: regionId
|
|
}
|
|
|
|
let headerParams = {
|
|
'User-Agent': 'JdcloudSdkNode/1.0.0 gcs/1.0.1'
|
|
}
|
|
|
|
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 describeInstances 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}/describeInstances',
|
|
'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)
|
|
}
|
|
)
|
|
}
|
|
|
|
/**
|
|
* 查询GPU容器实例详情
|
|
* @param {Object} opts - parameters
|
|
* @param {string} [opts.instanceId] - 实例ID optional
|
|
* @param {string} regionId - ID of the region
|
|
* @param {string} callback - callback
|
|
@return {Object} result
|
|
* @param instance instance GPU容器实例详细信息
|
|
*/
|
|
|
|
describeInstance (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 describeInstance"
|
|
)
|
|
}
|
|
|
|
opts = opts || {}
|
|
|
|
let postBody = null
|
|
let queryParams = {}
|
|
if (opts.instanceId !== undefined && opts.instanceId !== null) {
|
|
queryParams['instanceId'] = opts.instanceId
|
|
}
|
|
|
|
let pathParams = {
|
|
regionId: regionId
|
|
}
|
|
|
|
let headerParams = {
|
|
'User-Agent': 'JdcloudSdkNode/1.0.0 gcs/1.0.1'
|
|
}
|
|
|
|
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 describeInstance 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}/describeInstance',
|
|
'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)
|
|
}
|
|
)
|
|
}
|
|
|
|
/**
|
|
* 彻底删除一个GPU容器实例,包含其相关的一切资源配置信息
|
|
* @param {Object} opts - parameters
|
|
* @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/>
|
|
如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/>
|
|
optional
|
|
* @param {string} [opts.instanceId] - 实例ID optional
|
|
* @param {string} regionId - ID of the region
|
|
* @param {string} callback - callback
|
|
@return {Object} result
|
|
* @param boolean success 删除操作是否成功
|
|
*/
|
|
|
|
deleteInstance (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 deleteInstance"
|
|
)
|
|
}
|
|
|
|
opts = opts || {}
|
|
|
|
let postBody = null
|
|
let queryParams = {}
|
|
if (opts.clientToken !== undefined && opts.clientToken !== null) {
|
|
queryParams['clientToken'] = opts.clientToken
|
|
}
|
|
if (opts.instanceId !== undefined && opts.instanceId !== null) {
|
|
queryParams['instanceId'] = opts.instanceId
|
|
}
|
|
|
|
let pathParams = {
|
|
regionId: regionId
|
|
}
|
|
|
|
let headerParams = {
|
|
'User-Agent': 'JdcloudSdkNode/1.0.0 gcs/1.0.1'
|
|
}
|
|
|
|
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 deleteInstance 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}/deleteInstance',
|
|
'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.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/>
|
|
如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/>
|
|
optional
|
|
* @param {string} opts.instanceId - 实例ID
|
|
* @param {string} regionId - ID of the region
|
|
* @param {string} callback - callback
|
|
@return {Object} result
|
|
* @param boolean success 操作是否成功
|
|
*/
|
|
|
|
startInstance (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 startInstance"
|
|
)
|
|
}
|
|
|
|
opts = opts || {}
|
|
|
|
if (opts.instanceId === undefined || opts.instanceId === null) {
|
|
throw new Error(
|
|
"Missing the required parameter 'opts.instanceId' when calling startInstance"
|
|
)
|
|
}
|
|
|
|
let postBody = {}
|
|
if (opts.clientToken !== undefined && opts.clientToken !== null) {
|
|
postBody['clientToken'] = opts.clientToken
|
|
}
|
|
if (opts.instanceId !== undefined && opts.instanceId !== null) {
|
|
postBody['instanceId'] = opts.instanceId
|
|
}
|
|
|
|
let queryParams = {}
|
|
|
|
let pathParams = {
|
|
regionId: regionId
|
|
}
|
|
|
|
let headerParams = {
|
|
'User-Agent': 'JdcloudSdkNode/1.0.0 gcs/1.0.1'
|
|
}
|
|
|
|
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 startInstance 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}/startInstance',
|
|
'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.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/>
|
|
如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/>
|
|
optional
|
|
* @param {string} opts.instanceId - 实例ID
|
|
* @param {string} [opts.operType] - 操作类型,定时关机 timer optional
|
|
* @param {string} regionId - ID of the region
|
|
* @param {string} callback - callback
|
|
@return {Object} result
|
|
* @param boolean success 操作是否成功
|
|
*/
|
|
|
|
stopInstance (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 stopInstance"
|
|
)
|
|
}
|
|
|
|
opts = opts || {}
|
|
|
|
if (opts.instanceId === undefined || opts.instanceId === null) {
|
|
throw new Error(
|
|
"Missing the required parameter 'opts.instanceId' when calling stopInstance"
|
|
)
|
|
}
|
|
|
|
let postBody = {}
|
|
if (opts.clientToken !== undefined && opts.clientToken !== null) {
|
|
postBody['clientToken'] = opts.clientToken
|
|
}
|
|
if (opts.instanceId !== undefined && opts.instanceId !== null) {
|
|
postBody['instanceId'] = opts.instanceId
|
|
}
|
|
if (opts.operType !== undefined && opts.operType !== null) {
|
|
postBody['operType'] = opts.operType
|
|
}
|
|
|
|
let queryParams = {}
|
|
|
|
let pathParams = {
|
|
regionId: regionId
|
|
}
|
|
|
|
let headerParams = {
|
|
'User-Agent': 'JdcloudSdkNode/1.0.0 gcs/1.0.1'
|
|
}
|
|
|
|
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 stopInstance 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}/stopInstance',
|
|
'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.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/>
|
|
如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/>
|
|
optional
|
|
* @param {string} opts.instanceId - 实例ID
|
|
* @param {string} opts.chargeItem - 山海计费项
|
|
* @param {string} regionId - ID of the region
|
|
* @param {string} callback - callback
|
|
@return {Object} result
|
|
* @param boolean success 操作是否成功
|
|
*/
|
|
|
|
modifyInstanceSpec (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 modifyInstanceSpec"
|
|
)
|
|
}
|
|
|
|
opts = opts || {}
|
|
|
|
if (opts.instanceId === undefined || opts.instanceId === null) {
|
|
throw new Error(
|
|
"Missing the required parameter 'opts.instanceId' when calling modifyInstanceSpec"
|
|
)
|
|
}
|
|
if (opts.chargeItem === undefined || opts.chargeItem === null) {
|
|
throw new Error(
|
|
"Missing the required parameter 'opts.chargeItem' when calling modifyInstanceSpec"
|
|
)
|
|
}
|
|
|
|
let postBody = {}
|
|
if (opts.clientToken !== undefined && opts.clientToken !== null) {
|
|
postBody['clientToken'] = opts.clientToken
|
|
}
|
|
if (opts.instanceId !== undefined && opts.instanceId !== null) {
|
|
postBody['instanceId'] = opts.instanceId
|
|
}
|
|
if (opts.chargeItem !== undefined && opts.chargeItem !== null) {
|
|
postBody['chargeItem'] = opts.chargeItem
|
|
}
|
|
|
|
let queryParams = {}
|
|
|
|
let pathParams = {
|
|
regionId: regionId
|
|
}
|
|
|
|
let headerParams = {
|
|
'User-Agent': 'JdcloudSdkNode/1.0.0 gcs/1.0.1'
|
|
}
|
|
|
|
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 modifyInstanceSpec 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}/modifyInstanceSpec',
|
|
'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.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/>
|
|
如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/>
|
|
optional
|
|
* @param {string} opts.instanceId - 实例ID
|
|
* @param {string} opts.stopTime - 关机时间,格式:2024-09-04 14:22:00
|
|
* @param {string} regionId - ID of the region
|
|
* @param {string} callback - callback
|
|
@return {Object} result
|
|
* @param boolean success 操作是否成功
|
|
*/
|
|
|
|
stopInstanceTimer (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 stopInstanceTimer"
|
|
)
|
|
}
|
|
|
|
opts = opts || {}
|
|
|
|
if (opts.instanceId === undefined || opts.instanceId === null) {
|
|
throw new Error(
|
|
"Missing the required parameter 'opts.instanceId' when calling stopInstanceTimer"
|
|
)
|
|
}
|
|
if (opts.stopTime === undefined || opts.stopTime === null) {
|
|
throw new Error(
|
|
"Missing the required parameter 'opts.stopTime' when calling stopInstanceTimer"
|
|
)
|
|
}
|
|
|
|
let postBody = {}
|
|
if (opts.clientToken !== undefined && opts.clientToken !== null) {
|
|
postBody['clientToken'] = opts.clientToken
|
|
}
|
|
if (opts.instanceId !== undefined && opts.instanceId !== null) {
|
|
postBody['instanceId'] = opts.instanceId
|
|
}
|
|
if (opts.stopTime !== undefined && opts.stopTime !== null) {
|
|
postBody['stopTime'] = opts.stopTime
|
|
}
|
|
|
|
let queryParams = {}
|
|
|
|
let pathParams = {
|
|
regionId: regionId
|
|
}
|
|
|
|
let headerParams = {
|
|
'User-Agent': 'JdcloudSdkNode/1.0.0 gcs/1.0.1'
|
|
}
|
|
|
|
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 stopInstanceTimer 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}/stopInstanceTimer',
|
|
'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.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/>
|
|
如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/>
|
|
optional
|
|
* @param {string} opts.instanceId - 实例ID
|
|
* @param {string} regionId - ID of the region
|
|
* @param {string} callback - callback
|
|
@return {Object} result
|
|
* @param boolean success 操作是否成功
|
|
*/
|
|
|
|
stopInstanceTimerCancle (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 stopInstanceTimerCancle"
|
|
)
|
|
}
|
|
|
|
opts = opts || {}
|
|
|
|
if (opts.instanceId === undefined || opts.instanceId === null) {
|
|
throw new Error(
|
|
"Missing the required parameter 'opts.instanceId' when calling stopInstanceTimerCancle"
|
|
)
|
|
}
|
|
|
|
let postBody = {}
|
|
if (opts.clientToken !== undefined && opts.clientToken !== null) {
|
|
postBody['clientToken'] = opts.clientToken
|
|
}
|
|
if (opts.instanceId !== undefined && opts.instanceId !== null) {
|
|
postBody['instanceId'] = opts.instanceId
|
|
}
|
|
|
|
let queryParams = {}
|
|
|
|
let pathParams = {
|
|
regionId: regionId
|
|
}
|
|
|
|
let headerParams = {
|
|
'User-Agent': 'JdcloudSdkNode/1.0.0 gcs/1.0.1'
|
|
}
|
|
|
|
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 stopInstanceTimerCancle 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}/stopInstanceTimerCancle',
|
|
'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.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/>
|
|
如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/>
|
|
optional
|
|
* @param {string} opts.instanceId - 实例ID
|
|
* @param {string} opts.az - az
|
|
* @param {string} opts.password - 新密码,为空则自动生成10位随机字符串
|
|
* @param {string} regionId - ID of the region
|
|
* @param {string} callback - callback
|
|
@return {Object} result
|
|
* @param boolean success 操作是否成功
|
|
*/
|
|
|
|
modifyInstanceSecret (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 modifyInstanceSecret"
|
|
)
|
|
}
|
|
|
|
opts = opts || {}
|
|
|
|
if (opts.instanceId === undefined || opts.instanceId === null) {
|
|
throw new Error(
|
|
"Missing the required parameter 'opts.instanceId' when calling modifyInstanceSecret"
|
|
)
|
|
}
|
|
if (opts.az === undefined || opts.az === null) {
|
|
throw new Error(
|
|
"Missing the required parameter 'opts.az' when calling modifyInstanceSecret"
|
|
)
|
|
}
|
|
if (opts.password === undefined || opts.password === null) {
|
|
throw new Error(
|
|
"Missing the required parameter 'opts.password' when calling modifyInstanceSecret"
|
|
)
|
|
}
|
|
|
|
let postBody = {}
|
|
if (opts.clientToken !== undefined && opts.clientToken !== null) {
|
|
postBody['clientToken'] = opts.clientToken
|
|
}
|
|
if (opts.instanceId !== undefined && opts.instanceId !== null) {
|
|
postBody['instanceId'] = opts.instanceId
|
|
}
|
|
if (opts.az !== undefined && opts.az !== null) {
|
|
postBody['az'] = opts.az
|
|
}
|
|
if (opts.password !== undefined && opts.password !== null) {
|
|
postBody['password'] = opts.password
|
|
}
|
|
|
|
let queryParams = {}
|
|
|
|
let pathParams = {
|
|
regionId: regionId
|
|
}
|
|
|
|
let headerParams = {
|
|
'User-Agent': 'JdcloudSdkNode/1.0.0 gcs/1.0.1'
|
|
}
|
|
|
|
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 modifyInstanceSecret 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}/modifyInstanceSecret',
|
|
'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.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/>
|
|
如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/>
|
|
optional
|
|
* @param {string} opts.instanceId - 实例ID
|
|
* @param {string} opts.imageId - 镜像ID
|
|
* @param {string} regionId - ID of the region
|
|
* @param {string} callback - callback
|
|
@return {Object} result
|
|
* @param boolean success 操作是否成功
|
|
*/
|
|
|
|
modifyInstanceImage (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 modifyInstanceImage"
|
|
)
|
|
}
|
|
|
|
opts = opts || {}
|
|
|
|
if (opts.instanceId === undefined || opts.instanceId === null) {
|
|
throw new Error(
|
|
"Missing the required parameter 'opts.instanceId' when calling modifyInstanceImage"
|
|
)
|
|
}
|
|
if (opts.imageId === undefined || opts.imageId === null) {
|
|
throw new Error(
|
|
"Missing the required parameter 'opts.imageId' when calling modifyInstanceImage"
|
|
)
|
|
}
|
|
|
|
let postBody = {}
|
|
if (opts.clientToken !== undefined && opts.clientToken !== null) {
|
|
postBody['clientToken'] = opts.clientToken
|
|
}
|
|
if (opts.instanceId !== undefined && opts.instanceId !== null) {
|
|
postBody['instanceId'] = opts.instanceId
|
|
}
|
|
if (opts.imageId !== undefined && opts.imageId !== null) {
|
|
postBody['imageId'] = opts.imageId
|
|
}
|
|
|
|
let queryParams = {}
|
|
|
|
let pathParams = {
|
|
regionId: regionId
|
|
}
|
|
|
|
let headerParams = {
|
|
'User-Agent': 'JdcloudSdkNode/1.0.0 gcs/1.0.1'
|
|
}
|
|
|
|
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 modifyInstanceImage 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}/modifyInstanceImage',
|
|
'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] - GCS系统资源实例ID optional
|
|
* @param {string} [opts.orderNumber] - 主订单编号 optional
|
|
* @param {string} [opts.subOrderNumber] - 子订单编号 optional
|
|
* @param {string} [opts.orderType] - 订单类型:1-新购|2-续费|3-配置变更 optional
|
|
* @param {string} [opts.taskId] - 主单打包id号 optional
|
|
* @param {string} regionId - ID of the region
|
|
* @param {string} callback - callback
|
|
@return {Object} result
|
|
* @param orderInfo list
|
|
*/
|
|
|
|
describeOrderInfos (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 describeOrderInfos"
|
|
)
|
|
}
|
|
|
|
opts = opts || {}
|
|
|
|
let postBody = null
|
|
let queryParams = {}
|
|
if (opts.instanceId !== undefined && opts.instanceId !== null) {
|
|
queryParams['instanceId'] = opts.instanceId
|
|
}
|
|
if (opts.orderNumber !== undefined && opts.orderNumber !== null) {
|
|
queryParams['orderNumber'] = opts.orderNumber
|
|
}
|
|
if (opts.subOrderNumber !== undefined && opts.subOrderNumber !== null) {
|
|
queryParams['subOrderNumber'] = opts.subOrderNumber
|
|
}
|
|
if (opts.orderType !== undefined && opts.orderType !== null) {
|
|
queryParams['orderType'] = opts.orderType
|
|
}
|
|
if (opts.taskId !== undefined && opts.taskId !== null) {
|
|
queryParams['taskId'] = opts.taskId
|
|
}
|
|
|
|
let pathParams = {
|
|
regionId: regionId
|
|
}
|
|
|
|
let headerParams = {
|
|
'User-Agent': 'JdcloudSdkNode/1.0.0 gcs/1.0.1'
|
|
}
|
|
|
|
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 describeOrderInfos 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}/describeOrderInfos',
|
|
'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)
|
|
}
|
|
)
|
|
}
|
|
|
|
/**
|
|
* 查询GPU算力服务地域列表
|
|
* @param {Object} opts - parameters
|
|
* @param {string} [opts.region] - 返回一个指定region下的地域信息,比如:cn-north-1 optional
|
|
* @param {string} callback - callback
|
|
@return {Object} result
|
|
* @param region regions
|
|
*/
|
|
|
|
describeRegions (opts, callback) {
|
|
opts = opts || {}
|
|
|
|
let postBody = null
|
|
let queryParams = {}
|
|
if (opts.region !== undefined && opts.region !== null) {
|
|
queryParams['region'] = opts.region
|
|
}
|
|
|
|
let pathParams = {
|
|
regionId: 'jdcloud'
|
|
}
|
|
|
|
let headerParams = {
|
|
'User-Agent': 'JdcloudSdkNode/1.0.0 gcs/1.0.1'
|
|
}
|
|
|
|
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 describeRegions 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',
|
|
'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)
|
|
}
|
|
)
|
|
}
|
|
|
|
/**
|
|
* 查询SKU可用库存数量
|
|
* @param {Object} opts - parameters
|
|
* @param {string} [opts.skuId] - sku id optional
|
|
* @param {string} regionId - ID of the region
|
|
* @param {string} callback - callback
|
|
@return {Object} result
|
|
* @param skuStock stock SKU可用库存详情
|
|
*/
|
|
|
|
describeStock (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 describeStock"
|
|
)
|
|
}
|
|
|
|
opts = opts || {}
|
|
|
|
let postBody = null
|
|
let queryParams = {}
|
|
if (opts.skuId !== undefined && opts.skuId !== null) {
|
|
queryParams['skuId'] = opts.skuId
|
|
}
|
|
|
|
let pathParams = {
|
|
regionId: regionId
|
|
}
|
|
|
|
let headerParams = {
|
|
'User-Agent': 'JdcloudSdkNode/1.0.0 gcs/1.0.1'
|
|
}
|
|
|
|
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 describeStock 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}/describeStock',
|
|
'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.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/>
|
|
如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/>
|
|
optional
|
|
* @param {string} [opts.az] - 可用区名称 optional
|
|
* @param {string} regionId - ID of the region
|
|
* @param {string} callback - callback
|
|
@return {Object} result
|
|
* @param boolean success 开通操作是否成功
|
|
*/
|
|
|
|
modifyNetDisk (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 modifyNetDisk"
|
|
)
|
|
}
|
|
|
|
opts = opts || {}
|
|
|
|
let postBody = {}
|
|
if (opts.clientToken !== undefined && opts.clientToken !== null) {
|
|
postBody['clientToken'] = opts.clientToken
|
|
}
|
|
if (opts.az !== undefined && opts.az !== null) {
|
|
postBody['az'] = opts.az
|
|
}
|
|
|
|
let queryParams = {}
|
|
|
|
let pathParams = {
|
|
regionId: regionId
|
|
}
|
|
|
|
let headerParams = {
|
|
'User-Agent': 'JdcloudSdkNode/1.0.0 gcs/1.0.1'
|
|
}
|
|
|
|
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 modifyNetDisk 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}/modifyNetDisk',
|
|
'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.az] - 可用区名称 optional
|
|
* @param {string} regionId - ID of the region
|
|
* @param {string} callback - callback
|
|
@return {Object} result
|
|
* @param string open 已开通 yes,否则 no
|
|
* @param integer bytesUsed 用量数值,单位Byte
|
|
* @param integer bytesQuota 总量数值,单位Byte
|
|
* @param string namespace 命名空间
|
|
* @param string netdiskId 网盘UUID
|
|
* @param string az 可用区
|
|
* @param string pvcName 网盘pvc名称
|
|
* @param string netType 网盘类型 ceph
|
|
* @param string pvPath 网盘挂载路径
|
|
* @param string netVolumeName 网盘在网络存储中地址
|
|
* @param string netVolumePath 网盘在网络存储中物理路径
|
|
* @param integer storage 网盘大小,G
|
|
*/
|
|
|
|
describeNetDisk (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 describeNetDisk"
|
|
)
|
|
}
|
|
|
|
opts = opts || {}
|
|
|
|
let postBody = null
|
|
let queryParams = {}
|
|
if (opts.az !== undefined && opts.az !== null) {
|
|
queryParams['az'] = opts.az
|
|
}
|
|
|
|
let pathParams = {
|
|
regionId: regionId
|
|
}
|
|
|
|
let headerParams = {
|
|
'User-Agent': 'JdcloudSdkNode/1.0.0 gcs/1.0.1'
|
|
}
|
|
|
|
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 describeNetDisk 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}/describeNetDisk',
|
|
'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)
|
|
}
|
|
)
|
|
}
|
|
}
|
|
module.exports = GCS
|