diff --git a/packages/libs/lib-huawei/rollup.config.js b/packages/libs/lib-huawei/rollup.config.js index 2d7ff274f..d452ab890 100644 --- a/packages/libs/lib-huawei/rollup.config.js +++ b/packages/libs/lib-huawei/rollup.config.js @@ -30,7 +30,7 @@ module.exports = { allowSyntheticDefaultImports: true, }), json(), - terser(), + // terser(), ], external: ["vue", "lodash-es", "dayjs", "log4js", "@midwayjs/core", "@certd/pipeline", "axios"], }; diff --git a/packages/libs/lib-jdcloud/.eslintrc b/packages/libs/lib-jdcloud/.eslintrc new file mode 100644 index 000000000..eeb127a3d --- /dev/null +++ b/packages/libs/lib-jdcloud/.eslintrc @@ -0,0 +1,22 @@ +{ + "parser": "@typescript-eslint/parser", + "plugins": [ + "@typescript-eslint" + ], + "extends": [ + "plugin:@typescript-eslint/recommended", + "plugin:prettier/recommended", + "prettier" + ], + "env": { + "mocha": true + }, + "rules": { + "@typescript-eslint/no-var-requires": "off", + "@typescript-eslint/ban-ts-comment": "off", + "@typescript-eslint/ban-ts-ignore": "off", + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-empty-function": "off", + "@typescript-eslint/no-unused-vars": "off" + } +} diff --git a/packages/libs/lib-jdcloud/.gitignore b/packages/libs/lib-jdcloud/.gitignore new file mode 100644 index 000000000..b59eedaab --- /dev/null +++ b/packages/libs/lib-jdcloud/.gitignore @@ -0,0 +1,28 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? + +test/user.secret.ts + +.rollup.cache diff --git a/packages/libs/lib-jdcloud/.npmignore b/packages/libs/lib-jdcloud/.npmignore new file mode 100644 index 000000000..ec6e82b7e --- /dev/null +++ b/packages/libs/lib-jdcloud/.npmignore @@ -0,0 +1,3 @@ +node_modules +src +.rollup.cache diff --git a/packages/libs/lib-jdcloud/.travis.yml b/packages/libs/lib-jdcloud/.travis.yml new file mode 100644 index 000000000..d2f32091d --- /dev/null +++ b/packages/libs/lib-jdcloud/.travis.yml @@ -0,0 +1 @@ +language: node_js \ No newline at end of file diff --git a/packages/libs/lib-jdcloud/LICENSE b/packages/libs/lib-jdcloud/LICENSE new file mode 100644 index 000000000..261eeb9e9 --- /dev/null +++ b/packages/libs/lib-jdcloud/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/packages/libs/lib-jdcloud/README.md b/packages/libs/lib-jdcloud/README.md new file mode 100644 index 000000000..8c9008c89 --- /dev/null +++ b/packages/libs/lib-jdcloud/README.md @@ -0,0 +1,177 @@ +--- +[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) + +# 简介 # + 欢迎使用京东云开发者Node.js工具套件(Node.js SDK)。使用京东云Node.js SDK,您无需复杂编程就可以访问京东云提供的各种服务。 + + 为了方便您理解SDK中的一些概念和参数的含义,使用SDK前建议您先查看[京东云OpenAPI使用入门](http://www.jdcloud.com/help/detail/355/isCatalog/0)。要了解每个API的具体参数和含义,请参考程序注释或参考OpenAPI&SDK下具体产品线的API文档。 + + + +# 环境准备 # + 1.京东云Node.js SDK适用于Node.js 8.6.0及以上,npm 5.6.0及以上。 + + 2.在开始调用京东云open API之前,需提前在京东云用户中心账户管理下的[AccessKey管理页面](https://uc.jdcloud.com/accesskey/index)申请accesskey和secretKey密钥对(简称AK/SK)。AK/SK信息请妥善保管,如果遗失可能会造成非法用户使用此信息操作您在云上的资源,给你造成数据和财产损失。 + + + +# SDK使用方法 # +建议使用npm安装京东云Node.js SDK,如下所示: + +npm install jdcloud-sdk-js + + + +您还可以下载sdk源代码自行使用,[源代码地址](https://github.com/jdcloud-api/jdcloud-sdk-nodejs)。 + + + +SDK使用中的任何问题,欢迎您在[SDK使用问题反馈页面](https://github.com/jdcloud-api/jdcloud-sdk-nodejs/issues)交流。 + + + +注意:京东云并没有提供其他下载方式,请务必使用上述官方下载方式! + + + +# 调用SDK # + +## 两种引用方式 ## + var JDCloud = require('jdcloud-sdk-js'); + +这种引用方式会加载所有的可用的services + + + + var NC = require('jdcloud-sdk-js/services/nativecontainer'); + +这种引用方式只会加载用到的service,此时仍然可以使用var JDCloud = require('jdcloud-sdk-js/global')来引用JDCloud对象 + +## 配置方法 ## + +对JDCloud的配置为通用配置,所有services共享配置: + + JDCloud.config.update({//*配置项/*/}); + +对某个service的配置会覆盖通用配置: + + var NC = require('jdcloud-sdk-js/services/nativecontainer'); + var nc = new NATIVECONTAINER({//*配置项/*/}); + + +## 配置项 ## + + let config = { + credentials: { + accessKeyId: global.accessKeyId, secretAccessKey: global.secretAccessKey + }, + regionId: 'cn-north-1' //地域信息,某个api调用可以单独传参regionId,如果不传则会使用此配置中的regionId + } + + +## 调用示例 ## + +以下是查询单个云主机实例详情的调用示例 + + +### 引用和配置 ### + + var VM = require('jdcloud-sdk-js/services/vm') + var vm = new VM({ + credentials: { + accessKeyId: global.accessKeyId, + secretAccessKey: global.secretAccessKey + }, + regionId: 'cn-north-1' + }) + + + +### Promise方式调用 #### + + vm.createInstances({ + instanceSpec: { + instanceType: 'g.s1.micro', + az: 'cn-north-1a', + imageId: '98d44a0f-88c1-451a-8971-f1f769073b6c', + name: 'node-sdk-test', + elasticIp: { + bandwidthMbps: 2, provider: 'BGP' + }, + primaryNetworkInterface: { + networkInterface: { + subnetId: 'subnet-3dm13k30gh', + az: 'cn-north-1a' + } + }, + systemDisk: { + diskCategory: 'local' + }, + description: 'sdk' + }, + maxCount: 1 + },'cn-north-1').then(function(data){ // 返回数据处理 data + }, + function(e){ // 调用API失败,错误处理 + }) + + + +### callback方式调用 ### + + vm.createInstances({ + instanceSpec: { + instanceType: 'g.s1.micro', + az: 'cn-north-1a', + imageId: '98d44a0f-88c1-451a-8971-f1f769073b6c', + name: 'node-sdk-test', + elasticIp: { + bandwidthMbps: 2, + provider: 'BGP' + }, + primaryNetworkInterface: { + networkInterface: { + subnetId: 'subnet-3dm13k30gh', + az: 'cn-north-1a' + } + }, + systemDisk: { + diskCategory: 'local' + }, + description: 'sdk' + }, + maxCount: 1 + },'cn-north-1', + function(err, data){ + if(err){ // 调用API失败,错误处理 + } + else { // 返回数据处理 data + } + }) + +如果需要设置访问点,配置超时,额外请求头等,请参考如下更复杂的例子: + +``` + var nc = new NATIVECONTAINER({ + credentials: { + accessKeyId: global.accessKeyId, + secretAccessKey: global.secretAccessKey + }, + endpoint: { + host: 'nativecontainer.internal.cn-north-1.jdcloud-api.com', //指定非默认Endpoint + protocol: 'http' //设置使用HTTP而不是HTTPS,vpc专用域名不支持HTTPS + }, + 'x-extra-header': { //指定额外header + "x-jdcloud-security-token" : "xxx", //要调用开启了MFA操作保护的接口需要传递 + "x-jdcloud-content-sha256" : "xxx", //body过大,希望用此value替代对body进行哈希的过程 + "MyOwn" : "xxx" + }, + version: { + nativecontainer: 'v1' + } + }) +``` + + +更多调用示例参考 [SDK使用Demo](https://github.com/jdcloud-api/jdcloud-sdk-nodejs/tree/master/test) + diff --git a/packages/libs/lib-jdcloud/package.json b/packages/libs/lib-jdcloud/package.json new file mode 100644 index 000000000..4fa31eeb3 --- /dev/null +++ b/packages/libs/lib-jdcloud/package.json @@ -0,0 +1,63 @@ +{ + "name": "@certd/jdcloud", + "version": "1.31.10", + "description": "jdcloud openApi sdk", + "main": "./dist/bundle.js", + "module": "./dist/bundle.js", + "types": "./dist/d/index.d.ts", + "scripts": { + "test": "cross-env NODE_CONFIG_DIR=./test/config mocha --recursive --require babel-register", + "dev": "babel src --out-dir babel -w", + "build": "rollup -c ", + "dev-build": "npm run build" + }, + "author": "", + "license": "Apache", + "dependencies": { + "babel-register": "^6.26.0", + "buffer": "^5.0.8", + "create-hash": "^1.1.3", + "create-hmac": "^1.1.6", + "debug": "^3.1.0", + "node-fetch": "^2.1.2", + "querystring": "^0.2.0", + "rollup": "^3.7.4", + "url": "^0.11.0", + "uuid": "^3.1.0" + }, + "devDependencies": { + "@rollup/plugin-typescript": "^11.0.0", + "@typescript-eslint/eslint-plugin": "^8.26.1", + "@typescript-eslint/parser": "^8.26.1", + "babel-cli": "^6.26.0", + "babel-preset-env": "^1.6.1", + "chai": "^4.1.2", + "config": "^1.30.0", + "cross-env": "^5.1.4", + "js-yaml": "^3.11.0", + "mocha": "^5.0.0", + "prettier": "^2.8.8", + "tslib": "^2.8.1" + }, + "engines": { + "node": ">= 8.6.0", + "npm": ">= 5.6.0" + }, + "browserslist": [ + "> 1%", + "last 2 versions", + "not ie <= 9" + ], + "standard": { + "env": [ + "node", + "mocha", + "browser" + ], + "globals": [ + "Request", + "Headers", + "fetch" + ] + } +} diff --git a/packages/libs/lib-jdcloud/rollup.config.js b/packages/libs/lib-jdcloud/rollup.config.js new file mode 100644 index 000000000..d452ab890 --- /dev/null +++ b/packages/libs/lib-jdcloud/rollup.config.js @@ -0,0 +1,36 @@ +const resolve = require("@rollup/plugin-node-resolve"); +const commonjs = require("@rollup/plugin-commonjs"); +//const Typescript = require("rollup-plugin-typescript2"); +const Typescript = require("@rollup/plugin-typescript"); +const json = require("@rollup/plugin-json"); +const terser = require("@rollup/plugin-terser"); +module.exports = { + input: "src/index.ts", + output: { + file: "dist/bundle.js", + format: "cjs", + }, + plugins: [ + // 解析第三方依赖 + resolve(), + // 识别 commonjs 模式第三方依赖 + commonjs({ + // dynamicRequireRoot: "../../../../", + // dynamicRequireTargets: [ + // // include using a glob pattern (either a string or an array of strings) + // "../../../../**/shelljs/src/*", + // ], + }), + Typescript({ + target: "esnext", + rootDir: "src", + declaration: true, + declarationDir: "dist/d", + exclude: ["./node_modules/**", "./src/**/*.vue", "./src/**/*.spec.ts"], + allowSyntheticDefaultImports: true, + }), + json(), + // terser(), + ], + external: ["vue", "lodash-es", "dayjs", "log4js", "@midwayjs/core", "@certd/pipeline", "axios"], +}; diff --git a/packages/libs/lib-jdcloud/src/global.js b/packages/libs/lib-jdcloud/src/global.js new file mode 100644 index 000000000..1266af2b4 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/global.js @@ -0,0 +1,2 @@ +require('./lib/node_loader') +module.exports = require('./lib/core') diff --git a/packages/libs/lib-jdcloud/src/index.ts b/packages/libs/lib-jdcloud/src/index.ts new file mode 100644 index 000000000..3c34209c0 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/index.ts @@ -0,0 +1,7 @@ +import jdCloud from "./lib/core.js"; +import jdService from './lib/service.js' + +import domainService from './repo/domainservice/v2/domainservice.js' +export const JDCloud = jdCloud; +export const JDService = jdService; +export const JDDomainService = domainService; \ No newline at end of file diff --git a/packages/libs/lib-jdcloud/src/jdcloud.js b/packages/libs/lib-jdcloud/src/jdcloud.js new file mode 100644 index 000000000..e273e76f5 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/jdcloud.js @@ -0,0 +1 @@ +module.exports = require('./lib/jc') diff --git a/packages/libs/lib-jdcloud/src/lib/browser.js b/packages/libs/lib-jdcloud/src/lib/browser.js new file mode 100644 index 000000000..7d7b0266a --- /dev/null +++ b/packages/libs/lib-jdcloud/src/lib/browser.js @@ -0,0 +1,5 @@ +require('babel-polyfill') +require('./browser_loader') +var JC = require('./core') +require('../services/all') +module.exports = JC diff --git a/packages/libs/lib-jdcloud/src/lib/browser_loader.js b/packages/libs/lib-jdcloud/src/lib/browser_loader.js new file mode 100644 index 000000000..ecdf1ae66 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/lib/browser_loader.js @@ -0,0 +1,13 @@ +var util = require('./util') +util.crypto.lib = { + createHash: require('create-hash'), + createHmac: require('create-hmac') +} +util.Buffer = require('buffer/').Buffer +util.url = require('url/') +util.querystring = require('querystring/') +util.environment = 'js' + +var JC = require('./core') + +module.exports = JC diff --git a/packages/libs/lib-jdcloud/src/lib/common.js b/packages/libs/lib-jdcloud/src/lib/common.js new file mode 100644 index 000000000..2e62001cf --- /dev/null +++ b/packages/libs/lib-jdcloud/src/lib/common.js @@ -0,0 +1,6 @@ +require('./core') + +require('./config') +require('./request') +require('./service') +require('./credentials') diff --git a/packages/libs/lib-jdcloud/src/lib/config.js b/packages/libs/lib-jdcloud/src/lib/config.js new file mode 100644 index 000000000..d1d66c97c --- /dev/null +++ b/packages/libs/lib-jdcloud/src/lib/config.js @@ -0,0 +1,78 @@ +var JDCloud = require('./core') + +let defaultValues = { + credentials: null, + regionId: null, + apiVersions: null, + endpoint: {}, + version: {}, + logger: function (string, level = 'INFO') { + // level: INFO / DEBUG / ERROR / WARN + console.log(string) + } +} +JDCloud.Config = class Config { + constructor (options = {}) { + options = this.extractCredentials(options) + + JDCloud.util.each.call(this, defaultValues, function (key, value) { + if (options[key] === undefined) { + this[key] = value + } else { + this[key] = options[key] + } + }) + JDCloud.util.each.call(this, JDCloud.Service._services, function ( + key, + value + ) { + if (options[key] !== undefined) { + this[key] = options[key] + } + }) + } + + extractCredentials (options) { + if (options.accessKeyId && options.secretAccessKey) { + options = Object.assign({}, options) + options.credentials = new JDCloud.Credentials(options) + } + return options + } + + getCredentials () { + var p = new Promise((resolve, reject) => { + if (this.credentials) { + if (typeof this.credentials.get === 'function') { + } else if ( + this.credentials.accessKeyId && + this.credentials.secretAccessKey + ) { + resolve() + } else { + reject(new Error('missing credentials')) + } + } else if (this.credentialProvider) { + } else { + reject(new Error('get credentials failed')) + } + }) + + return p + } + + update (options, allowUnknownKeys = false) { + options = this.extractCredentials(options) + JDCloud.util.each.call(this, options, function (key, value) { + if ( + allowUnknownKeys || + defaultValues.hasOwnProperty(key) || + JDCloud.Service.hasService(key) + ) { + this[key] = options[key] + } + }) + } +} + +JDCloud.config = new JDCloud.Config() diff --git a/packages/libs/lib-jdcloud/src/lib/core.js b/packages/libs/lib-jdcloud/src/lib/core.js new file mode 100644 index 000000000..18a7c44cb --- /dev/null +++ b/packages/libs/lib-jdcloud/src/lib/core.js @@ -0,0 +1,13 @@ +require('node-fetch') + +var JDCloud = { + util: require('./util'), + // todo swaggerVar + VERSION: '' +} + +module.exports = JDCloud + +require('./service') +require('./config') +require('./request') diff --git a/packages/libs/lib-jdcloud/src/lib/credentials.js b/packages/libs/lib-jdcloud/src/lib/credentials.js new file mode 100644 index 000000000..1567ac818 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/lib/credentials.js @@ -0,0 +1,21 @@ +var JDCloud = require('./core') + +JDCloud.Credentials = class Credentials { + constructor () { + this.expired = false + this.expireTime = null + + if (arguments.length === 1 && typeof arguments[0] === 'object') { + var creds = arguments[0].credentials || arguments[0] + this.accessKeyId = creds.accessKeyId + this.secretAccessKey = creds.secretAccessKey + this.sessionToken = creds.sessionToken + } else { + this.accessKeyId = arguments[0] + this.secretAccessKey = arguments[1] + this.sessionToken = arguments[2] + } + } +} + +module.exports = JDCloud.Credentials diff --git a/packages/libs/lib-jdcloud/src/lib/jc.js b/packages/libs/lib-jdcloud/src/lib/jc.js new file mode 100644 index 000000000..03a3bc260 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/lib/jc.js @@ -0,0 +1,4 @@ +require('./node_loader') +var JDCloud = require('./core') +require('../services/all') +module.exports = JDCloud diff --git a/packages/libs/lib-jdcloud/src/lib/node_loader.js b/packages/libs/lib-jdcloud/src/lib/node_loader.js new file mode 100644 index 000000000..c5cb38d6d --- /dev/null +++ b/packages/libs/lib-jdcloud/src/lib/node_loader.js @@ -0,0 +1,12 @@ +var util = require('./util') + +util.crypto.lib = require('crypto') +util.Buffer = require('buffer').Buffer +util.url = require('url') +util.querystring = require('querystring') +util.environment = 'nodejs' +let JDCloud = require('./core') +JDCloud.fetch = require('node-fetch') +module.exports = JDCloud + +require('./credentials') diff --git a/packages/libs/lib-jdcloud/src/lib/request.js b/packages/libs/lib-jdcloud/src/lib/request.js new file mode 100644 index 000000000..c83f139b0 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/lib/request.js @@ -0,0 +1,159 @@ +var JDCloud = require('./core') + +let util = JDCloud.util +JDCloud.JCRequest = class JCRequest { + constructor ( + service, + path, + httpMethod, + pathParams, + queryParams, + headerParams, + formParams, + postBody, + contentTypes, + accepts, + returnType + ) { + this.service = service + + var endpoint = service.config.endpoint + pathParams.regionId = pathParams.regionId || service.config.regionId + this.regionId = pathParams.regionId + + this.path = this.buildPath(path, pathParams) + this.path = util.uriEscapePath(this.path) + + var queryString = this.buildQuery(queryParams) + + var url = this.path + if (queryString) { + url = this.path + '?' + queryString + } + + var contentType = this.jsonPreferredMime(contentTypes) || 'application/json' + headerParams['content-type'] = contentType + var requestHeaders = this.buildHeaders(headerParams) + + var requestInit = { + method: httpMethod || 'GET', + headers: requestHeaders + } + + if (contentType === 'application/x-www-form-urlencoded') { + } else if (contentType === 'multipart/form-data') { + } else if (postBody) { + requestInit.body = JSON.stringify(postBody) + } + var fetchUrl = endpoint.protocol + '://' + endpoint.host + url + JDCloud.config.logger( + `make request where url is :${fetchUrl} \nwith fetch config:${JSON.stringify( + requestInit + )}` + ) + this.request = new JDCloud.fetch.Request(fetchUrl, requestInit) + } + + buildPath (path, pathParams) { + var uri = (this.service.config.basePath || '') + path + uri = uri.replace(/\{([\w-]+)\}/g, (fullMatch, key) => { + var value + if (pathParams.hasOwnProperty(key)) { + value = pathParams[key] + } else { + value = fullMatch + } + return value + }) + return uri + } + + buildQuery (queryParams) { + var queryParamsWithoutEmptyItem = {} + var keys = Object.keys(queryParams) + for (let key of keys) { + if (queryParams[key] !== undefined) { + queryParamsWithoutEmptyItem[key] = queryParams[key] + } + } + return JDCloud.util.querystring.stringify(queryParamsWithoutEmptyItem) + } + + search () { + var query = this.request.url.split('?', 2)[1] + if (query) { + query = JDCloud.util.querystring.parse(query) + return JDCloud.util.queryParamsToString(query) + } + return '' + } + + digitizationArray (key, obj) { + var result = key + if (Array.isArray(obj)) { + JDCloud.util.arrayEach(obj, (arrayValue, index) => { + result += this.digitizationArray(`.${index + 1}`, arrayValue) + }) + } else if (typeof obj === 'object' && obj != null) { + JDCloud.util.each(obj, (key, ObjValue) => { + result += `.name=${key}&${result}.values` + this.digitizationArray() + result += + key + + '.name=' + + ObjValue + + '&' + + this.digitizationArray(key + '.values', ObjValue) + }) + } else { + result += key + '=' + encodeURI(obj) + } + return result + } + + buildHeaders (headerParams) { + var headers = new JDCloud.fetch.Headers({ + accept: 'application/json' + }) + + util.each.call(this, headerParams, function (key) { + if (headerParams[key] !== undefined && headerParams[key] != null) { + headers.append(key, headerParams[key]) + } + }) + return headers + } + + /** + * Checks whether the given content type represents JSON.
+ * JSON content type examples:
+ * + * @param {String} contentType The MIME content type to check. + * @returns {Boolean} true if contentType represents JSON, otherwise false. + */ + isJsonMime (contentType) { + return Boolean( + contentType != null && contentType.match(/^application\/json(;.*)?$/i) + ) + } + + /** + * Chooses a content type from the given array, with JSON preferred; i.e. return JSON if included, otherwise return the first. + * @param {Array.} contentTypes + * @returns {String} The chosen content type, preferring JSON. + */ + jsonPreferredMime (contentTypes) { + for (var i = 0; i < contentTypes.length; i++) { + if (this.isJsonMime(contentTypes[i])) { + return contentTypes[i] + } + } + + return contentTypes[0] + } +} + +module.exports = JDCloud.JCRequest diff --git a/packages/libs/lib-jdcloud/src/lib/service.js b/packages/libs/lib-jdcloud/src/lib/service.js new file mode 100644 index 000000000..989174f9e --- /dev/null +++ b/packages/libs/lib-jdcloud/src/lib/service.js @@ -0,0 +1,231 @@ +var JDCloud = require('./core') +var SignerV2 = require('./signers/v2') + +JDCloud.Service = class Service { + constructor (serviceId, config = {}) { + this.serviceId = serviceId + this.init(config) + } + + init (config) { + // 某个服务类型的全局配置 + var serviceConfig = JDCloud.config[this.serviceId] + // 全局配置 + this.config = new JDCloud.Config(JDCloud.config) + if (serviceConfig) { + this.config.update(serviceConfig, true) + } + if (config) { + if (!this.config.endpoint.host && !config.endpoint) { + config.endpoint = config._defaultEndpoint + } + delete config._defaultEndpoint + this.config.update(config, true) + } + } + + makeRequest ( + path, + httpMethod, + pathParams, + queryParams, + headerParams, + formParams, + postBody, + contentTypes, + accepts, + returnType, + callback + ) { + var request = new JDCloud.JCRequest( + this, + path, + httpMethod, + pathParams, + queryParams, + headerParams, + formParams, + postBody, + contentTypes, + accepts, + returnType + ) + + var signer = new SignerV2(request, this.serviceId) + + return this.config.getCredentials().then(() => { + signer.addAuthorization(this.config.credentials) + return JDCloud.fetch(signer.request.request).then(response => { + return response.json().then( + result => { + result.responseObj = response + if (response.ok) { + return result + } + return Promise.reject(result) + }, + error => { + error.responseObj = response + if (error.type === 'invalid-json') { + // oss没有返回json + if (response.ok) { + return Promise.resolve({ + requestId: response.headers.get('x-jdcloud-request-id') || '' + }) + } else { + /* eslint-disable */ + return Promise.reject({ + requestId: response.headers.get('x-jdcloud-request-id') || '' + }) + /* eslint-enable */ + } + } + throw error + } + ) + }) + }) + } + + buildCollectionParam (param, collectionFormat) { + if (param === null || param === undefined) { + return param + } + switch (collectionFormat) { + case 'csv': + return param.map(this.paramToString).join(',') + case 'ssv': + return param.map(this.paramToString).join(' ') + case 'tsv': + return param.map(this.paramToString).join('\t') + case 'pipes': + return param.map(this.paramToString).join('|') + case 'multi': + // return the array directly as SuperAgent will handle it as expected + return param.map(this.paramToString) + default: + throw new Error('Unknown collection format: ' + collectionFormat) + } + } + + /** + * filter is a special type of array + * only contains: + * [ + * { name: someString , values:[ someString, someString ] ,operator: someString} + * ] + * + */ + buildFilterParam (param, key) { + var result = {} + if (Array.isArray(param)) { + let index = 0 + for (var i = 0; i < param.length; i++) { + var obj = param[i] + + // 兼容空字符串 + if (obj.values !== '' && !Array.isArray(obj.values)) { + throw new Error('The type of filters.values should be Array!') + } + if (obj.name && obj.values) { + if (!obj.values.length) continue + result[`${key}.${index + 1}.name`] = obj.name + for (var j = 0; j < obj.values.length; j++) { + var someString = obj.values[j] + result[`${key}.${index + 1}.values.${j + 1}`] = someString + } + if (obj.operator) { + result[`${key}.${index + 1}.operator`] = obj.operator + } + index++ + } + } + } + return result + } + + buildTagFilterParam (param = [], key) { + var result = {} + if (!Array.isArray(param)) { + throw new Error(`The type of param 'param' should be Array!`) + } + + for (var i = 0; i < param.length; i++) { + var obj = param[i] + + if (obj.values && !Array.isArray(obj.values)) { + throw new Error( + `The type of param 'param[${i}].values' should be Array or NULL!` + ) + } + + if (obj.key) { + result[`${key}.${i + 1}.key`] = obj.key + + if (obj.values) { + for (var j = 0; j < obj.values.length; j++) { + var someString = obj.values[j] + result[`${key}.${i + 1}.values.${j + 1}`] = someString + } + } + } + } + return result + } + + buildSortParam (param = [], key) { + var result = {} + if (!Array.isArray(param)) { + throw new Error(`The type of param 'param' should be Array!`) + } + + var index = 0 + for (var i = 0; i < param.length; i++) { + var obj = param[i] + + if (obj.name && obj.direction) { + index++ + result[`${key}.${index}.name`] = obj.name + result[`${key}.${index}.direction`] = obj.direction + } + } + return result + } + + // arr=[a,b,c] => arr={arr1:a, arr2:b, arr3:c} + buildArrayParam (param = [], key) { + var result = {} + if (!Array.isArray(param)) { + throw new Error(`The type of param 'param' should be Array!`) + } + + for (var i = 0; i < param.length; i++) { + var value = param[i] + result[`${key}.${i + 1}`] = value + } + return result + } + + /** + * Returns a string representation for an actual parameter. + * @param param The actual parameter. + * @returns {String} The string representation of param. + */ + paramToString (param) { + if (param === undefined || param === null) { + return '' + } + if (param instanceof Date) { + return param.toJSON() + } + + return param.toString() + } + + static hasService (id) { + return JDCloud.Service._services.hasOwnProperty(id) + } +} +JDCloud.Service._services = {} + +module.exports = JDCloud.Service diff --git a/packages/libs/lib-jdcloud/src/lib/signers/request_signer.js b/packages/libs/lib-jdcloud/src/lib/signers/request_signer.js new file mode 100644 index 000000000..73b756d8e --- /dev/null +++ b/packages/libs/lib-jdcloud/src/lib/signers/request_signer.js @@ -0,0 +1,13 @@ +module.exports = class RequestSigner { + constructor (request) { + this.request = request + } + + setServiceClientId (id) { + this.serviceClientId = id + } + + getServiceClientId () { + return this.serviceClientId + } +} diff --git a/packages/libs/lib-jdcloud/src/lib/signers/v2.js b/packages/libs/lib-jdcloud/src/lib/signers/v2.js new file mode 100644 index 000000000..3a8599f8e --- /dev/null +++ b/packages/libs/lib-jdcloud/src/lib/signers/v2.js @@ -0,0 +1,190 @@ +// 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 +// This signer is modified from AWS V4 signer algorithm. + +var util = require('../util') +var RequestSigner = require('./request_signer') +var v2Credentials = require('./v2_credentials') +var uuid = require('uuid') +var JDCloud = require('../core') + +module.exports = class SignerV2 extends RequestSigner { + constructor (request, serviceName, options = {}) { + super(request) + this.signatureCache = true + this.algorithm = 'JDCLOUD2-HMAC-SHA256' + this.unsignableHeaders = ['authorization', 'user-agent'] + this.serviceName = serviceName + // this.signatureCache = typeof options.signatureCache === 'boolean' ? options.signatureCache : true; + } + + // 签名流程见 https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html + + addAuthorization (credentials, date) { + // var datetime = '20180119T070300Z'; + var datetime = util.date.iso8601(date).replace(/[:-]|\.\d{3}/g, '') + this.addHeaders(credentials, datetime) + this.request.request.headers.set( + 'Authorization', + this.authorization(credentials, datetime) + ) + } + + addHeaders (credentials, datetime) { + this.request.request.headers.set('x-jdcloud-date', datetime) + this.request.request.headers.set('x-jdcloud-nonce', uuid.v4()) + this.request.request.headers.set( + 'host', + this.request.service.config.endpoint.host + ) + } + + signedHeaders () { + var keys = [] + this.request.request.headers.forEach((value, key) => { + key = key.toLowerCase() + if (this.isSignableHeader(key)) { + keys.push(key) + } + }) + /* util.each.call(this, this.request.headers, function (key) { + + }); */ + return keys.sort().join(';') + } + + credentialString (datetime) { + return v2Credentials.createScope( + datetime.substr(0, 8), + this.request.regionId, + this.serviceName + ) + } + + signature (credentials, datetime) { + var signingKey = v2Credentials.getSigningKey( + credentials, + datetime.substr(0, 8), + this.request.regionId, + this.serviceName, + this.signatureCache + ) + return util.crypto.hmac(signingKey, this.stringToSign(datetime), 'hex') + } + + stringToSign (datetime) { + var parts = [] + parts.push(this.algorithm) + parts.push(datetime) + parts.push(this.credentialString(datetime)) + parts.push(this.hexEncodedHash(this.canonicalString())) + JDCloud.config.logger('StringToSign is \n' + JSON.stringify(parts), 'DEBUG') + return parts.join('\n') + } + + // 构建标准签名字符串 + canonicalString () { + var parts = [] + var pathname = this.request.path + // if (this.serviceName !== 'jfs') { + // pathname = util.uriEscapePath(pathname) + // } + + parts.push(this.request.request.method) + parts.push(pathname) + parts.push(this.request.search()) + parts.push(this.canonicalHeaders() + '\n') + parts.push(this.signedHeaders()) + parts.push(this.hexEncodedBodyHash()) + JDCloud.config.logger( + 'canonicalString is \n' + JSON.stringify(parts), + 'DEBUG' + ) + return parts.join('\n') + } + + canonicalHeaders () { + var headers = [] + this.request.request.headers.forEach((value, key) => { + headers.push([key, value]) + }) + headers.sort(function (a, b) { + return a[0].toLowerCase() < b[0].toLowerCase() ? -1 : 1 + }) + var parts = [] + util.arrayEach.call(this, headers, function (item) { + var key = item[0].toLowerCase() + if (this.isSignableHeader(key)) { + var value = item[1] + if ( + typeof value === 'undefined' || + value === null || + typeof value.toString !== 'function' + ) { + throw util.error( + new Error('Header ' + key + ' contains invalid value'), + { + code: 'InvalidHeader' + } + ) + } + parts.push(key + ':' + this.canonicalHeaderValues(value.toString())) + } + }) + return parts.join('\n') + } + + canonicalHeaderValues (values) { + return values.replace(/\s+/g, ' ').replace(/^\s+|\s+$/g, '') + } + + authorization (credentials, datetime) { + var parts = [] + var credString = this.credentialString(datetime) + parts.push( + this.algorithm + + ' Credential=' + + credentials.accessKeyId + + '/' + + credString + ) + parts.push('SignedHeaders=' + this.signedHeaders()) + parts.push('Signature=' + this.signature(credentials, datetime)) + JDCloud.config.logger('Signature is \n' + JSON.stringify(parts), 'DEBUG') + return parts.join(', ') + } + + hexEncodedHash (string) { + return util.crypto.sha256(string, 'hex') + } + + hexEncodedBodyHash () { + return this.hexEncodedHash(this.request.request.body || '') + /* var request = this.request; + if (this.isPresigned() && this.serviceName === 's3' && !request.body) { + return 'UNSIGNED-PAYLOAD'; + } else if (request.headers['X-Amz-Content-Sha256']) { + return request.headers['X-Amz-Content-Sha256']; + } else { + return this.hexEncodedHash(this.request.body || ''); + } */ + } + + isSignableHeader (key) { + if (key.toLowerCase().includes('x-jdcloud-')) { + return true + } + return !this.unsignableHeaders.includes(key.toLowerCase()) + } +} diff --git a/packages/libs/lib-jdcloud/src/lib/signers/v2_credentials.js b/packages/libs/lib-jdcloud/src/lib/signers/v2_credentials.js new file mode 100644 index 000000000..c2123a147 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/lib/signers/v2_credentials.js @@ -0,0 +1,80 @@ +var cachedSecret = {} +var cacheQueue = [] +var maxCacheEntries = 50 +var v2Identifier = 'jdcloud2_request' + +var util = require('../util') + +module.exports = { + /** + * @api private + * + * @param date [String] + * @param region [String] + * @param serviceName [String] + * @return [String] + */ + createScope: function createScope (date, region, serviceName) { + return [date.substr(0, 8), region, serviceName, v2Identifier].join('/') + }, + + /** + * @api private + * + * @param credentials [Credentials] + * @param date [String] + * @param region [String] + * @param service [String] + * @param shouldCache [Boolean] + * @return [String] + */ + getSigningKey: function getSigningKey ( + credentials, + date, + region, + service, + shouldCache + ) { + var credsIdentifier = util.crypto.hmac( + credentials.secretAccessKey, + credentials.accessKeyId, + 'base64' + ) + var cacheKey = [credsIdentifier, date, region, service].join('_') + shouldCache = shouldCache !== false + if (shouldCache && cacheKey in cachedSecret) { + return cachedSecret[cacheKey] + } + + var kDate = util.crypto.hmac( + 'JDCLOUD2' + credentials.secretAccessKey, + date, + 'buffer' + ) + var kRegion = util.crypto.hmac(kDate, region, 'buffer') + var kService = util.crypto.hmac(kRegion, service, 'buffer') + + var signingKey = util.crypto.hmac(kService, v2Identifier, 'buffer') + if (shouldCache) { + cachedSecret[cacheKey] = signingKey + cacheQueue.push(cacheKey) + if (cacheQueue.length > maxCacheEntries) { + // remove the oldest entry (not the least recently used) + delete cachedSecret[cacheQueue.shift()] + } + } + + return signingKey + }, + + /** + * @api private + * + * Empties the derived signing key cache. Made available for testing purposes + * only. + */ + emptyCache: function emptyCache () { + cachedSecret = {} + cacheQueue = [] + } +} diff --git a/packages/libs/lib-jdcloud/src/lib/util.js b/packages/libs/lib-jdcloud/src/lib/util.js new file mode 100644 index 000000000..adb3e7ba5 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/lib/util.js @@ -0,0 +1,477 @@ +var util = { + isBrowser: function isBrowser () { + return process && process.browser + }, + isNode: function isNode () { + return !util.isBrowser() + }, + uriEscape: function uriEscape (string) { + var output = encodeURIComponent(string) + output = output.replace(/[^A-Za-z0-9_.~\-%]+/g, escape) + + // AWS percent-encodes some extra non-standard characters in a URI + output = output.replace(/[*]/g, function (ch) { + return ( + '%' + + ch + .charCodeAt(0) + .toString(16) + .toUpperCase() + ) + }) + + return output + }, + uriEscapePath: function uriEscapePath (string) { + var parts = [] + util.arrayEach(string.split('/'), function (part) { + parts.push(util.uriEscape(part)) + }) + return parts.join('/') + }, + abort: {}, + each: function each (object, iterFunction) { + for (var key in object) { + if (Object.prototype.hasOwnProperty.call(object, key)) { + var ret = iterFunction.call(this, key, object[key]) + if (ret === util.abort) break + } + } + }, + + arrayEach: function arrayEach (array, iterFunction) { + for (var idx in array) { + if (Object.prototype.hasOwnProperty.call(array, idx)) { + var ret = iterFunction.call(this, array[idx], parseInt(idx, 10)) + if (ret === util.abort) break + } + } + }, + arraySliceFn: function arraySliceFn (obj) { + var fn = obj.slice || obj.webkitSlice || obj.mozSlice + return typeof fn === 'function' ? fn : null + }, + queryParamsToString: function queryParamsToString (params) { + var items = [] + var escape = util.uriEscape + var sortedKeys = Object.keys(params).sort() + + util.arrayEach(sortedKeys, function (name) { + var value = params[name] + var ename = escape(name) + var result = ename + '=' + if (Array.isArray(value)) { + var vals = [] + util.arrayEach(value, function (item) { + vals.push(escape(item)) + }) + result = ename + '=' + vals.sort().join('&' + ename + '=') + } else if (value !== undefined && value !== null) { + result = ename + '=' + escape(value) + } + items.push(result) + }) + + return items.join('&') + }, + date: { + getDate () { + return new Date() + }, + iso8601: function iso8601 (date) { + if (date === undefined) { + date = util.date.getDate() + } + return date.toISOString().replace(/\.\d{3}Z$/, 'Z') + } + }, + crypto: { + /* eslint-disable no-use-before-define */ + crc32Table: [ + 0x00000000, + 0x77073096, + 0xee0e612c, + 0x990951ba, + 0x076dc419, + 0x706af48f, + 0xe963a535, + 0x9e6495a3, + 0x0edb8832, + 0x79dcb8a4, + 0xe0d5e91e, + 0x97d2d988, + 0x09b64c2b, + 0x7eb17cbd, + 0xe7b82d07, + 0x90bf1d91, + 0x1db71064, + 0x6ab020f2, + 0xf3b97148, + 0x84be41de, + 0x1adad47d, + 0x6ddde4eb, + 0xf4d4b551, + 0x83d385c7, + 0x136c9856, + 0x646ba8c0, + 0xfd62f97a, + 0x8a65c9ec, + 0x14015c4f, + 0x63066cd9, + 0xfa0f3d63, + 0x8d080df5, + 0x3b6e20c8, + 0x4c69105e, + 0xd56041e4, + 0xa2677172, + 0x3c03e4d1, + 0x4b04d447, + 0xd20d85fd, + 0xa50ab56b, + 0x35b5a8fa, + 0x42b2986c, + 0xdbbbc9d6, + 0xacbcf940, + 0x32d86ce3, + 0x45df5c75, + 0xdcd60dcf, + 0xabd13d59, + 0x26d930ac, + 0x51de003a, + 0xc8d75180, + 0xbfd06116, + 0x21b4f4b5, + 0x56b3c423, + 0xcfba9599, + 0xb8bda50f, + 0x2802b89e, + 0x5f058808, + 0xc60cd9b2, + 0xb10be924, + 0x2f6f7c87, + 0x58684c11, + 0xc1611dab, + 0xb6662d3d, + 0x76dc4190, + 0x01db7106, + 0x98d220bc, + 0xefd5102a, + 0x71b18589, + 0x06b6b51f, + 0x9fbfe4a5, + 0xe8b8d433, + 0x7807c9a2, + 0x0f00f934, + 0x9609a88e, + 0xe10e9818, + 0x7f6a0dbb, + 0x086d3d2d, + 0x91646c97, + 0xe6635c01, + 0x6b6b51f4, + 0x1c6c6162, + 0x856530d8, + 0xf262004e, + 0x6c0695ed, + 0x1b01a57b, + 0x8208f4c1, + 0xf50fc457, + 0x65b0d9c6, + 0x12b7e950, + 0x8bbeb8ea, + 0xfcb9887c, + 0x62dd1ddf, + 0x15da2d49, + 0x8cd37cf3, + 0xfbd44c65, + 0x4db26158, + 0x3ab551ce, + 0xa3bc0074, + 0xd4bb30e2, + 0x4adfa541, + 0x3dd895d7, + 0xa4d1c46d, + 0xd3d6f4fb, + 0x4369e96a, + 0x346ed9fc, + 0xad678846, + 0xda60b8d0, + 0x44042d73, + 0x33031de5, + 0xaa0a4c5f, + 0xdd0d7cc9, + 0x5005713c, + 0x270241aa, + 0xbe0b1010, + 0xc90c2086, + 0x5768b525, + 0x206f85b3, + 0xb966d409, + 0xce61e49f, + 0x5edef90e, + 0x29d9c998, + 0xb0d09822, + 0xc7d7a8b4, + 0x59b33d17, + 0x2eb40d81, + 0xb7bd5c3b, + 0xc0ba6cad, + 0xedb88320, + 0x9abfb3b6, + 0x03b6e20c, + 0x74b1d29a, + 0xead54739, + 0x9dd277af, + 0x04db2615, + 0x73dc1683, + 0xe3630b12, + 0x94643b84, + 0x0d6d6a3e, + 0x7a6a5aa8, + 0xe40ecf0b, + 0x9309ff9d, + 0x0a00ae27, + 0x7d079eb1, + 0xf00f9344, + 0x8708a3d2, + 0x1e01f268, + 0x6906c2fe, + 0xf762575d, + 0x806567cb, + 0x196c3671, + 0x6e6b06e7, + 0xfed41b76, + 0x89d32be0, + 0x10da7a5a, + 0x67dd4acc, + 0xf9b9df6f, + 0x8ebeeff9, + 0x17b7be43, + 0x60b08ed5, + 0xd6d6a3e8, + 0xa1d1937e, + 0x38d8c2c4, + 0x4fdff252, + 0xd1bb67f1, + 0xa6bc5767, + 0x3fb506dd, + 0x48b2364b, + 0xd80d2bda, + 0xaf0a1b4c, + 0x36034af6, + 0x41047a60, + 0xdf60efc3, + 0xa867df55, + 0x316e8eef, + 0x4669be79, + 0xcb61b38c, + 0xbc66831a, + 0x256fd2a0, + 0x5268e236, + 0xcc0c7795, + 0xbb0b4703, + 0x220216b9, + 0x5505262f, + 0xc5ba3bbe, + 0xb2bd0b28, + 0x2bb45a92, + 0x5cb36a04, + 0xc2d7ffa7, + 0xb5d0cf31, + 0x2cd99e8b, + 0x5bdeae1d, + 0x9b64c2b0, + 0xec63f226, + 0x756aa39c, + 0x026d930a, + 0x9c0906a9, + 0xeb0e363f, + 0x72076785, + 0x05005713, + 0x95bf4a82, + 0xe2b87a14, + 0x7bb12bae, + 0x0cb61b38, + 0x92d28e9b, + 0xe5d5be0d, + 0x7cdcefb7, + 0x0bdbdf21, + 0x86d3d2d4, + 0xf1d4e242, + 0x68ddb3f8, + 0x1fda836e, + 0x81be16cd, + 0xf6b9265b, + 0x6fb077e1, + 0x18b74777, + 0x88085ae6, + 0xff0f6a70, + 0x66063bca, + 0x11010b5c, + 0x8f659eff, + 0xf862ae69, + 0x616bffd3, + 0x166ccf45, + 0xa00ae278, + 0xd70dd2ee, + 0x4e048354, + 0x3903b3c2, + 0xa7672661, + 0xd06016f7, + 0x4969474d, + 0x3e6e77db, + 0xaed16a4a, + 0xd9d65adc, + 0x40df0b66, + 0x37d83bf0, + 0xa9bcae53, + 0xdebb9ec5, + 0x47b2cf7f, + 0x30b5ffe9, + 0xbdbdf21c, + 0xcabac28a, + 0x53b39330, + 0x24b4a3a6, + 0xbad03605, + 0xcdd70693, + 0x54de5729, + 0x23d967bf, + 0xb3667a2e, + 0xc4614ab8, + 0x5d681b02, + 0x2a6f2b94, + 0xb40bbe37, + 0xc30c8ea1, + 0x5a05df1b, + 0x2d02ef8d + ], + /* eslint-disable no-use-before-define */ + + crc32: function crc32 (data) { + var tbl = util.crypto.crc32Table + var crc = 0 ^ -1 + + if (typeof data === 'string') { + data = new util.Buffer(data) + } + + for (var i = 0; i < data.length; i++) { + var code = data.readUInt8(i) + crc = (crc >>> 8) ^ tbl[(crc ^ code) & 0xff] + } + return (crc ^ -1) >>> 0 + }, + + hmac: function hmac (key, string, digest, fn) { + if (!digest) digest = 'binary' + if (digest === 'buffer') { + digest = undefined + } + if (!fn) fn = 'sha256' + if (typeof string === 'string') string = new util.Buffer(string) + return util.crypto.lib + .createHmac(fn, key) + .update(string) + .digest(digest) + }, + + md5: function md5 (data, digest, callback) { + return util.crypto.hash('md5', data, digest, callback) + }, + + sha256: function sha256 (data, digest, callback) { + return util.crypto.hash('sha256', data, digest, callback) + }, + + hash: function (algorithm, data, digest, callback) { + var hash = util.crypto.createHash(algorithm) + if (!digest) { + digest = 'binary' + } + if (digest === 'buffer') { + digest = undefined + } + if (typeof data === 'string') data = new util.Buffer(data) + var sliceFn = util.arraySliceFn(data) + var isBuffer = util.Buffer.isBuffer(data) + // Identifying objects with an ArrayBuffer as buffers + if ( + util.isBrowser() && + typeof ArrayBuffer !== 'undefined' && + data && + data.buffer instanceof ArrayBuffer + ) { + isBuffer = true + } + + if ( + callback && + typeof data === 'object' && + typeof data.on === 'function' && + !isBuffer + ) { + data.on('data', function (chunk) { + hash.update(chunk) + }) + data.on('error', function (err) { + callback(err) + }) + data.on('end', function () { + callback(null, hash.digest(digest)) + }) + } else if ( + callback && + sliceFn && + !isBuffer && + typeof FileReader !== 'undefined' + ) { + // this might be a File/Blob + var index = 0 + var size = 1024 * 512 + var reader = new FileReader() + reader.onerror = function () { + callback(new Error('Failed to read data.')) + } + reader.onload = function () { + var buf = new util.Buffer(new Uint8Array(reader.result)) + hash.update(buf) + index += buf.length + reader._continueReading() + } + reader._continueReading = function () { + if (index >= data.size) { + callback(null, hash.digest(digest)) + return + } + + var back = index + size + if (back > data.size) back = data.size + reader.readAsArrayBuffer(sliceFn.call(data, index, back)) + } + + reader._continueReading() + } else { + if (util.isBrowser() && typeof data === 'object' && !isBuffer) { + data = new util.Buffer(new Uint8Array(data)) + } + var out = hash.update(data).digest(digest) + if (callback) callback(null, out) + return out + } + }, + + toHex: function toHex (data) { + var out = [] + for (var i = 0; i < data.length; i++) { + out.push(('0' + data.charCodeAt(i).toString(16)).substr(-2, 2)) + } + return out.join('') + }, + + createHash: function createHash (algorithm) { + return util.crypto.lib.createHash(algorithm) + } + } +} + +module.exports = util diff --git a/packages/libs/lib-jdcloud/src/repo/ag/v1/ag.js b/packages/libs/lib-jdcloud/src/repo/ag/v1/ag.js new file mode 100644 index 000000000..655816f44 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/ag/v1/ag.js @@ -0,0 +1,4150 @@ +/* + * 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. + * + * Quota + * 关于高可用组配额的接口 + * + * 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 = 'ag' +Service._services[serviceId] = true + +/** + * ag service. + * @version 0.8.5 + */ + +class AG extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'ag.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 使用过滤条件查询一个或多个弹性伸缩活动 + * @param {Object} opts - parameters + * @param {string} opts.agId - 高可用组 ID + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 100] optional + * @param {filter} [opts.filters] - status - 状态,包括成功:SUCCESS,拒绝:REJECTED,失败:FAILED,执行中:RUNNING,部分成功:WARN,精确匹配 +beginTime - 开始时间,精确匹配,查询大于等于这个时间的记录 +endTime - 结束时间,精确匹配,查询小于等于这个时间的记录 +以上每个filter项仅支持单个值查询,如果传多个值仅取第一个值 + optional + * @param {sort} [opts.sorts] - 排序条件列表,目前只支持单个排序条件,不支持多个排序条件,默认按照 `startTime` 降序排序 +支持使用以下关键字进行排序 +- `startTime`: 活动开始时间 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param activity scalingActivities + * @param integer totalCount + */ + + describeScalingActivities (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 describeScalingActivities" + ) + } + + opts = opts || {} + + if (opts.agId === undefined || opts.agId === null) { + throw new Error( + "Missing the required parameter 'opts.agId' when calling describeScalingActivities" + ) + } + + 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')) + Object.assign(queryParams, super.buildSortParam(opts.sorts, 'sorts')) + + let pathParams = { + regionId: regionId, + agId: opts.agId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ag/0.8.5' + } + + 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 describeScalingActivities 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}/autoScaling/{agId}:describeScalingActivities', + '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`,最小值必须大于0 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为`20`,取值范围[`10` ~ `100`] optional + * @param {filter} [opts.filters] - 支持使用以下关键字进行过滤查询 +- `agId`: 高可用组ID,精确匹配,支持多个 +- `asAlarmId`: 告警任务ID,精确匹配,支持多个 +- `name`: 告警任务名称,模糊匹配,支持单个 +- `metricType`: 监控项类型,精确匹配,支持多个,取值范围:[`System`,`Custom`] + optional + * @param {sort} [opts.sorts] - 排序条件列表,目前只支持单个排序条件,不支持多个排序条件,默认按照 `createTime` 降序排序 +支持使用以下关键字进行排序 +- `createTime`: 创建时间 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount 本次查询可匹配到的总记录数,使用者需要结合 `pageNumber` 和 `pageSize` 计算是否可以继续分页。 + * @param asAlarmInfo asAlarms + */ + + describeAsAlarms (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 describeAsAlarms" + ) + } + + 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')) + Object.assign(queryParams, super.buildSortParam(opts.sorts, 'sorts')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ag/0.8.5' + } + + 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 describeAsAlarms 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}/asAlarms', + '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.agId - 高可用组ID + * @param {string} opts.name - 名称,长度为1~32个字符,只允许中文、数字、大小写字母、英文下划线(_)、连字符(-) + * @param {string} [opts.description] - 描述,最大长度为256个字符 optional + * @param {string} opts.metricType - 监控项类型,取值范围:[`System`,`Custom`] +- `System`:系统监控项 +- `Custom`:自定义监控项 + + * @param {string} opts.metricName - 监控项,云主机监控指标说明:https://docs.jdcloud.com/cn/monitoring/vm +目前支持的指标项如下: +- `cpu_util`: `CPU使用率` +- `memory.usage`: `内存使用率` +- `vm.disk.bytes.read`: `磁盘读吞吐量(host)` +- `vm.disk.bytes.write`: `磁盘写吞吐量(host)` +- `vm.network.bytes.incoming`: `网络进速率(host)` +- `vm.network.bytes.outgoing`: `网络出速率(host)` + + * @param {string} [opts.namespace] - 命名空间,当`metricType`为`Custom`,此参数必填 optional + * @param {integer} opts.period - 监控项数据统计周期,单位分钟,取值范围:[`1`,`2`,`5`,`10`,`15`,`30`,`60`] + * @param {string} opts.statistic - 统计监控项数据的方法 +- 系统监控取值范围:[`avg`,`max`,`min`] +- 自定义监控取值范围:[`avg`] + + * @param {number} opts.threshold - 监控指标的阈值,必须大于0,阈值单位与监控项单位一致 + * @param {string} opts.comparison - 对监控项阈值的判断方式,取值范围:[`gte`:`大于等于`,`lte`:`小于等于`,`gt`:`大于`,`lt`:`小于`] + * @param {integer} [opts.hitCount] - 触发告警需要满足阈值表达式的次数,默认为`3`,取值范围:[`1`,`2`,`3`,`5`,`10`,`15`,`30`,`60`] optional + * @param {string} [opts.asRuleId] - 伸缩规则ID,可以为告警任务绑定伸缩规则,目前只支持 `asRuleType` 为 `Simple` 的伸缩规则 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string asAlarmId 告警任务ID + */ + + createAsAlarm (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 createAsAlarm" + ) + } + + opts = opts || {} + + if (opts.agId === undefined || opts.agId === null) { + throw new Error( + "Missing the required parameter 'opts.agId' when calling createAsAlarm" + ) + } + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createAsAlarm" + ) + } + if (opts.metricType === undefined || opts.metricType === null) { + throw new Error( + "Missing the required parameter 'opts.metricType' when calling createAsAlarm" + ) + } + if (opts.metricName === undefined || opts.metricName === null) { + throw new Error( + "Missing the required parameter 'opts.metricName' when calling createAsAlarm" + ) + } + if (opts.period === undefined || opts.period === null) { + throw new Error( + "Missing the required parameter 'opts.period' when calling createAsAlarm" + ) + } + if (opts.statistic === undefined || opts.statistic === null) { + throw new Error( + "Missing the required parameter 'opts.statistic' when calling createAsAlarm" + ) + } + if (opts.threshold === undefined || opts.threshold === null) { + throw new Error( + "Missing the required parameter 'opts.threshold' when calling createAsAlarm" + ) + } + if (opts.comparison === undefined || opts.comparison === null) { + throw new Error( + "Missing the required parameter 'opts.comparison' when calling createAsAlarm" + ) + } + + let postBody = {} + if (opts.agId !== undefined && opts.agId !== null) { + postBody['agId'] = opts.agId + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.metricType !== undefined && opts.metricType !== null) { + postBody['metricType'] = opts.metricType + } + if (opts.metricName !== undefined && opts.metricName !== null) { + postBody['metricName'] = opts.metricName + } + if (opts.namespace !== undefined && opts.namespace !== null) { + postBody['namespace'] = opts.namespace + } + if (opts.period !== undefined && opts.period !== null) { + postBody['period'] = opts.period + } + if (opts.statistic !== undefined && opts.statistic !== null) { + postBody['statistic'] = opts.statistic + } + if (opts.threshold !== undefined && opts.threshold !== null) { + postBody['threshold'] = opts.threshold + } + if (opts.comparison !== undefined && opts.comparison !== null) { + postBody['comparison'] = opts.comparison + } + if (opts.hitCount !== undefined && opts.hitCount !== null) { + postBody['hitCount'] = opts.hitCount + } + if (opts.asRuleId !== undefined && opts.asRuleId !== null) { + postBody['asRuleId'] = opts.asRuleId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ag/0.8.5' + } + + 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 createAsAlarm 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}/asAlarms', + '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.asAlarmId - 告警任务ID + * @param {string} [opts.name] - 名称,长度为1~32个字符,只允许中文、数字、大小写字母、英文下划线(_)、连字符(-) optional + * @param {string} [opts.description] - 描述,最大长度为256个字符 optional + * @param {string} [opts.metricName] - 监控项,云主机监控指标说明:https://docs.jdcloud.com/cn/monitoring/vm +目前支持的指标项如下: +- `cpu_util`: `CPU使用率` +- `memory.usage`: `内存使用率` +- `vm.disk.bytes.read`: `磁盘读吞吐量(host)` +- `vm.disk.bytes.write`: `磁盘写吞吐量(host)` +- `vm.network.bytes.incoming`: `网络进速率(host)` +- `vm.network.bytes.outgoing`: `网络出速率(host)` + optional + * @param {integer} [opts.period] - 监控项数据统计周期,单位分钟,取值范围:[`1`,`2`,`5`,`10`,`15`,`30`,`60`] optional + * @param {string} [opts.statistic] - 统计监控项数据的方法 +- 系统监控取值范围:[`avg`,`max`,`min`] +- 自定义监控取值范围:[`avg`] + optional + * @param {number} [opts.threshold] - 监控指标的阈值,必须大于0,阈值单位与监控项单位一致 optional + * @param {string} [opts.comparison] - 对监控项阈值的判断方式,取值范围:[`gte`:`大于等于`,`lte`:`小于等于`,`gt`:`大于`,`lt`:`小于`] optional + * @param {integer} [opts.hitCount] - 触发告警需要满足阈值表达式的次数,取值范围:[`1`,`2`,`3`,`5`,`10`,`15`,`30`,`60`] optional + * @param {string} [opts.asRuleId] - 伸缩规则ID,更新告警任务关联的伸缩规则,目前只支持 `asRuleType` 为 `Simple` 的伸缩规则 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateAsAlarm (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 updateAsAlarm" + ) + } + + opts = opts || {} + + if (opts.asAlarmId === undefined || opts.asAlarmId === null) { + throw new Error( + "Missing the required parameter 'opts.asAlarmId' when calling updateAsAlarm" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.metricName !== undefined && opts.metricName !== null) { + postBody['metricName'] = opts.metricName + } + if (opts.period !== undefined && opts.period !== null) { + postBody['period'] = opts.period + } + if (opts.statistic !== undefined && opts.statistic !== null) { + postBody['statistic'] = opts.statistic + } + if (opts.threshold !== undefined && opts.threshold !== null) { + postBody['threshold'] = opts.threshold + } + if (opts.comparison !== undefined && opts.comparison !== null) { + postBody['comparison'] = opts.comparison + } + if (opts.hitCount !== undefined && opts.hitCount !== null) { + postBody['hitCount'] = opts.hitCount + } + if (opts.asRuleId !== undefined && opts.asRuleId !== null) { + postBody['asRuleId'] = opts.asRuleId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + asAlarmId: opts.asAlarmId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ag/0.8.5' + } + + 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 updateAsAlarm 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}/asAlarms/{asAlarmId}', + '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.asAlarmId - 告警任务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteAsAlarm (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 deleteAsAlarm" + ) + } + + opts = opts || {} + + if (opts.asAlarmId === undefined || opts.asAlarmId === null) { + throw new Error( + "Missing the required parameter 'opts.asAlarmId' when calling deleteAsAlarm" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + asAlarmId: opts.asAlarmId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ag/0.8.5' + } + + 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 deleteAsAlarm 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}/asAlarms/{asAlarmId}', + '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.asAlarmId - 告警任务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + disableAsAlarm (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 disableAsAlarm" + ) + } + + opts = opts || {} + + if (opts.asAlarmId === undefined || opts.asAlarmId === null) { + throw new Error( + "Missing the required parameter 'opts.asAlarmId' when calling disableAsAlarm" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + asAlarmId: opts.asAlarmId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ag/0.8.5' + } + + 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 disableAsAlarm 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}/asAlarms/{asAlarmId}:disable', + '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.asAlarmId - 告警任务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + enableAsAlarm (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 enableAsAlarm" + ) + } + + opts = opts || {} + + if (opts.asAlarmId === undefined || opts.asAlarmId === null) { + throw new Error( + "Missing the required parameter 'opts.asAlarmId' when calling enableAsAlarm" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + asAlarmId: opts.asAlarmId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ag/0.8.5' + } + + 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 enableAsAlarm 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}/asAlarms/{asAlarmId}:enable', + '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.pageNumber] - 页码,默认为`1`,最小值必须大于0 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为`20`,取值范围[`10` ~ `100`] optional + * @param {filter} [opts.filters] - 支持使用以下关键字进行过滤查询 +- `agId`: 高可用组ID,精确匹配,支持多个 +- `asCronId`: 定时任务ID,精确匹配,支持多个 +- `name`: 定时任务名称,模糊匹配,支持单个 + optional + * @param {sort} [opts.sorts] - 排序条件列表,目前只支持单个排序条件,不支持多个排序条件,默认按照 `createTime` 降序排序 +支持使用以下关键字进行排序 +- `createTime`: 创建时间 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount 本次查询可匹配到的总记录数,使用者需要结合 `pageNumber` 和 `pageSize` 计算是否可以继续分页。 + * @param asCronInfo asCrons + */ + + describeAsCrons (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 describeAsCrons" + ) + } + + 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')) + Object.assign(queryParams, super.buildSortParam(opts.sorts, 'sorts')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ag/0.8.5' + } + + 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 describeAsCrons 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}/asCrons', + '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.agId - 高可用组ID + * @param {string} opts.name - 名称,长度为1~32个字符,只允许中文、数字、大小写字母、英文下划线(_)、连字符(-) + * @param {string} [opts.description] - 描述,最大长度为256个字符 optional + * @param {string} [opts.asRuleId] - 可以为定时任务绑定伸缩规则,目前只支持简单规则,即 `asRuleType` 为 `Simple` 的伸缩规则 +- 当指定参数`asRuleId`时,不允许指定参数`minSize`,`maxSize`,`desiredCapacity` + optional + * @param {integer} [opts.minSize] - 设置伸缩组最小实例数,必须大于等于0,如果没有设置此参数,则此参数将会保存为 -1 +- 如果没有指定参数`asRuleId`,则参数`minSize`,`maxSize`,`desiredCapacity`三者至少填写一个 + optional + * @param {integer} [opts.maxSize] - 设置伸缩组最大实例数,必须大于等于0,如果没有设置此参数,则此参数将会保存为 -1 +- 如果没有指定参数`asRuleId`,则参数`minSize`,`maxSize`,`desiredCapacity`三者至少填写一个 + optional + * @param {integer} [opts.desiredCapacity] - 设置伸缩组期望实例数,必须大于等于0,如果没有设置此参数,则此参数将会保存为 -1 +- 如果没有指定参数`asRuleId`,则参数`minSize`,`maxSize`,`desiredCapacity`三者至少填写一个 + optional + * @param {string} opts.launchTime - 定时任务触发的时间点 +时间格式:`2023-05-10 10:10:00`,目前只支持到分钟,秒数会被忽略,但是需要严格按照此时间格式填写 +- 如果未指定`repeatType`,则按指定的日期和时间执行一次 +- 如果指定了`repeatType`,则此属性指定的时间点,表示从这个时间之后开始按照重复周期执行定时任务 +时间限制如下: +- 时间必须大于当前时间 +- 不能填写当前时间起30日后的时间 +- 时间必须小于`repeatEndTime` + + * @param {string} [opts.repeatType] - 重复执行定时任务的类型,如果指定了`repeatType`,则`repeatValue`必填 +取值范围:[`Daily`,`Weekly`,`Monthly`,`Cron`] +- Daily:每多少天重复执行一次定时任务 +- Weekly:每周指定几天重复执行一次定时任务 +- Monthly:每月内指定几天重复执行一次定时任务 +- Cron:按照指定的Cron表达式执行定时任务 + optional + * @param {string} [opts.repeatValue] - 重复执行定时任务的数值,如果指定了`repeatType`,则`repeatValue`必填 +- `repeatType`取值为`Daily`时,只能填一个值,取值范围:[ `1` ~ `31` ],表示:每几天执行 +- `repeatType`取值为`Weekly`时,可以填入多个值,填多个值时使用半角逗号(,)分隔。取值范围:[`0`,`1`,`2`,`3`,`4`,`5`,`6`],分别对应:周日、周一、周二、周三、周四、周五、周六,表示:每周几执行 +- `repeatType`取值为`Monthly`时,格式为A-B。A、B的取值范围:[ `1` ~ `31` ],并且B必须大于等于A,表示:每个月的几号到几号执行 +- `repeatType`取值为`Cron`时,必须填写Cron表达式,不支持秒,最小单位为分钟 + +支持的Cron格式如下: +* * * * * 从左到右依次表示:`[分] [小时] [日] [月] [周]` + +- 分,取值范围:[`0` ~ `59`],允许的连接符号取值范围:[`*` `/` `,` `-`] +- 小时,取值范围:[`0` ~ `23`],允许的连接符号取值范围:[`*` `/` `,` `-`] +- 日,取值范围:[`1` ~ `31`],允许的连接符号取值范围:[`*` `/` `,` `-` `?`] +- 月,取值范围:[`1` ~ `12`],允许的连接符号取值范围:[`*` `/` `,` `-`] +- 周,取值范围:[`0` ~ `6`],允许的连接符号取值范围:[`*` `/` `,` `-` `?`] + +符号解析:`*`表示任意值,`/`表示步长,`,`表示多个值,`-`表示范围,`?`表示不指定值 + +示例:0 10 * * * 表示:每天10点执行 + optional + * @param {string} [opts.repeatEndTime] - 重复执行定时任务的结束时间 +默认为空,表示不限制结束时间,一直重复执行 +时间格式:`2023-05-10 10:10:00`,目前只支持到分钟,秒数会被忽略,但是需要严格按照此时间格式填写 +时间限制如下: +- 时间必须大于`launchTime` + optional + * @param {integer} [opts.launchExpirationTime] - 定时任务触发操作失败后,在此时间内重试,单位为秒,默认为600,取值范围:[`0` ~ `1800`] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string asCronId 定时任务ID + */ + + createAsCron (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 createAsCron" + ) + } + + opts = opts || {} + + if (opts.agId === undefined || opts.agId === null) { + throw new Error( + "Missing the required parameter 'opts.agId' when calling createAsCron" + ) + } + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createAsCron" + ) + } + if (opts.launchTime === undefined || opts.launchTime === null) { + throw new Error( + "Missing the required parameter 'opts.launchTime' when calling createAsCron" + ) + } + + let postBody = {} + if (opts.agId !== undefined && opts.agId !== null) { + postBody['agId'] = opts.agId + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.asRuleId !== undefined && opts.asRuleId !== null) { + postBody['asRuleId'] = opts.asRuleId + } + if (opts.minSize !== undefined && opts.minSize !== null) { + postBody['minSize'] = opts.minSize + } + if (opts.maxSize !== undefined && opts.maxSize !== null) { + postBody['maxSize'] = opts.maxSize + } + if (opts.desiredCapacity !== undefined && opts.desiredCapacity !== null) { + postBody['desiredCapacity'] = opts.desiredCapacity + } + if (opts.launchTime !== undefined && opts.launchTime !== null) { + postBody['launchTime'] = opts.launchTime + } + if (opts.repeatType !== undefined && opts.repeatType !== null) { + postBody['repeatType'] = opts.repeatType + } + if (opts.repeatValue !== undefined && opts.repeatValue !== null) { + postBody['repeatValue'] = opts.repeatValue + } + if (opts.repeatEndTime !== undefined && opts.repeatEndTime !== null) { + postBody['repeatEndTime'] = opts.repeatEndTime + } + if ( + opts.launchExpirationTime !== undefined && + opts.launchExpirationTime !== null + ) { + postBody['launchExpirationTime'] = opts.launchExpirationTime + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ag/0.8.5' + } + + 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 createAsCron 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}/asCrons', + '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.asCronId - 定时任务ID + * @param {string} [opts.agId] - 高可用组ID optional + * @param {string} [opts.name] - 名称,长度为1~32个字符,只允许中文、数字、大小写字母、英文下划线(_)、连字符(-) optional + * @param {string} [opts.description] - 描述,最大长度为256个字符 optional + * @param {string} [opts.asRuleId] - 可以为定时任务绑定伸缩规则,目前只支持简单规则,即 `asRuleType` 为 `Simple` 的伸缩规则 +- 如果指定了参数`asRuleId`,则不允许指定参数`minSize`,`maxSize`,`desiredCapacity` +- 如果指定了参数`asRuleId`,并且当前伸缩方式为执行简单规则,那么表示更换定时任务关联的伸缩规则 +- 如果指定了参数`asRuleId`,但是当前伸缩方式为修改伸缩组属性[`minSize`,`maxSize`,`desiredCapacity`],那么将会清空`minSize`,`maxSize`,`desiredCapacity`的值,同时设置`asRuleId`的值 + optional + * @param {integer} [opts.minSize] - 设置伸缩组最小实例数,必须大于等于0,如果没有设置此参数,则此参数将会保存为 -1 +- 如果指定了参数`minSize`,`maxSize`,`desiredCapacity`三者任意一个或多个,则不允许指定参数`asRuleId` +- 如果指定了参数`minSize`,`maxSize`,`desiredCapacity`三者任意一个或多个,并且当前伸缩方式为修改伸缩组属性[`minSize`,`maxSize`,`desiredCapacity`],那么将会更新`minSize`,`maxSize`,`desiredCapacity`指定的参数值 +- 如果指定了参数`minSize`,`maxSize`,`desiredCapacity`三者任意一个或多个,但是当前伸缩方式为执行简单规则,那么将会清空`asRuleId`的值,同时设置`minSize`,`maxSize`,`desiredCapacity`指定的参数值 + optional + * @param {integer} [opts.maxSize] - 设置伸缩组最大实例数,必须大于等于0,如果没有设置此参数,则此参数将会保存为 -1 +- 如果指定了参数`minSize`,`maxSize`,`desiredCapacity`三者任意一个或多个,则不允许指定参数`asRuleId` +- 如果指定了参数`minSize`,`maxSize`,`desiredCapacity`三者任意一个或多个,并且当前伸缩方式为修改伸缩组属性[`minSize`,`maxSize`,`desiredCapacity`],那么将会更新`minSize`,`maxSize`,`desiredCapacity`指定的参数值 +- 如果指定了参数`minSize`,`maxSize`,`desiredCapacity`三者任意一个或多个,但是当前伸缩方式为执行简单规则,那么将会清空`asRuleId`的值,同时设置`minSize`,`maxSize`,`desiredCapacity`指定的参数值 + optional + * @param {integer} [opts.desiredCapacity] - 设置伸缩组期望实例数,必须大于等于0,如果没有设置此参数,则此参数将会保存为 -1 +- 如果指定了参数`minSize`,`maxSize`,`desiredCapacity`三者任意一个或多个,则不允许指定参数`asRuleId` +- 如果指定了参数`minSize`,`maxSize`,`desiredCapacity`三者任意一个或多个,并且当前伸缩方式为修改伸缩组属性[`minSize`,`maxSize`,`desiredCapacity`],那么将会更新`minSize`,`maxSize`,`desiredCapacity`指定的参数值 +- 如果指定了参数`minSize`,`maxSize`,`desiredCapacity`三者任意一个或多个,但是当前伸缩方式为执行简单规则,那么将会清空`asRuleId`的值,同时设置`minSize`,`maxSize`,`desiredCapacity`指定的参数值 + optional + * @param {string} [opts.launchTime] - 定时任务触发的时间点 +时间格式:`2023-05-10 10:10:00`,目前只支持到分钟,秒数会被忽略,但是需要严格按照此时间格式填写 +- 如果未指定`repeatType`,则按指定的日期和时间执行一次 +- 如果指定了`repeatType`,则此属性指定的时间点,表示从这个时间之后开始按照重复周期执行定时任务 +时间限制如下: +- 时间必须大于当前时间 +- 不能填写当前时间起30日后的时间 +- 时间必须小于`repeatEndTime` + optional + * @param {string} [opts.repeatType] - 重复执行定时任务的类型,如果指定了`repeatType`,则`repeatValue`必填 +取值范围:[`Daily`,`Weekly`,`Monthly`,`Cron`] +- Daily:每多少天重复执行一次定时任务 +- Weekly:每周指定几天重复执行一次定时任务 +- Monthly:每月内指定几天重复执行一次定时任务 +- Cron:按照指定的Cron表达式执行定时任务 + optional + * @param {string} [opts.repeatValue] - 重复执行定时任务的数值,如果指定了`repeatType`,则`repeatValue`必填 +- `repeatType`取值为`Daily`时,只能填一个值,取值范围:[ `1` ~ `31` ],表示:每几天执行 +- `repeatType`取值为`Weekly`时,可以填入多个值,填多个值时使用半角逗号(,)分隔。取值范围:[`0`,`1`,`2`,`3`,`4`,`5`,`6`],分别对应:周日、周一、周二、周三、周四、周五、周六,表示:每周几执行 +- `repeatType`取值为`Monthly`时,格式为A-B。A、B的取值范围:[ `1` ~ `31` ],并且B必须大于等于A,表示:每个月的几号到几号执行 +- `repeatType`取值为`Cron`时,必须填写Cron表达式,不支持秒,最小单位为分钟 + +支持的Cron格式如下: +* * * * * 从左到右依次表示:`[分] [小时] [日] [月] [周]` + +- 分,取值范围:[`0` ~ `59`],允许的连接符号取值范围:[`*` `/` `,` `-`] +- 小时,取值范围:[`0` ~ `23`],允许的连接符号取值范围:[`*` `/` `,` `-`] +- 日,取值范围:[`1` ~ `31`],允许的连接符号取值范围:[`*` `/` `,` `-` `?`] +- 月,取值范围:[`1` ~ `12`],允许的连接符号取值范围:[`*` `/` `,` `-`] +- 周,取值范围:[`0` ~ `6`],允许的连接符号取值范围:[`*` `/` `,` `-` `?`] + +符号解析:`*`表示任意值,`/`表示步长,`,`表示多个值,`-`表示范围,`?`表示不指定值 + +示例:0 10 * * * 表示:每天10点执行 + optional + * @param {string} [opts.repeatEndTime] - 重复执行定时任务的结束时间 +默认为空,表示不限制结束时间,一直重复执行 +时间格式:`2023-05-10 10:10:00`,目前只支持到分钟,秒数会被忽略,但是需要严格按照此时间格式填写 +时间限制如下: +- 时间必须大于`launchTime` + optional + * @param {integer} [opts.launchExpirationTime] - 定时任务触发操作失败后,在此时间内重试,单位为秒,取值范围:[`0` ~ `1800`] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateAsCron (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 updateAsCron" + ) + } + + opts = opts || {} + + if (opts.asCronId === undefined || opts.asCronId === null) { + throw new Error( + "Missing the required parameter 'opts.asCronId' when calling updateAsCron" + ) + } + + let postBody = {} + if (opts.agId !== undefined && opts.agId !== null) { + postBody['agId'] = opts.agId + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.asRuleId !== undefined && opts.asRuleId !== null) { + postBody['asRuleId'] = opts.asRuleId + } + if (opts.minSize !== undefined && opts.minSize !== null) { + postBody['minSize'] = opts.minSize + } + if (opts.maxSize !== undefined && opts.maxSize !== null) { + postBody['maxSize'] = opts.maxSize + } + if (opts.desiredCapacity !== undefined && opts.desiredCapacity !== null) { + postBody['desiredCapacity'] = opts.desiredCapacity + } + if (opts.launchTime !== undefined && opts.launchTime !== null) { + postBody['launchTime'] = opts.launchTime + } + if (opts.repeatType !== undefined && opts.repeatType !== null) { + postBody['repeatType'] = opts.repeatType + } + if (opts.repeatValue !== undefined && opts.repeatValue !== null) { + postBody['repeatValue'] = opts.repeatValue + } + if (opts.repeatEndTime !== undefined && opts.repeatEndTime !== null) { + postBody['repeatEndTime'] = opts.repeatEndTime + } + if ( + opts.launchExpirationTime !== undefined && + opts.launchExpirationTime !== null + ) { + postBody['launchExpirationTime'] = opts.launchExpirationTime + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + asCronId: opts.asCronId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ag/0.8.5' + } + + 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 updateAsCron 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}/asCrons/{asCronId}', + '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.asCronId - 定时任务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteAsCron (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 deleteAsCron" + ) + } + + opts = opts || {} + + if (opts.asCronId === undefined || opts.asCronId === null) { + throw new Error( + "Missing the required parameter 'opts.asCronId' when calling deleteAsCron" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + asCronId: opts.asCronId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ag/0.8.5' + } + + 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 deleteAsCron 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}/asCrons/{asCronId}', + '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.asCronId - 定时任务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + disableAsCron (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 disableAsCron" + ) + } + + opts = opts || {} + + if (opts.asCronId === undefined || opts.asCronId === null) { + throw new Error( + "Missing the required parameter 'opts.asCronId' when calling disableAsCron" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + asCronId: opts.asCronId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ag/0.8.5' + } + + 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 disableAsCron 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}/asCrons/{asCronId}:disable', + '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.asCronId - 定时任务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + enableAsCron (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 enableAsCron" + ) + } + + opts = opts || {} + + if (opts.asCronId === undefined || opts.asCronId === null) { + throw new Error( + "Missing the required parameter 'opts.asCronId' when calling enableAsCron" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + asCronId: opts.asCronId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ag/0.8.5' + } + + 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 enableAsCron 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}/asCrons/{asCronId}:enable', + '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.agId - 高可用组 ID + * @param {boolean} [opts.isManaged] - 高可用中实例是否托管给弹性伸缩组,托管后缩容时可以删除该实例,默认false optional + * @param {autoscalingSpec} [opts.autoscalingSpec] - 伸缩组详细信息,如果高可用组已开启过伸缩功能,该参数将被忽略 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + enableAutoScaling (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 enableAutoScaling" + ) + } + + opts = opts || {} + + if (opts.agId === undefined || opts.agId === null) { + throw new Error( + "Missing the required parameter 'opts.agId' when calling enableAutoScaling" + ) + } + + let postBody = {} + if (opts.isManaged !== undefined && opts.isManaged !== null) { + postBody['isManaged'] = opts.isManaged + } + if (opts.autoscalingSpec !== undefined && opts.autoscalingSpec !== null) { + postBody['autoscalingSpec'] = opts.autoscalingSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + agId: opts.agId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ag/0.8.5' + } + + 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 enableAutoScaling 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}/autoScaling/{agId}', + '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.agId - 高可用组 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + disableAutoScaling (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 disableAutoScaling" + ) + } + + opts = opts || {} + + if (opts.agId === undefined || opts.agId === null) { + throw new Error( + "Missing the required parameter 'opts.agId' when calling disableAutoScaling" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + agId: opts.agId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ag/0.8.5' + } + + 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 disableAutoScaling 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}/autoScaling/{agId}:disable', + '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) + } + ) + } + + /** + * 更新弹性伸缩组 + * @param {Object} opts - parameters + * @param {string} opts.agId - 高可用组 ID + * @param {autoscalingSpecByUpdate} opts.autoscalingSpec - 伸缩组详细信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateAutoScaling (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 updateAutoScaling" + ) + } + + opts = opts || {} + + if (opts.agId === undefined || opts.agId === null) { + throw new Error( + "Missing the required parameter 'opts.agId' when calling updateAutoScaling" + ) + } + if (opts.autoscalingSpec === undefined || opts.autoscalingSpec === null) { + throw new Error( + "Missing the required parameter 'opts.autoscalingSpec' when calling updateAutoScaling" + ) + } + + let postBody = {} + if (opts.autoscalingSpec !== undefined && opts.autoscalingSpec !== null) { + postBody['autoscalingSpec'] = opts.autoscalingSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + agId: opts.agId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ag/0.8.5' + } + + 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 updateAutoScaling 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}/autoScaling/{agId}:updateAutoScaling', + '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.agId - 高可用组 ID + * @param {boolean} opts.isManaged - 实例是否托管给弹性伸缩组,托管后缩容时可以删除该实例。 + * @param {array} [opts.instanceIds] - 资源ID数组。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyInstancesManaged (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 modifyInstancesManaged" + ) + } + + opts = opts || {} + + if (opts.agId === undefined || opts.agId === null) { + throw new Error( + "Missing the required parameter 'opts.agId' when calling modifyInstancesManaged" + ) + } + if (opts.isManaged === undefined || opts.isManaged === null) { + throw new Error( + "Missing the required parameter 'opts.isManaged' when calling modifyInstancesManaged" + ) + } + + let postBody = {} + if (opts.isManaged !== undefined && opts.isManaged !== null) { + postBody['isManaged'] = opts.isManaged + } + if (opts.instanceIds !== undefined && opts.instanceIds !== null) { + postBody['instanceIds'] = opts.instanceIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + agId: opts.agId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ag/0.8.5' + } + + 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 modifyInstancesManaged 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}/autoScaling/{agId}:modifyInstancesManaged', + '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.agId - 高可用组 ID + * @param {boolean} opts.isProtected - 实例在弹性伸缩组是否为保护状态,保护状态的实例缩容时不可以删除。 + * @param {array} [opts.instanceIds] - 资源ID数组。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyInstancesProtected (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 modifyInstancesProtected" + ) + } + + opts = opts || {} + + if (opts.agId === undefined || opts.agId === null) { + throw new Error( + "Missing the required parameter 'opts.agId' when calling modifyInstancesProtected" + ) + } + if (opts.isProtected === undefined || opts.isProtected === null) { + throw new Error( + "Missing the required parameter 'opts.isProtected' when calling modifyInstancesProtected" + ) + } + + let postBody = {} + if (opts.isProtected !== undefined && opts.isProtected !== null) { + postBody['isProtected'] = opts.isProtected + } + if (opts.instanceIds !== undefined && opts.instanceIds !== null) { + postBody['instanceIds'] = opts.instanceIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + agId: opts.agId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ag/0.8.5' + } + + 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 modifyInstancesProtected 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}/autoScaling/{agId}:modifyInstancesProtected', + '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.agId - 高可用组ID + * @param {integer} [opts.pageNumber] - 页码,默认为`1`,最小值必须大于0 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为`20`,取值范围[`10` ~ `100`] optional + * @param {filter} [opts.filters] - 支持使用以下关键字进行过滤查询 +- `asRuleId`: 伸缩规则ID,精确匹配,支持多个 +- `name`: 伸缩规则名称,模糊匹配,支持单个 +- `asRuleType`: 伸缩规则类型,精确匹配,支持多个,取值范围:[`Simple`,`Target`,`Step`] + optional + * @param {sort} [opts.sorts] - 排序条件列表,目前只支持单个排序条件,不支持多个排序条件,默认按照 `createTime` 降序排序 +支持使用以下关键字进行排序 +- `createTime`: 创建时间 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount 本次查询可匹配到的总记录数,使用者需要结合 `pageNumber` 和 `pageSize` 计算是否可以继续分页。 + * @param asRuleInfo asRules + */ + + describeAsRules (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 describeAsRules" + ) + } + + opts = opts || {} + + if (opts.agId === undefined || opts.agId === null) { + throw new Error( + "Missing the required parameter 'opts.agId' when calling describeAsRules" + ) + } + + let postBody = null + let queryParams = {} + if (opts.agId !== undefined && opts.agId !== null) { + queryParams['agId'] = opts.agId + } + 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')) + Object.assign(queryParams, super.buildSortParam(opts.sorts, 'sorts')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ag/0.8.5' + } + + 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 describeAsRules 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}/asRules', + '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.agId - 高可用组ID + * @param {string} opts.name - 伸缩规则名称,长度为1~32个字符,只允许中文、数字、大小写字母、英文下划线(_)、连字符(-) + * @param {string} [opts.description] - 伸缩规则描述,最大长度为256个字符 optional + * @param {string} opts.asRuleType - 伸缩规则类型,取值范围:[`Simple`,`Target`,`Step`] +- `Simple`:简单规则,直接设置调整方式和调整值 +- `Target`:目标跟踪规则,根据监控项和目标值计算需要扩缩容的实例数量,尽量将监控项的指标值维持在目标值和目标值的90%之间 +- `Step`:步进规则,根据阈值和指标值提供分步扩展方式 + + * @param {createSimpleAsRuleSpec} [opts.simpleAsRuleSpec] - 简单规则相关参数,当`asRuleType`为`Simple`时必填 optional + * @param {createTargetAsRuleSpec} [opts.targetAsRuleSpec] - 目标跟踪规则相关参数,当`asRuleType`为`Target`时必填 optional + * @param {createStepAsRuleSpec} [opts.stepAsRuleSpec] - 步进规则相关参数,当`asRuleType`为`Step`时必填 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string asRuleId 伸缩规则ID + */ + + createAsRule (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 createAsRule" + ) + } + + opts = opts || {} + + if (opts.agId === undefined || opts.agId === null) { + throw new Error( + "Missing the required parameter 'opts.agId' when calling createAsRule" + ) + } + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createAsRule" + ) + } + if (opts.asRuleType === undefined || opts.asRuleType === null) { + throw new Error( + "Missing the required parameter 'opts.asRuleType' when calling createAsRule" + ) + } + + let postBody = {} + if (opts.agId !== undefined && opts.agId !== null) { + postBody['agId'] = opts.agId + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.asRuleType !== undefined && opts.asRuleType !== null) { + postBody['asRuleType'] = opts.asRuleType + } + if (opts.simpleAsRuleSpec !== undefined && opts.simpleAsRuleSpec !== null) { + postBody['simpleAsRuleSpec'] = opts.simpleAsRuleSpec + } + if (opts.targetAsRuleSpec !== undefined && opts.targetAsRuleSpec !== null) { + postBody['targetAsRuleSpec'] = opts.targetAsRuleSpec + } + if (opts.stepAsRuleSpec !== undefined && opts.stepAsRuleSpec !== null) { + postBody['stepAsRuleSpec'] = opts.stepAsRuleSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ag/0.8.5' + } + + 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 createAsRule 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}/asRules', + '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.asRuleId - 伸缩规则ID + * @param {string} [opts.name] - 伸缩规则名称,长度为1~32个字符,只允许中文、数字、大小写字母、英文下划线(_)、连字符(-) optional + * @param {string} [opts.description] - 伸缩规则描述,最大长度为256个字符 optional + * @param {updateSimpleAsRuleSpec} [opts.simpleAsRuleSpec] - 简单规则相关参数,当待修改的规则类型为`Simple`时,填写此参数才有效 optional + * @param {updateTargetAsRuleSpec} [opts.targetAsRuleSpec] - 目标跟踪规则相关参数,当待修改的规则类型为`Target`时,填写此参数才有效 optional + * @param {updateStepAsRuleSpec} [opts.stepAsRuleSpec] - 步进规则相关参数,当待修改的规则类型为`Step`时,填写此参数才有效 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateAsRule (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 updateAsRule" + ) + } + + opts = opts || {} + + if (opts.asRuleId === undefined || opts.asRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.asRuleId' when calling updateAsRule" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.simpleAsRuleSpec !== undefined && opts.simpleAsRuleSpec !== null) { + postBody['simpleAsRuleSpec'] = opts.simpleAsRuleSpec + } + if (opts.targetAsRuleSpec !== undefined && opts.targetAsRuleSpec !== null) { + postBody['targetAsRuleSpec'] = opts.targetAsRuleSpec + } + if (opts.stepAsRuleSpec !== undefined && opts.stepAsRuleSpec !== null) { + postBody['stepAsRuleSpec'] = opts.stepAsRuleSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + asRuleId: opts.asRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ag/0.8.5' + } + + 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 updateAsRule 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}/asRules/{asRuleId}', + '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.asRuleId - 伸缩规则ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteAsRule (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 deleteAsRule" + ) + } + + opts = opts || {} + + if (opts.asRuleId === undefined || opts.asRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.asRuleId' when calling deleteAsRule" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + asRuleId: opts.asRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ag/0.8.5' + } + + 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 deleteAsRule 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}/asRules/{asRuleId}', + '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.asRuleId - 伸缩规则ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + executeAsRule (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 executeAsRule" + ) + } + + opts = opts || {} + + if (opts.asRuleId === undefined || opts.asRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.asRuleId' when calling executeAsRule" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + asRuleId: opts.asRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ag/0.8.5' + } + + 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 executeAsRule 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}/asRules/{asRuleId}:execute', + '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.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 100] optional + * @param {filter} [opts.filters] - agName - ag名字,支持模糊匹配 +agId - ag id,精确匹配 +instanceTemplateId - 实例模板id,精确匹配 +vpcId - vpc id,精确匹配 +placementType - placement type,放置策略 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param availabilityGroup ags + * @param integer totalCount + */ + + describeAgs (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 describeAgs" + ) + } + + 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 ag/0.8.5' + } + + 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 describeAgs 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}/availabilityGroups', + '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 {array} [opts.azs] - 支持的可用区,最少一个 optional + * @param {string} opts.agName - 高可用组名称,只支持中文、数字、大小写字母、英文下划线 “_” 及中划线 “-”,且不能超过 32 字符 + * @param {string} [opts.agType] - 高可用组资源类型,支持vm optional + * @param {string} [opts.instanceTemplateId] - 实例模板的ID optional + * @param {string} [opts.description] - 描述,长度不超过 256 字符 optional + * @param {string} [opts.configurationType] - 高可用组配置类型,支持strict(关联模板型)、loose(自定义配置型) optional + * @param {string} [opts.placementType] - 高可用资源放置类型,支持fd、switch、host optional + * @param {autoscalingSpec} [opts.autoscalingSpec] - 伸缩组详细信息,当创建时选择打开弹性伸缩功能时需要传该参数 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string agId 创建成功的高可用组 ID + */ + + createAg (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 createAg" + ) + } + + opts = opts || {} + + if (opts.agName === undefined || opts.agName === null) { + throw new Error( + "Missing the required parameter 'opts.agName' when calling createAg" + ) + } + + let postBody = {} + if (opts.azs !== undefined && opts.azs !== null) { + postBody['azs'] = opts.azs + } + if (opts.agName !== undefined && opts.agName !== null) { + postBody['agName'] = opts.agName + } + if (opts.agType !== undefined && opts.agType !== null) { + postBody['agType'] = opts.agType + } + if ( + opts.instanceTemplateId !== undefined && + opts.instanceTemplateId !== null + ) { + postBody['instanceTemplateId'] = opts.instanceTemplateId + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if ( + opts.configurationType !== undefined && + opts.configurationType !== null + ) { + postBody['configurationType'] = opts.configurationType + } + if (opts.placementType !== undefined && opts.placementType !== null) { + postBody['placementType'] = opts.placementType + } + if (opts.autoscalingSpec !== undefined && opts.autoscalingSpec !== null) { + postBody['autoscalingSpec'] = opts.autoscalingSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ag/0.8.5' + } + + 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 createAg 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}/availabilityGroups', + '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) + } + ) + } + + /** + * 根据 ID 查询高可用组详情 + * @param {Object} opts - parameters + * @param {string} opts.agId - 高可用组 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param availabilityGroup ag + */ + + describeAg (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 describeAg" + ) + } + + opts = opts || {} + + if (opts.agId === undefined || opts.agId === null) { + throw new Error( + "Missing the required parameter 'opts.agId' when calling describeAg" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + agId: opts.agId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ag/0.8.5' + } + + 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 describeAg 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}/availabilityGroups/{agId}', + '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.agId - 高可用组 ID + * @param {string} [opts.description] - 描述,长度不超过 256 字符 optional + * @param {string} [opts.name] - 高可用组名称,只支持中文、数字、大小写字母、英文下划线 “_” 及中划线 “-”,且不能超过 32 字符 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateAg (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 updateAg" + ) + } + + opts = opts || {} + + if (opts.agId === undefined || opts.agId === null) { + throw new Error( + "Missing the required parameter 'opts.agId' when calling updateAg" + ) + } + + let postBody = {} + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + agId: opts.agId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ag/0.8.5' + } + + 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 updateAg 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}/availabilityGroups/{agId}', + 'PATCH', + 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) + } + ) + } + + /** + * 根据 ID 删除高可用组,需确保 AG 中云主机实例已全部删除 + * @param {Object} opts - parameters + * @param {string} opts.agId - 高可用组 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteAg (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 deleteAg" + ) + } + + opts = opts || {} + + if (opts.agId === undefined || opts.agId === null) { + throw new Error( + "Missing the required parameter 'opts.agId' when calling deleteAg" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + agId: opts.agId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ag/0.8.5' + } + + 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 deleteAg 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}/availabilityGroups/{agId}', + '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.agId - 高可用组 ID + * @param {array} [opts.instanceIds] - 准备剔除出高可用组的实例 ID optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + abandonInstances (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 abandonInstances" + ) + } + + opts = opts || {} + + if (opts.agId === undefined || opts.agId === null) { + throw new Error( + "Missing the required parameter 'opts.agId' when calling abandonInstances" + ) + } + + let postBody = {} + if (opts.instanceIds !== undefined && opts.instanceIds !== null) { + postBody['instanceIds'] = opts.instanceIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + agId: opts.agId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ag/0.8.5' + } + + 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 abandonInstances 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}/availabilityGroups/{agId}:abandonInstances', + '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>- 对于更换实例模板来说,如果已经关联负载均衡,则VPC不可以更改。<br>- 自定义配置型不可更改实例模板。 + * @param {Object} opts - parameters + * @param {string} opts.agId - 高可用组 ID + * @param {string} opts.instanceTemplateId - 实例模板 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + setInstanceTemplate (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 setInstanceTemplate" + ) + } + + opts = opts || {} + + if (opts.agId === undefined || opts.agId === null) { + throw new Error( + "Missing the required parameter 'opts.agId' when calling setInstanceTemplate" + ) + } + if ( + opts.instanceTemplateId === undefined || + opts.instanceTemplateId === null + ) { + throw new Error( + "Missing the required parameter 'opts.instanceTemplateId' when calling setInstanceTemplate" + ) + } + + let postBody = {} + if ( + opts.instanceTemplateId !== undefined && + opts.instanceTemplateId !== null + ) { + postBody['instanceTemplateId'] = opts.instanceTemplateId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + agId: opts.agId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ag/0.8.5' + } + + 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 setInstanceTemplate 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}/availabilityGroups/{agId}:setInstanceTemplate', + '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) + } + ) + } + + /** + * 查询(ag)配额 + * @param {Object} opts - parameters + * @param {filter} [opts.filters] - resourceTypes - 资源类型,暂时只支持[ag] + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param quota quotas + */ + + describeQuotas (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 describeQuotas" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ag/0.8.5' + } + + 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 describeQuotas 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}/quotas', + '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 = AG diff --git a/packages/libs/lib-jdcloud/src/repo/ams/v1/ams.js b/packages/libs/lib-jdcloud/src/repo/ams/v1/ams.js new file mode 100644 index 000000000..515cdb53c --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/ams/v1/ams.js @@ -0,0 +1,261 @@ +/* + * 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. + * + * 应用管理平台API (仅对授权用户使用) + * 应用管理平台API + * + * 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 = 'ams' +Service._services[serviceId] = true + +/** + * ams service. + * @version 1.0.0 + */ + +JDCloud.AMS = class AMS extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'ams.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 获取收流基础数据查询 + * @param {Object} opts - parameters + * @param {string} opts.streamId - 流ID + * @param {string} [opts.startTime] - 起始时间 optional + * @param {string} [opts.endTime] - 结束时间 optional + * @param {string} callback - callback + @return {Object} result + * @param streamInputData streamInputDatas + */ + + describeStreamsInput (opts, callback) { + opts = opts || {} + + if (opts.streamId === undefined || opts.streamId === null) { + throw new Error( + "Missing the required parameter 'opts.streamId' when calling describeStreamsInput" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: 'jdcloud', + streamId: opts.streamId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ams/1.0.0' + } + + 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 describeStreamsInput 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 = this.makeRequest( + '/streams/{streamId}/inputs', + '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.pId - PinId + * @param {integer} [opts.ver] - 版本 optional + * @param {string} callback - callback + @return {Object} result + * @param string pId PinId + * @param integer ver 版本 + * @param number blacklist 集合 + * @param integer status 状态 + * @param string license 授权号 + */ + + describeAuthenticate (opts, callback) { + opts = opts || {} + + if (opts.pId === undefined || opts.pId === null) { + throw new Error( + "Missing the required parameter 'opts.pId' when calling describeAuthenticate" + ) + } + + let postBody = null + let queryParams = {} + if (opts.ver !== undefined && opts.ver !== null) { + queryParams['ver'] = opts.ver + } + + let pathParams = { + regionId: 'jdcloud', + pId: opts.pId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ams/1.0.0' + } + + 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 describeAuthenticate 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 = this.makeRequest( + '/appManager/{pId}/authenticates', + '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 = JDCloud.AMS diff --git a/packages/libs/lib-jdcloud/src/repo/antipro/v1/antipro.js b/packages/libs/lib-jdcloud/src/repo/antipro/v1/antipro.js new file mode 100644 index 000000000..8ba93bb26 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/antipro/v1/antipro.js @@ -0,0 +1,5241 @@ +/* + * 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. + * + * Operation Records APIs + * Anti DDoS Protection Package Operation Records APIs + * + * 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 = 'antipro' +Service._services[serviceId] = true + +/** + * antipro service. + * @version 1.2.0 + */ + +class ANTIPRO extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'antipro.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询攻击记录, 参数 ip 优先级大于 instanceId. <br>- 指定 ip 参数时, 忽略 instanceId 参数, 查询 ip 相关攻击记录. <br>- 未指定 ip 时, 查询 instanceId 指定实例相关攻击记录. <br>- ip 和 instanceId 均未指定时, 查询用户所有公网 IP 攻击记录 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 分页大小 optional + * @param {string} opts.startTime - 开始时间, 只能查询最近 90 天以内的数据, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ + * @param {string} opts.endTime - 查询的结束时间, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ + * @param {string} [opts.instanceId] - 防护包实例 Id optional + * @param {string} [opts.ip] - DDoS 防护包已防护的公网 IP. <br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-protection-package/api/describeprotectediplist'>describeProtectedIpList</a> 接口查询 DDoS 防护包已防护的公网 IP optional + * @param {string} callback - callback + @return {Object} result + * @param attackLog dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 实例总数 + * @param integer totalPage 总页数 + */ + + describeAttackLogs (opts, callback) { + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeAttackLogs" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeAttackLogs" + ) + } + + 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.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.instanceId !== undefined && opts.instanceId !== null) { + queryParams['instanceId'] = opts.instanceId + } + Object.assign(queryParams, super.buildArrayParam(opts.ip, 'ip')) + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 describeAttackLogs 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( + '/attacklog', + '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 优先级大于 instanceId. <br>- 指定 ip 参数时, 忽略 instanceId 参数, 统计 ip 的攻击情况. <br>- 未指定 ip 时, 统计 instanceId 指定实例相关攻击情况. <br>- ip 和 instanceId 均未指定时, 查询用户所有公网 IP 攻击情况 + * @param {Object} opts - parameters + * @param {string} opts.startTime - 开始时间, 只能查询最近 90 天以内的数据, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ + * @param {string} opts.endTime - 结束时间, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ + * @param {string} [opts.instanceId] - 防护包实例 Id optional + * @param {string} [opts.ip] - DDoS 防护包已防护的公网 IP. <br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-protection-package/api/describeprotectediplist'>describeProtectedIpList</a> 接口查询 DDoS 防护包已防护的公网 IP optional + * @param {string} callback - callback + @return {Object} result + * @param integer attackCount 攻击次数 + * @param integer blackHoleCount 黑洞次数 + * @param number peak 攻击流量峰值 + * @param string unit 攻击流量单位 + */ + + describeAttackStatistics (opts, callback) { + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeAttackStatistics" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeAttackStatistics" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.instanceId !== undefined && opts.instanceId !== null) { + queryParams['instanceId'] = opts.instanceId + } + Object.assign(queryParams, super.buildArrayParam(opts.ip, 'ip')) + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 describeAttackStatistics 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( + '/describeAttackStatistics', + '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 优先级大于 instanceId. <br>- 指定 ip 参数时, 忽略 instanceId 参数, 查询 ip 相关攻击记录的各类型攻击次数<br>- 未指定 ip 时, 查询 instanceId 指定实例相关攻击记录的各类型攻击次数<br>- ip 和 instanceId 均未指定时, 查询用户所有公网 IP 攻击记录的各类型攻击次数 + * @param {Object} opts - parameters + * @param {string} opts.startTime - 开始时间, 只能查询最近 90 天以内的数据, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ + * @param {string} opts.endTime - 结束时间, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ + * @param {string} [opts.instanceId] - 防护包实例 Id optional + * @param {string} [opts.ip] - DDoS 防护包已防护的公网 IP. <br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-protection-package/api/describeprotectediplist'>describeProtectedIpList</a> 接口查询 DDoS 防护包已防护的公网 IP optional + * @param {string} callback - callback + @return {Object} result + * @param attackTypeCount dataList + */ + + describeAttackTypeCount (opts, callback) { + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeAttackTypeCount" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeAttackTypeCount" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.instanceId !== undefined && opts.instanceId !== null) { + queryParams['instanceId'] = opts.instanceId + } + Object.assign(queryParams, super.buildArrayParam(opts.ip, 'ip')) + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 describeAttackTypeCount 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( + '/describeAttackTypeCount', + '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.attackLogId - 攻击记录 Id + * @param {string} opts.ip - DDoS 防护包已防护的公网 IP. <br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-protection-package/api/describeprotectediplist'>describeProtectedIpList</a> 接口查询 DDoS 防护包已防护的公网 IP + * @param {string} callback - callback + @return {Object} result + * @param string data + */ + + describeAttackSource (opts, callback) { + opts = opts || {} + + if (opts.attackLogId === undefined || opts.attackLogId === null) { + throw new Error( + "Missing the required parameter 'opts.attackLogId' when calling describeAttackSource" + ) + } + if (opts.ip === undefined || opts.ip === null) { + throw new Error( + "Missing the required parameter 'opts.ip' when calling describeAttackSource" + ) + } + + let postBody = null + let queryParams = {} + if (opts.ip !== undefined && opts.ip !== null) { + queryParams['ip'] = opts.ip + } + + let pathParams = { + regionId: 'jdcloud', + attackLogId: opts.attackLogId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 describeAttackSource 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( + '/attacklog/{attackLogId}:describeAttackSource', + '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 的监控流量 + * @param {Object} opts - parameters + * @param {string} opts.startTime - 开始时间, 只能查询最近 90 天以内的数据, UTC 时间, 格式:yyyy-MM-dd'T'HH:mm:ssZ + * @param {string} opts.endTime - 查询的结束时间, UTC 时间, 格式:yyyy-MM-dd'T'HH:mm:ssZ + * @param {string} [opts.ip] - DDoS 防护包已防护的公网 IP. <br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-protection-package/api/describeprotectediplist'>describeProtectedIpList</a> 接口查询 DDoS 防护包已防护的公网 IP optional + * @param {string} callback - callback + @return {Object} result + * @param ipResourceFlow bps + * @param ipResourceFlow pps + */ + + describeIpMonitorFlow (opts, callback) { + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeIpMonitorFlow" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeIpMonitorFlow" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + Object.assign(queryParams, super.buildArrayParam(opts.ip, 'ip')) + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 describeIpMonitorFlow 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( + '/describeIpMonitorFlow', + '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] - 页码 optional + * @param {integer} [opts.pageSize] - 分页大小 optional + * @param {string} [opts.name] - 防护包名称, 支持模糊匹配 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instance dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 实例总数 + * @param integer totalPage 总页数 + */ + + 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.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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}/instances', + '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 {createInstanceSpec} opts.createInstanceSpec - 创建防护包实例请求参数 + * @param {autoRenewalSpec} [opts.autoRenewalSpec] - 自动续费配置, 默认不开通 optional + * @param {extraOperationSpec} [opts.extraOperationSpec] - 提交订单附加操作 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string instanceId 创建的防护包实例 Id + */ + + createInstance (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 createInstance" + ) + } + + opts = opts || {} + + if ( + opts.createInstanceSpec === undefined || + opts.createInstanceSpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.createInstanceSpec' when calling createInstance" + ) + } + + let postBody = {} + if ( + opts.createInstanceSpec !== undefined && + opts.createInstanceSpec !== null + ) { + postBody['createInstanceSpec'] = opts.createInstanceSpec + } + if (opts.autoRenewalSpec !== undefined && opts.autoRenewalSpec !== null) { + postBody['autoRenewalSpec'] = opts.autoRenewalSpec + } + if ( + opts.extraOperationSpec !== undefined && + opts.extraOperationSpec !== null + ) { + postBody['extraOperationSpec'] = opts.extraOperationSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 createInstance 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}/instances', + '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 - 防护包实例 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instance data + */ + + 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 || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeInstance" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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}/instances/{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.instanceId - 防护包实例 Id + * @param {modifyInstanceSpec} opts.modifyInstanceSpec - 升级防护包实例请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string instanceId 升级的防护包实例 Id + */ + + 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.modifyInstanceSpec === undefined || + opts.modifyInstanceSpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.modifyInstanceSpec' when calling modifyInstance" + ) + } + + let postBody = {} + if ( + opts.modifyInstanceSpec !== undefined && + opts.modifyInstanceSpec !== null + ) { + postBody['modifyInstanceSpec'] = opts.modifyInstanceSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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}/instances/{instanceId}', + 'PATCH', + 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 {modifyInstanceNameSpec} opts.modifyInstanceNameSpec - 修改防护包实例名称请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 修改结果, 0: 修改失败, 1: 修改成功 + * @param string message 修改失败时给出具体原因 + */ + + modifyInstanceName (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 modifyInstanceName" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyInstanceName" + ) + } + if ( + opts.modifyInstanceNameSpec === undefined || + opts.modifyInstanceNameSpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.modifyInstanceNameSpec' when calling modifyInstanceName" + ) + } + + let postBody = {} + if ( + opts.modifyInstanceNameSpec !== undefined && + opts.modifyInstanceNameSpec !== null + ) { + postBody['modifyInstanceNameSpec'] = opts.modifyInstanceNameSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 modifyInstanceName 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}/instances/{instanceId}:modifyInstanceName', + 'PATCH', + 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. <br>- 防护包仅能防护防护包实例所在区域的公网 IP, 且该公网 IP 未被其他防护包防护, 如果已经被其他防护包防护, 请先调用删除防护包防护 IP 接口删除防护 IP<br>- 防护包可添加的防护 IP 个数小于等于防护包的可防护 IP 数量减去已防护的 IP 数量<br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-protection-package/api/describeelasticipresources'>describeElasticIpResources</a> 接口查询防护包可防护的弹性公网 IP<br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-protection-package/api/describecpsipresources'>describeCpsIpResources</a> 接口查询防护包可防护的云物理服务器公网 IP<br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-protection-package/api/describewafipresources'>describeWafIpResources</a> 接口查询防护包可防护的Web应用防火墙公网 IP<br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-protection-package/api/describeccsipresources'>describeCcsIpResources</a> 接口查询防护包可防护的托管区公网 IP + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 防护包实例 Id + * @param {protectedIpSpec} opts.protectedIpSpec - 添加防护包防护 IP 请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 添加防护 IP 结果, 0: 添加失败, 1: 添加成功 + * @param string message 添加失败时给出具体原因 + */ + + addProtectedIp (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 addProtectedIp" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling addProtectedIp" + ) + } + if (opts.protectedIpSpec === undefined || opts.protectedIpSpec === null) { + throw new Error( + "Missing the required parameter 'opts.protectedIpSpec' when calling addProtectedIp" + ) + } + + let postBody = {} + if (opts.protectedIpSpec !== undefined && opts.protectedIpSpec !== null) { + postBody['protectedIpSpec'] = opts.protectedIpSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 addProtectedIp 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}/instances/{instanceId}:addProtectedIp', + '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) + } + ) + } + + /** + * 删除防护包防护 IP + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 防护包实例 Id + * @param {protectedIpSpec} opts.protectedIpSpec - 删除防护包防护 IP 请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 删除防护 IP 结果, 0: 删除失败, 1: 删除成功 + * @param string message 删除失败时给出具体原因 + */ + + deleteProtectedIp (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 deleteProtectedIp" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteProtectedIp" + ) + } + if (opts.protectedIpSpec === undefined || opts.protectedIpSpec === null) { + throw new Error( + "Missing the required parameter 'opts.protectedIpSpec' when calling deleteProtectedIp" + ) + } + + let postBody = {} + if (opts.protectedIpSpec !== undefined && opts.protectedIpSpec !== null) { + postBody['protectedIpSpec'] = opts.protectedIpSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 deleteProtectedIp 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}/instances/{instanceId}:deleteProtectedIp', + '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) + } + ) + } + + /** + * 查询已防护 IP 列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 分页大小 optional + * @param {string} [opts.instanceId] - 实例 Id, 缺省时查询用户所有已防护 IP optional + * @param {integer} opts.type - 被防护 IP类型. <br>- 0: 全部<br>- 1: 弹性公网 IP<br>- 2: 云物理服务器公网 IP<br>- 3: Web应用防护墙公网 IP<br>- 4: 托管区公网 IP + * @param {string} [opts.ip] - 被防护 IP, 支持模糊查询 optional + * @param {string} callback - callback + @return {Object} result + * @param protectedIp dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 实例总数 + * @param integer totalPage 总页数 + */ + + describeProtectedIpList (opts, callback) { + opts = opts || {} + + if (opts.type === undefined || opts.type === null) { + throw new Error( + "Missing the required parameter 'opts.type' when calling describeProtectedIpList" + ) + } + + 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.instanceId !== undefined && opts.instanceId !== null) { + queryParams['instanceId'] = opts.instanceId + } + if (opts.type !== undefined && opts.type !== null) { + queryParams['type'] = opts.type + } + if (opts.ip !== undefined && opts.ip !== null) { + queryParams['ip'] = opts.ip + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 describeProtectedIpList 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( + '/describeProtectedIpList', + '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 的防护规则 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 防护包实例 Id + * @param {string} [opts.ip] - 被防护 IP, 缺省时获取防护包实例的防护规则 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param protectionRule data + */ + + describeProtectionRule (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 describeProtectionRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeProtectionRule" + ) + } + + let postBody = null + let queryParams = {} + if (opts.ip !== undefined && opts.ip !== null) { + queryParams['ip'] = opts.ip + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 describeProtectionRule 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}/instances/{instanceId}:describeProtectionRule', + '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) + } + ) + } + + /** + * 查询防护规则 Geo 拦截可设置区域 + * @param {Object} opts - parameters + * @param {string} callback - callback + @return {Object} result + * @param country dataList + */ + + describeGeoAreas (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 describeGeoAreas 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( + '/describeGeoAreas', + '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 的防护规则 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 防护包实例 Id + * @param {protectionRuleSpec} opts.protectionRuleSpec - 修改防护规则请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 修改防护规则结果, 0: 修改失败, 1: 修改成功 + * @param string message 修改失败时给出具体原因 + */ + + modifyProtectionRule (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 modifyProtectionRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyProtectionRule" + ) + } + if ( + opts.protectionRuleSpec === undefined || + opts.protectionRuleSpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.protectionRuleSpec' when calling modifyProtectionRule" + ) + } + + let postBody = {} + if ( + opts.protectionRuleSpec !== undefined && + opts.protectionRuleSpec !== null + ) { + postBody['protectionRuleSpec'] = opts.protectionRuleSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 modifyProtectionRule 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}/instances/{instanceId}:modifyProtectionRule', + '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.instanceName - 待检测实例名称, 长度限制为 1-80 个字符, 只允许包含中文, 字母, 数字, -, ., /, _ + * @param {string} callback - callback + @return {Object} result + * @param integer code 检测结果 code, 0: 不可用, 1: 可用 + * @param string message 检测结果, 不可用时给出具体原因 + */ + + checkInstanceName (opts, callback) { + opts = opts || {} + + if (opts.instanceName === undefined || opts.instanceName === null) { + throw new Error( + "Missing the required parameter 'opts.instanceName' when calling checkInstanceName" + ) + } + + let postBody = null + let queryParams = {} + if (opts.instanceName !== undefined && opts.instanceName !== null) { + queryParams['instanceName'] = opts.instanceName + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 checkInstanceName 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( + '/checkInstanceName', + '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} callback - callback + @return {Object} result + * @param protectionOutline data + */ + + describeProtectionOutline (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 describeProtectionOutline 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( + '/describeProtectionOutline', + '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 integer cnt 已添加的访问控制规则数量 + */ + + describeInstanceAclCnt (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 describeInstanceAclCnt" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeInstanceAclCnt" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 describeInstanceAclCnt 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}/instances/{instanceId}:describeInstanceAclCnt', + '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 - 防护包实例 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + enableInstanceAcl (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 enableInstanceAcl" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling enableInstanceAcl" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 enableInstanceAcl 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}/instances/{instanceId}:enableInstanceAcl', + '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 - 防护包实例 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + disableInstanceAcl (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 disableInstanceAcl" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling disableInstanceAcl" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 disableInstanceAcl 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}/instances/{instanceId}:disableInstanceAcl', + '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 - 防护包实例 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer aclEnable 实例访问控制总开关: 0: 关闭, 1: 打开 + */ + + describeInstanceAclEnable (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 describeInstanceAclEnable" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeInstanceAclEnable" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 describeInstanceAclEnable 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}/instances/{instanceId}:describeInstanceAclEnable', + '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 {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 分页大小 optional + * @param {filter} [opts.filters] - sip - 按照源 IP, 源 IP 范围或者 IP 地址库名称匹配, 仅支持 like 操作符,支持单个 +dip - 按照目的 IP, 目的 IP 范围或者 IP 地址库名称匹配, 仅支持 like 操作符,支持单个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param acl dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 实例总数 + * @param integer totalPage 总页数 + */ + + describeAcls (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 describeAcls" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeAcls" + ) + } + + 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, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 describeAcls 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}/instances/{instanceId}/acl', + '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 {createAclSpec} opts.createAclSpec - 创建防护包实例请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string aclId 创建的访问控制规则 Id + */ + + createAcl (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 createAcl" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createAcl" + ) + } + if (opts.createAclSpec === undefined || opts.createAclSpec === null) { + throw new Error( + "Missing the required parameter 'opts.createAclSpec' when calling createAcl" + ) + } + + let postBody = {} + if (opts.createAclSpec !== undefined && opts.createAclSpec !== null) { + postBody['createAclSpec'] = opts.createAclSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 createAcl 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}/instances/{instanceId}/acl', + '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 - 防护包实例 Id + * @param {string} opts.aclId - 访问控制规则 Id + * @param {modifyAclSpec} opts.modifyAclSpec - 修改访问控制规则请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyAcl (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 modifyAcl" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyAcl" + ) + } + if (opts.aclId === undefined || opts.aclId === null) { + throw new Error( + "Missing the required parameter 'opts.aclId' when calling modifyAcl" + ) + } + if (opts.modifyAclSpec === undefined || opts.modifyAclSpec === null) { + throw new Error( + "Missing the required parameter 'opts.modifyAclSpec' when calling modifyAcl" + ) + } + + let postBody = {} + if (opts.modifyAclSpec !== undefined && opts.modifyAclSpec !== null) { + postBody['modifyAclSpec'] = opts.modifyAclSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + aclId: opts.aclId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 modifyAcl 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}/instances/{instanceId}/acl/{aclId}', + 'PATCH', + 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) + } + ) + } + + /** + * 删除实例的访问控制规则. 支持批量操作, 批量操作时 aclId个, 以 ',' 分隔 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 防护包实例 Id + * @param {string} opts.aclId - 访问控制规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param batchResultDetail data + */ + + deleteAcl (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 deleteAcl" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteAcl" + ) + } + if (opts.aclId === undefined || opts.aclId === null) { + throw new Error( + "Missing the required parameter 'opts.aclId' when calling deleteAcl" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + aclId: opts.aclId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 deleteAcl 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}/instances/{instanceId}/acl/{aclId}', + '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.instanceId - 防护包实例 Id + * @param {string} opts.aclId - 访问控制规则 Id + * @param {modifyAclPrioritySpec} opts.modifyAclPrioritySpec - 修改访问控制规则请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyAclPriority (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 modifyAclPriority" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyAclPriority" + ) + } + if (opts.aclId === undefined || opts.aclId === null) { + throw new Error( + "Missing the required parameter 'opts.aclId' when calling modifyAclPriority" + ) + } + if ( + opts.modifyAclPrioritySpec === undefined || + opts.modifyAclPrioritySpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.modifyAclPrioritySpec' when calling modifyAclPriority" + ) + } + + let postBody = {} + if ( + opts.modifyAclPrioritySpec !== undefined && + opts.modifyAclPrioritySpec !== null + ) { + postBody['modifyAclPrioritySpec'] = opts.modifyAclPrioritySpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + aclId: opts.aclId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 modifyAclPriority 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}/instances/{instanceId}/acl/{aclId}:modifyAclPriority', + 'PATCH', + 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) + } + ) + } + + /** + * 打开实例的访问控制规则. 支持批量操作, 批量操作时 aclId 传多个, 以 ',' 分隔 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 防护包实例 Id + * @param {string} opts.aclId - 访问控制规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param batchResultDetail data + */ + + enableAcl (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 enableAcl" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling enableAcl" + ) + } + if (opts.aclId === undefined || opts.aclId === null) { + throw new Error( + "Missing the required parameter 'opts.aclId' when calling enableAcl" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + aclId: opts.aclId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 enableAcl 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}/instances/{instanceId}/acl/{aclId}:enableAcl', + '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) + } + ) + } + + /** + * 关闭实例的访问控制规则. 支持批量操作, 批量操作时 aclId 传多个, 以 ',' 分隔 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 防护包实例 Id + * @param {string} opts.aclId - 访问控制规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param batchResultDetail data + */ + + disableAcl (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 disableAcl" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling disableAcl" + ) + } + if (opts.aclId === undefined || opts.aclId === null) { + throw new Error( + "Missing the required parameter 'opts.aclId' when calling disableAcl" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + aclId: opts.aclId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 disableAcl 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}/instances/{instanceId}/acl/{aclId}:disableAcl', + '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) + } + ) + } + + /** + * 查询实例的 IP 库列表 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 防护包实例 Id + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 分页大小 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param ipSet dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 实例总数 + * @param integer totalPage 总页数 + */ + + describeIpSets (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 describeIpSets" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeIpSets" + ) + } + + 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 antipro/1.2.0' + } + + 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 describeIpSets 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}/instances/{instanceId}/ipSets', + '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 库 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 防护包实例 Id + * @param {ipSetSpec} opts.ipSetSpec - 创建实例的 IP 库请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string ipSetId 创建的IP库 Id + */ + + createIpSet (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 createIpSet" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createIpSet" + ) + } + if (opts.ipSetSpec === undefined || opts.ipSetSpec === null) { + throw new Error( + "Missing the required parameter 'opts.ipSetSpec' when calling createIpSet" + ) + } + + let postBody = {} + if (opts.ipSetSpec !== undefined && opts.ipSetSpec !== null) { + postBody['ipSetSpec'] = opts.ipSetSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 createIpSet 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}/instances/{instanceId}/ipSets', + '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) + } + ) + } + + /** + * 查询实例的 IP 库 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 防护包实例 Id + * @param {string} opts.ipSetId - IP 库 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param ipSet data + */ + + describeIpSet (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 describeIpSet" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeIpSet" + ) + } + if (opts.ipSetId === undefined || opts.ipSetId === null) { + throw new Error( + "Missing the required parameter 'opts.ipSetId' when calling describeIpSet" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + ipSetId: opts.ipSetId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 describeIpSet 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}/instances/{instanceId}/ipSets/{ipSetId}', + '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 库 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 防护包实例 Id + * @param {string} opts.ipSetId - IP 库 Id + * @param {ipSetSpec} opts.ipSetSpec - 添加实例的 IP 库请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyIpSet (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 modifyIpSet" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyIpSet" + ) + } + if (opts.ipSetId === undefined || opts.ipSetId === null) { + throw new Error( + "Missing the required parameter 'opts.ipSetId' when calling modifyIpSet" + ) + } + if (opts.ipSetSpec === undefined || opts.ipSetSpec === null) { + throw new Error( + "Missing the required parameter 'opts.ipSetSpec' when calling modifyIpSet" + ) + } + + let postBody = {} + if (opts.ipSetSpec !== undefined && opts.ipSetSpec !== null) { + postBody['ipSetSpec'] = opts.ipSetSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + ipSetId: opts.ipSetId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 modifyIpSet 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}/instances/{instanceId}/ipSets/{ipSetId}', + 'PATCH', + 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 库. 支持批量操作, 批量操作时 ipSetId 传多个, 以 ',' 分隔. IP 黑白名单规则被引用时不允许删除 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 防护包实例 Id + * @param {string} opts.ipSetId - IP 库 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param batchResultDetail data + */ + + deleteIpSet (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 deleteIpSet" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteIpSet" + ) + } + if (opts.ipSetId === undefined || opts.ipSetId === null) { + throw new Error( + "Missing the required parameter 'opts.ipSetId' when calling deleteIpSet" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + ipSetId: opts.ipSetId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 deleteIpSet 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}/instances/{instanceId}/ipSets/{ipSetId}', + '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.instanceId - 防护包实例 Id + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 分页大小 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param portSet dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 实例总数 + * @param integer totalPage 总页数 + */ + + describePortSets (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 describePortSets" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describePortSets" + ) + } + + 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 antipro/1.2.0' + } + + 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 describePortSets 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}/instances/{instanceId}/portSets', + '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 {portSetSpec} opts.portSetSpec - 创建实例的端口库请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string portSetId 创建的端口库 Id + */ + + createPortSet (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 createPortSet" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createPortSet" + ) + } + if (opts.portSetSpec === undefined || opts.portSetSpec === null) { + throw new Error( + "Missing the required parameter 'opts.portSetSpec' when calling createPortSet" + ) + } + + let postBody = {} + if (opts.portSetSpec !== undefined && opts.portSetSpec !== null) { + postBody['portSetSpec'] = opts.portSetSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 createPortSet 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}/instances/{instanceId}/portSets', + '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 - 防护包实例 Id + * @param {string} opts.portSetId - 端口库 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param portSet data + */ + + describePortSet (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 describePortSet" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describePortSet" + ) + } + if (opts.portSetId === undefined || opts.portSetId === null) { + throw new Error( + "Missing the required parameter 'opts.portSetId' when calling describePortSet" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + portSetId: opts.portSetId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 describePortSet 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}/instances/{instanceId}/portSets/{portSetId}', + '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} opts.portSetId - 端口库 Id + * @param {portSetSpec} opts.portSetSpec - 添加实例的端口库请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyPortSet (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 modifyPortSet" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyPortSet" + ) + } + if (opts.portSetId === undefined || opts.portSetId === null) { + throw new Error( + "Missing the required parameter 'opts.portSetId' when calling modifyPortSet" + ) + } + if (opts.portSetSpec === undefined || opts.portSetSpec === null) { + throw new Error( + "Missing the required parameter 'opts.portSetSpec' when calling modifyPortSet" + ) + } + + let postBody = {} + if (opts.portSetSpec !== undefined && opts.portSetSpec !== null) { + postBody['portSetSpec'] = opts.portSetSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + portSetId: opts.portSetId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 modifyPortSet 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}/instances/{instanceId}/portSets/{portSetId}', + 'PATCH', + 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) + } + ) + } + + /** + * 删除实例的端口库. 支持批量操作, 批量操作时 ipSetId 传多个, 以 ',' 分隔. IP 黑白名单规则被引用时不允许删除 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 防护包实例 Id + * @param {string} opts.portSetId - 端口库 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param batchResultDetail data + */ + + deletePortSet (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 deletePortSet" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deletePortSet" + ) + } + if (opts.portSetId === undefined || opts.portSetId === null) { + throw new Error( + "Missing the required parameter 'opts.portSetId' when calling deletePortSet" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + portSetId: opts.portSetId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 deletePortSet 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}/instances/{instanceId}/portSets/{portSetId}', + '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) + } + ) + } + + /** + * 查询 DDoS 防护包可防护的私有网络弹性公网 IP(不包括运营商级 NAT 保留地址和 IPv6) + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 分页大小 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param ipResource dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 实例总数 + * @param integer totalPage 总页数 + */ + + describeElasticIpResources (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 describeElasticIpResources" + ) + } + + 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 + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 describeElasticIpResources 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}/elasticIpResources', + '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) + } + ) + } + + /** + * 查询 DDoS 防护包可防护的云物理服务器公网 IP(包括云物理服务器弹性公网 IP 及云物理服务器基础网络实例的公网 IP) + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 分页大小 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param ipResource dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 实例总数 + * @param integer totalPage 总页数 + */ + + describeCpsIpResources (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 describeCpsIpResources" + ) + } + + 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 + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 describeCpsIpResources 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}/cpsIpResources', + '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) + } + ) + } + + /** + * 查询 DDoS 防护包可防护的托管区公网 IP + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 分页大小 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param ipResource dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 总数 + * @param integer totalPage 总页数 + */ + + describeCcsIpResources (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 describeCcsIpResources" + ) + } + + 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 + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 describeCcsIpResources 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}/ccsIpResources', + '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) + } + ) + } + + /** + * 查询 DDoS 防护包可防护的Web应用防护墙 IP + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 分页大小 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param ipResource dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 总数 + * @param integer totalPage 总页数 + */ + + describeWafIpResources (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 describeWafIpResources" + ) + } + + 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 + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 describeWafIpResources 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}/wafIpResources', + '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] - 页码 optional + * @param {integer} [opts.pageSize] - 分页大小 optional + * @param {string} opts.startTime - 开始时间, UTC 时间, 格式:yyyy-MM-dd'T'HH:mm:ssZ + * @param {string} opts.endTime - 结束时间, UTC 时间, 格式:yyyy-MM-dd'T'HH:mm:ssZ + * @param {integer} [opts.action] - 操作类型, 默认查全部. <br>- 0: 全部<br>- 1: 套餐变更<br>- 2: 防护规则变更<br>- 3: 防护对象变更<br>- 4: IP 地址变更<br>- 5: 防护包名称变更<br>- 6: IP地址库变更<br>- 7: 端口库变更<br>- 8: 访问控制规则变更 optional + * @param {string} [opts.name] - 防护包名称, 支持模糊匹配 optional + * @param {string} callback - callback + @return {Object} result + * @param operationRecord dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 实例总数 + * @param integer totalPage 总页数 + */ + + describeOperationRecords (opts, callback) { + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeOperationRecords" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeOperationRecords" + ) + } + + 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.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.action !== undefined && opts.action !== null) { + queryParams['action'] = opts.action + } + if (opts.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 antipro/1.2.0' + } + + 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 describeOperationRecords 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( + '/operationRecords', + '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 = ANTIPRO diff --git a/packages/libs/lib-jdcloud/src/repo/apigateway/v1/apigateway.js b/packages/libs/lib-jdcloud/src/repo/apigateway/v1/apigateway.js new file mode 100644 index 000000000..e2b0f2b7e --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/apigateway/v1/apigateway.js @@ -0,0 +1,9140 @@ +/* + * 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. + * + * 自定义域名 + * api 自定义域名 service + * + * 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 = 'apigateway' +Service._services[serviceId] = true + +/** + * apigateway service. + * @version 1.0.1 + */ + +JDCloud.APIGATEWAY = class APIGATEWAY extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'apigateway.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询访问授权列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞) optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {filter} [opts.filters] - auth_user_type - 授权类型,默认为 全部类型 +auth_user_id - 用户标识,精确匹配,jd_cloud(京东云用户), jd_apikms(api网关签名密钥), jd_subscription_key(订阅密钥),jd_cloud_pin(激活用户) + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param accessAuth accessAuths + * @param integer totalCount 查询的访问授权数目 + */ + + queryAccessAuths (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 queryAccessAuths" + ) + } + + 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, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 queryAccessAuths 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 = this.makeRequest( + '/regions/{regionId}/accessAuths', + '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 {accessAuthView} [opts.accessAuthView] - api分组 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string accessAuthId 已创建访问授权ID + */ + + createAccessAuth (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 createAccessAuth" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.accessAuthView !== undefined && opts.accessAuthView !== null) { + postBody['accessAuthView'] = opts.accessAuthView + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 createAccessAuth 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 = this.makeRequest( + '/regions/{regionId}/accessAuths', + '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) + } + ) + } + + /** + * 检查accessAuth是否重复 + * @param {Object} opts - parameters + * @param {string} opts.accessKey + * @param {string} opts.authUserType + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string accessAuthId 返回accessAuthId + */ + + checkAuthExist (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 checkAuthExist" + ) + } + + opts = opts || {} + + if (opts.accessKey === undefined || opts.accessKey === null) { + throw new Error( + "Missing the required parameter 'opts.accessKey' when calling checkAuthExist" + ) + } + if (opts.authUserType === undefined || opts.authUserType === null) { + throw new Error( + "Missing the required parameter 'opts.authUserType' when calling checkAuthExist" + ) + } + + let postBody = {} + if (opts.accessKey !== undefined && opts.accessKey !== null) { + postBody['accessKey'] = opts.accessKey + } + if (opts.authUserType !== undefined && opts.authUserType !== null) { + postBody['authUserType'] = opts.authUserType + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 checkAuthExist 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 = this.makeRequest( + '/regions/{regionId}/accessAuths:checkAccessKeyExist', + '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.accessAuthId - 访问授权ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param accessAuth accessAuth + */ + + queryAccessAuth (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 queryAccessAuth" + ) + } + + opts = opts || {} + + if (opts.accessAuthId === undefined || opts.accessAuthId === null) { + throw new Error( + "Missing the required parameter 'opts.accessAuthId' when calling queryAccessAuth" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + accessAuthId: opts.accessAuthId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 queryAccessAuth 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 = this.makeRequest( + '/regions/{regionId}/accessAuths/{accessAuthId}', + '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.accessAuthId - 访问授权ID + * @param {accessAuthView} [opts.accessAuthView] - 访问授权详情 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string accessAuthId 已更新访问授权ID + */ + + updateAccessAuth (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 updateAccessAuth" + ) + } + + opts = opts || {} + + if (opts.accessAuthId === undefined || opts.accessAuthId === null) { + throw new Error( + "Missing the required parameter 'opts.accessAuthId' when calling updateAccessAuth" + ) + } + + let postBody = {} + if (opts.accessAuthView !== undefined && opts.accessAuthView !== null) { + postBody['accessAuthView'] = opts.accessAuthView + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + accessAuthId: opts.accessAuthId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 updateAccessAuth 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 = this.makeRequest( + '/regions/{regionId}/accessAuths/{accessAuthId}', + 'PATCH', + 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.accessAuthId - 访问授权ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string accessAuthId 已删除授权ID + */ + + deleteAccessAuth (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 deleteAccessAuth" + ) + } + + opts = opts || {} + + if (opts.accessAuthId === undefined || opts.accessAuthId === null) { + throw new Error( + "Missing the required parameter 'opts.accessAuthId' when calling deleteAccessAuth" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + accessAuthId: opts.accessAuthId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 deleteAccessAuth 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 = this.makeRequest( + '/regions/{regionId}/accessAuths/{accessAuthId}', + '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.accessAuthId - 访问授权ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param bindGroups bindGroups + */ + + queryBindGroupAuth (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 queryBindGroupAuth" + ) + } + + opts = opts || {} + + if (opts.accessAuthId === undefined || opts.accessAuthId === null) { + throw new Error( + "Missing the required parameter 'opts.accessAuthId' when calling queryBindGroupAuth" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + accessAuthId: opts.accessAuthId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 queryBindGroupAuth 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 = this.makeRequest( + '/regions/{regionId}/accessAuths/{accessAuthId}:bindGroup', + '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.accessAuthId - 访问授权ID + * @param {string} opts.deploymentIds - 待绑定的部署ids逗号隔开 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param bindGroups bindGroups + */ + + bindGroupAuth (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 bindGroupAuth" + ) + } + + opts = opts || {} + + if (opts.accessAuthId === undefined || opts.accessAuthId === null) { + throw new Error( + "Missing the required parameter 'opts.accessAuthId' when calling bindGroupAuth" + ) + } + if (opts.deploymentIds === undefined || opts.deploymentIds === null) { + throw new Error( + "Missing the required parameter 'opts.deploymentIds' when calling bindGroupAuth" + ) + } + + let postBody = {} + if (opts.deploymentIds !== undefined && opts.deploymentIds !== null) { + postBody['deploymentIds'] = opts.deploymentIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + accessAuthId: opts.accessAuthId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 bindGroupAuth 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 = this.makeRequest( + '/regions/{regionId}/accessAuths/{accessAuthId}:bindGroup', + '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.authUserType - 待绑定的用户类型 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param bindGroups bindGroups + */ + + queryAuthGroupList (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 queryAuthGroupList" + ) + } + + opts = opts || {} + + if (opts.authUserType === undefined || opts.authUserType === null) { + throw new Error( + "Missing the required parameter 'opts.authUserType' when calling queryAuthGroupList" + ) + } + + let postBody = null + let queryParams = {} + if (opts.authUserType !== undefined && opts.authUserType !== null) { + queryParams['authUserType'] = opts.authUserType + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 queryAuthGroupList 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 = this.makeRequest( + '/regions/{regionId}/accessAuths:groupList', + '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) + } + ) + } + + /** + * 查询所有已授权api分组列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞) optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {filter} [opts.filters] - apiGroupName - 名称,模糊匹配 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param userBindedGroups apiGroups + */ + + authorizedApiGroupList (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 authorizedApiGroupList" + ) + } + + 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, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 authorizedApiGroupList 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 = this.makeRequest( + '/regions/{regionId}/accessAuths:authorizedApiGroupList', + '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 {filter} [opts.filters] - description - 名称,模糊匹配 +accessKey - accesskey,模糊匹配 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param accessKey accessKeys + * @param integer totalCount 查询的密钥数目 + */ + + queryAccessKeys (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 queryAccessKeys" + ) + } + + 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, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 queryAccessKeys 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 = this.makeRequest( + '/regions/{regionId}/accessKeys', + '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.description] - 描述 optional + * @param {string} [opts.accessKeyType] - 密钥类型 optional + * @param {string} [opts.accessKey] - Access Key optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string accessKeyId 已创建密钥ID + */ + + createAccessKey (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 createAccessKey" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.accessKeyType !== undefined && opts.accessKeyType !== null) { + postBody['accessKeyType'] = opts.accessKeyType + } + if (opts.accessKey !== undefined && opts.accessKey !== null) { + postBody['accessKey'] = opts.accessKey + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 createAccessKey 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 = this.makeRequest( + '/regions/{regionId}/accessKeys', + '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) + } + ) + } + + /** + * 检查AccessKey是否重复 + * @param {Object} opts - parameters + * @param {string} opts.accessKey + * @param {string} opts.accessKeyType + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + checkKeyExist (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 checkKeyExist" + ) + } + + opts = opts || {} + + if (opts.accessKey === undefined || opts.accessKey === null) { + throw new Error( + "Missing the required parameter 'opts.accessKey' when calling checkKeyExist" + ) + } + if (opts.accessKeyType === undefined || opts.accessKeyType === null) { + throw new Error( + "Missing the required parameter 'opts.accessKeyType' when calling checkKeyExist" + ) + } + + let postBody = {} + if (opts.accessKey !== undefined && opts.accessKey !== null) { + postBody['accessKey'] = opts.accessKey + } + if (opts.accessKeyType !== undefined && opts.accessKeyType !== null) { + postBody['accessKeyType'] = opts.accessKeyType + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 checkKeyExist 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 = this.makeRequest( + '/regions/{regionId}/accessKeys:checkAccessKeyExist', + '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.accessKeyId - access key id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param accessKey accessKey + */ + + queryAccessKey (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 queryAccessKey" + ) + } + + opts = opts || {} + + if (opts.accessKeyId === undefined || opts.accessKeyId === null) { + throw new Error( + "Missing the required parameter 'opts.accessKeyId' when calling queryAccessKey" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + accessKeyId: opts.accessKeyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 queryAccessKey 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 = this.makeRequest( + '/regions/{regionId}/accessKeys/{accessKeyId}', + '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.accessKeyId - access key id + * @param {string} [opts.description] - 描述 optional + * @param {string} [opts.accessKeyType] - 密钥类型 optional + * @param {string} [opts.accessKey] - Access Key optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string accessKeyId 已更新密钥Id + */ + + updateAccessKey (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 updateAccessKey" + ) + } + + opts = opts || {} + + if (opts.accessKeyId === undefined || opts.accessKeyId === null) { + throw new Error( + "Missing the required parameter 'opts.accessKeyId' when calling updateAccessKey" + ) + } + + let postBody = {} + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.accessKeyType !== undefined && opts.accessKeyType !== null) { + postBody['accessKeyType'] = opts.accessKeyType + } + if (opts.accessKey !== undefined && opts.accessKey !== null) { + postBody['accessKey'] = opts.accessKey + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + accessKeyId: opts.accessKeyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 updateAccessKey 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 = this.makeRequest( + '/regions/{regionId}/accessKeys/{accessKeyId}', + 'PATCH', + 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.accessKeyId - access key id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string accessKeyId 已删除密钥Id + */ + + deleteAccessKey (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 deleteAccessKey" + ) + } + + opts = opts || {} + + if (opts.accessKeyId === undefined || opts.accessKeyId === null) { + throw new Error( + "Missing the required parameter 'opts.accessKeyId' when calling deleteAccessKey" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + accessKeyId: opts.accessKeyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 deleteAccessKey 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 = this.makeRequest( + '/regions/{regionId}/accessKeys/{accessKeyId}', + '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.accessKeyId - access key id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param bindGroups bindGroups + */ + + queryBindGroupKey (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 queryBindGroupKey" + ) + } + + opts = opts || {} + + if (opts.accessKeyId === undefined || opts.accessKeyId === null) { + throw new Error( + "Missing the required parameter 'opts.accessKeyId' when calling queryBindGroupKey" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + accessKeyId: opts.accessKeyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 queryBindGroupKey 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 = this.makeRequest( + '/regions/{regionId}/accessKeys/{accessKeyId}:bindGroup', + '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.accessKeyId - access key id + * @param {string} opts.deploymentIds - 待绑定的部署ids用逗号隔开 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param bindGroups bindGroups + */ + + bindGroupKey (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 bindGroupKey" + ) + } + + opts = opts || {} + + if (opts.accessKeyId === undefined || opts.accessKeyId === null) { + throw new Error( + "Missing the required parameter 'opts.accessKeyId' when calling bindGroupKey" + ) + } + if (opts.deploymentIds === undefined || opts.deploymentIds === null) { + throw new Error( + "Missing the required parameter 'opts.deploymentIds' when calling bindGroupKey" + ) + } + + let postBody = {} + if (opts.deploymentIds !== undefined && opts.deploymentIds !== null) { + postBody['deploymentIds'] = opts.deploymentIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + accessKeyId: opts.accessKeyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 bindGroupKey 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 = this.makeRequest( + '/regions/{regionId}/accessKeys/{accessKeyId}:bindGroup', + '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.accessKeyId - access key id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param bindGroups bindGroups + */ + + queryKeyGroupList (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 queryKeyGroupList" + ) + } + + opts = opts || {} + + if (opts.accessKeyId === undefined || opts.accessKeyId === null) { + throw new Error( + "Missing the required parameter 'opts.accessKeyId' when calling queryKeyGroupList" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + accessKeyId: opts.accessKeyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 queryKeyGroupList 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 = this.makeRequest( + '/regions/{regionId}/accessKeys/{accessKeyId}:groupList', + '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) + } + ) + } + + /** + * 查询api列表 + * @param {Object} opts - parameters + * @param {string} opts.apiGroupId - 分组ID + * @param {string} opts.revision - 版本号 + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞) optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {filter} [opts.filters] - apiName - API名称,模糊匹配,支持单个 +action - 动作,精确匹配,支持多个 +backServiceType- 后端服务类型,精确匹配,支持多个 +path - 路径,模糊匹配,支持单个 +description - 描述,模糊匹配,支持单个 +isApiProduct - 是否API产品,精确匹配,1为是 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param api apis + * @param integer totalCount 查询的数目 + */ + + queryApis (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 queryApis" + ) + } + + opts = opts || {} + + if (opts.apiGroupId === undefined || opts.apiGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.apiGroupId' when calling queryApis" + ) + } + if (opts.revision === undefined || opts.revision === null) { + throw new Error( + "Missing the required parameter 'opts.revision' when calling queryApis" + ) + } + + 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, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId, + apiGroupId: opts.apiGroupId, + revision: opts.revision + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 queryApis 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 = this.makeRequest( + '/regions/{regionId}/apiGroups/{apiGroupId}/revision/{revision}/apis', + '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) + } + ) + } + + /** + * 创建api + * @param {Object} opts - parameters + * @param {string} opts.apiGroupId - 分组ID + * @param {string} opts.revision - 版本号 + * @param {createApi} [opts.api] - api optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string apiId apiId + */ + + createApis (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 createApis" + ) + } + + opts = opts || {} + + if (opts.apiGroupId === undefined || opts.apiGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.apiGroupId' when calling createApis" + ) + } + if (opts.revision === undefined || opts.revision === null) { + throw new Error( + "Missing the required parameter 'opts.revision' when calling createApis" + ) + } + + let postBody = {} + if (opts.api !== undefined && opts.api !== null) { + postBody['api'] = opts.api + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + apiGroupId: opts.apiGroupId, + revision: opts.revision + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 createApis 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 = this.makeRequest( + '/regions/{regionId}/apiGroups/{apiGroupId}/revision/{revision}/apis', + '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) + } + ) + } + + /** + * 创建API时,检查API名称是否重复,返回重复的apiId,如果没有返回空 + * @param {Object} opts - parameters + * @param {string} opts.apiGroupId - 分组ID + * @param {string} opts.revision - 版本号 + * @param {string} opts.apiName - API名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string apiId API名称 + */ + + checkApiNameExist (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 checkApiNameExist" + ) + } + + opts = opts || {} + + if (opts.apiGroupId === undefined || opts.apiGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.apiGroupId' when calling checkApiNameExist" + ) + } + if (opts.revision === undefined || opts.revision === null) { + throw new Error( + "Missing the required parameter 'opts.revision' when calling checkApiNameExist" + ) + } + if (opts.apiName === undefined || opts.apiName === null) { + throw new Error( + "Missing the required parameter 'opts.apiName' when calling checkApiNameExist" + ) + } + + let postBody = {} + if (opts.apiName !== undefined && opts.apiName !== null) { + postBody['apiName'] = opts.apiName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + apiGroupId: opts.apiGroupId, + revision: opts.revision + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 checkApiNameExist 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 = this.makeRequest( + '/regions/{regionId}/apiGroups/{apiGroupId}/revision/{revision}/apis:checkApiNameExist', + '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) + } + ) + } + + /** + * 查询单个api + * @param {Object} opts - parameters + * @param {string} opts.apiGroupId - 分组ID + * @param {string} opts.revision - 版本号 + * @param {string} opts.apiId - 接口ID + * @param {filter} [opts.filters] - isApiProduct - 是否API产品,精确匹配,1为是 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param api api + */ + + queryApi (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 queryApi" + ) + } + + opts = opts || {} + + if (opts.apiGroupId === undefined || opts.apiGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.apiGroupId' when calling queryApi" + ) + } + if (opts.revision === undefined || opts.revision === null) { + throw new Error( + "Missing the required parameter 'opts.revision' when calling queryApi" + ) + } + if (opts.apiId === undefined || opts.apiId === null) { + throw new Error( + "Missing the required parameter 'opts.apiId' when calling queryApi" + ) + } + + let postBody = null + let queryParams = {} + Object.assign(queryParams, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId, + apiGroupId: opts.apiGroupId, + revision: opts.revision, + apiId: opts.apiId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 queryApi 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 = this.makeRequest( + '/regions/{regionId}/apiGroups/{apiGroupId}/revision/{revision}/apis/{apiId}', + '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) + } + ) + } + + /** + * 修改api + * @param {Object} opts - parameters + * @param {string} opts.apiGroupId - 分组ID + * @param {string} opts.revision - 版本号 + * @param {string} opts.apiId - 接口ID + * @param {createApi} [opts.api] - api optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string apiId apiId + */ + + updateApi (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 updateApi" + ) + } + + opts = opts || {} + + if (opts.apiGroupId === undefined || opts.apiGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.apiGroupId' when calling updateApi" + ) + } + if (opts.revision === undefined || opts.revision === null) { + throw new Error( + "Missing the required parameter 'opts.revision' when calling updateApi" + ) + } + if (opts.apiId === undefined || opts.apiId === null) { + throw new Error( + "Missing the required parameter 'opts.apiId' when calling updateApi" + ) + } + + let postBody = {} + if (opts.api !== undefined && opts.api !== null) { + postBody['api'] = opts.api + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + apiGroupId: opts.apiGroupId, + revision: opts.revision, + apiId: opts.apiId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 updateApi 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 = this.makeRequest( + '/regions/{regionId}/apiGroups/{apiGroupId}/revision/{revision}/apis/{apiId}', + '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) + } + ) + } + + /** + * 删除api + * @param {Object} opts - parameters + * @param {string} opts.apiGroupId - 分组ID + * @param {string} opts.revision - 版本号 + * @param {string} opts.apiId - 接口ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteApi (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 deleteApi" + ) + } + + opts = opts || {} + + if (opts.apiGroupId === undefined || opts.apiGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.apiGroupId' when calling deleteApi" + ) + } + if (opts.revision === undefined || opts.revision === null) { + throw new Error( + "Missing the required parameter 'opts.revision' when calling deleteApi" + ) + } + if (opts.apiId === undefined || opts.apiId === null) { + throw new Error( + "Missing the required parameter 'opts.apiId' when calling deleteApi" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + apiGroupId: opts.apiGroupId, + revision: opts.revision, + apiId: opts.apiId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 deleteApi 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 = this.makeRequest( + '/regions/{regionId}/apiGroups/{apiGroupId}/revision/{revision}/apis/{apiId}', + '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) + } + ) + } + + /** + * 修改api + * @param {Object} opts - parameters + * @param {string} opts.apiGroupId - 分组ID + * @param {string} opts.revision - 版本号 + * @param {string} opts.apiName + * @param {createApi} [opts.api] - api optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateApiByName (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 updateApiByName" + ) + } + + opts = opts || {} + + if (opts.apiGroupId === undefined || opts.apiGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.apiGroupId' when calling updateApiByName" + ) + } + if (opts.revision === undefined || opts.revision === null) { + throw new Error( + "Missing the required parameter 'opts.revision' when calling updateApiByName" + ) + } + if (opts.apiName === undefined || opts.apiName === null) { + throw new Error( + "Missing the required parameter 'opts.apiName' when calling updateApiByName" + ) + } + + let postBody = {} + if (opts.api !== undefined && opts.api !== null) { + postBody['api'] = opts.api + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + apiGroupId: opts.apiGroupId, + revision: opts.revision, + apiName: opts.apiName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 updateApiByName 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 = this.makeRequest( + '/regions/{regionId}/apiGroups/{apiGroupId}/revision/{revision}/apisName/{apiName}', + '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) + } + ) + } + + /** + * 删除api + * @param {Object} opts - parameters + * @param {string} opts.apiGroupId - 分组ID + * @param {string} opts.revision - 版本号 + * @param {string} opts.apiName + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteApiByName (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 deleteApiByName" + ) + } + + opts = opts || {} + + if (opts.apiGroupId === undefined || opts.apiGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.apiGroupId' when calling deleteApiByName" + ) + } + if (opts.revision === undefined || opts.revision === null) { + throw new Error( + "Missing the required parameter 'opts.revision' when calling deleteApiByName" + ) + } + if (opts.apiName === undefined || opts.apiName === null) { + throw new Error( + "Missing the required parameter 'opts.apiName' when calling deleteApiByName" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + apiGroupId: opts.apiGroupId, + revision: opts.revision, + apiName: opts.apiName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 deleteApiByName 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 = this.makeRequest( + '/regions/{regionId}/apiGroups/{apiGroupId}/revision/{revision}/apisName/{apiName}', + '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] - groupName - 分组名称,模糊匹配,支持单个 +description - 描述信息,模糊匹配,支持单个 +groupId - 分组ID,精确匹配 +domain - 域名,模糊匹配 +jdsfId - 微服务网关ID,精确匹配 + optional + * @param {tagFilter} [opts.tagFilters] - 标签查询条件 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param apiGroup apiGroups + * @param integer totalCount 查询的分组数目 + */ + + describeApiGroups (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 describeApiGroups" + ) + } + + 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, this.buildFilterParam(opts.filters, 'filters')) + Object.assign( + queryParams, + this.buildTagFilterParam(opts.tagFilters, 'tagFilters') + ) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 describeApiGroups 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 = this.makeRequest( + '/regions/{regionId}/apiGroups', + '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) + } + ) + } + + /** + * 创建API分组 + * @param {Object} opts - parameters + * @param {string} opts.groupName - 名称 + * @param {string} [opts.description] - 描述 optional + * @param {string} [opts.prefix] - 分组路径前缀,无需添加/ optional + * @param {string} [opts.keyCheck] - 密钥验证方式:check_exist(密钥必须在访问授权中已配置)、no_check_exist(无需事先配置) optional + * @param {string} opts.authType - 访问授权方式:None(免鉴权)、jd_cloud(开启访问授权,且必须使用京东云的AK、SK验签)、hufu(虎符用户) + * @param {integer} [opts.prefixStrip] - 是否转发分组路径到后端服务:0(不转发)、1(转发)默认为1 optional + * @param {string} [opts.groupType] - 分组类型:api_group(api分组)、jdsf_group(微服务分组)默认为 api_group optional + * @param {string} [opts.jdsfName] - 微服务网关名称 optional + * @param {string} [opts.jdsfRegistryName] - 微服务注册中心ID optional + * @param {string} [opts.jdsfId] - 微服务网关ID optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string apiGroupId 创建的API分组ID + * @param string revision 修订版本号 + */ + + createApiGroup (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 createApiGroup" + ) + } + + opts = opts || {} + + if (opts.groupName === undefined || opts.groupName === null) { + throw new Error( + "Missing the required parameter 'opts.groupName' when calling createApiGroup" + ) + } + if (opts.authType === undefined || opts.authType === null) { + throw new Error( + "Missing the required parameter 'opts.authType' when calling createApiGroup" + ) + } + + let postBody = {} + if (opts.groupName !== undefined && opts.groupName !== null) { + postBody['groupName'] = opts.groupName + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.prefix !== undefined && opts.prefix !== null) { + postBody['prefix'] = opts.prefix + } + if (opts.keyCheck !== undefined && opts.keyCheck !== null) { + postBody['keyCheck'] = opts.keyCheck + } + if (opts.authType !== undefined && opts.authType !== null) { + postBody['authType'] = opts.authType + } + if (opts.prefixStrip !== undefined && opts.prefixStrip !== null) { + postBody['prefixStrip'] = opts.prefixStrip + } + if (opts.groupType !== undefined && opts.groupType !== null) { + postBody['groupType'] = opts.groupType + } + if (opts.jdsfName !== undefined && opts.jdsfName !== null) { + postBody['jdsfName'] = opts.jdsfName + } + if (opts.jdsfRegistryName !== undefined && opts.jdsfRegistryName !== null) { + postBody['jdsfRegistryName'] = opts.jdsfRegistryName + } + if (opts.jdsfId !== undefined && opts.jdsfId !== null) { + postBody['jdsfId'] = opts.jdsfId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 createApiGroup 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 = this.makeRequest( + '/regions/{regionId}/apiGroups', + '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) + } + ) + } + + /** + * 检查分组名称是否重复,返回重复的apiGroupId,如果没有返回空 + * @param {Object} opts - parameters + * @param {string} opts.groupName - 分组名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string apiGroupId 分组id + */ + + checkGroupNameExist (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 checkGroupNameExist" + ) + } + + opts = opts || {} + + if (opts.groupName === undefined || opts.groupName === null) { + throw new Error( + "Missing the required parameter 'opts.groupName' when calling checkGroupNameExist" + ) + } + + let postBody = {} + if (opts.groupName !== undefined && opts.groupName !== null) { + postBody['groupName'] = opts.groupName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 checkGroupNameExist 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 = this.makeRequest( + '/regions/{regionId}/apiGroups:checkGroupNameExist', + '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) + } + ) + } + + /** + * 查询API分组详情 + * @param {Object} opts - parameters + * @param {string} opts.apiGroupId - 分组ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param apiGroup apiGroup + */ + + describeApiGroup (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 describeApiGroup" + ) + } + + opts = opts || {} + + if (opts.apiGroupId === undefined || opts.apiGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.apiGroupId' when calling describeApiGroup" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + apiGroupId: opts.apiGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 describeApiGroup 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 = this.makeRequest( + '/regions/{regionId}/apiGroups/{apiGroupId}', + '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) + } + ) + } + + /** + * 修改API分组信息 + * @param {Object} opts - parameters + * @param {string} opts.apiGroupId - 分组ID + * @param {string} [opts.groupName] - 名称 optional + * @param {string} [opts.description] - 描述 optional + * @param {string} [opts.prefix] - 分组路径前缀 optional + * @param {string} [opts.keyCheck] - 密钥验证方式:check_exist(密钥必须在访问授权中已配置)、no_check_exist(无需事先配置) optional + * @param {string} [opts.authType] - 访问授权方式:None(免鉴权)、jd_cloud(开启访问授权,且必须使用京东云的AK、SK验签)、hufu(虎符用户) optional + * @param {integer} [opts.prefixStrip] - 是否转发分组路径到后端服务:0(不转发)、1(转发)默认为1 optional + * @param {string} [opts.groupType] - 分组类型:api_group(api分组)、jdsf_group(微服务分组)默认为 api_group optional + * @param {string} [opts.jdsfName] - 微服务网关名称 optional + * @param {string} [opts.jdsfRegistryName] - 微服务注册中心ID optional + * @param {string} [opts.jdsfId] - 微服务网关ID optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyApiGroupAttribute (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 modifyApiGroupAttribute" + ) + } + + opts = opts || {} + + if (opts.apiGroupId === undefined || opts.apiGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.apiGroupId' when calling modifyApiGroupAttribute" + ) + } + + let postBody = {} + if (opts.groupName !== undefined && opts.groupName !== null) { + postBody['groupName'] = opts.groupName + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.prefix !== undefined && opts.prefix !== null) { + postBody['prefix'] = opts.prefix + } + if (opts.keyCheck !== undefined && opts.keyCheck !== null) { + postBody['keyCheck'] = opts.keyCheck + } + if (opts.authType !== undefined && opts.authType !== null) { + postBody['authType'] = opts.authType + } + if (opts.prefixStrip !== undefined && opts.prefixStrip !== null) { + postBody['prefixStrip'] = opts.prefixStrip + } + if (opts.groupType !== undefined && opts.groupType !== null) { + postBody['groupType'] = opts.groupType + } + if (opts.jdsfName !== undefined && opts.jdsfName !== null) { + postBody['jdsfName'] = opts.jdsfName + } + if (opts.jdsfRegistryName !== undefined && opts.jdsfRegistryName !== null) { + postBody['jdsfRegistryName'] = opts.jdsfRegistryName + } + if (opts.jdsfId !== undefined && opts.jdsfId !== null) { + postBody['jdsfId'] = opts.jdsfId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + apiGroupId: opts.apiGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 modifyApiGroupAttribute 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 = this.makeRequest( + '/regions/{regionId}/apiGroups/{apiGroupId}', + '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) + } + ) + } + + /** + * 删除单个API分组 + * @param {Object} opts - parameters + * @param {string} opts.apiGroupId - 分组ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteApiGroup (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 deleteApiGroup" + ) + } + + opts = opts || {} + + if (opts.apiGroupId === undefined || opts.apiGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.apiGroupId' when calling deleteApiGroup" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + apiGroupId: opts.apiGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 deleteApiGroup 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 = this.makeRequest( + '/regions/{regionId}/apiGroups/{apiGroupId}', + '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 {filter} [opts.filters] - deployStatus - 发布状态,已发布:1,未发布:0 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param apiGroup apiGroups + * @param integer totalCount 查询的分组数目 + */ + + describeIsDeployApiGroups (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 describeIsDeployApiGroups" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + Object.assign(queryParams, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 describeIsDeployApiGroups 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 = this.makeRequest( + '/regions/{regionId}/apiGroups:isDeploy', + '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.apiGroupId - 分组ID + * @param {string} [opts.backendConfigId] - 接口ID optional + * @param {string} [opts.baseGroupId] - 分组ID optional + * @param {string} opts.environment - 环境:test、preview、online + * @param {string} [opts.backendUrl] - 后端地址 optional + * @param {string} opts.backendServiceType - 后端服务类型:mock、HTTP/HTTPS + * @param {array} [opts.headerParams] - header参数列表 optional + * @param {array} [opts.queryParams] - query参数列表 optional + * @param {string} [opts.description] - 描述 optional + * @param {integer} [opts.createTime] - 发布日期,格式为毫秒级时间戳 optional + * @param {integer} opts.sort - 排序,赋值0时为默认的后端配置 + * @param {integer} [opts.userSort] - 排序,用于展示使用 optional + * @param {string} [opts.jdsfId] - vpc网关id optional + * @param {string} [opts.jdsfParam] - vpc后端地址 optional + * @param {string} [opts.jdsfRegion] - vpc网关所属region optional + * @param {string} [opts.jdsfPin] - vpc网关创建者的pin optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string backendConfigId 主键Id + */ + + createBackendConfig (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 createBackendConfig" + ) + } + + opts = opts || {} + + if (opts.apiGroupId === undefined || opts.apiGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.apiGroupId' when calling createBackendConfig" + ) + } + if (opts.environment === undefined || opts.environment === null) { + throw new Error( + "Missing the required parameter 'opts.environment' when calling createBackendConfig" + ) + } + if ( + opts.backendServiceType === undefined || + opts.backendServiceType === null + ) { + throw new Error( + "Missing the required parameter 'opts.backendServiceType' when calling createBackendConfig" + ) + } + if (opts.sort === undefined || opts.sort === null) { + throw new Error( + "Missing the required parameter 'opts.sort' when calling createBackendConfig" + ) + } + + let postBody = {} + if (opts.backendConfigId !== undefined && opts.backendConfigId !== null) { + postBody['backendConfigId'] = opts.backendConfigId + } + if (opts.baseGroupId !== undefined && opts.baseGroupId !== null) { + postBody['baseGroupId'] = opts.baseGroupId + } + if (opts.environment !== undefined && opts.environment !== null) { + postBody['environment'] = opts.environment + } + if (opts.backendUrl !== undefined && opts.backendUrl !== null) { + postBody['backendUrl'] = opts.backendUrl + } + if ( + opts.backendServiceType !== undefined && + opts.backendServiceType !== null + ) { + postBody['backendServiceType'] = opts.backendServiceType + } + if (opts.headerParams !== undefined && opts.headerParams !== null) { + postBody['headerParams'] = opts.headerParams + } + if (opts.queryParams !== undefined && opts.queryParams !== null) { + postBody['queryParams'] = opts.queryParams + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.createTime !== undefined && opts.createTime !== null) { + postBody['createTime'] = opts.createTime + } + if (opts.sort !== undefined && opts.sort !== null) { + postBody['sort'] = opts.sort + } + if (opts.userSort !== undefined && opts.userSort !== null) { + postBody['userSort'] = opts.userSort + } + if (opts.jdsfId !== undefined && opts.jdsfId !== null) { + postBody['jdsfId'] = opts.jdsfId + } + if (opts.jdsfParam !== undefined && opts.jdsfParam !== null) { + postBody['jdsfParam'] = opts.jdsfParam + } + if (opts.jdsfRegion !== undefined && opts.jdsfRegion !== null) { + postBody['jdsfRegion'] = opts.jdsfRegion + } + if (opts.jdsfPin !== undefined && opts.jdsfPin !== null) { + postBody['jdsfPin'] = opts.jdsfPin + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + apiGroupId: opts.apiGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 createBackendConfig 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 = this.makeRequest( + '/regions/{regionId}/apiGroups/{apiGroupId}/backendConfig', + '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.apiGroupId - 分组ID + * @param {string} opts.environment - 环境:test、preview、online + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞) optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {filter} [opts.filters] - sort - 路由排序,赋值0时为默认的后端配置 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param backendConfig backendConfigs + * @param integer totalCount 结果总数 + */ + + describeBackendConfigs (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 describeBackendConfigs" + ) + } + + opts = opts || {} + + if (opts.apiGroupId === undefined || opts.apiGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.apiGroupId' when calling describeBackendConfigs" + ) + } + if (opts.environment === undefined || opts.environment === null) { + throw new Error( + "Missing the required parameter 'opts.environment' when calling describeBackendConfigs" + ) + } + + 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, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId, + apiGroupId: opts.apiGroupId, + environment: opts.environment + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 describeBackendConfigs 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 = this.makeRequest( + '/regions/{regionId}/apiGroups/{apiGroupId}/environment/{environment}/backendConfigs', + '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) + } + ) + } + + /** + * 查询backendConfig + * @param {Object} opts - parameters + * @param {string} opts.apiGroupId - 分组ID + * @param {string} opts.backendConfigId - backendConfigId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param backendConfig backendConfig + */ + + describeBackendConfig (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 describeBackendConfig" + ) + } + + opts = opts || {} + + if (opts.apiGroupId === undefined || opts.apiGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.apiGroupId' when calling describeBackendConfig" + ) + } + if (opts.backendConfigId === undefined || opts.backendConfigId === null) { + throw new Error( + "Missing the required parameter 'opts.backendConfigId' when calling describeBackendConfig" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + apiGroupId: opts.apiGroupId, + backendConfigId: opts.backendConfigId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 describeBackendConfig 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 = this.makeRequest( + '/regions/{regionId}/apiGroups/{apiGroupId}/backendConfig/{backendConfigId}', + '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.apiGroupId - 分组ID + * @param {string} opts.backendConfigId - backendConfigId + * @param {string} [opts.baseGroupId] - 分组ID optional + * @param {string} opts.environment - 环境:test、preview、online + * @param {string} [opts.backendUrl] - 后端地址 optional + * @param {string} opts.backendServiceType - 后端服务类型:mock、HTTP/HTTPS + * @param {array} [opts.headerParams] - header参数列表 optional + * @param {array} [opts.queryParams] - query参数列表 optional + * @param {string} [opts.description] - 描述 optional + * @param {integer} [opts.createTime] - 发布日期,格式为毫秒级时间戳 optional + * @param {integer} opts.sort - 排序,赋值0时为默认的后端配置 + * @param {integer} [opts.userSort] - 排序,用于展示使用 optional + * @param {string} [opts.jdsfId] - vpc网关id optional + * @param {string} [opts.jdsfParam] - vpc后端地址 optional + * @param {string} [opts.jdsfRegion] - vpc网关所属region optional + * @param {string} [opts.jdsfPin] - vpc网关创建者的pin optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateBackendConfig (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 updateBackendConfig" + ) + } + + opts = opts || {} + + if (opts.apiGroupId === undefined || opts.apiGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.apiGroupId' when calling updateBackendConfig" + ) + } + if (opts.backendConfigId === undefined || opts.backendConfigId === null) { + throw new Error( + "Missing the required parameter 'opts.backendConfigId' when calling updateBackendConfig" + ) + } + if (opts.environment === undefined || opts.environment === null) { + throw new Error( + "Missing the required parameter 'opts.environment' when calling updateBackendConfig" + ) + } + if ( + opts.backendServiceType === undefined || + opts.backendServiceType === null + ) { + throw new Error( + "Missing the required parameter 'opts.backendServiceType' when calling updateBackendConfig" + ) + } + if (opts.sort === undefined || opts.sort === null) { + throw new Error( + "Missing the required parameter 'opts.sort' when calling updateBackendConfig" + ) + } + + let postBody = {} + if (opts.baseGroupId !== undefined && opts.baseGroupId !== null) { + postBody['baseGroupId'] = opts.baseGroupId + } + if (opts.environment !== undefined && opts.environment !== null) { + postBody['environment'] = opts.environment + } + if (opts.backendUrl !== undefined && opts.backendUrl !== null) { + postBody['backendUrl'] = opts.backendUrl + } + if ( + opts.backendServiceType !== undefined && + opts.backendServiceType !== null + ) { + postBody['backendServiceType'] = opts.backendServiceType + } + if (opts.headerParams !== undefined && opts.headerParams !== null) { + postBody['headerParams'] = opts.headerParams + } + if (opts.queryParams !== undefined && opts.queryParams !== null) { + postBody['queryParams'] = opts.queryParams + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.createTime !== undefined && opts.createTime !== null) { + postBody['createTime'] = opts.createTime + } + if (opts.sort !== undefined && opts.sort !== null) { + postBody['sort'] = opts.sort + } + if (opts.userSort !== undefined && opts.userSort !== null) { + postBody['userSort'] = opts.userSort + } + if (opts.jdsfId !== undefined && opts.jdsfId !== null) { + postBody['jdsfId'] = opts.jdsfId + } + if (opts.jdsfParam !== undefined && opts.jdsfParam !== null) { + postBody['jdsfParam'] = opts.jdsfParam + } + if (opts.jdsfRegion !== undefined && opts.jdsfRegion !== null) { + postBody['jdsfRegion'] = opts.jdsfRegion + } + if (opts.jdsfPin !== undefined && opts.jdsfPin !== null) { + postBody['jdsfPin'] = opts.jdsfPin + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + apiGroupId: opts.apiGroupId, + backendConfigId: opts.backendConfigId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 updateBackendConfig 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 = this.makeRequest( + '/regions/{regionId}/apiGroups/{apiGroupId}/backendConfig/{backendConfigId}', + 'PATCH', + 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.apiGroupId - 分组ID + * @param {string} opts.backendConfigId - backendConfigId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteBackendConfig (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 deleteBackendConfig" + ) + } + + opts = opts || {} + + if (opts.apiGroupId === undefined || opts.apiGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.apiGroupId' when calling deleteBackendConfig" + ) + } + if (opts.backendConfigId === undefined || opts.backendConfigId === null) { + throw new Error( + "Missing the required parameter 'opts.backendConfigId' when calling deleteBackendConfig" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + apiGroupId: opts.apiGroupId, + backendConfigId: opts.backendConfigId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 deleteBackendConfig 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 = this.makeRequest( + '/regions/{regionId}/apiGroups/{apiGroupId}/backendConfig/{backendConfigId}', + '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.apiGroupId - 分组ID + * @param {filter} [opts.filters] - isApiProduct - 是否API产品,精确匹配,1为是 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param deployment deployments + */ + + describeDeployments (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 describeDeployments" + ) + } + + opts = opts || {} + + if (opts.apiGroupId === undefined || opts.apiGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.apiGroupId' when calling describeDeployments" + ) + } + + let postBody = null + let queryParams = {} + Object.assign(queryParams, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId, + apiGroupId: opts.apiGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 describeDeployments 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 = this.makeRequest( + '/regions/{regionId}/apiGroups/{apiGroupId}/deployments', + '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.apiGroupId - 分组ID + * @param {string} opts.revision - 发布的修订版本号 + * @param {string} opts.environment - 环境:test、preview、online + * @param {string} [opts.backendServiceType] - 后端服务类型:mock、unique、vpc optional + * @param {string} [opts.backendUrl] - 后端地址 optional + * @param {string} [opts.description] - 描述 optional + * @param {string} [opts.jdsfName] - 微服务网关名称 optional + * @param {string} [opts.jdsfRegistryName] - 微服务注册中心ID optional + * @param {string} [opts.jdsfId] - 微服务ID optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deploy (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 deploy" + ) + } + + opts = opts || {} + + if (opts.apiGroupId === undefined || opts.apiGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.apiGroupId' when calling deploy" + ) + } + if (opts.revision === undefined || opts.revision === null) { + throw new Error( + "Missing the required parameter 'opts.revision' when calling deploy" + ) + } + if (opts.environment === undefined || opts.environment === null) { + throw new Error( + "Missing the required parameter 'opts.environment' when calling deploy" + ) + } + + let postBody = {} + if (opts.revision !== undefined && opts.revision !== null) { + postBody['revision'] = opts.revision + } + if (opts.environment !== undefined && opts.environment !== null) { + postBody['environment'] = opts.environment + } + if ( + opts.backendServiceType !== undefined && + opts.backendServiceType !== null + ) { + postBody['backendServiceType'] = opts.backendServiceType + } + if (opts.backendUrl !== undefined && opts.backendUrl !== null) { + postBody['backendUrl'] = opts.backendUrl + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.jdsfName !== undefined && opts.jdsfName !== null) { + postBody['jdsfName'] = opts.jdsfName + } + if (opts.jdsfRegistryName !== undefined && opts.jdsfRegistryName !== null) { + postBody['jdsfRegistryName'] = opts.jdsfRegistryName + } + if (opts.jdsfId !== undefined && opts.jdsfId !== null) { + postBody['jdsfId'] = opts.jdsfId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + apiGroupId: opts.apiGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 deploy 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 = this.makeRequest( + '/regions/{regionId}/apiGroups/{apiGroupId}/deployments', + '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.apiGroupId - 分组ID + * @param {string} opts.deploymentId - 部署ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param deployment apiGroup + */ + + describeDeployment (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 describeDeployment" + ) + } + + opts = opts || {} + + if (opts.apiGroupId === undefined || opts.apiGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.apiGroupId' when calling describeDeployment" + ) + } + if (opts.deploymentId === undefined || opts.deploymentId === null) { + throw new Error( + "Missing the required parameter 'opts.deploymentId' when calling describeDeployment" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + apiGroupId: opts.apiGroupId, + deploymentId: opts.deploymentId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 describeDeployment 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 = this.makeRequest( + '/regions/{regionId}/apiGroups/{apiGroupId}/deployments/{deploymentId}', + '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.apiGroupId - 分组ID + * @param {string} opts.deploymentId - 部署ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + offline (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 offline" + ) + } + + opts = opts || {} + + if (opts.apiGroupId === undefined || opts.apiGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.apiGroupId' when calling offline" + ) + } + if (opts.deploymentId === undefined || opts.deploymentId === null) { + throw new Error( + "Missing the required parameter 'opts.deploymentId' when calling offline" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + apiGroupId: opts.apiGroupId, + deploymentId: opts.deploymentId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 offline 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 = this.makeRequest( + '/regions/{regionId}/apiGroups/{apiGroupId}/deployments/{deploymentId}:offline', + '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.apiGroupId - 分组ID + * @param {string} [opts.deploymentIds] - 要删除的部署ID集合,以,分隔 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer successCount 操作成功的资源个数 + * @param errorItem failed + */ + + batchOffline (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 batchOffline" + ) + } + + opts = opts || {} + + if (opts.apiGroupId === undefined || opts.apiGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.apiGroupId' when calling batchOffline" + ) + } + + let postBody = {} + if (opts.deploymentIds !== undefined && opts.deploymentIds !== null) { + postBody['deploymentIds'] = opts.deploymentIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + apiGroupId: opts.apiGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 batchOffline 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 = this.makeRequest( + '/regions/{regionId}/apiGroups/{apiGroupId}/deployments:offline', + '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) + } + ) + } + + /** + * 查询key列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞) optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {string} [opts.orderBy] - 排序类型 optional + * @param {string} [opts.userType] - 用户类型 optional + * @param {string} [opts.keyId] - 密钥Id optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer total total count + * @param keyInfo data + */ + + queryKeys (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 queryKeys" + ) + } + + 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.orderBy !== undefined && opts.orderBy !== null) { + queryParams['orderBy'] = opts.orderBy + } + if (opts.userType !== undefined && opts.userType !== null) { + queryParams['userType'] = opts.userType + } + if (opts.keyId !== undefined && opts.keyId !== null) { + queryParams['keyId'] = opts.keyId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 queryKeys 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 = this.makeRequest( + '/regions/{regionId}/kms', + '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) + } + ) + } + + /** + * 创建key + * @param {Object} opts - parameters + * @param {string} [opts.keyName] - key 名称 optional + * @param {string} [opts.keyDesc] - key 描述 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string accessKey 生成的accessKey + * @param string secretKey 生成的secretKey + */ + + createKey (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 createKey" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.keyName !== undefined && opts.keyName !== null) { + postBody['keyName'] = opts.keyName + } + if (opts.keyDesc !== undefined && opts.keyDesc !== null) { + postBody['keyDesc'] = opts.keyDesc + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 createKey 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 = this.makeRequest( + '/regions/{regionId}/kms', + '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) + } + ) + } + + /** + * 重置key的acesskey和secretkey + * @param {Object} opts - parameters + * @param {string} opts.keyId - keyId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param keyInfo keyInfo + */ + + resetKey (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 resetKey" + ) + } + + opts = opts || {} + + if (opts.keyId === undefined || opts.keyId === null) { + throw new Error( + "Missing the required parameter 'opts.keyId' when calling resetKey" + ) + } + + let postBody = {} + if (opts.keyId !== undefined && opts.keyId !== null) { + postBody['keyId'] = opts.keyId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 resetKey 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 = this.makeRequest( + '/regions/{regionId}/kms', + '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) + } + ) + } + + /** + * 修改key信息 + * @param {Object} opts - parameters + * @param {string} opts.keyId - keyid + * @param {string} [opts.keyName] - key 名称 optional + * @param {string} [opts.keyDesc] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateKey (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 updateKey" + ) + } + + opts = opts || {} + + if (opts.keyId === undefined || opts.keyId === null) { + throw new Error( + "Missing the required parameter 'opts.keyId' when calling updateKey" + ) + } + + let postBody = {} + if (opts.keyId !== undefined && opts.keyId !== null) { + postBody['keyId'] = opts.keyId + } + if (opts.keyName !== undefined && opts.keyName !== null) { + postBody['keyName'] = opts.keyName + } + if (opts.keyDesc !== undefined && opts.keyDesc !== null) { + postBody['keyDesc'] = opts.keyDesc + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 updateKey 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 = this.makeRequest( + '/regions/{regionId}/kms', + 'PATCH', + 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) + } + ) + } + + /** + * 查询key详情 + * @param {Object} opts - parameters + * @param {string} opts.keyId - keyId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param keyInfo keyInfo + */ + + queryKeyInfo (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 queryKeyInfo" + ) + } + + opts = opts || {} + + if (opts.keyId === undefined || opts.keyId === null) { + throw new Error( + "Missing the required parameter 'opts.keyId' when calling queryKeyInfo" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + keyId: opts.keyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 queryKeyInfo 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 = this.makeRequest( + '/regions/{regionId}/kms/{keyId}', + '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 {filter} [opts.filters] - policyName - 策略名称,模糊匹配 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param rateLimitPolicy rateLimitPolicys + * @param integer totalCount 查询的流控策略数目 + */ + + queryRateLimitPolicies (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 queryRateLimitPolicies" + ) + } + + 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, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 queryRateLimitPolicies 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 = this.makeRequest( + '/regions/{regionId}/rateLimitPolicies', + '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 {rateLimitPolicyView} [opts.rateLimitPolicyView] - 流控策略详情 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string policyId 流控策略Id + */ + + createRateLimitPolicy (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 createRateLimitPolicy" + ) + } + + opts = opts || {} + + let postBody = {} + if ( + opts.rateLimitPolicyView !== undefined && + opts.rateLimitPolicyView !== null + ) { + postBody['rateLimitPolicyView'] = opts.rateLimitPolicyView + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 createRateLimitPolicy 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 = this.makeRequest( + '/regions/{regionId}/rateLimitPolicies', + '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.policyName + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string policyId 返回policyID + */ + + checkPolicyName (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 checkPolicyName" + ) + } + + opts = opts || {} + + if (opts.policyName === undefined || opts.policyName === null) { + throw new Error( + "Missing the required parameter 'opts.policyName' when calling checkPolicyName" + ) + } + + let postBody = {} + if (opts.policyName !== undefined && opts.policyName !== null) { + postBody['policyName'] = opts.policyName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 checkPolicyName 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 = this.makeRequest( + '/regions/{regionId}/rateLimitPolicies:checkPolicyNameExist', + 'PATCH', + 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.policyId - 限流策略ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param rateLimitPolicy rateLimitPolicy + */ + + queryRateLimitPolicy (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 queryRateLimitPolicy" + ) + } + + opts = opts || {} + + if (opts.policyId === undefined || opts.policyId === null) { + throw new Error( + "Missing the required parameter 'opts.policyId' when calling queryRateLimitPolicy" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + policyId: opts.policyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 queryRateLimitPolicy 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 = this.makeRequest( + '/regions/{regionId}/rateLimitPolicies/{policyId}', + '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.policyId - 限流策略ID + * @param {rateLimitPolicyView} [opts.rateLimitPolicyView] - 流控策略详情 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string policyId 流控策略Id + */ + + updateRateLimitPolicy (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 updateRateLimitPolicy" + ) + } + + opts = opts || {} + + if (opts.policyId === undefined || opts.policyId === null) { + throw new Error( + "Missing the required parameter 'opts.policyId' when calling updateRateLimitPolicy" + ) + } + + let postBody = {} + if ( + opts.rateLimitPolicyView !== undefined && + opts.rateLimitPolicyView !== null + ) { + postBody['rateLimitPolicyView'] = opts.rateLimitPolicyView + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + policyId: opts.policyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 updateRateLimitPolicy 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 = this.makeRequest( + '/regions/{regionId}/rateLimitPolicies/{policyId}', + 'PATCH', + 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.policyId - 限流策略ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string policyId 已删除流控策略Id + */ + + deleteRateLimitPolicy (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 deleteRateLimitPolicy" + ) + } + + opts = opts || {} + + if (opts.policyId === undefined || opts.policyId === null) { + throw new Error( + "Missing the required parameter 'opts.policyId' when calling deleteRateLimitPolicy" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + policyId: opts.policyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 deleteRateLimitPolicy 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 = this.makeRequest( + '/regions/{regionId}/rateLimitPolicies/{policyId}', + '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.policyId - 限流策略ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param bindGroups bindGroups + */ + + queryBindGroupPolicy (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 queryBindGroupPolicy" + ) + } + + opts = opts || {} + + if (opts.policyId === undefined || opts.policyId === null) { + throw new Error( + "Missing the required parameter 'opts.policyId' when calling queryBindGroupPolicy" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + policyId: opts.policyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 queryBindGroupPolicy 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 = this.makeRequest( + '/regions/{regionId}/rateLimitPolicies/{policyId}:bindGroup', + '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.policyId - 限流策略ID + * @param {string} opts.deploymentIds - 待绑定的部署ids逗号隔开 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param bindGroups bindGroups + */ + + bindGroupPolicy (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 bindGroupPolicy" + ) + } + + opts = opts || {} + + if (opts.policyId === undefined || opts.policyId === null) { + throw new Error( + "Missing the required parameter 'opts.policyId' when calling bindGroupPolicy" + ) + } + if (opts.deploymentIds === undefined || opts.deploymentIds === null) { + throw new Error( + "Missing the required parameter 'opts.deploymentIds' when calling bindGroupPolicy" + ) + } + + let postBody = {} + if (opts.deploymentIds !== undefined && opts.deploymentIds !== null) { + postBody['deploymentIds'] = opts.deploymentIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + policyId: opts.policyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 bindGroupPolicy 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 = this.makeRequest( + '/regions/{regionId}/rateLimitPolicies/{policyId}:bindGroup', + '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.policyId - 限流策略ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param bindGroups bindGroups + */ + + queryPolicyGroupList (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 queryPolicyGroupList" + ) + } + + opts = opts || {} + + if (opts.policyId === undefined || opts.policyId === null) { + throw new Error( + "Missing the required parameter 'opts.policyId' when calling queryPolicyGroupList" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + policyId: opts.policyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 queryPolicyGroupList 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 = this.makeRequest( + '/regions/{regionId}/rateLimitPolicies/{policyId}:groupList', + '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.apiGroupId - 分组ID + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞) optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {filter} [opts.filters] - revision - 修订版本号,精确匹配 +environment - 发布环境,模糊匹配 +revisionNote - 修订备注,精确匹配 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param revisionList revisions + * @param integer totalCount 查询的版本数目 + */ + + describeRevisions (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 describeRevisions" + ) + } + + opts = opts || {} + + if (opts.apiGroupId === undefined || opts.apiGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.apiGroupId' when calling describeRevisions" + ) + } + + 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, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId, + apiGroupId: opts.apiGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 describeRevisions 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 = this.makeRequest( + '/regions/{regionId}/apiGroups/{apiGroupId}/revision', + '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.apiGroupId - 分组ID + * @param {string} [opts.revision] - 修订版本号,如果创建版本时传回修订版本,此为必填项 optional + * @param {string} [opts.baseRevision] - 基于此版本,如果创建版本时传回修订版本,此为必填项 optional + * @param {string} [opts.revisionNote] - 修订备注 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string revision 新建的修订版本号 + */ + + createRevision (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 createRevision" + ) + } + + opts = opts || {} + + if (opts.apiGroupId === undefined || opts.apiGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.apiGroupId' when calling createRevision" + ) + } + + let postBody = {} + if (opts.revision !== undefined && opts.revision !== null) { + postBody['revision'] = opts.revision + } + if (opts.baseRevision !== undefined && opts.baseRevision !== null) { + postBody['baseRevision'] = opts.baseRevision + } + if (opts.revisionNote !== undefined && opts.revisionNote !== null) { + postBody['revisionNote'] = opts.revisionNote + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + apiGroupId: opts.apiGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 createRevision 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 = this.makeRequest( + '/regions/{regionId}/apiGroups/{apiGroupId}/revision', + '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.apiGroupId - 分组ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param revisionList revisions + */ + + getRevisionIds (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 getRevisionIds" + ) + } + + opts = opts || {} + + if (opts.apiGroupId === undefined || opts.apiGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.apiGroupId' when calling getRevisionIds" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + apiGroupId: opts.apiGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 getRevisionIds 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 = this.makeRequest( + '/regions/{regionId}/apiGroups/{apiGroupId}/revisions', + '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.apiGroupId - 分组ID + * @param {string} opts.revision - 版本号 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean isRepeate 新建修订版本号重复否 + */ + + checkRevisionExist (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 checkRevisionExist" + ) + } + + opts = opts || {} + + if (opts.apiGroupId === undefined || opts.apiGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.apiGroupId' when calling checkRevisionExist" + ) + } + if (opts.revision === undefined || opts.revision === null) { + throw new Error( + "Missing the required parameter 'opts.revision' when calling checkRevisionExist" + ) + } + + let postBody = {} + if (opts.revision !== undefined && opts.revision !== null) { + postBody['revision'] = opts.revision + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + apiGroupId: opts.apiGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 checkRevisionExist 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 = this.makeRequest( + '/regions/{regionId}/apiGroups/{apiGroupId}/revision:checkExist', + '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) + } + ) + } + + /** + * 查询某版本对应的api + * @param {Object} opts - parameters + * @param {string} opts.apiGroupId - 分组ID + * @param {string} opts.revisionId - 版本ID + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞) optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {filter} [opts.filters] - revision - 修订版本号,模糊匹配 +environment - 发布环境,模糊匹配 +revisionNote - 修订备注,模糊匹配 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param api apis + * @param integer totalCount 查询的版本数目 + */ + + queryRevision (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 queryRevision" + ) + } + + opts = opts || {} + + if (opts.apiGroupId === undefined || opts.apiGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.apiGroupId' when calling queryRevision" + ) + } + if (opts.revisionId === undefined || opts.revisionId === null) { + throw new Error( + "Missing the required parameter 'opts.revisionId' when calling queryRevision" + ) + } + + 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, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId, + apiGroupId: opts.apiGroupId, + revisionId: opts.revisionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 queryRevision 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 = this.makeRequest( + '/regions/{regionId}/apiGroups/{apiGroupId}/revision/{revisionId}', + '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.apiGroupId - 分组ID + * @param {string} opts.revisionId - 版本ID + * @param {string} [opts.revisionNote] - 修订备注 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean updateRevision 修改修订版本成功否 + */ + + modifyRevision (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 modifyRevision" + ) + } + + opts = opts || {} + + if (opts.apiGroupId === undefined || opts.apiGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.apiGroupId' when calling modifyRevision" + ) + } + if (opts.revisionId === undefined || opts.revisionId === null) { + throw new Error( + "Missing the required parameter 'opts.revisionId' when calling modifyRevision" + ) + } + + let postBody = {} + if (opts.revisionNote !== undefined && opts.revisionNote !== null) { + postBody['revisionNote'] = opts.revisionNote + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + apiGroupId: opts.apiGroupId, + revisionId: opts.revisionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 modifyRevision 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 = this.makeRequest( + '/regions/{regionId}/apiGroups/{apiGroupId}/revision/{revisionId}', + 'PATCH', + 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.apiGroupId - 分组ID + * @param {string} opts.revisionId - 版本ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean deleteRevision 删除修订版本成功否 + */ + + deleteRevision (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 deleteRevision" + ) + } + + opts = opts || {} + + if (opts.apiGroupId === undefined || opts.apiGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.apiGroupId' when calling deleteRevision" + ) + } + if (opts.revisionId === undefined || opts.revisionId === null) { + throw new Error( + "Missing the required parameter 'opts.revisionId' when calling deleteRevision" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + apiGroupId: opts.apiGroupId, + revisionId: opts.revisionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 deleteRevision 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 = this.makeRequest( + '/regions/{regionId}/apiGroups/{apiGroupId}/revision/{revisionId}', + '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] - description - 名称,模糊匹配 +subscriptionKeyId - subscriptionKeyId,精确匹配 +orderBy - 排序类型 desc asc + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param subscriptionKey subscriptionKeys + * @param integer totalCount 查询的密钥数目 + */ + + querySubscriptionKeys (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 querySubscriptionKeys" + ) + } + + 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, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 querySubscriptionKeys 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 = this.makeRequest( + '/regions/{regionId}/subscriptionKeys', + '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.description] - 描述 optional + * @param {string} [opts.name] - 密钥名称 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string subscriptionKeyId 已创建密钥ID + */ + + createSubscriptionKey (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 createSubscriptionKey" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 createSubscriptionKey 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 = this.makeRequest( + '/regions/{regionId}/subscriptionKeys', + '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.subscriptionKeyId - subscription key id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param subscriptionKey subscriptionKey + */ + + querySubscriptionKey (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 querySubscriptionKey" + ) + } + + opts = opts || {} + + if ( + opts.subscriptionKeyId === undefined || + opts.subscriptionKeyId === null + ) { + throw new Error( + "Missing the required parameter 'opts.subscriptionKeyId' when calling querySubscriptionKey" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + subscriptionKeyId: opts.subscriptionKeyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 querySubscriptionKey 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 = this.makeRequest( + '/regions/{regionId}/subscriptionKeys/{subscriptionKeyId}', + '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.subscriptionKeyId - subscription key id + * @param {string} [opts.description] - 描述 optional + * @param {string} [opts.name] - 密钥名称 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string subscriptionKeyId 已更新密钥Id + */ + + updateSubscriptionKey (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 updateSubscriptionKey" + ) + } + + opts = opts || {} + + if ( + opts.subscriptionKeyId === undefined || + opts.subscriptionKeyId === null + ) { + throw new Error( + "Missing the required parameter 'opts.subscriptionKeyId' when calling updateSubscriptionKey" + ) + } + + let postBody = {} + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + subscriptionKeyId: opts.subscriptionKeyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 updateSubscriptionKey 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 = this.makeRequest( + '/regions/{regionId}/subscriptionKeys/{subscriptionKeyId}', + 'PATCH', + 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.subscriptionKeyId - subscription key id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string subscriptionKeyId 已删除密钥Id + */ + + deleteSubscriptionKey (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 deleteSubscriptionKey" + ) + } + + opts = opts || {} + + if ( + opts.subscriptionKeyId === undefined || + opts.subscriptionKeyId === null + ) { + throw new Error( + "Missing the required parameter 'opts.subscriptionKeyId' when calling deleteSubscriptionKey" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + subscriptionKeyId: opts.subscriptionKeyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 deleteSubscriptionKey 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 = this.makeRequest( + '/regions/{regionId}/subscriptionKeys/{subscriptionKeyId}', + '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] - accessKey - accesskey,精确匹配 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param ucAccessKey accessKeys + * @param integer totalCount 查询的密钥数目 + */ + + queryUcAccessKeys (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 queryUcAccessKeys" + ) + } + + 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, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 queryUcAccessKeys 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 = this.makeRequest( + '/regions/{regionId}/ucAccessKeys', + '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) + } + ) + } + + /** + * 校验pin是否存在 + * @param {Object} opts - parameters + * @param {string} opts.pin - 京东云pin + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + checkPin (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 checkPin" + ) + } + + opts = opts || {} + + if (opts.pin === undefined || opts.pin === null) { + throw new Error( + "Missing the required parameter 'opts.pin' when calling checkPin" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + pin: opts.pin + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 checkPin 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 = this.makeRequest( + '/regions/{regionId}/pins/{pin}:checkPin', + '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) + } + ) + } + + /** + * 查询domian列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {string} [opts.orderBy] - 排序类型 optional + * @param {string} opts.apiGroupId - api分组id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer total total count + * @param domainInfo data + */ + + queryUserDomains (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 queryUserDomains" + ) + } + + opts = opts || {} + + if (opts.apiGroupId === undefined || opts.apiGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.apiGroupId' when calling queryUserDomains" + ) + } + + 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.orderBy !== undefined && opts.orderBy !== null) { + queryParams['orderBy'] = opts.orderBy + } + if (opts.apiGroupId !== undefined && opts.apiGroupId !== null) { + queryParams['apiGroupId'] = opts.apiGroupId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 queryUserDomains 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 = this.makeRequest( + '/regions/{regionId}/userdomain', + '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.domain - 域名 + * @param {string} [opts.protocol] - 协议 optional + * @param {string} opts.apiGroupId - api分组id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string domainId 生成的domainId + */ + + createUserDomain (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 createUserDomain" + ) + } + + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling createUserDomain" + ) + } + if (opts.apiGroupId === undefined || opts.apiGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.apiGroupId' when calling createUserDomain" + ) + } + + let postBody = {} + if (opts.domain !== undefined && opts.domain !== null) { + postBody['domain'] = opts.domain + } + if (opts.protocol !== undefined && opts.protocol !== null) { + postBody['protocol'] = opts.protocol + } + if (opts.apiGroupId !== undefined && opts.apiGroupId !== null) { + postBody['apiGroupId'] = opts.apiGroupId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 createUserDomain 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 = this.makeRequest( + '/regions/{regionId}/userdomain', + '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.domainIds - 要删除domain的id集合,以,分隔 + * @param {string} [opts.apiGroupId] - api分组id optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteUserDomain (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 deleteUserDomain" + ) + } + + opts = opts || {} + + if (opts.domainIds === undefined || opts.domainIds === null) { + throw new Error( + "Missing the required parameter 'opts.domainIds' when calling deleteUserDomain" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainIds !== undefined && opts.domainIds !== null) { + queryParams['domainIds'] = opts.domainIds + } + if (opts.apiGroupId !== undefined && opts.apiGroupId !== null) { + queryParams['apiGroupId'] = opts.apiGroupId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 apigateway/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 deleteUserDomain 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 = this.makeRequest( + '/regions/{regionId}/userdomain', + '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) + } + ) + } +} +module.exports = JDCloud.APIGATEWAY diff --git a/packages/libs/lib-jdcloud/src/repo/asset/v1/asset.js b/packages/libs/lib-jdcloud/src/repo/asset/v1/asset.js new file mode 100644 index 000000000..07d952258 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/asset/v1/asset.js @@ -0,0 +1,274 @@ +/* + * 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. + * + * JDCLOUD asset API + * API JDCLOUD asset API + * + * 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 = 'asset' +Service._services[serviceId] = true + +/** + * asset service. + * @version 0.0.3 + */ + +class ASSET extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'asset.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询账户金额(总金额、可用金额、冻结金额、可提现金额、提现中金额) + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string totalAmount 总金额:可用金额+冻结金额 + * @param string availableAmount 可用金额 + * @param string frozenAmount 冻结金额:提现失败、处理中或预占中金额 + * @param string enableWithdrawAmount 可提现金额:排除对公充值金额总额后的充值总额,如果余额大于非对公充值总额,则为非对公充值总额,否则为余额(对公充值=企业线下汇款+企业充值+活动充值金额) + * @param string withdrawingAmount 提现中金额:提现状态为处理中和预占中的金额 + */ + + describeAccountAmount (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 describeAccountAmount" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 asset/0.0.3' + } + + 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 describeAccountAmount 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}/assets:describeAccountAmount', + '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 {balanceWarningInfoVo} opts.balanceWarningInfoVo + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status + */ + + modifyBalanceWarningInfo (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 modifyBalanceWarningInfo" + ) + } + + opts = opts || {} + + if ( + opts.balanceWarningInfoVo === undefined || + opts.balanceWarningInfoVo === null + ) { + throw new Error( + "Missing the required parameter 'opts.balanceWarningInfoVo' when calling modifyBalanceWarningInfo" + ) + } + + let postBody = {} + if ( + opts.balanceWarningInfoVo !== undefined && + opts.balanceWarningInfoVo !== null + ) { + postBody['balanceWarningInfoVo'] = opts.balanceWarningInfoVo + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 asset/0.0.3' + } + + 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 modifyBalanceWarningInfo 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}/assets:modifyBalanceWarningInfo', + '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 = ASSET diff --git a/packages/libs/lib-jdcloud/src/repo/assistant/v1/assistant.js b/packages/libs/lib-jdcloud/src/repo/assistant/v1/assistant.js new file mode 100644 index 000000000..3ce835a3f --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/assistant/v1/assistant.js @@ -0,0 +1,919 @@ +/* + * 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. + * + * LogConfig + * 用户日志相关配置 + * + * 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 = 'assistant' +Service._services[serviceId] = true + +/** + * assistant service. + * @version 1.0.2 + */ + +class ASSISTANT extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'assistant.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * +保存用户自定义命令。 + +详细操作说明请参考帮助文档:[用户自定义命令概述](https://docs.jdcloud.com/cn/virtual-machines/assistant-overview) + +## 接口说明 +- 该接口用于保存用户自定义命令。 + + * @param {Object} opts - parameters + * @param {string} opts.commandName - 命令名称,长度为1\~128个字符,只允许中文、数字、大小写字母、英文下划线(\_)、连字符(-)及点(.)。 + + * @param {string} [opts.commandType] - 命令类型,可选值:shell和powershell,默认shell + optional + * @param {string} opts.commandContent - 以base64编码的命令内容,编码后长度小于36KB + + * @param {integer} [opts.timeout] - 超时时间,取值范围:[10, 86400], 超过该时间后,尚未执行完的命令会置为失败。默认60s + optional + * @param {string} [opts.username] - 用户名,执行该命令时的用户身份。在linux上默认是root,windows上默认是administrator。长度小于256 + optional + * @param {string} [opts.workdir] - 命令执行路径。在linux上默认是/root,windows上默认是C:\Windows\System32。长度小于256。 + optional + * @param {string} [opts.commandDescription] - 命令描述,描述该命令详细信息,如功能、使用注意事项等。长度小于256。 + optional + * @param {boolean} [opts.enableParameter] - 是否使用参数, 默认false,不使用参数 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string commandId 命令Id。 + */ + + createCommand (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 createCommand" + ) + } + + opts = opts || {} + + if (opts.commandName === undefined || opts.commandName === null) { + throw new Error( + "Missing the required parameter 'opts.commandName' when calling createCommand" + ) + } + if (opts.commandContent === undefined || opts.commandContent === null) { + throw new Error( + "Missing the required parameter 'opts.commandContent' when calling createCommand" + ) + } + + let postBody = {} + if (opts.commandName !== undefined && opts.commandName !== null) { + postBody['commandName'] = opts.commandName + } + if (opts.commandType !== undefined && opts.commandType !== null) { + postBody['commandType'] = opts.commandType + } + if (opts.commandContent !== undefined && opts.commandContent !== null) { + postBody['commandContent'] = opts.commandContent + } + if (opts.timeout !== undefined && opts.timeout !== null) { + postBody['timeout'] = opts.timeout + } + if (opts.username !== undefined && opts.username !== null) { + postBody['username'] = opts.username + } + if (opts.workdir !== undefined && opts.workdir !== null) { + postBody['workdir'] = opts.workdir + } + if ( + opts.commandDescription !== undefined && + opts.commandDescription !== null + ) { + postBody['commandDescription'] = opts.commandDescription + } + if (opts.enableParameter !== undefined && opts.enableParameter !== null) { + postBody['enableParameter'] = opts.enableParameter + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 assistant/1.0.2' + } + + 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 createCommand 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}/createCommand', + '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) + } + ) + } + + /** + * +查询用户自定义命令。 + +详细操作说明请参考帮助文档:[用户自定义命令概述](https://docs.jdcloud.com/cn/virtual-machines/assistant-overview) + +## 接口说明 +- 该接口用于查询用户保存的自定义命令。 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页数,默认是第一页,取值为 1 + optional + * @param {integer} [opts.pageSize] - 每页命令数,默认为20,最大为100 + optional + * @param {array} [opts.commandIds] - 命令Id,最多可传入100个命令Id + optional + * @param {array} [opts.commandNames] - 命令名称,长度为1\~128个字符,只允许中文、数字、大小写字母、英文下划线(\_)、连字符(-)及点(.)。最多可传入100个命令名称。 + optional + * @param {array} [opts.commandTypes] - 命令类型,可选值:shell和powershell,默认shell + optional + * @param {string} [opts.sourceType] - 命令来源,可选值:jdcloud(官方)和self,默认self + optional + * @param {array} [opts.usernames] - 用户名,执行该命令时的用户身份。在linux上默认是root,windows上默认是administrator。长度小于256 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount 总的命令数,可以根据该字段来决定是否继续查找 + * @param command commands + */ + + describeCommands (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 describeCommands" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + if (opts.commandIds !== undefined && opts.commandIds !== null) { + postBody['commandIds'] = opts.commandIds + } + if (opts.commandNames !== undefined && opts.commandNames !== null) { + postBody['commandNames'] = opts.commandNames + } + if (opts.commandTypes !== undefined && opts.commandTypes !== null) { + postBody['commandTypes'] = opts.commandTypes + } + if (opts.sourceType !== undefined && opts.sourceType !== null) { + postBody['sourceType'] = opts.sourceType + } + if (opts.usernames !== undefined && opts.usernames !== null) { + postBody['usernames'] = opts.usernames + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 assistant/1.0.2' + } + + 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 describeCommands 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}/describeCommands', + '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) + } + ) + } + + /** + * +删除用户自定义命令。 + +详细操作说明请参考帮助文档:[用户自定义命令概述](https://docs.jdcloud.com/cn/virtual-machines/assistant-overview) + +## 接口说明 +- 该接口用于删除用户自定义命令。 + + * @param {Object} opts - parameters + * @param {array} [opts.commandIds] - 用户创建的命令Id + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string commandId 命令Id。 + */ + + deleteCommands (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 deleteCommands" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.commandIds !== undefined && opts.commandIds !== null) { + postBody['commandIds'] = opts.commandIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 assistant/1.0.2' + } + + 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 deleteCommands 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}/deleteCommands', + '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) + } + ) + } + + /** + * +执行用户保存的自定义命令。 + +详细操作说明请参考帮助文档:[用户自定义命令概述](https://docs.jdcloud.com/cn/virtual-machines/assistant-overview) + +## 接口说明 +- 该接口用于执行用户保存的自定义命令。 + + * @param {Object} opts - parameters + * @param {string} opts.commandId - 命令Id + + * @param {array} [opts.instances] - 运行该命令的云主机,与tags查到云主机取并集,一次最多云主机数50 + optional + * @param {array} [opts.tags] - 根据tags确定运行该命令的云主机,与指定instances云主机取并集,一次最多云主机数50 + optional + * @param {string} [opts.execTime] - 配置运行该命令的时刻,格式`yyyy-MM-dd HH:mm:ss`。不传该参数,立即执行命令。默认为空,可配置的时间范围为`当前时间+10minute`~`当前时间+6month`。 + optional + * @param {integer} [opts.timeout] - 超时时间,取值范围:[10, 86400], 超过该时间后,尚未执行完的命令会置为失败。默认60s + optional + * @param {string} [opts.username] - 用户名,执行该命令时的用户身份。在linux上默认是root,windows上默认是administrator。长度小于256 + optional + * @param {string} [opts.workdir] - 命令执行路径,在linux上默认为用户的home目录:/root, 在windows上默认为:C:\Windows\system32 + optional + * @param {string} [opts.windowsPassword] - 和用户名相匹配的密码,仅适用于windows系统 + optional + * @param {boolean} [opts.enableParameter] - 脚本中是否启用参数,true:启用,false:不启用。 + optional + * @param {array} [opts.parameters] - 用户自定义参数和对应的参数值,数量不超过20。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string invokeId 命令调用Id。 + */ + + invokeCommand (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 invokeCommand" + ) + } + + opts = opts || {} + + if (opts.commandId === undefined || opts.commandId === null) { + throw new Error( + "Missing the required parameter 'opts.commandId' when calling invokeCommand" + ) + } + + let postBody = {} + if (opts.commandId !== undefined && opts.commandId !== null) { + postBody['commandId'] = opts.commandId + } + if (opts.instances !== undefined && opts.instances !== null) { + postBody['instances'] = opts.instances + } + if (opts.tags !== undefined && opts.tags !== null) { + postBody['tags'] = opts.tags + } + if (opts.execTime !== undefined && opts.execTime !== null) { + postBody['execTime'] = opts.execTime + } + if (opts.timeout !== undefined && opts.timeout !== null) { + postBody['timeout'] = opts.timeout + } + if (opts.username !== undefined && opts.username !== null) { + postBody['username'] = opts.username + } + if (opts.workdir !== undefined && opts.workdir !== null) { + postBody['workdir'] = opts.workdir + } + if (opts.windowsPassword !== undefined && opts.windowsPassword !== null) { + postBody['windowsPassword'] = opts.windowsPassword + } + if (opts.enableParameter !== undefined && opts.enableParameter !== null) { + postBody['enableParameter'] = opts.enableParameter + } + if (opts.parameters !== undefined && opts.parameters !== null) { + postBody['parameters'] = opts.parameters + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 assistant/1.0.2' + } + + 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 invokeCommand 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}/invokeCommand', + '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) + } + ) + } + + /** + * +查询命令调用。 + +详细操作说明请参考帮助文档:[用户自定义命令概述](https://docs.jdcloud.com/cn/virtual-machines/assistant-overview) + +## 接口说明 +- 该接口用于查询命令调用。 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页数,默认是第一页,取值1 + optional + * @param {integer} [opts.pageSize] - 每页大小,默认20, 最大100 + optional + * @param {array} [opts.invokeIds] - 命令执行Id + optional + * @param {array} [opts.commandIds] - 命令Id + optional + * @param {array} [opts.status] - 命令执行状态 + optional + * @param {array} [opts.commandNames] - 命令名字 + optional + * @param {array} [opts.commandTypes] - 命令类型, shell or powershell + optional + * @param {array} [opts.userNames] - 命令执行用户 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount 命令调用的总数 + * @param invocation invocations + */ + + describeInvocations (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 describeInvocations" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + if (opts.invokeIds !== undefined && opts.invokeIds !== null) { + postBody['invokeIds'] = opts.invokeIds + } + if (opts.commandIds !== undefined && opts.commandIds !== null) { + postBody['commandIds'] = opts.commandIds + } + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + if (opts.commandNames !== undefined && opts.commandNames !== null) { + postBody['commandNames'] = opts.commandNames + } + if (opts.commandTypes !== undefined && opts.commandTypes !== null) { + postBody['commandTypes'] = opts.commandTypes + } + if (opts.userNames !== undefined && opts.userNames !== null) { + postBody['userNames'] = opts.userNames + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 assistant/1.0.2' + } + + 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 describeInvocations 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}/describeInvocations', + '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) + } + ) + } + + /** + * +配置用户日志信息。 + +详细操作说明请参考帮助文档:[用户自定义命令概述](https://docs.jdcloud.com/cn/virtual-machines/assistant-overview) + +## 接口说明 +- 该接口用于配置用户日志信息。 + + * @param {Object} opts - parameters + * @param {string} [opts.logset] - 用户日志集名字 + optional + * @param {string} opts.logtopic - 用户日志主题名字 + + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + addLogConfig (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 addLogConfig" + ) + } + + opts = opts || {} + + if (opts.logtopic === undefined || opts.logtopic === null) { + throw new Error( + "Missing the required parameter 'opts.logtopic' when calling addLogConfig" + ) + } + + let postBody = {} + if (opts.logset !== undefined && opts.logset !== null) { + postBody['logset'] = opts.logset + } + if (opts.logtopic !== undefined && opts.logtopic !== null) { + postBody['logtopic'] = opts.logtopic + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 assistant/1.0.2' + } + + 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 addLogConfig 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}/addLogConfig', + '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 = ASSISTANT diff --git a/packages/libs/lib-jdcloud/src/repo/autotaskpolicy/v1/autotaskpolicy.js b/packages/libs/lib-jdcloud/src/repo/autotaskpolicy/v1/autotaskpolicy.js new file mode 100644 index 000000000..359d26d65 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/autotaskpolicy/v1/autotaskpolicy.js @@ -0,0 +1,1227 @@ +/* + * 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. + * + * 配额 + * 与配额相关的接口 + * + * 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 = 'autotaskpolicy' +Service._services[serviceId] = true + +/** + * autotaskpolicy service. + * @version 1.0.1 + */ + +class AUTOTASKPOLICY extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'autotaskpolicy.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 创建策略,不同策略类型有不同的规则,具体如下。 +- AutoImage: 自动创建镜像策略 + - fireCondition + - 仅支持"interval",执行周期仅支持"小时/天/周",如: "interval 7d" + - 两次执行时间间隔需要大于12小时 + - fireTime + - 触发时间,首次创建时距离当前时间必须在30分钟以后至1年以内。 + - 若策略曾经执行过,再次修改该字段时必须满足距离上一次执行时间超过12小时 + - execResource + - 哪些云主机需要制作镜像,可指定具体云主机ID列表,每个策略最多绑定100个。 + - 仅支持云盘系统盘的虚机 + - execConfig + - 配置规则例子: + - [{"key":"includeDeviceName","value":"vdb,vdc"},{"key":"imageLiveDays","10"}] + - includeDeviceName说明:云主机中的哪些云盘需要制作镜像,可指定具体盘符列表,或指定为"all"。云主机中的vda系统盘不可改变,一定要参与制作镜像。 + - imageLiveDays说明:镜像保留时间,以天为单位,范围1-36500。不指定则永久有效。 + + * @param {Object} opts - parameters + * @param {policySpec} opts.policySpec - 策略配置 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string policyId 策略ID + */ + + createPolicy (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 createPolicy" + ) + } + + opts = opts || {} + + if (opts.policySpec === undefined || opts.policySpec === null) { + throw new Error( + "Missing the required parameter 'opts.policySpec' when calling createPolicy" + ) + } + + let postBody = {} + if (opts.policySpec !== undefined && opts.policySpec !== null) { + postBody['policySpec'] = opts.policySpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 autotaskpolicy/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 createPolicy 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}/policy', + '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.policyId - 策略ID + * @param {modifyPolicySpec} opts.policySpec - 策略配置 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyPolicy (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 modifyPolicy" + ) + } + + opts = opts || {} + + if (opts.policyId === undefined || opts.policyId === null) { + throw new Error( + "Missing the required parameter 'opts.policyId' when calling modifyPolicy" + ) + } + if (opts.policySpec === undefined || opts.policySpec === null) { + throw new Error( + "Missing the required parameter 'opts.policySpec' when calling modifyPolicy" + ) + } + + let postBody = {} + if (opts.policySpec !== undefined && opts.policySpec !== null) { + postBody['policySpec'] = opts.policySpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + policyId: opts.policyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 autotaskpolicy/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 modifyPolicy 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}/policy/{policyId}:modify', + '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.policyId - 策略ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param policy policy + */ + + describePolicy (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 describePolicy" + ) + } + + opts = opts || {} + + if (opts.policyId === undefined || opts.policyId === null) { + throw new Error( + "Missing the required parameter 'opts.policyId' when calling describePolicy" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + policyId: opts.policyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 autotaskpolicy/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 describePolicy 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}/policy/{policyId}', + '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.policyId - 策略ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deletePolicy (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 deletePolicy" + ) + } + + opts = opts || {} + + if (opts.policyId === undefined || opts.policyId === null) { + throw new Error( + "Missing the required parameter 'opts.policyId' when calling deletePolicy" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + policyId: opts.policyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 autotaskpolicy/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 deletePolicy 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}/policy/{policyId}', + '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 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,最大100。 optional + * @param {filter} [opts.filters] - policyId - 策略ID,精确匹配,支持多个 +policyState - 策略状态,精确匹配,支持多个 +policyType - 策略类型,精确匹配,支持多个 +policyName - 策略名称,模糊匹配,支持一个 +resourceId - 已关联的资源ID,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param policy policies + * @param number totalCount + */ + + describePolicies (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 describePolicies" + ) + } + + 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 autotaskpolicy/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 describePolicies 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}/policies', + '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.policyId - 策略ID + * @param {string} opts.targetRegion - 目标地域 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string policyId 策略ID + */ + + copyPolicy (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 copyPolicy" + ) + } + + opts = opts || {} + + if (opts.policyId === undefined || opts.policyId === null) { + throw new Error( + "Missing the required parameter 'opts.policyId' when calling copyPolicy" + ) + } + if (opts.targetRegion === undefined || opts.targetRegion === null) { + throw new Error( + "Missing the required parameter 'opts.targetRegion' when calling copyPolicy" + ) + } + + let postBody = {} + if (opts.targetRegion !== undefined && opts.targetRegion !== null) { + postBody['targetRegion'] = opts.targetRegion + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + policyId: opts.policyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 autotaskpolicy/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 copyPolicy 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}/policy/{policyId}:copy', + '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.policyId - 策略ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + enablePolicy (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 enablePolicy" + ) + } + + opts = opts || {} + + if (opts.policyId === undefined || opts.policyId === null) { + throw new Error( + "Missing the required parameter 'opts.policyId' when calling enablePolicy" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + policyId: opts.policyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 autotaskpolicy/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 enablePolicy 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}/policy/{policyId}:enable', + '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.policyId - 策略ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + disablePolicy (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 disablePolicy" + ) + } + + opts = opts || {} + + if (opts.policyId === undefined || opts.policyId === null) { + throw new Error( + "Missing the required parameter 'opts.policyId' when calling disablePolicy" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + policyId: opts.policyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 autotaskpolicy/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 disablePolicy 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}/policy/{policyId}:disable', + '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.policyId - 策略ID + * @param {resource} opts.execResource - 关联的资源 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + associateExecResource (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 associateExecResource" + ) + } + + opts = opts || {} + + if (opts.policyId === undefined || opts.policyId === null) { + throw new Error( + "Missing the required parameter 'opts.policyId' when calling associateExecResource" + ) + } + if (opts.execResource === undefined || opts.execResource === null) { + throw new Error( + "Missing the required parameter 'opts.execResource' when calling associateExecResource" + ) + } + + let postBody = {} + if (opts.execResource !== undefined && opts.execResource !== null) { + postBody['execResource'] = opts.execResource + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + policyId: opts.policyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 autotaskpolicy/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 associateExecResource 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}/policy/{policyId}:associateExecResource', + '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.policyId - 策略ID + * @param {resource} opts.execResource - 取消关联的资源 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + disassociateExecResource (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 disassociateExecResource" + ) + } + + opts = opts || {} + + if (opts.policyId === undefined || opts.policyId === null) { + throw new Error( + "Missing the required parameter 'opts.policyId' when calling disassociateExecResource" + ) + } + if (opts.execResource === undefined || opts.execResource === null) { + throw new Error( + "Missing the required parameter 'opts.execResource' when calling disassociateExecResource" + ) + } + + let postBody = {} + if (opts.execResource !== undefined && opts.execResource !== null) { + postBody['execResource'] = opts.execResource + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + policyId: opts.policyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 autotaskpolicy/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 disassociateExecResource 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}/policy/{policyId}:disassociateExecResource', + '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 = AUTOTASKPOLICY diff --git a/packages/libs/lib-jdcloud/src/repo/baseanti/v1/baseanti.js b/packages/libs/lib-jdcloud/src/repo/baseanti/v1/baseanti.js new file mode 100644 index 000000000..0764686a7 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/baseanti/v1/baseanti.js @@ -0,0 +1,1933 @@ +/* + * 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. + * + * IP Resource APIs + * Anti DDoS Basic IP Resource APIs + * + * 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 = 'baseanti' +Service._services[serviceId] = true + +/** + * baseanti service. + * @version 1.3.0 + */ + +class BASEANTI extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'baseanti.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询攻击记录 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 分页大小 optional + * @param {string} opts.startTime - 开始时间, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ + * @param {string} opts.endTime - 结束时间, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ + * @param {string} [opts.ip] - 基础防护已防护的公网 IP, ip 不为空时, 查询 ip 对应的攻击记录, ip 为空时, 查询用户所有攻击记录<br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describeelasticipresources'>describeElasticIpResources</a> 接口查询基础防护已防护的私有网络弹性公网 IP<br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describecpsipresources'>describeCpsIpResources</a> 接口查询基础防护已防护的云物理服务器公网IP 和 弹性公网 IP<br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describeccsipresources'>describeCcsIpResources</a> 接口查询基础防护已防护的托管区公网 IP optional + * @param {string} callback - callback + @return {Object} result + * @param attackLog dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 实例总数 + * @param integer totalPage 总页数 + */ + + describeAttackLogs (opts, callback) { + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeAttackLogs" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeAttackLogs" + ) + } + + 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.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + Object.assign(queryParams, super.buildArrayParam(opts.ip, 'ip')) + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 baseanti/1.3.0' + } + + 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 describeAttackLogs 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( + '/attacklog', + '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.startTime - 开始时间, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ + * @param {string} opts.endTime - 结束时间, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ + * @param {string} [opts.ip] - 基础防护已防护的公网 IP, ip 不为空时, 统计 ip 对应的攻击情况, ip 为空时, 统计用户所有公网 IP 的攻击情况. <br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describeelasticipresources'>describeElasticIpResources</a> 接口查询基础防护已防护的私有网络弹性公网 IP. <br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describecpsipresources'>describeCpsIpResources</a> 接口查询基础防护已防护的云物理服务器公网IP 和 弹性公网 IP. <br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describeccsipresources'>describeCcsIpResources</a> 接口查询基础防护已防护的托管区公网 IP optional + * @param {string} callback - callback + @return {Object} result + * @param integer attackCount 攻击次数 + * @param integer blackHoleCount 黑洞次数 + * @param number peak 攻击流量峰值 + * @param string unit 攻击流量单位 + */ + + describeAttackStatistics (opts, callback) { + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeAttackStatistics" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeAttackStatistics" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + Object.assign(queryParams, super.buildArrayParam(opts.ip, 'ip')) + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 baseanti/1.3.0' + } + + 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 describeAttackStatistics 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( + '/describeAttackStatistics', + '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.startTime - 开始时间, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ + * @param {string} opts.endTime - 结束时间, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ + * @param {string} [opts.ip] - 基础防护已防护的公网 IP, ip 不为空时, 查询 ip 对应的各类型攻击次数, ip 为空时, 查询用户所有公网 IP 的各类型攻击次数. <br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describeelasticipresources'>describeElasticIpResources</a> 接口查询基础防护已防护的私有网络弹性公网 IP. <br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describecpsipresources'>describeCpsIpResources</a> 接口查询基础防护已防护的云物理服务器公网IP 和 弹性公网 IP. <br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describeccsipresources'>describeCcsIpResources</a> 接口查询基础防护已防护的托管区公网 IP optional + * @param {string} callback - callback + @return {Object} result + * @param attackTypeCount dataList + */ + + describeAttackTypeCount (opts, callback) { + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeAttackTypeCount" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeAttackTypeCount" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + Object.assign(queryParams, super.buildArrayParam(opts.ip, 'ip')) + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 baseanti/1.3.0' + } + + 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 describeAttackTypeCount 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( + '/describeAttackTypeCount', + '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 的监控流量, 支持 ipv4 和 ipv6 + * @param {Object} opts - parameters + * @param {string} opts.startTime - 开始时间, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ + * @param {string} opts.endTime - 结束时间, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ + * @param {string} [opts.ip] - 基础防护已防护的公网 IP. <br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describeelasticipresources'>describeElasticIpResources</a> 接口查询基础防护已防护的私有网络弹性公网 IP. <br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describecpsipresources'>describeCpsIpResources</a> 接口查询基础防护已防护的云物理服务器公网IP 和 弹性公网 IP. <br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describeccsipresources'>describeCcsIpResources</a> 接口查询基础防护已防护的托管区公网 IP optional + * @param {string} callback - callback + @return {Object} result + * @param ipResourceFlow bps + * @param ipResourceFlow pps + */ + + describeIpMonitorFlow (opts, callback) { + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeIpMonitorFlow" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeIpMonitorFlow" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + Object.assign(queryParams, super.buildArrayParam(opts.ip, 'ip')) + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 baseanti/1.3.0' + } + + 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 describeIpMonitorFlow 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( + '/describeIpMonitorFlow', + '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(运营商级 NAT 保留地址除外), 云物理服务器的公网 IP 和弹性公网 IP. (已废弃, 建议使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describeelasticipresources'>describeElasticIpResources</a>, <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describecpsipresources'>describeCpsIpResources</a> 接口) + * @param {Object} opts - parameters + * @param {string} [opts.ip] - IP 模糊匹配 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param ipResource dataList + * @param integer totalCount + */ + + describeIpResources (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 describeIpResources" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.ip !== undefined && opts.ip !== null) { + queryParams['ip'] = opts.ip + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 baseanti/1.3.0' + } + + 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 describeIpResources 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}/ipResources', + '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(运营商级 NAT 保留地址除外) + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 分页大小 optional + * @param {string} [opts.ip] - IP 模糊匹配 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param ipResource dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 总数 + * @param integer totalPage 总页数 + */ + + describeElasticIpResources (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 describeElasticIpResources" + ) + } + + 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.ip !== undefined && opts.ip !== null) { + queryParams['ip'] = opts.ip + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 baseanti/1.3.0' + } + + 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 describeElasticIpResources 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}/elasticIpResources', + '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. + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 分页大小 optional + * @param {string} [opts.ip] - IP 模糊匹配 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param ipResource dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 总数 + * @param integer totalPage 总页数 + */ + + describeCpsIpResources (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 describeCpsIpResources" + ) + } + + 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.ip !== undefined && opts.ip !== null) { + queryParams['ip'] = opts.ip + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 baseanti/1.3.0' + } + + 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 describeCpsIpResources 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}/cpsIpResources', + '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 的安全信息 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 分页大小 optional + * @param {string} [opts.ip] - IP 模糊匹配 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param ipResource dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 总数 + * @param integer totalPage 总页数 + */ + + describeCcsIpResources (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 describeCcsIpResources" + ) + } + + 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.ip !== undefined && opts.ip !== null) { + queryParams['ip'] = opts.ip + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 baseanti/1.3.0' + } + + 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 describeCcsIpResources 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}/ccsIpResources', + '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) + } + ) + } + + /** + * 查询基础防护已防护的Web应用防火墙 IP 的安全信息 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 分页大小 optional + * @param {string} [opts.ip] - IP 模糊匹配 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param ipResource dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 总数 + * @param integer totalPage 总页数 + */ + + describeWafIpResources (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 describeWafIpResources" + ) + } + + 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.ip !== undefined && opts.ip !== null) { + queryParams['ip'] = opts.ip + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 baseanti/1.3.0' + } + + 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 describeWafIpResources 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}/wafIpResources', + '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 安全信息, 仅支持 ipv4. (已废弃, 建议使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describeipsafetyinfo'>describeIpSafetyInfo</a> 接口) + + * @param {Object} opts - parameters + * @param {string} opts.ip - 基础防护已防护的公网 IP, 仅支持 ipv4 格式. <br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describeelasticipresources'>describeElasticIpResources</a> 接口查询基础防护已防护的私有网络弹性公网 IP<br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describecpsipresources'>describeCpsIpResources</a> 接口查询基础防护已防护的云物理服务器公网 IP 和 弹性公网 IP<br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describeccsipresources'>describeCcsIpResources</a> 接口查询基础防护已防护的托管区公网 IP + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param ipResourceInfo data + */ + + describeIpResourceInfo (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 describeIpResourceInfo" + ) + } + + opts = opts || {} + + if (opts.ip === undefined || opts.ip === null) { + throw new Error( + "Missing the required parameter 'opts.ip' when calling describeIpResourceInfo" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + ip: opts.ip + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 baseanti/1.3.0' + } + + 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 describeIpResourceInfo 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}/ipResources/{ip}', + '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 安全信息, 支持 ipv4 和 ipv6 + * @param {Object} opts - parameters + * @param {string} opts.ip - 基础防护已防护公网 IP, 支持 ipv4 和 ipv6. +<br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describeelasticipresources'>describeElasticIpResources</a> 接口查询基础防护已防护的私有网络弹性公网 IP +<br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describecpsipresources'>describeCpsIpResources</a> 接口查询基础防护已防护的云物理服务器公网IP 和 弹性公网 IP +<br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describewafipresources'>describeWafIpResources</a> 接口查询基础防护已防护的Web应用防火墙 IP +<br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describeccsipresources'>describeCcsIpResources</a> 接口查询基础防护已防护的托管区公网 IP + + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param ipSafetyInfo data + */ + + describeIpSafetyInfo (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 describeIpSafetyInfo" + ) + } + + opts = opts || {} + + if (opts.ip === undefined || opts.ip === null) { + throw new Error( + "Missing the required parameter 'opts.ip' when calling describeIpSafetyInfo" + ) + } + + let postBody = null + let queryParams = {} + if (opts.ip !== undefined && opts.ip !== null) { + queryParams['ip'] = opts.ip + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 baseanti/1.3.0' + } + + 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 describeIpSafetyInfo 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}/describeIpSafetyInfo', + '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 的清洗阈值, 仅支持 ipv4. (已废弃, 建议使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/setipcleanthreshold'>setIpCleanThreshold</a> 接口) + + * @param {Object} opts - parameters + * @param {string} opts.ip - 基础防护已防护的公网 IP, 仅支持 ipv4 格式. <br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describeelasticipresources'>describeElasticIpResources</a> 接口查询基础防护已防护的私有网络弹性公网 IP<br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describecpsipresources'>describeCpsIpResources</a> 接口查询基础防护已防护的云物理服务器公网 IP 和 弹性公网 IP<br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describeccsipresources'>describeCcsIpResources</a> 接口查询基础防护已防护的托管区公网 IP + * @param {cleanThresholdSpec} opts.cleanThresholdSpec - 请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + setCleanThreshold (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 setCleanThreshold" + ) + } + + opts = opts || {} + + if (opts.ip === undefined || opts.ip === null) { + throw new Error( + "Missing the required parameter 'opts.ip' when calling setCleanThreshold" + ) + } + if ( + opts.cleanThresholdSpec === undefined || + opts.cleanThresholdSpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.cleanThresholdSpec' when calling setCleanThreshold" + ) + } + + let postBody = {} + if ( + opts.cleanThresholdSpec !== undefined && + opts.cleanThresholdSpec !== null + ) { + postBody['cleanThresholdSpec'] = opts.cleanThresholdSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + ip: opts.ip + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 baseanti/1.3.0' + } + + 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 setCleanThreshold 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}/ipResources/{ip}:setCleanThreshold', + '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) + } + ) + } + + /** + * 设置基础防护已防护公网 IP 的清洗阈值, 支持 ipv4 和 ipv6 + * @param {Object} opts - parameters + * @param {ipCleanThresholdSpec} opts.ipCleanThresholdSpec - 请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 修改结果, 0: 修改失败, 1: 修改成功 + * @param string message 修改失败时给出具体原因 + */ + + setIpCleanThreshold (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 setIpCleanThreshold" + ) + } + + opts = opts || {} + + if ( + opts.ipCleanThresholdSpec === undefined || + opts.ipCleanThresholdSpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.ipCleanThresholdSpec' when calling setIpCleanThreshold" + ) + } + + let postBody = {} + if ( + opts.ipCleanThresholdSpec !== undefined && + opts.ipCleanThresholdSpec !== null + ) { + postBody['ipCleanThresholdSpec'] = opts.ipCleanThresholdSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 baseanti/1.3.0' + } + + 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 setIpCleanThreshold 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}/setIpCleanThreshold', + '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) + } + ) + } + + /** + * 查询公网 IP 可设置清洗阈值范围, 支持 ipv4 和 ipv6 + * @param {Object} opts - parameters + * @param {string} opts.ip - 基础防护已防护公网 IP, 支持 ipv4 和 ipv6. +<br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describeelasticipresources'>describeElasticIpResources</a> 接口查询基础防护已防护的私有网络弹性公网 IP +<br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describecpsipresources'>describeCpsIpResources</a> 接口查询基础防护已防护的云物理服务器公网IP 和 弹性公网 IP +<br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describewafipresources'>describeWafIpResources</a> 接口查询基础防护已防护的Web应用防火墙 IP +<br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describeccsipresources'>describeCcsIpResources</a> 接口查询基础防护已防护的托管区公网 IP + + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param ipCleanThresholdRange data + */ + + describeIpCleanThresholdRange ( + 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 describeIpCleanThresholdRange" + ) + } + + opts = opts || {} + + if (opts.ip === undefined || opts.ip === null) { + throw new Error( + "Missing the required parameter 'opts.ip' when calling describeIpCleanThresholdRange" + ) + } + + let postBody = null + let queryParams = {} + if (opts.ip !== undefined && opts.ip !== null) { + queryParams['ip'] = opts.ip + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 baseanti/1.3.0' + } + + 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 describeIpCleanThresholdRange 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}/describeIpCleanThresholdRange', + '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 的攻击记录, 仅支持 ipv4. (已废弃, 建议使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describeattacklogs'>describeAttackLogs</a> 接口) + + * @param {Object} opts - parameters + * @param {string} opts.ip - 基础防护已防护的公网 IP, 仅支持 ipv4 格式. <br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describeelasticipresources'>describeElasticIpResources</a> 接口查询基础防护已防护的私有网络弹性公网 IP<br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describecpsipresources'>describeCpsIpResources</a> 接口查询基础防护已防护的云物理服务器公网 IP 和 弹性公网 IP<br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describeccsipresources'>describeCcsIpResources</a> 接口查询基础防护已防护的托管区公网 IP + * @param {integer} [opts.start] - 限制查询的开始范围 optional + * @param {integer} [opts.limit] - 限制查询的记录数 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param ipResourceProtectInfo dataList + */ + + describeIpResourceProtectInfo ( + 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 describeIpResourceProtectInfo" + ) + } + + opts = opts || {} + + if (opts.ip === undefined || opts.ip === null) { + throw new Error( + "Missing the required parameter 'opts.ip' when calling describeIpResourceProtectInfo" + ) + } + + let postBody = null + let queryParams = {} + if (opts.start !== undefined && opts.start !== null) { + queryParams['start'] = opts.start + } + if (opts.limit !== undefined && opts.limit !== null) { + queryParams['limit'] = opts.limit + } + + let pathParams = { + regionId: regionId, + ip: opts.ip + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 baseanti/1.3.0' + } + + 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 describeIpResourceProtectInfo 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}/ipResources/{ip}/protectInfo', + '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 的 endTime 之前 15 分钟内监控流量, 仅支持 ipv4. (已废弃, 建议使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describeipmonitorflow'>describeIpMonitorFlow</a> 接口) + + * @param {Object} opts - parameters + * @param {string} opts.ip - 基础防护已防护的公网 IP, 仅支持 ipv4 格式. <br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describeelasticipresources'>describeElasticIpResources</a> 接口查询基础防护已防护的私有网络弹性公网 IP<br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describecpsipresources'>describeCpsIpResources</a> 接口查询基础防护已防护的云物理服务器公网 IP 和 弹性公网 IP<br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-basic/api/describeccsipresources'>describeCcsIpResources</a> 接口查询基础防护已防护的托管区公网 IP + * @param {string} [opts.endTime] - 查询的结束时间, UTC时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ, 为空时查询当前时间之前 15 分钟内监控流量 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param ipResourceFlow bps + * @param ipResourceFlow pps + */ + + describeIpResourceFlow (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 describeIpResourceFlow" + ) + } + + opts = opts || {} + + if (opts.ip === undefined || opts.ip === null) { + throw new Error( + "Missing the required parameter 'opts.ip' when calling describeIpResourceFlow" + ) + } + + let postBody = null + let queryParams = {} + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: regionId, + ip: opts.ip + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 baseanti/1.3.0' + } + + 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 describeIpResourceFlow 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}/ipResources/{ip}/monitorFlow', + '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 = BASEANTI diff --git a/packages/libs/lib-jdcloud/src/repo/bastion/v1/bastion.js b/packages/libs/lib-jdcloud/src/repo/bastion/v1/bastion.js new file mode 100644 index 000000000..4e4a8369c --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/bastion/v1/bastion.js @@ -0,0 +1,1613 @@ +/* + * 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. + * + * statistics + * 堡垒机规格分布数量信息 + * + * 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 = 'bastion' +Service._services[serviceId] = true + +/** + * bastion service. + * @version 1.0.0 + */ + +class BASTION extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'bastion.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 批量查询堡垒机的信息,此接口支持分页查询,默认每页20条 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 100] optional + * @param {filter} [opts.filters] - bid - 应用ID,精确匹配 +name - 应用名,精确匹配 + optional + * @param {sort} [opts.sorts] - createTime - 创建时间,asc(正序),desc(倒序) + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param bastion bastions + * @param number totalCount + */ + + describeBastions (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 describeBastions" + ) + } + + 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')) + Object.assign(queryParams, super.buildSortParam(opts.sorts, 'sorts')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 bastion/1.0.0' + } + + 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 describeBastions 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}/bastions', + '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.bid - 堡垒机id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param bastion bastion + */ + + describeBastion (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 describeBastion" + ) + } + + opts = opts || {} + + if (opts.bid === undefined || opts.bid === null) { + throw new Error( + "Missing the required parameter 'opts.bid' when calling describeBastion" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + bid: opts.bid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 bastion/1.0.0' + } + + 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 describeBastion 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}/bastion/{bid}', + '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.bid - 堡垒机id + * @param {string} opts.desc - 描述信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean result + */ + + updateBastionDesc (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 updateBastionDesc" + ) + } + + opts = opts || {} + + if (opts.bid === undefined || opts.bid === null) { + throw new Error( + "Missing the required parameter 'opts.bid' when calling updateBastionDesc" + ) + } + if (opts.desc === undefined || opts.desc === null) { + throw new Error( + "Missing the required parameter 'opts.desc' when calling updateBastionDesc" + ) + } + + let postBody = {} + if (opts.desc !== undefined && opts.desc !== null) { + postBody['desc'] = opts.desc + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + bid: opts.bid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 bastion/1.0.0' + } + + 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 updateBastionDesc 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}/bastion/{bid}', + 'PATCH', + 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) + } + ) + } + + /** + * 获取加密sign + * @param {Object} opts - parameters + * @param {string} [opts.pin] - 用户pin optional + * @param {string} opts.bastionId - 堡垒机实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param sign sign + */ + + describeSign (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 describeSign" + ) + } + + opts = opts || {} + + if (opts.bastionId === undefined || opts.bastionId === null) { + throw new Error( + "Missing the required parameter 'opts.bastionId' when calling describeSign" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pin !== undefined && opts.pin !== null) { + queryParams['pin'] = opts.pin + } + if (opts.bastionId !== undefined && opts.bastionId !== null) { + queryParams['bastionId'] = opts.bastionId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 bastion/1.0.0' + } + + 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 describeSign 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}/sign', + '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} opts.instanceId - 资源id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instance bastion + */ + + 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 || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeInstance" + ) + } + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeInstance" + ) + } + + let postBody = null + let queryParams = {} + if (opts.instanceId !== undefined && opts.instanceId !== null) { + queryParams['instanceId'] = opts.instanceId + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 bastion/1.0.0' + } + + 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}/instance/{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.instanceId - 堡垒机id + * @param {string} opts.instanceId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean result 结果 + */ + + 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 || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteInstance" + ) + } + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteInstance" + ) + } + + let postBody = null + let queryParams = {} + if (opts.instanceId !== undefined && opts.instanceId !== null) { + queryParams['instanceId'] = opts.instanceId + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 bastion/1.0.0' + } + + 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}/instance/{instanceId}', + '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.instanceId - 堡垒机id + * @param {string} opts.instanceId + * @param {boolean} opts.status + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean result 结果 + */ + + setInstanceZeroEnable (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 setInstanceZeroEnable" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling setInstanceZeroEnable" + ) + } + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling setInstanceZeroEnable" + ) + } + if (opts.status === undefined || opts.status === null) { + throw new Error( + "Missing the required parameter 'opts.status' when calling setInstanceZeroEnable" + ) + } + + let postBody = {} + if (opts.instanceId !== undefined && opts.instanceId !== null) { + postBody['instanceId'] = opts.instanceId + } + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 bastion/1.0.0' + } + + 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 setInstanceZeroEnable 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}/instance/{instanceId}/zero', + '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) + } + ) + } + + /** + * 设置公网IP状态,true为开放,false为关闭 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 堡垒机id + * @param {string} opts.instanceId + * @param {boolean} opts.status + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean result 结果 + */ + + setInstancePublicAccess (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 setInstancePublicAccess" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling setInstancePublicAccess" + ) + } + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling setInstancePublicAccess" + ) + } + if (opts.status === undefined || opts.status === null) { + throw new Error( + "Missing the required parameter 'opts.status' when calling setInstancePublicAccess" + ) + } + + let postBody = {} + if (opts.instanceId !== undefined && opts.instanceId !== null) { + postBody['instanceId'] = opts.instanceId + } + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 bastion/1.0.0' + } + + 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 setInstancePublicAccess 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}/instance/{instanceId}/publicAccess', + 'PATCH', + 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 {instanceSpec} opts.instanceSpec - 实例的相关配置 + * @param {chargeSpec} [opts.chargeSpec] - 计费信息的相关配置 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string buyId 交易buyId + * @param source sourceIds + */ + + createInstance (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 createInstance" + ) + } + + opts = opts || {} + + if (opts.instanceSpec === undefined || opts.instanceSpec === null) { + throw new Error( + "Missing the required parameter 'opts.instanceSpec' when calling createInstance" + ) + } + + let postBody = {} + if (opts.instanceSpec !== undefined && opts.instanceSpec !== null) { + postBody['instanceSpec'] = opts.instanceSpec + } + if (opts.chargeSpec !== undefined && opts.chargeSpec !== null) { + postBody['chargeSpec'] = opts.chargeSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 bastion/1.0.0' + } + + 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 createInstance 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}/instances', + '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 - 实例ID + * @param {string} opts.spec - 升配的规格 + * @param {boolean} [opts.autoPay] - 自动付款 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string buyId 交易buyId + */ + + 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.spec === undefined || opts.spec === null) { + throw new Error( + "Missing the required parameter 'opts.spec' when calling modifyInstanceSpec" + ) + } + + let postBody = {} + if (opts.spec !== undefined && opts.spec !== null) { + postBody['spec'] = opts.spec + } + if (opts.autoPay !== undefined && opts.autoPay !== null) { + postBody['autoPay'] = opts.autoPay + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 bastion/1.0.0' + } + + 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}/instances/{instanceId}: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.instanceId - 实例ID + * @param {integer} opts.status - 实例到期或者恢复实例服务 1:恢复实例服务 13:设置服务到期状态 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean result + */ + + modifyInstanceExpireOrStart (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 modifyInstanceExpireOrStart" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyInstanceExpireOrStart" + ) + } + if (opts.status === undefined || opts.status === null) { + throw new Error( + "Missing the required parameter 'opts.status' when calling modifyInstanceExpireOrStart" + ) + } + + let postBody = {} + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 bastion/1.0.0' + } + + 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 modifyInstanceExpireOrStart 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}/instances/{instanceId}:modifyInstanceExpireOrStart', + '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.sourceId - sourceid + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param bastion bastion + */ + + describeSourceId (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 describeSourceId" + ) + } + + opts = opts || {} + + if (opts.sourceId === undefined || opts.sourceId === null) { + throw new Error( + "Missing the required parameter 'opts.sourceId' when calling describeSourceId" + ) + } + + let postBody = null + let queryParams = {} + if (opts.sourceId !== undefined && opts.sourceId !== null) { + queryParams['sourceId'] = opts.sourceId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 bastion/1.0.0' + } + + 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 describeSourceId 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}/order/{sourceId}', + '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 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 100] optional + * @param {filter} [opts.filters] - valid - 有效用户 1:0 +upgrade - 升配标志 1:0 + optional + * @param {sort} [opts.sorts] - createTime - 创建时间,asc(正序),desc(倒序) + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param userPin pins + */ + + describePins (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 describePins" + ) + } + + 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')) + Object.assign(queryParams, super.buildSortParam(opts.sorts, 'sorts')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 bastion/1.0.0' + } + + 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 describePins 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}/pins', + '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 = BASTION diff --git a/packages/libs/lib-jdcloud/src/repo/bgw/v1/bgw.js b/packages/libs/lib-jdcloud/src/repo/bgw/v1/bgw.js new file mode 100644 index 000000000..bcc06a626 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/bgw/v1/bgw.js @@ -0,0 +1,285 @@ +/* + * 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. + * + * instances + * 续费查询实例信息接口 + * + * 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 = 'bgw' +Service._services[serviceId] = true + +/** + * bgw service. + * @version 1.3.1 + */ + +class BGW extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'bgw.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 修改VPN隧道管理状态 + * @param {Object} opts - parameters + * @param {string} opts.vpnTunnelId - VPN Tunnel ID + * @param {string} opts.adminStatus - 隧道管理状态, UP, DOWN + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyAdminStatus (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 modifyAdminStatus" + ) + } + + opts = opts || {} + + if (opts.vpnTunnelId === undefined || opts.vpnTunnelId === null) { + throw new Error( + "Missing the required parameter 'opts.vpnTunnelId' when calling modifyAdminStatus" + ) + } + if (opts.adminStatus === undefined || opts.adminStatus === null) { + throw new Error( + "Missing the required parameter 'opts.adminStatus' when calling modifyAdminStatus" + ) + } + + let postBody = {} + if (opts.adminStatus !== undefined && opts.adminStatus !== null) { + postBody['adminStatus'] = opts.adminStatus + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + vpnTunnelId: opts.vpnTunnelId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 bgw/1.3.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 modifyAdminStatus 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}/vpnTunnels/{vpnTunnelId}:adminStatus', + '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.pageNumber] - 页码, 默认为1, 取值范围:[1,∞), 页码超过总页数时, 显示最后一页 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {filter} [opts.filters] - connectionIds - 连接ID列表,支持多个 +connectionNames - 连接名称列表,支持多个 +types - 类型,取值:jcloud_hosted:托管连接、jcloud_partner:合作伙伴连接、jcloud:自助连接, 支持多个 +status - Connection状态,支持单个。取值为:待审核(Ordering)、待支付(Installation_Paying)、施工中(Pending)、等待确认(Confirming)、可用(Active)、不可用(InActive)、删除中(Deleting)、已删除(Deleted)、审核未通过(Rejected) + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param connection connections + * @param integer totalCount 总数量 + */ + + describeConnections (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 describeConnections" + ) + } + + 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 bgw/1.3.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 describeConnections 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}/connections/', + '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 = BGW diff --git a/packages/libs/lib-jdcloud/src/repo/billing/v1/billing.js b/packages/libs/lib-jdcloud/src/repo/billing/v1/billing.js new file mode 100644 index 000000000..a56489f92 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/billing/v1/billing.js @@ -0,0 +1,1427 @@ +/* + * 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. + * + * 停删规则 + * 停删规则 + * + * 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 = 'billing' +Service._services[serviceId] = true + +/** + * billing service. + * @version 1.1.16 + */ + +class BILLING extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'billing.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询账单资源汇总数据 + * @param {Object} opts - parameters + * @param {string} opts.startTime - 账期开始时间,不支持跨月查询。格式:yyyy-MM-dd HH:mm:ss + * @param {string} opts.endTime - 账期结束时间,不支持跨月查询。格式:yyyy-MM-dd HH:mm:ss + * @param {string} [opts.appCode] - 产品线代码 optional + * @param {string} [opts.serviceCode] - 产品代码 optional + * @param {array} [opts.resourceIds] - 资源单id列表,最多支持传入500个 optional + * @param {array} [opts.tags] - 标签,JSON格式:[{"k1":"v1"},{"k1":"v2"},{"k2":""}] +示例: +选择的标签为, 部门:广告部、部门:物流部、项目 +则传值为:[{"部门":"广告部"},{"部门":"物流部"},{"项目":""}] + optional + * @param {integer} [opts.pageIndex] - pageIndex 分页,默认从1开始 optional + * @param {integer} [opts.pageSize] - pageSize 每页查询数据条数,最多支持1000条 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param pagination pagination + * @param billSummary result + */ + + queryBillSummary (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 queryBillSummary" + ) + } + + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling queryBillSummary" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling queryBillSummary" + ) + } + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.appCode !== undefined && opts.appCode !== null) { + postBody['appCode'] = opts.appCode + } + if (opts.serviceCode !== undefined && opts.serviceCode !== null) { + postBody['serviceCode'] = opts.serviceCode + } + if (opts.resourceIds !== undefined && opts.resourceIds !== null) { + postBody['resourceIds'] = opts.resourceIds + } + if (opts.tags !== undefined && opts.tags !== null) { + postBody['tags'] = opts.tags + } + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + postBody['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 billing/1.1.16' + } + + 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 queryBillSummary 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}/billSummary:list', + '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.startTime - 账期开始时间,不支持跨月查询。格式:yyyy-MM-dd HH:mm:ss + * @param {string} opts.endTime - 账期结束时间,不支持跨月查询。格式:yyyy-MM-dd HH:mm:ss + * @param {string} [opts.appCode] - 产品线代码 optional + * @param {string} [opts.serviceCode] - 产品代码 optional + * @param {integer} [opts.billingType] - 计费类型 1、按配置 2、按用量 3、包年包月 4、按次 optional + * @param {array} [opts.resourceIds] - 资源单id列表,最多支持传入500个 optional + * @param {array} [opts.tags] - 标签,JSON格式:[{"k1":"v1"},{"k1":"v2"},{"k2":""}] +示例: +选择的标签为, 部门:广告部、部门:物流部、项目 +则传值为:[{"部门":"广告部"},{"部门":"物流部"},{"项目":""}] + optional + * @param {integer} [opts.pageIndex] - pageIndex 分页,默认从1开始 optional + * @param {integer} [opts.pageSize] - pageSize 每页查询数据条数,最多支持1000条 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param pagination pagination + * @param billSummary result + */ + + queryBillDetail (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 queryBillDetail" + ) + } + + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling queryBillDetail" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling queryBillDetail" + ) + } + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.appCode !== undefined && opts.appCode !== null) { + postBody['appCode'] = opts.appCode + } + if (opts.serviceCode !== undefined && opts.serviceCode !== null) { + postBody['serviceCode'] = opts.serviceCode + } + if (opts.billingType !== undefined && opts.billingType !== null) { + postBody['billingType'] = opts.billingType + } + if (opts.resourceIds !== undefined && opts.resourceIds !== null) { + postBody['resourceIds'] = opts.resourceIds + } + if (opts.tags !== undefined && opts.tags !== null) { + postBody['tags'] = opts.tags + } + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + postBody['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 billing/1.1.16' + } + + 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 queryBillDetail 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}/billDetail:list', + '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) + } + ) + } + + /** + * 查询账单资源汇总数据V2版本 + * @param {Object} opts - parameters + * @param {string} opts.startTime - 账期开始时间,不支持跨月查询。格式:yyyy-MM-dd HH:mm:ss + * @param {string} opts.endTime - 账期结束时间,不支持跨月查询。格式:yyyy-MM-dd HH:mm:ss + * @param {string} [opts.appCode] - 产品线代码 optional + * @param {string} [opts.serviceCode] - 产品代码 optional + * @param {array} [opts.resourceIds] - 资源单id列表,最多支持传入500个 optional + * @param {array} [opts.tags] - 标签,JSON格式:[{"k1":"v1"},{"k1":"v2"},{"k2":""}] +示例: +选择的标签为, 部门:广告部、部门:物流部、项目 +则传值为:[{"部门":"广告部"},{"部门":"物流部"},{"项目":""}] + optional + * @param {integer} [opts.pageIndex] - pageIndex 分页,默认从1开始 optional + * @param {integer} [opts.pageSize] - pageSize 每页查询数据条数,最多支持1000条 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param pagination pagination + * @param billSummaryV2 result + */ + + describeBillSummarys (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 describeBillSummarys" + ) + } + + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeBillSummarys" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeBillSummarys" + ) + } + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.appCode !== undefined && opts.appCode !== null) { + postBody['appCode'] = opts.appCode + } + if (opts.serviceCode !== undefined && opts.serviceCode !== null) { + postBody['serviceCode'] = opts.serviceCode + } + if (opts.resourceIds !== undefined && opts.resourceIds !== null) { + postBody['resourceIds'] = opts.resourceIds + } + if (opts.tags !== undefined && opts.tags !== null) { + postBody['tags'] = opts.tags + } + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + postBody['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 billing/1.1.16' + } + + 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 describeBillSummarys 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}/describeBillSummarys', + '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) + } + ) + } + + /** + * 查询账单明细数据V2版本 + * @param {Object} opts - parameters + * @param {string} opts.startTime - 账期开始时间,不支持跨月查询。格式:yyyy-MM-dd HH:mm:ss + * @param {string} opts.endTime - 账期结束时间,不支持跨月查询。格式:yyyy-MM-dd HH:mm:ss + * @param {string} [opts.appCode] - 产品线代码 optional + * @param {string} [opts.serviceCode] - 产品代码 optional + * @param {integer} [opts.billingType] - 计费类型 1、按配置 2、按用量 3、包年包月 4、按次 optional + * @param {array} [opts.resourceIds] - 资源单id列表,最多支持传入500个 optional + * @param {array} [opts.tags] - 标签,JSON格式:[{"k1":"v1"},{"k1":"v2"},{"k2":""}] +示例: +选择的标签为, 部门:广告部、部门:物流部、项目 +则传值为:[{"部门":"广告部"},{"部门":"物流部"},{"项目":""}] + optional + * @param {integer} [opts.pageIndex] - pageIndex 分页,默认从1开始 optional + * @param {integer} [opts.pageSize] - pageSize 每页查询数据条数,最多支持1000条 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param pagination pagination + * @param billSummaryV2 result + */ + + describeBillDetails (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 describeBillDetails" + ) + } + + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeBillDetails" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeBillDetails" + ) + } + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.appCode !== undefined && opts.appCode !== null) { + postBody['appCode'] = opts.appCode + } + if (opts.serviceCode !== undefined && opts.serviceCode !== null) { + postBody['serviceCode'] = opts.serviceCode + } + if (opts.billingType !== undefined && opts.billingType !== null) { + postBody['billingType'] = opts.billingType + } + if (opts.resourceIds !== undefined && opts.resourceIds !== null) { + postBody['resourceIds'] = opts.resourceIds + } + if (opts.tags !== undefined && opts.tags !== null) { + postBody['tags'] = opts.tags + } + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + postBody['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 billing/1.1.16' + } + + 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 describeBillDetails 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}/describeBillDetails', + '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.billDate - 账期时间,不支持跨月查询。格式:yyyyMM + * @param {string} [opts.appCode] - 产品线代码 optional + * @param {string} [opts.serviceCode] - 产品代码 optional + * @param {string} [opts.region] - 地域编码,如:cn-north-1 optional + * @param {string} [opts.resourceId] - 资源单id optional + * @param {integer} [opts.pageIndex] - pageIndex 分页,默认从1开始 optional + * @param {integer} [opts.pageSize] - pageSize 每页查询数据条数,最多支持1000条 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param pagination pagination + * @param formulaBillSummary result + */ + + describeFormulaSummaryList (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 describeFormulaSummaryList" + ) + } + + opts = opts || {} + + if (opts.billDate === undefined || opts.billDate === null) { + throw new Error( + "Missing the required parameter 'opts.billDate' when calling describeFormulaSummaryList" + ) + } + + let postBody = {} + if (opts.billDate !== undefined && opts.billDate !== null) { + postBody['billDate'] = opts.billDate + } + 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.pageIndex !== undefined && opts.pageIndex !== null) { + postBody['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 billing/1.1.16' + } + + 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 describeFormulaSummaryList 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}/describeFormulaSummaryList', + '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.startTime - 账期开始时间,不支持跨月查询。格式:yyyy-MM-dd HH:mm:ss + * @param {string} opts.endTime - 账期结束时间,不支持跨月查询。格式:yyyy-MM-dd HH:mm:ss + * @param {string} [opts.appCode] - 产品线代码 optional + * @param {string} [opts.serviceCode] - 产品代码 optional + * @param {array} [opts.subIds] - 拆分项ID列表,最多支持传入500个 optional + * @param {array} [opts.tags] - 标签,JSON格式:[{"k1":"v1"},{"k1":"v2"},{"k2":""}] +示例: +选择的标签为, 部门:广告部、部门:物流部、项目 +则传值为:[{"部门":"广告部"},{"部门":"物流部"},{"项目":""}] + optional + * @param {integer} [opts.pageIndex] - pageIndex 分页,默认从1开始 optional + * @param {integer} [opts.pageSize] - pageSize 每页查询数据条数,最多支持1000条 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param pagination pagination + * @param splitItemBillSummary result + */ + + querySplitItemDaySummary (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 querySplitItemDaySummary" + ) + } + + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling querySplitItemDaySummary" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling querySplitItemDaySummary" + ) + } + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.appCode !== undefined && opts.appCode !== null) { + postBody['appCode'] = opts.appCode + } + if (opts.serviceCode !== undefined && opts.serviceCode !== null) { + postBody['serviceCode'] = opts.serviceCode + } + if (opts.subIds !== undefined && opts.subIds !== null) { + postBody['subIds'] = opts.subIds + } + if (opts.tags !== undefined && opts.tags !== null) { + postBody['tags'] = opts.tags + } + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + postBody['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 billing/1.1.16' + } + + 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 querySplitItemDaySummary 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}/splitItemBillDaySummary:List', + '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.startTime - 账期开始时间,不支持跨月查询。格式:yyyy-MM-dd HH:mm:ss + * @param {string} opts.endTime - 账期结束时间,不支持跨月查询。格式:yyyy-MM-dd HH:mm:ss + * @param {string} [opts.appCode] - 产品线代码 optional + * @param {string} [opts.serviceCode] - 产品代码 optional + * @param {array} [opts.subIds] - 拆分项ID列表,最多支持传入500个 optional + * @param {array} [opts.tags] - 标签,JSON格式:[{"k1":"v1"},{"k1":"v2"},{"k2":""}] +示例: +选择的标签为, 部门:广告部、部门:物流部、项目 +则传值为:[{"部门":"广告部"},{"部门":"物流部"},{"项目":""}] + optional + * @param {integer} [opts.pageIndex] - pageIndex 分页,默认从1开始 optional + * @param {integer} [opts.pageSize] - pageSize 每页查询数据条数,最多支持1000条 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param pagination pagination + * @param splitItemBillSummary result + */ + + querySplitItemMonthSummary (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 querySplitItemMonthSummary" + ) + } + + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling querySplitItemMonthSummary" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling querySplitItemMonthSummary" + ) + } + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.appCode !== undefined && opts.appCode !== null) { + postBody['appCode'] = opts.appCode + } + if (opts.serviceCode !== undefined && opts.serviceCode !== null) { + postBody['serviceCode'] = opts.serviceCode + } + if (opts.subIds !== undefined && opts.subIds !== null) { + postBody['subIds'] = opts.subIds + } + if (opts.tags !== undefined && opts.tags !== null) { + postBody['tags'] = opts.tags + } + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + postBody['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 billing/1.1.16' + } + + 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 querySplitItemMonthSummary 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}/splitItemBillMonthSummary:List', + '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.startTime - 账期开始时间,不支持跨月查询。格式:yyyy-MM-dd HH:mm:ss + * @param {string} opts.endTime - 账期结束时间,不支持跨月查询。格式:yyyy-MM-dd HH:mm:ss + * @param {string} [opts.appCode] - 产品线代码 optional + * @param {string} [opts.serviceCode] - 产品代码 optional + * @param {array} [opts.resourceIds] - 资源单id列表,最多支持传入500个 optional + * @param {array} [opts.tags] - 标签,JSON格式:[{"k1":"v1"},{"k1":"v2"},{"k2":""}] +示例: +选择的标签为, 部门:广告部、部门:物流部、项目 +则传值为:[{"部门":"广告部"},{"部门":"物流部"},{"项目":""}] + optional + * @param {integer} [opts.pageIndex] - pageIndex 分页,默认从1开始 optional + * @param {integer} [opts.pageSize] - pageSize 每页查询数据条数,最多支持1000条 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param pagination pagination + * @param billSummary result + */ + + queryBillDaySummary (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 queryBillDaySummary" + ) + } + + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling queryBillDaySummary" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling queryBillDaySummary" + ) + } + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.appCode !== undefined && opts.appCode !== null) { + postBody['appCode'] = opts.appCode + } + if (opts.serviceCode !== undefined && opts.serviceCode !== null) { + postBody['serviceCode'] = opts.serviceCode + } + if (opts.resourceIds !== undefined && opts.resourceIds !== null) { + postBody['resourceIds'] = opts.resourceIds + } + if (opts.tags !== undefined && opts.tags !== null) { + postBody['tags'] = opts.tags + } + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + postBody['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 billing/1.1.16' + } + + 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 queryBillDaySummary 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}/billDaySummary:list', + '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.cmd - 操作类型 1:新购 2:续费 3:变配 + * @param {array} [opts.orderList] - 计算价格的订单 optional + * @param {string} [opts.operateTime] - 操作时间(格式为:yyyy-MM-dd HH:mm:ss) optional + * @param {string} [opts.promotionInfo] - 1:折扣(不需要传) 2:免费活动3:付费活动 4:推荐码 5:会员价 [{"promotionType":1,"activityCode":123},{"promotionType":2,"activityCode":}] optional + * @param {integer} [opts.clientType] - 客户端:1.PC端;2.移动端; optional + * @param {integer} opts.packageCount - 批量购买时数量 + * @param {integer} [opts.processType] - 临时升配时必传,3-临时升配 optional + * @param {integer} [opts.renewMode] - 续费方式 0:正常续费 1:续费至统一到期日,续费时必传 optional + * @param {integer} [opts.unifyExpireDay] - 续费统一到期日(1-28),续费时必传 optional + * @param {integer} [opts.totalPriceRule] - 计算总价规则 1:计算预付费资源总价(计费类型为包年包月、按次) ;不传计算所有资源总价 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param number totalPrice 原价(6位) + * @param number totalPriceScale4 原价(6位,兼容之前4位保留字段) + * @param number discountedTotalPrice 应付金额(2位) + * @param number totalDiscount 折扣金额(6位) + * @param number afterFavorableTotalPrice 折扣后金额(6位) + * @param number eraseTotalPrice 抹零金额(6位) + * @param orderPriceDetail list + * @param number totalOriginalPrice 订单原价 包年时 一年原价为12个月价格,totalPrice为10个月价格(6位) + * @param string favorableInfos 参与优惠的明细 + * @param string remark 备注 + * @param number totalUnitPrice 各订单单价总和(6位) + * @param number refundTotalPrice 退款总金额 + * @param number cashRefundTotalPrice 现金退款总金额 + * @param number balanceRefundTotalPrice 余额退款总金额 + * @param number couponRefundTotalPrice 代金券退款总金额 + */ + + calculateTotalPrice (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 calculateTotalPrice" + ) + } + + opts = opts || {} + + if (opts.cmd === undefined || opts.cmd === null) { + throw new Error( + "Missing the required parameter 'opts.cmd' when calling calculateTotalPrice" + ) + } + if (opts.packageCount === undefined || opts.packageCount === null) { + throw new Error( + "Missing the required parameter 'opts.packageCount' when calling calculateTotalPrice" + ) + } + + let postBody = {} + if (opts.cmd !== undefined && opts.cmd !== null) { + postBody['cmd'] = opts.cmd + } + if (opts.orderList !== undefined && opts.orderList !== null) { + postBody['orderList'] = opts.orderList + } + if (opts.operateTime !== undefined && opts.operateTime !== null) { + postBody['operateTime'] = opts.operateTime + } + if (opts.promotionInfo !== undefined && opts.promotionInfo !== null) { + postBody['promotionInfo'] = opts.promotionInfo + } + if (opts.clientType !== undefined && opts.clientType !== null) { + postBody['clientType'] = opts.clientType + } + if (opts.packageCount !== undefined && opts.packageCount !== null) { + postBody['packageCount'] = opts.packageCount + } + if (opts.processType !== undefined && opts.processType !== null) { + postBody['processType'] = opts.processType + } + if (opts.renewMode !== undefined && opts.renewMode !== null) { + postBody['renewMode'] = opts.renewMode + } + if (opts.unifyExpireDay !== undefined && opts.unifyExpireDay !== null) { + postBody['unifyExpireDay'] = opts.unifyExpireDay + } + if (opts.totalPriceRule !== undefined && opts.totalPriceRule !== null) { + postBody['totalPriceRule'] = opts.totalPriceRule + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 billing/1.1.16' + } + + 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 calculateTotalPrice 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}/calculateTotalPrice', + '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 = BILLING diff --git a/packages/libs/lib-jdcloud/src/repo/bri/v1/bri.js b/packages/libs/lib-jdcloud/src/repo/bri/v1/bri.js new file mode 100644 index 000000000..eb8196f8d --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/bri/v1/bri.js @@ -0,0 +1,490 @@ +/* + * 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. + * + * 页面测试检测接口 + * 京东云信用评分-OpenAPI页面测试检测接口 + * + * 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 = 'bri' +Service._services[serviceId] = true + +/** + * bri service. + * @version 1.1.0 + */ + +class BRI extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'bri.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 获取黑白名单列表 + * @param {Object} opts - parameters + * @param {string} [opts.resourceType] - 数据类型,不传或者为空返回所有类型数据,ip-IP,phone-手机,addr-地址,card-身份,pin-账户,eid-设备 optional + * @param {string} [opts.bwType] - 数据类型,不传或者为空返回所有类型数据,列表类型,black-黑名单,white-白名单 optional + * @param {integer} [opts.size] - 页面大小,缺省为10 optional + * @param {integer} [opts.index] - 起始页,缺省为1 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount 总量 + * @param integer index 分页-页码 + * @param integer size 分页-每页大小 + * @param bwcfg list + */ + + describeBWList (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 describeBWList" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.resourceType !== undefined && opts.resourceType !== null) { + queryParams['resourceType'] = opts.resourceType + } + if (opts.bwType !== undefined && opts.bwType !== null) { + queryParams['bwType'] = opts.bwType + } + if (opts.size !== undefined && opts.size !== null) { + queryParams['size'] = opts.size + } + if (opts.index !== undefined && opts.index !== null) { + queryParams['index'] = opts.index + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 bri/1.1.0' + } + + 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 describeBWList 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}/blackwhite:list', + '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 {bwcfgSet} opts.req - 黑白名单数据 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + setBWList (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 setBWList" + ) + } + + opts = opts || {} + + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling setBWList" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 bri/1.1.0' + } + + 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 setBWList 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}/blackwhite:list', + '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.id - 黑白名单ID, 多个用逗号分隔 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + delBWList (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 delBWList" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling delBWList" + ) + } + + let postBody = null + let queryParams = {} + if (opts.id !== undefined && opts.id !== null) { + queryParams['id'] = opts.id + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 bri/1.1.0' + } + + 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 delBWList 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}/blackwhite:list', + '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 {} [opts.tasks] - 检测任务列表,包含一个或多个元素。每个元素是个结构体,最多可添加100元素,即最多对100个数据进行评分。每个元素的具体结构描述见creditTask。 optional + * @param {string} callback - callback + @return {Object} result + * @param creditResult data + */ + + creditScore (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.tasks !== undefined && opts.tasks !== null) { + postBody['tasks'] = opts.tasks + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 bri/1.1.0' + } + + 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 creditScore 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( + '/creditScore:check', + '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 = BRI diff --git a/packages/libs/lib-jdcloud/src/repo/captcha/v1/captcha.js b/packages/libs/lib-jdcloud/src/repo/captcha/v1/captcha.js new file mode 100644 index 000000000..8ea8af84a --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/captcha/v1/captcha.js @@ -0,0 +1,303 @@ +/* + * 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. + * + * 运营后台类接口 + * 京东云验证码-OpenAPI应用管理类接口 + * + * 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 = 'captcha' +Service._services[serviceId] = true + +/** + * captcha service. + * @version 1.0.1 + */ + +class CAPTCHA extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'captcha.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 获取会话id + * @param {Object} opts - parameters + * @param {} [opts.appId] - 应用id optional + * @param {} [opts.sceneId] - 场景id optional + * @param {} [opts.secret] - 密钥,从界面获取 optional + * @param {} [opts.uuid] - uuid,ios客户端传openudid, android客户端传androidid, m, pc, wxapp客户端此值为空即可 optional + * @param {} [opts.ip] - 客户端ip optional + * @param {} [opts.userAgent] - 客户端userAgent optional + * @param {} [opts.fingerPrint] - 指纹,ios和android客户端(clientType)从sdk获取, m, pc, wxapp客户端此值为空即可 optional + * @param {} [opts.clientType] - 客户端类型, android, ios, pc, wxmapp, m optional + * @param {} [opts.clientVersion] - 客户端版本,用户端app版本,可选 optional + * @param {string} callback - callback + @return {Object} result + * @param sessionDataResp data + */ + + getSessionId (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.sceneId !== undefined && opts.sceneId !== null) { + postBody['sceneId'] = opts.sceneId + } + if (opts.secret !== undefined && opts.secret !== null) { + postBody['secret'] = opts.secret + } + if (opts.uuid !== undefined && opts.uuid !== null) { + postBody['uuid'] = opts.uuid + } + if (opts.ip !== undefined && opts.ip !== null) { + postBody['ip'] = opts.ip + } + if (opts.userAgent !== undefined && opts.userAgent !== null) { + postBody['userAgent'] = opts.userAgent + } + if (opts.fingerPrint !== undefined && opts.fingerPrint !== null) { + postBody['fingerPrint'] = opts.fingerPrint + } + if (opts.clientType !== undefined && opts.clientType !== null) { + postBody['clientType'] = opts.clientType + } + if (opts.clientVersion !== undefined && opts.clientVersion !== null) { + postBody['clientVersion'] = opts.clientVersion + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 captcha/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 getSessionId 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( + '/captcha:getsessionid', + '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) + } + ) + } + + /** + * 验证verifyToken + * @param {Object} opts - parameters + * @param {} [opts.verifyToken] - 提交后台校验的token,客户端sdk获取 optional + * @param {} [opts.sessionId] - 验证码会话id,getsessionid返回 optional + * @param {} [opts.appId] - 应用id optional + * @param {} [opts.sceneId] - 场景id optional + * @param {} [opts.secret] - 密钥,从界面获取 optional + * @param {} [opts.ip] - 客户端ip optional + * @param {} [opts.userAgent] - 客户端userAgent optional + * @param {} [opts.clientType] - 客户端类型, 可选值: android, ios, pc, wxapp, m optional + * @param {} [opts.clientVersion] - 客户端版本,用户端app版本,可选 optional + * @param {string} callback - callback + @return {Object} result + * @param verifyDataResp data + */ + + verifyToken (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.verifyToken !== undefined && opts.verifyToken !== null) { + postBody['verifyToken'] = opts.verifyToken + } + if (opts.sessionId !== undefined && opts.sessionId !== null) { + postBody['sessionId'] = opts.sessionId + } + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.sceneId !== undefined && opts.sceneId !== null) { + postBody['sceneId'] = opts.sceneId + } + if (opts.secret !== undefined && opts.secret !== null) { + postBody['secret'] = opts.secret + } + if (opts.ip !== undefined && opts.ip !== null) { + postBody['ip'] = opts.ip + } + if (opts.userAgent !== undefined && opts.userAgent !== null) { + postBody['userAgent'] = opts.userAgent + } + if (opts.clientType !== undefined && opts.clientType !== null) { + postBody['clientType'] = opts.clientType + } + if (opts.clientVersion !== undefined && opts.clientVersion !== null) { + postBody['clientVersion'] = opts.clientVersion + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 captcha/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 verifyToken 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( + '/captcha:verifytoken', + '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 = CAPTCHA diff --git a/packages/libs/lib-jdcloud/src/repo/cdn/v1/cdn.js b/packages/libs/lib-jdcloud/src/repo/cdn/v1/cdn.js new file mode 100644 index 000000000..2f6480a92 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/cdn/v1/cdn.js @@ -0,0 +1,22614 @@ +/* + * 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. + * + * SCDN相关接口 + * Openapi For JCLOUD cdn + * + * OpenAPI spec version: v1 + * Contact: pid-cdn@jd.com + * + * 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 = 'cdn' +Service._services[serviceId] = true + +/** + * cdn service. + * @version 0.10.47 + */ + +class CDN extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'cdn.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 批量域名查询日志 + * @param {Object} opts - parameters + * @param {} [opts.domains] optional + * @param {} [opts.startTime] - 查询起始时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.endTime] - 查询截止时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.interval] - 时间间隔,取值(hour,day,fiveMin),不传默认小时。 optional + * @param {} [opts.logType] - 日志类型,取值(log,zip,gz),不传默认gz。 optional + * @param {string} callback - callback + @return {Object} result + * @param domainsLog logs + */ + + queryDomainsLog (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.domains !== undefined && opts.domains !== null) { + postBody['domains'] = opts.domains + } + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.interval !== undefined && opts.interval !== null) { + postBody['interval'] = opts.interval + } + if (opts.logType !== undefined && opts.logType !== null) { + postBody['logType'] = opts.logType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryDomainsLog 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( + '/logs', + '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) + } + ) + } + + /** + * 批量域名查询日志-pin维度 + * @param {Object} opts - parameters + * @param {} [opts.pin] - pin optional + * @param {} [opts.startTime] - 查询起始时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.endTime] - 查询截止时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.interval] - 时间间隔,取值(hour,day,fiveMin),不传默认小时。 optional + * @param {} [opts.logType] - 日志类型,取值(log,zip,gz),不传默认gz。 optional + * @param {string} callback - callback + @return {Object} result + * @param domainsLog logs + */ + + queryDomainsLogForJd (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.pin !== undefined && opts.pin !== null) { + postBody['pin'] = opts.pin + } + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.interval !== undefined && opts.interval !== null) { + postBody['interval'] = opts.interval + } + if (opts.logType !== undefined && opts.logType !== null) { + postBody['logType'] = opts.logType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryDomainsLogForJd 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( + '/logsJd', + '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.domain - 用户域名 + * @param {} [opts.startTime] - 查询起始时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.endTime] - 查询截止时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.interval] - 时间间隔,取值(hour,day,fiveMin),不传默认小时。 optional + * @param {} [opts.logType] - 日志类型,取值(log,zip,gz),不传默认gz。 optional + * @param {} [opts.pageSize] - 页面大小,默认值10 optional + * @param {} [opts.pageNumber] - 分页页数,默认值1 optional + * @param {string} callback - callback + @return {Object} result + * @param integer total 总的数量 + * @param integer pageSize 页面大小 + * @param integer pageNumber 页面页数 + * @param domainLog urls + */ + + queryDomainLog (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryDomainLog" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.interval !== undefined && opts.interval !== null) { + queryParams['interval'] = opts.interval + } + if (opts.logType !== undefined && opts.logType !== null) { + queryParams['logType'] = opts.logType + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + queryParams['pageNumber'] = opts.pageNumber + } + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryDomainLog 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( + '/domain/{domain}/log', + '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} callback - callback + @return {Object} result + * @param integer allType 计费方式,取值[0,1],0:日流量计费,1:日峰值带宽计费. + * @param integer vip vip(1:vip客户,0:普通客户) + */ + + queryOnlineBillingType (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryOnlineBillingType 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( + '/onlineBillingType', + '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 {} [opts.allType] - 计费方式,取值[0,1],0:日流量计费,1:日峰值带宽计费. optional + * @param {string} callback - callback + @return {Object} result + */ + + setOnlineBillingType (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.allType !== undefined && opts.allType !== null) { + postBody['allType'] = opts.allType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setOnlineBillingType 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( + '/onlineBillingType', + '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) + } + ) + } + + /** + * dash鉴权设置 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.enableUrlAuth] - 是否开启鉴权[on,off] optional + * @param {} [opts.authKey] - 鉴权key optional + * @param {} [opts.age] - 鉴权时间戳过期时间,默认为0 optional + * @param {} [opts.encAlgorithm] - 鉴权参数加密算法,默认为md5且只支持md5 optional + * @param {} [opts.timeFormat] - 时间戳格式[hex,dec] optional + * @param {} [opts.uriType] - 加密算法版本[dash,dashv2,video],默认dashv2 optional + * @param {} [opts.rule] - 鉴权key生成顺序 optional + * @param {string} callback - callback + @return {Object} result + * @param string taskId 任务的id + */ + + setAuthConfig (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setAuthConfig" + ) + } + + let postBody = {} + if (opts.enableUrlAuth !== undefined && opts.enableUrlAuth !== null) { + postBody['enableUrlAuth'] = opts.enableUrlAuth + } + if (opts.authKey !== undefined && opts.authKey !== null) { + postBody['authKey'] = opts.authKey + } + if (opts.age !== undefined && opts.age !== null) { + postBody['age'] = opts.age + } + if (opts.encAlgorithm !== undefined && opts.encAlgorithm !== null) { + postBody['encAlgorithm'] = opts.encAlgorithm + } + if (opts.timeFormat !== undefined && opts.timeFormat !== null) { + postBody['timeFormat'] = opts.timeFormat + } + if (opts.uriType !== undefined && opts.uriType !== null) { + postBody['uriType'] = opts.uriType + } + if (opts.rule !== undefined && opts.rule !== null) { + postBody['rule'] = opts.rule + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setAuthConfig 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( + '/domain/{domain}/setAuthConfig', + '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.domain - 用户域名 + * @param {} [opts.enable] - 是否开启鉴权[on,off] optional + * @param {} [opts.originRole] - 回源为主/备[master,slave] optional + * @param {} [opts.authType] - 鉴权类型[oss,aws,tos],aws暂不支持 optional + * @param {} [opts.tosAuthInfo] - tos类型鉴权参数,authType为tos是不能为空 optional + * @param {} [opts.ossAuthInfo] - oss类型鉴权参数,authType为oss是不能为空 optional + * @param {string} callback - callback + @return {Object} result + * @param string taskId 任务的id + */ + + setSourceAuthConfig (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setSourceAuthConfig" + ) + } + + let postBody = {} + if (opts.enable !== undefined && opts.enable !== null) { + postBody['enable'] = opts.enable + } + if (opts.originRole !== undefined && opts.originRole !== null) { + postBody['originRole'] = opts.originRole + } + if (opts.authType !== undefined && opts.authType !== null) { + postBody['authType'] = opts.authType + } + if (opts.tosAuthInfo !== undefined && opts.tosAuthInfo !== null) { + postBody['tosAuthInfo'] = opts.tosAuthInfo + } + if (opts.ossAuthInfo !== undefined && opts.ossAuthInfo !== null) { + postBody['ossAuthInfo'] = opts.ossAuthInfo + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setSourceAuthConfig 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( + '/domain/{domain}/setSourceAuthConfig', + '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 {} [opts.startTime] - 查询起始时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.endTime] - 查询截止时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.domain] - 需要查询的域名, 必须为用户pin下有权限的域名 optional + * @param {} [opts.area] - 地域 optional + * @param {} [opts.isp] - 运营商 optional + * @param {} [opts.period] - 查询周期 optional + * @param {string} callback - callback + @return {Object} result + * @param bandTrafficDataItem resultList + */ + + queryBand (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.domain !== undefined && opts.domain !== null) { + postBody['domain'] = opts.domain + } + if (opts.area !== undefined && opts.area !== null) { + postBody['area'] = opts.area + } + if (opts.isp !== undefined && opts.isp !== null) { + postBody['isp'] = opts.isp + } + if (opts.period !== undefined && opts.period !== null) { + postBody['period'] = opts.period + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryBand 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( + '/bandQuery', + '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 {} [opts.startTime] - 查询起始时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.endTime] - 查询截止时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.domain] - 需要查询的域名, 必须为用户pin下有权限的域名 optional + * @param {} [opts.area] - 地域 optional + * @param {} [opts.isp] - 运营商 optional + * @param {} [opts.period] - 查询周期 optional + * @param {string} callback - callback + @return {Object} result + * @param bandTrafficWithAreaDataItem resultList + */ + + queryBandWithArea (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.domain !== undefined && opts.domain !== null) { + postBody['domain'] = opts.domain + } + if (opts.area !== undefined && opts.area !== null) { + postBody['area'] = opts.area + } + if (opts.isp !== undefined && opts.isp !== null) { + postBody['isp'] = opts.isp + } + if (opts.period !== undefined && opts.period !== null) { + postBody['period'] = opts.period + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryBandWithArea 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( + '/bandQuery:areaIsp', + '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.taskId - 任务ID + * @param {string} callback - callback + @return {Object} result + * @param string taskStatus 任务状态,[success:成功,failed:失败,configuring:配置中] + */ + + queryDomainConfigStatus (opts, callback) { + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling queryDomainConfigStatus" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryDomainConfigStatus 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( + '/domain/{taskId}/status', + '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} callback - callback + @return {Object} result + * @param areaIspItem mainLand + * @param areaIspItem overseas + * @param areaIspItem isp + * @param areaIspItem gangaotai + * @param areaIspItem oceanica + * @param areaIspItem southAmerica + * @param areaIspItem northAmerica + * @param areaIspItem asia + * @param areaIspItem europe + */ + + queryAreaIspList (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryAreaIspList 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( + '/console:areaIspList', + '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} callback - callback + @return {Object} result + * @param areaIspItem mainLand + * @param areaIspItem overseas + * @param areaIspItem isp + * @param areaIspItem africa + * @param areaIspItem oceania + * @param areaIspItem southAmerica + * @param areaIspItem northAmerica + * @param areaIspItem asia + * @param areaIspItem europe + * @param areaIspItem midEast + */ + + queryAreaIspListV2 (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryAreaIspListV2 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( + '/console:areaIspListV2', + '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 {} [opts.queryDomain] - 封禁域名,模糊查询 optional + * @param {} [opts.forbiddenUrl] - 封禁url,精确查询 optional + * @param {} [opts.pageNumber] - 页码数 optional + * @param {} [opts.pageSize] - 每页size optional + * @param {string} callback - callback + @return {Object} result + * @param integer total 总的数量 + * @param forbiddenInfo list + */ + + queryForbiddenInfoList (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.queryDomain !== undefined && opts.queryDomain !== null) { + postBody['queryDomain'] = opts.queryDomain + } + if (opts.forbiddenUrl !== undefined && opts.forbiddenUrl !== null) { + postBody['forbiddenUrl'] = opts.forbiddenUrl + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryForbiddenInfoList 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( + '/forbiddenInfo:query', + '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 {} [opts.forbiddenType] - 封禁类型,domain 域名封禁,url url封禁 optional + * @param {} [opts.forbiddenDomain] - 封禁域名 optional + * @param {} [opts.forbiddenUrl] - 封禁url,多个以;隔开 optional + * @param {} [opts.reason] - 封禁原因 optional + * @param {} [opts.linkOther] - y,n y表示是,n表示否 optional + * @param {} [opts.shareCacheDomainFlag] - 是否同步操作共享缓存域名,0:仅操作本域名,1:同步操作共享缓存域名,默认为0 optional + * @param {} [opts.token] - 用于封禁前缀识别的URL,应为单个特殊字符,如:~ optional + * @param {string} callback - callback + @return {Object} result + */ + + createForbiddenInfo (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.forbiddenType !== undefined && opts.forbiddenType !== null) { + postBody['forbiddenType'] = opts.forbiddenType + } + if (opts.forbiddenDomain !== undefined && opts.forbiddenDomain !== null) { + postBody['forbiddenDomain'] = opts.forbiddenDomain + } + if (opts.forbiddenUrl !== undefined && opts.forbiddenUrl !== null) { + postBody['forbiddenUrl'] = opts.forbiddenUrl + } + if (opts.reason !== undefined && opts.reason !== null) { + postBody['reason'] = opts.reason + } + if (opts.linkOther !== undefined && opts.linkOther !== null) { + postBody['linkOther'] = opts.linkOther + } + if ( + opts.shareCacheDomainFlag !== undefined && + opts.shareCacheDomainFlag !== null + ) { + postBody['shareCacheDomainFlag'] = opts.shareCacheDomainFlag + } + if (opts.token !== undefined && opts.token !== null) { + postBody['token'] = opts.token + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 createForbiddenInfo 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( + '/forbiddenInfo:create', + '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 {} [opts.forbiddenType] - 封禁类型,domain 域名封禁,url url封禁 optional + * @param {} [opts.forbiddenDomain] - 封禁域名 optional + * @param {} [opts.forbiddenUrl] - 封禁url,多个以;隔开 optional + * @param {} [opts.shareCacheDomainFlag] - 是否同步操作共享缓存域名,0:仅操作本域名,1:同步操作共享缓存域名,默认为0 optional + * @param {} [opts.token] - 用于封禁前缀识别的URL,应为单个特殊字符,如:~ optional + * @param {string} callback - callback + @return {Object} result + * @param string taskId + */ + + deleteForbiddenInfo (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.forbiddenType !== undefined && opts.forbiddenType !== null) { + postBody['forbiddenType'] = opts.forbiddenType + } + if (opts.forbiddenDomain !== undefined && opts.forbiddenDomain !== null) { + postBody['forbiddenDomain'] = opts.forbiddenDomain + } + if (opts.forbiddenUrl !== undefined && opts.forbiddenUrl !== null) { + postBody['forbiddenUrl'] = opts.forbiddenUrl + } + if ( + opts.shareCacheDomainFlag !== undefined && + opts.shareCacheDomainFlag !== null + ) { + postBody['shareCacheDomainFlag'] = opts.shareCacheDomainFlag + } + if (opts.token !== undefined && opts.token !== null) { + postBody['token'] = opts.token + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 deleteForbiddenInfo 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( + '/forbiddenInfo:delete', + '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.domain] - 根据域名进行匹配 optional + * @param {string} [opts.url] - 根据url进行匹配 optional + * @param {string} [opts.taskId] - 解封的任务id optional + * @param {integer} [opts.pageNumber] - pageNumber,默认值1 optional + * @param {integer} [opts.pageSize] - pageSize,最大值50,默认值10 optional + * @param {string} callback - callback + @return {Object} result + * @param integer total 总的数量 + * @param unForbiddenTaskItem tasks + */ + + queryUnForbiddenStatus (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.domain !== undefined && opts.domain !== null) { + queryParams['domain'] = opts.domain + } + if (opts.url !== undefined && opts.url !== null) { + queryParams['url'] = opts.url + } + if (opts.taskId !== undefined && opts.taskId !== null) { + queryParams['taskId'] = opts.taskId + } + 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: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryUnForbiddenStatus 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( + '/unForbiddenStatus', + '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 {} [opts.queryDomain] - 封禁域名.queryDomain和taskId至少传入一个 optional + * @param {} [opts.taskId] - 任务id.queryDomain和taskId至少传入一个 optional + * @param {} [opts.forbiddenUrl] - 封禁url,精确查询 optional + * @param {} [opts.pageNumber] - 页码数 optional + * @param {} [opts.pageSize] - 每页size optional + * @param {string} callback - callback + @return {Object} result + * @param integer total 总的数量 + * @param forbiddenInfoCommon list + */ + + queryForbiddenInfoListCommon (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.queryDomain !== undefined && opts.queryDomain !== null) { + postBody['queryDomain'] = opts.queryDomain + } + if (opts.taskId !== undefined && opts.taskId !== null) { + postBody['taskId'] = opts.taskId + } + if (opts.forbiddenUrl !== undefined && opts.forbiddenUrl !== null) { + postBody['forbiddenUrl'] = opts.forbiddenUrl + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryForbiddenInfoListCommon 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( + '/forbiddenInfoCommon:query', + '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 {} [opts.forbiddenType] - 封禁类型,domain:域名封禁,url:url封禁 optional + * @param {} [opts.forbiddenDomain] - 封禁域名 optional + * @param {} [opts.forbiddenUrl] - 封禁url,多个以;隔开。单url最大字符长度1024,以/开头,内容中不包含逗号.forbiddenType为url时需传入 optional + * @param {} [opts.reason] - 封禁原因 optional + * @param {} [opts.linkOther] - y,n y表示是,n表示否,默认n。forbiddenType为domain时可传入,若为y表示封禁该域名后,不允许添加该域名的根域名以及根域名下的所有子域名 optional + * @param {} [opts.shareCacheDomainFlag] - forbiddenType为url时可传入。即当forbiddenDomain为域名组共享缓存主域名时,是否同步操作共享缓存从域名下的url,0:仅操作本域名,1:同步操作共享缓存域名,默认为0。 optional + * @param {} [opts.token] - forbiddenType为url时有效。用于封禁前缀识别的URL,应为单个特殊字符,如:~ optional + * @param {string} callback - callback + @return {Object} result + * @param string taskId + */ + + createForbiddenInfoCommon (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.forbiddenType !== undefined && opts.forbiddenType !== null) { + postBody['forbiddenType'] = opts.forbiddenType + } + if (opts.forbiddenDomain !== undefined && opts.forbiddenDomain !== null) { + postBody['forbiddenDomain'] = opts.forbiddenDomain + } + if (opts.forbiddenUrl !== undefined && opts.forbiddenUrl !== null) { + postBody['forbiddenUrl'] = opts.forbiddenUrl + } + if (opts.reason !== undefined && opts.reason !== null) { + postBody['reason'] = opts.reason + } + if (opts.linkOther !== undefined && opts.linkOther !== null) { + postBody['linkOther'] = opts.linkOther + } + if ( + opts.shareCacheDomainFlag !== undefined && + opts.shareCacheDomainFlag !== null + ) { + postBody['shareCacheDomainFlag'] = opts.shareCacheDomainFlag + } + if (opts.token !== undefined && opts.token !== null) { + postBody['token'] = opts.token + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 createForbiddenInfoCommon 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( + '/forbiddenInfoCommon:create', + '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 {} [opts.forbiddenType] - 封禁类型,domain:域名封禁,url:url封禁 optional + * @param {} [opts.forbiddenDomain] - 封禁域名 optional + * @param {} [opts.forbiddenUrl] - 封禁url,多个以;隔开。单url最大字符长度1024,以/开头,内容中不包含逗号.forbiddenType为url时需传入 optional + * @param {} [opts.shareCacheDomainFlag] - forbiddenType为url时有效。即当forbiddenDomain为域名组共享缓存主域名时,是否同步操作共享缓存从域名下的url,0:仅操作本域名,1:同步操作共享缓存域名,默认为0。 optional + * @param {} [opts.token] - forbiddenType为url时有效。用于封禁前缀识别的URL,应为单个特殊字符,如:~ optional + * @param {string} callback - callback + @return {Object} result + * @param string taskId + */ + + deleteForbiddenInfoCommon (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.forbiddenType !== undefined && opts.forbiddenType !== null) { + postBody['forbiddenType'] = opts.forbiddenType + } + if (opts.forbiddenDomain !== undefined && opts.forbiddenDomain !== null) { + postBody['forbiddenDomain'] = opts.forbiddenDomain + } + if (opts.forbiddenUrl !== undefined && opts.forbiddenUrl !== null) { + postBody['forbiddenUrl'] = opts.forbiddenUrl + } + if ( + opts.shareCacheDomainFlag !== undefined && + opts.shareCacheDomainFlag !== null + ) { + postBody['shareCacheDomainFlag'] = opts.shareCacheDomainFlag + } + if (opts.token !== undefined && opts.token !== null) { + postBody['token'] = opts.token + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 deleteForbiddenInfoCommon 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( + '/forbiddenInfoCommon:delete', + '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.domain - 用户域名 + * @param {} [opts.content] optional + * @param {string} callback - callback + @return {Object} result + * @param string sigAlgName + * @param string issuer + * @param string startDate + * @param string endDate + * @param string user + * @param string sigHashAlgName + */ + + previewCertificate (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling previewCertificate" + ) + } + + let postBody = {} + if (opts.content !== undefined && opts.content !== null) { + postBody['content'] = opts.content + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 previewCertificate 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( + '/domain/{domain}/certificate', + '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) + } + ) + } + + /** + * 查询默认http header头部参数列表 + * @param {Object} opts - parameters + * @param {string} callback - callback + @return {Object} result + * @param string reqDefaultHttpHeaderKey + * @param string respDefaultHttpHeaderKey + */ + + queryDefaultHttpHeaderKey (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryDefaultHttpHeaderKey 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( + '/defaultHttpHeaderKey', + '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黑白名单 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + * @param string domain 域名 + * @param string ips + * @param string status 黑名单状态,on:开启,off:关闭 + * @param string whiteIps + */ + + queryIpBlackList (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryIpBlackList" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryIpBlackList 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( + '/domain/{domain}/ipBlackList', + '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黑名白单 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.ips] - ip名单,ips中url不能超过50条,中国境外/全球加速域名暂不支持传IP段 optional + * @param {} [opts.ipListType] - ip黑白名单类型,black:黑名单,white:白名单 optional + * @param {string} callback - callback + @return {Object} result + */ + + setIpBlackList (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setIpBlackList" + ) + } + + let postBody = {} + if (opts.ips !== undefined && opts.ips !== null) { + postBody['ips'] = opts.ips + } + if (opts.ipListType !== undefined && opts.ipListType !== null) { + postBody['ipListType'] = opts.ipListType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setIpBlackList 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( + '/domain/{domain}/ipBlackList', + '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) + } + ) + } + + /** + * 设置ip黑名单状态 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.status] - ip黑名单状态取值[on,off] optional + * @param {string} callback - callback + @return {Object} result + */ + + operateIpBlackList (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling operateIpBlackList" + ) + } + + let postBody = {} + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 operateIpBlackList 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( + '/domain/{domain}/ipBlackList:operate', + '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) + } + ) + } + + /** + * 查询自定义错误页面信息 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + * @param string domain 域名 + * @param string enable 自定义错误页面开关(on:开启 off:关闭) + * @param errorPageConfigs customErrorPageInfos + */ + + queryCustomErrorPage (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryCustomErrorPage" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryCustomErrorPage 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( + '/domain/{domain}/customErrorPage', + '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.domain - 用户域名 + * @param {} [opts.errorPageConfigs] - 自定义错误页面配置 optional + * @param {string} callback - callback + @return {Object} result + */ + + setCustomErrorPage (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setCustomErrorPage" + ) + } + + let postBody = {} + if (opts.errorPageConfigs !== undefined && opts.errorPageConfigs !== null) { + postBody['errorPageConfigs'] = opts.errorPageConfigs + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setCustomErrorPage 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( + '/domain/{domain}/customErrorPage', + '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.domain - 用户域名 + * @param {} [opts.weight] - 此条配置的权重值, 取值范围为1-10,1最大 optional + * @param {} [opts.ttl] - 缓存时间,单位秒,中国境内加速域名最长可配置2年,中国境外/全球加速域名最长可配置1年 optional + * @param {} [opts.contents] - 规则内容。其他类型只能以/或者.开头,如/a/b或.jpg optional + * @param {} [opts.cacheType] - 缓存方式:0、不缓存,1自定义 optional + * @param {string} callback - callback + @return {Object} result + * @param integer configId 缓存规则配置ID + */ + + createCacheRule (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling createCacheRule" + ) + } + + let postBody = {} + if (opts.weight !== undefined && opts.weight !== null) { + postBody['weight'] = opts.weight + } + if (opts.ttl !== undefined && opts.ttl !== null) { + postBody['ttl'] = opts.ttl + } + if (opts.contents !== undefined && opts.contents !== null) { + postBody['contents'] = opts.contents + } + if (opts.cacheType !== undefined && opts.cacheType !== null) { + postBody['cacheType'] = opts.cacheType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 createCacheRule 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( + '/domain/{domain}/cacheRule', + '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.domain - 用户域名 + * @param {} [opts.weight] - 此条配置的权重值, 取值范围为1-10,1最大 optional + * @param {} [opts.ttl] - 缓存时间,单位秒,中国境内加速域名最长可配置2年,中国境外/全球加速域名最长可配置1年 optional + * @param {} [opts.contents] - 规则内容。其他类型只能以/或者.开头,如/a/b或.jpg optional + * @param {} [opts.cacheType] - 缓存方式:0、不缓存,1自定义 optional + * @param {} [opts.configId] - 缓存规则配置ID optional + * @param {string} callback - callback + @return {Object} result + */ + + updateCacheRule (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling updateCacheRule" + ) + } + + let postBody = {} + if (opts.weight !== undefined && opts.weight !== null) { + postBody['weight'] = opts.weight + } + if (opts.ttl !== undefined && opts.ttl !== null) { + postBody['ttl'] = opts.ttl + } + if (opts.contents !== undefined && opts.contents !== null) { + postBody['contents'] = opts.contents + } + if (opts.cacheType !== undefined && opts.cacheType !== null) { + postBody['cacheType'] = opts.cacheType + } + if (opts.configId !== undefined && opts.configId !== null) { + postBody['configId'] = opts.configId + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 updateCacheRule 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( + '/domain/{domain}/cacheRule', + '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) + } + ) + } + + /** + * 删除缓存规则 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.configId] - 缓存规则配置ID optional + * @param {string} callback - callback + @return {Object} result + */ + + deleteCacheRule (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling deleteCacheRule" + ) + } + + let postBody = null + let queryParams = {} + if (opts.configId !== undefined && opts.configId !== null) { + queryParams['configId'] = opts.configId + } + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 deleteCacheRule 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( + '/domain/{domain}/cacheRule', + '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.domain - 用户域名 + * @param {} [opts.cacheRules] optional + * @param {string} callback - callback + @return {Object} result + * @param cacheVo data + */ + + setCacheRules (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setCacheRules" + ) + } + + let postBody = {} + if (opts.cacheRules !== undefined && opts.cacheRules !== null) { + postBody['cacheRules'] = opts.cacheRules + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setCacheRules 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( + '/domain/{domain}/cacheRules', + '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) + } + ) + } + + /** + * 查询http header头 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.edgeType] - header生效节点,0边缘,1回源,2两者都 optional + * @param {string} callback - callback + @return {Object} result + * @param string domain + * @param queryHttpHeaderResp headers + */ + + queryHttpHeader (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryHttpHeader" + ) + } + + let postBody = null + let queryParams = {} + if (opts.edgeType !== undefined && opts.edgeType !== null) { + queryParams['edgeType'] = opts.edgeType + } + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryHttpHeader 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( + '/domain/{domain}/httpHeader', + '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) + } + ) + } + + /** + * 添加httpHeader + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.edgeType] - 0表示header在边缘生效,1表示header回源生效,2表示在边缘和回源都生效,该字段不传时默认header在边缘和回源都生效 optional + * @param {} [opts.headerType] - header类型[resp,req],resp:配置响应头,req:配置请求头 optional + * @param {} [opts.headerName] - header名,例如:Content-Disposition,可自定义,长度不能超过256个字符,不能包含中文字符,不能包含$和_,不支持设置如下头名:["Content-Length","Date","Host","Content-Encoding","If-Modified-Since","If-Range","Content-Type","Transfer-Encoding","Cache-Control","Last-Modified","Connection", "Content-Range","ETag","Age","Authentication-Info","Proxy-Authenticate","Retry-After","Set-Cookie","Vary","Content-Location","Meter","Allow","Error","X-Trace", "Proxy-Connection"] optional + * @param {} [opts.headerValue] - header值,不能包含($,_,#),不能超过256个字符 optional + * @param {string} callback - callback + @return {Object} result + */ + + setHttpHeader (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setHttpHeader" + ) + } + + let postBody = {} + if (opts.edgeType !== undefined && opts.edgeType !== null) { + postBody['edgeType'] = opts.edgeType + } + if (opts.headerType !== undefined && opts.headerType !== null) { + postBody['headerType'] = opts.headerType + } + if (opts.headerName !== undefined && opts.headerName !== null) { + postBody['headerName'] = opts.headerName + } + if (opts.headerValue !== undefined && opts.headerValue !== null) { + postBody['headerValue'] = opts.headerValue + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setHttpHeader 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( + '/domain/{domain}/httpHeader', + '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) + } + ) + } + + /** + * 删除httpHeader + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.edgeType] - 0表示header在边缘生效,1表示header回源生效,2表示在边缘和回源都生效,该字段不传时默认header在边缘和回源都生效 optional + * @param {} [opts.headerType] - header类型[resp,req] optional + * @param {} [opts.headerName] - header名 optional + * @param {string} callback - callback + @return {Object} result + */ + + deleteHttpHeader (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling deleteHttpHeader" + ) + } + + let postBody = {} + if (opts.edgeType !== undefined && opts.edgeType !== null) { + postBody['edgeType'] = opts.edgeType + } + if (opts.headerType !== undefined && opts.headerType !== null) { + postBody['headerType'] = opts.headerType + } + if (opts.headerName !== undefined && opts.headerName !== null) { + postBody['headerName'] = opts.headerName + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 deleteHttpHeader 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( + '/domain/{domain}/httpHeader', + '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) + } + ) + } + + /** + * 设置视频拖拽 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.status] - 开关取值[on,off] optional + * @param {string} callback - callback + @return {Object} result + */ + + setVideoDraft (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setVideoDraft" + ) + } + + let postBody = {} + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setVideoDraft 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( + '/domain/{domain}/videoDraft', + '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) + } + ) + } + + /** + * 设置range参数 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.status] - 开关取值[on,off] optional + * @param {string} callback - callback + @return {Object} result + */ + + setRange (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setRange" + ) + } + + let postBody = {} + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setRange 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( + '/domain/{domain}/range', + '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.domain - 用户域名 + * @param {} [opts.status] - 开关取值[on,off] optional + * @param {string} callback - callback + @return {Object} result + */ + + setIgnoreQueryString (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setIgnoreQueryString" + ) + } + + let postBody = {} + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setIgnoreQueryString 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( + '/domain/{domain}/ignoreQueryString', + '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.domain - 用户域名 + * @param {} [opts.retainArgs] - 保留参数,多个用;隔开 optional + * @param {} [opts.status] - 忽略参数开关,取值:on or off optional + * @param {string} callback - callback + @return {Object} result + */ + + setFilterArgs (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setFilterArgs" + ) + } + + let postBody = {} + if (opts.retainArgs !== undefined && opts.retainArgs !== null) { + postBody['retainArgs'] = opts.retainArgs + } + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setFilterArgs 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( + '/domain/{domain}/filterArgs:set', + '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.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + * @param string domain 域名 + * @param string retainArgs + * @param string ignoreQueryString 忽略参数开关 + */ + + queryFilterArgs (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryFilterArgs" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryFilterArgs 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( + '/domain/{domain}/filterArgs:query', + '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) + } + ) + } + + /** + * 设置userAgent信息 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + * @param string domain + * @param string userAgentType userAgent类型,取值:block(黑名单),allow(白名单),默认为block + * @param string userAgentList + * @param string allowNoUserAgentHeader 是否允许空userAgent访问,默认为“on” + */ + + queryUserAgent (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryUserAgent" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryUserAgent 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( + '/domain/{domain}/userAgentConfig', + '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) + } + ) + } + + /** + * 设置userAgent信息 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.userAgentType] - userAgent类型,取值:block(黑名单),allow(白名单),默认为block optional + * @param {} [opts.userAgentList] - UA列表,如果userAgentList为空,则为全部删除 optional + * @param {string} callback - callback + @return {Object} result + */ + + setUserAgentConfig (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setUserAgentConfig" + ) + } + + let postBody = {} + if (opts.userAgentType !== undefined && opts.userAgentType !== null) { + postBody['userAgentType'] = opts.userAgentType + } + if (opts.userAgentList !== undefined && opts.userAgentList !== null) { + postBody['userAgentList'] = opts.userAgentList + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setUserAgentConfig 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( + '/domain/{domain}/userAgentConfig', + '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) + } + ) + } + + /** + * 查询url鉴权 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + * @param integer accesskeyType 鉴权类型,0表示无鉴权,1表示参数鉴权,2表示路径鉴权 + * @param string accesskeyKey 密码,长度为8到32 + * @param integer accesskeyKeep 是否是回源鉴权 0表示是 1表示否 + */ + + queryAccesskeyConfig (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryAccesskeyConfig" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryAccesskeyConfig 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( + '/domain/{domain}/accesskeyConfig', + '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) + } + ) + } + + /** + * 设置url鉴权 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.accesskeyType] - 鉴权类型,0表示无鉴权,1表示参数鉴权,2表示路径鉴权 optional + * @param {} [opts.accesskeyKey] - 密码,长度为8到32 optional + * @param {} [opts.accesskeyKeep] - 是否是回源鉴权 0表示是 1表示否 optional + * @param {string} callback - callback + @return {Object} result + */ + + setAccesskeyConfig (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setAccesskeyConfig" + ) + } + + let postBody = {} + if (opts.accesskeyType !== undefined && opts.accesskeyType !== null) { + postBody['accesskeyType'] = opts.accesskeyType + } + if (opts.accesskeyKey !== undefined && opts.accesskeyKey !== null) { + postBody['accesskeyKey'] = opts.accesskeyKey + } + if (opts.accesskeyKeep !== undefined && opts.accesskeyKeep !== null) { + postBody['accesskeyKeep'] = opts.accesskeyKeep + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setAccesskeyConfig 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( + '/domain/{domain}/accesskeyConfig', + '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) + } + ) + } + + /** + * 设置域名refer + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.referType] - refer类型,取值:block(黑名单),allow(白名单)默认为block optional + * @param {} [opts.referList] - 逗号隔开的域名列表,如果referList传空则为删除,中国境内加速域名至多可配置400条,中国境外/全球加速域名至多可配置50条 optional + * @param {} [opts.allowNoReferHeader] - 是否允许空refer访问,默认为“on” optional + * @param {} [opts.allowNullReferHeader] - 是否允许无ua访问,默认为“on” optional + * @param {string} callback - callback + @return {Object} result + */ + + setRefer (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setRefer" + ) + } + + let postBody = {} + if (opts.referType !== undefined && opts.referType !== null) { + postBody['referType'] = opts.referType + } + if (opts.referList !== undefined && opts.referList !== null) { + postBody['referList'] = opts.referList + } + if ( + opts.allowNoReferHeader !== undefined && + opts.allowNoReferHeader !== null + ) { + postBody['allowNoReferHeader'] = opts.allowNoReferHeader + } + if ( + opts.allowNullReferHeader !== undefined && + opts.allowNullReferHeader !== null + ) { + postBody['allowNullReferHeader'] = opts.allowNullReferHeader + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setRefer 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( + '/domain/{domain}/refer', + '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.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + * @param string domain 域名 + * @param integer cycle 探测周期,单位分钟 + * @param string monitorPath 探测路径 + * @param object httpRequestHeader 查询结果,类型为HashMap<String, Object> + */ + + queryMonitor (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryMonitor" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryMonitor 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( + '/domain/{domain}/monitor', + '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.domain - 用户域名 + * @param {} [opts.cycle] - 探测周期,取值1和5,单位为分钟 optional + * @param {} [opts.monitorPath] - 探测路径 optional + * @param {} [opts.httpRequestHeader] - http请求头 optional + * @param {string} callback - callback + @return {Object} result + * @param integer monitorId + */ + + setMonitor (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setMonitor" + ) + } + + let postBody = {} + if (opts.cycle !== undefined && opts.cycle !== null) { + postBody['cycle'] = opts.cycle + } + if (opts.monitorPath !== undefined && opts.monitorPath !== null) { + postBody['monitorPath'] = opts.monitorPath + } + if ( + opts.httpRequestHeader !== undefined && + opts.httpRequestHeader !== null + ) { + postBody['httpRequestHeader'] = opts.httpRequestHeader + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setMonitor 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( + '/domain/{domain}/monitor', + '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.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + */ + + stopMonitor (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling stopMonitor" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 stopMonitor 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( + '/domain/{domain}/monitor:stop', + '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.domain - 用户域名 + * @param {} [opts.sourceType] - 回源类型只能是[ips,domain,oss]中的一种 optional + * @param {} [opts.backSourceType] - 回源方式,只能是[https,http]中的一种,默认http optional + * @param {} [opts.accelerateRegion] - 加速区域,必须是[mainland,nonMainland,all]中的一种,分别代表大陆,海外+中国港澳台,全球 optional + * @param {} [opts.ipSource] optional + * @param {} [opts.domainSource] optional + * @param {} [opts.ossSource] - oss回源域名 optional + * @param {} [opts.defaultSourceHost] - 默认回源host optional + * @param {string} callback - callback + @return {Object} result + * @param string taskId 任务id + */ + + setSource (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setSource" + ) + } + + let postBody = {} + if (opts.sourceType !== undefined && opts.sourceType !== null) { + postBody['sourceType'] = opts.sourceType + } + if (opts.backSourceType !== undefined && opts.backSourceType !== null) { + postBody['backSourceType'] = opts.backSourceType + } + if (opts.accelerateRegion !== undefined && opts.accelerateRegion !== null) { + postBody['accelerateRegion'] = opts.accelerateRegion + } + if (opts.ipSource !== undefined && opts.ipSource !== null) { + postBody['ipSource'] = opts.ipSource + } + if (opts.domainSource !== undefined && opts.domainSource !== null) { + postBody['domainSource'] = opts.domainSource + } + if (opts.ossSource !== undefined && opts.ossSource !== null) { + postBody['ossSource'] = opts.ossSource + } + if ( + opts.defaultSourceHost !== undefined && + opts.defaultSourceHost !== null + ) { + postBody['defaultSourceHost'] = opts.defaultSourceHost + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setSource 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( + '/domain/{domain}/source', + '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.domain - 用户域名 + * @param {} [opts.status] - 共享缓存只能是off或者on optional + * @param {string} callback - callback + @return {Object} result + */ + + operateShareCache (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling operateShareCache" + ) + } + + let postBody = {} + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 operateShareCache 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( + '/domain/{domain}/shareCache', + '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) + } + ) + } + + /** + * 设置http协议 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.httpType] - http类型,只能为http或者https,默认为http.当设为https时,需要调用“设置通讯协议”接口上传证书和私钥 optional + * @param {} [opts.certificate] - 用户证书,当Type为https时必须设置 optional + * @param {} [opts.rsaKey] - 证书私钥 optional + * @param {} [opts.jumpType] - 有三种类型:default、http、https optional + * @param {} [opts.certFrom] - 证书来源有两种类型:default,ssl optional + * @param {} [opts.sslCertId] - ssl证书id optional + * @param {} [opts.syncToSsl] - 是否同步到ssl,boolean值,取值true或者false optional + * @param {} [opts.certName] - syncToSsl是true时,certName是必填项 optional + * @param {string} callback - callback + @return {Object} result + * @param string taskId 任务taskId + */ + + setHttpType (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setHttpType" + ) + } + + let postBody = {} + if (opts.httpType !== undefined && opts.httpType !== null) { + postBody['httpType'] = opts.httpType + } + if (opts.certificate !== undefined && opts.certificate !== null) { + postBody['certificate'] = opts.certificate + } + if (opts.rsaKey !== undefined && opts.rsaKey !== null) { + postBody['rsaKey'] = opts.rsaKey + } + if (opts.jumpType !== undefined && opts.jumpType !== null) { + postBody['jumpType'] = opts.jumpType + } + if (opts.certFrom !== undefined && opts.certFrom !== null) { + postBody['certFrom'] = opts.certFrom + } + if (opts.sslCertId !== undefined && opts.sslCertId !== null) { + postBody['sslCertId'] = opts.sslCertId + } + if (opts.syncToSsl !== undefined && opts.syncToSsl !== null) { + postBody['syncToSsl'] = opts.syncToSsl + } + if (opts.certName !== undefined && opts.certName !== null) { + postBody['certName'] = opts.certName + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setHttpType 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( + '/domain/{domain}/httpType', + '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) + } + ) + } + + /** + * 查询回源302跳转信息 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + * @param string domain + * @param string followRedirect + */ + + queryFollowRedirect (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryFollowRedirect" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryFollowRedirect 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( + '/domain/{domain}/followRedirect', + '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) + } + ) + } + + /** + * 设置回源302跳转 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.status] - 开关取值[on,off] optional + * @param {string} callback - callback + @return {Object} result + */ + + setFollowRedirect (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setFollowRedirect" + ) + } + + let postBody = {} + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setFollowRedirect 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( + '/domain/{domain}/followRedirect', + '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.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + * @param string domain + * @param string followProtocolStatus + */ + + queryFollowSourceProtocol (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryFollowSourceProtocol" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryFollowSourceProtocol 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( + '/domain/{domain}/followSourceProtocol', + '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.domain - 用户域名 + * @param {} [opts.status] - 开关取值[on,off] optional + * @param {string} callback - callback + @return {Object} result + * @param string taskId 任务id + */ + + setFollowSourceProtocol (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setFollowSourceProtocol" + ) + } + + let postBody = {} + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setFollowSourceProtocol 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( + '/domain/{domain}/followSourceProtocol', + '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.domain - 用户域名 + * @param {} [opts.httpType] - http类型,只能为http或者https optional + * @param {} [opts.backSourceType] - 回源类型 optional + * @param {} [opts.jumpType] - 有三种类型:default、http、https optional + * @param {} [opts.jcdnTimeAnti] - dash鉴权相关配置 optional + * @param {} [opts.hdrCtrl] - 回源鉴权相关配置 optional + * @param {} [opts.toutiaoHeader] - 头条header配置 optional + * @param {string} callback - callback + @return {Object} result + * @param string taskId 任务taskId + */ + + setDomainConfig (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setDomainConfig" + ) + } + + let postBody = {} + if (opts.httpType !== undefined && opts.httpType !== null) { + postBody['httpType'] = opts.httpType + } + if (opts.backSourceType !== undefined && opts.backSourceType !== null) { + postBody['backSourceType'] = opts.backSourceType + } + if (opts.jumpType !== undefined && opts.jumpType !== null) { + postBody['jumpType'] = opts.jumpType + } + if (opts.jcdnTimeAnti !== undefined && opts.jcdnTimeAnti !== null) { + postBody['jcdnTimeAnti'] = opts.jcdnTimeAnti + } + if (opts.hdrCtrl !== undefined && opts.hdrCtrl !== null) { + postBody['hdrCtrl'] = opts.hdrCtrl + } + if (opts.toutiaoHeader !== undefined && opts.toutiaoHeader !== null) { + postBody['toutiaoHeader'] = opts.toutiaoHeader + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setDomainConfig 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( + '/domain/{domain}/config', + '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.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + * @param configItem configItems + */ + + queryDomainAllConfigClassify (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryDomainAllConfigClassify" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryDomainAllConfigClassify 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( + '/domain/{domain}/queryDomainAllConfigClassify', + '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 {} [opts.domain] - 源域名 optional + * @param {} [opts.copyDomains] - 待复制的域名列表,多个以","分隔,且不超过20个 optional + * @param {} [opts.configKeys] - 待复制的配置项名字,区分大小写.配置项的含义:originConfig:回源配置信息;refererConfig:referer防盗链;urlAuthConfig:URL鉴权;userAgentConfig:UA访问控制;ipBlackListConfig:IP黑名单;cacheConfig:缓存配置;schemeFollowOriConfig:协议跟随回源;oriFollowRedirectConfig:回源跟随302;filterParamsConfig:过滤参数;rangeConfig:range回源;videoDraftConfig:视频拖拽;httpsConfig:Https配置;httpHeaderConfig:HttpHeader设置;otherConfig:其他配置 optional + * @param {string} callback - callback + @return {Object} result + * @param errorEntity errorResult + */ + + executeDomainCopy (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.domain !== undefined && opts.domain !== null) { + postBody['domain'] = opts.domain + } + if (opts.copyDomains !== undefined && opts.copyDomains !== null) { + postBody['copyDomains'] = opts.copyDomains + } + if (opts.configKeys !== undefined && opts.configKeys !== null) { + postBody['configKeys'] = opts.configKeys + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 executeDomainCopy 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( + '/executeDomainCopy', + '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.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + * @param string domain + * @param extraCacheTime extraCacheTimes + */ + + queryExtraCacheTime (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryExtraCacheTime" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryExtraCacheTime 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( + '/domain/{domain}/extraCacheTime:query', + '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.domain - 用户域名 + * @param {} [opts.httpCode] - 异常状态码 ["4xx","400", "401", "402", "404", "405", "406", "407", "408", "409", "410", "411", "412", "413", "414", "415", "416", "417", "5xx","500", "501", "502", "503", "504", "505"]中的其中一个 optional + * @param {} [opts.cacheTime] - 缓存时间(单位:秒) optional + * @param {string} callback - callback + @return {Object} result + */ + + setExtraCacheTime (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setExtraCacheTime" + ) + } + + let postBody = {} + if (opts.httpCode !== undefined && opts.httpCode !== null) { + postBody['httpCode'] = opts.httpCode + } + if (opts.cacheTime !== undefined && opts.cacheTime !== null) { + postBody['cacheTime'] = opts.cacheTime + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setExtraCacheTime 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( + '/domain/{domain}/extraCacheTime:set', + '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.domain - 用户域名 + * @param {} [opts.httpCode] - 异常状态码 ["4xx","400", "401", "402", "404", "405", "406", "407", "408", "409", "410", "411", "412", "413", "414", "415", "416", "417", "5xx","500", "501", "502", "503", "504", "505"]中的其中一个 optional + * @param {string} callback - callback + @return {Object} result + */ + + deleteExtraCacheTime (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling deleteExtraCacheTime" + ) + } + + let postBody = {} + if (opts.httpCode !== undefined && opts.httpCode !== null) { + postBody['httpCode'] = opts.httpCode + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 deleteExtraCacheTime 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( + '/domain/{domain}/extraCacheTime:delete', + '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.domain - 用户域名 + * @param {} [opts.content] - 状态码和过期时间,多个用英文分号分隔,如404:3;500:10;异常状态码 ["4xx","400", "401", "402", "404", "405", "406", "407", "408", "409", "410", "411", "412", "413", "414", "415", "416", "417", "5xx","500", "501", "502", "503", "504", "505"]中的其中一个,缓存时间(单位:秒) optional + * @param {string} callback - callback + @return {Object} result + */ + + batchSetExtraCacheTime (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling batchSetExtraCacheTime" + ) + } + + let postBody = {} + if (opts.content !== undefined && opts.content !== null) { + postBody['content'] = opts.content + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 batchSetExtraCacheTime 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( + '/domain/{domain}/extraCacheTime:batchSet', + '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) + } + ) + } + + /** + * 设置gzip + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.status] - 开关取值[on,off] optional + * @param {} [opts.gzipTypes] - gzip类型,如application/x-javascript,application/xml optional + * @param {string} callback - callback + @return {Object} result + */ + + setGzip (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setGzip" + ) + } + + let postBody = {} + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + if (opts.gzipTypes !== undefined && opts.gzipTypes !== null) { + postBody['gzipTypes'] = opts.gzipTypes + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setGzip 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( + '/domain/{domain}/gzip', + '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.domain - 用户域名 + * @param {} [opts.beforeRegex] - 回源改写之前的正则表达式 optional + * @param {} [opts.afterRegex] - 回源改写之后的正则表达式 optional + * @param {string} callback - callback + @return {Object} result + */ + + configBackSourceRule (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling configBackSourceRule" + ) + } + + let postBody = {} + if (opts.beforeRegex !== undefined && opts.beforeRegex !== null) { + postBody['beforeRegex'] = opts.beforeRegex + } + if (opts.afterRegex !== undefined && opts.afterRegex !== null) { + postBody['afterRegex'] = opts.afterRegex + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 configBackSourceRule 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( + '/domain/{domain}/configBackSourceRule', + '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.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + * @param string domain 加速域名 + * @param string beforeRegex 回源改写之前的正则表达式 + * @param string afterRegex 回源改写之后的正则表达式 + */ + + queryBackSourceRule (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryBackSourceRule" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryBackSourceRule 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( + '/domain/{domain}/queryBackSourceRule', + '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) + } + ) + } + + /** + * URL改写配置 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.beforeRegex] - url改写之前的正则表达式 optional + * @param {} [opts.afterRegex] - url改写之后的正则表达式 optional + * @param {string} callback - callback + @return {Object} result + */ + + configUrlRule (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling configUrlRule" + ) + } + + let postBody = {} + if (opts.beforeRegex !== undefined && opts.beforeRegex !== null) { + postBody['beforeRegex'] = opts.beforeRegex + } + if (opts.afterRegex !== undefined && opts.afterRegex !== null) { + postBody['afterRegex'] = opts.afterRegex + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 configUrlRule 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( + '/domain/{domain}/configUrlRule', + '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) + } + ) + } + + /** + * 查询Url改写配置 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + * @param string domain 加速域名 + * @param string beforeRegex url改写之前的正则表达式 + * @param string afterRegex url改写之后的正则表达式 + */ + + queryUrlRule (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryUrlRule" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryUrlRule 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( + '/domain/{domain}/queryUrlRule', + '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) + } + ) + } + + /** + * http2配置,中国境外/全球加速域名暂不支持该配置 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.status] - HTTP2功能开关,取值on/off optional + * @param {string} callback - callback + @return {Object} result + */ + + configHttp2 (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling configHttp2" + ) + } + + let postBody = {} + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 configHttp2 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( + '/domain/{domain}/configHttp2', + '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) + } + ) + } + + /** + * 查询http2配置 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + * @param string domain 加速域名 + * @param string status HTTP2功能开关,取值on/off + */ + + queryHttp2 (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryHttp2" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryHttp2 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( + '/domain/{domain}/queryHttp2', + '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) + } + ) + } + + /** + * 多path回源配置 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.configs] optional + * @param {string} callback - callback + @return {Object} result + */ + + configBackSourcePath (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling configBackSourcePath" + ) + } + + let postBody = {} + if (opts.configs !== undefined && opts.configs !== null) { + postBody['configs'] = opts.configs + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 configBackSourcePath 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( + '/domain/{domain}/configBackSourcePath', + '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) + } + ) + } + + /** + * 查询回源path + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + * @param string domain 加速域名 + * @param configBackSourcePathItems configs 配置信息 + */ + + queryBackSourcePath (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryBackSourcePath" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryBackSourcePath 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( + '/domain/{domain}/queryBackSourcePath', + '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.domain - 用户域名 + * @param {} [opts.accelerateRegion] - 加速区域,取值[mainland,nonMainland,all] optional + * @param {string} callback - callback + @return {Object} result + */ + + setAccelerateRegion (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setAccelerateRegion" + ) + } + + let postBody = {} + if (opts.accelerateRegion !== undefined && opts.accelerateRegion !== null) { + postBody['accelerateRegion'] = opts.accelerateRegion + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setAccelerateRegion 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( + '/domain/{domain}/accelerateRegion', + '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.domain - 用户域名 + * @param {} [opts.status] - on/off,若为off则数组需为空,若为on则数组不可为空 optional + * @param {} [opts.rules] optional + * @param {string} callback - callback + @return {Object} result + */ + + configBackSourceRules (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling configBackSourceRules" + ) + } + + let postBody = {} + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + if (opts.rules !== undefined && opts.rules !== null) { + postBody['rules'] = opts.rules + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 configBackSourceRules 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( + '/domain/{domain}/configBackSourceRules', + '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.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + * @param string domain 加速域名 + * @param string status on/off + * @param backSourceRule rules 配置信息 + */ + + queryBackSourceRules (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryBackSourceRules" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryBackSourceRules 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( + '/domain/{domain}/queryBackSourceRules', + '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) + } + ) + } + + /** + * 设置回源OSS鉴权 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.status] - on/off,若为on则以下必传参数不可为空[accessKey,secretKey,bucket,domain2],若为off则以下参数均不能有值[accessKey,secretKey,bucket,suffix,domain2] optional + * @param {} [opts.accessKey] - status 为on时必填 optional + * @param {} [opts.secretKey] - status 为on时必填 optional + * @param {} [opts.bucket] - oss桶名,status 为on时必填 optional + * @param {} [opts.suffix] - oss后缀,status 为on时选填 optional + * @param {} [opts.domain2] - status 为on时必填 optional + * @param {string} callback - callback + @return {Object} result + */ + + configBackSourceOss (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling configBackSourceOss" + ) + } + + let postBody = {} + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + if (opts.accessKey !== undefined && opts.accessKey !== null) { + postBody['accessKey'] = opts.accessKey + } + if (opts.secretKey !== undefined && opts.secretKey !== null) { + postBody['secretKey'] = opts.secretKey + } + if (opts.bucket !== undefined && opts.bucket !== null) { + postBody['bucket'] = opts.bucket + } + if (opts.suffix !== undefined && opts.suffix !== null) { + postBody['suffix'] = opts.suffix + } + if (opts.domain2 !== undefined && opts.domain2 !== null) { + postBody['domain2'] = opts.domain2 + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 configBackSourceOss 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( + '/domain/{domain}/configBackSourceOss', + '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) + } + ) + } + + /** + * 查询回源OSS鉴权配置 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + * @param string status on/off + * @param string bucket oss桶名 + * @param string suffix oss后缀 + * @param string domain2 + */ + + queryBackSourceOss (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryBackSourceOss" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryBackSourceOss 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( + '/domain/{domain}/queryBackSourceOss', + '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.domain - 用户域名 + * @param {} [opts.limitRate] - 限速值,单位为KB/s,取值范围[1,20480] optional + * @param {string} callback - callback + @return {Object} result + */ + + speedLimit (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling speedLimit" + ) + } + + let postBody = {} + if (opts.limitRate !== undefined && opts.limitRate !== null) { + postBody['limitRate'] = opts.limitRate + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 speedLimit 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( + '/domain/{domain}/speedLimit', + '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) + } + ) + } + + /** + * 批量添加域名ip黑名单 + * @param {Object} opts - parameters + * @param {} [opts.operateDomainRange] - 可选值。表示域名操作范围,可指定为all代表操作该账号下全量域名,全量域名个数应<=单次可批量操作的域名个数(默认50) optional + * @param {} [opts.domains] - 可选值。待操作的域名列表,个数默认限制50个。注意operateDomainRange和domains至少指定一个参数。operateDomainRange为all时该参数不生效. optional + * @param {} [opts.ipList] - ip列表。最多50个 optional + * @param {} [opts.forbidTime] - 封禁时长,单位分钟。默认1440 optional + * @param {} [opts.action] - forbid or resume.代表封禁和解封。 optional + * @param {string} callback - callback + @return {Object} result + */ + + batchIpBlackList (opts, callback) { + opts = opts || {} + + let postBody = {} + if ( + opts.operateDomainRange !== undefined && + opts.operateDomainRange !== null + ) { + postBody['operateDomainRange'] = opts.operateDomainRange + } + if (opts.domains !== undefined && opts.domains !== null) { + postBody['domains'] = opts.domains + } + if (opts.ipList !== undefined && opts.ipList !== null) { + postBody['ipList'] = opts.ipList + } + if (opts.forbidTime !== undefined && opts.forbidTime !== null) { + postBody['forbidTime'] = opts.forbidTime + } + if (opts.action !== undefined && opts.action !== null) { + postBody['action'] = opts.action + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 batchIpBlackList 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( + '/batchIpBlackList', + '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) + } + ) + } + + /** + * 设置回源IP类型 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.backSourceIpVersion] - 回源IP类型,取值ipv4/ipv6/ipv46。ipv4:回源IP为ipv4;ipv6:ipv6优先;ipv46:ipv4/ipv6负载均衡 optional + * @param {string} callback - callback + @return {Object} result + */ + + configBackSourceIpVersion (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling configBackSourceIpVersion" + ) + } + + let postBody = {} + if ( + opts.backSourceIpVersion !== undefined && + opts.backSourceIpVersion !== null + ) { + postBody['backSourceIpVersion'] = opts.backSourceIpVersion + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 configBackSourceIpVersion 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( + '/domain/{domain}/configBackSourceIpVersion', + '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) + } + ) + } + + /** + * 查询回源IP类型 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + * @param string backSourceIpVersion 回源IP类型,取值ipv4/ipv6/ipv46。ipv4:回源IP为ipv4;ipv6:ipv6优先;ipv46:ipv4/ipv6负载均衡 + */ + + queryBackSourceIpVersion (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryBackSourceIpVersion" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryBackSourceIpVersion 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( + '/domain/{domain}/queryBackSourceIpVersion', + '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.shareCache] - 根据是否共享内存筛选 optional + * @param {integer} [opts.pageNumber] - pageNumber optional + * @param {integer} [opts.pageSize] - pageSize optional + * @param {string} [opts.primaryDomain] - 根据主域名模糊查询 optional + * @param {string} [opts.domainGroupName] - 根据域名组模糊查询 optional + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount + * @param integer pageSize + * @param integer pageNumber + * @param domainGroupItem domainGroups + */ + + queryDomainGroupList (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.shareCache !== undefined && opts.shareCache !== null) { + queryParams['shareCache'] = opts.shareCache + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + queryParams['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.primaryDomain !== undefined && opts.primaryDomain !== null) { + queryParams['primaryDomain'] = opts.primaryDomain + } + if (opts.domainGroupName !== undefined && opts.domainGroupName !== null) { + queryParams['domainGroupName'] = opts.domainGroupName + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryDomainGroupList 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( + '/domainGroup', + '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.id - 域名组id + * @param {string} callback - callback + @return {Object} result + * @param string domains + * @param string primaryDomain 主域名 + * @param string shareCache 是否共享缓存 + * @param string domainGroupName 域名组名称 + */ + + queryDomainGroupDetail (opts, callback) { + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling queryDomainGroupDetail" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryDomainGroupDetail 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( + '/domainGroup/{id}', + '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} callback - callback + @return {Object} result + * @param string domains + */ + + queryDomainsNotInGroup (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryDomainsNotInGroup 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( + '/domainGroup:notInGroup', + '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.id - 域名组id + * @param {} [opts.domains] - 域名组内域名,包含主域名 optional + * @param {} [opts.primaryDomain] - 主域名,开启共享缓存时必传 optional + * @param {} [opts.shareCache] - 是否共享内存,共享缓存仅对中国境内加速域名生效 optional + * @param {} [opts.domainGroupName] optional + * @param {string} callback - callback + @return {Object} result + */ + + updateDomainGroup (opts, callback) { + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling updateDomainGroup" + ) + } + + let postBody = {} + if (opts.domains !== undefined && opts.domains !== null) { + postBody['domains'] = opts.domains + } + if (opts.primaryDomain !== undefined && opts.primaryDomain !== null) { + postBody['primaryDomain'] = opts.primaryDomain + } + if (opts.shareCache !== undefined && opts.shareCache !== null) { + postBody['shareCache'] = opts.shareCache + } + if (opts.domainGroupName !== undefined && opts.domainGroupName !== null) { + postBody['domainGroupName'] = opts.domainGroupName + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 updateDomainGroup 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( + '/domainGroup/{id}:update', + '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 {} [opts.shareCache] - 是否共享内存,共享缓存仅对中国境内加速域名生效 optional + * @param {} [opts.primaryDomain] - 主域名,开启共享缓存时必传 optional + * @param {} [opts.domainGroupName] - 域名组名称 optional + * @param {} [opts.domains] - 域名组内域名包含主域名 optional + * @param {string} callback - callback + @return {Object} result + */ + + createDomainGroup (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.shareCache !== undefined && opts.shareCache !== null) { + postBody['shareCache'] = opts.shareCache + } + if (opts.primaryDomain !== undefined && opts.primaryDomain !== null) { + postBody['primaryDomain'] = opts.primaryDomain + } + if (opts.domainGroupName !== undefined && opts.domainGroupName !== null) { + postBody['domainGroupName'] = opts.domainGroupName + } + if (opts.domains !== undefined && opts.domains !== null) { + postBody['domains'] = opts.domains + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 createDomainGroup 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( + '/domainGroup:create', + '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 {array} opts.ids + * @param {string} callback - callback + @return {Object} result + */ + + batchDeleteDomainGroup (opts, callback) { + opts = opts || {} + + if (opts.ids === undefined || opts.ids === null) { + throw new Error( + "Missing the required parameter 'opts.ids' when calling batchDeleteDomainGroup" + ) + } + + let postBody = {} + if (opts.ids !== undefined && opts.ids !== null) { + postBody['ids'] = opts.ids + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 batchDeleteDomainGroup 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( + '/domainGroup:batchDelete', + '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.keyWord] - 根据关键字进行模糊匹配 optional + * @param {integer} [opts.pageNumber] - pageNumber,默认值1 optional + * @param {integer} [opts.pageSize] - pageSize,最大值50,默认值20 optional + * @param {string} [opts.status] - 根据域名状态查询, 可选值[offline, online, configuring, auditing, audit_reject] optional + * @param {string} [opts.type] - 域名类型,(web:静态小文件,download:大文件加速,vod:视频加速,live:直播加速),不传查所有 optional + * @param {string} [opts.accelerateRegion] - 加速区域,(mainLand:中国大陆,nonMainLand:海外加港澳台,all:全球),不传为全球 optional + * @param {boolean} [opts.withThirdPartyStatus] - 筛选依据(false不需要查询, true 需要查询海外状态)默认false optional + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount + * @param integer pageSize + * @param integer pageNumber + * @param listDomainItem domains + */ + + getDomainList (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.keyWord !== undefined && opts.keyWord !== null) { + queryParams['keyWord'] = opts.keyWord + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + queryParams['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + if (opts.type !== undefined && opts.type !== null) { + queryParams['type'] = opts.type + } + if (opts.accelerateRegion !== undefined && opts.accelerateRegion !== null) { + queryParams['accelerateRegion'] = opts.accelerateRegion + } + if ( + opts.withThirdPartyStatus !== undefined && + opts.withThirdPartyStatus !== null + ) { + queryParams['withThirdPartyStatus'] = opts.withThirdPartyStatus + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 getDomainList 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( + '/domain', + '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.keyWord] - 根据关键字进行模糊匹配,域名或者回源信息 optional + * @param {integer} [opts.pageNumber] - pageNumber,默认值为1 optional + * @param {integer} [opts.pageSize] - pageSize,默认值为20,最大值为50 optional + * @param {string} [opts.status] - 根据域名状态查询, 可选值[offline, online, configuring, auditing, audit_reject] optional + * @param {string} [opts.type] - 域名类型,(web:静态小文件,download:大文件加速,vod:视频加速,live:直播加速),不传查所有 optional + * @param {string} [opts.accelerateRegion] - 加速区域,(mainLand:中国大陆,nonMainLand:海外加港澳台,all:全球),不传为全球 optional + * @param {integer} [opts.filterBy] - 筛选依据(0:根据域名筛选,1:根据回源信息筛选),默认按照域名进行筛选 optional + * @param {array} [opts.tagFilters] - 标签过滤条件 optional + * @param {boolean} [opts.withThirdPartyStatus] - 筛选依据(false不需要查询, true 需要查询海外状态)默认false optional + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount + * @param integer pageSize + * @param integer pageNumber + * @param listDomainItemByFilter domains + */ + + getDomainListByFilter (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.keyWord !== undefined && opts.keyWord !== null) { + postBody['keyWord'] = opts.keyWord + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + if (opts.type !== undefined && opts.type !== null) { + postBody['type'] = opts.type + } + if (opts.accelerateRegion !== undefined && opts.accelerateRegion !== null) { + postBody['accelerateRegion'] = opts.accelerateRegion + } + if (opts.filterBy !== undefined && opts.filterBy !== null) { + postBody['filterBy'] = opts.filterBy + } + if (opts.tagFilters !== undefined && opts.tagFilters !== null) { + postBody['tagFilters'] = opts.tagFilters + } + if ( + opts.withThirdPartyStatus !== undefined && + opts.withThirdPartyStatus !== null + ) { + postBody['withThirdPartyStatus'] = opts.withThirdPartyStatus + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 getDomainListByFilter 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( + '/domain:query', + '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.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + * @param string allStatus null + * @param string allowNoReferHeader 是否允许空refer访问 + * @param string allowNullReferHeader null + * @param integer dailyBandWidth 日带宽(单位Mbps) + * @param string forbiddenType 封禁类型,取值:domain,url + * @param integer maxFileSize 最大单个文件大小(单位MB) + * @param integer minFileSize 最小单个文件大小(单位MB) + * @param integer sumFileSize 总文件大小(单位MB) + * @param integer avgFileSize 平均文件大小(单位MB) + * @param string referList + * @param string referType refer类型,取值:block(黑名单),allow(白名单) + * @param string domain 域名 + * @param string cname 为加速域名生成的一个CNAME域名,需要在域名解析服务商处将加速域名CNAME解析到该域名 + * @param string archiveNo 域名备案号 + * @param string type 域名加速类型,web表示图片及小文件加速 + * @param string created 创建时间 + * @param string modified 最后修改时间 + * @param string status 加速域名运行状态 ,online 表示启用;offline表示停用;configuring表示配置中;configure_failed表示配置失败 + * @param string auditStatus 域名审核状态,取值:0(未审核),1(审核通过),2(审核不通过) + * @param backSourceInfo source null + * @param string sourceType 回源类型:取值 ips(IP列表),domain(域名),oss(oss回源) + * @param string defaultSourceHost 默认的回源host + * @param string backSourceType 回源类型,只能为http(80端口回源)或者https(443端口回源),默认为http + * @param string httpType http类型,只能为http或者https,默认为http。当设为https时,需要调用“设置通讯协议”接口上传证书和私钥 + * @param string certificate 用户证书,当Type为https时必须设置 + * @param string rsaKey 证书私钥 + * @param string jumpType 跳转类型,有三种类型:default、http、https + * @param string certFrom 证书来源,取值:ssl,defalut + * @param string sslCertId 证书id + * @param string certName 证书名称 + * @param string certType 证书类型 + * @param string sslCertStartTime 证书开始时间 + * @param string sslCertEndTime 证书结束时间 + * @param string accelerateRegion 加速区域 + * @param string txt txt记录 + * @param integer overseaStatus 海外状态(-1:不涉及海外加速,0:未激活,1:已激活,2:域名在cf不存在) + */ + + getDomainDetail (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling getDomainDetail" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 getDomainDetail 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( + '/domain/{domain}', + '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.domain - 用户域名 + * @param {} [opts.sourceType] - 回源类型只能是[ips,domain,oss]中的一种 optional + * @param {} [opts.cdnType] - 点播域名的类型只能是[vod,download,web]中的一种 optional + * @param {} [opts.backSourceType] - 回源方式,只能是[https,http]中的一种,默认http optional + * @param {} [opts.dailyBandWidth] - 日带宽(Mbps) optional + * @param {} [opts.quaility] - 服务质量,只能是[good,general]中的一种,默认为good optional + * @param {} [opts.maxFileSize] optional + * @param {} [opts.minFileSize] optional + * @param {} [opts.sumFileSize] optional + * @param {} [opts.avgFileSize] optional + * @param {} [opts.defaultSourceHost] optional + * @param {} [opts.httpType] optional + * @param {} [opts.ipSource] optional + * @param {} [opts.domainSource] optional + * @param {} [opts.ossSource] optional + * @param {} [opts.accelerateRegion] - 加速区域:(mainLand:中国大陆,nonMainLand:海外加港澳台,all:全球)默认为中国大陆 optional + * @param {} [opts.tempInstId] optional + * @param {} [opts.domainCnameTag] - cname标签,使用时通过queryDomainCnameTag接口获取 optional + * @param {string} callback - callback + @return {Object} result + */ + + createDomain (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling createDomain" + ) + } + + let postBody = {} + if (opts.sourceType !== undefined && opts.sourceType !== null) { + postBody['sourceType'] = opts.sourceType + } + if (opts.cdnType !== undefined && opts.cdnType !== null) { + postBody['cdnType'] = opts.cdnType + } + if (opts.backSourceType !== undefined && opts.backSourceType !== null) { + postBody['backSourceType'] = opts.backSourceType + } + if (opts.dailyBandWidth !== undefined && opts.dailyBandWidth !== null) { + postBody['dailyBandWidth'] = opts.dailyBandWidth + } + if (opts.quaility !== undefined && opts.quaility !== null) { + postBody['quaility'] = opts.quaility + } + if (opts.maxFileSize !== undefined && opts.maxFileSize !== null) { + postBody['maxFileSize'] = opts.maxFileSize + } + if (opts.minFileSize !== undefined && opts.minFileSize !== null) { + postBody['minFileSize'] = opts.minFileSize + } + if (opts.sumFileSize !== undefined && opts.sumFileSize !== null) { + postBody['sumFileSize'] = opts.sumFileSize + } + if (opts.avgFileSize !== undefined && opts.avgFileSize !== null) { + postBody['avgFileSize'] = opts.avgFileSize + } + if ( + opts.defaultSourceHost !== undefined && + opts.defaultSourceHost !== null + ) { + postBody['defaultSourceHost'] = opts.defaultSourceHost + } + if (opts.httpType !== undefined && opts.httpType !== null) { + postBody['httpType'] = opts.httpType + } + if (opts.ipSource !== undefined && opts.ipSource !== null) { + postBody['ipSource'] = opts.ipSource + } + if (opts.domainSource !== undefined && opts.domainSource !== null) { + postBody['domainSource'] = opts.domainSource + } + if (opts.ossSource !== undefined && opts.ossSource !== null) { + postBody['ossSource'] = opts.ossSource + } + if (opts.accelerateRegion !== undefined && opts.accelerateRegion !== null) { + postBody['accelerateRegion'] = opts.accelerateRegion + } + if (opts.tempInstId !== undefined && opts.tempInstId !== null) { + postBody['tempInstId'] = opts.tempInstId + } + if (opts.domainCnameTag !== undefined && opts.domainCnameTag !== null) { + postBody['domainCnameTag'] = opts.domainCnameTag + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 createDomain 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( + '/domain/{domain}', + '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.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + */ + + deleteDomain (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling deleteDomain" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 deleteDomain 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( + '/domain/{domain}', + '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) + } + ) + } + + /** + * 查询域名cname标签 + * @param {Object} opts - parameters + * @param {string} opts.domainType - 域名类型,取值范围web,download,vod,dynamic,live + * @param {string} callback - callback + @return {Object} result + * @param string cnameTags + */ + + queryDomainCnameTag (opts, callback) { + opts = opts || {} + + if (opts.domainType === undefined || opts.domainType === null) { + throw new Error( + "Missing the required parameter 'opts.domainType' when calling queryDomainCnameTag" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainType !== undefined && opts.domainType !== null) { + queryParams['domainType'] = opts.domainType + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryDomainCnameTag 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( + '/queryDomainCnameTag', + '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.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + */ + + startDomain (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling startDomain" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 startDomain 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( + '/domain/{domain}:start', + '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.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + */ + + stopDomain (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling stopDomain" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 stopDomain 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( + '/domain/{domain}:stop', + '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) + } + ) + } + + /** + * 查询oss存储域名 + * @param {Object} opts - parameters + * @param {string} callback - callback + @return {Object} result + * @param integer total + * @param object ossBuckets + */ + + queryOssBuckets (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryOssBuckets 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( + '/ossBuckets', + '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 {} [opts.domains] optional + * @param {} [opts.sourceType] - 回源类型只能是[ips,domain,oss]中的一种 optional + * @param {} [opts.cdnType] - 点播域名的类型只能是[vod,download,web]中的一种 optional + * @param {} [opts.backSourceType] - 回源方式,只能是[https,http]中的一种,默认http optional + * @param {} [opts.dailyBandWidth] - 日带宽(Mbps) optional + * @param {} [opts.quaility] - 服务质量,只能是[good,general]中的一种,默认为good optional + * @param {} [opts.maxFileSize] optional + * @param {} [opts.minFileSize] optional + * @param {} [opts.sumFileSize] optional + * @param {} [opts.avgFileSize] optional + * @param {} [opts.defaultSourceHost] optional + * @param {} [opts.httpType] optional + * @param {} [opts.ipSource] optional + * @param {} [opts.domainSource] optional + * @param {} [opts.ossSource] optional + * @param {} [opts.accelerateRegion] - 加速区域 (mainLand:中国大陆,nonMainLand:海外加港澳台,all:全球)默认为中国大陆 optional + * @param {} [opts.tempInstId] optional + * @param {string} callback - callback + @return {Object} result + */ + + batchCreate (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.domains !== undefined && opts.domains !== null) { + postBody['domains'] = opts.domains + } + if (opts.sourceType !== undefined && opts.sourceType !== null) { + postBody['sourceType'] = opts.sourceType + } + if (opts.cdnType !== undefined && opts.cdnType !== null) { + postBody['cdnType'] = opts.cdnType + } + if (opts.backSourceType !== undefined && opts.backSourceType !== null) { + postBody['backSourceType'] = opts.backSourceType + } + if (opts.dailyBandWidth !== undefined && opts.dailyBandWidth !== null) { + postBody['dailyBandWidth'] = opts.dailyBandWidth + } + if (opts.quaility !== undefined && opts.quaility !== null) { + postBody['quaility'] = opts.quaility + } + if (opts.maxFileSize !== undefined && opts.maxFileSize !== null) { + postBody['maxFileSize'] = opts.maxFileSize + } + if (opts.minFileSize !== undefined && opts.minFileSize !== null) { + postBody['minFileSize'] = opts.minFileSize + } + if (opts.sumFileSize !== undefined && opts.sumFileSize !== null) { + postBody['sumFileSize'] = opts.sumFileSize + } + if (opts.avgFileSize !== undefined && opts.avgFileSize !== null) { + postBody['avgFileSize'] = opts.avgFileSize + } + if ( + opts.defaultSourceHost !== undefined && + opts.defaultSourceHost !== null + ) { + postBody['defaultSourceHost'] = opts.defaultSourceHost + } + if (opts.httpType !== undefined && opts.httpType !== null) { + postBody['httpType'] = opts.httpType + } + if (opts.ipSource !== undefined && opts.ipSource !== null) { + postBody['ipSource'] = opts.ipSource + } + if (opts.domainSource !== undefined && opts.domainSource !== null) { + postBody['domainSource'] = opts.domainSource + } + if (opts.ossSource !== undefined && opts.ossSource !== null) { + postBody['ossSource'] = opts.ossSource + } + if (opts.accelerateRegion !== undefined && opts.accelerateRegion !== null) { + postBody['accelerateRegion'] = opts.accelerateRegion + } + if (opts.tempInstId !== undefined && opts.tempInstId !== null) { + postBody['tempInstId'] = opts.tempInstId + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 batchCreate 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( + '/domain:batchCreate', + '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.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + * @param string ignoreQueryString 忽略参数[on,off] + * @param string range range参数[on,off] + * @param string httpType httpType参数[on,off] + * @param string httpsCertificate https证书 + * @param string httpsRsaKey rsa秘钥 + * @param string httpsJumpType 跳转类型[default,http,https] + * @param string videoDraft 是否支持视频拖拽[on,off] + * @param string groupName group + * @param integer shareId + * @param string shareName + * @param string jcdnTimeAnti + * @param string shareCache + * @param string isShareOpen + * @param string gzip gzip参数[on,off] + * @param string gzipTypes + * @param cacheRule cacheRules + */ + + queryDomainConfig (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryDomainConfig" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryDomainConfig 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( + '/domain/{domain}/config', + '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) + } + ) + } + + /** + * 生成域名txt记录 + * @param {Object} opts - parameters + * @param {} [opts.domain] - 域名 optional + * @param {string} callback - callback + @return {Object} result + * @param string txt 生成的txt文本 + */ + + generateDomainTxt (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.domain !== undefined && opts.domain !== null) { + postBody['domain'] = opts.domain + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 generateDomainTxt 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( + '/generateDomainTxt', + '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) + } + ) + } + + /** + * 域名txt校验 + * @param {Object} opts - parameters + * @param {} [opts.domain] - 域名 optional + * @param {} [opts.validateType] - 校验类型,dns or file optional + * @param {} [opts.hostRecord] - 主机记录,dns验证方式时必传.值为_cdnautover optional + * @param {} [opts.txt] - 主机记录值 optional + * @param {} [opts.url] - file验证方式时必传 optional + * @param {string} callback - callback + @return {Object} result + * @param boolean pass 是否校验通过,true通过,false不通过 + * @param string errMsg 不通过原因,仅校验不通过时有值 + */ + + domainTxtValidate (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.domain !== undefined && opts.domain !== null) { + postBody['domain'] = opts.domain + } + if (opts.validateType !== undefined && opts.validateType !== null) { + postBody['validateType'] = opts.validateType + } + if (opts.hostRecord !== undefined && opts.hostRecord !== null) { + postBody['hostRecord'] = opts.hostRecord + } + if (opts.txt !== undefined && opts.txt !== null) { + postBody['txt'] = opts.txt + } + if (opts.url !== undefined && opts.url !== null) { + postBody['url'] = opts.url + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 domainTxtValidate 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( + '/domainTxtValidate', + '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.instName] - 根据关键字进行模糊匹配 optional + * @param {integer} [opts.pageNumber] - pageNumber,默认值1 optional + * @param {integer} [opts.pageSize] - pageSize,最大值50,默认值20 optional + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount + * @param integer pageSize + * @param integer pageNumber + * @param listDomainTempItem instList + */ + + queryDomainTempInstList (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.instName !== undefined && opts.instName !== null) { + queryParams['instName'] = opts.instName + } + 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: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryDomainTempInstList 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( + '/domainTempInst:list', + '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} callback - callback + @return {Object} result + * @param object proKeyMap 查询结果,类型为HashMap<String, List<String>> + */ + + queryDomainTempProKeys (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryDomainTempProKeys 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( + '/domainTemp', + '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 {} [opts.tempId] - 模板id,预留字段 optional + * @param {} [opts.instId] - 模板实例id,修改时必传 optional + * @param {} [opts.instName] - 模板实例名称 optional + * @param {} [opts.instProInfoMap] - 查询结果,类型为Map<String,Map<String,Object>> optional + * @param {string} callback - callback + @return {Object} result + */ + + modifyDomainTempInst (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.tempId !== undefined && opts.tempId !== null) { + postBody['tempId'] = opts.tempId + } + if (opts.instId !== undefined && opts.instId !== null) { + postBody['instId'] = opts.instId + } + if (opts.instName !== undefined && opts.instName !== null) { + postBody['instName'] = opts.instName + } + if (opts.instProInfoMap !== undefined && opts.instProInfoMap !== null) { + postBody['instProInfoMap'] = opts.instProInfoMap + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 modifyDomainTempInst 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( + '/domainTempInst', + '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.instId - 模板实例id + * @param {string} callback - callback + @return {Object} result + * @param string instName 模板实例名称 + * @param string createTime 创建时间utc格式 + * @param string updateTime 创建时间utc格式 + * @param object instProInfoMap 查询结果,类型为Map<String,Map<String,Object>> + */ + + queryDomainTempInst (opts, callback) { + opts = opts || {} + + if (opts.instId === undefined || opts.instId === null) { + throw new Error( + "Missing the required parameter 'opts.instId' when calling queryDomainTempInst" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + instId: opts.instId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryDomainTempInst 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( + '/domainTempInst/{instId}', + '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.instId - 模板实例id + * @param {string} callback - callback + @return {Object} result + */ + + delDomainTempInstance (opts, callback) { + opts = opts || {} + + if (opts.instId === undefined || opts.instId === null) { + throw new Error( + "Missing the required parameter 'opts.instId' when calling delDomainTempInstance" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + instId: opts.instId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 delDomainTempInstance 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( + '/domainTempInst/{instId}', + '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) + } + ) + } + + /** + * 查询IP归属,适用于查询边缘节点,仅支持中国境内IP地址查询 + * @param {Object} opts - parameters + * @param {} [opts.ips] optional + * @param {string} callback - callback + @return {Object} result + * @param checkWhetherIpBelongToJCloudItem ipList + */ + + checkWhetherIpBelongToJCloud (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.ips !== undefined && opts.ips !== null) { + postBody['ips'] = opts.ips + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 checkWhetherIpBelongToJCloud 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( + '/ip:whetherBelongToJCloud', + '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) + } + ) + } + + /** + * 查询一个域名的全部调度ip + * @param {Object} opts - parameters + * @param {} [opts.domainList] optional + * @param {string} callback - callback + @return {Object} result + * @param domainSchedResultItem domainSchedResultItemList + */ + + queryServiceIp (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.domainList !== undefined && opts.domainList !== null) { + postBody['domainList'] = opts.domainList + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryServiceIp 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( + '/ip:queryServiceIp', + '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.domain - 用户域名 + * @param {} [opts.sourceType] - 回源类型只能为[ips,domain]中的一种 optional + * @param {} [opts.backSourceType] optional + * @param {} [opts.defaultSourceHost] - 默认回源host optional + * @param {} [opts.domainSource] optional + * @param {} [opts.ipSource] optional + * @param {string} callback - callback + @return {Object} result + */ + + setLiveDomainBackSource (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setLiveDomainBackSource" + ) + } + + let postBody = {} + if (opts.sourceType !== undefined && opts.sourceType !== null) { + postBody['sourceType'] = opts.sourceType + } + if (opts.backSourceType !== undefined && opts.backSourceType !== null) { + postBody['backSourceType'] = opts.backSourceType + } + if ( + opts.defaultSourceHost !== undefined && + opts.defaultSourceHost !== null + ) { + postBody['defaultSourceHost'] = opts.defaultSourceHost + } + if (opts.domainSource !== undefined && opts.domainSource !== null) { + postBody['domainSource'] = opts.domainSource + } + if (opts.ipSource !== undefined && opts.ipSource !== null) { + postBody['ipSource'] = opts.ipSource + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setLiveDomainBackSource 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( + '/liveDomain/{domain}/backSource', + '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) + } + ) + } + + /** + * 设置直播域名ip黑白名单 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.ips] - ip名单,ips中url不能超过50条 optional + * @param {} [opts.ipListType] - ip黑白名单类型,black:黑名单,white:白名单 optional + * @param {string} callback - callback + @return {Object} result + */ + + setLiveDomainIpBlackList (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setLiveDomainIpBlackList" + ) + } + + let postBody = {} + if (opts.ips !== undefined && opts.ips !== null) { + postBody['ips'] = opts.ips + } + if (opts.ipListType !== undefined && opts.ipListType !== null) { + postBody['ipListType'] = opts.ipListType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setLiveDomainIpBlackList 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( + '/liveDomain/{domain}/ipBlackList', + '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) + } + ) + } + + /** + * 设置域名refer防盗链 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.referType] - refer类型,取值:block(黑名单),allow(白名单)默认为block optional + * @param {} [opts.referList] - 逗号隔开的域名列表,如果referList传空则为删除 optional + * @param {} [opts.allowNoReferHeader] - 是否允许空refer访问,默认为“on” optional + * @param {} [opts.allowNullReferHeader] - 是否允许无ua访问,默认为“on” optional + * @param {string} callback - callback + @return {Object} result + */ + + setLiveDomainRefer (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setLiveDomainRefer" + ) + } + + let postBody = {} + if (opts.referType !== undefined && opts.referType !== null) { + postBody['referType'] = opts.referType + } + if (opts.referList !== undefined && opts.referList !== null) { + postBody['referList'] = opts.referList + } + if ( + opts.allowNoReferHeader !== undefined && + opts.allowNoReferHeader !== null + ) { + postBody['allowNoReferHeader'] = opts.allowNoReferHeader + } + if ( + opts.allowNullReferHeader !== undefined && + opts.allowNullReferHeader !== null + ) { + postBody['allowNullReferHeader'] = opts.allowNullReferHeader + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setLiveDomainRefer 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( + '/liveDomain/{domain}/refer', + '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) + } + ) + } + + /** + * 开启或关闭ip黑名单 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.blackIpsEnable] optional + * @param {string} callback - callback + @return {Object} result + */ + + operateLiveDomainIpBlackList (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling operateLiveDomainIpBlackList" + ) + } + + let postBody = {} + if (opts.blackIpsEnable !== undefined && opts.blackIpsEnable !== null) { + postBody['blackIpsEnable'] = opts.blackIpsEnable + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 operateLiveDomainIpBlackList 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( + '/liveDomain/{domain}/ipBlackList:operate', + '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) + } + ) + } + + /** + * 设置直播域名回源host + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.sourceHost] - 默认回源host optional + * @param {string} callback - callback + @return {Object} result + */ + + setLiveDomainBackSourceHost (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setLiveDomainBackSourceHost" + ) + } + + let postBody = {} + if (opts.sourceHost !== undefined && opts.sourceHost !== null) { + postBody['sourceHost'] = opts.sourceHost + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setLiveDomainBackSourceHost 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( + '/liveDomain/{domain}/backSourceHost', + '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) + } + ) + } + + /** + * 设置URL鉴权 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.accesskeyType] - url鉴权开启1关闭0 optional + * @param {} [opts.accesskeyKey] - url鉴权开启时必传 optional + * @param {} [opts.authLifeTime] - 开启时默认值为300s,关闭时为0 optional + * @param {string} callback - callback + @return {Object} result + */ + + setLiveDomainAccessKey (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setLiveDomainAccessKey" + ) + } + + let postBody = {} + if (opts.accesskeyType !== undefined && opts.accesskeyType !== null) { + postBody['accesskeyType'] = opts.accesskeyType + } + if (opts.accesskeyKey !== undefined && opts.accesskeyKey !== null) { + postBody['accesskeyKey'] = opts.accesskeyKey + } + if (opts.authLifeTime !== undefined && opts.authLifeTime !== null) { + postBody['authLifeTime'] = opts.authLifeTime + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setLiveDomainAccessKey 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( + '/liveDomain/{domain}/accesskeyConfig', + '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.domain - 用户域名 + * @param {} [opts.certificate] - https证书,转https格式时必传 optional + * @param {} [opts.rsaKey] - https私钥,转https格式时必传 optional + * @param {} [opts.certFrom] - 证书来源有两种类型:default,ssl optional + * @param {} [opts.sslCertId] - ssl证书id optional + * @param {} [opts.syncToSsl] - 是否同步到ssl,boolean值,取值true或者false optional + * @param {} [opts.certName] - syncToSsl是true时,certName是必填项 optional + * @param {} [opts.protocolConverts] optional + * @param {string} callback - callback + @return {Object} result + */ + + setProtocolConvert (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setProtocolConvert" + ) + } + + let postBody = {} + if (opts.certificate !== undefined && opts.certificate !== null) { + postBody['certificate'] = opts.certificate + } + if (opts.rsaKey !== undefined && opts.rsaKey !== null) { + postBody['rsaKey'] = opts.rsaKey + } + if (opts.certFrom !== undefined && opts.certFrom !== null) { + postBody['certFrom'] = opts.certFrom + } + if (opts.sslCertId !== undefined && opts.sslCertId !== null) { + postBody['sslCertId'] = opts.sslCertId + } + if (opts.syncToSsl !== undefined && opts.syncToSsl !== null) { + postBody['syncToSsl'] = opts.syncToSsl + } + if (opts.certName !== undefined && opts.certName !== null) { + postBody['certName'] = opts.certName + } + if (opts.protocolConverts !== undefined && opts.protocolConverts !== null) { + postBody['protocolConverts'] = opts.protocolConverts + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setProtocolConvert 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( + '/liveDomain/{domain}/protocolConvert', + '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.domain - 用户域名 + * @param {} [opts.deleteStreams] - 要删除的禁播流 optional + * @param {string} callback - callback + @return {Object} result + */ + + deleteForbiddenStream (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling deleteForbiddenStream" + ) + } + + let postBody = {} + if (opts.deleteStreams !== undefined && opts.deleteStreams !== null) { + postBody['deleteStreams'] = opts.deleteStreams + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 deleteForbiddenStream 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( + '/liveDomain/{domain}/stream:unForbidden', + '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) + } + ) + } + + /** + * 查询用户推流域名app名/流名 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {string} [opts.app] - app名,传appName查询流名列表 optional + * @param {string} [opts.stream] - 流名模糊查询 optional + * @param {integer} [opts.limit] - 指定app/流名列表大小,默认50 optional + * @param {string} callback - callback + @return {Object} result + * @param string streams + */ + + queryPushDomainORAppOrStream (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryPushDomainORAppOrStream" + ) + } + + let postBody = null + let queryParams = {} + if (opts.app !== undefined && opts.app !== null) { + queryParams['app'] = opts.app + } + if (opts.stream !== undefined && opts.stream !== null) { + queryParams['stream'] = opts.stream + } + if (opts.limit !== undefined && opts.limit !== null) { + queryParams['limit'] = opts.limit + } + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryPushDomainORAppOrStream 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( + '/liveDomain/{domain}/stream:fuzzyQuery', + '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黑白名单 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + * @param string domain 域名 + * @param string blackIps + * @param string whiteIps + */ + + queryLiveDomainIpBlackWhiteList (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryLiveDomainIpBlackWhiteList" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryLiveDomainIpBlackWhiteList 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( + '/liveDomain/{domain}/ipList', + '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 {} [opts.playDomain] - 播放域名 optional + * @param {} [opts.publishDomain] - 创建推流域名时,必传推流域名 optional + * @param {} [opts.sourceType] - 回源类型只能是[ips,domain]中的一种 optional + * @param {} [opts.backHttpType] optional + * @param {} [opts.defaultSourceHost] - 默认回源host optional + * @param {} [opts.siteType] - 站点类型pull(拉流)push(推流) optional + * @param {} [opts.backSourceType] - 回源类型,目前只能为rtmp optional + * @param {} [opts.ipSource] optional + * @param {} [opts.domainSource] optional + * @param {} [opts.accelerateRegion] - 加速区域(mainLand:中国大陆,nonMainLand:海外加港澳台,all:全球)默认为中国大陆 optional + * @param {string} callback - callback + @return {Object} result + */ + + batchCreateLiveDomain (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.playDomain !== undefined && opts.playDomain !== null) { + postBody['playDomain'] = opts.playDomain + } + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + postBody['publishDomain'] = opts.publishDomain + } + if (opts.sourceType !== undefined && opts.sourceType !== null) { + postBody['sourceType'] = opts.sourceType + } + if (opts.backHttpType !== undefined && opts.backHttpType !== null) { + postBody['backHttpType'] = opts.backHttpType + } + if ( + opts.defaultSourceHost !== undefined && + opts.defaultSourceHost !== null + ) { + postBody['defaultSourceHost'] = opts.defaultSourceHost + } + if (opts.siteType !== undefined && opts.siteType !== null) { + postBody['siteType'] = opts.siteType + } + if (opts.backSourceType !== undefined && opts.backSourceType !== null) { + postBody['backSourceType'] = opts.backSourceType + } + if (opts.ipSource !== undefined && opts.ipSource !== null) { + postBody['ipSource'] = opts.ipSource + } + if (opts.domainSource !== undefined && opts.domainSource !== null) { + postBody['domainSource'] = opts.domainSource + } + if (opts.accelerateRegion !== undefined && opts.accelerateRegion !== null) { + postBody['accelerateRegion'] = opts.accelerateRegion + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 batchCreateLiveDomain 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( + '/liveDomain:batchCreate', + '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) + } + ) + } + + /** + * 查询直播域名详情v1 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + * @param string domainType 域名类型 + * @param string playDomain 播放域名 + * @param string publishDomain 推流域名 + * @param string originDomain 回源域名 + * @param string createdTime 创建时间 + * @param string cname cname + * @param string siteType 站点类型推流push,拉流pull + * @param string status 域名状态 + * @param backSourceInfo source 回源信息 + * @param string sourceType 域名回源类型 + * @param string backSourceType 回源类型目前只能未rtmp + * @param string videoType 视频格式 H.264 + * @param string audioType 音频格式AAC + * @param string type 域名类型 + * @param string defaultSourceHost 默认回源host + * @param string archiveNo 备案号 + * @param string rtmpDomain rtmpDomain + * @param string rtmpCname rtmpCname + * @param string hdlDomain hdlDomain + * @param string hdlCname hdlCname + * @param string hlsDomain hlsDomain + * @param string hlsCname hlsCname + * @param string forwardCustomVhost forwardCustomVhost + * @param string flvUrls + * @param string hlsUrls + * @param string rtmpUrls + * @param protocolConvert protocolConverts + * @param string certificate https证书 + * @param string rsaKey https私钥 + * @param integer accesskeyType url鉴权开关 + * @param string accesskeyKey url鉴权key + * @param integer playAuthLifeTime playAuthLifeTime + * @param integer authLifeTime authLifeTime + * @param integer forwardAccessKeyType 转推鉴权开关 + * @param string forwardPrivateKey 转推鉴权key + * @param integer originAccessKeyType 回源鉴权开关 + * @param string originPrivateKey 回源鉴权key + * @param string allowApps + * @param string ips + * @param string blackIpsEnable 是否开启ip黑名单 + * @param string externId 外部关联id + * @param string ignoreQueryString ignoreQueryString + * @param string referType referType + * @param string referList + * @param string allowNoReferHeader 允许无refer + * @param string allowNullReferHeader 允许空refer + * @param string publishNormalTimeout 推流中断超时时间(单位秒) + * @param string notifyCustomUrl 推断流通知Url + * @param string notifyCustomAuthKey 推断流通知key + * @param string certFrom 证书来源有两种类型:default,ssl + * @param string sslCertId ssl证书id + * @param string certName 证书名称 + * @param string certType 证书类型 + * @param string sslCertStartTime + * @param string sslCertEndTime + * @param string accelerateRegion + */ + + queryLiveDomainDetail (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryLiveDomainDetail" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryLiveDomainDetail 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( + '/liveDomain/{domain}', + '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) + } + ) + } + + /** + * 查询直播域名app列表 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + * @param string apps + * @param string domain 域名 + */ + + queryLiveDomainApps (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryLiveDomainApps" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryLiveDomainApps 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( + '/liveDomain/{domain}/app', + '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 {} [opts.urlList] - 预热的URL optional + * @param {} [opts.prefetchTime] - 预热时长 optional + * @param {} [opts.action] - 操作类型只能是[start,stop]中的一种 optional + * @param {string} callback - callback + @return {Object} result + */ + + createLiveDomainPrefecthTask (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.urlList !== undefined && opts.urlList !== null) { + postBody['urlList'] = opts.urlList + } + if (opts.prefetchTime !== undefined && opts.prefetchTime !== null) { + postBody['prefetchTime'] = opts.prefetchTime + } + if (opts.action !== undefined && opts.action !== null) { + postBody['action'] = opts.action + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 createLiveDomainPrefecthTask 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( + '/task:createLivePrefetchTask', + '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 {} [opts.urlList] - 预热的URL optional + * @param {string} callback - callback + @return {Object} result + * @param queryLivePrefetchItem result + */ + + queryLivePrefetchTask (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.urlList !== undefined && opts.urlList !== null) { + postBody['urlList'] = opts.urlList + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryLivePrefetchTask 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( + '/task:queryLivePrefetchTask', + '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) + } + ) + } + + /** + * null + * @param {Object} opts - parameters + * @param {string} callback - callback + @return {Object} result + * @param boolean canIPType true可以 + */ + + queryPinCanIPType (opts, callback) { + opts = opts || {} + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryPinCanIPType 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( + '/mix:queryPinCanIPType', + '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 {} [opts.tasks] optional + * @param {string} callback - callback + @return {Object} result + */ + + batCreatePrefetchTask (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.tasks !== undefined && opts.tasks !== null) { + postBody['tasks'] = opts.tasks + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 batCreatePrefetchTask 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( + '/prefetchTask:batCreate', + '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 {} [opts.url] - url optional + * @param {} [opts.region] - 地区[huabei huadong dongbei huazhong huanan xinan xibei gangaotai]中的一个 optional + * @param {} [opts.isp] - 运营商[ct uni cm]中的一个,分别代表电信 联通 移动 optional + * @param {} [opts.copyNum] - 副本数,介于1-1000之间 optional + * @param {string} callback - callback + @return {Object} result + */ + + updatePrefetchTask (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.url !== undefined && opts.url !== null) { + postBody['url'] = opts.url + } + if (opts.region !== undefined && opts.region !== null) { + postBody['region'] = opts.region + } + if (opts.isp !== undefined && opts.isp !== null) { + postBody['isp'] = opts.isp + } + if (opts.copyNum !== undefined && opts.copyNum !== null) { + postBody['copyNum'] = opts.copyNum + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 updatePrefetchTask 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( + '/prefetchTask:update', + '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 {} [opts.url] - url optional + * @param {} [opts.region] - 地区[huabei huadong dongbei huazhong huanan xinan xibei gangaotai]中的一个 optional + * @param {} [opts.isp] - 运营商[ct uni cm]中的一个,分别代表电信 联通 移动 optional + * @param {} [opts.status] - 查询状态 1:active维护预热中,2:表示purge中暂时停止预热 optional + * @param {} [opts.fileId] - 同url,系统内部url对应id(url和file_id同时存在时以url为准) optional + * @param {} [opts.pageNumber] - 页码数,最小为1 optional + * @param {} [opts.pageSize] - 每页大小,默认10 optional + * @param {} [opts.taskType] - 1:代表控制台下发的预热任务2:代表热度计算下发的预热任务3:代表控制台、热度计算共同下发的任务 optional + * @param {} [opts.domain] - 域名 optional + * @param {string} callback - callback + @return {Object} result + * @param integer totalNumber + * @param integer totalPage + * @param integer pageNumber + * @param integer pageSize + * @param prefetchTaskInfo taskList + */ + + queryPrefetchTask (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.url !== undefined && opts.url !== null) { + postBody['url'] = opts.url + } + if (opts.region !== undefined && opts.region !== null) { + postBody['region'] = opts.region + } + if (opts.isp !== undefined && opts.isp !== null) { + postBody['isp'] = opts.isp + } + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + if (opts.fileId !== undefined && opts.fileId !== null) { + postBody['fileId'] = opts.fileId + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + if (opts.taskType !== undefined && opts.taskType !== null) { + postBody['taskType'] = opts.taskType + } + if (opts.domain !== undefined && opts.domain !== null) { + postBody['domain'] = opts.domain + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryPrefetchTask 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( + '/prefetchTask:query', + '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 {} [opts.urls] - 待停止预热的url optional + * @param {} [opts.region] - 地区[huabei huadong dongbei huazhong huanan xinan xibei gangaotai]中的一个 optional + * @param {} [opts.isp] - 运营商[ct uni cm]中的一个,分别代表电信 联通 移动 optional + * @param {string} callback - callback + @return {Object} result + */ + + stopPrefetchTask (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.urls !== undefined && opts.urls !== null) { + postBody['urls'] = opts.urls + } + if (opts.region !== undefined && opts.region !== null) { + postBody['region'] = opts.region + } + if (opts.isp !== undefined && opts.isp !== null) { + postBody['isp'] = opts.isp + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 stopPrefetchTask 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( + '/prefetchTask:stop', + '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 {} [opts.urls] - 待刷新的url optional + * @param {} [opts.optType] - 操作类型:add代表创建刷新任务,stop代表停止刷新任务 optional + * @param {string} callback - callback + @return {Object} result + */ + + operatePurgeTask (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.urls !== undefined && opts.urls !== null) { + postBody['urls'] = opts.urls + } + if (opts.optType !== undefined && opts.optType !== null) { + postBody['optType'] = opts.optType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 operatePurgeTask 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( + '/purgeTask', + '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 {} [opts.url] - url optional + * @param {} [opts.status] - 查询状态 1:进行中 2:已完成 optional + * @param {} [opts.fileId] - 同url,系统内部url对应id(url和file_id同时存在时以url为准) optional + * @param {} [opts.pageNumber] - 页码数,最小为1 optional + * @param {} [opts.pageSize] - 每页大小,默认10 optional + * @param {} [opts.domain] - 域名 optional + * @param {string} callback - callback + @return {Object} result + * @param integer totalNumber + * @param integer totalPage + * @param integer pageNumber + * @param integer pageSize + * @param purgeTaskInfo taskList + */ + + queryPurgeTask (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.url !== undefined && opts.url !== null) { + postBody['url'] = opts.url + } + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + if (opts.fileId !== undefined && opts.fileId !== null) { + postBody['fileId'] = opts.fileId + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + if (opts.domain !== undefined && opts.domain !== null) { + postBody['domain'] = opts.domain + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryPurgeTask 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( + '/purgeTask:query', + '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} callback - callback + @return {Object} result + * @param integer dirAllCount 总的目录刷新上限 + * @param integer dirUsedCount 已使用的目录刷新个数 + * @param integer dirRemainedCount 剩余可用的目录刷新个数 + * @param integer forbiddenUrlRemainedCount 剩余可封禁的URL个数 + * @param integer forbiddenUrlUsedCount 已封禁的URL个数 + * @param integer forbiddenUrlAllCount 总的封禁URL上限 + * @param integer hasForbiddenDomainCount 已封禁的域名个数,即用户账号下对违法内容封禁的域名 + * @param integer prefetchRemainedCount 剩余可用的预热URL个数 + * @param integer prefetchAllCount 总的预热URL上限 + * @param integer prefetchUsedCount 已使用的预热URL个数 + * @param integer refreshAllCount 总的刷新URL上限 + * @param integer refreshRemainedCount 剩余可用的刷新URL个数 + * @param integer refreshUsedCount 已使用的刷新URL个数 + * @param integer totalUserDomainQuota 总的用户域名数上限; 即针对账号下可添加域名的总个数 + * @param integer usedUserDomainQuota 已使用的用户域名个数;即账号下已经添加的域名个数,包括停用域名、封禁域名等 + * @param integer remainUserDomainQuota 剩余可配置的用户域名个数 + */ + + queryCdnUserQuota (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryCdnUserQuota 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( + '/user:quota', + '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) + } + ) + } + + /** + * 根据taskIds查询刷新预热任务 + * @param {Object} opts - parameters + * @param {} [opts.taskIds] - 查询的任务taskIds列表,最多能查10条 optional + * @param {} [opts.keyword] - url的模糊查询关键字 optional + * @param {string} callback - callback + @return {Object} result + * @param refreshTask tasks + */ + + queryRefreshTaskByIds (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.taskIds !== undefined && opts.taskIds !== null) { + postBody['taskIds'] = opts.taskIds + } + if (opts.keyword !== undefined && opts.keyword !== null) { + postBody['keyword'] = opts.keyword + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryRefreshTaskByIds 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( + '/task:queryByIds', + '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 {} [opts.subUsers] - 子账号,只有传值才会设置子账号,其余不传或传空是设置主账号 optional + * @param {} [opts.refreshCount] - 刷新个数,如果是首次设置,不传默认是2000;已经设置,再次设置是更新,不传表示不进行更新 optional + * @param {} [opts.prefetchCount] - 刷新个数,如果是首次设置,不传默认是2000;已经设置,再次设置是更新,不传表示不进行更新 optional + * @param {} [opts.dirCount] - 刷新个数,如果是首次设置,不传默认是50;已经设置,再次设置是更新,不传表示不进行更新 optional + * @param {string} callback - callback + @return {Object} result + */ + + setRefreshLimit (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.subUsers !== undefined && opts.subUsers !== null) { + postBody['subUsers'] = opts.subUsers + } + if (opts.refreshCount !== undefined && opts.refreshCount !== null) { + postBody['refreshCount'] = opts.refreshCount + } + if (opts.prefetchCount !== undefined && opts.prefetchCount !== null) { + postBody['prefetchCount'] = opts.prefetchCount + } + if (opts.dirCount !== undefined && opts.dirCount !== null) { + postBody['dirCount'] = opts.dirCount + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setRefreshLimit 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( + '/task:configLimit', + '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 {} [opts.subUsers] - 子账号,传哪些子账号就查哪些的,不传或传空默认返回所有子账号的额度 optional + * @param {} [opts.pageNumber] - 默认为1 optional + * @param {} [opts.pageSize] - 默认为10,最大100 optional + * @param {string} callback - callback + @return {Object} result + * @param string user 主账号 + * @param integer refreshCount 主账号刷新个数 + * @param integer dirCount 主账号目录个数 + * @param integer prefetchCount 主账号预热个数 + * @param integer pageNumber 默认为1 + * @param integer pageSize 默认为10,最大100 + * @param integer total 默认为10,最大100 + * @param subUserRefreshLimit subUserQuota + */ + + queryRefreshLimit (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.subUsers !== undefined && opts.subUsers !== null) { + postBody['subUsers'] = opts.subUsers + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryRefreshLimit 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( + '/task:queryLimit', + '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) + } + ) + } + + /** + * 根据taskId查询刷新预热任务 + * @param {Object} opts - parameters + * @param {string} opts.taskId - 域名组id + * @param {string} callback - callback + @return {Object} result + * @param refreshTask task + */ + + queryRefreshTaskById (opts, callback) { + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling queryRefreshTaskById" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryRefreshTaskById 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( + '/task/{taskId}', + '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 {} [opts.taskType] - 刷新预热类型,(url:url刷新,dir:目录刷新,prefetch:预热) optional + * @param {} [opts.urlItems] optional + * @param {string} callback - callback + @return {Object} result + * @param integer errorCount 失败任务的个数 + * @param string taskId 任务的id + */ + + createRefreshTaskForCallback (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.taskType !== undefined && opts.taskType !== null) { + postBody['taskType'] = opts.taskType + } + if (opts.urlItems !== undefined && opts.urlItems !== null) { + postBody['urlItems'] = opts.urlItems + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 createRefreshTaskForCallback 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( + '/task:createForCallback', + '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 {} [opts.taskType] - 刷新预热类型,(url:url刷新,dir:目录刷新,prefetch:预热) optional + * @param {} [opts.urlItems] optional + * @param {string} callback - callback + @return {Object} result + * @param integer errorCount 失败任务的个数 + * @param string taskId 任务的id + */ + + createRefreshTaskForCallbackV2 (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.taskType !== undefined && opts.taskType !== null) { + postBody['taskType'] = opts.taskType + } + if (opts.urlItems !== undefined && opts.urlItems !== null) { + postBody['urlItems'] = opts.urlItems + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 createRefreshTaskForCallbackV2 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( + '/task:createForCallbackV2', + '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 {} [opts.startTime] - 查询起始时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.endTime] - 查询截止时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.keyword] - url或者目录的模糊查询关键字 optional + * @param {} [opts.taskId] - 任务id optional + * @param {} [opts.taskStatus] - null optional + * @param {} [opts.taskType] - null optional + * @param {} [opts.pageNumber] - 分页页数,默认值1 optional + * @param {} [opts.pageSize] - 分页页面大小,默认值50 optional + * @param {} [opts.accountType] - 查询的账号范围 optional + * @param {} [opts.subUsers] - 查询的子账号,多个用逗号隔开 optional + * @param {string} callback - callback + @return {Object} result + * @param integer total 总的刷新预热条数. + * @param refreshTask tasks + */ + + queryRefreshTask (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.keyword !== undefined && opts.keyword !== null) { + queryParams['keyword'] = opts.keyword + } + if (opts.taskId !== undefined && opts.taskId !== null) { + queryParams['taskId'] = opts.taskId + } + if (opts.taskStatus !== undefined && opts.taskStatus !== null) { + queryParams['taskStatus'] = opts.taskStatus + } + if (opts.taskType !== undefined && opts.taskType !== null) { + queryParams['taskType'] = opts.taskType + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + queryParams['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.accountType !== undefined && opts.accountType !== null) { + queryParams['accountType'] = opts.accountType + } + if (opts.subUsers !== undefined && opts.subUsers !== null) { + queryParams['subUsers'] = opts.subUsers + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryRefreshTask 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( + '/task', + '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 {} [opts.taskType] - 刷新预热类型,(url:url刷新,dir:目录刷新,prefetch:预热),中国境外/全球加速域名暂不支持预热功能 optional + * @param {} [opts.urls] optional + * @param {string} callback - callback + @return {Object} result + * @param integer errorCount 失败任务的个数 + * @param string taskId 任务的id + */ + + createRefreshTask (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.taskType !== undefined && opts.taskType !== null) { + postBody['taskType'] = opts.taskType + } + if (opts.urls !== undefined && opts.urls !== null) { + postBody['urls'] = opts.urls + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 createRefreshTask 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( + '/task', + '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} callback - callback + @return {Object} result + * @param string switchStatus 网络防护层总开关,取值on,off,其中on开启,off关闭 + * @param string srcNewConnLimitEnable 源新建连接限速,取值on,off,其中on开启,off关闭 + * @param string dstNewConnLimitEnable 目的新建连接,取值on,off,其中on开启,off关闭 + * @param integer datagramRangeMin 报文最小长度(包最小长度),取值:1-1500 + * @param integer datagramRangeMax 报文最大长度(包最大长度),取值:1-1500 + * @param integer srcNewConnLimitValue 源新建连接限速值,取值:0-4294967295 + * @param integer dstNewConnLimitValue 目的新建连接限速值,取值:0-4294967295 + * @param geoArea geoBlack + * @param string ipBlack + * @param string ipWhite + */ + + queryNetProtectionRules (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryNetProtectionRules 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( + '/netProtectionRules', + '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 {} [opts.srcNewConnLimitEnable] - 源新建连接限速,取值on,off,其中on开启,off关闭 optional + * @param {} [opts.dstNewConnLimitEnable] - 目的新建连接,取值on,off,其中on开启,off关闭 optional + * @param {} [opts.datagramRangeMin] - 报文最小长度(包最小长度),取值:1-1500 optional + * @param {} [opts.datagramRangeMax] - 报文最大长度(包最大长度),取值:1-1500 optional + * @param {} [opts.dstNewConnLimitValue] - 目的新建连接限速值,取值:0-4294967295 optional + * @param {} [opts.srcNewConnLimitValue] - 源新建连接限速值,取值:0-4294967295 optional + * @param {} [opts.geoBlack] - 地域黑名单(GEO IP拦截) optional + * @param {} [opts.ipBlack] - ip 黑名单 optional + * @param {} [opts.ipWhite] - ip 白名单 optional + * @param {string} callback - callback + @return {Object} result + */ + + setNetProtectionRules (opts, callback) { + opts = opts || {} + + let postBody = {} + if ( + opts.srcNewConnLimitEnable !== undefined && + opts.srcNewConnLimitEnable !== null + ) { + postBody['srcNewConnLimitEnable'] = opts.srcNewConnLimitEnable + } + if ( + opts.dstNewConnLimitEnable !== undefined && + opts.dstNewConnLimitEnable !== null + ) { + postBody['dstNewConnLimitEnable'] = opts.dstNewConnLimitEnable + } + if (opts.datagramRangeMin !== undefined && opts.datagramRangeMin !== null) { + postBody['datagramRangeMin'] = opts.datagramRangeMin + } + if (opts.datagramRangeMax !== undefined && opts.datagramRangeMax !== null) { + postBody['datagramRangeMax'] = opts.datagramRangeMax + } + if ( + opts.dstNewConnLimitValue !== undefined && + opts.dstNewConnLimitValue !== null + ) { + postBody['dstNewConnLimitValue'] = opts.dstNewConnLimitValue + } + if ( + opts.srcNewConnLimitValue !== undefined && + opts.srcNewConnLimitValue !== null + ) { + postBody['srcNewConnLimitValue'] = opts.srcNewConnLimitValue + } + if (opts.geoBlack !== undefined && opts.geoBlack !== null) { + postBody['geoBlack'] = opts.geoBlack + } + if (opts.ipBlack !== undefined && opts.ipBlack !== null) { + postBody['ipBlack'] = opts.ipBlack + } + if (opts.ipWhite !== undefined && opts.ipWhite !== null) { + postBody['ipWhite'] = opts.ipWhite + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setNetProtectionRules 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( + '/netProtectionRules', + '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} callback - callback + @return {Object} result + * @param string switchStatus on:开启,off:关闭 + */ + + queryNetProtectionRulesSwitch (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryNetProtectionRulesSwitch 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( + '/netProtectionSwitch', + '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 {} [opts.switchStatus] - on,off optional + * @param {string} callback - callback + @return {Object} result + */ + + setNetProtectionRulesSwitch (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.switchStatus !== undefined && opts.switchStatus !== null) { + postBody['switchStatus'] = opts.switchStatus + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setNetProtectionRulesSwitch 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( + '/netProtectionSwitch', + '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) + } + ) + } + + /** + * 查询geo地域 + * @param {Object} opts - parameters + * @param {string} callback - callback + @return {Object} result + * @param geoArea geoBlack + */ + + queryGeoAreas (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryGeoAreas 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( + '/netProtectionGeoAreas', + '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 {} [opts.startTime] - 查询起始时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2019-08-16T06:00:00Z optional + * @param {} [opts.endTime] - 查询截止时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2019-08-16T07:00:00Z optional + * @param {string} callback - callback + @return {Object} result + * @param attackTypeCount attackTypeCounts + */ + + queryAttackTypeCount (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryAttackTypeCount 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( + '/netProtectionData:attackTypeCount', + '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) + } + ) + } + + /** + * DDOS攻击报表接口 + * @param {Object} opts - parameters + * @param {} [opts.startTime] - 查询起始时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2019-08-16T06:00:00Z optional + * @param {} [opts.endTime] - 查询截止时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2019-08-16T07:00:00Z optional + * @param {string} callback - callback + @return {Object} result + * @param protectData dataList + * @param string unit + */ + + queryDdosGraph (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryDdosGraph 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( + '/netProtectionData:ddosGraph', + '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 {} [opts.startTime] - 查询起始时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2019-08-16T06:00:00Z optional + * @param {} [opts.endTime] - 查询截止时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2019-08-16T07:00:00Z optional + * @param {} [opts.pageNumber] - 页码 optional + * @param {} [opts.pageSize] - 分页条数 optional + * @param {} [opts.sortField] - 排序字段,默认传avgbandwidth optional + * @param {} [opts.sortRule] - 排序规则,默认是降序排序,传值asc或者desc optional + * @param {string} callback - callback + @return {Object} result + * @param integer currentCount 记录数 + * @param attackLogRecord dataList + * @param integer totalCount 总记录数 + * @param integer totalPage 总页数 + */ + + searchAttackLog (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + if (opts.sortField !== undefined && opts.sortField !== null) { + postBody['sortField'] = opts.sortField + } + if (opts.sortRule !== undefined && opts.sortRule !== null) { + postBody['sortRule'] = opts.sortRule + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 searchAttackLog 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( + '/netProtectionData:attackLog', + '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) + } + ) + } + + /** + * 获取所有上层节点的ip + * @param {Object} opts - parameters + * @param {string} callback - callback + @return {Object} result + * @param string ipList + */ + + getAllUpperNodeIpList (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 getAllUpperNodeIpList 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( + '/serviceNode:getAllUpperNodeIpList', + '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 {} [opts.id] - id 修改操作必传 optional + * @param {} [opts.noticeType] - 通知类型,取值[reportForm],reportForm:报表. optional + * @param {} [opts.noticeWay] - 通知方式,取值[mail],mail:邮件. optional + * @param {} [opts.noticeTo] - 通知接收人,多个用逗号隔开. optional + * @param {} [opts.noticeCC] - 通知抄送人,多个用逗号隔开. optional + * @param {} [opts.noticeContent] - 通知正文. optional + * @param {} [opts.noticePeriod] - 通知周期,取值[daily,weekly,monthly]. optional + * @param {} [opts.noticeStatus] - 通知状态,取值[init,start,stop] optional + * @param {string} callback - callback + @return {Object} result + */ + + configServiceNotice (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.id !== undefined && opts.id !== null) { + postBody['id'] = opts.id + } + if (opts.noticeType !== undefined && opts.noticeType !== null) { + postBody['noticeType'] = opts.noticeType + } + if (opts.noticeWay !== undefined && opts.noticeWay !== null) { + postBody['noticeWay'] = opts.noticeWay + } + if (opts.noticeTo !== undefined && opts.noticeTo !== null) { + postBody['noticeTo'] = opts.noticeTo + } + if (opts.noticeCC !== undefined && opts.noticeCC !== null) { + postBody['noticeCC'] = opts.noticeCC + } + if (opts.noticeContent !== undefined && opts.noticeContent !== null) { + postBody['noticeContent'] = opts.noticeContent + } + if (opts.noticePeriod !== undefined && opts.noticePeriod !== null) { + postBody['noticePeriod'] = opts.noticePeriod + } + if (opts.noticeStatus !== undefined && opts.noticeStatus !== null) { + postBody['noticeStatus'] = opts.noticeStatus + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 configServiceNotice 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( + '/serviceNotice:config', + '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.noticeType] - 通知类型,取值[reportForm],reportForm:报表. optional + * @param {string} [opts.noticeWay] - 通知方式,取值[mail],mail:邮件. optional + * @param {string} callback - callback + @return {Object} result + * @param serviceNoticeItem notices + */ + + queryServiceNotice (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.noticeType !== undefined && opts.noticeType !== null) { + queryParams['noticeType'] = opts.noticeType + } + if (opts.noticeWay !== undefined && opts.noticeWay !== null) { + queryParams['noticeWay'] = opts.noticeWay + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryServiceNotice 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( + '/serviceNotice', + '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开始计数 optional + * @param {integer} [opts.pageSize] - 每页显示的数目 optional + * @param {string} [opts.domain] - 域名,支持按照域名检索证书 optional + * @param {string} callback - callback + @return {Object} result + * @param sslCertModel certList + * @param integer totalCount 总数量 + */ + + getSslCertList (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 + } + if (opts.domain !== undefined && opts.domain !== null) { + queryParams['domain'] = opts.domain + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 getSslCertList 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( + '/sslCert', + '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.sslCertId - 证书 Id + * @param {string} callback - callback + @return {Object} result + * @param sslCertModelDetail sslCertModelDetail + */ + + getSslCertDetail (opts, callback) { + opts = opts || {} + + if (opts.sslCertId === undefined || opts.sslCertId === null) { + throw new Error( + "Missing the required parameter 'opts.sslCertId' when calling getSslCertDetail" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + sslCertId: opts.sslCertId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 getSslCertDetail 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( + '/sslCert/{sslCertId}', + '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.certName - 证书名称 + * @param {string} opts.keyFile - 私钥 + * @param {string} opts.certFile - 证书 + * @param {string} [opts.aliasName] - 证书别名 optional + * @param {string} callback - callback + @return {Object} result + * @param string certId + * @param string digest 对私钥文件使用sha256算法计算的摘要信息 + */ + + uploadCert (opts, callback) { + opts = opts || {} + + if (opts.certName === undefined || opts.certName === null) { + throw new Error( + "Missing the required parameter 'opts.certName' when calling uploadCert" + ) + } + if (opts.keyFile === undefined || opts.keyFile === null) { + throw new Error( + "Missing the required parameter 'opts.keyFile' when calling uploadCert" + ) + } + if (opts.certFile === undefined || opts.certFile === null) { + throw new Error( + "Missing the required parameter 'opts.certFile' when calling uploadCert" + ) + } + + let postBody = {} + if (opts.certName !== undefined && opts.certName !== null) { + postBody['certName'] = opts.certName + } + if (opts.keyFile !== undefined && opts.keyFile !== null) { + postBody['keyFile'] = opts.keyFile + } + if (opts.certFile !== undefined && opts.certFile !== null) { + postBody['certFile'] = opts.certFile + } + if (opts.aliasName !== undefined && opts.aliasName !== null) { + postBody['aliasName'] = opts.aliasName + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 uploadCert 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( + '/sslCert:upload', + '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 {} [opts.startTime] - 查询起始时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.endTime] - 查询截止时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.domain] - 需要查询的域名, 必须为用户pin下有权限的域名 optional + * @param {} [opts.fields] - 需要查询的字段 optional + * @param {} [opts.area] - 查询的区域,如beijing,shanghai。多个用逗号分隔 optional + * @param {} [opts.isp] - 查询的运营商,cmcc,cnc,ct,表示移动、联通、电信。多个用逗号分隔 optional + * @param {} [opts.period] - 时间粒度,可选值:[oneMin,fiveMin,followTime],followTime只会返回一个汇总后的数据 optional + * @param {} [opts.scheme] - 查询协议,可选值:[http,https,all],传空默认返回全部协议汇总后的数据 optional + * @param {} [opts.cacheType] - 查询节点层级,可选值:[all,edge,mid],默认查询all,edge边缘 mid中间 optional + * @param {} [opts.ipType] - 查询IP类型,可选值:[,ipv4,ipv6],默认查询all optional + * @param {string} callback - callback + @return {Object} result + * @param string startTime + * @param string endTime + * @param string domain + * @param statisticsDataItem statistics + */ + + queryMixStatisticsData (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.domain !== undefined && opts.domain !== null) { + postBody['domain'] = opts.domain + } + if (opts.fields !== undefined && opts.fields !== null) { + postBody['fields'] = opts.fields + } + if (opts.area !== undefined && opts.area !== null) { + postBody['area'] = opts.area + } + if (opts.isp !== undefined && opts.isp !== null) { + postBody['isp'] = opts.isp + } + if (opts.period !== undefined && opts.period !== null) { + postBody['period'] = opts.period + } + if (opts.scheme !== undefined && opts.scheme !== null) { + postBody['scheme'] = opts.scheme + } + if (opts.cacheType !== undefined && opts.cacheType !== null) { + postBody['cacheType'] = opts.cacheType + } + if (opts.ipType !== undefined && opts.ipType !== null) { + postBody['ipType'] = opts.ipType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryMixStatisticsData 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( + '/statistics', + '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 {} [opts.startTime] - 查询起始时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.endTime] - 查询截止时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.domain] - 需要查询的域名, 必须为用户pin下有权限的域名 optional + * @param {} [opts.fields] - 需要查询的字段 optional + * @param {} [opts.area] - 查询的区域,如beijing,shanghai。多个用逗号分隔 optional + * @param {} [opts.isp] - 查询的运营商,cmcc,cnc,ct,表示移动、联通、电信。多个用逗号分隔 optional + * @param {} [opts.period] - 时间粒度,可选值:[oneMin,fiveMin,followTime],followTime只会返回一个汇总后的数据 optional + * @param {} [opts.cacheType] - 查询节点层级,可选值:[all,edge,mid],默认查询all,edge边缘 mid中间 optional + * @param {} [opts.ipType] - 查询IP类型,可选值:[,ipv4,ipv6],默认查询all optional + * @param {string} callback - callback + @return {Object} result + * @param string startTime + * @param string endTime + * @param string domain + * @param statisticsWithAreaGroupDetail statistics + */ + + queryMixStatisticsWithAreaData (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.domain !== undefined && opts.domain !== null) { + postBody['domain'] = opts.domain + } + if (opts.fields !== undefined && opts.fields !== null) { + postBody['fields'] = opts.fields + } + if (opts.area !== undefined && opts.area !== null) { + postBody['area'] = opts.area + } + if (opts.isp !== undefined && opts.isp !== null) { + postBody['isp'] = opts.isp + } + if (opts.period !== undefined && opts.period !== null) { + postBody['period'] = opts.period + } + if (opts.cacheType !== undefined && opts.cacheType !== null) { + postBody['cacheType'] = opts.cacheType + } + if (opts.ipType !== undefined && opts.ipType !== null) { + postBody['ipType'] = opts.ipType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryMixStatisticsWithAreaData 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( + '/statistics:groupByArea', + '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 {} [opts.startTime] - 查询起始时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.endTime] - 查询截止时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.domain] - 需要查询的域名, 必须为用户pin下有权限的域名 optional + * @param {} [opts.fields] - 需要查询的字段 optional + * @param {} [opts.area] - 查询的区域,如beijing,shanghai。多个用逗号分隔 optional + * @param {} [opts.isp] - 查询的运营商,cmcc,cnc,ct,表示移动、联通、电信。多个用逗号分隔 optional + * @param {} [opts.period] - 时间粒度,可选值:[oneMin,fiveMin,followTime],followTime只会返回一个汇总后的数据 optional + * @param {} [opts.groupBy] - 分组依据,只能按域名[domain]分组 optional + * @param {} [opts.cacheType] - 查询节点层级,可选值:[all,edge,mid],默认查询all,edge边缘 mid中间 optional + * @param {} [opts.ipType] - 查询IP类型,可选值:[,ipv4,ipv6],默认查询all optional + * @param {string} callback - callback + @return {Object} result + * @param string startTime + * @param string endTime + * @param string domain + * @param statisticsGroupSumDataItem statistics + */ + + queryMixTrafficGroupSum (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.domain !== undefined && opts.domain !== null) { + postBody['domain'] = opts.domain + } + if (opts.fields !== undefined && opts.fields !== null) { + postBody['fields'] = opts.fields + } + if (opts.area !== undefined && opts.area !== null) { + postBody['area'] = opts.area + } + if (opts.isp !== undefined && opts.isp !== null) { + postBody['isp'] = opts.isp + } + if (opts.period !== undefined && opts.period !== null) { + postBody['period'] = opts.period + } + if (opts.groupBy !== undefined && opts.groupBy !== null) { + postBody['groupBy'] = opts.groupBy + } + if (opts.cacheType !== undefined && opts.cacheType !== null) { + postBody['cacheType'] = opts.cacheType + } + if (opts.ipType !== undefined && opts.ipType !== null) { + postBody['ipType'] = opts.ipType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryMixTrafficGroupSum 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( + '/statistics:groupSum', + '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 {} [opts.startTime] - 查询起始时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.endTime] - 查询截止时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.domain] - 需要查询的域名, 必须为用户pin下有权限的域名 optional + * @param {} [opts.subDomain] - 查询泛域名时,指定的子域名列表,多个用逗号分隔。非泛域名时,传入空即可 optional + * @param {} [opts.fields] - 需要查询的字段 optional + * @param {} [opts.area] - 查询的区域,如beijing,shanghai。多个用逗号分隔 optional + * @param {} [opts.isp] - 查询的运营商,cmcc,cnc,ct,表示移动、联通、电信。多个用逗号分隔 optional + * @param {} [opts.origin] - 是否查询回源统计信息。取值为true和false,默认为false。注意,如果查询回源信息,Fields的取值当前只支持oribandwidth,oripv,oricodestat三个,其余Fields忽略。 optional + * @param {} [opts.period] - 时间粒度,可选值:[oneMin,fiveMin,followTime],followTime只会返回一个汇总后的数据 optional + * @param {} [opts.abroad] - true 代表查询境外数据,默认false查询境内数据 optional + * @param {} [opts.cacheType] - 查询节点层级,可选值:[all,edge,mid],默认查询all,edge边缘 mid中间 optional + * @param {} [opts.ipType] - 查询IP类型,可选值:[,ipv4,ipv6],默认查询all optional + * @param {string} callback - callback + @return {Object} result + * @param string startTime + * @param string endTime + * @param string domain + * @param statisticsDataItem statistics + */ + + queryStatisticsData (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.domain !== undefined && opts.domain !== null) { + postBody['domain'] = opts.domain + } + if (opts.subDomain !== undefined && opts.subDomain !== null) { + postBody['subDomain'] = opts.subDomain + } + if (opts.fields !== undefined && opts.fields !== null) { + postBody['fields'] = opts.fields + } + if (opts.area !== undefined && opts.area !== null) { + postBody['area'] = opts.area + } + if (opts.isp !== undefined && opts.isp !== null) { + postBody['isp'] = opts.isp + } + if (opts.origin !== undefined && opts.origin !== null) { + postBody['origin'] = opts.origin + } + if (opts.period !== undefined && opts.period !== null) { + postBody['period'] = opts.period + } + if (opts.abroad !== undefined && opts.abroad !== null) { + postBody['abroad'] = opts.abroad + } + if (opts.cacheType !== undefined && opts.cacheType !== null) { + postBody['cacheType'] = opts.cacheType + } + if (opts.ipType !== undefined && opts.ipType !== null) { + postBody['ipType'] = opts.ipType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryStatisticsData 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( + '/vodStatistics', + '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 {} [opts.startTime] - 查询起始时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.endTime] - 查询截止时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.domain] - 需要查询的域名, 必须为用户pin下有权限的域名 optional + * @param {} [opts.subDomain] - 查询泛域名时,指定的子域名列表,多个用逗号分隔。非泛域名时,传入空即可 optional + * @param {} [opts.fields] - 需要查询的字段 optional + * @param {} [opts.area] - 查询的区域,如beijing,shanghai。多个用逗号分隔 optional + * @param {} [opts.isp] - 查询的运营商,cmcc,cnc,ct,表示移动、联通、电信。多个用逗号分隔 optional + * @param {} [opts.origin] - 是否查询回源统计信息。取值为true和false,默认为false。注意,如果查询回源信息,Fields的取值当前只支持oribandwidth,oripv,oricodestat三个,其余Fields忽略 optional + * @param {} [opts.period] - 时间粒度,可选值:[oneMin,fiveMin,followTime],followTime只会返回一个汇总后的数据 optional + * @param {} [opts.groupBy] - 分组依据,可选值:[terminal,sdtfrom],如果为空,则只按area/isp进行group optional + * @param {} [opts.scheme] - 查询协议,可选值:[http,https,all],传空默认返回全部协议汇总后的数据 optional + * @param {} [opts.abroad] - true 代表查询境外数据,默认false查询境内数据 optional + * @param {} [opts.cacheType] - 查询节点层级,可选值:[all,edge,mid],默认查询all,edge边缘 mid中间 optional + * @param {} [opts.ipType] - 查询IP类型,可选值:[,ipv4,ipv6],默认查询all optional + * @param {string} callback - callback + @return {Object} result + * @param string startTime + * @param string endTime + * @param string domain + * @param statisticsWithAreaGroupDetail statistics + */ + + queryStatisticsDataGroupByArea (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.domain !== undefined && opts.domain !== null) { + postBody['domain'] = opts.domain + } + if (opts.subDomain !== undefined && opts.subDomain !== null) { + postBody['subDomain'] = opts.subDomain + } + if (opts.fields !== undefined && opts.fields !== null) { + postBody['fields'] = opts.fields + } + if (opts.area !== undefined && opts.area !== null) { + postBody['area'] = opts.area + } + if (opts.isp !== undefined && opts.isp !== null) { + postBody['isp'] = opts.isp + } + if (opts.origin !== undefined && opts.origin !== null) { + postBody['origin'] = opts.origin + } + if (opts.period !== undefined && opts.period !== null) { + postBody['period'] = opts.period + } + if (opts.groupBy !== undefined && opts.groupBy !== null) { + postBody['groupBy'] = opts.groupBy + } + if (opts.scheme !== undefined && opts.scheme !== null) { + postBody['scheme'] = opts.scheme + } + if (opts.abroad !== undefined && opts.abroad !== null) { + postBody['abroad'] = opts.abroad + } + if (opts.cacheType !== undefined && opts.cacheType !== null) { + postBody['cacheType'] = opts.cacheType + } + if (opts.ipType !== undefined && opts.ipType !== null) { + postBody['ipType'] = opts.ipType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryStatisticsDataGroupByArea 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( + '/vodStatistics:groupByArea', + '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 {} [opts.startTime] - 查询起始时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.endTime] - 查询截止时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.domain] - 需要查询的域名, 必须为用户pin下有权限的域名 optional + * @param {} [opts.subDomain] - 查询泛域名时,指定的子域名列表,多个用逗号分隔。非泛域名时,传入空即可 optional + * @param {} [opts.fields] - 需要查询的字段 optional + * @param {} [opts.area] - 查询的区域,如beijing,shanghai。多个用逗号分隔 optional + * @param {} [opts.isp] - 查询的运营商,cmcc,cnc,ct,表示移动、联通、电信。多个用逗号分隔 optional + * @param {} [opts.origin] - 是否查询回源统计信息。取值为true和false,默认为false。注意,如果查询回源信息,Fields的取值当前只支持oribandwidth,oripv,oricodestat三个,其余Fields忽略。 optional + * @param {} [opts.period] - 时间粒度,可选值:[oneMin,fiveMin,followTime],followTime只会返回一个汇总后的数据 optional + * @param {} [opts.groupBy] - 分组依据,可选值:[area,isp,domain,scheme] optional + * @param {} [opts.abroad] - true 代表查询境外数据,默认false查询境内数据 optional + * @param {} [opts.cacheType] - 查询节点层级,可选值:[all,edge,mid],默认查询all,edge边缘 mid中间 optional + * @param {} [opts.ipType] - 查询IP类型,可选值:[,ipv4,ipv6],默认查询all optional + * @param {string} callback - callback + @return {Object} result + * @param string startTime + * @param string endTime + * @param string domain + * @param statisticsGroupSumDataItem statistics + */ + + queryStatisticsDataGroupSum (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.domain !== undefined && opts.domain !== null) { + postBody['domain'] = opts.domain + } + if (opts.subDomain !== undefined && opts.subDomain !== null) { + postBody['subDomain'] = opts.subDomain + } + if (opts.fields !== undefined && opts.fields !== null) { + postBody['fields'] = opts.fields + } + if (opts.area !== undefined && opts.area !== null) { + postBody['area'] = opts.area + } + if (opts.isp !== undefined && opts.isp !== null) { + postBody['isp'] = opts.isp + } + if (opts.origin !== undefined && opts.origin !== null) { + postBody['origin'] = opts.origin + } + if (opts.period !== undefined && opts.period !== null) { + postBody['period'] = opts.period + } + if (opts.groupBy !== undefined && opts.groupBy !== null) { + postBody['groupBy'] = opts.groupBy + } + if (opts.abroad !== undefined && opts.abroad !== null) { + postBody['abroad'] = opts.abroad + } + if (opts.cacheType !== undefined && opts.cacheType !== null) { + postBody['cacheType'] = opts.cacheType + } + if (opts.ipType !== undefined && opts.ipType !== null) { + postBody['ipType'] = opts.ipType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryStatisticsDataGroupSum 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( + '/vodStatistics:groupSum', + '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 {} [opts.startTime] - 查询起始时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.endTime] - 查询截止时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.domain] - 需要查询的域名, 必须为用户pin下有权限的域名 optional + * @param {} [opts.appName] - app名,查询的App名称,多个用逗号分隔。注意,传如多个AppName时,表示查询这些AppName的和值,即“或”的关系。默认为空,表示查询所有App optional + * @param {} [opts.streamName] - 流名,查询的流名称,多个用逗号分隔。注意,传如多个StreamName时,表示查询这些StreamName的和值,即“或”的关系。默认为空,表示查询所有Stream optional + * @param {} [opts.subDomain] - 子域名,查询泛域名时,指定的子域名列表,多个用逗号分隔。非泛域名时,传入空即可 optional + * @param {} [opts.fields] - 需要查询的字段 optional + * @param {} [opts.area] - 查询的区域,如beijing,shanghai。多个用逗号分隔 optional + * @param {} [opts.isp] - 查询的运营商,cmcc,cnc,ct,表示移动、联通、电信。多个用逗号分隔 optional + * @param {} [opts.reqMethod] - 当前取值范围("GET,HEAD,forward,forward-hls,ingest,play,publish,detour-ingest,Forward-Origin") optional + * @param {} [opts.scheme] - 查询的流协议类型,取值范围:"rtmp,hdl,hls",多个用逗号分隔,默认为空,表示查询所有协议。 optional + * @param {} [opts.cacheLevel] - cacheLevel,可选值:[L1,L2,L3] optional + * @param {} [opts.period] - 时间粒度,可选值:[oneMin,fiveMin,followTime],followTime只会返回一个汇总后的数据 optional + * @param {} [opts.cacheType] - 查询节点层级,可选值:[all,edge,mid],默认查询all,edge边缘 mid中间 optional + * @param {string} callback - callback + @return {Object} result + * @param string startTime + * @param string endTime + * @param string domain + * @param statisticsDataItem statistics + */ + + queryLiveStatisticsData (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.domain !== undefined && opts.domain !== null) { + postBody['domain'] = opts.domain + } + if (opts.appName !== undefined && opts.appName !== null) { + postBody['appName'] = opts.appName + } + if (opts.streamName !== undefined && opts.streamName !== null) { + postBody['streamName'] = opts.streamName + } + if (opts.subDomain !== undefined && opts.subDomain !== null) { + postBody['subDomain'] = opts.subDomain + } + if (opts.fields !== undefined && opts.fields !== null) { + postBody['fields'] = opts.fields + } + if (opts.area !== undefined && opts.area !== null) { + postBody['area'] = opts.area + } + if (opts.isp !== undefined && opts.isp !== null) { + postBody['isp'] = opts.isp + } + if (opts.reqMethod !== undefined && opts.reqMethod !== null) { + postBody['reqMethod'] = opts.reqMethod + } + if (opts.scheme !== undefined && opts.scheme !== null) { + postBody['scheme'] = opts.scheme + } + if (opts.cacheLevel !== undefined && opts.cacheLevel !== null) { + postBody['cacheLevel'] = opts.cacheLevel + } + if (opts.period !== undefined && opts.period !== null) { + postBody['period'] = opts.period + } + if (opts.cacheType !== undefined && opts.cacheType !== null) { + postBody['cacheType'] = opts.cacheType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryLiveStatisticsData 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( + '/liveStatistics', + '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 {} [opts.startTime] - 查询起始时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.endTime] - 查询截止时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.domain] - 需要查询的域名, 必须为用户pin下有权限的域名 optional + * @param {} [opts.appName] - 查询的App名称,多个用逗号分隔。 optional + * @param {} [opts.fields] - 需要查询的字段 optional + * @param {} [opts.area] - 查询的区域,如beijing,shanghai。多个用逗号分隔 optional + * @param {} [opts.isp] - 查询的运营商,cmcc,cnc,ct,表示移动、联通、电信。多个用逗号分隔 optional + * @param {} [opts.streamName] - 查询的流名称,多个用逗号分隔。 optional + * @param {} [opts.period] - 时间粒度,可选值:[oneMin,fiveMin,followTime],followTime只会返回一个汇总后的数据 optional + * @param {} [opts.groupBy] - 分组依据,可选值:[appname,streamname],如果为空,则只按area/isp进行group。 optional + * @param {} [opts.subDomain] - 查询泛域名时,指定的子域名列表,多个用逗号分隔。非泛域名时,传入空即可 optional + * @param {} [opts.scheme] - 查询的流协议,取值范围:"rtmp,hdl,hls",多个用逗号分隔,默认为空,表示查询所有协议。 optional + * @param {} [opts.reqMethod] - 当前取值范围("GET,HEAD,forward,forward-hls,ingest,play,publish,detour-ingest,Forward-Origin") optional + * @param {} [opts.cacheLevel] - cacheLevel,可选值:[L1,L2,L3] optional + * @param {} [opts.cacheType] - 查询节点层级,可选值:[all,edge,mid],默认查询all,edge边缘 mid中间 optional + * @param {string} callback - callback + @return {Object} result + * @param string startTime + * @param string endTime + * @param string domain + * @param statisticsWithAreaGroupDetail statistics + */ + + queryLiveStatisticsAreaDataGroupBy (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.domain !== undefined && opts.domain !== null) { + postBody['domain'] = opts.domain + } + if (opts.appName !== undefined && opts.appName !== null) { + postBody['appName'] = opts.appName + } + if (opts.fields !== undefined && opts.fields !== null) { + postBody['fields'] = opts.fields + } + if (opts.area !== undefined && opts.area !== null) { + postBody['area'] = opts.area + } + if (opts.isp !== undefined && opts.isp !== null) { + postBody['isp'] = opts.isp + } + if (opts.streamName !== undefined && opts.streamName !== null) { + postBody['streamName'] = opts.streamName + } + if (opts.period !== undefined && opts.period !== null) { + postBody['period'] = opts.period + } + if (opts.groupBy !== undefined && opts.groupBy !== null) { + postBody['groupBy'] = opts.groupBy + } + if (opts.subDomain !== undefined && opts.subDomain !== null) { + postBody['subDomain'] = opts.subDomain + } + if (opts.scheme !== undefined && opts.scheme !== null) { + postBody['scheme'] = opts.scheme + } + if (opts.reqMethod !== undefined && opts.reqMethod !== null) { + postBody['reqMethod'] = opts.reqMethod + } + if (opts.cacheLevel !== undefined && opts.cacheLevel !== null) { + postBody['cacheLevel'] = opts.cacheLevel + } + if (opts.cacheType !== undefined && opts.cacheType !== null) { + postBody['cacheType'] = opts.cacheType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryLiveStatisticsAreaDataGroupBy 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( + '/liveStatistics:groupByArea', + '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 {} [opts.startTime] - 查询起始时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.endTime] - 查询截止时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.domain] - 需要查询的域名, 必须为用户pin下有权限的域名 optional + * @param {} [opts.subDomain] - 查询泛域名时,指定的子域名列表,多个用逗号分隔。非泛域名时,传入空即可 optional + * @param {} [opts.appName] - 查询的App名称,多个用逗号分隔。 optional + * @param {} [opts.streamName] - 查询的流名称,多个用逗号分隔。 optional + * @param {} [opts.fields] - 需要查询的字段 optional + * @param {} [opts.area] - 查询的区域,如beijing,shanghai。多个用逗号分隔 optional + * @param {} [opts.isp] - 查询的运营商,cmcc,cnc,ct,表示移动、联通、电信。多个用逗号分隔 optional + * @param {} [opts.scheme] - 查询的流协议,取值范围:"rtmp,hdl,hls",多个用逗号分隔,默认为空,表示查询所有协议。 optional + * @param {} [opts.period] - 时间粒度,可选值:[oneMin,fiveMin,followTime],followTime只会返回一个汇总后的数据 optional + * @param {} [opts.groupBy] - 分组依据,可选值:[appname,streamname,domain,area,isp,scheme] optional + * @param {} [opts.reqMethod] - 当前取值范围("GET,HEAD,forward,forward-hls,ingest,play,publish,detour-ingest,Forward-Origin") optional + * @param {} [opts.cacheLevel] - cacheLevel,可选值:[L1,L2,L3] optional + * @param {} [opts.cacheType] - 查询节点层级,可选值:[all,edge,mid],默认查询all,edge边缘 mid中间 optional + * @param {string} callback - callback + @return {Object} result + * @param string startTime + * @param string endTime + * @param string domain + * @param statisticsGroupSumDataItem statistics + */ + + queryLiveTrafficGroupSum (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.domain !== undefined && opts.domain !== null) { + postBody['domain'] = opts.domain + } + if (opts.subDomain !== undefined && opts.subDomain !== null) { + postBody['subDomain'] = opts.subDomain + } + if (opts.appName !== undefined && opts.appName !== null) { + postBody['appName'] = opts.appName + } + if (opts.streamName !== undefined && opts.streamName !== null) { + postBody['streamName'] = opts.streamName + } + if (opts.fields !== undefined && opts.fields !== null) { + postBody['fields'] = opts.fields + } + if (opts.area !== undefined && opts.area !== null) { + postBody['area'] = opts.area + } + if (opts.isp !== undefined && opts.isp !== null) { + postBody['isp'] = opts.isp + } + if (opts.scheme !== undefined && opts.scheme !== null) { + postBody['scheme'] = opts.scheme + } + if (opts.period !== undefined && opts.period !== null) { + postBody['period'] = opts.period + } + if (opts.groupBy !== undefined && opts.groupBy !== null) { + postBody['groupBy'] = opts.groupBy + } + if (opts.reqMethod !== undefined && opts.reqMethod !== null) { + postBody['reqMethod'] = opts.reqMethod + } + if (opts.cacheLevel !== undefined && opts.cacheLevel !== null) { + postBody['cacheLevel'] = opts.cacheLevel + } + if (opts.cacheType !== undefined && opts.cacheType !== null) { + postBody['cacheType'] = opts.cacheType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryLiveTrafficGroupSum 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( + '/liveStatistics:groupSum', + '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) + } + ) + } + + /** + * 查询TOP IP,仅可查询中国境内的相关信息 + * @param {Object} opts - parameters + * @param {} [opts.startTime] - 查询起始时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.endTime] - 查询截止时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.domain] - 需要查询的域名, 必须为用户pin下有权限的域名 optional + * @param {} [opts.subDomain] - 待查询的子域名,查询泛域名时,指定的子域名列表,多个用逗号分隔。非泛域名时,传入空即可 optional + * @param {} [opts.size] - 查询的topN的条数,取值范围:1-100,默认为20 optional + * @param {} [opts.topBy] - 排序依据,当前可选:pv,flow, 分别表示按pv、按流量topN ip,默认为"pv" optional + * @param {string} callback - callback + @return {Object} result + * @param string startTime + * @param string endTime + * @param string domain + * @param statisticsTopIpData ipData + */ + + queryStatisticsTopIp (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.domain !== undefined && opts.domain !== null) { + postBody['domain'] = opts.domain + } + if (opts.subDomain !== undefined && opts.subDomain !== null) { + postBody['subDomain'] = opts.subDomain + } + if (opts.size !== undefined && opts.size !== null) { + postBody['size'] = opts.size + } + if (opts.topBy !== undefined && opts.topBy !== null) { + postBody['topBy'] = opts.topBy + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryStatisticsTopIp 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( + '/statistics:topIp', + '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) + } + ) + } + + /** + * 查询TOP Url,仅可查询中国境内的相关信息 + * @param {Object} opts - parameters + * @param {} [opts.startTime] - 查询起始时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.endTime] - 查询截止时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.domain] - 需要查询的域名, 必须为用户pin下有权限的域名 optional + * @param {} [opts.subDomain] - 待查询的子域名,查询泛域名时,指定的子域名列表,多个用逗号分隔。非泛域名时,传入空即可 optional + * @param {} [opts.size] - 查询的topN的条数,取值范围:1-100,默认为20 optional + * @param {} [opts.topBy] - 排序依据,当前可选:pv,flow,bandwidth, 分别表示按pv、按流量、按带宽topN url,默认为"pv" optional + * @param {string} callback - callback + @return {Object} result + * @param string startTime + * @param string endTime + * @param string domain + * @param statisticsTopUrlData urlData + */ + + queryStatisticsTopUrl (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.domain !== undefined && opts.domain !== null) { + postBody['domain'] = opts.domain + } + if (opts.subDomain !== undefined && opts.subDomain !== null) { + postBody['subDomain'] = opts.subDomain + } + if (opts.size !== undefined && opts.size !== null) { + postBody['size'] = opts.size + } + if (opts.topBy !== undefined && opts.topBy !== null) { + postBody['topBy'] = opts.topBy + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryStatisticsTopUrl 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( + '/statistics:topUrl', + '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 {} [opts.startTime] - 查询起始时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.endTime] - 查询截止时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.domain] - 需要查询的域名, 必须为用户pin下有权限的域名,该接口仅支持单域名查询 optional + * @param {} [opts.dirs] - 需要过滤的目录 optional + * @param {} [opts.regions] - 需要过滤的地区 optional + * @param {} [opts.cacheType] - 查询节点层级,可选值:[all,edge,mid],默认查询all,edge边缘 mid中间 optional + * @param {string} callback - callback + @return {Object} result + * @param string domain + * @param dirBandwidthItem datas + */ + + queryDirBandwidth (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.domain !== undefined && opts.domain !== null) { + postBody['domain'] = opts.domain + } + if (opts.dirs !== undefined && opts.dirs !== null) { + postBody['dirs'] = opts.dirs + } + if (opts.regions !== undefined && opts.regions !== null) { + postBody['regions'] = opts.regions + } + if (opts.cacheType !== undefined && opts.cacheType !== null) { + postBody['cacheType'] = opts.cacheType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryDirBandwidth 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( + '/statistics:queryDirBandwidth', + '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 {} [opts.startTime] - 查询起始时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.endTime] - 查询截止时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.domain] - 需要查询的域名, 必须为用户pin下有权限的域名,该接口仅支持单域名查询 optional + * @param {} [opts.dirs] - 需要过滤的目录 optional + * @param {} [opts.cacheType] - 查询节点层级,可选值:[all,edge,mid],默认查询all,edge边缘 mid中间 optional + * @param {string} callback - callback + @return {Object} result + * @param string domain + * @param dirStatsItem datas + */ + + queryDirStatsData (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.domain !== undefined && opts.domain !== null) { + postBody['domain'] = opts.domain + } + if (opts.dirs !== undefined && opts.dirs !== null) { + postBody['dirs'] = opts.dirs + } + if (opts.cacheType !== undefined && opts.cacheType !== null) { + postBody['cacheType'] = opts.cacheType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryDirStatsData 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( + '/statistics:queryDirStatsData', + '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 {} [opts.startTime] - 查询起始时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2020-12-07T16:00:00Z optional + * @param {} [opts.endTime] - 查询截止时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2020-12-07T16:20:00Z,开始时间和结束时间跨度 不能超过4个小时 optional + * @param {} [opts.domain] - 需要查询的域名, 必须为用户pin下有权限的域名,该接口仅支持单域名查询 optional + * @param {} [opts.dir] - 需要过滤的目录,以正斜线(/)开头,不填表示查询所有目录。查询目录同时需要以正斜线(/)结尾。 如:/path1/path2/path3/ optional + * @param {string} callback - callback + @return {Object} result + * @param string domain + * @param flowItem data + */ + + queryCustomizedDirBandWidth (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.domain !== undefined && opts.domain !== null) { + postBody['domain'] = opts.domain + } + if (opts.dir !== undefined && opts.dir !== null) { + postBody['dir'] = opts.dir + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryCustomizedDirBandWidth 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( + '/statistics:queryCustomizedDirBandWidth', + '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.domain - 用户域名 + * @param {} [opts.startTime] - 查询起始时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.endTime] - 查询截止时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.appName] - app名 optional + * @param {} [opts.streamName] - 流名 optional + * @param {} [opts.pageNum] - 页码,不传默认1 optional + * @param {} [opts.pageSize] - 页size,不传默认100,最大值1000 optional + * @param {string} callback - callback + @return {Object} result + * @param integer total + * @param integer pageNum + * @param integer pageSize + * @param statisticsLiveStreamInfo streamInfoList + */ + + queryStreamInfo (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryStreamInfo" + ) + } + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.appName !== undefined && opts.appName !== null) { + postBody['appName'] = opts.appName + } + if (opts.streamName !== undefined && opts.streamName !== null) { + postBody['streamName'] = opts.streamName + } + if (opts.pageNum !== undefined && opts.pageNum !== null) { + postBody['pageNum'] = opts.pageNum + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryStreamInfo 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( + '/domain/{domain}/liveStatistics:streamInfo', + '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.starttime - 指定查询开始时间(格式:201906011000),返回数据包含该时间点。 + * @param {string} opts.stoptime - 指定查询结束时间(格式:201906011100),返回数据不包含该时间点 + * @param {string} [opts.clientid] - 按照设备ID查询设备带宽。 optional + * @param {integer} [opts.page] - 用于支持分页查询,默认为1,表示第几页。 optional + * @param {integer} [opts.size] - 用于支持分页查询,表示每页返回多少条数据,默认每页返回10条数据,size必须是10的整数倍,并且最大值是100。 optional + * @param {string} callback - callback + @return {Object} result + * @param page page 分页信息 + * @param queryAvgBandwidthGroup data + */ + + queryAvgBandwidthForPCdn (opts, callback) { + opts = opts || {} + + if (opts.starttime === undefined || opts.starttime === null) { + throw new Error( + "Missing the required parameter 'opts.starttime' when calling queryAvgBandwidthForPCdn" + ) + } + if (opts.stoptime === undefined || opts.stoptime === null) { + throw new Error( + "Missing the required parameter 'opts.stoptime' when calling queryAvgBandwidthForPCdn" + ) + } + + let postBody = null + let queryParams = {} + if (opts.starttime !== undefined && opts.starttime !== null) { + queryParams['starttime'] = opts.starttime + } + if (opts.stoptime !== undefined && opts.stoptime !== null) { + queryParams['stoptime'] = opts.stoptime + } + if (opts.clientid !== undefined && opts.clientid !== null) { + queryParams['clientid'] = opts.clientid + } + if (opts.page !== undefined && opts.page !== null) { + queryParams['page'] = opts.page + } + if (opts.size !== undefined && opts.size !== null) { + queryParams['size'] = opts.size + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryAvgBandwidthForPCdn 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( + '/pcdn:queryAvgBandwidth', + '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.macAddr - 查询dev的mac地址(如DCD87C047117) + * @param {string} callback - callback + @return {Object} result + * @param string macAddress mac地址 + * @param integer activeConnNum 活跃链接数量 + * @param string startupTime 启动时间 + * @param string cacheFree 指定缓存剩余空间,单位GB,float64,保留小数点后两位 + * @param string diskFree 设备磁盘剩余空间,单位GB,float64,保留小数点后两位 + * @param number cpuIdle cpu idle百分比,float64,保留小数点后两位 + * @param integer port nginx对外访问端口 + * @param number memFreePercent 内存剩余百分比, float64,保留小数点后两位 + * @param string devId 内容管理中为设备分配的设备id + * @param string remoteIp 设备外网地址 + * @param string region 设备所属区域,如huadong、huanan + * @param string isp 设备所属运营商,如ct、uni、cm + * @param string report 设备最近心跳上报 + */ + + queryDeviceStatusForPCdn (opts, callback) { + opts = opts || {} + + if (opts.macAddr === undefined || opts.macAddr === null) { + throw new Error( + "Missing the required parameter 'opts.macAddr' when calling queryDeviceStatusForPCdn" + ) + } + + let postBody = null + let queryParams = {} + if (opts.macAddr !== undefined && opts.macAddr !== null) { + queryParams['macAddr'] = opts.macAddr + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryDeviceStatusForPCdn 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( + '/pcdn:queryDeviceStatus', + '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 {} [opts.startTime] - 查询起始时间,时间戳 optional + * @param {} [opts.endTime] - 查询截止时间,时间戳 optional + * @param {} [opts.fields] - 查询的字段,取值范围(avgbandwidth,pv,flow)。多个用逗号分隔。默认为空,表示查询带宽流量 optional + * @param {} [opts.area] optional + * @param {} [opts.isp] optional + * @param {} [opts.period] - 查询周期,当前取值范围:“oneMin,fiveMin”,分别表示1min,5min。默认为空,表示fiveMin optional + * @param {} [opts.category] - 业务类型 optional + * @param {} [opts.macAddr] - 设备id optional + * @param {} [opts.pluginPin] - 插件pin optional + * @param {string} callback - callback + @return {Object} result + * @param string startTime 2020/07/30 10:30,查询起始时间 + * @param string endTime 2020/07/30 11:00,查询截止时间 + * @param statisticsDataItem statistics + */ + + queryJDBoxStatisticsData (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.fields !== undefined && opts.fields !== null) { + postBody['fields'] = opts.fields + } + if (opts.area !== undefined && opts.area !== null) { + postBody['area'] = opts.area + } + if (opts.isp !== undefined && opts.isp !== null) { + postBody['isp'] = opts.isp + } + if (opts.period !== undefined && opts.period !== null) { + postBody['period'] = opts.period + } + if (opts.category !== undefined && opts.category !== null) { + postBody['category'] = opts.category + } + if (opts.macAddr !== undefined && opts.macAddr !== null) { + postBody['macAddr'] = opts.macAddr + } + if (opts.pluginPin !== undefined && opts.pluginPin !== null) { + postBody['pluginPin'] = opts.pluginPin + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryJDBoxStatisticsData 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( + '/jdBoxStatistics', + '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) + } + ) + } + + /** + * 无线宝按group查询的统计接口 + * @param {Object} opts - parameters + * @param {} [opts.startTime] - 查询起始时间,时间戳 optional + * @param {} [opts.endTime] - 查询截止时间,时间戳 optional + * @param {} [opts.groupBy] - 取值范围:area,isp,pin ,mac_addr,category,多个用,隔开,多个维度的查询,必须要限制较短的时间间隔 optional + * @param {} [opts.fields] - 查询的字段,取值范围(avgbandwidth,pv,flow)。多个用逗号分隔。默认为空,表示查询带宽流量 optional + * @param {} [opts.area] - 区域 optional + * @param {} [opts.isp] - 运营商 optional + * @param {} [opts.period] - 查询周期,当前取值范围:“oneMin,fiveMin”,分别表示1min,5min。默认为空,表示fiveMin optional + * @param {} [opts.category] - 业务类型 optional + * @param {} [opts.macAddr] - 设备id optional + * @param {} [opts.pluginPin] - 插件pin optional + * @param {string} callback - callback + @return {Object} result + * @param string startTime 2021/01/19 10:30,查询起始时间 + * @param string endTime 2021/01/19 11:00,查询截止时间 + * @param statisticsDataItem statistics + */ + + queryJDBoxStatisticsDataWithGroup (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.groupBy !== undefined && opts.groupBy !== null) { + postBody['groupBy'] = opts.groupBy + } + if (opts.fields !== undefined && opts.fields !== null) { + postBody['fields'] = opts.fields + } + if (opts.area !== undefined && opts.area !== null) { + postBody['area'] = opts.area + } + if (opts.isp !== undefined && opts.isp !== null) { + postBody['isp'] = opts.isp + } + if (opts.period !== undefined && opts.period !== null) { + postBody['period'] = opts.period + } + if (opts.category !== undefined && opts.category !== null) { + postBody['category'] = opts.category + } + if (opts.macAddr !== undefined && opts.macAddr !== null) { + postBody['macAddr'] = opts.macAddr + } + if (opts.pluginPin !== undefined && opts.pluginPin !== null) { + postBody['pluginPin'] = opts.pluginPin + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryJDBoxStatisticsDataWithGroup 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( + '/jdBoxStatisticsWithGroup', + '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.starttime - 指定查询开始时间(格式:201906011000),返回数据包含该时间点。 + * @param {string} opts.stoptime - 指定查询结束时间(格式:201906011100),返回数据不包含该时间点 + * @param {string} opts.pluginPin - 插件pin,多个用,隔开 + * @param {string} [opts.clientid] - 按照设备ID查询设备带宽,即macaddr,多个用,隔开 optional + * @param {integer} [opts.page] - 用于支持分页查询,默认为1,表示第几页。 optional + * @param {integer} [opts.size] - 用于支持分页查询,表示每页返回多少条数据,默认每页返回10条数据,size必须是10的整数倍,并且最大值是100。 optional + * @param {string} callback - callback + @return {Object} result + * @param page page 分页信息 + * @param queryAvgBandwidthGroup data + */ + + queryJBoxAvgBandwidth (opts, callback) { + opts = opts || {} + + if (opts.starttime === undefined || opts.starttime === null) { + throw new Error( + "Missing the required parameter 'opts.starttime' when calling queryJBoxAvgBandwidth" + ) + } + if (opts.stoptime === undefined || opts.stoptime === null) { + throw new Error( + "Missing the required parameter 'opts.stoptime' when calling queryJBoxAvgBandwidth" + ) + } + if (opts.pluginPin === undefined || opts.pluginPin === null) { + throw new Error( + "Missing the required parameter 'opts.pluginPin' when calling queryJBoxAvgBandwidth" + ) + } + + let postBody = null + let queryParams = {} + if (opts.starttime !== undefined && opts.starttime !== null) { + queryParams['starttime'] = opts.starttime + } + if (opts.stoptime !== undefined && opts.stoptime !== null) { + queryParams['stoptime'] = opts.stoptime + } + if (opts.pluginPin !== undefined && opts.pluginPin !== null) { + queryParams['pluginPin'] = opts.pluginPin + } + if (opts.clientid !== undefined && opts.clientid !== null) { + queryParams['clientid'] = opts.clientid + } + if (opts.page !== undefined && opts.page !== null) { + queryParams['page'] = opts.page + } + if (opts.size !== undefined && opts.size !== null) { + queryParams['size'] = opts.size + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryJBoxAvgBandwidth 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( + '/jdbox:queryAvgBandwidth', + '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) + } + ) + } + + /** + * 查询WAF总开关 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + * @param string switchStatus 开关状态, on:开启,off:关闭 + */ + + queryWafSwitch (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryWafSwitch" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryWafSwitch 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( + '/domain/{domain}/wafSwitch', + '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) + } + ) + } + + /** + * 设置WAF总开关 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.switchStatus] - 开关状态, on:开启,off:关闭 optional + * @param {string} callback - callback + @return {Object} result + */ + + setWafSwitch (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setWafSwitch" + ) + } + + let postBody = {} + if (opts.switchStatus !== undefined && opts.switchStatus !== null) { + postBody['switchStatus'] = opts.switchStatus + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setWafSwitch 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( + '/domain/{domain}/wafSwitch', + '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) + } + ) + } + + /** + * 查询WAF总开关 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + * @param string switchStatus 开关状态, on:开启,off:关闭 + */ + + queryWafWhiteRuleSwitch (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryWafWhiteRuleSwitch" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryWafWhiteRuleSwitch 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( + '/domain/{domain}/wafWhiteRuleSwitch', + '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) + } + ) + } + + /** + * 设置WAF白名单开关 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.switchStatus] - 开关状态, on:开启,off:关闭 optional + * @param {string} callback - callback + @return {Object} result + */ + + setWafWhiteRuleSwitch (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setWafWhiteRuleSwitch" + ) + } + + let postBody = {} + if (opts.switchStatus !== undefined && opts.switchStatus !== null) { + postBody['switchStatus'] = opts.switchStatus + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setWafWhiteRuleSwitch 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( + '/domain/{domain}/wafWhiteRuleSwitch', + '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) + } + ) + } + + /** + * 查询WAF白名单规则列表 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {string} opts.ruleType - ruleType, valid values [ip, geo, uri] + * @param {string} [opts.id] - ruleId, defalut empty optional + * @param {integer} [opts.pageSize] - page size , default 0 to query all optional + * @param {integer} [opts.pageIndex] - page index , default 0 to query all optional + * @param {string} callback - callback + @return {Object} result + * @param wafWhiteRuleModel rules + */ + + querywafWhiteRules (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling querywafWhiteRules" + ) + } + if (opts.ruleType === undefined || opts.ruleType === null) { + throw new Error( + "Missing the required parameter 'opts.ruleType' when calling querywafWhiteRules" + ) + } + + let postBody = null + let queryParams = {} + if (opts.ruleType !== undefined && opts.ruleType !== null) { + queryParams['ruleType'] = opts.ruleType + } + if (opts.id !== undefined && opts.id !== null) { + queryParams['id'] = opts.id + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 querywafWhiteRules 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( + '/domain/{domain}/wafWhiteRules', + '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.domain - 用户域名 + * @param {} [opts.ruleType] - 白名单类型, uri ip geo optional + * @param {} [opts.matchOp] - 匹配模式,uri类型有效,0=完全匹配 1=前缀匹配 2=包含 3=正则 4=大于 5=后缀 optional + * @param {} [opts.val] - 匹配值 optional + * @param {} [opts.actions] - 后续处理 "waf" "cc" "deny"自由组合,空表示跳过后续所有阶段 optional + * @param {string} callback - callback + @return {Object} result + */ + + createWafWhiteRule (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling createWafWhiteRule" + ) + } + + let postBody = {} + if (opts.ruleType !== undefined && opts.ruleType !== null) { + postBody['ruleType'] = opts.ruleType + } + if (opts.matchOp !== undefined && opts.matchOp !== null) { + postBody['matchOp'] = opts.matchOp + } + if (opts.val !== undefined && opts.val !== null) { + postBody['val'] = opts.val + } + if (opts.actions !== undefined && opts.actions !== null) { + postBody['actions'] = opts.actions + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 createWafWhiteRule 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( + '/domain/{domain}/wafWhiteRule', + '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.domain - 用户域名 + * @param {string} opts.id - 需要修改的白名单ID + * @param {} [opts.ruleType] - 白名单类型, uri ip geo optional + * @param {} [opts.matchOp] - 匹配模式,uri类型有效,0=完全匹配 1=前缀匹配 2=包含 3=正则 4=大于 5=后缀 optional + * @param {} [opts.val] - 匹配值 optional + * @param {} [opts.actions] - 后续处理 "waf" "cc" "deny"自由组合,空表示跳过后续所有阶段 optional + * @param {string} callback - callback + @return {Object} result + */ + + updateWafWhiteRule (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling updateWafWhiteRule" + ) + } + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling updateWafWhiteRule" + ) + } + + let postBody = {} + if (opts.ruleType !== undefined && opts.ruleType !== null) { + postBody['ruleType'] = opts.ruleType + } + if (opts.matchOp !== undefined && opts.matchOp !== null) { + postBody['matchOp'] = opts.matchOp + } + if (opts.val !== undefined && opts.val !== null) { + postBody['val'] = opts.val + } + if (opts.actions !== undefined && opts.actions !== null) { + postBody['actions'] = opts.actions + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 updateWafWhiteRule 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( + '/domain/{domain}/wafWhiteRule/{id}', + '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) + } + ) + } + + /** + * 启用WAF白名单 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.ids] optional + * @param {} [opts.ruleType] optional + * @param {string} callback - callback + @return {Object} result + */ + + enableWafWhiteRules (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling enableWafWhiteRules" + ) + } + + let postBody = {} + if (opts.ids !== undefined && opts.ids !== null) { + postBody['ids'] = opts.ids + } + if (opts.ruleType !== undefined && opts.ruleType !== null) { + postBody['ruleType'] = opts.ruleType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 enableWafWhiteRules 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( + '/domain/{domain}/wafWhiteRule:enable', + '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) + } + ) + } + + /** + * 禁用WAF白名单 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.ids] optional + * @param {} [opts.ruleType] optional + * @param {string} callback - callback + @return {Object} result + */ + + disableWafWhiteRules (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling disableWafWhiteRules" + ) + } + + let postBody = {} + if (opts.ids !== undefined && opts.ids !== null) { + postBody['ids'] = opts.ids + } + if (opts.ruleType !== undefined && opts.ruleType !== null) { + postBody['ruleType'] = opts.ruleType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 disableWafWhiteRules 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( + '/domain/{domain}/wafWhiteRule:disable', + '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) + } + ) + } + + /** + * 删除WAF白名单 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {string} opts.ids + * @param {string} opts.ruleType + * @param {string} callback - callback + @return {Object} result + */ + + deleteWafWhiteRules (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling deleteWafWhiteRules" + ) + } + if (opts.ids === undefined || opts.ids === null) { + throw new Error( + "Missing the required parameter 'opts.ids' when calling deleteWafWhiteRules" + ) + } + if (opts.ruleType === undefined || opts.ruleType === null) { + throw new Error( + "Missing the required parameter 'opts.ruleType' when calling deleteWafWhiteRules" + ) + } + + let postBody = null + let queryParams = {} + if (opts.ruleType !== undefined && opts.ruleType !== null) { + queryParams['ruleType'] = opts.ruleType + } + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain, + ids: opts.ids + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 deleteWafWhiteRules 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( + '/domain/{domain}/wafWhiteRule/{ids}', + '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) + } + ) + } + + /** + * 查询WAF黑名单开关 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + * @param string switchStatus 开关状态, on:开启,off:关闭 + */ + + queryWafBlackRuleSwitch (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryWafBlackRuleSwitch" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryWafBlackRuleSwitch 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( + '/domain/{domain}/wafBlackRuleSwitch', + '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) + } + ) + } + + /** + * 设置WAF黑名单开关 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.switchStatus] - 开关状态, on:开启,off:关闭 optional + * @param {string} callback - callback + @return {Object} result + */ + + setWafBlackRuleSwitch (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setWafBlackRuleSwitch" + ) + } + + let postBody = {} + if (opts.switchStatus !== undefined && opts.switchStatus !== null) { + postBody['switchStatus'] = opts.switchStatus + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setWafBlackRuleSwitch 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( + '/domain/{domain}/wafBlackRuleSwitch', + '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) + } + ) + } + + /** + * 查询WAF黑名单规则列表 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {string} opts.ruleType - ruleType, valid values [ip, geo, uri] + * @param {string} [opts.id] - ruleId, defalut empty optional + * @param {integer} [opts.pageSize] - page size , default 0 to query all optional + * @param {integer} [opts.pageIndex] - page index , default 0 to query all optional + * @param {string} callback - callback + @return {Object} result + * @param wafBlackRuleModel rules + */ + + querywafBlackRules (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling querywafBlackRules" + ) + } + if (opts.ruleType === undefined || opts.ruleType === null) { + throw new Error( + "Missing the required parameter 'opts.ruleType' when calling querywafBlackRules" + ) + } + + let postBody = null + let queryParams = {} + if (opts.ruleType !== undefined && opts.ruleType !== null) { + queryParams['ruleType'] = opts.ruleType + } + if (opts.id !== undefined && opts.id !== null) { + queryParams['id'] = opts.id + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 querywafBlackRules 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( + '/domain/{domain}/wafBlackRules', + '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.domain - 用户域名 + * @param {} [opts.ruleType] - 黑名单类型, uri ip geo optional + * @param {} [opts.matchOp] - 匹配模式,uri类型有效,0=完全匹配 1=前缀匹配 2=包含 3=正则 4=大于 5=后缀 optional + * @param {} [opts.val] - 匹配值 optional + * @param {} [opts.atOp] - 1:forbidden,493封禁并返回自定义页面 2:redirect,302跳转 3: verify@captcha 4: verify@jscookie optional + * @param {} [opts.atVal] - action为1时为自定义页面名称,空值或缺省值default为默认页面,2时为跳转url,其他时无效 optional + * @param {string} callback - callback + @return {Object} result + */ + + createWafBlackRule (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling createWafBlackRule" + ) + } + + let postBody = {} + if (opts.ruleType !== undefined && opts.ruleType !== null) { + postBody['ruleType'] = opts.ruleType + } + if (opts.matchOp !== undefined && opts.matchOp !== null) { + postBody['matchOp'] = opts.matchOp + } + if (opts.val !== undefined && opts.val !== null) { + postBody['val'] = opts.val + } + if (opts.atOp !== undefined && opts.atOp !== null) { + postBody['atOp'] = opts.atOp + } + if (opts.atVal !== undefined && opts.atVal !== null) { + postBody['atVal'] = opts.atVal + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 createWafBlackRule 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( + '/domain/{domain}/wafBlackRule', + '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.domain - 用户域名 + * @param {string} opts.id - 需要修改的黑名单ID + * @param {} [opts.ruleType] - 黑名单类型, uri ip geo optional + * @param {} [opts.matchOp] - 匹配模式,uri类型有效,0=完全匹配 1=前缀匹配 2=包含 3=正则 4=大于 5=后缀 optional + * @param {} [opts.val] - 匹配值 optional + * @param {} [opts.atOp] - 1:forbidden,493封禁并返回自定义页面 2:redirect,302跳转 3: verify@captcha 4: verify@jscookie optional + * @param {} [opts.atVal] - action为1时为自定义页面名称,空值或缺省值default为默认页面,2时为跳转url,其他时无效 optional + * @param {string} callback - callback + @return {Object} result + */ + + updateWafBlackRule (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling updateWafBlackRule" + ) + } + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling updateWafBlackRule" + ) + } + + let postBody = {} + if (opts.ruleType !== undefined && opts.ruleType !== null) { + postBody['ruleType'] = opts.ruleType + } + if (opts.matchOp !== undefined && opts.matchOp !== null) { + postBody['matchOp'] = opts.matchOp + } + if (opts.val !== undefined && opts.val !== null) { + postBody['val'] = opts.val + } + if (opts.atOp !== undefined && opts.atOp !== null) { + postBody['atOp'] = opts.atOp + } + if (opts.atVal !== undefined && opts.atVal !== null) { + postBody['atVal'] = opts.atVal + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 updateWafBlackRule 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( + '/domain/{domain}/wafBlackRule/{id}', + '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) + } + ) + } + + /** + * 启用WAF黑名单 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.ids] optional + * @param {} [opts.ruleType] optional + * @param {string} callback - callback + @return {Object} result + */ + + enableWafBlackRules (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling enableWafBlackRules" + ) + } + + let postBody = {} + if (opts.ids !== undefined && opts.ids !== null) { + postBody['ids'] = opts.ids + } + if (opts.ruleType !== undefined && opts.ruleType !== null) { + postBody['ruleType'] = opts.ruleType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 enableWafBlackRules 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( + '/domain/{domain}/wafBlackRule:enable', + '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) + } + ) + } + + /** + * 禁用WAF黑名单 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.ids] optional + * @param {} [opts.ruleType] optional + * @param {string} callback - callback + @return {Object} result + */ + + disableWafBlackRules (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling disableWafBlackRules" + ) + } + + let postBody = {} + if (opts.ids !== undefined && opts.ids !== null) { + postBody['ids'] = opts.ids + } + if (opts.ruleType !== undefined && opts.ruleType !== null) { + postBody['ruleType'] = opts.ruleType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 disableWafBlackRules 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( + '/domain/{domain}/wafBlackRule:disable', + '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) + } + ) + } + + /** + * 删除WAF黑名单 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {string} opts.ids + * @param {string} opts.ruleType + * @param {string} callback - callback + @return {Object} result + */ + + deleteWafBlackRules (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling deleteWafBlackRules" + ) + } + if (opts.ids === undefined || opts.ids === null) { + throw new Error( + "Missing the required parameter 'opts.ids' when calling deleteWafBlackRules" + ) + } + if (opts.ruleType === undefined || opts.ruleType === null) { + throw new Error( + "Missing the required parameter 'opts.ruleType' when calling deleteWafBlackRules" + ) + } + + let postBody = null + let queryParams = {} + if (opts.ruleType !== undefined && opts.ruleType !== null) { + queryParams['ruleType'] = opts.ruleType + } + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain, + ids: opts.ids + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 deleteWafBlackRules 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( + '/domain/{domain}/wafBlackRule/{ids}', + '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) + } + ) + } + + /** + * 查询CC 防护开关 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + * @param string switchStatus 开关状态, on:开启,off:关闭 + */ + + queryCCProtectSwitch (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryCCProtectSwitch" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryCCProtectSwitch 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( + '/domain/{domain}/ccProtectSwitch', + '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) + } + ) + } + + /** + * 设置CC 防护开关 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.switchStatus] - 开关状态, on:开启,off:关闭 optional + * @param {string} callback - callback + @return {Object} result + */ + + setCCProtectSwitch (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setCCProtectSwitch" + ) + } + + let postBody = {} + if (opts.switchStatus !== undefined && opts.switchStatus !== null) { + postBody['switchStatus'] = opts.switchStatus + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setCCProtectSwitch 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( + '/domain/{domain}/ccProtectSwitch', + '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) + } + ) + } + + /** + * 查询CC防护规则列表 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {string} [opts.id] - ruleId, defalut empty optional + * @param {integer} [opts.pageSize] - page size , default 0 to query all optional + * @param {integer} [opts.pageIndex] - page index , default 0 to query all optional + * @param {string} callback - callback + @return {Object} result + * @param wafCCProtectRuleModel rules + */ + + queryCCProtectRules (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryCCProtectRules" + ) + } + + let postBody = null + let queryParams = {} + if (opts.id !== undefined && opts.id !== null) { + queryParams['id'] = opts.id + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryCCProtectRules 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( + '/domain/{domain}/ccProtectRules', + '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) + } + ) + } + + /** + * 新增一条CC防护规则 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.uri] - null optional + * @param {} [opts.detectPeriod] - null optional + * @param {} [opts.singleIpLimit] - null optional + * @param {} [opts.blockType] - null optional + * @param {} [opts.blockTime] - null optional + * @param {string} callback - callback + @return {Object} result + */ + + createCCProtectRule (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling createCCProtectRule" + ) + } + + let postBody = {} + if (opts.uri !== undefined && opts.uri !== null) { + postBody['uri'] = opts.uri + } + if (opts.detectPeriod !== undefined && opts.detectPeriod !== null) { + postBody['detectPeriod'] = opts.detectPeriod + } + if (opts.singleIpLimit !== undefined && opts.singleIpLimit !== null) { + postBody['singleIpLimit'] = opts.singleIpLimit + } + if (opts.blockType !== undefined && opts.blockType !== null) { + postBody['blockType'] = opts.blockType + } + if (opts.blockTime !== undefined && opts.blockTime !== null) { + postBody['blockTime'] = opts.blockTime + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 createCCProtectRule 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( + '/domain/{domain}/ccProtectRule', + '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) + } + ) + } + + /** + * 修改CC防护规则 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {string} opts.id - 需要修改的规则ID + * @param {} [opts.uri] - null optional + * @param {} [opts.detectPeriod] - null optional + * @param {} [opts.singleIpLimit] - null optional + * @param {} [opts.blockType] - null optional + * @param {} [opts.blockTime] - null optional + * @param {string} callback - callback + @return {Object} result + */ + + updateCCProtectRule (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling updateCCProtectRule" + ) + } + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling updateCCProtectRule" + ) + } + + let postBody = {} + if (opts.uri !== undefined && opts.uri !== null) { + postBody['uri'] = opts.uri + } + if (opts.detectPeriod !== undefined && opts.detectPeriod !== null) { + postBody['detectPeriod'] = opts.detectPeriod + } + if (opts.singleIpLimit !== undefined && opts.singleIpLimit !== null) { + postBody['singleIpLimit'] = opts.singleIpLimit + } + if (opts.blockType !== undefined && opts.blockType !== null) { + postBody['blockType'] = opts.blockType + } + if (opts.blockTime !== undefined && opts.blockTime !== null) { + postBody['blockTime'] = opts.blockTime + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 updateCCProtectRule 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( + '/domain/{domain}/ccProtectRule/{id}', + '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) + } + ) + } + + /** + * 启用CC防护规则 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.ids] optional + * @param {string} callback - callback + @return {Object} result + */ + + enableCCProtectRule (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling enableCCProtectRule" + ) + } + + let postBody = {} + if (opts.ids !== undefined && opts.ids !== null) { + postBody['ids'] = opts.ids + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 enableCCProtectRule 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( + '/domain/{domain}/ccProtectRule:enable', + '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) + } + ) + } + + /** + * 禁用CC防护规则 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.ids] optional + * @param {string} callback - callback + @return {Object} result + */ + + disableCCProtectRule (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling disableCCProtectRule" + ) + } + + let postBody = {} + if (opts.ids !== undefined && opts.ids !== null) { + postBody['ids'] = opts.ids + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 disableCCProtectRule 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( + '/domain/{domain}/ccProtectRule:disable', + '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) + } + ) + } + + /** + * 删除ccProtectRule + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {string} opts.ids + * @param {string} callback - callback + @return {Object} result + */ + + deleteCCProtectRule (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling deleteCCProtectRule" + ) + } + if (opts.ids === undefined || opts.ids === null) { + throw new Error( + "Missing the required parameter 'opts.ids' when calling deleteCCProtectRule" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain, + ids: opts.ids + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 deleteCCProtectRule 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( + '/domain/{domain}/ccProtectRule/{ids}', + '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) + } + ) + } + + /** + * 查询web防护开关 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + * @param string switchStatus 开关状态, on:开启,off:关闭 + */ + + queryWebProtectSwitch (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryWebProtectSwitch" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryWebProtectSwitch 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( + '/domain/{domain}/wafWebProtectSwitch', + '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) + } + ) + } + + /** + * 设置web防护开关 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.switchStatus] - 开关状态, on:开启,off:关闭 optional + * @param {string} callback - callback + @return {Object} result + */ + + setWebProtectSwitch (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling setWebProtectSwitch" + ) + } + + let postBody = {} + if (opts.switchStatus !== undefined && opts.switchStatus !== null) { + postBody['switchStatus'] = opts.switchStatus + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 setWebProtectSwitch 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( + '/domain/{domain}/wafWebProtectSwitch', + '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) + } + ) + } + + /** + * 查询web防护开关 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + * @param string wafMode 0:拦截模式 (阻断forbidden 493跳到自定义页面) ,1-检测模式(观察notice) + * @param integer wafLevel 规则策略等级 0为宽松, 1为正常, 2为严格 + * @param string redirection 拦截模式跳转的自定义页面名称, 缺省或default返回默认页面 + */ + + queryWebProtectSettings (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryWebProtectSettings" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryWebProtectSettings 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( + '/domain/{domain}/wafWebProtectSettings', + '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) + } + ) + } + + /** + * 设置web防护开关 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {} [opts.wafMode] - 0:拦截模式 (阻断forbidden 493跳到自定义页面) ,1-检测模式(观察notice) optional + * @param {} [opts.wafLevel] - 规则策略等级 0为宽松, 1为正常, 2为严格 optional + * @param {} [opts.redirection] - 拦截模式跳转的自定义页面名称, 缺省或default返回默认页面 optional + * @param {string} callback - callback + @return {Object} result + */ + + updateWebProtectSettings (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling updateWebProtectSettings" + ) + } + + let postBody = {} + if (opts.wafMode !== undefined && opts.wafMode !== null) { + postBody['wafMode'] = opts.wafMode + } + if (opts.wafLevel !== undefined && opts.wafLevel !== null) { + postBody['wafLevel'] = opts.wafLevel + } + if (opts.redirection !== undefined && opts.redirection !== null) { + postBody['redirection'] = opts.redirection + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 updateWebProtectSettings 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( + '/domain/{domain}/wafWebProtectSettings', + '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) + } + ) + } + + /** + * 查询waf地域信息 + * @param {Object} opts - parameters + * @param {string} opts.skipType - skipType, valid values [skip, deny] + * @param {string} callback - callback + @return {Object} result + * @param wafRegionsModel china + * @param wafRegionsModel foreign + */ + + queryWafRegions (opts, callback) { + opts = opts || {} + + if (opts.skipType === undefined || opts.skipType === null) { + throw new Error( + "Missing the required parameter 'opts.skipType' when calling queryWafRegions" + ) + } + + let postBody = null + let queryParams = {} + if (opts.skipType !== undefined && opts.skipType !== null) { + queryParams['skipType'] = opts.skipType + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryWafRegions 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( + '/wafRegions', + '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) + } + ) + } + + /** + * 查询waf ip黑名单配置状态 + * @param {Object} opts - parameters + * @param {string} opts.domain - 用户域名 + * @param {string} callback - callback + @return {Object} result + * @param boolean settingStatus true or false, true:scdn的黑名单为打开状态,并至少存在一条ruleType=ip的黑名单规则且为启用状态 + */ + + queryIpBlackSettingStatus (opts, callback) { + opts = opts || {} + + if (opts.domain === undefined || opts.domain === null) { + throw new Error( + "Missing the required parameter 'opts.domain' when calling queryIpBlackSettingStatus" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domain: opts.domain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 queryIpBlackSettingStatus 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( + '/domain/{domain}/wafIpBlackSettingStatus', + '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 {} [opts.startTime] - 查询起始时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.endTime] - 查询截止时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.domain] - 需要查询的域名, 必须为用户pin下有权限的域名 optional + * @param {string} callback - callback + @return {Object} result + * @param areaData areaDatas + */ + + wafQueryPvForAreaAndIp (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.domain !== undefined && opts.domain !== null) { + postBody['domain'] = opts.domain + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 wafQueryPvForAreaAndIp 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( + '/wafPvForAreaAndIp', + '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 {} [opts.startTime] - 查询起始时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.endTime] - 查询截止时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.domain] - 需要查询的域名, 必须为用户pin下有权限的域名 optional + * @param {string} callback - callback + @return {Object} result + * @param pvItem pvs + * @param integer peakAttackPv + * @param integer peakTotalPv + */ + + wafQueryPv (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.domain !== undefined && opts.domain !== null) { + postBody['domain'] = opts.domain + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 wafQueryPv 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( + '/wafPvStatistic', + '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 {} [opts.startTime] - 查询起始时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.endTime] - 查询截止时间,UTC时间,格式为:yyyy-MM-dd'T'HH:mm:ss'Z',示例:2018-10-21T10:00:00Z optional + * @param {} [opts.domain] - 需要查询的域名, 必须为用户pin下有权限的域名 optional + * @param {} [opts.sortField] - 排序字段 optional + * @param {} [opts.sortRule] - 排序规则:desc,asc optional + * @param {} [opts.pageNumber] - 页码,从1开始 optional + * @param {} [opts.pageSize] - 页大小,默认20 optional + * @param {string} callback - callback + @return {Object} result + * @param string total + * @param attackDetail attackDetails + */ + + wafQueryAttackDetails (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.domain !== undefined && opts.domain !== null) { + postBody['domain'] = opts.domain + } + if (opts.sortField !== undefined && opts.sortField !== null) { + postBody['sortField'] = opts.sortField + } + if (opts.sortRule !== undefined && opts.sortRule !== null) { + postBody['sortRule'] = opts.sortRule + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cdn/0.10.47' + } + + 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 wafQueryAttackDetails 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( + '/wafAttackDetails', + '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 = CDN diff --git a/packages/libs/lib-jdcloud/src/repo/censor/v1/censor.js b/packages/libs/lib-jdcloud/src/repo/censor/v1/censor.js new file mode 100644 index 000000000..6562d87e0 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/censor/v1/censor.js @@ -0,0 +1,2349 @@ +/* + * 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. + * + * 站点检测类接口 + * 京东云内容安全-OpenAPI站点检测类接口 + * + * 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 = 'censor' +Service._services[serviceId] = true + +/** + * censor service. + * @version 1.0.3 + */ + +class CENSOR extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'censor.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 提交音频异步检测任务 + * @param {Object} opts - parameters + * @param {} [opts.bizType] - 机审策略,eg: default optional + * @param {} [opts.scenes] - 指定检测场景 optional + * @param {} [opts.tasks] - 检测任务列表,包含一个或多个元素。每个元素是个结构体,最多可添加10个元素,每个元素的具体结构描述见audioTask。 optional + * @param {} [opts.callback] - 异步检测结果回调通知您的URL,支持HTTP/HTTPS。该字段为空时,您必须定时检索检测结果。 optional + * @param {} [opts.seed] - 随机字符串,该值用于回调通知请求中的签名。当使用callback时,该字段必须提供。 optional + * @param {string} callback - callback + @return {Object} result + * @param taskData data + */ + + asyncAudioScan (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.bizType !== undefined && opts.bizType !== null) { + postBody['bizType'] = opts.bizType + } + if (opts.scenes !== undefined && opts.scenes !== null) { + postBody['scenes'] = opts.scenes + } + if (opts.tasks !== undefined && opts.tasks !== null) { + postBody['tasks'] = opts.tasks + } + if (opts.callback !== undefined && opts.callback !== null) { + postBody['callback'] = opts.callback + } + if (opts.seed !== undefined && opts.seed !== null) { + postBody['seed'] = opts.seed + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 censor/1.0.3' + } + + 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 asyncAudioScan 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( + '/audio:asyncscan', + '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 {array} opts.taskIds + * @param {string} callback - callback + @return {Object} result + * @param audioResult data + */ + + audioResults (opts, callback) { + opts = opts || {} + + if (opts.taskIds === undefined || opts.taskIds === null) { + throw new Error( + "Missing the required parameter 'opts.taskIds' when calling audioResults" + ) + } + + let postBody = {} + if (opts.taskIds !== undefined && opts.taskIds !== null) { + postBody['taskIds'] = opts.taskIds + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 censor/1.0.3' + } + + 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 audioResults 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( + '/audio:results', + '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) + } + ) + } + + /** + * 提交音频异步检测任务V2 + * @param {Object} opts - parameters + * @param {} [opts.bizType] - 业务bizType,请联系客户经理获取 optional + * @param {} [opts.url] - 最大长度512, 语音文件url optional + * @param {} [opts.version] - 最大长度4,接口版本号,可选值 v3.5 optional + * @param {} [opts.title] - 最大长度512,文件标题 optional + * @param {} [opts.ip] - 最大长度32,用户IP地址 optional + * @param {} [opts.account] - 最大长度128,用户唯一标识,如果无需登录则为空 optional + * @param {} [opts.deviceId] - 最大长度128,用户设备 id,与设备画像库匹配,明文请转大写传入;MD5加密请明文转大写后MD5计算,再转大写传入,建议抄送 optional + * @param {} [opts.deviceType] - 用户设备id的类型,0:其他,10:IMEI,11:AndroidID,12:IDFA,13:IDFV,14:MAC ,20:IMEI_MD5,21:AndroidID_MD5,22:IDFA_MD5,23:IDFV_MD5,24:MAC_MD5 optional + * @param {} [opts.callback] - 最大长度2^16-1,数据回调参数,调用方根据业务情况自行设计,当调用离线结果获取接口时,该接口会原样返回该字段,详细见音频离线检测结果获取。作为数据处理标识,因此该字段应该设计为能唯一定位到该次请求的数据结构,如对用户的昵称进行检测,dataId可设为用户标识(用户ID),用户修改多次,每次请求数据的dataId可能一致,但是callback参数可以设计成定位该次请求的数据结构,比如callback字段设计成json,包含dataId和请求的时间戳等信息,当然如果不想做区分,也可以直接把callback设置成dataId的值。 optional + * @param {} [opts.callbackUrl] - 最大长度256,离线结果回调通知到客户的URL。主动回调数据接口超时时间设置为2s,为了保证顺利接收数据,需保证接收接口性能稳定并且保证幂等性。 optional + * @param {string} callback - callback + @return {Object} result + * @param audioTaskData result + */ + + asyncAudioScanV2 (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.bizType !== undefined && opts.bizType !== null) { + postBody['bizType'] = opts.bizType + } + if (opts.url !== undefined && opts.url !== null) { + postBody['url'] = opts.url + } + if (opts.version !== undefined && opts.version !== null) { + postBody['version'] = opts.version + } + if (opts.title !== undefined && opts.title !== null) { + postBody['title'] = opts.title + } + if (opts.ip !== undefined && opts.ip !== null) { + postBody['ip'] = opts.ip + } + if (opts.account !== undefined && opts.account !== null) { + postBody['account'] = opts.account + } + if (opts.deviceId !== undefined && opts.deviceId !== null) { + postBody['deviceId'] = opts.deviceId + } + if (opts.deviceType !== undefined && opts.deviceType !== null) { + postBody['deviceType'] = opts.deviceType + } + if (opts.callback !== undefined && opts.callback !== null) { + postBody['callback'] = opts.callback + } + if (opts.callbackUrl !== undefined && opts.callbackUrl !== null) { + postBody['callbackUrl'] = opts.callbackUrl + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 censor/1.0.3' + } + + 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 asyncAudioScanV2 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( + '/audio:asyncscanv2', + '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) + } + ) + } + + /** + * 语音检测结果获取接口,获取离线处理的数据后,下次调用,不会再次返回之前获取过的离线数据。小于10s/20次,请求频率过快服务器会拒绝处理 + * @param {Object} opts - parameters + * @param {} [opts.bizType] - 业务bizType,请联系客户经理获取 optional + * @param {} [opts.version] - 接口版本v1 optional + * @param {string} callback - callback + @return {Object} result + * @param audioAntispamResult antispam + * @param audioASRResult asr + * @param audioLanguageResult language + * @param audioVoiceResult voice + */ + + audioCallbackV2 (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.bizType !== undefined && opts.bizType !== null) { + postBody['bizType'] = opts.bizType + } + if (opts.version !== undefined && opts.version !== null) { + postBody['version'] = opts.version + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 censor/1.0.3' + } + + 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 audioCallbackV2 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( + '/audio:callbackv2', + '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) + } + ) + } + + /** + * 根据taskid查询语音检测结果,小于10s/20次,请求频率过快服务器会拒绝处理 + * @param {Object} opts - parameters + * @param {} [opts.bizType] - 业务bizType,请联系客户经理获取 optional + * @param {} [opts.version] - 接口版本v1 optional + * @param {} [opts.taskIds] - 要查询的taskId optional + * @param {string} callback - callback + @return {Object} result + * @param audioAntispamResult result + */ + + audioResultsV2 (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.bizType !== undefined && opts.bizType !== null) { + postBody['bizType'] = opts.bizType + } + if (opts.version !== undefined && opts.version !== null) { + postBody['version'] = opts.version + } + if (opts.taskIds !== undefined && opts.taskIds !== null) { + postBody['taskIds'] = opts.taskIds + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 censor/1.0.3' + } + + 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 audioResultsV2 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( + '/audio:resultsv2', + '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.libId - 敏感库id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteCensorLib (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 deleteCensorLib" + ) + } + + opts = opts || {} + + if (opts.libId === undefined || opts.libId === null) { + throw new Error( + "Missing the required parameter 'opts.libId' when calling deleteCensorLib" + ) + } + + let postBody = null + let queryParams = {} + if (opts.libId !== undefined && opts.libId !== null) { + queryParams['libId'] = opts.libId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 censor/1.0.3' + } + + 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 deleteCensorLib 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}/customCensorLib:custom', + '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) + } + ) + } + + /** + * 删除敏感库Item + * @param {Object} opts - parameters + * @param {string} opts.libId - 敏感库id + * @param {string} opts.itemId - itemId,支持多个,用','分隔,表示批量删除 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteCensorLibItems (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 deleteCensorLibItems" + ) + } + + opts = opts || {} + + if (opts.libId === undefined || opts.libId === null) { + throw new Error( + "Missing the required parameter 'opts.libId' when calling deleteCensorLibItems" + ) + } + if (opts.itemId === undefined || opts.itemId === null) { + throw new Error( + "Missing the required parameter 'opts.itemId' when calling deleteCensorLibItems" + ) + } + + let postBody = null + let queryParams = {} + if (opts.libId !== undefined && opts.libId !== null) { + queryParams['libId'] = opts.libId + } + if (opts.itemId !== undefined && opts.itemId !== null) { + queryParams['itemId'] = opts.itemId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 censor/1.0.3' + } + + 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 deleteCensorLibItems 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}/customCensorLib:customItem', + '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 {} [opts.bizType] - 机审策略,eg: default optional + * @param {} [opts.scenes] - 指定检测场景 optional + * @param {} [opts.tasks] - 检测任务列表,包含一个或多个元素。每个元素是个结构体,最多可添加10个元素,即最多对10段文本进行检测。每个元素的具体结构描述见ImageTask。 optional + * @param {string} callback - callback + @return {Object} result + * @param imageResult data + */ + + imageScan (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.bizType !== undefined && opts.bizType !== null) { + postBody['bizType'] = opts.bizType + } + if (opts.scenes !== undefined && opts.scenes !== null) { + postBody['scenes'] = opts.scenes + } + if (opts.tasks !== undefined && opts.tasks !== null) { + postBody['tasks'] = opts.tasks + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 censor/1.0.3' + } + + 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 imageScan 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( + '/image:scan', + '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 {} [opts.bizType] - 机审策略,eg: default optional + * @param {} [opts.scenes] - 指定检测场景 optional + * @param {} [opts.tasks] - 检测任务列表,包含一个或多个元素。每个元素是个结构体,最多可添加10个元素,每个元素的具体结构描述见ImageTask。 optional + * @param {} [opts.callback] - 异步检测结果回调通知您的URL,支持HTTP/HTTPS。该字段为空时,您必须定时检索检测结果。 optional + * @param {} [opts.seed] - 随机字符串,该值用于回调通知请求中的签名。当使用callback时,该字段必须提供。 optional + * @param {string} callback - callback + @return {Object} result + * @param taskData data + */ + + asyncImageScan (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.bizType !== undefined && opts.bizType !== null) { + postBody['bizType'] = opts.bizType + } + if (opts.scenes !== undefined && opts.scenes !== null) { + postBody['scenes'] = opts.scenes + } + if (opts.tasks !== undefined && opts.tasks !== null) { + postBody['tasks'] = opts.tasks + } + if (opts.callback !== undefined && opts.callback !== null) { + postBody['callback'] = opts.callback + } + if (opts.seed !== undefined && opts.seed !== null) { + postBody['seed'] = opts.seed + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 censor/1.0.3' + } + + 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 asyncImageScan 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( + '/image:asyncscan', + '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 {array} opts.taskIds + * @param {string} callback - callback + @return {Object} result + * @param imageResult data + */ + + imageResults (opts, callback) { + opts = opts || {} + + if (opts.taskIds === undefined || opts.taskIds === null) { + throw new Error( + "Missing the required parameter 'opts.taskIds' when calling imageResults" + ) + } + + let postBody = {} + if (opts.taskIds !== undefined && opts.taskIds !== null) { + postBody['taskIds'] = opts.taskIds + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 censor/1.0.3' + } + + 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 imageResults 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( + '/image:results', + '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) + } + ) + } + + /** + * 图片同步检测v2 + * @param {Object} opts - parameters + * @param {} [opts.images] - 指定检测场景 optional + * @param {} [opts.version] - 接口版本v4.1 optional + * @param {} [opts.bizType] - 业务bizType,请联系客户经理获取 optional + * @param {} [opts.checkLabels] - 接口指定过检分类,可多选,过检分类列表:100:色情,110:性感低俗,200:广告,210:二维码,260:广告法,300:暴恐,400:违禁,500:涉政,800:恶心类,900:其他,1100:涉价值观响应结果 optional + * @param {string} callback - callback + @return {Object} result + * @param imageAntispamResult antispam + * @param oCRResult ocr + * @param faceResult face + * @param qualityResult quality + * @param logoResult logo + * @param sceneResult scene + */ + + imageScanV2 (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.images !== undefined && opts.images !== null) { + postBody['images'] = opts.images + } + if (opts.version !== undefined && opts.version !== null) { + postBody['version'] = opts.version + } + if (opts.bizType !== undefined && opts.bizType !== null) { + postBody['bizType'] = opts.bizType + } + if (opts.checkLabels !== undefined && opts.checkLabels !== null) { + postBody['checkLabels'] = opts.checkLabels + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 censor/1.0.3' + } + + 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 imageScanV2 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( + '/image:scanv2', + '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.limitId - 限制参数配置id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteLimit (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 deleteLimit" + ) + } + + opts = opts || {} + + if (opts.limitId === undefined || opts.limitId === null) { + throw new Error( + "Missing the required parameter 'opts.limitId' when calling deleteLimit" + ) + } + + let postBody = null + let queryParams = {} + if (opts.limitId !== undefined && opts.limitId !== null) { + queryParams['limitId'] = opts.limitId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 censor/1.0.3' + } + + 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 deleteLimit 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}/limit:limit', + '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 {} [opts.bizType] - 机审策略,eg: default optional + * @param {} [opts.scenes] - 指定检测场景,固定值:antispam optional + * @param {} [opts.tasks] - 检测任务列表,包含一个或多个元素。每个元素是个结构体,最多可添加10个元素,即最多对10段文本进行检测。每个元素的具体结构描述见TextTask。 optional + * @param {string} callback - callback + @return {Object} result + * @param textResult data + */ + + textScan (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.bizType !== undefined && opts.bizType !== null) { + postBody['bizType'] = opts.bizType + } + if (opts.scenes !== undefined && opts.scenes !== null) { + postBody['scenes'] = opts.scenes + } + if (opts.tasks !== undefined && opts.tasks !== null) { + postBody['tasks'] = opts.tasks + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 censor/1.0.3' + } + + 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 textScan 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( + '/text:scan', + '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 {} [opts.scenes] - 指定检测场景,固定值:antispam optional + * @param {} [opts.tasks] - 检测任务列表,包含一个或多个元素。每个元素是个结构体,最多可添加10个元素,即最多对10段文本进行检测。每个元素的具体结构描述见TextTask。 optional + * @param {string} callback - callback + @return {Object} result + * @param textResult data + */ + + innerTextScan (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.scenes !== undefined && opts.scenes !== null) { + postBody['scenes'] = opts.scenes + } + if (opts.tasks !== undefined && opts.tasks !== null) { + postBody['tasks'] = opts.tasks + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 censor/1.0.3' + } + + 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 innerTextScan 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( + '/text:innerscan', + '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 {} [opts.bizType] - 业务bizType,请联系客户经理获取 optional + * @param {} [opts.version] - 接口版本号,固定值 v4 optional + * @param {} [opts.checkLabels] - 可指定多个垃圾类别进行机器检测,多个垃圾类别以逗号分隔("100,200") optional + * @param {} [opts.texts] - 1-100条文本数据。 optional + * @param {string} callback - callback + @return {Object} result + * @param textResultDetailV2 result + */ + + textScanV2 (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.bizType !== undefined && opts.bizType !== null) { + postBody['bizType'] = opts.bizType + } + if (opts.version !== undefined && opts.version !== null) { + postBody['version'] = opts.version + } + if (opts.checkLabels !== undefined && opts.checkLabels !== null) { + postBody['checkLabels'] = opts.checkLabels + } + if (opts.texts !== undefined && opts.texts !== null) { + postBody['texts'] = opts.texts + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 censor/1.0.3' + } + + 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 textScanV2 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( + '/text:scanv2', + '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) + } + ) + } + + /** + * 查看文本疑似结果,小于10s/20次,请求频率过快服务器会拒绝处理 + * @param {Object} opts - parameters + * @param {} [opts.bizType] - 业务bizType,请联系客户经理获取 optional + * @param {} [opts.version] - 接口版本v4 optional + * @param {string} callback - callback + @return {Object} result + * @param textResultDetailV2 result + */ + + textResultsV2 (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.bizType !== undefined && opts.bizType !== null) { + postBody['bizType'] = opts.bizType + } + if (opts.version !== undefined && opts.version !== null) { + postBody['version'] = opts.version + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 censor/1.0.3' + } + + 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 textResultsV2 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( + '/text:resultsv2', + '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 {} [opts.bizType] - 机审策略,eg: default optional + * @param {} [opts.live] - 是否直播。默认为false,表示为普通视频检测;若是直播检测,该值必须传入true。 optional + * @param {} [opts.scenes] - 指定检测场景 optional + * @param {} [opts.audioScenes] - 视频中语音的检测场景 optional + * @param {} [opts.tasks] - 检测任务列表,包含一个或多个元素。每个元素是个结构体,最多可添加10个元素,每个元素的具体结构描述见videoTask。 optional + * @param {} [opts.callback] - 异步检测结果回调通知您的URL,支持HTTP/HTTPS。该字段为空时,您必须定时检索检测结果。 optional + * @param {} [opts.seed] - 随机字符串,该值用于回调通知请求中的签名。当使用callback时,该字段必须提供。 optional + * @param {string} callback - callback + @return {Object} result + * @param taskData data + */ + + asyncVideoScan (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.bizType !== undefined && opts.bizType !== null) { + postBody['bizType'] = opts.bizType + } + if (opts.live !== undefined && opts.live !== null) { + postBody['live'] = opts.live + } + if (opts.scenes !== undefined && opts.scenes !== null) { + postBody['scenes'] = opts.scenes + } + if (opts.audioScenes !== undefined && opts.audioScenes !== null) { + postBody['audioScenes'] = opts.audioScenes + } + if (opts.tasks !== undefined && opts.tasks !== null) { + postBody['tasks'] = opts.tasks + } + if (opts.callback !== undefined && opts.callback !== null) { + postBody['callback'] = opts.callback + } + if (opts.seed !== undefined && opts.seed !== null) { + postBody['seed'] = opts.seed + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 censor/1.0.3' + } + + 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 asyncVideoScan 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( + '/video:asyncscan', + '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 {array} opts.taskIds + * @param {string} callback - callback + @return {Object} result + * @param videoResult data + */ + + videoResults (opts, callback) { + opts = opts || {} + + if (opts.taskIds === undefined || opts.taskIds === null) { + throw new Error( + "Missing the required parameter 'opts.taskIds' when calling videoResults" + ) + } + + let postBody = {} + if (opts.taskIds !== undefined && opts.taskIds !== null) { + postBody['taskIds'] = opts.taskIds + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 censor/1.0.3' + } + + 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 videoResults 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( + '/video:results', + '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) + } + ) + } + + /** + * 提交视频异步检测任务V2 + * @param {Object} opts - parameters + * @param {} [opts.bizType] - 业务bizType,请联系客户经理获取 optional + * @param {} [opts.url] - 最大长度512, 点播视频地址 optional + * @param {} [opts.dataId] - 最大长度128,点播视频唯一标识 optional + * @param {} [opts.version] - 接口版本号,可选值 v3.2 optional + * @param {} [opts.title] - 最大长度512,视频名称 optional + * @param {} [opts.callback] - 最大长度512,数据回调参数,产品根据业务情况自行设计,当获取离线检测结果时,内容安全服务会返回该字段 optional + * @param {} [opts.callbackUrl] - 最大长度256,离线结果回调通知到客户的URL。主动回调数据接口超时时间设置为2s,为了保证顺利接收数据,需保证接收接口性能稳定并且保证幂等性。 optional + * @param {} [opts.uniqueKey] - 最大长度64,客户个性化视频唯一性标识,传入后,将以此值作为重复检测依据,若不传,默认以URL作为查重依据,如果重复提交会被拒绝,返回报错信息请求重复,以及原提交taskID值,具体返回请查看响应示例 optional + * @param {} [opts.scFrequency] - 最大长度64,客户个性化视频唯一性标识,传入后,将以此值作为重复检测依据,若不传,默认以URL作为查重依据,如果重复提交会被拒绝,返回报错信息请求重复,以及原提交taskID值,具体返回请查看响应示例 optional + * @param {} [opts.advancedFrequency] - 高级截帧设置,此项填写,默认截帧策略失效 optional + * @param {string} callback - callback + @return {Object} result + * @param videoTaskData result + */ + + asyncVideoScanV2 (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.bizType !== undefined && opts.bizType !== null) { + postBody['bizType'] = opts.bizType + } + if (opts.url !== undefined && opts.url !== null) { + postBody['url'] = opts.url + } + if (opts.dataId !== undefined && opts.dataId !== null) { + postBody['dataId'] = opts.dataId + } + if (opts.version !== undefined && opts.version !== null) { + postBody['version'] = opts.version + } + if (opts.title !== undefined && opts.title !== null) { + postBody['title'] = opts.title + } + if (opts.callback !== undefined && opts.callback !== null) { + postBody['callback'] = opts.callback + } + if (opts.callbackUrl !== undefined && opts.callbackUrl !== null) { + postBody['callbackUrl'] = opts.callbackUrl + } + if (opts.uniqueKey !== undefined && opts.uniqueKey !== null) { + postBody['uniqueKey'] = opts.uniqueKey + } + if (opts.scFrequency !== undefined && opts.scFrequency !== null) { + postBody['scFrequency'] = opts.scFrequency + } + if ( + opts.advancedFrequency !== undefined && + opts.advancedFrequency !== null + ) { + postBody['advancedFrequency'] = opts.advancedFrequency + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 censor/1.0.3' + } + + 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 asyncVideoScanV2 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( + '/video:asyncscanv2', + '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) + } + ) + } + + /** + * 视频检测结果获取接口,获取离线处理的数据后,下次调用,不会再次返回之前获取过的离线数据。小于10s/20次,请求频率过快服务器会拒绝处理 + * @param {Object} opts - parameters + * @param {} [opts.bizType] - 业务bizType,请联系客户经理获取 optional + * @param {} [opts.version] - 接口版本v1 optional + * @param {string} callback - callback + @return {Object} result + * @param videoResultV2 result + */ + + videoCallbackV2 (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.bizType !== undefined && opts.bizType !== null) { + postBody['bizType'] = opts.bizType + } + if (opts.version !== undefined && opts.version !== null) { + postBody['version'] = opts.version + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 censor/1.0.3' + } + + 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 videoCallbackV2 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( + '/video:callbackv2', + '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) + } + ) + } + + /** + * 根据taskid查询视频检测结果,小于10s/20次,请求频率过快服务器会拒绝处理 + * @param {Object} opts - parameters + * @param {} [opts.bizType] - 业务bizType,请联系客户经理获取 optional + * @param {} [opts.version] - 接口版本v1 optional + * @param {} [opts.taskIds] - 要查询的taskId optional + * @param {string} callback - callback + @return {Object} result + * @param videoResultV2 result + */ + + videoResultsV2 (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.bizType !== undefined && opts.bizType !== null) { + postBody['bizType'] = opts.bizType + } + if (opts.version !== undefined && opts.version !== null) { + postBody['version'] = opts.version + } + if (opts.taskIds !== undefined && opts.taskIds !== null) { + postBody['taskIds'] = opts.taskIds + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 censor/1.0.3' + } + + 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 videoResultsV2 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( + '/video:resultsv2', + '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 = CENSOR diff --git a/packages/libs/lib-jdcloud/src/repo/clickhouse/v1/clickhouse.js b/packages/libs/lib-jdcloud/src/repo/clickhouse/v1/clickhouse.js new file mode 100644 index 000000000..148eae88e --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/clickhouse/v1/clickhouse.js @@ -0,0 +1,4546 @@ +/* + * 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. + * + * 白名单 + * 白名单相关接口 + * + * 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 = 'clickhouse' +Service._services[serviceId] = true + +/** + * clickhouse service. + * @version 0.4.0 + */ + +class CLICKHOUSE extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'clickhouse.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询 Clickhouse account列表信息 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {integer} [opts.pageNumber] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageNumber为-1时,返回所有数据页码;超过总页数时,显示最后一页; optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[10,100],用于查询列表的接口 optional + * @param {filter} [opts.filters] - accountStatus, 支持operator选项:eq + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param account accounts + * @param number totalCount + */ + + describeAccounts (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 describeAccounts" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeAccounts" + ) + } + + 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, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 describeAccounts 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}/instances/{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) + } + ) + } + + /** + * 创建一个Clickhouse账号 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {string} opts.accountName - 账号名 + * @param {string} opts.accountPassword - 密码 + * @param {string} opts.privilege - 账号权限 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + createAccount (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 createAccount" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createAccount" + ) + } + if (opts.accountName === undefined || opts.accountName === null) { + throw new Error( + "Missing the required parameter 'opts.accountName' when calling createAccount" + ) + } + if (opts.accountPassword === undefined || opts.accountPassword === null) { + throw new Error( + "Missing the required parameter 'opts.accountPassword' when calling createAccount" + ) + } + if (opts.privilege === undefined || opts.privilege === null) { + throw new Error( + "Missing the required parameter 'opts.privilege' when calling createAccount" + ) + } + + let postBody = {} + if (opts.accountName !== undefined && opts.accountName !== null) { + postBody['accountName'] = opts.accountName + } + if (opts.accountPassword !== undefined && opts.accountPassword !== null) { + postBody['accountPassword'] = opts.accountPassword + } + if (opts.privilege !== undefined && opts.privilege !== null) { + postBody['privilege'] = opts.privilege + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 createAccount 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}/instances/{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) + } + ) + } + + /** + * 删除一个Clickhouse实例 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {string} opts.accountName - 账号名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteAccount (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 deleteAccount" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteAccount" + ) + } + if (opts.accountName === undefined || opts.accountName === null) { + throw new Error( + "Missing the required parameter 'opts.accountName' when calling deleteAccount" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + accountName: opts.accountName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 deleteAccount 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}/instances/{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) + } + ) + } + + /** + * 修改账号权限 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {string} opts.accountName - 账号名称 + * @param {string} [opts.privileges] - 账号的访问权限 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyPrivilege (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 modifyPrivilege" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyPrivilege" + ) + } + if (opts.accountName === undefined || opts.accountName === null) { + throw new Error( + "Missing the required parameter 'opts.accountName' when calling modifyPrivilege" + ) + } + + let postBody = {} + if (opts.privileges !== undefined && opts.privileges !== null) { + postBody['privileges'] = opts.privileges + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + accountName: opts.accountName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 modifyPrivilege 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}/instances/{instanceId}/accounts/{accountName}:modifyPrivilege', + '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 - 实例ID + * @param {string} opts.accountName - 账号名称 + * @param {string} [opts.accountPassword] - 新密码 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + resetPassword (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 resetPassword" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling resetPassword" + ) + } + if (opts.accountName === undefined || opts.accountName === null) { + throw new Error( + "Missing the required parameter 'opts.accountName' when calling resetPassword" + ) + } + + let postBody = {} + if (opts.accountPassword !== undefined && opts.accountPassword !== null) { + postBody['accountPassword'] = opts.accountPassword + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + accountName: opts.accountName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 resetPassword 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}/instances/{instanceId}/accounts/{accountName}:resetPassword', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string azs + */ + + azs (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 azs" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 azs 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}/azs', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer engineStatus + * @param az orderableAZs + */ + + orderableInstanceType (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 orderableInstanceType" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 orderableInstanceType 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}/OrderableInstanceType', + '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) + } + ) + } + + /** + * 创建一个Clickhouse实例 + * @param {Object} opts - parameters + * @param {clickhouseInstanceSpec} opts.instanceSpec - 新建实例规格 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string instanceId + * @param string orderId + * @param string buyId + */ + + createInstance (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 createInstance" + ) + } + + opts = opts || {} + + if (opts.instanceSpec === undefined || opts.instanceSpec === null) { + throw new Error( + "Missing the required parameter 'opts.instanceSpec' when calling createInstance" + ) + } + + let postBody = {} + 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 clickhouse/0.4.0' + } + + 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 createInstance 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}/instances', + '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) + } + ) + } + + /** + * Clickhouse实例变配 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {} [opts.chNodeClass] - clickhouse实例规格 optional + * @param {} [opts.zkNodeClass] - zookeeper实例规格 optional + * @param {} [opts.chNodeStorageGB] - clickhouse实例磁盘大小(GB) optional + * @param {} [opts.monitorNodeClass] - 监控实例规格 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string instanceId + * @param string orderId + * @param string buyId + */ + + 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" + ) + } + + let postBody = {} + if (opts.chNodeClass !== undefined && opts.chNodeClass !== null) { + postBody['chNodeClass'] = opts.chNodeClass + } + if (opts.zkNodeClass !== undefined && opts.zkNodeClass !== null) { + postBody['zkNodeClass'] = opts.zkNodeClass + } + if (opts.chNodeStorageGB !== undefined && opts.chNodeStorageGB !== null) { + postBody['chNodeStorageGB'] = opts.chNodeStorageGB + } + if (opts.monitorNodeClass !== undefined && opts.monitorNodeClass !== null) { + postBody['monitorNodeClass'] = opts.monitorNodeClass + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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}/instances/{instanceId}: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) + } + ) + } + + /** + * 查询 Clickhouse 实例的详细信息 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param clickhouseInstanceAttributes clickhouseInstanceAttributes + */ + + describeInstanceAttributes (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 describeInstanceAttributes" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeInstanceAttributes" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 describeInstanceAttributes 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}/instances/{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) + } + ) + } + + /** + * 删除一个Clickhouse实例 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + 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 || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteInstance" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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}/instances/{instanceId}', + '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,∞)。pageNumber为-1时,返回所有数据页码;超过总页数时,显示最后一页; optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[10,100],用于查询列表的接口 optional + * @param {filter} [opts.filters] - 过滤参数,多个过滤参数之间的关系为“与”(and) +支持以下属性的过滤: +instanceId, 支持operator选项:eq,ne +resourceId, 支持operator选项:eq,ne +instanceName, 支持operator选项:eq,ne,like +instanceStatus, 支持operator选项:eq,ne + optional + * @param {tagFilter} [opts.tagFilters] - 资源标签 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instance instances + * @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 + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + Object.assign( + queryParams, + super.buildTagFilterParam(opts.tagFilters, 'tagFilters') + ) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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}/instances: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) + } + ) + } + + /** + * 查询 node 可用规格 + * @param {Object} opts - parameters + * @param {string} [opts.nodeType] - 节点类型 CH ZK Monitor optional + * @param {string} [opts.nodeStorageType] - 存储类型: EBS_SSD optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param chSpec chSpec + * @param zkSpec zkSpec + * @param monitorSpec monitorSpec + */ + + describeNodeClasses (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 describeNodeClasses" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.nodeType !== undefined && opts.nodeType !== null) { + queryParams['nodeType'] = opts.nodeType + } + if (opts.nodeStorageType !== undefined && opts.nodeStorageType !== null) { + queryParams['nodeStorageType'] = opts.nodeStorageType + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 describeNodeClasses 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}/instances:describeNodeClasses', + '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) + } + ) + } + + /** + * 查询 Clickhouse 推荐规格 + * @param {Object} opts - parameters + * @param {string} [opts.chNodeClass] - 计算节点规格 optional + * @param {integer} [opts.shardNum] - 分片数 optional + * @param {integer} [opts.replicaNum] - 副本数 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string zkNodeClass + * @param integer zkNodeNum + * @param integer zkNodeCPU + * @param integer zkNodeMemoryGB + * @param integer zkNodeStorageGB + * @param string monitorNodeClass + * @param integer monitorNodeCPU + * @param integer monitorNodeMemoryGB + * @param integer monitorNodeStorageGB + */ + + describeDefaultConfig (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 describeDefaultConfig" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.chNodeClass !== undefined && opts.chNodeClass !== null) { + queryParams['chNodeClass'] = opts.chNodeClass + } + if (opts.shardNum !== undefined && opts.shardNum !== null) { + queryParams['shardNum'] = opts.shardNum + } + if (opts.replicaNum !== undefined && opts.replicaNum !== null) { + queryParams['replicaNum'] = opts.replicaNum + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 describeDefaultConfig 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}/instances:describeDefaultConfig', + '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 string podIds + */ + + describePodMap (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 describePodMap" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describePodMap" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 describePodMap 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}/instances/{instanceId}:describePodMap', + '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 shards shards + * @param integer shardNum 分片数量 + * @param integer replicaNum 副本数 + * @param string publicDomainName 实例公网域名 + * @param string internalDomainName 实例内网域名 + */ + + describeDomainNames (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 describeDomainNames" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeDomainNames" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 describeDomainNames 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}/instances/{instanceId}:describeDomainNames', + '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) + } + ) + } + + /** + * 强行删除DRDS实例,包括包年包月未过期实例 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {} opts.requestUser - 发出请求的运营后台的ERP账号 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteInstanceByForce (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 deleteInstanceByForce" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteInstanceByForce" + ) + } + if (opts.requestUser === undefined || opts.requestUser === null) { + throw new Error( + "Missing the required parameter 'opts.requestUser' when calling deleteInstanceByForce" + ) + } + + let postBody = {} + if (opts.requestUser !== undefined && opts.requestUser !== null) { + postBody['requestUser'] = opts.requestUser + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 deleteInstanceByForce 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}/instances/{instanceId}:deleteInstanceByForce', + '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 - 实例ID + * @param {string} opts.instanceName - 实例名 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyInstanceName (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 modifyInstanceName" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyInstanceName" + ) + } + if (opts.instanceName === undefined || opts.instanceName === null) { + throw new Error( + "Missing the required parameter 'opts.instanceName' when calling modifyInstanceName" + ) + } + + let postBody = {} + if (opts.instanceName !== undefined && opts.instanceName !== null) { + postBody['instanceName'] = opts.instanceName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 modifyInstanceName 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}/instances/{instanceId}:modifyInstanceName', + '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 - 实例ID + * @param {string} opts.targetVersion - 集群版本号 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + upgradeEngineVersion (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 upgradeEngineVersion" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling upgradeEngineVersion" + ) + } + if (opts.targetVersion === undefined || opts.targetVersion === null) { + throw new Error( + "Missing the required parameter 'opts.targetVersion' when calling upgradeEngineVersion" + ) + } + + let postBody = {} + if (opts.targetVersion !== undefined && opts.targetVersion !== null) { + postBody['targetVersion'] = opts.targetVersion + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 upgradeEngineVersion 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}/instances/{instanceId}:upgradeEngineVersion', + '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 - 实例ID + * @param {string} opts.serviceType - 服务类型(database/monitor) + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + disableInternetAccess (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 disableInternetAccess" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling disableInternetAccess" + ) + } + if (opts.serviceType === undefined || opts.serviceType === null) { + throw new Error( + "Missing the required parameter 'opts.serviceType' when calling disableInternetAccess" + ) + } + + let postBody = {} + if (opts.serviceType !== undefined && opts.serviceType !== null) { + postBody['serviceType'] = opts.serviceType + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 disableInternetAccess 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}/instances/{instanceId}:disableInternetAccess', + '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 - 实例ID + * @param {string} opts.serviceType - 服务类型 (database/monitor) + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + enableInternetAccess (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 enableInternetAccess" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling enableInternetAccess" + ) + } + if (opts.serviceType === undefined || opts.serviceType === null) { + throw new Error( + "Missing the required parameter 'opts.serviceType' when calling enableInternetAccess" + ) + } + + let postBody = {} + if (opts.serviceType !== undefined && opts.serviceType !== null) { + postBody['serviceType'] = opts.serviceType + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 enableInternetAccess 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}/instances/{instanceId}:enableInternetAccess', + '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) + } + ) + } + + /** + * 查询 Clickhouse 节点信息 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {integer} [opts.pageNumber] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageNumber为-1时,返回所有数据页码;超过总页数时,显示最后一页; optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为50,取值范围:[50,100],用于查询列表的接口 optional + * @param {filter} [opts.filters] - nodeStatus, 支持operator选项:eq ne + optional + * @param {sort} [opts.sorts] - nodeId - node序号 +cpuUtil - CPU使用率 +memeryUtil - 内存使用率 +diskUsage - 磁盘使用率 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param node nodes + * @param number totalCount + */ + + describeNodes (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 describeNodes" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeNodes" + ) + } + + 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')) + Object.assign(queryParams, super.buildSortParam(opts.sorts, 'sorts')) + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 describeNodes 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}/instances/{instanceId}/nodes', + '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) + } + ) + } + + /** + * 查询 Clickhouse 集群进度 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {integer} [opts.backendProgress] - 是否获取创建域名进度,0不需要,1需要 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer instanceReadyDomain 就绪的域名个数 + * @param integer instanceTotalDomain 总域名个数 + * @param integer instanceReadyNode 就绪的节点个数 + * @param integer instanceTotalNode 总节点个数 + */ + + describeProgress (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 describeProgress" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeProgress" + ) + } + + let postBody = null + let queryParams = {} + if (opts.backendProgress !== undefined && opts.backendProgress !== null) { + queryParams['backendProgress'] = opts.backendProgress + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 describeProgress 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}/instances/{instanceId}/progress', + '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) + } + ) + } + + /** + * 根据实例的的id,获取实例相关信息。 + * @param {Object} opts - parameters + * @param {string} opts.resourceList - 资源id列表(多个以,分隔) + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param resourceInfo data + */ + + selectDetailList (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 selectDetailList" + ) + } + + opts = opts || {} + + if (opts.resourceList === undefined || opts.resourceList === null) { + throw new Error( + "Missing the required parameter 'opts.resourceList' when calling selectDetailList" + ) + } + + let postBody = null + let queryParams = {} + if (opts.resourceList !== undefined && opts.resourceList !== null) { + queryParams['resourceList'] = opts.resourceList + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 selectDetailList 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}/instances:selectDetailList', + '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 boolean cloudStorageLock 当前实例是否已开启云盘扩容锁,如已开启,返回true,如未开启,返回false + * @param boolean parametersGroupLock 当前实例是否已开启参数组锁,如已开启,返回true,如未开启,返回false + */ + + internalDescribeInstance (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 internalDescribeInstance" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling internalDescribeInstance" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 internalDescribeInstance 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}/instances/{instanceId}:internalDescribeInstance', + '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.pin - pin + * @param {string} [opts.instanceId] - instanceId optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + enableCloudDiskCapacity (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 enableCloudDiskCapacity" + ) + } + + opts = opts || {} + + if (opts.pin === undefined || opts.pin === null) { + throw new Error( + "Missing the required parameter 'opts.pin' when calling enableCloudDiskCapacity" + ) + } + + let postBody = {} + if (opts.pin !== undefined && opts.pin !== null) { + postBody['pin'] = opts.pin + } + 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 clickhouse/0.4.0' + } + + 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 enableCloudDiskCapacity 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}/cloudDiskCapacity:enableCloudDiskCapacity', + '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.pin - pin + * @param {string} [opts.instanceId] - instanceId optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + disableCloudDiskCapacity (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 disableCloudDiskCapacity" + ) + } + + opts = opts || {} + + if (opts.pin === undefined || opts.pin === null) { + throw new Error( + "Missing the required parameter 'opts.pin' when calling disableCloudDiskCapacity" + ) + } + + let postBody = {} + if (opts.pin !== undefined && opts.pin !== null) { + postBody['pin'] = opts.pin + } + 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 clickhouse/0.4.0' + } + + 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 disableCloudDiskCapacity 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}/cloudDiskCapacity:disableCloudDiskCapacity', + '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) + } + ) + } + + /** + * 当实例欠费或者到期了,关闭Clickhouse实例的网络访问功能 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + detachNetwork (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 detachNetwork" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling detachNetwork" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 detachNetwork 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}/instances/{instanceId}:detachNetwork', + '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) + } + ) + } + + /** + * 当实例不欠费了或者续费了,开启Clickhouse实例的网络访问功能。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + attachNetwork (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 attachNetwork" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling attachNetwork" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 attachNetwork 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}/instances/{instanceId}:attachNetwork', + '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) + } + ) + } + + /** + * 查询 Clickhouse audit列表信息 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {integer} [opts.pageNumber] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageNumber为-1时,返回所有数据页码;超过总页数时,显示最后一页; optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[10,100],用于查询列表的接口 optional + * @param {string} [opts.startTime] - 开始时间 optional + * @param {string} [opts.endTime] - 结束时间 optional + * @param {string} [opts.segmentName] - 节点名称 optional + * @param {filter} [opts.filters] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param auditLog auditResult + * @param number totalCount + */ + + describeAuditResult (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 describeAuditResult" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeAuditResult" + ) + } + + 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.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.segmentName !== undefined && opts.segmentName !== null) { + queryParams['segmentName'] = opts.segmentName + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 describeAuditResult 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}/instances/{instanceId}/audit:describeAuditResult', + '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) + } + ) + } + + /** + * 查询 Clickhouse audit列表信息 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {integer} [opts.pageNumber] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageNumber为-1时,返回所有数据页码;超过总页数时,显示最后一页; optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[10,100],用于查询列表的接口 optional + * @param {string} [opts.startTime] - 开始时间 optional + * @param {string} [opts.endTime] - 结束时间 optional + * @param {string} [opts.segmentName] - 节点名称 optional + * @param {string} [opts.queryTime] - 查询时间 optional + * @param {filter} [opts.filters] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param slowLog slowlogResult + * @param number totalCount + */ + + describeSlowlogResult (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 describeSlowlogResult" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeSlowlogResult" + ) + } + + 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.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.segmentName !== undefined && opts.segmentName !== null) { + queryParams['segmentName'] = opts.segmentName + } + if (opts.queryTime !== undefined && opts.queryTime !== null) { + queryParams['queryTime'] = opts.queryTime + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 describeSlowlogResult 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}/instances/{instanceId}/slowlog:describeSlowlogResult', + '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) + } + ) + } + + /** + * 查看JCHDB实例的配置参数。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID,唯一标识一个实例 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instanceParameter parameters + */ + + describeParameters (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 describeParameters" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeParameters" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 describeParameters 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}/instances/{instanceId}/parameters', + '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 {} [opts.parameters] - 目前支持的参数 keep_alive_timeout、max_connections、max_partition_size_to_drop、max_table_size_to_drop、max_concurrent_queries、uncompressed_cache_size、mark_cache_size、use_uncompressed_cache、max_memory_usage、distributed_ddl_task_timeout、background_pool_size、max_memory_usage_for_all_queries、max_query_size、max_partitions_per_insert_block optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyParameters (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 modifyParameters" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyParameters" + ) + } + + let postBody = {} + if (opts.parameters !== undefined && opts.parameters !== null) { + postBody['parameters'] = opts.parameters + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 modifyParameters 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}/instances/{instanceId}/parameters', + '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) + } + ) + } + + /** + * 查询k8s集群支持的集群外访问方式 + * @param {Object} opts - parameters + * @param {string} opts.vpcId - vpcId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string exposeType exposeType,目前支持的可选项:NodePort、LoadBalancer + */ + + describeExposeType (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 describeExposeType" + ) + } + + opts = opts || {} + + if (opts.vpcId === undefined || opts.vpcId === null) { + throw new Error( + "Missing the required parameter 'opts.vpcId' when calling describeExposeType" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + vpcId: opts.vpcId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 describeExposeType 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}/vpcs/{vpcId}:describeExposeType', + '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段列表,缺省情况下,白名单对本VPC开放。如果用户开启了外网访问的功能,还需要对外网的IP配置白名单。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID,唯一标识一个实例 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param whiteList whiteLists + */ + + describeWhiteList (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 describeWhiteList" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeWhiteList" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 describeWhiteList 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}/instances/{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 - 实例ID,唯一标识一个实例 + * @param {string} opts.ips - IP或IP段,不同的IP/IP段之间用英文逗号分隔,例如0.0.0.0/0,192.168.0.10 + * @param {string} opts.name - 白名单分组名 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyWhiteList (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 modifyWhiteList" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyWhiteList" + ) + } + if (opts.ips === undefined || opts.ips === null) { + throw new Error( + "Missing the required parameter 'opts.ips' when calling modifyWhiteList" + ) + } + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling modifyWhiteList" + ) + } + + let postBody = {} + if (opts.ips !== undefined && opts.ips !== null) { + postBody['ips'] = opts.ips + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 modifyWhiteList 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}/instances/{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) + } + ) + } + + /** + * 删除白名单分组。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID,唯一标识一个实例 + * @param {string} opts.name - 白名单分组名 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteWhiteListGroup (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 deleteWhiteListGroup" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteWhiteListGroup" + ) + } + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling deleteWhiteListGroup" + ) + } + + let postBody = null + let queryParams = {} + if (opts.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 deleteWhiteListGroup 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}/instances/{instanceId}/whiteList', + '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.instanceId - 实例ID,唯一标识一个实例 + * @param {string} opts.name - 白名单分组名 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + addWhiteListGroup (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 addWhiteListGroup" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling addWhiteListGroup" + ) + } + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling addWhiteListGroup" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clickhouse/0.4.0' + } + + 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 addWhiteListGroup 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}/instances/{instanceId}/whiteList:addWhiteListGroup', + '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 = CLICKHOUSE diff --git a/packages/libs/lib-jdcloud/src/repo/cloudauth/v1/cloudauth.js b/packages/libs/lib-jdcloud/src/repo/cloudauth/v1/cloudauth.js new file mode 100644 index 000000000..695438f25 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/cloudauth/v1/cloudauth.js @@ -0,0 +1,3186 @@ +/* + * 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. + * + * 用户管理接口 + * 实名认证-用户管理接口 + * + * 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 = 'cloudauth' +Service._services[serviceId] = true + +/** + * cloudauth service. + * @version 1.0.16 + */ + +class CLOUDAUTH extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'cloudauth.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 个人实名认证 + * @param {Object} opts - parameters + * @param {personalSpec} opts.personalSpec + * @param {string} callback - callback + @return {Object} result + * @param authInfo authInfo + */ + + personalAuth (opts, callback) { + opts = opts || {} + + if (opts.personalSpec === undefined || opts.personalSpec === null) { + throw new Error( + "Missing the required parameter 'opts.personalSpec' when calling personalAuth" + ) + } + + let postBody = {} + if (opts.personalSpec !== undefined && opts.personalSpec !== null) { + postBody['personalSpec'] = opts.personalSpec + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudauth/1.0.16' + } + + 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 personalAuth 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( + '/personal', + '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 {personalMobileSpec} opts.personalMobileSpec + * @param {string} callback - callback + @return {Object} result + * @param authInfo authInfo + */ + + personalMobile (opts, callback) { + opts = opts || {} + + if ( + opts.personalMobileSpec === undefined || + opts.personalMobileSpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.personalMobileSpec' when calling personalMobile" + ) + } + + let postBody = {} + if ( + opts.personalMobileSpec !== undefined && + opts.personalMobileSpec !== null + ) { + postBody['personalMobileSpec'] = opts.personalMobileSpec + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudauth/1.0.16' + } + + 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 personalMobile 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( + '/detail:mobile3', + '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 {personalBankcard} opts.personalSpec + * @param {string} callback - callback + @return {Object} result + * @param authInfo authInfo + */ + + personalBankcard3Detail (opts, callback) { + opts = opts || {} + + if (opts.personalSpec === undefined || opts.personalSpec === null) { + throw new Error( + "Missing the required parameter 'opts.personalSpec' when calling personalBankcard3Detail" + ) + } + + let postBody = {} + if (opts.personalSpec !== undefined && opts.personalSpec !== null) { + postBody['personalSpec'] = opts.personalSpec + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudauth/1.0.16' + } + + 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 personalBankcard3Detail 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( + '/detail:bankcard3', + '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 {personalBankcardOther} opts.personalSpec + * @param {string} callback - callback + @return {Object} result + * @param authInfo authInfo + */ + + personalBankcard3Other (opts, callback) { + opts = opts || {} + + if (opts.personalSpec === undefined || opts.personalSpec === null) { + throw new Error( + "Missing the required parameter 'opts.personalSpec' when calling personalBankcard3Other" + ) + } + + let postBody = {} + if (opts.personalSpec !== undefined && opts.personalSpec !== null) { + postBody['personalSpec'] = opts.personalSpec + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudauth/1.0.16' + } + + 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 personalBankcard3Other 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( + '/other:bankcard3', + '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 {personalBankcard} opts.personalSpec + * @param {string} callback - callback + @return {Object} result + * @param authInfo authInfo + */ + + personalBankcard4Detail (opts, callback) { + opts = opts || {} + + if (opts.personalSpec === undefined || opts.personalSpec === null) { + throw new Error( + "Missing the required parameter 'opts.personalSpec' when calling personalBankcard4Detail" + ) + } + + let postBody = {} + if (opts.personalSpec !== undefined && opts.personalSpec !== null) { + postBody['personalSpec'] = opts.personalSpec + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudauth/1.0.16' + } + + 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 personalBankcard4Detail 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( + '/detail:bankcard4', + '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 {personalBankcardOther} opts.personalSpec + * @param {string} callback - callback + @return {Object} result + * @param authInfo authInfo + */ + + personalBankcard4Other (opts, callback) { + opts = opts || {} + + if (opts.personalSpec === undefined || opts.personalSpec === null) { + throw new Error( + "Missing the required parameter 'opts.personalSpec' when calling personalBankcard4Other" + ) + } + + let postBody = {} + if (opts.personalSpec !== undefined && opts.personalSpec !== null) { + postBody['personalSpec'] = opts.personalSpec + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudauth/1.0.16' + } + + 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 personalBankcard4Other 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( + '/other:bankcard4', + '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 {accountInfo} opts.accountInfo + * @param {string} callback - callback + @return {Object} result + * @param authInfo authInfo + */ + + companyTransfer (opts, callback) { + opts = opts || {} + + if (opts.accountInfo === undefined || opts.accountInfo === null) { + throw new Error( + "Missing the required parameter 'opts.accountInfo' when calling companyTransfer" + ) + } + + let postBody = {} + if (opts.accountInfo !== undefined && opts.accountInfo !== null) { + postBody['accountInfo'] = opts.accountInfo + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudauth/1.0.16' + } + + 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 companyTransfer 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( + '/company:transfer', + '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 {checkInfo} opts.checkInfo + * @param {string} callback - callback + @return {Object} result + * @param authInfo authInfo + */ + + checkCompanyTransfer (opts, callback) { + opts = opts || {} + + if (opts.checkInfo === undefined || opts.checkInfo === null) { + throw new Error( + "Missing the required parameter 'opts.checkInfo' when calling checkCompanyTransfer" + ) + } + + let postBody = {} + if (opts.checkInfo !== undefined && opts.checkInfo !== null) { + postBody['checkInfo'] = opts.checkInfo + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudauth/1.0.16' + } + + 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 checkCompanyTransfer 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( + '/company:check', + '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.orderNumber - 订单号 + * @param {string} callback - callback + @return {Object} result + * @param authInfo authInfo + */ + + queryCompanyTransfer (opts, callback) { + opts = opts || {} + + if (opts.orderNumber === undefined || opts.orderNumber === null) { + throw new Error( + "Missing the required parameter 'opts.orderNumber' when calling queryCompanyTransfer" + ) + } + + let postBody = {} + if (opts.orderNumber !== undefined && opts.orderNumber !== null) { + postBody['orderNumber'] = opts.orderNumber + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudauth/1.0.16' + } + + 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 queryCompanyTransfer 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( + '/company:transferStatus', + '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 {companyInfo} opts.companyInfo + * @param {string} callback - callback + @return {Object} result + * @param authInfo authInfo + */ + + checkCompanyInfo (opts, callback) { + opts = opts || {} + + if (opts.companyInfo === undefined || opts.companyInfo === null) { + throw new Error( + "Missing the required parameter 'opts.companyInfo' when calling checkCompanyInfo" + ) + } + + let postBody = {} + if (opts.companyInfo !== undefined && opts.companyInfo !== null) { + postBody['companyInfo'] = opts.companyInfo + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudauth/1.0.16' + } + + 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 checkCompanyInfo 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( + '/company:info', + '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 {legalPersonSpec} opts.legalPersonSpec + * @param {string} callback - callback + @return {Object} result + * @param authInfo authInfo + */ + + checkLegalPerson (opts, callback) { + opts = opts || {} + + if (opts.legalPersonSpec === undefined || opts.legalPersonSpec === null) { + throw new Error( + "Missing the required parameter 'opts.legalPersonSpec' when calling checkLegalPerson" + ) + } + + let postBody = {} + if (opts.legalPersonSpec !== undefined && opts.legalPersonSpec !== null) { + postBody['legalPersonSpec'] = opts.legalPersonSpec + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudauth/1.0.16' + } + + 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 checkLegalPerson 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( + '/company:legalPerson', + '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 {legalPersonSpec} opts.legalPersonSpec + * @param {string} callback - callback + @return {Object} result + * @param authInfo authInfo + */ + + checkLegalPersonDetail (opts, callback) { + opts = opts || {} + + if (opts.legalPersonSpec === undefined || opts.legalPersonSpec === null) { + throw new Error( + "Missing the required parameter 'opts.legalPersonSpec' when calling checkLegalPersonDetail" + ) + } + + let postBody = {} + if (opts.legalPersonSpec !== undefined && opts.legalPersonSpec !== null) { + postBody['legalPersonSpec'] = opts.legalPersonSpec + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudauth/1.0.16' + } + + 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 checkLegalPersonDetail 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( + '/company:legalPersonDetail', + '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 {companyInfo3Spec} opts.companyInfo3Spec + * @param {string} callback - callback + @return {Object} result + * @param authInfo authInfo + */ + + checkCompanyInfo3 (opts, callback) { + opts = opts || {} + + if (opts.companyInfo3Spec === undefined || opts.companyInfo3Spec === null) { + throw new Error( + "Missing the required parameter 'opts.companyInfo3Spec' when calling checkCompanyInfo3" + ) + } + + let postBody = {} + if (opts.companyInfo3Spec !== undefined && opts.companyInfo3Spec !== null) { + postBody['companyInfo3Spec'] = opts.companyInfo3Spec + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudauth/1.0.16' + } + + 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 checkCompanyInfo3 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( + '/company:info3', + '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.provinceCode - 省份代码 + * @param {string} callback - callback + @return {Object} result + * @param boolean success 认证结果true 成功, false 失败 + * @param boolean hasException 是否有异常 true 有异常, false 无异常 + * @param string code 认证结果状态码 + * @param string message 认证结果 + * @param string detail 字符串形式的查询结果,内容为json + */ + + queryCityList (opts, callback) { + opts = opts || {} + + if (opts.provinceCode === undefined || opts.provinceCode === null) { + throw new Error( + "Missing the required parameter 'opts.provinceCode' when calling queryCityList" + ) + } + + let postBody = null + let queryParams = {} + if (opts.provinceCode !== undefined && opts.provinceCode !== null) { + queryParams['provinceCode'] = opts.provinceCode + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudauth/1.0.16' + } + + 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 queryCityList 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( + '/query:cityList', + '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 {accountInfoSimple} opts.accountInfo + * @param {string} callback - callback + @return {Object} result + * @param authInfo authInfo + */ + + companyTransferSimple (opts, callback) { + opts = opts || {} + + if (opts.accountInfo === undefined || opts.accountInfo === null) { + throw new Error( + "Missing the required parameter 'opts.accountInfo' when calling companyTransferSimple" + ) + } + + let postBody = {} + if (opts.accountInfo !== undefined && opts.accountInfo !== null) { + postBody['accountInfo'] = opts.accountInfo + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudauth/1.0.16' + } + + 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 companyTransferSimple 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( + '/company:transferSimple', + '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} callback - callback + @return {Object} result + * @param boolean success 认证结果true 成功, false 失败 + * @param boolean hasException 是否有异常 true 有异常, false 无异常 + * @param string code 认证结果状态码 + * @param string message 认证结果 + * @param string detail 字符串形式的查询结果,内容为json + */ + + queryProvinceList (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudauth/1.0.16' + } + + 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 queryProvinceList 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( + '/query:provinceList', + '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} callback - callback + @return {Object} result + * @param boolean success 认证结果true 成功, false 失败 + * @param boolean hasException 是否有异常 true 有异常, false 无异常 + * @param string code 认证结果状态码 + * @param string message 认证结果 + * @param string detail 字符串形式的查询结果,内容为json + */ + + queryBankList (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudauth/1.0.16' + } + + 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 queryBankList 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( + '/query:bankList', + '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.bankCode - 银行代码 + * @param {string} opts.cityCode - 城市代码 + * @param {string} callback - callback + @return {Object} result + * @param boolean success 认证结果true 成功, false 失败 + * @param boolean hasException 是否有异常 true 有异常, false 无异常 + * @param string code 认证结果状态码 + * @param string message 认证结果 + * @param string detail 字符串形式的查询结果,内容为json + */ + + queryBankBranchList (opts, callback) { + opts = opts || {} + + if (opts.bankCode === undefined || opts.bankCode === null) { + throw new Error( + "Missing the required parameter 'opts.bankCode' when calling queryBankBranchList" + ) + } + if (opts.cityCode === undefined || opts.cityCode === null) { + throw new Error( + "Missing the required parameter 'opts.cityCode' when calling queryBankBranchList" + ) + } + + let postBody = null + let queryParams = {} + if (opts.bankCode !== undefined && opts.bankCode !== null) { + queryParams['bankCode'] = opts.bankCode + } + if (opts.cityCode !== undefined && opts.cityCode !== null) { + queryParams['cityCode'] = opts.cityCode + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudauth/1.0.16' + } + + 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 queryBankBranchList 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( + '/query:bankBranchList', + '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) + } + ) + } + + /** + * 个人身份证OCR + * @param {Object} opts - parameters + * @param {string} opts.imageData - 身份证图像base64(支持base64编码后小于4M,分辨率不高于4096x4096的图像) + * @param {string} callback - callback + @return {Object} result + * @param oCRInfo oCRInfo + */ + + iDCard (opts, callback) { + opts = opts || {} + + if (opts.imageData === undefined || opts.imageData === null) { + throw new Error( + "Missing the required parameter 'opts.imageData' when calling iDCard" + ) + } + + let postBody = {} + if (opts.imageData !== undefined && opts.imageData !== null) { + postBody['imageData'] = opts.imageData + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudauth/1.0.16' + } + + 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 iDCard 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( + '/ocr:IDCard', + '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) + } + ) + } + + /** + * 银行卡OCR + * @param {Object} opts - parameters + * @param {string} opts.imageData - 银行卡图像base64(支持base64编码后小于3M) + * @param {string} callback - callback + @return {Object} result + * @param bankCardOCRInfo bankCardOCRInfo + */ + + bankCardOCR (opts, callback) { + opts = opts || {} + + if (opts.imageData === undefined || opts.imageData === null) { + throw new Error( + "Missing the required parameter 'opts.imageData' when calling bankCardOCR" + ) + } + + let postBody = {} + if (opts.imageData !== undefined && opts.imageData !== null) { + postBody['imageData'] = opts.imageData + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudauth/1.0.16' + } + + 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 bankCardOCR 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( + '/ocr:BankCard', + '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) + } + ) + } + + /** + * 营业执照OCR + * @param {Object} opts - parameters + * @param {string} opts.imageData - 营业执照图像base64(支持base64编码后小于3M) + * @param {string} callback - callback + @return {Object} result + * @param businessOCRInfo businessOCRInfo + */ + + businessOCR (opts, callback) { + opts = opts || {} + + if (opts.imageData === undefined || opts.imageData === null) { + throw new Error( + "Missing the required parameter 'opts.imageData' when calling businessOCR" + ) + } + + let postBody = {} + if (opts.imageData !== undefined && opts.imageData !== null) { + postBody['imageData'] = opts.imageData + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudauth/1.0.16' + } + + 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 businessOCR 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( + '/ocr:Business', + '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) + } + ) + } + + /** + * H5活体检测获取采集页面链接 + * @param {Object} opts - parameters + * @param {string} [opts.name] - 姓名(需要进行身份核验时传递此参数) optional + * @param {string} [opts.idcard] - 身份证号(需要进行身份核验时传递此参数) optional + * @param {string} opts.returnUrl - 采集结束后自动跳转的目标地址(须以http或https开头,长度不超过128字符) + * @param {string} callback - callback + @return {Object} result + * @param aliveUrlInfo aliveUrlInfo + */ + + getAliveUrl (opts, callback) { + opts = opts || {} + + if (opts.returnUrl === undefined || opts.returnUrl === null) { + throw new Error( + "Missing the required parameter 'opts.returnUrl' when calling getAliveUrl" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.idcard !== undefined && opts.idcard !== null) { + postBody['idcard'] = opts.idcard + } + if (opts.returnUrl !== undefined && opts.returnUrl !== null) { + postBody['returnUrl'] = opts.returnUrl + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudauth/1.0.16' + } + + 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 getAliveUrl 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( + '/alive:getUrl', + '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) + } + ) + } + + /** + * H5活体检测结果 + * @param {Object} opts - parameters + * @param {string} opts.token - 检测token + * @param {string} callback - callback + @return {Object} result + * @param aliveResultInfo aliveResultInfo + */ + + getAliveResult (opts, callback) { + opts = opts || {} + + if (opts.token === undefined || opts.token === null) { + throw new Error( + "Missing the required parameter 'opts.token' when calling getAliveResult" + ) + } + + let postBody = {} + if (opts.token !== undefined && opts.token !== null) { + postBody['token'] = opts.token + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudauth/1.0.16' + } + + 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 getAliveResult 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( + '/alive:getResult', + '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) + } + ) + } + + /** + * H5活体检测获取采集页面链接新版 + * @param {Object} opts - parameters + * @param {string} [opts.name] - 姓名(需要进行身份核验时传递此参数) optional + * @param {string} [opts.idcard] - 身份证号(需要进行身份核验时传递此参数) optional + * @param {string} opts.returnUrl - 采集结束后自动跳转的目标地址(须以http或https开头,长度不超过128字符) + * @param {string} [opts.actions] - 指定动作,逗号隔开。(LookLeft 向左,LookRight 向右,OpenMouth 张嘴,BlinkEye 眨眼,ShakeHead 摇头,NodHead 点头) optional + * @param {boolean} [opts.showFail] - 是否展示失败结果页面 optional + * @param {string} [opts.photo] - 自有源照片(不超过2M) optional + * @param {integer} [opts.photoThresh] - 自有源照片对比通过阈值(0-1000) optional + * @param {string} callback - callback + @return {Object} result + * @param aliveUrlInfo aliveUrlInfo + */ + + getAliveUrlNew (opts, callback) { + opts = opts || {} + + if (opts.returnUrl === undefined || opts.returnUrl === null) { + throw new Error( + "Missing the required parameter 'opts.returnUrl' when calling getAliveUrlNew" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.idcard !== undefined && opts.idcard !== null) { + postBody['idcard'] = opts.idcard + } + if (opts.returnUrl !== undefined && opts.returnUrl !== null) { + postBody['returnUrl'] = opts.returnUrl + } + if (opts.actions !== undefined && opts.actions !== null) { + postBody['actions'] = opts.actions + } + if (opts.showFail !== undefined && opts.showFail !== null) { + postBody['showFail'] = opts.showFail + } + if (opts.photo !== undefined && opts.photo !== null) { + postBody['photo'] = opts.photo + } + if (opts.photoThresh !== undefined && opts.photoThresh !== null) { + postBody['photoThresh'] = opts.photoThresh + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudauth/1.0.16' + } + + 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 getAliveUrlNew 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( + '/alive:getUrlNew', + '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) + } + ) + } + + /** + * H5活体检测结果新版 + * @param {Object} opts - parameters + * @param {string} opts.token - 检测token + * @param {string} callback - callback + @return {Object} result + * @param aliveResultInfo aliveResultInfo + */ + + getAliveResultNew (opts, callback) { + opts = opts || {} + + if (opts.token === undefined || opts.token === null) { + throw new Error( + "Missing the required parameter 'opts.token' when calling getAliveResultNew" + ) + } + + let postBody = {} + if (opts.token !== undefined && opts.token !== null) { + postBody['token'] = opts.token + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudauth/1.0.16' + } + + 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 getAliveResultNew 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( + '/alive:getResultNew', + '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.token - 移动端获取的token + * @param {string} [opts.userInformation] - 浏览器加密指纹(H5时必传) optional + * @param {integer} opts.appType - 应用类型(1 ios应用;2 H5应用;3 安卓应用) + * @param {string} callback - callback + @return {Object} result + * @param string chargeFlag 1收费,0不收费 + * @param string msisdn 手机号(AES加密,用对应appkey解密) + * @param string code 认证结果状态码 + * @param string message 认证结果 + */ + + oneClick (opts, callback) { + opts = opts || {} + + if (opts.token === undefined || opts.token === null) { + throw new Error( + "Missing the required parameter 'opts.token' when calling oneClick" + ) + } + if (opts.appType === undefined || opts.appType === null) { + throw new Error( + "Missing the required parameter 'opts.appType' when calling oneClick" + ) + } + + let postBody = {} + if (opts.token !== undefined && opts.token !== null) { + postBody['token'] = opts.token + } + if (opts.userInformation !== undefined && opts.userInformation !== null) { + postBody['userInformation'] = opts.userInformation + } + if (opts.appType !== undefined && opts.appType !== null) { + postBody['appType'] = opts.appType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudauth/1.0.16' + } + + 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 oneClick 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( + '/oneClick:login', + '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.phoneNumber] - 手机号(手机号和身份证号不能同时为空) optional + * @param {string} [opts.idNumber] - 身份证号(手机号和身份证号不能同时为空) optional + * @param {string} [opts.address] - 详细地址 optional + * @param {string} opts.customerCode - 商户号 + * @param {string} callback - callback + @return {Object} result + * @param string chargeFlag 1收费,0不收费 + * @param string code 认证结果状态码 + * @param string message 认证结果 + * @param string taskId taskId(查询地址时需要) + * @param string detail 描述详细信息 + */ + + addressInfo (opts, callback) { + opts = opts || {} + + if (opts.customerCode === undefined || opts.customerCode === null) { + throw new Error( + "Missing the required parameter 'opts.customerCode' when calling addressInfo" + ) + } + + let postBody = {} + if (opts.phoneNumber !== undefined && opts.phoneNumber !== null) { + postBody['phoneNumber'] = opts.phoneNumber + } + if (opts.idNumber !== undefined && opts.idNumber !== null) { + postBody['idNumber'] = opts.idNumber + } + if (opts.address !== undefined && opts.address !== null) { + postBody['address'] = opts.address + } + if (opts.customerCode !== undefined && opts.customerCode !== null) { + postBody['customerCode'] = opts.customerCode + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudauth/1.0.16' + } + + 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 addressInfo 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( + '/address:info', + '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.taskId - taskId(查询接口返回) + * @param {string} opts.customerCode - 商户号 + * @param {string} callback - callback + @return {Object} result + * @param string code 认证结果状态码 + * @param string message 认证结果 + * @param data data 详细信息 + */ + + addressDetail (opts, callback) { + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling addressDetail" + ) + } + if (opts.customerCode === undefined || opts.customerCode === null) { + throw new Error( + "Missing the required parameter 'opts.customerCode' when calling addressDetail" + ) + } + + let postBody = {} + if (opts.taskId !== undefined && opts.taskId !== null) { + postBody['taskId'] = opts.taskId + } + if (opts.customerCode !== undefined && opts.customerCode !== null) { + postBody['customerCode'] = opts.customerCode + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudauth/1.0.16' + } + + 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 addressDetail 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( + '/address:detail', + '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.mobile - 手机号码 + * @param {string} callback - callback + @return {Object} result + * @param string code 认证结果状态码 + * @param string message 认证结果描述 + * @param string chargeFlag 是否收费:0不收费,1收费 + * @param string area 归属地 + * @param string operator 运营商 + * @param string status 号码状态(1 正常 2 空号 3 通话中 4 不在网(空号) 5 关机 7 在网但不可用 13 停机 10 未知 9 服务器异常 12 不存在的号码) + * @param string mnpStatus 是否携号转网 1-是 0-否 + */ + + mobileStatus (opts, callback) { + opts = opts || {} + + if (opts.mobile === undefined || opts.mobile === null) { + throw new Error( + "Missing the required parameter 'opts.mobile' when calling mobileStatus" + ) + } + + let postBody = {} + if (opts.mobile !== undefined && opts.mobile !== null) { + postBody['mobile'] = opts.mobile + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudauth/1.0.16' + } + + 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 mobileStatus 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( + '/mobile:status', + '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} callback - callback + @return {Object} result + * @param string pin 用户pin + * @param integer status 当前服务状态(0 未开通 1 开通中 2 正常 3 停服 ) + * @param string applyTime 申请开通服务时间 + */ + + describeApplyStatus (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudauth/1.0.16' + } + + 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 describeApplyStatus 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( + '/manage:applyStatus', + '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 = CLOUDAUTH diff --git a/packages/libs/lib-jdcloud/src/repo/clouddnsservice/v1/clouddnsservice.js b/packages/libs/lib-jdcloud/src/repo/clouddnsservice/v1/clouddnsservice.js new file mode 100644 index 000000000..161c40cd1 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/clouddnsservice/v1/clouddnsservice.js @@ -0,0 +1,3340 @@ +/* + * 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. + * + * 实例信息 + * 云解析OpenAPI实例信息接口 + * + * 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 = 'clouddnsservice' +Service._services[serviceId] = true + +/** + * clouddnsservice service. + * @version 1.0.12 + */ + +JDCloud.CLOUDDNSSERVICE = class CLOUDDNSSERVICE extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'clouddnsservice.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查看用户在云解析服务下的操作记录 + * @param {Object} opts - parameters + * @param {integer} opts.pageNumber - 分页参数,页的序号,默认是1 + * @param {integer} opts.pageSize - 分页参数,每页含有的结果的数目,默认是10 + * @param {string} opts.startTime - 记录的起始时间,格式:UTC时间例如2017-11-10T23:00:00Z + * @param {string} opts.endTime - 记录的终止时间,格式:UTC时间例如2017-11-10T23:00:00Z + * @param {string} [opts.keyWord] - 日志需要匹配的关键词 optional + * @param {boolean} [opts.success] - 日志里面的结果是成功还是失败 optional + * @param {integer} [opts.type] - 日志的类型 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param actionlog dataList + * @param integer currentCount 当前页的操作记录列表里的个数 + * @param integer totalCount 所有操作记录的个数 + * @param integer totalPage 操作记录列表按照分页参数一共的页数 + */ + + getActionLog (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 getActionLog" + ) + } + + opts = opts || {} + + if (opts.pageNumber === undefined || opts.pageNumber === null) { + throw new Error( + "Missing the required parameter 'opts.pageNumber' when calling getActionLog" + ) + } + if (opts.pageSize === undefined || opts.pageSize === null) { + throw new Error( + "Missing the required parameter 'opts.pageSize' when calling getActionLog" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling getActionLog" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling getActionLog" + ) + } + + 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.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.keyWord !== undefined && opts.keyWord !== null) { + queryParams['keyWord'] = opts.keyWord + } + if (opts.success !== undefined && opts.success !== null) { + queryParams['success'] = opts.success + } + if (opts.type !== undefined && opts.type !== null) { + queryParams['type'] = opts.type + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clouddnsservice/1.0.12' + } + + 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 getActionLog 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 = this.makeRequest( + '/regions/{regionId}/log/actionLog', + '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) + } + ) + } + + /** + * 获取用户所属的主域名列表。 +请在调用域名相关的接口之前,调用此接口获取相关的domainId和domainName。 +主域名的相关概念,请查阅<a href="https://docs.jdcloud.com/cn/jd-cloud-dns/product-overview">云解析文档</a> + + * @param {Object} opts - parameters + * @param {integer} opts.pageNumber - 分页查询时查询的每页的序号,起始值为1,默认为1 + * @param {integer} opts.pageSize - 分页查询时设置的每页行数,默认为10 + * @param {string} [opts.domainName] - 关键字,按照”%domainName%”模式匹配主域名 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param domain dataList + * @param integer currentCount 当前页的域名列表里域名的个数 + * @param integer totalCount 所有匹配的域名列表的个数 + * @param integer totalPage 所有匹配的域名列表按照分页参数一共的页数 + */ + + getDomains (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 getDomains" + ) + } + + opts = opts || {} + + if (opts.pageNumber === undefined || opts.pageNumber === null) { + throw new Error( + "Missing the required parameter 'opts.pageNumber' when calling getDomains" + ) + } + if (opts.pageSize === undefined || opts.pageSize === null) { + throw new Error( + "Missing the required parameter 'opts.pageSize' when calling getDomains" + ) + } + + 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.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clouddnsservice/1.0.12' + } + + 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 getDomains 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 = this.makeRequest( + '/regions/{regionId}/domain', + '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) + } + ) + } + + /** + * 添加主域名 +如何添加免费域名,详细情况请查阅<a href="https://docs.jdcloud.com/cn/jd-cloud-dns/domainadd">文档</a> +添加收费域名,请查阅<a href="https://docs.jdcloud.com/cn/jd-cloud-dns/purchase-process">文档</a>, +添加收费域名前,请确保用户的京东云账户有足够的资金支付,Openapi接口回返回订单号,可以用此订单号向计费系统查阅详情。 + + * @param {Object} opts - parameters + * @param {integer} opts.packId - 主域名的套餐类型, 0->免费 ,1->企业版, 2->高级版 + * @param {string} opts.domainName - 要添加的主域名 + * @param {integer} [opts.domainId] - 主域名的ID,升级套餐必填,请使用getDomains获取 optional + * @param {integer} [opts.buyType] - 1->新购买、3->升级,收费套餐的域名必填 optional + * @param {integer} [opts.timeSpan] - 取值1,2,3 ,含义:时长,收费套餐的域名必填 optional + * @param {integer} [opts.timeUnit] - 时间单位,收费套餐的域名必填,1:小时,2:天,3:月,4:年 optional + * @param {integer} [opts.billingType] - 计费类型,可以不传此参数。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param domainAdded data 新添加的的域名结构 + * @param string order 添加收费版域名的订单号 + */ + + addDomain (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 addDomain" + ) + } + + opts = opts || {} + + if (opts.packId === undefined || opts.packId === null) { + throw new Error( + "Missing the required parameter 'opts.packId' when calling addDomain" + ) + } + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling addDomain" + ) + } + + let postBody = {} + if (opts.packId !== undefined && opts.packId !== null) { + postBody['packId'] = opts.packId + } + if (opts.domainName !== undefined && opts.domainName !== null) { + postBody['domainName'] = opts.domainName + } + if (opts.domainId !== undefined && opts.domainId !== null) { + postBody['domainId'] = opts.domainId + } + if (opts.buyType !== undefined && opts.buyType !== null) { + postBody['buyType'] = opts.buyType + } + if (opts.timeSpan !== undefined && opts.timeSpan !== null) { + postBody['timeSpan'] = opts.timeSpan + } + if (opts.timeUnit !== undefined && opts.timeUnit !== null) { + postBody['timeUnit'] = opts.timeUnit + } + if (opts.billingType !== undefined && opts.billingType !== null) { + postBody['billingType'] = opts.billingType + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clouddnsservice/1.0.12' + } + + 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 addDomain 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 = this.makeRequest( + '/regions/{regionId}/domainAdd', + '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.domainId - 需要删除的主域名ID,请使用getDomains接口获取 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + delDomain (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 delDomain" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling delDomain" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainId !== undefined && opts.domainId !== null) { + queryParams['domainId'] = opts.domainId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clouddnsservice/1.0.12' + } + + 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 delDomain 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 = this.makeRequest( + '/regions/{regionId}/domainDel', + '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.domainName - 需要修改的主域名,请使用getDomains接口获取 + * @param {integer} opts.id - 需要修改的主域名ID,请使用getDomains接口获取 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateDomain (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 updateDomain" + ) + } + + opts = opts || {} + + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling updateDomain" + ) + } + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling updateDomain" + ) + } + + let postBody = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + postBody['domainName'] = opts.domainName + } + if (opts.id !== undefined && opts.id !== null) { + postBody['id'] = opts.id + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clouddnsservice/1.0.12' + } + + 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 updateDomain 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 = this.makeRequest( + '/regions/{regionId}/domainUpdate', + '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.domainId - 域名ID,请使用getDomains接口获取。 + * @param {string} opts.domainName - 查询的主域名,,请使用getDomains接口获取 + * @param {string} opts.start - 查询时间段的起始时间, UTC时间,例如2017-11-10T23:00:00Z + * @param {string} opts.end - 查询时间段的终止时间, UTC时间,例如2017-11-10T23:00:00Z + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer time + * @param integer traffic + */ + + getDomainQueryCount (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 getDomainQueryCount" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling getDomainQueryCount" + ) + } + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling getDomainQueryCount" + ) + } + if (opts.start === undefined || opts.start === null) { + throw new Error( + "Missing the required parameter 'opts.start' when calling getDomainQueryCount" + ) + } + if (opts.end === undefined || opts.end === null) { + throw new Error( + "Missing the required parameter 'opts.end' when calling getDomainQueryCount" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + if (opts.start !== undefined && opts.start !== null) { + queryParams['start'] = opts.start + } + if (opts.end !== undefined && opts.end !== null) { + queryParams['end'] = opts.end + } + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clouddnsservice/1.0.12' + } + + 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 getDomainQueryCount 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/queryCount', + '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.domainId - 域名ID,请使用getDomains接口获取。 + * @param {string} opts.domainName - 主域名,请使用getDomains接口获取 + * @param {string} opts.start - 时间段的起始时间, UTC时间,例如2017-11-10T23:00:00Z + * @param {string} opts.end - 时间段的终止时间, UTC时间,例如2017-11-10T23:00:00Z + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer time + * @param string unit 数据序列的单位 + * @param number traffic + */ + + getDomainQueryTraffic (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 getDomainQueryTraffic" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling getDomainQueryTraffic" + ) + } + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling getDomainQueryTraffic" + ) + } + if (opts.start === undefined || opts.start === null) { + throw new Error( + "Missing the required parameter 'opts.start' when calling getDomainQueryTraffic" + ) + } + if (opts.end === undefined || opts.end === null) { + throw new Error( + "Missing the required parameter 'opts.end' when calling getDomainQueryTraffic" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + if (opts.start !== undefined && opts.start !== null) { + queryParams['start'] = opts.start + } + if (opts.end !== undefined && opts.end !== null) { + queryParams['end'] = opts.end + } + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clouddnsservice/1.0.12' + } + + 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 getDomainQueryTraffic 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/queryTraffic', + '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.domainId - 域名ID,请使用getDomains接口获取。 + * @param {integer} [opts.pageNumber] - 当前页数,起始值为1,默认为1 optional + * @param {integer} [opts.pageSize] - 分页查询时设置的每页行数, 默认为10 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param rR dataList + * @param integer totalCount 所有解析记录的个数 + * @param integer totalPage 所有解析记录的页数 + * @param integer currentCount 当前页解析记录的个数 + */ + + searchRR (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 searchRR" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling searchRR" + ) + } + + 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, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clouddnsservice/1.0.12' + } + + 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 searchRR 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/RR', + '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) + } + ) + } + + /** + * 查询云解析所有的基础解析线路。 +在使用解析线路的参数之前,请调用此接口获取解析线路的ID。 + + * @param {Object} opts - parameters + * @param {string} opts.domainId - 域名ID,请使用getDomains接口获取。 + * @param {integer} [opts.loadMode] - 展示方式,暂时不使用 optional + * @param {integer} opts.packId - 套餐ID,0->免费版 1->企业版 2->企业高级版 + * @param {integer} opts.viewId - view ID,默认为-1 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param viewTree data + */ + + getViewTree (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 getViewTree" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling getViewTree" + ) + } + if (opts.packId === undefined || opts.packId === null) { + throw new Error( + "Missing the required parameter 'opts.packId' when calling getViewTree" + ) + } + if (opts.viewId === undefined || opts.viewId === null) { + throw new Error( + "Missing the required parameter 'opts.viewId' when calling getViewTree" + ) + } + + let postBody = null + let queryParams = {} + if (opts.loadMode !== undefined && opts.loadMode !== null) { + queryParams['loadMode'] = opts.loadMode + } + if (opts.packId !== undefined && opts.packId !== null) { + queryParams['packId'] = opts.packId + } + if (opts.viewId !== undefined && opts.viewId !== null) { + queryParams['viewId'] = opts.viewId + } + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clouddnsservice/1.0.12' + } + + 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 getViewTree 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/viewTree', + '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.domainId - 域名ID,请使用getDomains接口获取。 + * @param {addRR} opts.req - RR参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param rR dataList 添加成功后的解析记录结果 + */ + + addRR (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 addRR" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling addRR" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling addRR" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clouddnsservice/1.0.12' + } + + 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 addRR 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/RRAdd', + '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.domainId - 域名ID,请使用getDomains接口获取。 + * @param {updateRR} opts.req - updateRR参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateRR (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 updateRR" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling updateRR" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling updateRR" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clouddnsservice/1.0.12' + } + + 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 updateRR 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/RRUpdate', + '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.domainId - 域名ID,请使用getDomains接口获取。 + * @param {array} [opts.ids] - 需要操作的解析记录ID,请使用searchRR接口获取。 optional + * @param {string} opts.action - 操作类型,on->启用 off->停用 del->删除 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + operateRR (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 operateRR" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling operateRR" + ) + } + if (opts.action === undefined || opts.action === null) { + throw new Error( + "Missing the required parameter 'opts.action' when calling operateRR" + ) + } + + let postBody = {} + if (opts.ids !== undefined && opts.ids !== null) { + postBody['ids'] = opts.ids + } + if (opts.action !== undefined && opts.action !== null) { + postBody['action'] = opts.action + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clouddnsservice/1.0.12' + } + + 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 operateRR 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/RROperate', + '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) + } + ) + } + + /** + * 同一个主域名下,批量新增或者批量更新导入解析记录。 +如果解析记录的ID为0,是新增解析记录,如果不为0,则是更新解析记录。 + + * @param {Object} opts - parameters + * @param {array} [opts.req] - 需要设置的解析记录列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string data + */ + + batchSetDnsResolve (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 batchSetDnsResolve" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clouddnsservice/1.0.12' + } + + 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 batchSetDnsResolve 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 = this.makeRequest( + '/regions/{regionId}/BatchSetDnsResolve', + '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 {addView} opts.req - 添加自定义线路的参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param userview data 添加成功后返回的自定义线路的结构 + */ + + addUserView (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 addUserView" + ) + } + + opts = opts || {} + + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling addUserView" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clouddnsservice/1.0.12' + } + + 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 addUserView 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 = this.makeRequest( + '/regions/{regionId}/userview/addUserView', + '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 {delView} opts.req - 删除自定义线路的参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + delUserView (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 delUserView" + ) + } + + opts = opts || {} + + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling delUserView" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clouddnsservice/1.0.12' + } + + 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 delUserView 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 = this.makeRequest( + '/regions/{regionId}/userview/delUserView', + '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.domainId - 主域名ID + * @param {integer} opts.viewId - 自定义线路ID + * @param {string} [opts.viewName] - 自定义线路名称, 最多64个字符 optional + * @param {integer} opts.pageNumber - 分页参数,页的序号 + * @param {integer} opts.pageSize - 分页参数,每页含有的结果的数目 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param userViewInput dataList + * @param integer currentCount 当前页的自定义线路列表里的个数 + * @param integer totalCount 所有自定义线路列表的个数 + * @param integer totalPage 所有自定义线路列表按照分页参数一共的页数 + */ + + getUserView (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 getUserView" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling getUserView" + ) + } + if (opts.viewId === undefined || opts.viewId === null) { + throw new Error( + "Missing the required parameter 'opts.viewId' when calling getUserView" + ) + } + if (opts.pageNumber === undefined || opts.pageNumber === null) { + throw new Error( + "Missing the required parameter 'opts.pageNumber' when calling getUserView" + ) + } + if (opts.pageSize === undefined || opts.pageSize === null) { + throw new Error( + "Missing the required parameter 'opts.pageSize' when calling getUserView" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainId !== undefined && opts.domainId !== null) { + queryParams['domainId'] = opts.domainId + } + if (opts.viewId !== undefined && opts.viewId !== null) { + queryParams['viewId'] = opts.viewId + } + if (opts.viewName !== undefined && opts.viewName !== null) { + queryParams['viewName'] = opts.viewName + } + 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 + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clouddnsservice/1.0.12' + } + + 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 getUserView 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 = this.makeRequest( + '/regions/{regionId}/userview/getUserView', + '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段 + * @param {Object} opts - parameters + * @param {addViewIP} opts.req - 添加域名的自定义解析线路的IP段的参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + addUserViewIP (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 addUserViewIP" + ) + } + + opts = opts || {} + + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling addUserViewIP" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clouddnsservice/1.0.12' + } + + 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 addUserViewIP 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 = this.makeRequest( + '/regions/{regionId}/userview/addUserViewIP', + '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) + } + ) + } + + /** + * 删除主域名的自定义解析线路的IP段 + * @param {Object} opts - parameters + * @param {delViewIP} opts.req - 删除域名的自定义解析线路的IP段的参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + delUserViewIP (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 delUserViewIP" + ) + } + + opts = opts || {} + + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling delUserViewIP" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clouddnsservice/1.0.12' + } + + 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 delUserViewIP 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 = this.makeRequest( + '/regions/{regionId}/userview/delUserViewIP', + '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) + } + ) + } + + /** + * 查询主域名的自定义解析线路的IP段 + * @param {Object} opts - parameters + * @param {integer} opts.domainId - 主域名ID + * @param {integer} opts.viewId - 自定义线路ID + * @param {string} [opts.viewName] - 自定义线路名称, 最多64个字符 optional + * @param {integer} opts.pageNumber - 分页参数,页的序号, 默认为1 + * @param {integer} opts.pageSize - 分页参数,每页含有的结果的数目,默认为10 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string dataList + * @param integer currentCount 当前页的IP列表里的个数 + * @param integer totalCount IP列表里的IP段的个数 + * @param integer totalPage IP列表按照分页参数一共的页数 + */ + + getUserViewIP (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 getUserViewIP" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling getUserViewIP" + ) + } + if (opts.viewId === undefined || opts.viewId === null) { + throw new Error( + "Missing the required parameter 'opts.viewId' when calling getUserViewIP" + ) + } + if (opts.pageNumber === undefined || opts.pageNumber === null) { + throw new Error( + "Missing the required parameter 'opts.pageNumber' when calling getUserViewIP" + ) + } + if (opts.pageSize === undefined || opts.pageSize === null) { + throw new Error( + "Missing the required parameter 'opts.pageSize' when calling getUserViewIP" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainId !== undefined && opts.domainId !== null) { + queryParams['domainId'] = opts.domainId + } + if (opts.viewId !== undefined && opts.viewId !== null) { + queryParams['viewId'] = opts.viewId + } + if (opts.viewName !== undefined && opts.viewName !== null) { + queryParams['viewName'] = opts.viewName + } + 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 + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clouddnsservice/1.0.12' + } + + 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 getUserViewIP 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 = this.makeRequest( + '/regions/{regionId}/userview/getUserViewIP', + '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.domainId - 域名ID,请使用getDomains接口获取。 + * @param {integer} [opts.pageIndex] - 当前页数,起始值为1,默认为1 optional + * @param {integer} [opts.pageSize] - 分页查询时设置的每页行数 optional + * @param {string} [opts.searchValue] - 查询的值 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer currentCount 当前页面网站监控项的个数 + * @param integer totalCount 所有网站监控项的个数 + * @param integer totalPage 所有网站监控项的页数 + * @param monitor dataList + */ + + getMonitor (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 getMonitor" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling getMonitor" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.searchValue !== undefined && opts.searchValue !== null) { + queryParams['searchValue'] = opts.searchValue + } + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clouddnsservice/1.0.12' + } + + 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 getMonitor 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/monitor', + '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.domainId - 域名ID,请使用getDomains接口获取。 + * @param {string} opts.subDomainName - 子域名 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + addMonitor (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 addMonitor" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling addMonitor" + ) + } + if (opts.subDomainName === undefined || opts.subDomainName === null) { + throw new Error( + "Missing the required parameter 'opts.subDomainName' when calling addMonitor" + ) + } + + let postBody = {} + if (opts.subDomainName !== undefined && opts.subDomainName !== null) { + postBody['subDomainName'] = opts.subDomainName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clouddnsservice/1.0.12' + } + + 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 addMonitor 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/monitorAdd', + '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.domainId - 域名ID,请使用getDomains接口获取。 + * @param {string} opts.subDomainName - 子域名 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string data + */ + + getTargets (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 getTargets" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling getTargets" + ) + } + if (opts.subDomainName === undefined || opts.subDomainName === null) { + throw new Error( + "Missing the required parameter 'opts.subDomainName' when calling getTargets" + ) + } + + let postBody = null + let queryParams = {} + if (opts.subDomainName !== undefined && opts.subDomainName !== null) { + queryParams['subDomainName'] = opts.subDomainName + } + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clouddnsservice/1.0.12' + } + + 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 getTargets 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/getTargets', + '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.domainId - 域名ID,请使用getDomains接口获取。 + * @param {string} opts.subDomainName - 子域名 + * @param {array} [opts.targets] - 子域名可用监控对象的数组 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + addMonitorTarget (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 addMonitorTarget" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling addMonitorTarget" + ) + } + if (opts.subDomainName === undefined || opts.subDomainName === null) { + throw new Error( + "Missing the required parameter 'opts.subDomainName' when calling addMonitorTarget" + ) + } + + let postBody = {} + if (opts.subDomainName !== undefined && opts.subDomainName !== null) { + postBody['subDomainName'] = opts.subDomainName + } + if (opts.targets !== undefined && opts.targets !== null) { + postBody['targets'] = opts.targets + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clouddnsservice/1.0.12' + } + + 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 addMonitorTarget 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/monitorAddTarget', + '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.domainId - 域名ID,请使用getDomains接口获取。 + * @param {string} opts.action - 删除del, 暂停stop, 开启start, 手动恢复recover,手动切换switch + * @param {array} [opts.ids] - 监控项ID optional + * @param {string} [opts.switchTarget] - 监控项的主机值, 手动切换时必填 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + operateMonitor (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 operateMonitor" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling operateMonitor" + ) + } + if (opts.action === undefined || opts.action === null) { + throw new Error( + "Missing the required parameter 'opts.action' when calling operateMonitor" + ) + } + + let postBody = {} + if (opts.action !== undefined && opts.action !== null) { + postBody['action'] = opts.action + } + if (opts.ids !== undefined && opts.ids !== null) { + postBody['ids'] = opts.ids + } + if (opts.switchTarget !== undefined && opts.switchTarget !== null) { + postBody['switchTarget'] = opts.switchTarget + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clouddnsservice/1.0.12' + } + + 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 operateMonitor 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/monitorOperate', + '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.domainId - 域名ID,请使用getDomains接口获取。 + * @param {updateMonitor} opts.updateMonitor - 监控项设置信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateMonitor (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 updateMonitor" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling updateMonitor" + ) + } + if (opts.updateMonitor === undefined || opts.updateMonitor === null) { + throw new Error( + "Missing the required parameter 'opts.updateMonitor' when calling updateMonitor" + ) + } + + let postBody = {} + if (opts.updateMonitor !== undefined && opts.updateMonitor !== null) { + postBody['updateMonitor'] = opts.updateMonitor + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clouddnsservice/1.0.12' + } + + 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 updateMonitor 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/monitorUpdate', + '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.domainId - 域名ID,请使用getDomains接口获取。 + * @param {integer} [opts.pageIndex] - 当前页数,起始值为1,默认为1 optional + * @param {integer} [opts.pageSize] - 分页查询时设置的每页行数 optional + * @param {string} [opts.searchValue] - 关键字 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer currentCount 当前页面报警信息的个数 + * @param integer totalCount 所有报警信息的个数 + * @param integer totalPage 所有报警信息的页数 + * @param monitorAlarmInfo dataList + */ + + getMonitorAlarmInfo (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 getMonitorAlarmInfo" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling getMonitorAlarmInfo" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.searchValue !== undefined && opts.searchValue !== null) { + queryParams['searchValue'] = opts.searchValue + } + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 clouddnsservice/1.0.12' + } + + 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 getMonitorAlarmInfo 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/monitor/alarminfo', + '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 = JDCloud.CLOUDDNSSERVICE diff --git a/packages/libs/lib-jdcloud/src/repo/cloudsign/v1/cloudsign.js b/packages/libs/lib-jdcloud/src/repo/cloudsign/v1/cloudsign.js new file mode 100644 index 000000000..89698a4c9 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/cloudsign/v1/cloudsign.js @@ -0,0 +1,4895 @@ +/* + * 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. + * + * OLD合同模板管理接口 + * OLD合同模板管理接口 + * + * 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 = 'cloudsign' +Service._services[serviceId] = true + +/** + * cloudsign service. + * @version 2.0.9 + */ + +class CLOUDSIGN extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'cloudsign.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 获取已签章合同列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码, 默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小, 默认为10, 取值范围[10, 100] optional + * @param {string} [opts.contractTitle] - 合同标题 optional + * @param {string} callback - callback + @return {Object} result + * @param contractInfo contractList + * @param integer totalCount 合同数量 + */ + + describeContractList (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 + } + if (opts.contractTitle !== undefined && opts.contractTitle !== null) { + queryParams['contractTitle'] = opts.contractTitle + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 describeContractList 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( + '/contract', + '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) + } + ) + } + + /** + * 合同签章四种方式: +1. 合同文件 + 印章文件:contractContent + stampContent +2. 合同文件 + 印章ID:contractContent + stampId +3. 模板ID + 印章文件:templateId + stampContent +4. 模板ID + 印章ID:templateId + stampId + + * @param {Object} opts - parameters + * @param {contractSpec} opts.contractSpec + * @param {string} callback - callback + @return {Object} result + * @param string contractId 新签的合同ID + * @param string contractContent 新签的合同文件(base64) + */ + + signContract (opts, callback) { + opts = opts || {} + + if (opts.contractSpec === undefined || opts.contractSpec === null) { + throw new Error( + "Missing the required parameter 'opts.contractSpec' when calling signContract" + ) + } + + let postBody = {} + if (opts.contractSpec !== undefined && opts.contractSpec !== null) { + postBody['contractSpec'] = opts.contractSpec + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 signContract 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( + '/contract', + '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) + } + ) + } + + /** + * 1. 下载已签章的合同 +2. 多个合同id用逗号分隔 + [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.contractId - 合同ID + * @param {string} callback - callback + @return {Object} result + * @param contractInfo contractList + * @param integer totalCount 合同数量 + */ + + downloadContracts (opts, callback) { + opts = opts || {} + + if (opts.contractId === undefined || opts.contractId === null) { + throw new Error( + "Missing the required parameter 'opts.contractId' when calling downloadContracts" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + contractId: opts.contractId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 downloadContracts 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( + '/contract/{contractId}', + '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.contractId - 合同ID + * @param {contractVerifySpec} opts.contractVerifySpec + * @param {string} callback - callback + @return {Object} result + * @param boolean success 验签是否成功,true 成功 false 失败 + * @param string message 验证消息 + * @param stampResult results + */ + + verifyContract (opts, callback) { + opts = opts || {} + + if (opts.contractId === undefined || opts.contractId === null) { + throw new Error( + "Missing the required parameter 'opts.contractId' when calling verifyContract" + ) + } + if ( + opts.contractVerifySpec === undefined || + opts.contractVerifySpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.contractVerifySpec' when calling verifyContract" + ) + } + + let postBody = {} + if ( + opts.contractVerifySpec !== undefined && + opts.contractVerifySpec !== null + ) { + postBody['contractVerifySpec'] = opts.contractVerifySpec + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + contractId: opts.contractId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 verifyContract 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( + '/contract/{contractId}', + '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) + } + ) + } + + /** + * 删除已签章的合同 [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.contractId - 合同ID + * @param {string} callback - callback + @return {Object} result + */ + + deleteContract (opts, callback) { + opts = opts || {} + + if (opts.contractId === undefined || opts.contractId === null) { + throw new Error( + "Missing the required parameter 'opts.contractId' when calling deleteContract" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + contractId: opts.contractId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 deleteContract 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( + '/contract/{contractId}', + '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 optional + * @param {integer} [opts.pageSize] - 分页大小, 默认为10, 取值范围[10, 100] optional + * @param {string} [opts.contractTitle] - 合同标题 optional + * @param {string} callback - callback + @return {Object} result + * @param contractInfo contractList + * @param integer totalCount 合同数量 + */ + + describeContractList (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 + } + if (opts.contractTitle !== undefined && opts.contractTitle !== null) { + queryParams['contractTitle'] = opts.contractTitle + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 describeContractList 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( + '/smqContract:describeContractList', + '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) + } + ) + } + + /** + * 合同签章四种方式: +1. 合同文件 + 印章文件:contractContent + stampContent +2. 合同文件 + 印章ID:contractContent + stampId +3. 模板ID + 印章文件:templateId + stampContent +4. 模板ID + 印章ID:templateId + stampId + + * @param {Object} opts - parameters + * @param {contractSpec} opts.contractSpec + * @param {string} callback - callback + @return {Object} result + * @param boolean success + * @param string message + * @param string code + * @param string contractId 新签的合同ID + * @param string contractContent 新签的合同文件(base64) + */ + + signContract (opts, callback) { + opts = opts || {} + + if (opts.contractSpec === undefined || opts.contractSpec === null) { + throw new Error( + "Missing the required parameter 'opts.contractSpec' when calling signContract" + ) + } + + let postBody = {} + if (opts.contractSpec !== undefined && opts.contractSpec !== null) { + postBody['contractSpec'] = opts.contractSpec + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 signContract 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( + '/smqContract:signContract', + '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.contractId - 合同ID + * @param {contractVerifySpec} opts.contractVerifySpec + * @param {string} callback - callback + @return {Object} result + * @param boolean success 验签是否成功,true 成功 false 失败 + * @param string message 验证消息 + * @param string code + * @param stampResult results + */ + + verifyContract (opts, callback) { + opts = opts || {} + + if (opts.contractId === undefined || opts.contractId === null) { + throw new Error( + "Missing the required parameter 'opts.contractId' when calling verifyContract" + ) + } + if ( + opts.contractVerifySpec === undefined || + opts.contractVerifySpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.contractVerifySpec' when calling verifyContract" + ) + } + + let postBody = {} + if ( + opts.contractVerifySpec !== undefined && + opts.contractVerifySpec !== null + ) { + postBody['contractVerifySpec'] = opts.contractVerifySpec + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + contractId: opts.contractId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 verifyContract 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( + '/smqContract/{contractId}:verifyContract', + '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) + } + ) + } + + /** + * 1. 下载已签章的合同 +2. 多个合同id用逗号分隔 + [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.contractId - 合同ID + * @param {string} opts.contractId - 合同ID + * @param {string} callback - callback + @return {Object} result + * @param contractInfo contractList + * @param integer totalCount 合同数量 + */ + + downloadContracts (opts, callback) { + opts = opts || {} + + if (opts.contractId === undefined || opts.contractId === null) { + throw new Error( + "Missing the required parameter 'opts.contractId' when calling downloadContracts" + ) + } + if (opts.contractId === undefined || opts.contractId === null) { + throw new Error( + "Missing the required parameter 'opts.contractId' when calling downloadContracts" + ) + } + + let postBody = null + let queryParams = {} + if (opts.contractId !== undefined && opts.contractId !== null) { + queryParams['contractId'] = opts.contractId + } + + let pathParams = { + regionId: 'jdcloud', + contractId: opts.contractId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 downloadContracts 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( + '/smqContract/{contractId}:downloadContracts', + '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) + } + ) + } + + /** + * 删除已签章合同 [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.contractId - 合同ID + * @param {string} callback - callback + @return {Object} result + * @param boolean success 删除是否成功,true 成功 false 失败 + * @param string message + * @param string code + */ + + deleteContract (opts, callback) { + opts = opts || {} + + if (opts.contractId === undefined || opts.contractId === null) { + throw new Error( + "Missing the required parameter 'opts.contractId' when calling deleteContract" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + contractId: opts.contractId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 deleteContract 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( + '/smqContract/{contractId}:deleteContract', + '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.businessId - 业务流水号 + * @param {string} opts.file - 存证数据json字符串的Base64 + * @param {string} callback - callback + @return {Object} result + * @param string code + * @param string message + * @param boolean success + * @param saveEvidenceResp data + */ + + saveEvidence (opts, callback) { + opts = opts || {} + + if (opts.businessId === undefined || opts.businessId === null) { + throw new Error( + "Missing the required parameter 'opts.businessId' when calling saveEvidence" + ) + } + if (opts.file === undefined || opts.file === null) { + throw new Error( + "Missing the required parameter 'opts.file' when calling saveEvidence" + ) + } + + let postBody = {} + if (opts.businessId !== undefined && opts.businessId !== null) { + postBody['businessId'] = opts.businessId + } + if (opts.file !== undefined && opts.file !== null) { + postBody['file'] = opts.file + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 saveEvidence 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( + '/evidence:evidenceSave', + '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.businessId - 业务流水号 + * @param {string} opts.file - 存证数据json字符串的Base64 + * @param {string} [opts.businessCode] - 证据链代码 optional + * @param {string} [opts.lender] - 资方信息(借钱传:ZY;票据传 PJ_SHOUXIN--授信,PJ_JIEKUAN--借款) optional + * @param {string} [opts.messageId] - 请求流水号 optional + * @param {string} [opts.evidenceType] - 业务类型(JIEQIAN–借钱;PIAOJU--票据) optional + * @param {string} [opts.messageDate] - 请求时间 optional + * @param {string} callback - callback + @return {Object} result + * @param string code + * @param string message + * @param boolean success + * @param saveEvidenceResp data + */ + + saveMultiEvidence (opts, callback) { + opts = opts || {} + + if (opts.businessId === undefined || opts.businessId === null) { + throw new Error( + "Missing the required parameter 'opts.businessId' when calling saveMultiEvidence" + ) + } + if (opts.file === undefined || opts.file === null) { + throw new Error( + "Missing the required parameter 'opts.file' when calling saveMultiEvidence" + ) + } + + let postBody = {} + if (opts.businessId !== undefined && opts.businessId !== null) { + postBody['businessId'] = opts.businessId + } + if (opts.file !== undefined && opts.file !== null) { + postBody['file'] = opts.file + } + if (opts.businessCode !== undefined && opts.businessCode !== null) { + postBody['businessCode'] = opts.businessCode + } + if (opts.lender !== undefined && opts.lender !== null) { + postBody['lender'] = opts.lender + } + if (opts.messageId !== undefined && opts.messageId !== null) { + postBody['messageId'] = opts.messageId + } + if (opts.evidenceType !== undefined && opts.evidenceType !== null) { + postBody['evidenceType'] = opts.evidenceType + } + if (opts.messageDate !== undefined && opts.messageDate !== null) { + postBody['messageDate'] = opts.messageDate + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 saveMultiEvidence 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( + '/evidence:evidenceMultisave', + '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.businessId - 业务流水号 + * @param {string} opts.evidenceId - 存证编号 + * @param {string} callback - callback + @return {Object} result + * @param string code + * @param string message + * @param boolean success + * @param getEvidenceResp data + */ + + getEvidence (opts, callback) { + opts = opts || {} + + if (opts.businessId === undefined || opts.businessId === null) { + throw new Error( + "Missing the required parameter 'opts.businessId' when calling getEvidence" + ) + } + if (opts.evidenceId === undefined || opts.evidenceId === null) { + throw new Error( + "Missing the required parameter 'opts.evidenceId' when calling getEvidence" + ) + } + + let postBody = null + let queryParams = {} + if (opts.businessId !== undefined && opts.businessId !== null) { + queryParams['businessId'] = opts.businessId + } + if (opts.evidenceId !== undefined && opts.evidenceId !== null) { + queryParams['evidenceId'] = opts.evidenceId + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 getEvidence 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( + '/evidence:evidenceGetEvidence', + '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.businessId] - 业务流水号 optional + * @param {string} [opts.evidenceId] - 存证编号 optional + * @param {string} [opts.applicantIdType] - 申请取证主体的ID类型 optional + * @param {string} [opts.applicantIdNum] - 申请取证主体的ID optional + * @param {string} [opts.messageId] - 请求流水号 optional + * @param {string} [opts.evidenceType] - 业务类型 optional + * @param {string} [opts.messageDate] - 请求时间 optional + * @param {string} [opts.evidenceMessageId] - 存证时的请求流水 optional + * @param {string} callback - callback + @return {Object} result + * @param string code + * @param string message + * @param boolean success + * @param getEvidenceResp data + */ + + getMultiEvidence (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.businessId !== undefined && opts.businessId !== null) { + queryParams['businessId'] = opts.businessId + } + if (opts.evidenceId !== undefined && opts.evidenceId !== null) { + queryParams['evidenceId'] = opts.evidenceId + } + if (opts.applicantIdType !== undefined && opts.applicantIdType !== null) { + queryParams['applicantIdType'] = opts.applicantIdType + } + if (opts.applicantIdNum !== undefined && opts.applicantIdNum !== null) { + queryParams['applicantIdNum'] = opts.applicantIdNum + } + if (opts.messageId !== undefined && opts.messageId !== null) { + queryParams['messageId'] = opts.messageId + } + if (opts.evidenceType !== undefined && opts.evidenceType !== null) { + queryParams['evidenceType'] = opts.evidenceType + } + if (opts.messageDate !== undefined && opts.messageDate !== null) { + queryParams['messageDate'] = opts.messageDate + } + if ( + opts.evidenceMessageId !== undefined && + opts.evidenceMessageId !== null + ) { + queryParams['evidenceMessageId'] = opts.evidenceMessageId + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 getMultiEvidence 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( + '/evidence:evidenceGetmulti', + '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.businessId - 业务流水号 + * @param {string} [opts.chainCode] - 业务代码 optional + * @param {string} callback - callback + @return {Object} result + * @param string code + * @param string message + * @param boolean success + * @param evidenceFile data 存证报告文件 + */ + + getSaveReport (opts, callback) { + opts = opts || {} + + if (opts.businessId === undefined || opts.businessId === null) { + throw new Error( + "Missing the required parameter 'opts.businessId' when calling getSaveReport" + ) + } + + let postBody = null + let queryParams = {} + if (opts.businessId !== undefined && opts.businessId !== null) { + queryParams['businessId'] = opts.businessId + } + if (opts.chainCode !== undefined && opts.chainCode !== null) { + queryParams['chainCode'] = opts.chainCode + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 getSaveReport 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( + '/evidence:evidenceGetSaveReport', + '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} callback - callback + @return {Object} result + * @param string pin 用户pin + * @param integer usedCapacity 已用存储容量 + * @param integer status 当前服务状态(0 未开通 1 开通中 2 正常 3 停服) + * @param boolean contractSaving 是否开启合同托管 + * @param string kmsKeyId 签章系统所用的托管密钥 + * @param string applyTime 申请开通服务时间 + */ + + describeApplyStatus (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 describeApplyStatus 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( + '/manage:applyStatus', + '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} callback - callback + @return {Object} result + */ + + enableContractSave (opts, callback) { + opts = opts || {} + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 enableContractSave 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( + '/manage:enableContractSave', + 'PATCH', + 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} callback - callback + @return {Object} result + */ + + disableContractSave (opts, callback) { + opts = opts || {} + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 disableContractSave 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( + '/manage:disableContractSave', + 'PATCH', + 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) + } + ) + } + + /** + * 签章系统加密密钥 [MFA enabled] + * @param {Object} opts - parameters + * @param {} [opts.keyId] - KmsKeyId optional + * @param {string} callback - callback + @return {Object} result + */ + + setKmsKeyId (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.keyId !== undefined && opts.keyId !== null) { + postBody['keyId'] = opts.keyId + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 setKmsKeyId 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( + '/manage:setKmsKeyId', + '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 {certSpec} opts.certSpec + * @param {string} callback - callback + @return {Object} result + * @param boolean success + * @param string message + * @param string code + * @param certResp data + */ + + applyCert (opts, callback) { + opts = opts || {} + + if (opts.certSpec === undefined || opts.certSpec === null) { + throw new Error( + "Missing the required parameter 'opts.certSpec' when calling applyCert" + ) + } + + let postBody = {} + if (opts.certSpec !== undefined && opts.certSpec !== null) { + postBody['certSpec'] = opts.certSpec + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 applyCert 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( + '/smqCert:applyCert', + '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 {renewCertSpec} opts.renewCertSpec + * @param {string} callback - callback + @return {Object} result + * @param boolean success + * @param string message + * @param string code + * @param certResp data + */ + + renewCert (opts, callback) { + opts = opts || {} + + if (opts.renewCertSpec === undefined || opts.renewCertSpec === null) { + throw new Error( + "Missing the required parameter 'opts.renewCertSpec' when calling renewCert" + ) + } + + let postBody = {} + if (opts.renewCertSpec !== undefined && opts.renewCertSpec !== null) { + postBody['renewCertSpec'] = opts.renewCertSpec + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 renewCert 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( + '/smqCert:renewCert', + '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 {updateCertSpec} opts.updateCertSpec + * @param {string} callback - callback + @return {Object} result + * @param boolean success + * @param string message + * @param string code + * @param certResp data + */ + + updateCert (opts, callback) { + opts = opts || {} + + if (opts.updateCertSpec === undefined || opts.updateCertSpec === null) { + throw new Error( + "Missing the required parameter 'opts.updateCertSpec' when calling updateCert" + ) + } + + let postBody = {} + if (opts.updateCertSpec !== undefined && opts.updateCertSpec !== null) { + postBody['updateCertSpec'] = opts.updateCertSpec + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 updateCert 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( + '/smqCert:updateCert', + '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 {revokeCertSpec} opts.revokeCertSpec + * @param {string} callback - callback + @return {Object} result + * @param boolean success 吊销是否成功,true 成功 false 失败 + * @param string message + * @param string code + */ + + revokeCert (opts, callback) { + opts = opts || {} + + if (opts.revokeCertSpec === undefined || opts.revokeCertSpec === null) { + throw new Error( + "Missing the required parameter 'opts.revokeCertSpec' when calling revokeCert" + ) + } + + let postBody = {} + if (opts.revokeCertSpec !== undefined && opts.revokeCertSpec !== null) { + postBody['revokeCertSpec'] = opts.revokeCertSpec + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 revokeCert 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( + '/smqCert:revokeCert', + '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.pageNumber] - 页码, 默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小, 默认为10, 取值范围[10, 100] optional + * @param {string} [opts.caType] - 证书渠道 optional + * @param {string} [opts.name] - 个人用户姓名或企业名 optional + * @param {string} [opts.serialNo] - 证书序列号 optional + * @param {string} [opts.keyAlg] - 证书算法 optional + * @param {integer} [opts.certStatus] - 证书状态 optional + * @param {string} callback - callback + @return {Object} result + * @param certInfo certList + * @param integer totalCount 证书数量 + */ + + describeCertList (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 + } + if (opts.caType !== undefined && opts.caType !== null) { + queryParams['caType'] = opts.caType + } + if (opts.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + if (opts.serialNo !== undefined && opts.serialNo !== null) { + queryParams['serialNo'] = opts.serialNo + } + if (opts.keyAlg !== undefined && opts.keyAlg !== null) { + queryParams['keyAlg'] = opts.keyAlg + } + if (opts.certStatus !== undefined && opts.certStatus !== null) { + queryParams['certStatus'] = opts.certStatus + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 describeCertList 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( + '/smqCert:list', + '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 optional + * @param {integer} [opts.pageSize] - 分页大小, 默认为10, 取值范围[10, 100] optional + * @param {string} [opts.stampName] - 印章名称 optional + * @param {string} callback - callback + @return {Object} result + * @param stampInfo stampList + * @param integer totalCount 印章数量 + * @param integer pageNumber 页码,默认为1 + * @param integer pageSize 分页大小, 默认为10, 取值范围[10, 100] + */ + + describeStampList (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 + } + if (opts.stampName !== undefined && opts.stampName !== null) { + queryParams['stampName'] = opts.stampName + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 describeStampList 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( + '/smqStamp:describeStampList', + '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 {stampSpec} [opts.stampSpec] optional + * @param {string} callback - callback + @return {Object} result + * @param string stampId 印章ID + */ + + uploadStamp (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.stampSpec !== undefined && opts.stampSpec !== null) { + postBody['stampSpec'] = opts.stampSpec + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 uploadStamp 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( + '/smqStamp:uploadStamp', + '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) + } + ) + } + + /** + * 此接口仅供前端使用 +1. 下载印章 +2. 多个印章id用逗号分隔 + [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.stampId - 印章ID + * @param {string} callback - callback + @return {Object} result + */ + + downloadStamps (opts, callback) { + opts = opts || {} + + if (opts.stampId === undefined || opts.stampId === null) { + throw new Error( + "Missing the required parameter 'opts.stampId' when calling downloadStamps" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + stampId: opts.stampId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 downloadStamps 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( + '/smqStamp/{stampId}:downloadStamps', + '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) + } + ) + } + + /** + * 此接口仅供api使用 +1. 下载印章 +2. 多个印章id用逗号分隔 + [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.stampId - 印章ID + * @param {string} callback - callback + @return {Object} result + * @param stampInfo stampList + */ + + downloadStampsNew (opts, callback) { + opts = opts || {} + + if (opts.stampId === undefined || opts.stampId === null) { + throw new Error( + "Missing the required parameter 'opts.stampId' when calling downloadStampsNew" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + stampId: opts.stampId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 downloadStampsNew 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( + '/smqStampApi/{stampId}:downloadStamps', + '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) + } + ) + } + + /** + * 删除印章 [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.stampId - 印章ID + * @param {string} callback - callback + @return {Object} result + */ + + deleteStamp (opts, callback) { + opts = opts || {} + + if (opts.stampId === undefined || opts.stampId === null) { + throw new Error( + "Missing the required parameter 'opts.stampId' when calling deleteStamp" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + stampId: opts.stampId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 deleteStamp 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( + '/smqStamp/{stampId}:deleteStamp', + '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) + } + ) + } + + /** + * 编辑印章 [MFA enabled] + * @param {Object} opts - parameters + * @param {string} [opts.stampId] - 印章ID optional + * @param {string} [opts.stampName] - 印章名称 optional + * @param {string} callback - callback + @return {Object} result + * @param boolean success true 成功 false 失败 + * @param string message 响应消息 + * @param string code 状态码 + */ + + editStamp (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.stampId !== undefined && opts.stampId !== null) { + postBody['stampId'] = opts.stampId + } + if (opts.stampName !== undefined && opts.stampName !== null) { + postBody['stampName'] = opts.stampName + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 editStamp 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( + '/smqStamp:editStamp', + '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.pageSize] - 分页大小, 默认为10, 取值范围[10, 100] optional + * @param {integer} [opts.pageNumber] - 页码, 默认为1 optional + * @param {string} opts.stampId - 印章ID + * @param {string} callback - callback + @return {Object} result + * @param boolean success true 成功 false 失败 + * @param string message 响应消息 + * @param string code 状态码 + * @param pageStampHistoryResp data + */ + + describeStampHistoryList (opts, callback) { + opts = opts || {} + + if (opts.stampId === undefined || opts.stampId === null) { + throw new Error( + "Missing the required parameter 'opts.stampId' when calling describeStampHistoryList" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + queryParams['pageNumber'] = opts.pageNumber + } + if (opts.stampId !== undefined && opts.stampId !== null) { + queryParams['stampId'] = opts.stampId + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 describeStampHistoryList 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( + '/smqStamphistory:describeStampHistoryList', + '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 optional + * @param {integer} [opts.pageSize] - 分页大小, 默认为10, 取值范围[10, 100] optional + * @param {string} [opts.templateNameOrTitle] - 合同模板名称或者标题 optional + * @param {string} [opts.templateType] - 模板类型 pdf,word,pdf-auto(不传查所有类型) optional + * @param {string} callback - callback + @return {Object} result + * @param templateInfo templateList + * @param integer totalCount 合同模板数量 + * @param integer pageNumber 页码,默认为1 + * @param integer pageSize 分页大小, 默认为10, 取值范围[10, 100] + */ + + describeTemplateList (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 + } + if ( + opts.templateNameOrTitle !== undefined && + opts.templateNameOrTitle !== null + ) { + queryParams['templateNameOrTitle'] = opts.templateNameOrTitle + } + if (opts.templateType !== undefined && opts.templateType !== null) { + queryParams['templateType'] = opts.templateType + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 describeTemplateList 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( + '/smqTemplate:describeTemplateList', + '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 {templateSpec} [opts.templateSpec] optional + * @param {string} callback - callback + @return {Object} result + * @param string templateId 模板ID + */ + + uploadTemplate (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.templateSpec !== undefined && opts.templateSpec !== null) { + postBody['templateSpec'] = opts.templateSpec + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 uploadTemplate 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( + '/smqTemplate:uploadTemplate', + '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) + } + ) + } + + /** + * 此接口仅供前端使用 +1. 下载合同模板 +2. 多个合同id用逗号分隔 + [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.templateId - 合同模板ID + * @param {string} callback - callback + @return {Object} result + */ + + downloadTemplates (opts, callback) { + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling downloadTemplates" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 downloadTemplates 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( + '/smqTemplate/{templateId}:downloadTemplates', + '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) + } + ) + } + + /** + * 此接口仅供api使用 +1. 下载合同模板 +2. 多个合同id用逗号分隔 + [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.templateId - 合同模板ID + * @param {string} callback - callback + @return {Object} result + * @param templateInfo templateList + */ + + downloadTemplatesNew (opts, callback) { + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling downloadTemplatesNew" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 downloadTemplatesNew 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( + '/smqTemplateApi/{templateId}:downloadTemplates', + '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) + } + ) + } + + /** + * 删除合同模板 [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.templateId - 合同模板ID + * @param {string} callback - callback + @return {Object} result + */ + + deleteTemplate (opts, callback) { + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling deleteTemplate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 deleteTemplate 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( + '/smqTemplate/{templateId}:deleteTemplate', + '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.templateId - 合同模板ID + * @param {paddingSpec} opts.paddingSpec + * @param {string} callback - callback + @return {Object} result + * @param string templateId 模板ID + */ + + paddingTemplate (opts, callback) { + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling paddingTemplate" + ) + } + if (opts.paddingSpec === undefined || opts.paddingSpec === null) { + throw new Error( + "Missing the required parameter 'opts.paddingSpec' when calling paddingTemplate" + ) + } + + let postBody = {} + if (opts.paddingSpec !== undefined && opts.paddingSpec !== null) { + postBody['paddingSpec'] = opts.paddingSpec + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 paddingTemplate 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( + '/smqTemplate/{templateId}:paddingTemplate', + 'PATCH', + 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 optional + * @param {integer} [opts.pageSize] - 分页大小, 默认为10, 取值范围[10, 100] optional + * @param {string} [opts.stampName] - 印章名称 optional + * @param {string} callback - callback + @return {Object} result + * @param stampInfo stampList + * @param integer totalCount 印章数量 + * @param integer pageNumber 页码,默认为1 + * @param integer pageSize 分页大小, 默认为10, 取值范围[10, 100] + */ + + describeStampList (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 + } + if (opts.stampName !== undefined && opts.stampName !== null) { + queryParams['stampName'] = opts.stampName + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 describeStampList 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( + '/stamp', + '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 {stampSpec} opts.stampSpec + * @param {string} callback - callback + @return {Object} result + * @param string stampId 印章ID + */ + + uploadStamp (opts, callback) { + opts = opts || {} + + if (opts.stampSpec === undefined || opts.stampSpec === null) { + throw new Error( + "Missing the required parameter 'opts.stampSpec' when calling uploadStamp" + ) + } + + let postBody = {} + if (opts.stampSpec !== undefined && opts.stampSpec !== null) { + postBody['stampSpec'] = opts.stampSpec + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 uploadStamp 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( + '/stamp', + '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) + } + ) + } + + /** + * 1. 下载印章 +2. 多个印章id用逗号分隔 + [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.stampId - 印章ID + * @param {string} callback - callback + @return {Object} result + */ + + downloadStamps (opts, callback) { + opts = opts || {} + + if (opts.stampId === undefined || opts.stampId === null) { + throw new Error( + "Missing the required parameter 'opts.stampId' when calling downloadStamps" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + stampId: opts.stampId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 downloadStamps 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( + '/stamp/{stampId}', + '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) + } + ) + } + + /** + * 删除印章 [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.stampId - 印章ID + * @param {string} callback - callback + @return {Object} result + */ + + deleteStamp (opts, callback) { + opts = opts || {} + + if (opts.stampId === undefined || opts.stampId === null) { + throw new Error( + "Missing the required parameter 'opts.stampId' when calling deleteStamp" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + stampId: opts.stampId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 deleteStamp 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( + '/stamp/{stampId}', + '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 optional + * @param {integer} [opts.pageSize] - 分页大小, 默认为10, 取值范围[10, 100] optional + * @param {string} [opts.templateNameOrTitle] - 合同模板名称或者标题 optional + * @param {string} [opts.templateType] - 模板类型 pdf,word,pdf-auto(不传查所有类型) optional + * @param {string} callback - callback + @return {Object} result + * @param templateInfo templateList + * @param integer totalCount 合同模板数量 + * @param integer pageNumber 页码,默认为1 + * @param integer pageSize 分页大小, 默认为10, 取值范围[10, 100] + */ + + describeTemplateList (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 + } + if ( + opts.templateNameOrTitle !== undefined && + opts.templateNameOrTitle !== null + ) { + queryParams['templateNameOrTitle'] = opts.templateNameOrTitle + } + if (opts.templateType !== undefined && opts.templateType !== null) { + queryParams['templateType'] = opts.templateType + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 describeTemplateList 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( + '/template', + '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 {templateSpec} opts.templateSpec + * @param {string} callback - callback + @return {Object} result + * @param string templateId 模板ID + */ + + uploadTemplate (opts, callback) { + opts = opts || {} + + if (opts.templateSpec === undefined || opts.templateSpec === null) { + throw new Error( + "Missing the required parameter 'opts.templateSpec' when calling uploadTemplate" + ) + } + + let postBody = {} + if (opts.templateSpec !== undefined && opts.templateSpec !== null) { + postBody['templateSpec'] = opts.templateSpec + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 uploadTemplate 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( + '/template', + '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) + } + ) + } + + /** + * 1. 下载合同模板 +2. 多个合同id用逗号分隔 + [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.templateId - 合同模板ID + * @param {string} callback - callback + @return {Object} result + */ + + downloadTemplates (opts, callback) { + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling downloadTemplates" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 downloadTemplates 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( + '/template/{templateId}', + '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.templateId - 合同模板ID + * @param {paddingSpec} opts.paddingSpec + * @param {string} callback - callback + @return {Object} result + * @param string templateId 填充完成的合同模板ID + */ + + paddingTemplate (opts, callback) { + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling paddingTemplate" + ) + } + if (opts.paddingSpec === undefined || opts.paddingSpec === null) { + throw new Error( + "Missing the required parameter 'opts.paddingSpec' when calling paddingTemplate" + ) + } + + let postBody = {} + if (opts.paddingSpec !== undefined && opts.paddingSpec !== null) { + postBody['paddingSpec'] = opts.paddingSpec + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 paddingTemplate 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( + '/template/{templateId}', + 'PATCH', + 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) + } + ) + } + + /** + * 删除合同模板 [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.templateId - 合同模板ID + * @param {string} callback - callback + @return {Object} result + */ + + deleteTemplate (opts, callback) { + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling deleteTemplate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cloudsign/2.0.9' + } + + 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 deleteTemplate 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( + '/template/{templateId}', + '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) + } + ) + } +} +module.exports = CLOUDSIGN diff --git a/packages/libs/lib-jdcloud/src/repo/compile/v1/compile.js b/packages/libs/lib-jdcloud/src/repo/compile/v1/compile.js new file mode 100644 index 000000000..43018c9b5 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/compile/v1/compile.js @@ -0,0 +1,1433 @@ +/* + * 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. + * + * code api + * API related to build + * + * 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 = 'compile' +Service._services[serviceId] = true + +/** + * compile service. + * @version 0.2.0 + */ + +JDCloud.COMPILE = class COMPILE extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'compile.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 创建Demo + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param job job + */ + + createDemo (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 createDemo" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 compile/0.2.0' + } + + 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 createDemo 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 = this.makeRequest( + '/regions/{regionId}/demo', + '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) + } + ) + } + + /** + * 查询获取编译任务列表,并显示最后一次编译的一些信息 +/v2/regions/cn-south-1/jobs/?sorts.1.name=status&sorts.1.direction=asc&pageNumber=1&pageSize=10&filters.1.name=name&filters.1.values.1=我的job + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[10, 100] optional + * @param {filter} [opts.filters] - 编译任务名 optional + * @param {sort} [opts.sorts] - 对某一列排序 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount + * @param simpleJob jobs + * @param string requestId + */ + + getJobs (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 getJobs" + ) + } + + 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, this.buildFilterParam(opts.filters, 'filters')) + Object.assign(queryParams, this.buildSortParam(opts.sorts, 'sorts')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 compile/0.2.0' + } + + 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 getJobs 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 = this.makeRequest( + '/regions/{regionId}/jobs', + '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 {jobRequest} [opts.data] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string id 构建任务的uuid + * @param string codeRepoUrlLabel 项目所有者/项目名称 + * @param boolean result 构建成功则是true + */ + + createJob (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 createJob" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.data !== undefined && opts.data !== null) { + postBody['data'] = opts.data + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 compile/0.2.0' + } + + 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 createJob 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 = this.makeRequest( + '/regions/{regionId}/jobs', + '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.jobIds] - 待删除job的UUID列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean result true表示删除成功,false表示删除失败 + * @param string ids + */ + + deleteJobs (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 deleteJobs" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + Object.assign(queryParams, this.buildArrayParam(opts.jobIds, 'jobIds')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 compile/0.2.0' + } + + 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 deleteJobs 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 = this.makeRequest( + '/regions/{regionId}/jobs', + '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) + } + ) + } + + /** + * 根据id获取构建任务的配置信息 + * @param {Object} opts - parameters + * @param {string} opts.id - Job uuid + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param job job + */ + + getJob (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 getJob" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling getJob" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 compile/0.2.0' + } + + 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 getJob 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 = this.makeRequest( + '/regions/{regionId}/jobs/{id}', + '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.id - job uuid + * @param {jobRequest} [opts.data] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string id 构建任务uuid + * @param string codeRepoUrlLabel 项目所有者/项目名称 + * @param boolean result 更新成功则是true + */ + + updateJob (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 updateJob" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling updateJob" + ) + } + + let postBody = {} + if (opts.data !== undefined && opts.data !== null) { + postBody['data'] = opts.data + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 compile/0.2.0' + } + + 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 updateJob 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 = this.makeRequest( + '/regions/{regionId}/jobs/{id}', + '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) + } + ) + } + + /** + * 删除一个编译任务 + * @param {Object} opts - parameters + * @param {string} opts.id - 编译任务uuid + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean commitresult 提交任务是否成功 + */ + + deleteJob (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 deleteJob" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling deleteJob" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 compile/0.2.0' + } + + 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 deleteJob 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 = this.makeRequest( + '/regions/{regionId}/jobs/{id}', + '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) + } + ) + } + + /** + * 根据id启动一个编译任务 + * @param {Object} opts - parameters + * @param {string} opts.id - Job uuid + * @param {} [opts.category] - 类型branch/commit/tag optional + * @param {} [opts.branch] - 类型对应的值 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean commitresult 提交任务是否成功 + * @param string buildUuid 提交运行的构建任务的uuid + */ + + startJob (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 startJob" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling startJob" + ) + } + + let postBody = {} + if (opts.category !== undefined && opts.category !== null) { + postBody['category'] = opts.category + } + if (opts.branch !== undefined && opts.branch !== null) { + postBody['branch'] = opts.branch + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 compile/0.2.0' + } + + 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 startJob 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 = this.makeRequest( + '/regions/{regionId}/jobs/{id}:start', + '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.jobid - job uuid + * @param {string} opts.id - 构建任务uuid + * @param {integer} [opts.offsetNumber] - 查询日志的偏移量, 默认为0 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string log + * @param integer offsetNumber + */ + + getBuildLog (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 getBuildLog" + ) + } + + opts = opts || {} + + if (opts.jobid === undefined || opts.jobid === null) { + throw new Error( + "Missing the required parameter 'opts.jobid' when calling getBuildLog" + ) + } + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling getBuildLog" + ) + } + + let postBody = null + let queryParams = {} + if (opts.offsetNumber !== undefined && opts.offsetNumber !== null) { + queryParams['offsetNumber'] = opts.offsetNumber + } + + let pathParams = { + regionId: regionId, + jobid: opts.jobid, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 compile/0.2.0' + } + + 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 getBuildLog 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 = this.makeRequest( + '/regions/{regionId}/jobs/{jobid}/builds/{id}/log', + '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.jobid - job uuid + * @param {string} opts.id - 构建任务uuid + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string name 执行任务的job名称 + * @param integer createdAt 开始执行构建的时间 + * @param string status 执行构建的状态 + * @param number completionRate 执行构建完成的百分比 + */ + + getBuildStatus (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 getBuildStatus" + ) + } + + opts = opts || {} + + if (opts.jobid === undefined || opts.jobid === null) { + throw new Error( + "Missing the required parameter 'opts.jobid' when calling getBuildStatus" + ) + } + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling getBuildStatus" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + jobid: opts.jobid, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 compile/0.2.0' + } + + 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 getBuildStatus 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 = this.makeRequest( + '/regions/{regionId}/jobs/{jobid}/builds/{id}/status', + '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.jobid - job uuid + * @param {string} opts.id - 构建任务uuid + * @param {integer} [opts.expires] - 过期时间,单位秒, 默认1800秒 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string url + * @param string token + */ + + getExternalLink (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 getExternalLink" + ) + } + + opts = opts || {} + + if (opts.jobid === undefined || opts.jobid === null) { + throw new Error( + "Missing the required parameter 'opts.jobid' when calling getExternalLink" + ) + } + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling getExternalLink" + ) + } + + let postBody = null + let queryParams = {} + if (opts.expires !== undefined && opts.expires !== null) { + queryParams['expires'] = opts.expires + } + + let pathParams = { + regionId: regionId, + jobid: opts.jobid, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 compile/0.2.0' + } + + 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 getExternalLink 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 = this.makeRequest( + '/regions/{regionId}/jobs/{jobid}/builds/{id}/externalLink', + '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.jobid - job uuid + * @param {string} opts.id - 构建任务uuid + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string id + * @param boolean result + */ + + stopBuild (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 stopBuild" + ) + } + + opts = opts || {} + + if (opts.jobid === undefined || opts.jobid === null) { + throw new Error( + "Missing the required parameter 'opts.jobid' when calling stopBuild" + ) + } + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling stopBuild" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + jobid: opts.jobid, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 compile/0.2.0' + } + + 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 stopBuild 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 = this.makeRequest( + '/regions/{regionId}/jobs/{jobid}/builds/{id}:stop', + '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 = JDCloud.COMPILE diff --git a/packages/libs/lib-jdcloud/src/repo/containerregistry/v1/containerregistry.js b/packages/libs/lib-jdcloud/src/repo/containerregistry/v1/containerregistry.js new file mode 100644 index 000000000..2733913d4 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/containerregistry/v1/containerregistry.js @@ -0,0 +1,1848 @@ +/* + * 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. + * + * Repository + * 容器镜像仓库相关接口 + * + * 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 = 'containerregistry' +Service._services[serviceId] = true + +/** + * containerregistry service. + * @version 1.0.1 + */ + +JDCloud.CONTAINERREGISTRY = class CONTAINERREGISTRY extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'containerregistry.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * <p>申请12小时有效期的令牌。 使用<code>docker</code> CLI push和pull镜像。</p> +<p><code>authorizationToken</code>为每个registry返回一个base64编码的字符串,解码后<code>docker login</code>命令 +可完成指定registry的鉴权。JCR CLI提供<code>jcr get-login</code>进行认证处理。</p> + + * @param {Object} opts - parameters + * @param {string} opts.registryName - 注册表名称 + * @param {integer} [opts.expiredAfterHours] - issue新token的过期时间, 可选参数为新生成令牌的过期时间,最大值为24小时,最小值为1小时,为空则默认为12小时过期时间。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string authorizationToken + * @param string loginCmdLine + * @param string expiresAt + */ + + getAuthorizationToken (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 getAuthorizationToken" + ) + } + + opts = opts || {} + + if (opts.registryName === undefined || opts.registryName === null) { + throw new Error( + "Missing the required parameter 'opts.registryName' when calling getAuthorizationToken" + ) + } + + let postBody = {} + if ( + opts.expiredAfterHours !== undefined && + opts.expiredAfterHours !== null + ) { + postBody['expiredAfterHours'] = opts.expiredAfterHours + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + registryName: opts.registryName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 containerregistry/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 getAuthorizationToken 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 = this.makeRequest( + '/regions/{regionId}/registries/{registryName}:getAuthorizationToken', + '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) + } + ) + } + + /** + * <p>批量查询令牌。</p> +<p>暂时不支持分页和过滤条件。</p> + + * @param {Object} opts - parameters + * @param {string} opts.registryName - 注册表名称 + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 100] optional + * @param {filter} [opts.filters] - token - 令牌 ID,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param authorizationData authorizationTokens + * @param number totalCount + */ + + describeAuthorizationTokens (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 describeAuthorizationTokens" + ) + } + + opts = opts || {} + + if (opts.registryName === undefined || opts.registryName === null) { + throw new Error( + "Missing the required parameter 'opts.registryName' when calling describeAuthorizationTokens" + ) + } + + 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, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId, + registryName: opts.registryName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 containerregistry/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 describeAuthorizationTokens 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 = this.makeRequest( + '/regions/{regionId}/registries/{registryName}/tokens', + '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) + } + ) + } + + /** + * 释放用户 registry 的 token。 + + * @param {Object} opts - parameters + * @param {string} opts.registryName - 注册表名称 + * @param {string} [opts.authorizationToken] - 准备释放的 token ID,功能为指定token释放。 optional + * @param {boolean} [opts.forceAll] - true 表示强制删除用户当前registry下所有有效token的标志;false 表示删除所有有效token。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + releaseAuthorizationToken (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 releaseAuthorizationToken" + ) + } + + opts = opts || {} + + if (opts.registryName === undefined || opts.registryName === null) { + throw new Error( + "Missing the required parameter 'opts.registryName' when calling releaseAuthorizationToken" + ) + } + + let postBody = {} + if ( + opts.authorizationToken !== undefined && + opts.authorizationToken !== null + ) { + postBody['authorizationToken'] = opts.authorizationToken + } + if (opts.forceAll !== undefined && opts.forceAll !== null) { + postBody['forceAll'] = opts.forceAll + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + registryName: opts.registryName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 containerregistry/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 releaseAuthorizationToken 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 = this.makeRequest( + '/regions/{regionId}/registries/{registryName}:releaseAuthorizationToken', + '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) + } + ) + } + + /** + * 返回指定repository中images的元数据,包括image size, image tags和creation date。 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 100] optional + * @param {filter} [opts.filters] - registryName - 镜像仓储名称 +repositoryName - 镜像库名称 +imageDigest - 镜像哈希值 +imageTag - 镜像标签 +tagStatus - 打标TAGGED或没打标UNTAGGED + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param imageDetail imageDetails + * @param number totalCount + */ + + describeImages (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 describeImages" + ) + } + + 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, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 containerregistry/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 describeImages 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 = this.makeRequest( + '/regions/{regionId}/images', + '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) + } + ) + } + + /** + * 删除镜像 +imageDigest imageTag imageTagStatus 三者只能且必须传一个。 +可根据Tag状态删除Image,例如删除所有tagged的镜像。 +digest和tag唯一表征单个镜像,其中imageDigest为sha256哈希,image manifest的digest。 +例如 sha256:examplee6d1e504117a17000003d3753086354a38375961f2e665416ef4b1b2f;image使用的tag, 如 "precise" + [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.registryName - 注册表名称 + * @param {string} opts.repositoryName - 镜像仓库表名称 + * @param {string} [opts.imageDigest] - sha256哈希,image manifest的digest. optional + * @param {string} [opts.imageTag] - image使用的tag optional + * @param {string} [opts.imageTagStatus] - 枚举中的一个值,如 tagged 和 untagged. optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteImage (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 deleteImage" + ) + } + + opts = opts || {} + + if (opts.registryName === undefined || opts.registryName === null) { + throw new Error( + "Missing the required parameter 'opts.registryName' when calling deleteImage" + ) + } + if (opts.repositoryName === undefined || opts.repositoryName === null) { + throw new Error( + "Missing the required parameter 'opts.repositoryName' when calling deleteImage" + ) + } + + let postBody = {} + if (opts.imageDigest !== undefined && opts.imageDigest !== null) { + postBody['imageDigest'] = opts.imageDigest + } + if (opts.imageTag !== undefined && opts.imageTag !== null) { + postBody['imageTag'] = opts.imageTag + } + if (opts.imageTagStatus !== undefined && opts.imageTagStatus !== null) { + postBody['imageTagStatus'] = opts.imageTagStatus + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + registryName: opts.registryName, + repositoryName: opts.repositoryName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 containerregistry/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 deleteImage 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 = this.makeRequest( + '/regions/{regionId}/registries/{registryName}/repositories/{repositoryName}:deleteImage', + '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 {filter} [opts.filters] - resourceTypes - 资源类型,暂时只支持 [registry, repository],支持同时查询两种配额。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param quota quotas + */ + + describeQuotas (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 describeQuotas" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + Object.assign(queryParams, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 containerregistry/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 describeQuotas 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 = this.makeRequest( + '/regions/{regionId}/quotas', + '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) + } + ) + } + + /** + * 批量查询指定用户下所有 registry 详情。 +暂不支持 filter. + + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param registry registries + */ + + describeRegistries (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 describeRegistries" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 containerregistry/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 describeRegistries 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 = this.makeRequest( + '/regions/{regionId}/registries', + '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.registryName - 用户定义的registry名称。<br> DNS兼容registry名称规则如下: + <br> 不可为空,且不能超过32字符 <br> 以小写字母开始和结尾,支持使用小写字母、数字、中划线(-) + + * @param {string} [opts.description] - 注册表描述,<a href="https://www.jdcloud.com/help/detail/3870/isCatalog/1">参考公共参数规范</a>。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param registry registry + */ + + createRegistry (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 createRegistry" + ) + } + + opts = opts || {} + + if (opts.registryName === undefined || opts.registryName === null) { + throw new Error( + "Missing the required parameter 'opts.registryName' when calling createRegistry" + ) + } + + let postBody = {} + if (opts.registryName !== undefined && opts.registryName !== null) { + postBody['registryName'] = opts.registryName + } + 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 containerregistry/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 createRegistry 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 = this.makeRequest( + '/regions/{regionId}/registries', + '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) + } + ) + } + + /** + * 查询指定用户下某个 registry 详情。 + + * @param {Object} opts - parameters + * @param {string} opts.registryName - 注册表名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param registry registry + */ + + describeRegistry (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 describeRegistry" + ) + } + + opts = opts || {} + + if (opts.registryName === undefined || opts.registryName === null) { + throw new Error( + "Missing the required parameter 'opts.registryName' when calling describeRegistry" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + registryName: opts.registryName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 containerregistry/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 describeRegistry 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 = this.makeRequest( + '/regions/{regionId}/registries/{registryName}', + '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) + } + ) + } + + /** + * 删除指定用户下某个 registry. + [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.registryName - 注册表名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteRegistry (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 deleteRegistry" + ) + } + + opts = opts || {} + + if (opts.registryName === undefined || opts.registryName === null) { + throw new Error( + "Missing the required parameter 'opts.registryName' when calling deleteRegistry" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + registryName: opts.registryName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 containerregistry/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 deleteRegistry 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 = this.makeRequest( + '/regions/{regionId}/registries/{registryName}', + '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.registryName - 待验证的注册表名。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 表示用户指定的注册表是否通过校验, 0 通过 1 名称为空 2 不符合规范 3 重名 + * @param string reason code字段非零时,给出详细原因。 + */ + + checkRegistryName (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 checkRegistryName" + ) + } + + opts = opts || {} + + if (opts.registryName === undefined || opts.registryName === null) { + throw new Error( + "Missing the required parameter 'opts.registryName' when calling checkRegistryName" + ) + } + + let postBody = {} + if (opts.registryName !== undefined && opts.registryName !== null) { + postBody['registryName'] = opts.registryName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 containerregistry/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 checkRegistryName 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 = this.makeRequest( + '/regions/{regionId}/registries:checkRegistryName', + '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) + } + ) + } + + /** + * 通过参数创建镜像仓库。 +仓库名称可以分解为多个路径名,每个名称必须至少包含一个小写字母数字,考虑URL规范。 +支持包含段划线或者下划线进行分割,但不允许点'.',多个路径名之间通过("/")连接,总长度不超过256个字符,当前只支持二级目录。 + + * @param {Object} opts - parameters + * @param {string} opts.registryName - 注册表名称 + * @param {string} opts.repositoryName - 镜像仓库名称。 +可以专有模式如默认命名空间nginx-web-app;或者和命名空间一起将多个仓库聚集在一起如 project-a/nginx-web-app。 + + * @param {string} [opts.description] - 注册表描述,<a href="https://www.jdcloud.com/help/detail/3870/isCatalog/1">参考公共参数规范</a>。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param repositoryShort repository + */ + + createRepository (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 createRepository" + ) + } + + opts = opts || {} + + if (opts.registryName === undefined || opts.registryName === null) { + throw new Error( + "Missing the required parameter 'opts.registryName' when calling createRepository" + ) + } + if (opts.repositoryName === undefined || opts.repositoryName === null) { + throw new Error( + "Missing the required parameter 'opts.repositoryName' when calling createRepository" + ) + } + + let postBody = {} + if (opts.repositoryName !== undefined && opts.repositoryName !== null) { + postBody['repositoryName'] = opts.repositoryName + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + registryName: opts.registryName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 containerregistry/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 createRepository 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 = this.makeRequest( + '/regions/{regionId}/registries/{registryName}/repositories', + '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) + } + ) + } + + /** + * 描述用户指定 registry 下的 repository. + + * @param {Object} opts - parameters + * @param {array} [opts.filters] - name - 仓库名称,模糊匹配,支持单个 + optional + * @param {string} [opts.registryName] - 注册表名 optional + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 100] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param repository repositories + * @param number totalCount + */ + + describeRepositories (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 describeRepositories" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.filters !== undefined && opts.filters !== null) { + postBody['filters'] = opts.filters + } + if (opts.registryName !== undefined && opts.registryName !== null) { + postBody['registryName'] = opts.registryName + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 containerregistry/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 describeRepositories 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 = this.makeRequest( + '/regions/{regionId}/listRepositories', + '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) + } + ) + } + + /** + * 删除指定用户下某个镜像仓库. + [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.registryName - 注册表名称 + * @param {string} opts.repositoryName - 镜像仓库名称 + * @param {boolean} [opts.force] - 是否强制删除有镜像的镜像仓库 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteRepository (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 deleteRepository" + ) + } + + opts = opts || {} + + if (opts.registryName === undefined || opts.registryName === null) { + throw new Error( + "Missing the required parameter 'opts.registryName' when calling deleteRepository" + ) + } + if (opts.repositoryName === undefined || opts.repositoryName === null) { + throw new Error( + "Missing the required parameter 'opts.repositoryName' when calling deleteRepository" + ) + } + + let postBody = null + let queryParams = {} + if (opts.force !== undefined && opts.force !== null) { + queryParams['force'] = opts.force + } + + let pathParams = { + regionId: regionId, + registryName: opts.registryName, + repositoryName: opts.repositoryName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 containerregistry/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 deleteRepository 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 = this.makeRequest( + '/regions/{regionId}/registries/{registryName}/repositories/{repositoryName}', + '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.registryName - 注册表名。 + * @param {string} opts.repositoryName - 待验证的镜像仓库名。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 表示用户指定的镜像仓库名是否通过校验, 0 通过 1 名称为空 2 不符合规范 3 重名 + * @param string reason code字段非零时,给出详细原因。 + */ + + checkRepositoryName (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 checkRepositoryName" + ) + } + + opts = opts || {} + + if (opts.registryName === undefined || opts.registryName === null) { + throw new Error( + "Missing the required parameter 'opts.registryName' when calling checkRepositoryName" + ) + } + if (opts.repositoryName === undefined || opts.repositoryName === null) { + throw new Error( + "Missing the required parameter 'opts.repositoryName' when calling checkRepositoryName" + ) + } + + let postBody = {} + if (opts.registryName !== undefined && opts.registryName !== null) { + postBody['registryName'] = opts.registryName + } + if (opts.repositoryName !== undefined && opts.repositoryName !== null) { + postBody['repositoryName'] = opts.repositoryName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 containerregistry/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 checkRepositoryName 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 = this.makeRequest( + '/regions/{regionId}/repositories:checkRepositoryName', + '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 = JDCloud.CONTAINERREGISTRY diff --git a/packages/libs/lib-jdcloud/src/repo/cp/v1/cp.js b/packages/libs/lib-jdcloud/src/repo/cp/v1/cp.js new file mode 100644 index 000000000..d5efde227 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/cp/v1/cp.js @@ -0,0 +1,1284 @@ +/* + * 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. + * + * Partner UserAuth Management + * Partner UserAuth Management API + * + * 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 = 'cp' +Service._services[serviceId] = true + +/** + * cp service. + * @version 0.2.5 + */ + +class CP extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'cp.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * createPartner + * @param {Object} opts - parameters + * @param {} [opts.pin] - 用户pin optional + * @param {} [opts.authProvider] - 实名认证类型 optional + * @param {} [opts.roleName] - 角色名称 optional + * @param {} [opts.policyNames] - 策略名称 optional + * @param {} [opts.assumeRolePolicyDocument] - assumeRolePolicyDocument optional + * @param {} [opts.roleDescription] - 角色描述信息 optional + * @param {string} callback - callback + @return {Object} result + * @param string pin 客户京东云账号的唯一标识 + * @param string partnerId 合作伙伴ID + */ + + createPartner (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.pin !== undefined && opts.pin !== null) { + postBody['pin'] = opts.pin + } + if (opts.authProvider !== undefined && opts.authProvider !== null) { + postBody['authProvider'] = opts.authProvider + } + if (opts.roleName !== undefined && opts.roleName !== null) { + postBody['roleName'] = opts.roleName + } + if (opts.policyNames !== undefined && opts.policyNames !== null) { + postBody['policyNames'] = opts.policyNames + } + if ( + opts.assumeRolePolicyDocument !== undefined && + opts.assumeRolePolicyDocument !== null + ) { + postBody['assumeRolePolicyDocument'] = opts.assumeRolePolicyDocument + } + if (opts.roleDescription !== undefined && opts.roleDescription !== null) { + postBody['roleDescription'] = opts.roleDescription + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cp/0.2.5' + } + + 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 createPartner 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( + '/partner', + '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) + } + ) + } + + /** + * usercpcheck + * @param {Object} opts - parameters + * @param {userCpCheckInfo} opts.userCpCheckInfo + * @param {string} callback - callback + @return {Object} result + * @param boolean check true-存在关联关系,false-不存在关联关系 + * @param string userId 合作伙伴用户的userId + */ + + usercpcheck (opts, callback) { + opts = opts || {} + + if (opts.userCpCheckInfo === undefined || opts.userCpCheckInfo === null) { + throw new Error( + "Missing the required parameter 'opts.userCpCheckInfo' when calling usercpcheck" + ) + } + + let postBody = {} + if (opts.userCpCheckInfo !== undefined && opts.userCpCheckInfo !== null) { + postBody['userCpCheckInfo'] = opts.userCpCheckInfo + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cp/0.2.5' + } + + 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 usercpcheck 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( + '/usercpcheck', + '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) + } + ) + } + + /** + * setUserGrace + * @param {Object} opts - parameters + * @param {} [opts.pin] - 用户pin optional + * @param {string} callback - callback + @return {Object} result + * @param boolean success true-设置成功, false-设置失败 + */ + + setUserGrace (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.pin !== undefined && opts.pin !== null) { + postBody['pin'] = opts.pin + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cp/0.2.5' + } + + 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 setUserGrace 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( + '/provider:graceSetting', + '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) + } + ) + } + + /** + * getUserGrace + * @param {Object} opts - parameters + * @param {} [opts.pin] - 用户pin optional + * @param {string} callback - callback + @return {Object} result + * @param integer periodResGraceDays 包周期宽限期天数 + * @param integer periodResRetentionDays 包周期资源保留期天数 + * @param integer onDemandResGraceDays 按需资源宽限期天数 + */ + + getUserGrace (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.pin !== undefined && opts.pin !== null) { + postBody['pin'] = opts.pin + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cp/0.2.5' + } + + 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 getUserGrace 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( + '/provider:graceInfo', + '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) + } + ) + } + + /** + * partnerToken + * @param {Object} opts - parameters + * @param {string} opts.partnerId - 合作伙伴ID + * @param {partnerToken} opts.partnerToken + * @param {string} callback - callback + @return {Object} result + * @param string token token + * @param string tokenOriginResult 置换aksk所用token的原始数据 + * @param string partnerId 合作伙伴id + * @param integer tokenType 1- 合作伙伴token 2-合作伙伴用户token + * @param string expiresAt token过期时间 示例 2022-06-24T12:09:58.888000Z, 响应参数为UTC时间格式,北京时间为UTC+8小时。如返回: 2020-01-08T02:56:19.587000Z 北京时间:2020-01-08 10:56:19.587 + * @param string issuedAt token下发时间 示例 2022-06-24T12:09:58.888000Z, 响应参数为UTC时间格式,北京时间为UTC+8小时。如返回: 2020-01-08T02:56:19.587000Z 北京时间:2020-01-08 10:56:19.587 + */ + + partnerToken (opts, callback) { + opts = opts || {} + + if (opts.partnerId === undefined || opts.partnerId === null) { + throw new Error( + "Missing the required parameter 'opts.partnerId' when calling partnerToken" + ) + } + if (opts.partnerToken === undefined || opts.partnerToken === null) { + throw new Error( + "Missing the required parameter 'opts.partnerToken' when calling partnerToken" + ) + } + + let postBody = {} + if (opts.partnerToken !== undefined && opts.partnerToken !== null) { + postBody['partnerToken'] = opts.partnerToken + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + partnerId: opts.partnerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cp/0.2.5' + } + + 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 partnerToken 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( + '/partner/{partnerId}/token', + '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) + } + ) + } + + /** + * partnerStsToken + * @param {Object} opts - parameters + * @param {string} opts.partnerId - 合作伙伴ID + * @param {partnerStsToken} opts.partnerStsToken + * @param {string} callback - callback + @return {Object} result + * @param string access AK + * @param string secret SK + * @param string securitytoken securitytoken是将所获的AK、SK等信息进行加密后的字符串。 + * @param string expiresAt AK/SK和securitytoken的过期时间。响应参数为UTC时间格式,北京时间为UTC+8小时。如返回: 2020-01-08T02:56:19.587000Z 北京时间:2020-01-08 10:56:19.587 + * @param string issuedAt token下发时间 + */ + + partnerStsToken (opts, callback) { + opts = opts || {} + + if (opts.partnerId === undefined || opts.partnerId === null) { + throw new Error( + "Missing the required parameter 'opts.partnerId' when calling partnerStsToken" + ) + } + if (opts.partnerStsToken === undefined || opts.partnerStsToken === null) { + throw new Error( + "Missing the required parameter 'opts.partnerStsToken' when calling partnerStsToken" + ) + } + + let postBody = {} + if (opts.partnerStsToken !== undefined && opts.partnerStsToken !== null) { + postBody['partnerStsToken'] = opts.partnerStsToken + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + partnerId: opts.partnerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cp/0.2.5' + } + + 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 partnerStsToken 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( + '/partner/{partnerId}/ststoken', + '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) + } + ) + } + + /** + * checkUser + * @param {Object} opts - parameters + * @param {string} opts.partnerId - 合作伙伴ID + * @param {checkUserInfo} opts.checkUserInfo + * @param {string} callback - callback + @return {Object} result + * @param integer status 0-该注册方式不存在,1-该注册方式已存在 + */ + + checkUser (opts, callback) { + opts = opts || {} + + if (opts.partnerId === undefined || opts.partnerId === null) { + throw new Error( + "Missing the required parameter 'opts.partnerId' when calling checkUser" + ) + } + if (opts.checkUserInfo === undefined || opts.checkUserInfo === null) { + throw new Error( + "Missing the required parameter 'opts.checkUserInfo' when calling checkUser" + ) + } + + let postBody = {} + if (opts.checkUserInfo !== undefined && opts.checkUserInfo !== null) { + postBody['checkUserInfo'] = opts.checkUserInfo + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + partnerId: opts.partnerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cp/0.2.5' + } + + 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 checkUser 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( + '/partner/{partnerId}/user:checkUserInfo', + '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) + } + ) + } + + /** + * sendVerificationCode + * @param {Object} opts - parameters + * @param {string} opts.partnerId - 合作伙伴ID + * @param {sendVerificationCodeInfo} opts.sendVerificationCodeInfo + * @param {string} callback - callback + @return {Object} result + */ + + sendVerificationCode (opts, callback) { + opts = opts || {} + + if (opts.partnerId === undefined || opts.partnerId === null) { + throw new Error( + "Missing the required parameter 'opts.partnerId' when calling sendVerificationCode" + ) + } + if ( + opts.sendVerificationCodeInfo === undefined || + opts.sendVerificationCodeInfo === null + ) { + throw new Error( + "Missing the required parameter 'opts.sendVerificationCodeInfo' when calling sendVerificationCode" + ) + } + + let postBody = {} + if ( + opts.sendVerificationCodeInfo !== undefined && + opts.sendVerificationCodeInfo !== null + ) { + postBody['sendVerificationCodeInfo'] = opts.sendVerificationCodeInfo + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + partnerId: opts.partnerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cp/0.2.5' + } + + 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 sendVerificationCode 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( + '/partner/{partnerId}/user:sendVerificationCode', + '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) + } + ) + } + + /** + * createUser + * @param {Object} opts - parameters + * @param {string} opts.partnerId - 合作伙伴ID + * @param {createUserInfo} opts.createUserInfo + * @param {string} callback - callback + @return {Object} result + * @param string pin 客户京东云账号的唯一标识 + * @param string userId 第三方系统的用户唯一标识,该标识的具体值由伙伴分配。 + * @param string roleJrn 客户授权给合作伙伴使用的角色标识(Role's JDCloud Resource Name),合作伙伴可以代入此角色,执行角色权限范围内的用户资源操作 + * @param string accessKey 用户的accessKey + * @param string secretkey 用户secretKey + */ + + createUser (opts, callback) { + opts = opts || {} + + if (opts.partnerId === undefined || opts.partnerId === null) { + throw new Error( + "Missing the required parameter 'opts.partnerId' when calling createUser" + ) + } + if (opts.createUserInfo === undefined || opts.createUserInfo === null) { + throw new Error( + "Missing the required parameter 'opts.createUserInfo' when calling createUser" + ) + } + + let postBody = {} + if (opts.createUserInfo !== undefined && opts.createUserInfo !== null) { + postBody['createUserInfo'] = opts.createUserInfo + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + partnerId: opts.partnerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cp/0.2.5' + } + + 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 createUser 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( + '/partner/{partnerId}/user:createUser', + '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.partnerId - 合作伙伴ID + * @param {string} [opts.pin] - 用户pin optional + * @param {string} [opts.mobilePhone] - 用户用手机注册时的手机号,手机号包括国家码,以00开头,格式:00XX-XXXXXXXX。 optional + * @param {string} [opts.email] - 用户用邮箱注册时的邮箱 optional + * @param {integer} [opts.pageNumber] - 页码,默认1 optional + * @param {integer} [opts.pageSize] - 分页大小,默认50,取值范围[10, 100] optional + * @param {string} [opts.cooperationStartTime] - 按关联时间查询时,起始UTC时间。格式为:yyyy-MM-dd'T'HH:mm:ss。 optional + * @param {string} [opts.cooperationEndTime] - 按关联时间查询时,截止UTC时间。格式为:yyyy-MM-dd'T'HH:mm:ss。 optional + * @param {integer} [opts.status] - 按用户状态查询,0-全部(默认),1-正常,-1-禁用 optional + * @param {integer} [opts.sort] - 排序规则:0-关联时间倒序排序(默认),1-关联时间顺序排序 optional + * @param {string} callback - callback + @return {Object} result + * @param integer total 总用户数 + * @param partnerUserInfo users + */ + + listPartnerUsers (opts, callback) { + opts = opts || {} + + if (opts.partnerId === undefined || opts.partnerId === null) { + throw new Error( + "Missing the required parameter 'opts.partnerId' when calling listPartnerUsers" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pin !== undefined && opts.pin !== null) { + queryParams['pin'] = opts.pin + } + if (opts.mobilePhone !== undefined && opts.mobilePhone !== null) { + queryParams['mobilePhone'] = opts.mobilePhone + } + if (opts.email !== undefined && opts.email !== null) { + queryParams['email'] = opts.email + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + queryParams['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if ( + opts.cooperationStartTime !== undefined && + opts.cooperationStartTime !== null + ) { + queryParams['cooperationStartTime'] = opts.cooperationStartTime + } + if ( + opts.cooperationEndTime !== undefined && + opts.cooperationEndTime !== null + ) { + queryParams['cooperationEndTime'] = opts.cooperationEndTime + } + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + if (opts.sort !== undefined && opts.sort !== null) { + queryParams['sort'] = opts.sort + } + + let pathParams = { + regionId: 'jdcloud', + partnerId: opts.partnerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cp/0.2.5' + } + + 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 listPartnerUsers 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( + '/partner/{partnerId}/users', + '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.partnerId - 合作伙伴ID + * @param {string} opts.userId - 合作伙伴用户ID + * @param {userAuthInfo} opts.userAuthInfo + * @param {string} callback - callback + @return {Object} result + */ + + createUserAuth (opts, callback) { + opts = opts || {} + + if (opts.partnerId === undefined || opts.partnerId === null) { + throw new Error( + "Missing the required parameter 'opts.partnerId' when calling createUserAuth" + ) + } + if (opts.userId === undefined || opts.userId === null) { + throw new Error( + "Missing the required parameter 'opts.userId' when calling createUserAuth" + ) + } + if (opts.userAuthInfo === undefined || opts.userAuthInfo === null) { + throw new Error( + "Missing the required parameter 'opts.userAuthInfo' when calling createUserAuth" + ) + } + + let postBody = {} + if (opts.userAuthInfo !== undefined && opts.userAuthInfo !== null) { + postBody['userAuthInfo'] = opts.userAuthInfo + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + partnerId: opts.partnerId, + userId: opts.userId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cp/0.2.5' + } + + 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 createUserAuth 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( + '/partner/{partnerId}/user/{userId}:createUserAuth', + '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 = CP diff --git a/packages/libs/lib-jdcloud/src/repo/cps/v1/cps.js b/packages/libs/lib-jdcloud/src/repo/cps/v1/cps.js new file mode 100644 index 000000000..384f7958e --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/cps/v1/cps.js @@ -0,0 +1,11516 @@ +/* + * 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. + * + * Cloud-Physical-Server + * 云物理服务器私有网络操作相关的接口 + * + * 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 = 'cps' +Service._services[serviceId] = true + +/** + * cps service. + * @version 2.4.3 + */ + +class CPS extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'cps.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询别名IP列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[20, 100] optional + * @param {string} [opts.subnetId] - 子网ID optional + * @param {string} [opts.instanceId] - 实例ID optional + * @param {string} [opts.cidr] - CIDR段,模糊搜索 optional + * @param {filter} [opts.filters] - aliasIpId - 别名IP id<br/> + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param aliasIp aliasIps + * @param integer pageNumber 页码;默认为1 + * @param integer pageSize 分页大小;默认为20;取值范围[20, 100] + * @param integer totalCount 查询结果总数 + */ + + describeAliasIps (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 describeAliasIps" + ) + } + + 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.subnetId !== undefined && opts.subnetId !== null) { + queryParams['subnetId'] = opts.subnetId + } + if (opts.instanceId !== undefined && opts.instanceId !== null) { + queryParams['instanceId'] = opts.instanceId + } + if (opts.cidr !== undefined && opts.cidr !== null) { + queryParams['cidr'] = opts.cidr + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeAliasIps 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}/aliasIps', + '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 + * @param {Object} opts - parameters + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {aliasIpSpec} opts.aliasIpSpec - 别名IP配置 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param aliasIpSuccessInfo successList + * @param aliasIpErrorInfo errorList + */ + + createAliasIp (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 createAliasIp" + ) + } + + opts = opts || {} + + if (opts.aliasIpSpec === undefined || opts.aliasIpSpec === null) { + throw new Error( + "Missing the required parameter 'opts.aliasIpSpec' when calling createAliasIp" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.aliasIpSpec !== undefined && opts.aliasIpSpec !== null) { + postBody['aliasIpSpec'] = opts.aliasIpSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 createAliasIp 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}/aliasIps', + '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) + } + ) + } + + /** + * 删除别名IP + * @param {Object} opts - parameters + * @param {string} opts.aliasIpId - 别名IP ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 删除操作是否成功 + */ + + deleteAliasIp (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 deleteAliasIp" + ) + } + + opts = opts || {} + + if (opts.aliasIpId === undefined || opts.aliasIpId === null) { + throw new Error( + "Missing the required parameter 'opts.aliasIpId' when calling deleteAliasIp" + ) + } + + let postBody = null + let queryParams = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + queryParams['clientToken'] = opts.clientToken + } + + let pathParams = { + regionId: regionId, + aliasIpId: opts.aliasIpId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 deleteAliasIp 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}/aliasIps/{aliasIpId}', + '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条<br/> + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[20, 100] optional + * @param {string} [opts.name] - 证书名称 optional + * @param {filter} [opts.filters] - certId - 证书ID,精确匹配,支持多个<br/> + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param cert certs + * @param integer pageNumber 页码;默认为1 + * @param integer pageSize 分页大小;默认为20;取值范围[20, 100] + * @param integer totalCount 查询结果总数 + */ + + describeCerts (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 describeCerts" + ) + } + + 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.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeCerts 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}/certs', + '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 {certSpec} opts.certSpec - 弹性公网IP配置 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string certId 证书ID + */ + + createCert (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 createCert" + ) + } + + opts = opts || {} + + if (opts.certSpec === undefined || opts.certSpec === null) { + throw new Error( + "Missing the required parameter 'opts.certSpec' when calling createCert" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.certSpec !== undefined && opts.certSpec !== null) { + postBody['certSpec'] = opts.certSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 createCert 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}/certs', + '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) + } + ) + } + + /** + * 查询证书详情 + * @param {Object} opts - parameters + * @param {string} opts.certId - 证书ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param cert cert 证书详细信息 + */ + + describeCert (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 describeCert" + ) + } + + opts = opts || {} + + if (opts.certId === undefined || opts.certId === null) { + throw new Error( + "Missing the required parameter 'opts.certId' when calling describeCert" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + certId: opts.certId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeCert 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}/certs/{certId}', + '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.certId - 证书ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 删除操作是否成功 + */ + + removeCert (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 removeCert" + ) + } + + opts = opts || {} + + if (opts.certId === undefined || opts.certId === null) { + throw new Error( + "Missing the required parameter 'opts.certId' when calling removeCert" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + certId: opts.certId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 removeCert 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}/certs/{certId}', + '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.certId - 证书ID + * @param {string} [opts.name] - 证书名称 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string certId 证书ID + * @param string name 证书名称 + * @param string certificate 证书内容 + * @param string createTime 创建时间 + * @param integer listenerCount 证书关联监听器数量 + */ + + modifyCert (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 modifyCert" + ) + } + + opts = opts || {} + + if (opts.certId === undefined || opts.certId === null) { + throw new Error( + "Missing the required parameter 'opts.certId' when calling modifyCert" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + certId: opts.certId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 modifyCert 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}/certs/{certId}:modifyCert', + '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) + } + ) + } + + /** + * 查询弹性公网IP列表<br/> +支持分页查询,默认每页20条<br/> + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[20, 100] optional + * @param {string} [opts.status] - 弹性公网IP状态,取值范围:associate、disassociate optional + * @param {string} [opts.includeLB] - 是否包含负载均衡 optional + * @param {string} [opts.chargeMode] - 支付模式,取值为:prepaid_by_duration表示预付费,postpaid_by_duration表示按配置后付费 optional + * @param {string} [opts.instanceId] - 实例Id optional + * @param {string} [opts.subnetId] - 子网Id optional + * @param {filter} [opts.filters] - elasticIpId - 弹性公网IPID,精确匹配,支持多个<br/> +elasticIp - 弹性公网IP,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param elasticIp elasticIps + * @param integer pageNumber 页码;默认为1 + * @param integer pageSize 分页大小;默认为20;取值范围[20, 100] + * @param integer totalCount 查询结果总数 + */ + + describeElasticIps (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 describeElasticIps" + ) + } + + 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.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + if (opts.includeLB !== undefined && opts.includeLB !== null) { + queryParams['includeLB'] = opts.includeLB + } + if (opts.chargeMode !== undefined && opts.chargeMode !== null) { + queryParams['chargeMode'] = opts.chargeMode + } + if (opts.instanceId !== undefined && opts.instanceId !== null) { + queryParams['instanceId'] = opts.instanceId + } + if (opts.subnetId !== undefined && opts.subnetId !== null) { + queryParams['subnetId'] = opts.subnetId + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeElasticIps 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}/elasticIps', + '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 + + * @param {Object} opts - parameters + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {elasticIpSpec} opts.elasticIpSpec - 弹性公网IP配置 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string elasticIpIds + */ + + applyElasticIps (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 applyElasticIps" + ) + } + + opts = opts || {} + + if (opts.elasticIpSpec === undefined || opts.elasticIpSpec === null) { + throw new Error( + "Missing the required parameter 'opts.elasticIpSpec' when calling applyElasticIps" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.elasticIpSpec !== undefined && opts.elasticIpSpec !== null) { + postBody['elasticIpSpec'] = opts.elasticIpSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 applyElasticIps 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}/elasticIps', + '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) + } + ) + } + + /** + * 查询弹性公网IP详情 + * @param {Object} opts - parameters + * @param {string} opts.elasticIpId - 弹性公网IPID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param elasticIp elasticIp 弹性公网IP详细信息 + */ + + describeElasticIp (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 describeElasticIp" + ) + } + + opts = opts || {} + + if (opts.elasticIpId === undefined || opts.elasticIpId === null) { + throw new Error( + "Missing the required parameter 'opts.elasticIpId' when calling describeElasticIp" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + elasticIpId: opts.elasticIpId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeElasticIp 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}/elasticIps/{elasticIpId}', + '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带宽 + + * @param {Object} opts - parameters + * @param {string} opts.elasticIpId - 弹性公网IPID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {integer} opts.bandwidth - 带宽,单位Mbps,取值范围[1,200] + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 修改带宽是否成功 + */ + + modifyElasticIpBandwidth (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 modifyElasticIpBandwidth" + ) + } + + opts = opts || {} + + if (opts.elasticIpId === undefined || opts.elasticIpId === null) { + throw new Error( + "Missing the required parameter 'opts.elasticIpId' when calling modifyElasticIpBandwidth" + ) + } + if (opts.bandwidth === undefined || opts.bandwidth === null) { + throw new Error( + "Missing the required parameter 'opts.bandwidth' when calling modifyElasticIpBandwidth" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.bandwidth !== undefined && opts.bandwidth !== null) { + postBody['bandwidth'] = opts.bandwidth + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + elasticIpId: opts.elasticIpId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 modifyElasticIpBandwidth 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}/elasticIps/{elasticIpId}:modifyElasticIpBandwidth', + '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) + } + ) + } + + /** + * 查询EIP名称 + * @param {Object} opts - parameters + * @param {string} opts.elasticIpId - 弹性公网IPID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string name EIP名称 + */ + + describeElasticIpName (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 describeElasticIpName" + ) + } + + opts = opts || {} + + if (opts.elasticIpId === undefined || opts.elasticIpId === null) { + throw new Error( + "Missing the required parameter 'opts.elasticIpId' when calling describeElasticIpName" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + elasticIpId: opts.elasticIpId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeElasticIpName 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}/elasticIp/{elasticIpId}:describeElasticIpName', + '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.az] - 可用区,精确匹配 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param deviceType deviceTypes + */ + + describeDeviceTypes (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 describeDeviceTypes" + ) + } + + 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 cps/2.4.3' + } + + 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 describeDeviceTypes 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}/deviceTypes', + '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.deviceType - 实例类型,可调用接口(describeDeviceTypes)获取指定地域的实例类型,例如:cps.c.normal + * @param {string} [opts.osType] - 操作系统类型,取值范围:CentOS、Ubuntu、Windows optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param os oss + */ + + describeOS (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 describeOS" + ) + } + + opts = opts || {} + + if (opts.deviceType === undefined || opts.deviceType === null) { + throw new Error( + "Missing the required parameter 'opts.deviceType' when calling describeOS" + ) + } + + let postBody = null + let queryParams = {} + if (opts.deviceType !== undefined && opts.deviceType !== null) { + queryParams['deviceType'] = opts.deviceType + } + if (opts.osType !== undefined && opts.osType !== null) { + queryParams['osType'] = opts.osType + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeOS 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}/os', + '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) + } + ) + } + + /** + * 查询某种实例类型的云物理服务器支持的RAID类型,可查询系统盘RAID类型和数据盘RAID类型 + * @param {Object} opts - parameters + * @param {string} opts.deviceType - 实例类型,可调用(describeDeviceTypes)接口获取指定地域的实例类型,例如:cps.c.normal + * @param {string} [opts.volumeType] - 磁盘类型,取值范围:system、data optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param raid raids + */ + + describeDeviceRaids (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 describeDeviceRaids" + ) + } + + opts = opts || {} + + if (opts.deviceType === undefined || opts.deviceType === null) { + throw new Error( + "Missing the required parameter 'opts.deviceType' when calling describeDeviceRaids" + ) + } + + let postBody = null + let queryParams = {} + if (opts.deviceType !== undefined && opts.deviceType !== null) { + queryParams['deviceType'] = opts.deviceType + } + if (opts.volumeType !== undefined && opts.volumeType !== null) { + queryParams['volumeType'] = opts.volumeType + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeDeviceRaids 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}/raids', + '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 + */ + + 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 || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeInstance" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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}/instances/{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/> +支持分页查询,默认每页20条<br/> + + * @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.name] - 云物理服务器名称,支持模糊匹配 optional + * @param {string} [opts.networkType] - 网络类型,精确匹配,支持basic(基础网络)、vpc(私有网络)、retail(零售中台网络) optional + * @param {string} [opts.deviceType] - 实例类型,精确匹配,调用接口(describeDeviceTypes)获取实例类型 optional + * @param {string} [opts.subnetId] - 子网ID optional + * @param {string} [opts.keypairId] - 密钥对ID optional + * @param {string} [opts.enableInternet] - 是否启用外网, yes、no optional + * @param {string} [opts.privateIp] - 内网ip optional + * @param {string} [opts.interfaceMode] - 实例网卡类型:bond(网卡bond)、dual(双网卡) optional + * @param {filter} [opts.filters] - instanceId - 云物理服务器ID,精确匹配,支持多个<br/> +status - 云物理服务器状态,参考云物理服务器状态,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instance instances + * @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.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + if (opts.networkType !== undefined && opts.networkType !== null) { + queryParams['networkType'] = opts.networkType + } + if (opts.deviceType !== undefined && opts.deviceType !== null) { + queryParams['deviceType'] = opts.deviceType + } + if (opts.subnetId !== undefined && opts.subnetId !== null) { + queryParams['subnetId'] = opts.subnetId + } + if (opts.keypairId !== undefined && opts.keypairId !== null) { + queryParams['keypairId'] = opts.keypairId + } + if (opts.enableInternet !== undefined && opts.enableInternet !== null) { + queryParams['enableInternet'] = opts.enableInternet + } + if (opts.privateIp !== undefined && opts.privateIp !== null) { + queryParams['privateIp'] = opts.privateIp + } + if (opts.interfaceMode !== undefined && opts.interfaceMode !== null) { + queryParams['interfaceMode'] = opts.interfaceMode + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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}/instances', + '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/> +- 地域与可用区<br/> + - 调用接口(describeRegiones)获取云物理服务器支持的地域与可用区<br/> +- 实例类型<br/> + - 调用接口(describeDeviceTypes)获取物理实例类型列表<br/> + - 不能使用已下线、或已售馨的实例类型<br/> +- 操作系统<br/> + - 可调用接口(describeOS)获取云物理服务器支持的操作系统列表<br/> +- 存储<br/> + - 数据盘多种RAID可选,可调用接口(describeDeviceRaids)获取服务器支持的RAID列表<br/> +- 网络<br/> + - 网络类型目前支持basic、vpc<br/> + - 线路目前只支持bgp<br/> + - 支持不启用外网,如果启用外网,带宽范围[1,200] 单位Mbps<br/> +- 其他<br/> + - 购买时长,可按年或月购买:月取值范围[1,9], 年取值范围[1,3]<br/> + - 密码设置参考公共参数规范<br/> + + * @param {Object} opts - parameters + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {instanceSpec} opts.instanceSpec - 描述云物理服务器配置 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string 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 cps/2.4.3' + } + + 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}/instances', + '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) + } + ) + } + + /** + * 查询云物理服务器名称 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云物理服务器ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string name 云物理服务器名称 + */ + + describeInstanceName (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 describeInstanceName" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeInstanceName" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeInstanceName 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}/instances/{instanceId}:describeInstanceName', + '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) + } + ) + } + + /** + * 申请IPv6地址 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云物理服务器ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} [opts.ipv6Address] - IPv6地址 optional + * @param {string} opts.subnetId - 子网ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string ipv6Address IPv6地址 + */ + + assignIpv6Address (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 assignIpv6Address" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling assignIpv6Address" + ) + } + if (opts.subnetId === undefined || opts.subnetId === null) { + throw new Error( + "Missing the required parameter 'opts.subnetId' when calling assignIpv6Address" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.ipv6Address !== undefined && opts.ipv6Address !== null) { + postBody['ipv6Address'] = opts.ipv6Address + } + if (opts.subnetId !== undefined && opts.subnetId !== null) { + postBody['subnetId'] = opts.subnetId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 assignIpv6Address 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}/instances/{instanceId}:assignIpv6Address', + '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 - 云物理服务器ID + * @param {string} [opts.name] - 云物理服务器名称 optional + * @param {string} [opts.description] - 云物理服务器描述 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string name 云物理服务器名称 + * @param string description 云物理服务器描述 + */ + + 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" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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}/instances/{instanceId}: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) + } + ) + } + + /** + * 查询单个云物理服务器已安装的RAID信息,包括系统盘RAID信息和数据盘RAID信息 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云物理服务器ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string sysRaidTypeId 系统盘RAID类型ID + * @param string sysRaidType 系统盘RAID类型 + * @param string dataRaidTypeId 数据盘RAID类型ID + * @param string dataRaidType 数据盘RAID类型 + */ + + describeInstanceRaid (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 describeInstanceRaid" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeInstanceRaid" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeInstanceRaid 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}/instances/{instanceId}:describeInstanceRaid', + '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 boolean cpus CPU状态是否正常 + * @param boolean mems 内存状态是否正常 + * @param boolean disks 硬盘状态是否正常 + * @param boolean nics 网卡状态是否正常 + */ + + describeInstanceStatus (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 describeInstanceStatus" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeInstanceStatus" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeInstanceStatus 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}/instances/{instanceId}:describeInstanceStatus', + '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) + } + ) + } + + /** + * 重启单台云物理服务器,只能重启running状态的服务器 [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云物理服务器ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 重启操作是否成功 + */ + + restartInstance (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 restartInstance" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling restartInstance" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 restartInstance 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}/instances/{instanceId}:restartInstance', + '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) + } + ) + } + + /** + * 对单台云物理服务器执行关机操作,只能停止running状态的服务器 [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云物理服务器ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + 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 + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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}/instances/{instanceId}:stopInstance', + '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) + } + ) + } + + /** + * 对单台云物理服务器执行开机操作,只能启动stopped状态的服务器 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云物理服务器ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @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 + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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}/instances/{instanceId}:startInstance', + '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) + } + ) + } + + /** + * 批量重启云物理服务器,只能重启running状态的服务器 [MFA enabled] + * @param {Object} opts - parameters + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {array} [opts.instanceIds] - 资源id列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 重启操作是否成功 + */ + + restartInstances (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 restartInstances" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.instanceIds !== undefined && opts.instanceIds !== null) { + postBody['instanceIds'] = opts.instanceIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 restartInstances 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}/instances:restartInstances', + '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) + } + ) + } + + /** + * 批量关闭云物理服务器,只能停止running状态的服务器 [MFA enabled] + * @param {Object} opts - parameters + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {array} [opts.instanceIds] - 资源id列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 关机操作是否成功 + */ + + stopInstances (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 stopInstances" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.instanceIds !== undefined && opts.instanceIds !== null) { + postBody['instanceIds'] = opts.instanceIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 stopInstances 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}/instances:stopInstances', + '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) + } + ) + } + + /** + * 批量开启云物理服务器,只能启动stopped状态的服务器 + * @param {Object} opts - parameters + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {array} [opts.instanceIds] - 资源id列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 开机操作是否成功 + */ + + startInstances (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 startInstances" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.instanceIds !== undefined && opts.instanceIds !== null) { + postBody['instanceIds'] = opts.instanceIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 startInstances 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}/instances:startInstances', + '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) + } + ) + } + + /** + * 重装云物理服务器,只能重装stopped状态的服务器<br/> +- 可调用接口(describeOS)获取云物理服务器支持的操作系统列表 + [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云物理服务器ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {reinstallInstanceSpec} opts.instanceSpec - 云物理服务器配置 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 重装操作是否成功 + */ + + reinstallInstance (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 reinstallInstance" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling reinstallInstance" + ) + } + if (opts.instanceSpec === undefined || opts.instanceSpec === null) { + throw new Error( + "Missing the required parameter 'opts.instanceSpec' when calling reinstallInstance" + ) + } + + 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, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 reinstallInstance 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}/instances/{instanceId}:reinstallInstance', + '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) + } + ) + } + + /** + * 升级云物理服务器外网带宽,只能操作running或者stopped状态的服务器<br/> +- 不支持未启用外网的服务器升级带宽 +- 外网带宽不支持降级 + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云物理服务器ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {integer} opts.bandwidth - 外网带宽,单位Mbps,取值范围[1,200] + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 升级带宽是否成功 + */ + + modifyBandwidth (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 modifyBandwidth" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyBandwidth" + ) + } + if (opts.bandwidth === undefined || opts.bandwidth === null) { + throw new Error( + "Missing the required parameter 'opts.bandwidth' when calling modifyBandwidth" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.bandwidth !== undefined && opts.bandwidth !== null) { + postBody['bandwidth'] = opts.bandwidth + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 modifyBandwidth 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}/instances/{instanceId}:modifyBandwidth', + '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) + } + ) + } + + /** + * 绑定弹性公网IP + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云物理服务器ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} opts.elasticIpId - 弹性公网IPID + * @param {string} [opts.targetIp] - 私有IP optional + * @param {string} [opts.subnetId] - 主网口或辅网口的子网ID,多网口实例必填 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 绑定结果 + */ + + associateElasticIp (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 associateElasticIp" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling associateElasticIp" + ) + } + if (opts.elasticIpId === undefined || opts.elasticIpId === null) { + throw new Error( + "Missing the required parameter 'opts.elasticIpId' when calling associateElasticIp" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.elasticIpId !== undefined && opts.elasticIpId !== null) { + postBody['elasticIpId'] = opts.elasticIpId + } + if (opts.targetIp !== undefined && opts.targetIp !== null) { + postBody['targetIp'] = opts.targetIp + } + if (opts.subnetId !== undefined && opts.subnetId !== null) { + postBody['subnetId'] = opts.subnetId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 associateElasticIp 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}/instances/{instanceId}:associateElasticIp', + '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) + } + ) + } + + /** + * 解绑弹性公网IP + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云物理服务器ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} opts.elasticIpId - 弹性公网IPId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 解绑结果 + */ + + disassociateElasticIp (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 disassociateElasticIp" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling disassociateElasticIp" + ) + } + if (opts.elasticIpId === undefined || opts.elasticIpId === null) { + throw new Error( + "Missing the required parameter 'opts.elasticIpId' when calling disassociateElasticIp" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.elasticIpId !== undefined && opts.elasticIpId !== null) { + postBody['elasticIpId'] = opts.elasticIpId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 disassociateElasticIp 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}/instances/{instanceId}:disassociateElasticIp', + '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) + } + ) + } + + /** + * 重置云物理服务器密码 + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云物理服务器ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} opts.password - 密码 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 重置结果 + */ + + resetPassword (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 resetPassword" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling resetPassword" + ) + } + if (opts.password === undefined || opts.password === null) { + throw new Error( + "Missing the required parameter 'opts.password' when calling resetPassword" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.password !== undefined && opts.password !== null) { + postBody['password'] = opts.password + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 resetPassword 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}/instances/{instanceId}:resetPassword', + '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) + } + ) + } + + /** + * 查询可用的私有IP列表 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云物理服务器ID + * @param {string} opts.subnetId - 主网口或者辅网口的子网id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string availablePrivateIps + */ + + describeAvailablePrivateIp (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 describeAvailablePrivateIp" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeAvailablePrivateIp" + ) + } + if (opts.subnetId === undefined || opts.subnetId === null) { + throw new Error( + "Missing the required parameter 'opts.subnetId' when calling describeAvailablePrivateIp" + ) + } + + let postBody = null + let queryParams = {} + if (opts.subnetId !== undefined && opts.subnetId !== null) { + queryParams['subnetId'] = opts.subnetId + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeAvailablePrivateIp 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}/instances/{instanceId}/availablePrivateIps', + '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 {integer} [opts.startTime] - 开始时间的时间戳,格式:1562915166551 optional + * @param {integer} [opts.endTime] - 结束时间的时间戳,格式:1562915166551 optional + * @param {filter} [opts.filters] - metric - 监控指标,精确匹配,支持多个,具体如下<br/> +cps.cpu.util - CPU使用率<br/> +cps.memory.util - 内存使用率<br/> +cps.memory.used - 内存使用量<br/> +cps.disk.used - 磁盘使用量<br/> +cps.disk.util - 磁盘使用率<br/> +cps.disk.bytes.read - 磁盘读流量<br/> +cps.disk.bytes.write - 磁盘写流量<br/> +cps.disk.counts.read - 磁盘读IOPS<br/> +cps.disk.counts.write - 磁盘写IOPS<br/> +cps.network.bytes.ingress - 网卡进流量<br/> +cps.network.bytes.egress - 网卡出流量<br/> +cps.network.packets.ingress - 网络进包量<br/> +cps.network.packets.egress - 网络出包量<br/> +cps.avg.load1 - CPU平均负载1min<br/> +cps.avg.load5 - CPU平均负载5min<br/> +cps.avg.load15 - CPU平均负载15min<br/> +cps.tcp.connect.total - TCP总连接数<br/> +cps.tcp.connect.established - TCP正常连接数<br/> +cps.process.total - 总进程数 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param metricData metricDatas + */ + + describeInstanceMonitorInfo (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 describeInstanceMonitorInfo" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeInstanceMonitorInfo" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeInstanceMonitorInfo 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}/instances/{instanceId}/monitor', + '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 {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[20, 100] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param eventLog eventLogs + * @param integer pageNumber 页码;默认为1 + * @param integer pageSize 分页大小;默认为20;取值范围[20, 100] + * @param integer totalCount 查询结果总数 + */ + + describeEventLogs (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 describeEventLogs" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeEventLogs" + ) + } + + 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 cps/2.4.3' + } + + 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 describeEventLogs 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}/instances/{instanceId}/describeEventLogs', + '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) + } + ) + } + + /** + * 查询IPv6地址例详情 + * @param {Object} opts - parameters + * @param {string} opts.ipv6AddressId - IPv6地址ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param ipv6Address ipv6Address IPv6地址详细信息 + */ + + describeIpv6Address (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 describeIpv6Address" + ) + } + + opts = opts || {} + + if (opts.ipv6AddressId === undefined || opts.ipv6AddressId === null) { + throw new Error( + "Missing the required parameter 'opts.ipv6AddressId' when calling describeIpv6Address" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + ipv6AddressId: opts.ipv6AddressId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeIpv6Address 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}/ipv6Addresses/{ipv6AddressId}', + '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) + } + ) + } + + /** + * 查询IPv6地址列表<br/> +支持分页查询,默认每页20条<br/> + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[20, 100] optional + * @param {string} [opts.ipv6GatewayId] - IPv6网关ID optional + * @param {string} [opts.ipv6Address] - IPv6地址 optional + * @param {boolean} [opts.enableInternet] - 是否已开通公网 optional + * @param {filter} [opts.filters] - ipv6AddressId - IPv6地址ID,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param ipv6Address ipv6Addresses + * @param integer pageNumber 页码;默认为1 + * @param integer pageSize 分页大小;默认为20;取值范围[20, 100] + * @param integer totalCount 查询结果总数 + */ + + describeIpv6Addresses (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 describeIpv6Addresses" + ) + } + + 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.ipv6GatewayId !== undefined && opts.ipv6GatewayId !== null) { + queryParams['ipv6GatewayId'] = opts.ipv6GatewayId + } + if (opts.ipv6Address !== undefined && opts.ipv6Address !== null) { + queryParams['ipv6Address'] = opts.ipv6Address + } + if (opts.enableInternet !== undefined && opts.enableInternet !== null) { + queryParams['enableInternet'] = opts.enableInternet + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeIpv6Addresses 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}/ipv6Addresses', + '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) + } + ) + } + + /** + * 申请IPv6地址带宽 + + * @param {Object} opts - parameters + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {ipv6AddressSpec} opts.ipv6AddressSpec - IPv6地址配置 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string ipv6AddressIds + */ + + assignIpv6AddressesBandwidth ( + 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 assignIpv6AddressesBandwidth" + ) + } + + opts = opts || {} + + if (opts.ipv6AddressSpec === undefined || opts.ipv6AddressSpec === null) { + throw new Error( + "Missing the required parameter 'opts.ipv6AddressSpec' when calling assignIpv6AddressesBandwidth" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.ipv6AddressSpec !== undefined && opts.ipv6AddressSpec !== null) { + postBody['ipv6AddressSpec'] = opts.ipv6AddressSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 assignIpv6AddressesBandwidth 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}/ipv6Addresses', + '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) + } + ) + } + + /** + * 修改IPv6公网带宽 + + * @param {Object} opts - parameters + * @param {string} opts.ipv6AddressId - IPv6地址ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {integer} opts.bandwidth - 带宽,单位Mbps,取值范围[1,200] + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 修改带宽是否成功 + */ + + modifyIpv6AddressBandwidth (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 modifyIpv6AddressBandwidth" + ) + } + + opts = opts || {} + + if (opts.ipv6AddressId === undefined || opts.ipv6AddressId === null) { + throw new Error( + "Missing the required parameter 'opts.ipv6AddressId' when calling modifyIpv6AddressBandwidth" + ) + } + if (opts.bandwidth === undefined || opts.bandwidth === null) { + throw new Error( + "Missing the required parameter 'opts.bandwidth' when calling modifyIpv6AddressBandwidth" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.bandwidth !== undefined && opts.bandwidth !== null) { + postBody['bandwidth'] = opts.bandwidth + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + ipv6AddressId: opts.ipv6AddressId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 modifyIpv6AddressBandwidth 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}/ipv6Addresses/{ipv6AddressId}:modifyIpv6AddressBandwidth', + '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) + } + ) + } + + /** + * 查询IPv6网关实例列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[20, 100] optional + * @param {string} [opts.ipv6GatewayName] - IPv6网关名称 optional + * @param {filter} [opts.filters] - ipv6GatewayId - IPv6网关实例ID,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param ipv6Gateway ipv6Gateways + * @param integer pageNumber 页码;默认为1 + * @param integer pageSize 分页大小;默认为20;取值范围[20, 100] + * @param integer totalCount 查询结果总数 + */ + + describeIpv6Gateways (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 describeIpv6Gateways" + ) + } + + 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.ipv6GatewayName !== undefined && opts.ipv6GatewayName !== null) { + queryParams['ipv6GatewayName'] = opts.ipv6GatewayName + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeIpv6Gateways 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}/ipv6Gateways', + '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) + } + ) + } + + /** + * 查询IPv6网关实例详情 + * @param {Object} opts - parameters + * @param {string} opts.ipv6GatewayId - IPv6网关ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param ipv6Gateway ipv6Gateway IPv6网关实例详细信息 + */ + + describeIpv6Gateway (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 describeIpv6Gateway" + ) + } + + opts = opts || {} + + if (opts.ipv6GatewayId === undefined || opts.ipv6GatewayId === null) { + throw new Error( + "Missing the required parameter 'opts.ipv6GatewayId' when calling describeIpv6Gateway" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + ipv6GatewayId: opts.ipv6GatewayId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeIpv6Gateway 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}/ipv6Gateways/{ipv6GatewayId}', + '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) + } + ) + } + + /** + * 修改IPv6网关实例 + * @param {Object} opts - parameters + * @param {string} opts.ipv6GatewayId - IPv6网关ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} [opts.ipv6GatewayName] - IPv6网关实例名称 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param ipv6Gateway ipv6Gateway IPv6网关实例详细信息 + */ + + modifyIpv6Gateway (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 modifyIpv6Gateway" + ) + } + + opts = opts || {} + + if (opts.ipv6GatewayId === undefined || opts.ipv6GatewayId === null) { + throw new Error( + "Missing the required parameter 'opts.ipv6GatewayId' when calling modifyIpv6Gateway" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.ipv6GatewayName !== undefined && opts.ipv6GatewayName !== null) { + postBody['ipv6GatewayName'] = opts.ipv6GatewayName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + ipv6GatewayId: opts.ipv6GatewayId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 modifyIpv6Gateway 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}/ipv6Gateways/{ipv6GatewayId}', + '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.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[20, 100] optional + * @param {string} [opts.name] - 密钥对名称 optional + * @param {filter} [opts.filters] - keypairId - 密钥对ID,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param keypair keypairs + * @param integer pageNumber 页码;默认为1 + * @param integer pageSize 分页大小;默认为20;取值范围[20, 100] + * @param integer totalCount 查询结果总数 + */ + + describeKeypairs (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 describeKeypairs" + ) + } + + 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.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeKeypairs 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}/keypairs', + '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.name - 密钥对名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string keypairId 密钥对id + * @param string region 地域 + * @param string name 密钥对名称 + * @param string publicKey 公钥 + * @param string fingerPrint 指纹 + * @param string createTime 创建时间 + * @param string updateTime 更新时间 + * @param string privateKey 私钥 + */ + + createKeypairs (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 createKeypairs" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createKeypairs" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 createKeypairs 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}/keypairs', + '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) + } + ) + } + + /** + * 导入密钥对 + * @param {Object} opts - parameters + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} opts.name - 密钥对名称 + * @param {string} opts.publicKey - 公钥 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string keypairId 密钥对id + * @param string region 地域 + * @param string name 密钥对名称 + * @param string publicKey 公钥 + * @param string fingerPrint 指纹 + * @param string createTime 创建时间 + * @param string updateTime 更新时间 + */ + + importKeypairs (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 importKeypairs" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling importKeypairs" + ) + } + if (opts.publicKey === undefined || opts.publicKey === null) { + throw new Error( + "Missing the required parameter 'opts.publicKey' when calling importKeypairs" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.publicKey !== undefined && opts.publicKey !== null) { + postBody['publicKey'] = opts.publicKey + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 importKeypairs 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}/keypairs:import', + '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) + } + ) + } + + /** + * 查询密钥对详情 + * @param {Object} opts - parameters + * @param {string} opts.keypairId - 密钥对ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param keypair keypair 密钥对详细信息 + */ + + describeKeypair (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 describeKeypair" + ) + } + + opts = opts || {} + + if (opts.keypairId === undefined || opts.keypairId === null) { + throw new Error( + "Missing the required parameter 'opts.keypairId' when calling describeKeypair" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + keypairId: opts.keypairId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeKeypair 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}/keypairs/{keypairId}', + '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.keypairId - 密钥对ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 删除操作是否成功 + */ + + deleteKeypairs (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 deleteKeypairs" + ) + } + + opts = opts || {} + + if (opts.keypairId === undefined || opts.keypairId === null) { + throw new Error( + "Missing the required parameter 'opts.keypairId' when calling deleteKeypairs" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + keypairId: opts.keypairId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 deleteKeypairs 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}/keypairs/{keypairId}', + '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 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[20, 100] optional + * @param {string} [opts.name] - 名称 optional + * @param {string} [opts.loadBalancerId] - 负载均衡实例ID,精确匹配 optional + * @param {filter} [opts.filters] - listenerId - 监听器ID,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param listener listeners + * @param integer pageNumber 页码;默认为1 + * @param integer pageSize 分页大小;默认为20;取值范围[20, 100] + * @param integer totalCount 查询结果总数 + */ + + describeListeners (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 describeListeners" + ) + } + + 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.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + if (opts.loadBalancerId !== undefined && opts.loadBalancerId !== null) { + queryParams['loadBalancerId'] = opts.loadBalancerId + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeListeners 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}/listeners', + '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 {listenerSpec} opts.listenerSpec - 监听器配置 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string listenerId 监听器ID + */ + + createListener (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 createListener" + ) + } + + opts = opts || {} + + if (opts.listenerSpec === undefined || opts.listenerSpec === null) { + throw new Error( + "Missing the required parameter 'opts.listenerSpec' when calling createListener" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.listenerSpec !== undefined && opts.listenerSpec !== null) { + postBody['listenerSpec'] = opts.listenerSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 createListener 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}/listeners', + '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) + } + ) + } + + /** + * 修改监听器 + * @param {Object} opts - parameters + * @param {string} opts.listenerId - 监听器ID + * @param {string} [opts.algorithm] - 调度算法 optional + * @param {string} [opts.stickySession] - 会话保持 optional + * @param {string} [opts.realIp] - 是否获取真实ip,取值范围on|off optional + * @param {string} [opts.name] - 名称 optional + * @param {string} [opts.description] - 描述 optional + * @param {string} [opts.healthCheck] - 健康检查 optional + * @param {integer} [opts.healthCheckTimeout] - 健康检查响应的最大超时时间 optional + * @param {integer} [opts.healthCheckInterval] - 健康检查响应的最大间隔时间 optional + * @param {integer} [opts.healthyThreshold] - 健康检查结果为success的阈值 optional + * @param {integer} [opts.unhealthyThreshold] - 健康检查结果为fail的阈值 optional + * @param {string} [opts.serverGroupId] - 服务器组id optional + * @param {integer} [opts.stickySessionTimeout] - 会话保持超时时间,单位s optional + * @param {string} [opts.cookieType] - 会话类型,植入Cookie or 重写Cookie optional + * @param {string} [opts.healthCheckUri] - 检查路径 optional + * @param {string} [opts.healthCheckHttpCode] - 正常态码,要使用的Http状态码 optional + * @param {string} [opts.certificateId] - 证书ID optional + * @param {array} [opts.headers] - 获取HTTP头字段:X-Forwarded-For、X-Forwarded-Proto、X- Forwarded-Port、X-Forwarded-LBIP optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param listener listener 监听器详细信息 + */ + + modifyListener (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 modifyListener" + ) + } + + opts = opts || {} + + if (opts.listenerId === undefined || opts.listenerId === null) { + throw new Error( + "Missing the required parameter 'opts.listenerId' when calling modifyListener" + ) + } + + let postBody = {} + if (opts.algorithm !== undefined && opts.algorithm !== null) { + postBody['algorithm'] = opts.algorithm + } + if (opts.stickySession !== undefined && opts.stickySession !== null) { + postBody['stickySession'] = opts.stickySession + } + if (opts.realIp !== undefined && opts.realIp !== null) { + postBody['realIp'] = opts.realIp + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.healthCheck !== undefined && opts.healthCheck !== null) { + postBody['healthCheck'] = opts.healthCheck + } + if ( + opts.healthCheckTimeout !== undefined && + opts.healthCheckTimeout !== null + ) { + postBody['healthCheckTimeout'] = opts.healthCheckTimeout + } + if ( + opts.healthCheckInterval !== undefined && + opts.healthCheckInterval !== null + ) { + postBody['healthCheckInterval'] = opts.healthCheckInterval + } + if (opts.healthyThreshold !== undefined && opts.healthyThreshold !== null) { + postBody['healthyThreshold'] = opts.healthyThreshold + } + if ( + opts.unhealthyThreshold !== undefined && + opts.unhealthyThreshold !== null + ) { + postBody['unhealthyThreshold'] = opts.unhealthyThreshold + } + if (opts.serverGroupId !== undefined && opts.serverGroupId !== null) { + postBody['serverGroupId'] = opts.serverGroupId + } + if ( + opts.stickySessionTimeout !== undefined && + opts.stickySessionTimeout !== null + ) { + postBody['stickySessionTimeout'] = opts.stickySessionTimeout + } + if (opts.cookieType !== undefined && opts.cookieType !== null) { + postBody['cookieType'] = opts.cookieType + } + if (opts.healthCheckUri !== undefined && opts.healthCheckUri !== null) { + postBody['healthCheckUri'] = opts.healthCheckUri + } + if ( + opts.healthCheckHttpCode !== undefined && + opts.healthCheckHttpCode !== null + ) { + postBody['healthCheckHttpCode'] = opts.healthCheckHttpCode + } + if (opts.certificateId !== undefined && opts.certificateId !== null) { + postBody['certificateId'] = opts.certificateId + } + if (opts.headers !== undefined && opts.headers !== null) { + postBody['headers'] = opts.headers + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + listenerId: opts.listenerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 modifyListener 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}/listeners/{listenerId}:modifyListenerAttributes', + '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.listenerId - 监听器ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param listener listener 监听器详细信息 + */ + + describeListener (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 describeListener" + ) + } + + opts = opts || {} + + if (opts.listenerId === undefined || opts.listenerId === null) { + throw new Error( + "Missing the required parameter 'opts.listenerId' when calling describeListener" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + listenerId: opts.listenerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeListener 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}/listeners/{listenerId}', + '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.listenerId - 监听器ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 删除操作是否成功 + */ + + deleteListener (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 deleteListener" + ) + } + + opts = opts || {} + + if (opts.listenerId === undefined || opts.listenerId === null) { + throw new Error( + "Missing the required parameter 'opts.listenerId' when calling deleteListener" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + listenerId: opts.listenerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 deleteListener 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}/listeners/{listenerId}', + '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.listenerId - 监听器ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 开启监听器是否成功 + */ + + startListener (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 startListener" + ) + } + + opts = opts || {} + + if (opts.listenerId === undefined || opts.listenerId === null) { + throw new Error( + "Missing the required parameter 'opts.listenerId' when calling startListener" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + listenerId: opts.listenerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 startListener 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}/listeners/{listenerId}:startListener', + '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) + } + ) + } + + /** + * 关闭监听器 + * @param {Object} opts - parameters + * @param {string} opts.listenerId - 监听器ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 关闭监听器是否成功 + */ + + stopListener (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 stopListener" + ) + } + + opts = opts || {} + + if (opts.listenerId === undefined || opts.listenerId === null) { + throw new Error( + "Missing the required parameter 'opts.listenerId' when calling stopListener" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + listenerId: opts.listenerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 stopListener 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}/listeners/{listenerId}:stopListener', + '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) + } + ) + } + + /** + * 查询负载均衡实例列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[20, 100] optional + * @param {string} [opts.status] - 状态 optional + * @param {string} [opts.name] - 名称 optional + * @param {string} [opts.vpcId] - 私有网络ID,精确匹配 optional + * @param {boolean} [opts.bindEip] - 是否绑定eip optional + * @param {filter} [opts.filters] - loadBalancerId - 负载均衡实例ID,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param loadBalancer loadBalancers + * @param integer pageNumber 页码;默认为1 + * @param integer pageSize 分页大小;默认为20;取值范围[20, 100] + * @param integer totalCount 查询结果总数 + */ + + describeLoadBalancers (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 describeLoadBalancers" + ) + } + + 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.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + if (opts.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + if (opts.vpcId !== undefined && opts.vpcId !== null) { + queryParams['vpcId'] = opts.vpcId + } + if (opts.bindEip !== undefined && opts.bindEip !== null) { + queryParams['bindEip'] = opts.bindEip + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeLoadBalancers 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}/slbs', + '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 {loadBalancerSpec} opts.loadBalancerSpec - 负载均衡配置 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string loadBalancerId 负载均衡实例ID + */ + + createLoadBalancer (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 createLoadBalancer" + ) + } + + opts = opts || {} + + if (opts.loadBalancerSpec === undefined || opts.loadBalancerSpec === null) { + throw new Error( + "Missing the required parameter 'opts.loadBalancerSpec' when calling createLoadBalancer" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.loadBalancerSpec !== undefined && opts.loadBalancerSpec !== null) { + postBody['loadBalancerSpec'] = opts.loadBalancerSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 createLoadBalancer 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}/slbs', + '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) + } + ) + } + + /** + * 修改负载均衡实例 + * @param {Object} opts - parameters + * @param {string} opts.loadBalancerId - 负载均衡实例ID + * @param {string} [opts.name] - 名称 optional + * @param {string} [opts.description] - 描述 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param loadBalancer loadBalancer 负载均衡实例详细信息 + */ + + modifyLoadBalancer (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 modifyLoadBalancer" + ) + } + + opts = opts || {} + + if (opts.loadBalancerId === undefined || opts.loadBalancerId === null) { + throw new Error( + "Missing the required parameter 'opts.loadBalancerId' when calling modifyLoadBalancer" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + loadBalancerId: opts.loadBalancerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 modifyLoadBalancer 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}/slbs/{loadBalancerId}:modifyLoadBalancerAttributes', + '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.loadBalancerId - 负载均衡实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param loadBalancer loadBalancer 负载均衡实例详细信息 + */ + + describeLoadBalancer (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 describeLoadBalancer" + ) + } + + opts = opts || {} + + if (opts.loadBalancerId === undefined || opts.loadBalancerId === null) { + throw new Error( + "Missing the required parameter 'opts.loadBalancerId' when calling describeLoadBalancer" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + loadBalancerId: opts.loadBalancerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeLoadBalancer 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}/slbs/{loadBalancerId}', + '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.loadBalancerId - 负载均衡实例ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 开启负载均衡实例是否成功 + */ + + startLoadBalancer (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 startLoadBalancer" + ) + } + + opts = opts || {} + + if (opts.loadBalancerId === undefined || opts.loadBalancerId === null) { + throw new Error( + "Missing the required parameter 'opts.loadBalancerId' when calling startLoadBalancer" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + loadBalancerId: opts.loadBalancerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 startLoadBalancer 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}/slbs/{loadBalancerId}:startLoadBalancer', + '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) + } + ) + } + + /** + * 关闭负载均衡实例 + * @param {Object} opts - parameters + * @param {string} opts.loadBalancerId - 负载均衡实例ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 关闭负载均衡实例是否成功 + */ + + stopLoadBalancer (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 stopLoadBalancer" + ) + } + + opts = opts || {} + + if (opts.loadBalancerId === undefined || opts.loadBalancerId === null) { + throw new Error( + "Missing the required parameter 'opts.loadBalancerId' when calling stopLoadBalancer" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + loadBalancerId: opts.loadBalancerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 stopLoadBalancer 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}/slbs/{loadBalancerId}:stopLoadBalancer', + '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) + } + ) + } + + /** + * 绑定弹性公网IP + * @param {Object} opts - parameters + * @param {string} opts.loadBalancerId - 负载均衡实例ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} opts.elasticIpId - 弹性公网IPId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 绑定结果 + */ + + associateElasticIpLB (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 associateElasticIpLB" + ) + } + + opts = opts || {} + + if (opts.loadBalancerId === undefined || opts.loadBalancerId === null) { + throw new Error( + "Missing the required parameter 'opts.loadBalancerId' when calling associateElasticIpLB" + ) + } + if (opts.elasticIpId === undefined || opts.elasticIpId === null) { + throw new Error( + "Missing the required parameter 'opts.elasticIpId' when calling associateElasticIpLB" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.elasticIpId !== undefined && opts.elasticIpId !== null) { + postBody['elasticIpId'] = opts.elasticIpId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + loadBalancerId: opts.loadBalancerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 associateElasticIpLB 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}/slbs/{loadBalancerId}:associateElasticIp', + '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) + } + ) + } + + /** + * 解绑弹性公网IP + * @param {Object} opts - parameters + * @param {string} opts.loadBalancerId - 负载均衡实例ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} opts.elasticIpId - 弹性公网IPId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 解绑结果 + */ + + disassociateElasticIpLB (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 disassociateElasticIpLB" + ) + } + + opts = opts || {} + + if (opts.loadBalancerId === undefined || opts.loadBalancerId === null) { + throw new Error( + "Missing the required parameter 'opts.loadBalancerId' when calling disassociateElasticIpLB" + ) + } + if (opts.elasticIpId === undefined || opts.elasticIpId === null) { + throw new Error( + "Missing the required parameter 'opts.elasticIpId' when calling disassociateElasticIpLB" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.elasticIpId !== undefined && opts.elasticIpId !== null) { + postBody['elasticIpId'] = opts.elasticIpId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + loadBalancerId: opts.loadBalancerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 disassociateElasticIpLB 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}/slbs/{loadBalancerId}:disassociateElasticIp', + '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) + } + ) + } + + /** + * 查询SLB名称 + * @param {Object} opts - parameters + * @param {string} opts.loadBalancerId - 负载均衡实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string name SLB名称 + */ + + describeSlbsName (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 describeSlbsName" + ) + } + + opts = opts || {} + + if (opts.loadBalancerId === undefined || opts.loadBalancerId === null) { + throw new Error( + "Missing the required parameter 'opts.loadBalancerId' when calling describeSlbsName" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + loadBalancerId: opts.loadBalancerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeSlbsName 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}/slbs/{loadBalancerId}:describeSlbsName', + '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.networkType] - 网络类型basic(基础网络)、vpc(私有网络)、retail(零售中台网络), 默认basic optional + * @param {string} callback - callback + @return {Object} result + * @param region regions + */ + + describeRegiones (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.networkType !== undefined && opts.networkType !== null) { + queryParams['networkType'] = opts.networkType + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeRegiones 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) + } + ) + } + + /** + * 查询负载均衡地域列表 + * @param {Object} opts - parameters + * @param {string} callback - callback + @return {Object} result + * @param region regions + */ + + describeCPSLBRegions (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeCPSLBRegions 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( + '/cpslbRegions', + '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.routeTableId - 路由表ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param routeTable routeTable 路由表详细信息 + */ + + describeRouteTable (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 describeRouteTable" + ) + } + + opts = opts || {} + + if (opts.routeTableId === undefined || opts.routeTableId === null) { + throw new Error( + "Missing the required parameter 'opts.routeTableId' when calling describeRouteTable" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + routeTableId: opts.routeTableId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeRouteTable 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}/routeTables/{routeTableId}', + '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 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[20, 100] optional + * @param {string} [opts.name] - 名称 optional + * @param {string} [opts.vpcId] - 私有网络ID,精确匹配 optional + * @param {filter} [opts.filters] - routeTableId - 路由表ID,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param routeTable routeTables + * @param integer pageNumber 页码;默认为1 + * @param integer pageSize 分页大小;默认为20;取值范围[20, 100] + * @param integer totalCount 查询结果总数 + */ + + describeRouteTables (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 describeRouteTables" + ) + } + + 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.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + if (opts.vpcId !== undefined && opts.vpcId !== null) { + queryParams['vpcId'] = opts.vpcId + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeRouteTables 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}/routeTables', + '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) + } + ) + } + + /** + * 查询次要CIDR列表 + * @param {Object} opts - parameters + * @param {string} opts.subnetId - 子网ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param secondaryCidr secondaryCidrs + */ + + describeSecondaryCidrs (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 describeSecondaryCidrs" + ) + } + + opts = opts || {} + + if (opts.subnetId === undefined || opts.subnetId === null) { + throw new Error( + "Missing the required parameter 'opts.subnetId' when calling describeSecondaryCidrs" + ) + } + + let postBody = null + let queryParams = {} + if (opts.subnetId !== undefined && opts.subnetId !== null) { + queryParams['subnetId'] = opts.subnetId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeSecondaryCidrs 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}/secondaryCidrs', + '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) + } + ) + } + + /** + * 添加次要CIDR + * @param {Object} opts - parameters + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {secondaryCidrSpec} opts.secondaryCidrSpec - 次要cidr配置 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string secondaryCidrId 次要cidr的ID + */ + + createSecondaryCidr (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 createSecondaryCidr" + ) + } + + opts = opts || {} + + if ( + opts.secondaryCidrSpec === undefined || + opts.secondaryCidrSpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.secondaryCidrSpec' when calling createSecondaryCidr" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if ( + opts.secondaryCidrSpec !== undefined && + opts.secondaryCidrSpec !== null + ) { + postBody['secondaryCidrSpec'] = opts.secondaryCidrSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 createSecondaryCidr 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}/secondaryCidrs', + '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) + } + ) + } + + /** + * 删除次要CIDR + * @param {Object} opts - parameters + * @param {string} opts.secondaryCidrId - 次要CIDR ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 删除操作是否成功 + */ + + deleteSecondaryCidr (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 deleteSecondaryCidr" + ) + } + + opts = opts || {} + + if (opts.secondaryCidrId === undefined || opts.secondaryCidrId === null) { + throw new Error( + "Missing the required parameter 'opts.secondaryCidrId' when calling deleteSecondaryCidr" + ) + } + + let postBody = null + let queryParams = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + queryParams['clientToken'] = opts.clientToken + } + + let pathParams = { + regionId: regionId, + secondaryCidrId: opts.secondaryCidrId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 deleteSecondaryCidr 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}/secondaryCidrs/{secondaryCidrId}', + '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.serverGroupId - 服务器组ID + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[20, 100] optional + * @param {string} [opts.listenerId] - 监听器Id optional + * @param {filter} [opts.filters] - serverId - 后端服务器ID,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param server servers + * @param integer pageNumber 页码;默认为1 + * @param integer pageSize 分页大小;默认为20;取值范围[20, 100] + * @param integer totalCount 查询结果总数 + */ + + describeServers (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 describeServers" + ) + } + + opts = opts || {} + + if (opts.serverGroupId === undefined || opts.serverGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.serverGroupId' when calling describeServers" + ) + } + + 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.listenerId !== undefined && opts.listenerId !== null) { + queryParams['listenerId'] = opts.listenerId + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId, + serverGroupId: opts.serverGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeServers 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}/serverGroups/{serverGroupId}/servers', + '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.serverGroupId - 服务器组ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {array} [opts.serverSpec] - 后端服务器配置 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string serverIds + */ + + addServers (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 addServers" + ) + } + + opts = opts || {} + + if (opts.serverGroupId === undefined || opts.serverGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.serverGroupId' when calling addServers" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.serverSpec !== undefined && opts.serverSpec !== null) { + postBody['serverSpec'] = opts.serverSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + serverGroupId: opts.serverGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 addServers 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}/serverGroups/{serverGroupId}/servers', + '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) + } + ) + } + + /** + * 修改后端服务器 + * @param {Object} opts - parameters + * @param {string} opts.serverGroupId - 服务器组ID + * @param {string} opts.serverId - 后端服务器ID + * @param {integer} [opts.weight] - 权重 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string serverId 后端服务器ID + * @param string instanceId 后端云物理服务器ID + * @param string privateIp 内网Ip + * @param integer port 端口 + * @param integer weight 后端云物理服务器权重 + */ + + modifyServer (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 modifyServer" + ) + } + + opts = opts || {} + + if (opts.serverGroupId === undefined || opts.serverGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.serverGroupId' when calling modifyServer" + ) + } + if (opts.serverId === undefined || opts.serverId === null) { + throw new Error( + "Missing the required parameter 'opts.serverId' when calling modifyServer" + ) + } + + let postBody = {} + if (opts.weight !== undefined && opts.weight !== null) { + postBody['weight'] = opts.weight + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + serverGroupId: opts.serverGroupId, + serverId: opts.serverId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 modifyServer 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}/serverGroups/{serverGroupId}/servers/{serverId}', + '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.serverGroupId - 服务器组ID + * @param {string} opts.serverId - 后端服务器ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 删除操作是否成功 + */ + + removeServer (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 removeServer" + ) + } + + opts = opts || {} + + if (opts.serverGroupId === undefined || opts.serverGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.serverGroupId' when calling removeServer" + ) + } + if (opts.serverId === undefined || opts.serverId === null) { + throw new Error( + "Missing the required parameter 'opts.serverId' when calling removeServer" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + serverGroupId: opts.serverGroupId, + serverId: opts.serverId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 removeServer 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}/serverGroups/{serverGroupId}/servers/{serverId}', + '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 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[20, 100] optional + * @param {string} [opts.name] - 名称 optional + * @param {string} [opts.loadBalancerId] - 负载均衡ID optional + * @param {filter} [opts.filters] - serverGroupId - 虚拟服务器组ID,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param serverGroup serverGroups + * @param integer pageNumber 页码;默认为1 + * @param integer pageSize 分页大小;默认为20;取值范围[20, 100] + * @param integer totalCount 查询结果总数 + */ + + describeServerGroups (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 describeServerGroups" + ) + } + + 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.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + if (opts.loadBalancerId !== undefined && opts.loadBalancerId !== null) { + queryParams['loadBalancerId'] = opts.loadBalancerId + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeServerGroups 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}/serverGroups', + '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 {serverGroupSpec} opts.serverGroupSpec - 虚拟服务器组配置 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string serverGroupId 服务器组ID + */ + + createServerGroup (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 createServerGroup" + ) + } + + opts = opts || {} + + if (opts.serverGroupSpec === undefined || opts.serverGroupSpec === null) { + throw new Error( + "Missing the required parameter 'opts.serverGroupSpec' when calling createServerGroup" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.serverGroupSpec !== undefined && opts.serverGroupSpec !== null) { + postBody['serverGroupSpec'] = opts.serverGroupSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 createServerGroup 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}/serverGroups', + '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) + } + ) + } + + /** + * 查询虚拟服务器组 + * @param {Object} opts - parameters + * @param {string} opts.serverGroupId - 服务器组ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param serverGroup serverGroup 服务器组详细信息 + */ + + describeServerGroup (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 describeServerGroup" + ) + } + + opts = opts || {} + + if (opts.serverGroupId === undefined || opts.serverGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.serverGroupId' when calling describeServerGroup" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + serverGroupId: opts.serverGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeServerGroup 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}/serverGroups/{serverGroupId}', + '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.serverGroupId - 服务器组ID + * @param {string} [opts.name] - 名称 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string loadBalancerId 负载均衡ID + * @param string serverGroupId 服务器组ID + * @param string name 名称 + */ + + modifyServerGroup (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 modifyServerGroup" + ) + } + + opts = opts || {} + + if (opts.serverGroupId === undefined || opts.serverGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.serverGroupId' when calling modifyServerGroup" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + serverGroupId: opts.serverGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 modifyServerGroup 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}/serverGroups/{serverGroupId}', + '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.serverGroupId - 服务器组ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 删除操作是否成功 + */ + + deleteServerGroup (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 deleteServerGroup" + ) + } + + opts = opts || {} + + if (opts.serverGroupId === undefined || opts.serverGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.serverGroupId' when calling deleteServerGroup" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + serverGroupId: opts.serverGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 deleteServerGroup 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}/serverGroups/{serverGroupId}', + '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.az - 可用区, 如cn-east-1a;可调用接口(describeRegiones)获取云物理服务器在该地域支持的可用区 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param subnet subnet 子网详细信息 + */ + + describeBasicSubnet (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 describeBasicSubnet" + ) + } + + opts = opts || {} + + if (opts.az === undefined || opts.az === null) { + throw new Error( + "Missing the required parameter 'opts.az' when calling describeBasicSubnet" + ) + } + + 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 cps/2.4.3' + } + + 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 describeBasicSubnet 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}/subnet', + '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 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[20, 100] optional + * @param {string} [opts.az] - 可用区,精确匹配 optional + * @param {string} [opts.name] - 子网名称 optional + * @param {string} [opts.vpcId] - 私有网络ID,精确匹配 optional + * @param {filter} [opts.filters] - subnetId - 子网ID,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param subnet subnets + * @param integer pageNumber 页码;默认为1 + * @param integer pageSize 分页大小;默认为20;取值范围[20, 100] + * @param integer 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.az !== undefined && opts.az !== null) { + queryParams['az'] = opts.az + } + if (opts.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + if (opts.vpcId !== undefined && opts.vpcId !== null) { + queryParams['vpcId'] = opts.vpcId + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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}/subnets', + '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 {subnetSpec} opts.subnetSpec - 子网配置 + * @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.subnetSpec === undefined || opts.subnetSpec === null) { + throw new Error( + "Missing the required parameter 'opts.subnetSpec' when calling createSubnet" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.subnetSpec !== undefined && opts.subnetSpec !== null) { + postBody['subnetSpec'] = opts.subnetSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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}/subnets', + '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) + } + ) + } + + /** + * 申请IPv6网段 + + * @param {Object} opts - parameters + * @param {string} opts.subnetId - 子网ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} [opts.ipv6Cidr] - 子网IPv6 CIDR optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 申请操作是否成功 + */ + + assignIpv6Cidr (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 assignIpv6Cidr" + ) + } + + opts = opts || {} + + if (opts.subnetId === undefined || opts.subnetId === null) { + throw new Error( + "Missing the required parameter 'opts.subnetId' when calling assignIpv6Cidr" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.ipv6Cidr !== undefined && opts.ipv6Cidr !== null) { + postBody['ipv6Cidr'] = opts.ipv6Cidr + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + subnetId: opts.subnetId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 assignIpv6Cidr 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}/subnets/{subnetId}:assignIpv6Cidr', + '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 - 子网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 cps/2.4.3' + } + + 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}/subnets/{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 - 子网ID + * @param {string} [opts.name] - 名称 optional + * @param {string} [opts.description] - 描述 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param subnet subnet 子网详细信息 + */ + + modifySubnet (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 modifySubnet" + ) + } + + opts = opts || {} + + if (opts.subnetId === undefined || opts.subnetId === null) { + throw new Error( + "Missing the required parameter 'opts.subnetId' when calling modifySubnet" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + subnetId: opts.subnetId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 modifySubnet 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}/subnets/{subnetId}', + '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 - 子网ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 删除操作是否成功 + */ + + 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 = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + queryParams['clientToken'] = opts.clientToken + } + + let pathParams = { + regionId: regionId, + subnetId: opts.subnetId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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}/subnets/{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) + } + ) + } + + /** + * 查询私有网络详情 + * @param {Object} opts - parameters + * @param {string} opts.vpcId - 私有网络ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param vpc vpc 私有网络详细信息 + */ + + describeVpc (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 describeVpc" + ) + } + + opts = opts || {} + + if (opts.vpcId === undefined || opts.vpcId === null) { + throw new Error( + "Missing the required parameter 'opts.vpcId' when calling describeVpc" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + vpcId: opts.vpcId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeVpc 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}/vpcs/{vpcId}', + '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 - 私有网络ID + * @param {string} [opts.name] - 名称 optional + * @param {string} [opts.description] - 描述 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param vpc vpc 私有网络详细信息 + */ + + modifyVpc (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 modifyVpc" + ) + } + + opts = opts || {} + + if (opts.vpcId === undefined || opts.vpcId === null) { + throw new Error( + "Missing the required parameter 'opts.vpcId' when calling modifyVpc" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + vpcId: opts.vpcId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 modifyVpc 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}/vpcs/{vpcId}', + '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.vpcId - 私有网络ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 删除操作是否成功 + */ + + deleteVpc (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 deleteVpc" + ) + } + + opts = opts || {} + + if (opts.vpcId === undefined || opts.vpcId === null) { + throw new Error( + "Missing the required parameter 'opts.vpcId' when calling deleteVpc" + ) + } + + let postBody = null + let queryParams = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + queryParams['clientToken'] = opts.clientToken + } + + let pathParams = { + regionId: regionId, + vpcId: opts.vpcId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 deleteVpc 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}/vpcs/{vpcId}', + '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 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[20, 100] optional + * @param {string} [opts.name] - 私有网络名称 optional + * @param {filter} [opts.filters] - vpcId - 私有网络ID,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param vpc vpcs + * @param integer pageNumber 页码;默认为1 + * @param integer pageSize 分页大小;默认为20;取值范围[20, 100] + * @param integer totalCount 查询结果总数 + */ + + describeVpcs (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 describeVpcs" + ) + } + + 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.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 describeVpcs 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}/vpcs', + '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 {vpcSpec} opts.vpcSpec - 子网配置 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string vpcId 私有网络ID + */ + + createVpc (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 createVpc" + ) + } + + opts = opts || {} + + if (opts.vpcSpec === undefined || opts.vpcSpec === null) { + throw new Error( + "Missing the required parameter 'opts.vpcSpec' when calling createVpc" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.vpcSpec !== undefined && opts.vpcSpec !== null) { + postBody['vpcSpec'] = opts.vpcSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 createVpc 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}/vpcs', + '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) + } + ) + } + + /** + * 申请开通IPv6网关 + + * @param {Object} opts - parameters + * @param {string} opts.vpcId - 私有网络ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 申请操作是否成功 + */ + + assignIpv6Gateway (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 assignIpv6Gateway" + ) + } + + opts = opts || {} + + if (opts.vpcId === undefined || opts.vpcId === null) { + throw new Error( + "Missing the required parameter 'opts.vpcId' when calling assignIpv6Gateway" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + vpcId: opts.vpcId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cps/2.4.3' + } + + 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 assignIpv6Gateway 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}/vpcs/{vpcId}:assignIpv6Gateway', + '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 = CPS diff --git a/packages/libs/lib-jdcloud/src/repo/cr/v1/cr.js b/packages/libs/lib-jdcloud/src/repo/cr/v1/cr.js new file mode 100644 index 000000000..a4ea10e8d --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/cr/v1/cr.js @@ -0,0 +1,1840 @@ +/* + * 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. + * + * Repository + * 容器镜像仓库相关接口 + * + * 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 = 'cr' +Service._services[serviceId] = true + +/** + * cr service. + * @version 0.2.0 + */ + +JDCloud.CR = class CR extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'cr.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * <p>申请12小时有效期的令牌。 使用<code>docker</code> CLI push和pull镜像。</p> +<p><code>authorizationToken</code>为每个registry返回一个base64编码的字符串,解码后<code>docker login</code>命令 +可完成指定registry的鉴权。JCR CLI提供<code>jcr get-login</code>进行认证处理。</p> + + * @param {Object} opts - parameters + * @param {string} opts.registryName - 注册表名称 + * @param {integer} [opts.expiredAfterHours] - issue新token的过期时间, 可选参数为新生成令牌的过期时间,最大值为24小时,最小值为1小时,为空则默认为12小时过期时间。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string authorizationToken + * @param string loginCmdLine + * @param string expiresAt + */ + + getAuthorizationToken (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 getAuthorizationToken" + ) + } + + opts = opts || {} + + if (opts.registryName === undefined || opts.registryName === null) { + throw new Error( + "Missing the required parameter 'opts.registryName' when calling getAuthorizationToken" + ) + } + + let postBody = {} + if ( + opts.expiredAfterHours !== undefined && + opts.expiredAfterHours !== null + ) { + postBody['expiredAfterHours'] = opts.expiredAfterHours + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + registryName: opts.registryName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cr/0.2.0' + } + + 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 getAuthorizationToken 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 = this.makeRequest( + '/regions/{regionId}/registries/{registryName}:getAuthorizationToken', + '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) + } + ) + } + + /** + * <p>批量查询令牌。</p> +<p>暂时不支持分页和过滤条件。</p> + + * @param {Object} opts - parameters + * @param {string} opts.registryName - 注册表名称 + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 100] optional + * @param {filter} [opts.filters] - token - 令牌 ID,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param authorizationData authorizationTokens + * @param number totalCount + */ + + describeAuthorizationTokens (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 describeAuthorizationTokens" + ) + } + + opts = opts || {} + + if (opts.registryName === undefined || opts.registryName === null) { + throw new Error( + "Missing the required parameter 'opts.registryName' when calling describeAuthorizationTokens" + ) + } + + 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, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId, + registryName: opts.registryName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cr/0.2.0' + } + + 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 describeAuthorizationTokens 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 = this.makeRequest( + '/regions/{regionId}/registries/{registryName}/tokens', + '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) + } + ) + } + + /** + * 释放用户 registry 的 token。 + + * @param {Object} opts - parameters + * @param {string} opts.registryName - 注册表名称 + * @param {string} [opts.authorizationToken] - 准备释放的 token ID,功能为指定token释放。 optional + * @param {boolean} [opts.forceAll] - true 表示强制删除用户当前registry下所有有效token的标志;false 表示删除所有有效token。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + releaseAuthorizationToken (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 releaseAuthorizationToken" + ) + } + + opts = opts || {} + + if (opts.registryName === undefined || opts.registryName === null) { + throw new Error( + "Missing the required parameter 'opts.registryName' when calling releaseAuthorizationToken" + ) + } + + let postBody = {} + if ( + opts.authorizationToken !== undefined && + opts.authorizationToken !== null + ) { + postBody['authorizationToken'] = opts.authorizationToken + } + if (opts.forceAll !== undefined && opts.forceAll !== null) { + postBody['forceAll'] = opts.forceAll + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + registryName: opts.registryName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cr/0.2.0' + } + + 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 releaseAuthorizationToken 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 = this.makeRequest( + '/regions/{regionId}/registries/{registryName}:releaseAuthorizationToken', + '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) + } + ) + } + + /** + * 返回指定repository中images的元数据,包括image size, image tags和creation date。 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 100] optional + * @param {filter} [opts.filters] - registryName - 镜像仓储名称 +repositoryName - 镜像库名称 +imageDigest - 镜像哈希值 +imageTag - 镜像标签 +tagStatus - 打标TAGGED或没打标UNTAGGED + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param imageDetail imageDetails + * @param number totalCount + */ + + describeImages (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 describeImages" + ) + } + + 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, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cr/0.2.0' + } + + 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 describeImages 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 = this.makeRequest( + '/regions/{regionId}/images', + '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) + } + ) + } + + /** + * 删除镜像 +imageDigest imageTag imageTagStatus 三者只能且必须传一个。 +可根据Tag状态删除Image,例如删除所有tagged的镜像。 +digest和tag唯一表征单个镜像,其中imageDigest为sha256哈希,image manifest的digest。 +例如 sha256:examplee6d1e504117a17000003d3753086354a38375961f2e665416ef4b1b2f;image使用的tag, 如 "precise" + + * @param {Object} opts - parameters + * @param {string} opts.registryName - 注册表名称 + * @param {string} opts.repositoryName - 镜像仓库表名称 + * @param {string} [opts.imageDigest] - sha256哈希,image manifest的digest. optional + * @param {string} [opts.imageTag] - image使用的tag optional + * @param {string} [opts.imageTagStatus] - 枚举中的一个值,如 tagged 和 untagged. optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteImage (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 deleteImage" + ) + } + + opts = opts || {} + + if (opts.registryName === undefined || opts.registryName === null) { + throw new Error( + "Missing the required parameter 'opts.registryName' when calling deleteImage" + ) + } + if (opts.repositoryName === undefined || opts.repositoryName === null) { + throw new Error( + "Missing the required parameter 'opts.repositoryName' when calling deleteImage" + ) + } + + let postBody = {} + if (opts.imageDigest !== undefined && opts.imageDigest !== null) { + postBody['imageDigest'] = opts.imageDigest + } + if (opts.imageTag !== undefined && opts.imageTag !== null) { + postBody['imageTag'] = opts.imageTag + } + if (opts.imageTagStatus !== undefined && opts.imageTagStatus !== null) { + postBody['imageTagStatus'] = opts.imageTagStatus + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + registryName: opts.registryName, + repositoryName: opts.repositoryName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cr/0.2.0' + } + + 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 deleteImage 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 = this.makeRequest( + '/regions/{regionId}/registries/{registryName}/repositories/{repositoryName}:deleteImage', + '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 {filter} [opts.filters] - resourceTypes - 资源类型,暂时只支持 [registry, repository],支持同时查询两种配额。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param quota quotas + */ + + describeQuotas (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 describeQuotas" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + Object.assign(queryParams, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cr/0.2.0' + } + + 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 describeQuotas 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 = this.makeRequest( + '/regions/{regionId}/quotas', + '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) + } + ) + } + + /** + * 批量查询指定用户下所有 registry 详情。 +暂不支持 filter. + + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param registry registries + */ + + describeRegistries (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 describeRegistries" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cr/0.2.0' + } + + 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 describeRegistries 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 = this.makeRequest( + '/regions/{regionId}/registries', + '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.registryName - 用户定义的registry名称。<br> DNS兼容registry名称规则如下: + <br> 不可为空,且不能超过32字符 <br> 以小写字母开始和结尾,支持使用小写字母、数字、中划线(-) + + * @param {string} [opts.description] - 注册表描述,<a href="https://www.jdcloud.com/help/detail/3870/isCatalog/1">参考公共参数规范</a>。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param registry registry + */ + + createRegistry (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 createRegistry" + ) + } + + opts = opts || {} + + if (opts.registryName === undefined || opts.registryName === null) { + throw new Error( + "Missing the required parameter 'opts.registryName' when calling createRegistry" + ) + } + + let postBody = {} + if (opts.registryName !== undefined && opts.registryName !== null) { + postBody['registryName'] = opts.registryName + } + 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 cr/0.2.0' + } + + 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 createRegistry 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 = this.makeRequest( + '/regions/{regionId}/registries', + '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) + } + ) + } + + /** + * 查询指定用户下某个 registry 详情。 + + * @param {Object} opts - parameters + * @param {string} opts.registryName - 注册表名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param registry registry + */ + + describeRegistry (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 describeRegistry" + ) + } + + opts = opts || {} + + if (opts.registryName === undefined || opts.registryName === null) { + throw new Error( + "Missing the required parameter 'opts.registryName' when calling describeRegistry" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + registryName: opts.registryName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cr/0.2.0' + } + + 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 describeRegistry 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 = this.makeRequest( + '/regions/{regionId}/registries/{registryName}', + '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) + } + ) + } + + /** + * 删除指定用户下某个 registry. + + * @param {Object} opts - parameters + * @param {string} opts.registryName - 注册表名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteRegistry (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 deleteRegistry" + ) + } + + opts = opts || {} + + if (opts.registryName === undefined || opts.registryName === null) { + throw new Error( + "Missing the required parameter 'opts.registryName' when calling deleteRegistry" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + registryName: opts.registryName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cr/0.2.0' + } + + 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 deleteRegistry 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 = this.makeRequest( + '/regions/{regionId}/registries/{registryName}', + '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.registryName - 待验证的注册表名。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 表示用户指定的注册表是否通过校验, 0 通过 1 名称为空 2 不符合规范 3 重名 + * @param string reason code字段非零时,给出详细原因。 + */ + + checkRegistryName (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 checkRegistryName" + ) + } + + opts = opts || {} + + if (opts.registryName === undefined || opts.registryName === null) { + throw new Error( + "Missing the required parameter 'opts.registryName' when calling checkRegistryName" + ) + } + + let postBody = {} + if (opts.registryName !== undefined && opts.registryName !== null) { + postBody['registryName'] = opts.registryName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cr/0.2.0' + } + + 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 checkRegistryName 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 = this.makeRequest( + '/regions/{regionId}/registries:checkRegistryName', + '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) + } + ) + } + + /** + * 通过参数创建镜像仓库。 +仓库名称可以分解为多个路径名,每个名称必须至少包含一个小写字母数字,考虑URL规范。 +支持包含段划线或者下划线进行分割,但不允许点'.',多个路径名之间通过("/")连接,总长度不超过256个字符,当前只支持二级目录。 + + * @param {Object} opts - parameters + * @param {string} opts.registryName - 注册表名称 + * @param {string} opts.repositoryName - 镜像仓库名称。 +可以专有模式如默认命名空间nginx-web-app;或者和命名空间一起将多个仓库聚集在一起如 project-a/nginx-web-app。 + + * @param {string} [opts.description] - 注册表描述,<a href="https://www.jdcloud.com/help/detail/3870/isCatalog/1">参考公共参数规范</a>。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param repositoryShort repository + */ + + createRepository (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 createRepository" + ) + } + + opts = opts || {} + + if (opts.registryName === undefined || opts.registryName === null) { + throw new Error( + "Missing the required parameter 'opts.registryName' when calling createRepository" + ) + } + if (opts.repositoryName === undefined || opts.repositoryName === null) { + throw new Error( + "Missing the required parameter 'opts.repositoryName' when calling createRepository" + ) + } + + let postBody = {} + if (opts.repositoryName !== undefined && opts.repositoryName !== null) { + postBody['repositoryName'] = opts.repositoryName + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + registryName: opts.registryName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cr/0.2.0' + } + + 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 createRepository 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 = this.makeRequest( + '/regions/{regionId}/registries/{registryName}/repositories', + '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) + } + ) + } + + /** + * 描述用户指定 registry 下的 repository. + + * @param {Object} opts - parameters + * @param {array} [opts.filters] - name - 仓库名称,模糊匹配,支持单个 + optional + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 100] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param repository repositories + * @param number totalCount + */ + + describeRepositories (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 describeRepositories" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.filters !== undefined && opts.filters !== null) { + postBody['filters'] = opts.filters + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cr/0.2.0' + } + + 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 describeRepositories 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 = this.makeRequest( + '/regions/{regionId}/listRepositories', + '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.registryName - 注册表名称 + * @param {string} opts.repositoryName - 镜像仓库名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteRepository (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 deleteRepository" + ) + } + + opts = opts || {} + + if (opts.registryName === undefined || opts.registryName === null) { + throw new Error( + "Missing the required parameter 'opts.registryName' when calling deleteRepository" + ) + } + if (opts.repositoryName === undefined || opts.repositoryName === null) { + throw new Error( + "Missing the required parameter 'opts.repositoryName' when calling deleteRepository" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + registryName: opts.registryName, + repositoryName: opts.repositoryName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cr/0.2.0' + } + + 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 deleteRepository 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 = this.makeRequest( + '/regions/{regionId}/registries/{registryName}/repositories/{repositoryName}', + '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.registryName - 注册表名。 + * @param {string} opts.repositoryName - 待验证的镜像仓库名。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 表示用户指定的镜像仓库名是否通过校验, 0 通过 1 名称为空 2 不符合规范 3 重名 + * @param string reason code字段非零时,给出详细原因。 + */ + + checkRepositoryName (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 checkRepositoryName" + ) + } + + opts = opts || {} + + if (opts.registryName === undefined || opts.registryName === null) { + throw new Error( + "Missing the required parameter 'opts.registryName' when calling checkRepositoryName" + ) + } + if (opts.repositoryName === undefined || opts.repositoryName === null) { + throw new Error( + "Missing the required parameter 'opts.repositoryName' when calling checkRepositoryName" + ) + } + + let postBody = {} + if (opts.registryName !== undefined && opts.registryName !== null) { + postBody['registryName'] = opts.registryName + } + if (opts.repositoryName !== undefined && opts.repositoryName !== null) { + postBody['repositoryName'] = opts.repositoryName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 cr/0.2.0' + } + + 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 checkRepositoryName 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 = this.makeRequest( + '/regions/{regionId}/repositories:checkRepositoryName', + '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 = JDCloud.CR diff --git a/packages/libs/lib-jdcloud/src/repo/datastar/v1/datastar.js b/packages/libs/lib-jdcloud/src/repo/datastar/v1/datastar.js new file mode 100644 index 000000000..b0d814411 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/datastar/v1/datastar.js @@ -0,0 +1,202 @@ +/* + * 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. + * + * 大屏数据查询接口 + * 陕西苹果大屏数据查询接口 + * + * 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 = 'datastar' +Service._services[serviceId] = true + +/** + * datastar service. + * @version 1.0.6 + */ + +JDCloud.DATASTAR = class DATASTAR extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'datastar.cn-south-1.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 根据区域、行业、一级指标、二级指标、起始时间等条件查询数据 + * @param {Object} opts - parameters + * @param {string} opts.region - 查询区域,比如某某省或某某市(可选区域以最终授权为准) + * @param {string} opts.industry - 查询行业,比如某个水果或者农作物(可选行业以最终授权为准) + * @param {string} opts.startDate - 查询起始时间,格式如下:yyyy-MM-dd + * @param {string} opts.endDate - 查询结束时间,格式如下:yyyy-MM-dd + * @param {string} opts.firstIndex - 数据对应的第一级分析指标(可选一级指标以最终授权为准) + * @param {string} [opts.secondIndex] - 数据对应的第二级分析指标,如不填写,则默认把一级指标下的所有二级指标都查询出来(可选二级指标以最终授权为准) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status true为成功,false为失败 + * @param string message 描述信息 + * @param regionIndustryDataList data 查询数据结果 + */ + + getLargeScreenData (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 getLargeScreenData" + ) + } + + opts = opts || {} + + if (opts.region === undefined || opts.region === null) { + throw new Error( + "Missing the required parameter 'opts.region' when calling getLargeScreenData" + ) + } + if (opts.industry === undefined || opts.industry === null) { + throw new Error( + "Missing the required parameter 'opts.industry' when calling getLargeScreenData" + ) + } + if (opts.startDate === undefined || opts.startDate === null) { + throw new Error( + "Missing the required parameter 'opts.startDate' when calling getLargeScreenData" + ) + } + if (opts.endDate === undefined || opts.endDate === null) { + throw new Error( + "Missing the required parameter 'opts.endDate' when calling getLargeScreenData" + ) + } + if (opts.firstIndex === undefined || opts.firstIndex === null) { + throw new Error( + "Missing the required parameter 'opts.firstIndex' when calling getLargeScreenData" + ) + } + + let postBody = null + let queryParams = {} + if (opts.region !== undefined && opts.region !== null) { + queryParams['region'] = opts.region + } + if (opts.industry !== undefined && opts.industry !== null) { + queryParams['industry'] = opts.industry + } + if (opts.startDate !== undefined && opts.startDate !== null) { + queryParams['startDate'] = opts.startDate + } + if (opts.endDate !== undefined && opts.endDate !== null) { + queryParams['endDate'] = opts.endDate + } + if (opts.firstIndex !== undefined && opts.firstIndex !== null) { + queryParams['firstIndex'] = opts.firstIndex + } + if (opts.secondIndex !== undefined && opts.secondIndex !== null) { + queryParams['secondIndex'] = opts.secondIndex + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 datastar/1.0.6' + } + + 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 getLargeScreenData 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 = this.makeRequest( + '/regions/{regionId}/largeScreen/getData', + '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 = JDCloud.DATASTAR diff --git a/packages/libs/lib-jdcloud/src/repo/dbaudit/v1/dbaudit.js b/packages/libs/lib-jdcloud/src/repo/dbaudit/v1/dbaudit.js new file mode 100644 index 000000000..9d2a0cd3d --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/dbaudit/v1/dbaudit.js @@ -0,0 +1,5738 @@ +/* + * 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. + * + * Rule Interface + * Rule Interface + * + * 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 = 'dbaudit' +Service._services[serviceId] = true + +/** + * dbaudit service. + * @version 1.0.2 + */ + +class DBAUDIT extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'dbaudit.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 获取数据库审计agent主机列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[10, 100] optional + * @param {filter} [opts.filters] - hostId: 云主机ID,精确匹配,支持多个 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount + * @param agentInfo list + */ + + describeAgentList (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 describeAgentList" + ) + } + + 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 dbaudit/1.0.2' + } + + 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 describeAgentList 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}/agents', + '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) + } + ) + } + + /** + * 安装数据库审计agent + * @param {Object} opts - parameters + * @param {agentSpec} opts.agentSpec - 数据库审计agent配置信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string message 安装信息 + */ + + installAgent (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 installAgent" + ) + } + + opts = opts || {} + + if (opts.agentSpec === undefined || opts.agentSpec === null) { + throw new Error( + "Missing the required parameter 'opts.agentSpec' when calling installAgent" + ) + } + + let postBody = {} + if (opts.agentSpec !== undefined && opts.agentSpec !== null) { + postBody['agentSpec'] = opts.agentSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 installAgent 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}/agents', + '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 {auditConfig} opts.auditConfig - 数据库审计信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + setAuditConfig (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 setAuditConfig" + ) + } + + opts = opts || {} + + if (opts.auditConfig === undefined || opts.auditConfig === null) { + throw new Error( + "Missing the required parameter 'opts.auditConfig' when calling setAuditConfig" + ) + } + + let postBody = {} + if (opts.auditConfig !== undefined && opts.auditConfig !== null) { + postBody['auditConfig'] = opts.auditConfig + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 setAuditConfig 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}/agents', + 'PATCH', + 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) + } + ) + } + + /** + * 获取数据库审计agent审计的数据库列表 + * @param {Object} opts - parameters + * @param {string} opts.agentId - agentId + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[10, 100] optional + * @param {string} [opts.nameFilter] - 检索的数据库名称 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param auditInfo auditInfo + */ + + describeAgentDatabases (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 describeAgentDatabases" + ) + } + + opts = opts || {} + + if (opts.agentId === undefined || opts.agentId === null) { + throw new Error( + "Missing the required parameter 'opts.agentId' when calling describeAgentDatabases" + ) + } + + 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.nameFilter !== undefined && opts.nameFilter !== null) { + queryParams['nameFilter'] = opts.nameFilter + } + + let pathParams = { + regionId: regionId, + agentId: opts.agentId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 describeAgentDatabases 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}/agents/{agentId}', + '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) + } + ) + } + + /** + * 修改agent资源限额,支持多个agentId,英文逗号分隔 + * @param {Object} opts - parameters + * @param {string} opts.agentId - agentId + * @param {integer} [opts.limitStatus] - 是否限制 0 不限制 1 限制(cpuLimit/memLimit必填) optional + * @param {integer} [opts.cpuLimit] - cpu使用限制(1%-50%) optional + * @param {integer} [opts.memLimit] - 内存占用限额(1%-50%) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modyfyAgentLimits (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 modyfyAgentLimits" + ) + } + + opts = opts || {} + + if (opts.agentId === undefined || opts.agentId === null) { + throw new Error( + "Missing the required parameter 'opts.agentId' when calling modyfyAgentLimits" + ) + } + + let postBody = {} + if (opts.limitStatus !== undefined && opts.limitStatus !== null) { + postBody['limitStatus'] = opts.limitStatus + } + if (opts.cpuLimit !== undefined && opts.cpuLimit !== null) { + postBody['cpuLimit'] = opts.cpuLimit + } + if (opts.memLimit !== undefined && opts.memLimit !== null) { + postBody['memLimit'] = opts.memLimit + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + agentId: opts.agentId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 modyfyAgentLimits 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}/agents/{agentId}', + 'PATCH', + 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) + } + ) + } + + /** + * 卸载agent,支持批量,多个ID用英文逗号分隔 + * @param {Object} opts - parameters + * @param {string} opts.agentId - agentId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + uninstallAgent (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 uninstallAgent" + ) + } + + opts = opts || {} + + if (opts.agentId === undefined || opts.agentId === null) { + throw new Error( + "Missing the required parameter 'opts.agentId' when calling uninstallAgent" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + agentId: opts.agentId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 uninstallAgent 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}/agents/{agentId}', + '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.databaseId - 数据库ID + * @param {string} opts.agentId - agentId + * @param {array} [opts.netCards] - 网卡信息 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modyfyAuditNetCards (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 modyfyAuditNetCards" + ) + } + + opts = opts || {} + + if (opts.databaseId === undefined || opts.databaseId === null) { + throw new Error( + "Missing the required parameter 'opts.databaseId' when calling modyfyAuditNetCards" + ) + } + if (opts.agentId === undefined || opts.agentId === null) { + throw new Error( + "Missing the required parameter 'opts.agentId' when calling modyfyAuditNetCards" + ) + } + + let postBody = {} + if (opts.netCards !== undefined && opts.netCards !== null) { + postBody['netCards'] = opts.netCards + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + databaseId: opts.databaseId, + agentId: opts.agentId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 modyfyAuditNetCards 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}/agents/{agentId}/database/{databaseId}', + 'PATCH', + 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) + } + ) + } + + /** + * 取消对该数据库的审计,支持批量,多个ID用英文逗号分隔 + * @param {Object} opts - parameters + * @param {string} opts.databaseId - 数据库ID + * @param {string} opts.agentId - agentId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteAuditFromAgent (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 deleteAuditFromAgent" + ) + } + + opts = opts || {} + + if (opts.databaseId === undefined || opts.databaseId === null) { + throw new Error( + "Missing the required parameter 'opts.databaseId' when calling deleteAuditFromAgent" + ) + } + if (opts.agentId === undefined || opts.agentId === null) { + throw new Error( + "Missing the required parameter 'opts.agentId' when calling deleteAuditFromAgent" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + databaseId: opts.databaseId, + agentId: opts.agentId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 deleteAuditFromAgent 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}/agents/{agentId}/database/{databaseId}', + '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.insId - 审计实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string insDomain Agent域名 + * @param integer totalCount 总数量 + * @param database list + */ + + describeDatabases (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 describeDatabases" + ) + } + + opts = opts || {} + + if (opts.insId === undefined || opts.insId === null) { + throw new Error( + "Missing the required parameter 'opts.insId' when calling describeDatabases" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + insId: opts.insId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 describeDatabases 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}/instances/{insId}/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) + } + ) + } + + /** + * 新建数据库配置 + * @param {Object} opts - parameters + * @param {string} opts.insId - 审计实例ID + * @param {databaseSpec} opts.databaseSpec - 数据库配置 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + addDatabase (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 addDatabase" + ) + } + + opts = opts || {} + + if (opts.insId === undefined || opts.insId === null) { + throw new Error( + "Missing the required parameter 'opts.insId' when calling addDatabase" + ) + } + if (opts.databaseSpec === undefined || opts.databaseSpec === null) { + throw new Error( + "Missing the required parameter 'opts.databaseSpec' when calling addDatabase" + ) + } + + let postBody = {} + if (opts.databaseSpec !== undefined && opts.databaseSpec !== null) { + postBody['databaseSpec'] = opts.databaseSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + insId: opts.insId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 addDatabase 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}/instances/{insId}/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) + } + ) + } + + /** + * 启用数据库的双向审计 + * @param {Object} opts - parameters + * @param {string} opts.insId - 审计实例ID + * @param {string} opts.dbId - 数据库ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + enableAuditResponse (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 enableAuditResponse" + ) + } + + opts = opts || {} + + if (opts.insId === undefined || opts.insId === null) { + throw new Error( + "Missing the required parameter 'opts.insId' when calling enableAuditResponse" + ) + } + if (opts.dbId === undefined || opts.dbId === null) { + throw new Error( + "Missing the required parameter 'opts.dbId' when calling enableAuditResponse" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + insId: opts.insId, + dbId: opts.dbId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 enableAuditResponse 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}/instances/{insId}/databases/{dbId}/auditResponse:enable', + 'PATCH', + 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.insId - 审计实例ID + * @param {string} opts.dbId - 数据库ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + disableAuditResponse (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 disableAuditResponse" + ) + } + + opts = opts || {} + + if (opts.insId === undefined || opts.insId === null) { + throw new Error( + "Missing the required parameter 'opts.insId' when calling disableAuditResponse" + ) + } + if (opts.dbId === undefined || opts.dbId === null) { + throw new Error( + "Missing the required parameter 'opts.dbId' when calling disableAuditResponse" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + insId: opts.insId, + dbId: opts.dbId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 disableAuditResponse 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}/instances/{insId}/databases/{dbId}/auditResponse:disable', + 'PATCH', + 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.insId - 审计实例ID + * @param {string} opts.dbId - 数据库ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param databaseDetail databaseDetail + */ + + describeDatabase (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 describeDatabase" + ) + } + + opts = opts || {} + + if (opts.insId === undefined || opts.insId === null) { + throw new Error( + "Missing the required parameter 'opts.insId' when calling describeDatabase" + ) + } + if (opts.dbId === undefined || opts.dbId === null) { + throw new Error( + "Missing the required parameter 'opts.dbId' when calling describeDatabase" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + insId: opts.insId, + dbId: opts.dbId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 describeDatabase 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}/instances/{insId}/databases/{dbId}', + '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.insId - 审计实例ID + * @param {string} opts.dbId - 数据库ID + * @param {databaseSpec} opts.databaseSpec + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateDatabase (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 updateDatabase" + ) + } + + opts = opts || {} + + if (opts.insId === undefined || opts.insId === null) { + throw new Error( + "Missing the required parameter 'opts.insId' when calling updateDatabase" + ) + } + if (opts.dbId === undefined || opts.dbId === null) { + throw new Error( + "Missing the required parameter 'opts.dbId' when calling updateDatabase" + ) + } + if (opts.databaseSpec === undefined || opts.databaseSpec === null) { + throw new Error( + "Missing the required parameter 'opts.databaseSpec' when calling updateDatabase" + ) + } + + let postBody = {} + if (opts.databaseSpec !== undefined && opts.databaseSpec !== null) { + postBody['databaseSpec'] = opts.databaseSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + insId: opts.insId, + dbId: opts.dbId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 updateDatabase 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}/instances/{insId}/databases/{dbId}', + '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.insId - 审计实例ID + * @param {string} opts.dbId - 数据库ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteDatabase (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 deleteDatabase" + ) + } + + opts = opts || {} + + if (opts.insId === undefined || opts.insId === null) { + throw new Error( + "Missing the required parameter 'opts.insId' when calling deleteDatabase" + ) + } + if (opts.dbId === undefined || opts.dbId === null) { + throw new Error( + "Missing the required parameter 'opts.dbId' when calling deleteDatabase" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + insId: opts.insId, + dbId: opts.dbId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 deleteDatabase 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}/instances/{insId}/databases/{dbId}', + '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) + } + ) + } + + /** + * 获取数据库审计实例列表 +pageNumber: 页码 +pageSize: 每页数量 +nameFilter: 按名称查询 +filters: 按instanceId 查询,只支持eq,单个instanceId匹配 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[10, 100] optional + * @param {string} [opts.nameFilter] - 列表过滤条件:数据库审计名称 optional + * @param {filter} [opts.filters] - 按instanceId 过滤 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount + * @param instanceAbstract list + */ + + describeInstanceList (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 describeInstanceList" + ) + } + + 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.nameFilter !== undefined && opts.nameFilter !== null) { + queryParams['nameFilter'] = opts.nameFilter + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 describeInstanceList 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}/instances', + '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.insId - 审计实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instanceAbstract instanceAbstract + */ + + 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 || {} + + if (opts.insId === undefined || opts.insId === null) { + throw new Error( + "Missing the required parameter 'opts.insId' when calling describeInstance" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + insId: opts.insId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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}/instances/{insId}', + '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.insId - 审计实例ID + * @param {string} [opts.insName] - 实例名称 optional + * @param {string} [opts.insDesc] - 实例描述 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + 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.insId === undefined || opts.insId === null) { + throw new Error( + "Missing the required parameter 'opts.insId' when calling modifyInstance" + ) + } + + let postBody = {} + if (opts.insName !== undefined && opts.insName !== null) { + postBody['insName'] = opts.insName + } + if (opts.insDesc !== undefined && opts.insDesc !== null) { + postBody['insDesc'] = opts.insDesc + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + insId: opts.insId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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}/instances/{insId}: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) + } + ) + } + + /** + * 获取此实例的所有IP白名单列表 + * @param {Object} opts - parameters + * @param {string} opts.insId - 审计实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string ipWhileList + * @param integer totalCount IP白名单记录的数量 + */ + + describeIpWhiteList (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 describeIpWhiteList" + ) + } + + opts = opts || {} + + if (opts.insId === undefined || opts.insId === null) { + throw new Error( + "Missing the required parameter 'opts.insId' when calling describeIpWhiteList" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + insId: opts.insId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 describeIpWhiteList 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}/instances/{insId}/ipwhitelist', + '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白名单记录 + * @param {Object} opts - parameters + * @param {string} opts.insId - 审计实例ID + * @param {string} opts.cidr - IP白名单记录,支持掩码 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + addIpWhiteItem (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 addIpWhiteItem" + ) + } + + opts = opts || {} + + if (opts.insId === undefined || opts.insId === null) { + throw new Error( + "Missing the required parameter 'opts.insId' when calling addIpWhiteItem" + ) + } + if (opts.cidr === undefined || opts.cidr === null) { + throw new Error( + "Missing the required parameter 'opts.cidr' when calling addIpWhiteItem" + ) + } + + let postBody = {} + if (opts.cidr !== undefined && opts.cidr !== null) { + postBody['cidr'] = opts.cidr + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + insId: opts.insId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 addIpWhiteItem 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}/instances/{insId}/ipwhitelist', + '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) + } + ) + } + + /** + * 删除一条IP白名单记录 + * @param {Object} opts - parameters + * @param {string} opts.insId - 审计实例ID + * @param {string} opts.cidr - IP白名单记录,支持掩码 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteIpWhiteItem (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 deleteIpWhiteItem" + ) + } + + opts = opts || {} + + if (opts.insId === undefined || opts.insId === null) { + throw new Error( + "Missing the required parameter 'opts.insId' when calling deleteIpWhiteItem" + ) + } + if (opts.cidr === undefined || opts.cidr === null) { + throw new Error( + "Missing the required parameter 'opts.cidr' when calling deleteIpWhiteItem" + ) + } + + let postBody = null + let queryParams = {} + if (opts.cidr !== undefined && opts.cidr !== null) { + queryParams['cidr'] = opts.cidr + } + + let pathParams = { + regionId: regionId, + insId: opts.insId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 deleteIpWhiteItem 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}/instances/{insId}/ipwhitelist', + '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) + } + ) + } + + /** + * 获取审计日志列表 +时间范围[0-180天] + + * @param {Object} opts - parameters + * @param {string} opts.insId - 审计实例ID + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[10, 100] optional + * @param {string} [opts.startTime] - 按照时间范围过滤,开始时间 optional + * @param {string} [opts.endTime] - 按照时间范围过滤,结束时间 optional + * @param {string} [opts.dbId] - 按照数据库Id过滤 optional + * @param {string} [opts.riskLevel] - 按照风险级别过滤: 0->无风险,1->低风险,2->中风险,3->高风险,4->致命风险,空字符串查询所有 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount 总数 + * @param auditLogAbstract list + */ + + describeAuditLogList (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 describeAuditLogList" + ) + } + + opts = opts || {} + + if (opts.insId === undefined || opts.insId === null) { + throw new Error( + "Missing the required parameter 'opts.insId' when calling describeAuditLogList" + ) + } + + 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.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.dbId !== undefined && opts.dbId !== null) { + queryParams['dbId'] = opts.dbId + } + if (opts.riskLevel !== undefined && opts.riskLevel !== null) { + queryParams['riskLevel'] = opts.riskLevel + } + + let pathParams = { + regionId: regionId, + insId: opts.insId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 describeAuditLogList 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}/instances/{insId}/logs', + '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.insId - 审计实例ID + * @param {string} opts.logId - 审计日志ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param auditLogDetail auditLogDetail + */ + + describeAuditLog (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 describeAuditLog" + ) + } + + opts = opts || {} + + if (opts.insId === undefined || opts.insId === null) { + throw new Error( + "Missing the required parameter 'opts.insId' when calling describeAuditLog" + ) + } + if (opts.logId === undefined || opts.logId === null) { + throw new Error( + "Missing the required parameter 'opts.logId' when calling describeAuditLog" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + insId: opts.insId, + logId: opts.logId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 describeAuditLog 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}/instances/{insId}/logs/{logId}', + '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.insId - 审计实例ID + * @param {string} opts.dbId - 数据库ID + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[10, 100] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount 总数 + * @param maskRuleDetail list + */ + + describeMaskRuleList (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 describeMaskRuleList" + ) + } + + opts = opts || {} + + if (opts.insId === undefined || opts.insId === null) { + throw new Error( + "Missing the required parameter 'opts.insId' when calling describeMaskRuleList" + ) + } + if (opts.dbId === undefined || opts.dbId === null) { + throw new Error( + "Missing the required parameter 'opts.dbId' when calling describeMaskRuleList" + ) + } + + 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, + insId: opts.insId, + dbId: opts.dbId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 describeMaskRuleList 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}/instances/{insId}/databases/{dbId}/maskRules', + '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.insId - 审计实例ID + * @param {string} opts.dbId - 数据库ID + * @param {maskRuleSpec} opts.maskRuleSpec - 敏感信息遮蔽规则 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + addMaskRule (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 addMaskRule" + ) + } + + opts = opts || {} + + if (opts.insId === undefined || opts.insId === null) { + throw new Error( + "Missing the required parameter 'opts.insId' when calling addMaskRule" + ) + } + if (opts.dbId === undefined || opts.dbId === null) { + throw new Error( + "Missing the required parameter 'opts.dbId' when calling addMaskRule" + ) + } + if (opts.maskRuleSpec === undefined || opts.maskRuleSpec === null) { + throw new Error( + "Missing the required parameter 'opts.maskRuleSpec' when calling addMaskRule" + ) + } + + let postBody = {} + if (opts.maskRuleSpec !== undefined && opts.maskRuleSpec !== null) { + postBody['maskRuleSpec'] = opts.maskRuleSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + insId: opts.insId, + dbId: opts.dbId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 addMaskRule 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}/instances/{insId}/databases/{dbId}/maskRules', + '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.insId - 审计实例ID + * @param {string} opts.maskRuleId - 敏感信息遮蔽规则ID + * @param {string} opts.dbId - 数据库ID + * @param {maskRuleSpec} opts.maskRuleSpec - 敏感信息遮蔽规则 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyMask (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 modifyMask" + ) + } + + opts = opts || {} + + if (opts.insId === undefined || opts.insId === null) { + throw new Error( + "Missing the required parameter 'opts.insId' when calling modifyMask" + ) + } + if (opts.maskRuleId === undefined || opts.maskRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.maskRuleId' when calling modifyMask" + ) + } + if (opts.dbId === undefined || opts.dbId === null) { + throw new Error( + "Missing the required parameter 'opts.dbId' when calling modifyMask" + ) + } + if (opts.maskRuleSpec === undefined || opts.maskRuleSpec === null) { + throw new Error( + "Missing the required parameter 'opts.maskRuleSpec' when calling modifyMask" + ) + } + + let postBody = {} + if (opts.maskRuleSpec !== undefined && opts.maskRuleSpec !== null) { + postBody['maskRuleSpec'] = opts.maskRuleSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + insId: opts.insId, + maskRuleId: opts.maskRuleId, + dbId: opts.dbId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 modifyMask 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}/instances/{insId}/databases/{dbId}/maskRules/{maskRuleId}', + '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.insId - 审计实例ID + * @param {string} opts.maskRuleId - 敏感信息遮蔽规则ID + * @param {string} opts.dbId - 数据库ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteMask (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 deleteMask" + ) + } + + opts = opts || {} + + if (opts.insId === undefined || opts.insId === null) { + throw new Error( + "Missing the required parameter 'opts.insId' when calling deleteMask" + ) + } + if (opts.maskRuleId === undefined || opts.maskRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.maskRuleId' when calling deleteMask" + ) + } + if (opts.dbId === undefined || opts.dbId === null) { + throw new Error( + "Missing the required parameter 'opts.dbId' when calling deleteMask" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + insId: opts.insId, + maskRuleId: opts.maskRuleId, + dbId: opts.dbId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 deleteMask 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}/instances/{insId}/databases/{dbId}/maskRules/{maskRuleId}', + '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) + } + ) + } + + /** + * 获取任务列表 +一次性任务报表时间范围[0-30天] + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[10, 100] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount + * @param taskInfo list + */ + + describeTaskList (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 describeTaskList" + ) + } + + 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 + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 describeTaskList 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}/tasks', + '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 {taskSpec} opts.taskSpec - 报表配置信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string taskId 创建的任务ID + */ + + createTask (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 createTask" + ) + } + + opts = opts || {} + + if (opts.taskSpec === undefined || opts.taskSpec === null) { + throw new Error( + "Missing the required parameter 'opts.taskSpec' when calling createTask" + ) + } + + let postBody = {} + if (opts.taskSpec !== undefined && opts.taskSpec !== null) { + postBody['taskSpec'] = opts.taskSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 createTask 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}/tasks', + '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.taskId - 任务ID + * @param {taskOpts} opts.taskOpts - 报表配置信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + startTask (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 startTask" + ) + } + + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling startTask" + ) + } + if (opts.taskOpts === undefined || opts.taskOpts === null) { + throw new Error( + "Missing the required parameter 'opts.taskOpts' when calling startTask" + ) + } + + let postBody = {} + if (opts.taskOpts !== undefined && opts.taskOpts !== null) { + postBody['taskOpts'] = opts.taskOpts + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 startTask 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}/tasks/{taskId}:start', + '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.taskId - 任务ID + * @param {taskOpts} opts.taskOpts - 报表配置信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + stopTask (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 stopTask" + ) + } + + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling stopTask" + ) + } + if (opts.taskOpts === undefined || opts.taskOpts === null) { + throw new Error( + "Missing the required parameter 'opts.taskOpts' when calling stopTask" + ) + } + + let postBody = {} + if (opts.taskOpts !== undefined && opts.taskOpts !== null) { + postBody['taskOpts'] = opts.taskOpts + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 stopTask 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}/tasks/{taskId}:stop', + '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.taskId - 任务ID + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[10, 100] optional + * @param {string} opts.instanceId - 实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount + * @param reportInfo list + */ + + describeReportList (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 describeReportList" + ) + } + + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling describeReportList" + ) + } + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeReportList" + ) + } + + 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.instanceId !== undefined && opts.instanceId !== null) { + queryParams['instanceId'] = opts.instanceId + } + + let pathParams = { + regionId: regionId, + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 describeReportList 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}/tasks/{taskId}', + '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.taskId - 任务ID + * @param {taskSpec} opts.taskSpec - 报表更新信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyTask (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 modifyTask" + ) + } + + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling modifyTask" + ) + } + if (opts.taskSpec === undefined || opts.taskSpec === null) { + throw new Error( + "Missing the required parameter 'opts.taskSpec' when calling modifyTask" + ) + } + + let postBody = {} + if (opts.taskSpec !== undefined && opts.taskSpec !== null) { + postBody['taskSpec'] = opts.taskSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 modifyTask 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}/tasks/{taskId}', + '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.taskId - 任务ID + * @param {string} opts.instanceId - 实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteTask (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 deleteTask" + ) + } + + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling deleteTask" + ) + } + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteTask" + ) + } + + let postBody = null + let queryParams = {} + if (opts.instanceId !== undefined && opts.instanceId !== null) { + queryParams['instanceId'] = opts.instanceId + } + + let pathParams = { + regionId: regionId, + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 deleteTask 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}/tasks/{taskId}', + '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.reportId - 报表ID + * @param {string} opts.taskId - 任务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + downloadReport (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 downloadReport" + ) + } + + opts = opts || {} + + if (opts.reportId === undefined || opts.reportId === null) { + throw new Error( + "Missing the required parameter 'opts.reportId' when calling downloadReport" + ) + } + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling downloadReport" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + reportId: opts.reportId, + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 downloadReport 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}/tasks/{taskId}/report/{reportId}', + '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.reportId - 报表ID + * @param {string} opts.taskId - 任务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteReport (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 deleteReport" + ) + } + + opts = opts || {} + + if (opts.reportId === undefined || opts.reportId === null) { + throw new Error( + "Missing the required parameter 'opts.reportId' when calling deleteReport" + ) + } + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling deleteReport" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + reportId: opts.reportId, + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 deleteReport 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}/tasks/{taskId}/report/{reportId}', + '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.insId - 审计实例ID + * @param {string} [opts.dbId] - 数据库ID optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount + * @param ruleGroup list + */ + + describeRuleGroups (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 describeRuleGroups" + ) + } + + opts = opts || {} + + if (opts.insId === undefined || opts.insId === null) { + throw new Error( + "Missing the required parameter 'opts.insId' when calling describeRuleGroups" + ) + } + + let postBody = null + let queryParams = {} + if (opts.dbId !== undefined && opts.dbId !== null) { + queryParams['dbId'] = opts.dbId + } + + let pathParams = { + regionId: regionId, + insId: opts.insId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 describeRuleGroups 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}/instances/{insId}/ruleGroups', + '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.insId - 审计实例ID + * @param {ruleGroup} opts.ruleGroup - 规则组详情 + * @param {string} [opts.dbId] - 数据库ID optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param ruleGroup ruleGroup + */ + + addRuleGroup (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 addRuleGroup" + ) + } + + opts = opts || {} + + if (opts.insId === undefined || opts.insId === null) { + throw new Error( + "Missing the required parameter 'opts.insId' when calling addRuleGroup" + ) + } + if (opts.ruleGroup === undefined || opts.ruleGroup === null) { + throw new Error( + "Missing the required parameter 'opts.ruleGroup' when calling addRuleGroup" + ) + } + + let postBody = {} + if (opts.ruleGroup !== undefined && opts.ruleGroup !== null) { + postBody['ruleGroup'] = opts.ruleGroup + } + if (opts.dbId !== undefined && opts.dbId !== null) { + postBody['dbId'] = opts.dbId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + insId: opts.insId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 addRuleGroup 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}/instances/{insId}/ruleGroups', + '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.insId - 审计实例ID + * @param {string} opts.ruleGroupId - 规则组ID + * @param {string} [opts.dbId] - 数据库ID optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount + * @param rule list + */ + + describeRuleGroupRules (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 describeRuleGroupRules" + ) + } + + opts = opts || {} + + if (opts.insId === undefined || opts.insId === null) { + throw new Error( + "Missing the required parameter 'opts.insId' when calling describeRuleGroupRules" + ) + } + if (opts.ruleGroupId === undefined || opts.ruleGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.ruleGroupId' when calling describeRuleGroupRules" + ) + } + + let postBody = null + let queryParams = {} + if (opts.dbId !== undefined && opts.dbId !== null) { + queryParams['dbId'] = opts.dbId + } + + let pathParams = { + regionId: regionId, + insId: opts.insId, + ruleGroupId: opts.ruleGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 describeRuleGroupRules 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}/instances/{insId}/ruleGroups/{ruleGroupId}', + '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.insId - 审计实例ID + * @param {string} opts.ruleGroupId - 规则组ID + * @param {string} [opts.dbId] - 数据库ID optional + * @param {rule} opts.rule - 规则详情 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + addRule (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 addRule" + ) + } + + opts = opts || {} + + if (opts.insId === undefined || opts.insId === null) { + throw new Error( + "Missing the required parameter 'opts.insId' when calling addRule" + ) + } + if (opts.ruleGroupId === undefined || opts.ruleGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.ruleGroupId' when calling addRule" + ) + } + if (opts.rule === undefined || opts.rule === null) { + throw new Error( + "Missing the required parameter 'opts.rule' when calling addRule" + ) + } + + let postBody = {} + if (opts.dbId !== undefined && opts.dbId !== null) { + postBody['dbId'] = opts.dbId + } + if (opts.rule !== undefined && opts.rule !== null) { + postBody['rule'] = opts.rule + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + insId: opts.insId, + ruleGroupId: opts.ruleGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 addRule 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}/instances/{insId}/ruleGroups/{ruleGroupId}', + '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.insId - 审计实例ID + * @param {string} opts.ruleGroupId - 规则组ID + * @param {string} [opts.dbId] - 数据库ID optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteRuleGroup (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 deleteRuleGroup" + ) + } + + opts = opts || {} + + if (opts.insId === undefined || opts.insId === null) { + throw new Error( + "Missing the required parameter 'opts.insId' when calling deleteRuleGroup" + ) + } + if (opts.ruleGroupId === undefined || opts.ruleGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.ruleGroupId' when calling deleteRuleGroup" + ) + } + + let postBody = null + let queryParams = {} + if (opts.dbId !== undefined && opts.dbId !== null) { + queryParams['dbId'] = opts.dbId + } + + let pathParams = { + regionId: regionId, + insId: opts.insId, + ruleGroupId: opts.ruleGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 deleteRuleGroup 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}/instances/{insId}/ruleGroups/{ruleGroupId}', + '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.insId - 审计实例ID + * @param {string} opts.ruleGroupId - 规则组ID + * @param {string} opts.ruleId - 规则ID + * @param {string} [opts.dbId] - 数据库ID optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param rule rule + */ + + describeRule (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 describeRule" + ) + } + + opts = opts || {} + + if (opts.insId === undefined || opts.insId === null) { + throw new Error( + "Missing the required parameter 'opts.insId' when calling describeRule" + ) + } + if (opts.ruleGroupId === undefined || opts.ruleGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.ruleGroupId' when calling describeRule" + ) + } + if (opts.ruleId === undefined || opts.ruleId === null) { + throw new Error( + "Missing the required parameter 'opts.ruleId' when calling describeRule" + ) + } + + let postBody = null + let queryParams = {} + if (opts.dbId !== undefined && opts.dbId !== null) { + queryParams['dbId'] = opts.dbId + } + + let pathParams = { + regionId: regionId, + insId: opts.insId, + ruleGroupId: opts.ruleGroupId, + ruleId: opts.ruleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 describeRule 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}/instances/{insId}/ruleGroups/{ruleGroupId}/rule/{ruleId}', + '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.insId - 审计实例ID + * @param {string} opts.ruleGroupId - 规则组ID + * @param {string} opts.ruleId - 规则ID + * @param {rule} opts.rule - 规则详情 + * @param {string} [opts.dbId] - 数据库ID optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyRule (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 modifyRule" + ) + } + + opts = opts || {} + + if (opts.insId === undefined || opts.insId === null) { + throw new Error( + "Missing the required parameter 'opts.insId' when calling modifyRule" + ) + } + if (opts.ruleGroupId === undefined || opts.ruleGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.ruleGroupId' when calling modifyRule" + ) + } + if (opts.ruleId === undefined || opts.ruleId === null) { + throw new Error( + "Missing the required parameter 'opts.ruleId' when calling modifyRule" + ) + } + if (opts.rule === undefined || opts.rule === null) { + throw new Error( + "Missing the required parameter 'opts.rule' when calling modifyRule" + ) + } + + let postBody = {} + if (opts.rule !== undefined && opts.rule !== null) { + postBody['rule'] = opts.rule + } + if (opts.dbId !== undefined && opts.dbId !== null) { + postBody['dbId'] = opts.dbId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + insId: opts.insId, + ruleGroupId: opts.ruleGroupId, + ruleId: opts.ruleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 modifyRule 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}/instances/{insId}/ruleGroups/{ruleGroupId}/rule/{ruleId}', + '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.insId - 审计实例ID + * @param {string} opts.ruleGroupId - 规则组ID + * @param {string} opts.ruleId - 规则ID + * @param {string} [opts.dbId] - 数据库ID optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteRule (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 deleteRule" + ) + } + + opts = opts || {} + + if (opts.insId === undefined || opts.insId === null) { + throw new Error( + "Missing the required parameter 'opts.insId' when calling deleteRule" + ) + } + if (opts.ruleGroupId === undefined || opts.ruleGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.ruleGroupId' when calling deleteRule" + ) + } + if (opts.ruleId === undefined || opts.ruleId === null) { + throw new Error( + "Missing the required parameter 'opts.ruleId' when calling deleteRule" + ) + } + + let postBody = null + let queryParams = {} + if (opts.dbId !== undefined && opts.dbId !== null) { + queryParams['dbId'] = opts.dbId + } + + let pathParams = { + regionId: regionId, + insId: opts.insId, + ruleGroupId: opts.ruleGroupId, + ruleId: opts.ruleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 deleteRule 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}/instances/{insId}/ruleGroups/{ruleGroupId}/rule/{ruleId}', + '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.insId - 审计实例ID + * @param {string} opts.ruleGroupId - 规则组ID + * @param {string} [opts.dbId] - 数据库ID optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + enableRuleGroup (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 enableRuleGroup" + ) + } + + opts = opts || {} + + if (opts.insId === undefined || opts.insId === null) { + throw new Error( + "Missing the required parameter 'opts.insId' when calling enableRuleGroup" + ) + } + if (opts.ruleGroupId === undefined || opts.ruleGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.ruleGroupId' when calling enableRuleGroup" + ) + } + + let postBody = {} + if (opts.dbId !== undefined && opts.dbId !== null) { + postBody['dbId'] = opts.dbId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + insId: opts.insId, + ruleGroupId: opts.ruleGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 enableRuleGroup 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}/instances/{insId}/ruleGroups/{ruleGroupId}:enable', + '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.insId - 审计实例ID + * @param {string} opts.ruleGroupId - 规则组ID + * @param {string} [opts.dbId] - 数据库ID optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + disableRuleGroup (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 disableRuleGroup" + ) + } + + opts = opts || {} + + if (opts.insId === undefined || opts.insId === null) { + throw new Error( + "Missing the required parameter 'opts.insId' when calling disableRuleGroup" + ) + } + if (opts.ruleGroupId === undefined || opts.ruleGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.ruleGroupId' when calling disableRuleGroup" + ) + } + + let postBody = {} + if (opts.dbId !== undefined && opts.dbId !== null) { + postBody['dbId'] = opts.dbId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + insId: opts.insId, + ruleGroupId: opts.ruleGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 disableRuleGroup 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}/instances/{insId}/ruleGroups/{ruleGroupId}:disable', + '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) + } + ) + } + + /** + * 下发规则组到指定dbIds + * @param {Object} opts - parameters + * @param {string} opts.insId - 审计实例ID + * @param {string} opts.ruleGroupId - 规则组ID + * @param {string} opts.dbIds - 数据库ID(多个用英文逗号分隔) + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deployRuleGroup (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 deployRuleGroup" + ) + } + + opts = opts || {} + + if (opts.insId === undefined || opts.insId === null) { + throw new Error( + "Missing the required parameter 'opts.insId' when calling deployRuleGroup" + ) + } + if (opts.ruleGroupId === undefined || opts.ruleGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.ruleGroupId' when calling deployRuleGroup" + ) + } + if (opts.dbIds === undefined || opts.dbIds === null) { + throw new Error( + "Missing the required parameter 'opts.dbIds' when calling deployRuleGroup" + ) + } + + let postBody = {} + if (opts.dbIds !== undefined && opts.dbIds !== null) { + postBody['dbIds'] = opts.dbIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + insId: opts.insId, + ruleGroupId: opts.ruleGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbaudit/1.0.2' + } + + 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 deployRuleGroup 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}/instances/{insId}/ruleGroups/{ruleGroupId}:deploy', + '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 = DBAUDIT diff --git a/packages/libs/lib-jdcloud/src/repo/dbs/v2/dbs.js b/packages/libs/lib-jdcloud/src/repo/dbs/v2/dbs.js new file mode 100644 index 000000000..babf7b9d0 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/dbs/v2/dbs.js @@ -0,0 +1,4328 @@ +/* + * 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. + * + * 数据库备份服务 + * 数据库备份服务接口 + * + * 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 = 'dbs' +Service._services[serviceId] = true + +/** + * dbs service. + * @version 2.0.0 + */ + +class DBS extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'dbs.jdcloud-api.com' + options.basePath = '/v2' // 默认要设为空"" + super(serviceId, options) + } + + /** + * Agent 注册接口 + * @param {Object} opts - parameters + * @param {string} [opts.ip] - agent的IP optional + * @param {string} opts.mac - agent的 MAC + * @param {string} [opts.hostname] - agent的hostname optional + * @param {string} opts.stat - agent的状态 + * @param {string} [opts.ver] - agent的版本号 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string createTime + * @param string hostname + * @param string id + * @param string ip agent取到的出口ip + * @param string lastActiveTime 上次心跳汇报时间 + * @param string name 用户自定义别名 + * @param string stat 状态:idle,offline,deleted,executing + * @param string updateTime + * @param string version 版本号 + */ + + agentRegister (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 agentRegister" + ) + } + + opts = opts || {} + + if (opts.mac === undefined || opts.mac === null) { + throw new Error( + "Missing the required parameter 'opts.mac' when calling agentRegister" + ) + } + if (opts.stat === undefined || opts.stat === null) { + throw new Error( + "Missing the required parameter 'opts.stat' when calling agentRegister" + ) + } + + let postBody = {} + if (opts.ip !== undefined && opts.ip !== null) { + postBody['ip'] = opts.ip + } + if (opts.mac !== undefined && opts.mac !== null) { + postBody['mac'] = opts.mac + } + if (opts.hostname !== undefined && opts.hostname !== null) { + postBody['hostname'] = opts.hostname + } + if (opts.stat !== undefined && opts.stat !== null) { + postBody['stat'] = opts.stat + } + if (opts.ver !== undefined && opts.ver !== null) { + postBody['ver'] = opts.ver + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 agentRegister 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}/agent', + '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) + } + ) + } + + /** + * 获取agent的任务 + * @param {Object} opts - parameters + * @param {string} opts.agentId - Agent ID + * @param {string} [opts.stat] - agent的状态 optional + * @param {string} opts.mac - agent的MAC地址 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param agentTasks tasks + */ + + agentTasks (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 agentTasks" + ) + } + + opts = opts || {} + + if (opts.agentId === undefined || opts.agentId === null) { + throw new Error( + "Missing the required parameter 'opts.agentId' when calling agentTasks" + ) + } + if (opts.mac === undefined || opts.mac === null) { + throw new Error( + "Missing the required parameter 'opts.mac' when calling agentTasks" + ) + } + + let postBody = null + let queryParams = {} + if (opts.stat !== undefined && opts.stat !== null) { + queryParams['stat'] = opts.stat + } + if (opts.mac !== undefined && opts.mac !== null) { + queryParams['mac'] = opts.mac + } + + let pathParams = { + regionId: regionId, + agentId: opts.agentId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 agentTasks 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}/manage/{agentId}/tasks', + '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) + } + ) + } + + /** + * 获取agent的备份计划 + * @param {Object} opts - parameters + * @param {string} opts.agentId - Agent ID + * @param {string} opts.mac - agent的MAC地址 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param agentPlan plans + */ + + agentPlans (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 agentPlans" + ) + } + + opts = opts || {} + + if (opts.agentId === undefined || opts.agentId === null) { + throw new Error( + "Missing the required parameter 'opts.agentId' when calling agentPlans" + ) + } + if (opts.mac === undefined || opts.mac === null) { + throw new Error( + "Missing the required parameter 'opts.mac' when calling agentPlans" + ) + } + + let postBody = null + let queryParams = {} + if (opts.mac !== undefined && opts.mac !== null) { + queryParams['mac'] = opts.mac + } + + let pathParams = { + regionId: regionId, + agentId: opts.agentId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 agentPlans 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}/manage/{agentId}/plans', + '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 {object} opts.agent + * @param {string} opts.taskType + * @param {string} [opts.planId] optional + * @param {integer} opts.progress + * @param {string} [opts.startTime] optional + * @param {string} [opts.endTime] optional + * @param {boolean} [opts.success] optional + * @param {string} [opts.errorMessage] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string id + */ + + reportTask (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 reportTask" + ) + } + + opts = opts || {} + + if (opts.agent === undefined || opts.agent === null) { + throw new Error( + "Missing the required parameter 'opts.agent' when calling reportTask" + ) + } + if (opts.taskType === undefined || opts.taskType === null) { + throw new Error( + "Missing the required parameter 'opts.taskType' when calling reportTask" + ) + } + if (opts.progress === undefined || opts.progress === null) { + throw new Error( + "Missing the required parameter 'opts.progress' when calling reportTask" + ) + } + + let postBody = {} + if (opts.agent !== undefined && opts.agent !== null) { + postBody['agent'] = opts.agent + } + if (opts.taskType !== undefined && opts.taskType !== null) { + postBody['taskType'] = opts.taskType + } + if (opts.planId !== undefined && opts.planId !== null) { + postBody['planId'] = opts.planId + } + if (opts.progress !== undefined && opts.progress !== null) { + postBody['progress'] = opts.progress + } + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.success !== undefined && opts.success !== null) { + postBody['success'] = opts.success + } + if (opts.errorMessage !== undefined && opts.errorMessage !== null) { + postBody['errorMessage'] = opts.errorMessage + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 reportTask 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}/task', + '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.taskId - Task ID + * @param {integer} opts.progress + * @param {string} [opts.startTime] optional + * @param {string} [opts.endTime] optional + * @param {boolean} opts.success + * @param {string} [opts.errorMessage] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean ok + */ + + modifyTask (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 modifyTask" + ) + } + + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling modifyTask" + ) + } + if (opts.progress === undefined || opts.progress === null) { + throw new Error( + "Missing the required parameter 'opts.progress' when calling modifyTask" + ) + } + if (opts.success === undefined || opts.success === null) { + throw new Error( + "Missing the required parameter 'opts.success' when calling modifyTask" + ) + } + + let postBody = {} + if (opts.progress !== undefined && opts.progress !== null) { + postBody['progress'] = opts.progress + } + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.success !== undefined && opts.success !== null) { + postBody['success'] = opts.success + } + if (opts.errorMessage !== undefined && opts.errorMessage !== null) { + postBody['errorMessage'] = opts.errorMessage + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 modifyTask 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}/task/{taskId}', + 'PATCH', + 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.planId + * @param {string} opts.backupType + * @param {string} opts.dataSourceId + * @param {integer} opts.isManual - 0代表自动备份 1代表的是手动触发备份 + * @param {string} opts.filename + * @param {string} opts.extInfo + * @param {string} opts.path + * @param {integer} opts.size + * @param {integer} [opts.srcSize] optional + * @param {string} opts.storageType + * @param {string} opts.taskId + * @param {string} [opts.binlogStartTime] optional + * @param {string} [opts.binlogEndTime] optional + * @param {integer} [opts.binlogStartPos] optional + * @param {integer} [opts.binlogEndPos] optional + * @param {string} [opts.version] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string id + */ + + backupFile (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 backupFile" + ) + } + + opts = opts || {} + + if (opts.planId === undefined || opts.planId === null) { + throw new Error( + "Missing the required parameter 'opts.planId' when calling backupFile" + ) + } + if (opts.backupType === undefined || opts.backupType === null) { + throw new Error( + "Missing the required parameter 'opts.backupType' when calling backupFile" + ) + } + if (opts.dataSourceId === undefined || opts.dataSourceId === null) { + throw new Error( + "Missing the required parameter 'opts.dataSourceId' when calling backupFile" + ) + } + if (opts.isManual === undefined || opts.isManual === null) { + throw new Error( + "Missing the required parameter 'opts.isManual' when calling backupFile" + ) + } + if (opts.filename === undefined || opts.filename === null) { + throw new Error( + "Missing the required parameter 'opts.filename' when calling backupFile" + ) + } + if (opts.extInfo === undefined || opts.extInfo === null) { + throw new Error( + "Missing the required parameter 'opts.extInfo' when calling backupFile" + ) + } + if (opts.path === undefined || opts.path === null) { + throw new Error( + "Missing the required parameter 'opts.path' when calling backupFile" + ) + } + if (opts.size === undefined || opts.size === null) { + throw new Error( + "Missing the required parameter 'opts.size' when calling backupFile" + ) + } + if (opts.storageType === undefined || opts.storageType === null) { + throw new Error( + "Missing the required parameter 'opts.storageType' when calling backupFile" + ) + } + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling backupFile" + ) + } + + let postBody = {} + if (opts.planId !== undefined && opts.planId !== null) { + postBody['planId'] = opts.planId + } + if (opts.backupType !== undefined && opts.backupType !== null) { + postBody['backupType'] = opts.backupType + } + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.isManual !== undefined && opts.isManual !== null) { + postBody['isManual'] = opts.isManual + } + if (opts.filename !== undefined && opts.filename !== null) { + postBody['filename'] = opts.filename + } + if (opts.extInfo !== undefined && opts.extInfo !== null) { + postBody['extInfo'] = opts.extInfo + } + if (opts.path !== undefined && opts.path !== null) { + postBody['path'] = opts.path + } + if (opts.size !== undefined && opts.size !== null) { + postBody['size'] = opts.size + } + if (opts.srcSize !== undefined && opts.srcSize !== null) { + postBody['srcSize'] = opts.srcSize + } + if (opts.storageType !== undefined && opts.storageType !== null) { + postBody['storageType'] = opts.storageType + } + if (opts.taskId !== undefined && opts.taskId !== null) { + postBody['taskId'] = opts.taskId + } + if (opts.binlogStartTime !== undefined && opts.binlogStartTime !== null) { + postBody['binlogStartTime'] = opts.binlogStartTime + } + if (opts.binlogEndTime !== undefined && opts.binlogEndTime !== null) { + postBody['binlogEndTime'] = opts.binlogEndTime + } + if (opts.binlogStartPos !== undefined && opts.binlogStartPos !== null) { + postBody['binlogStartPos'] = opts.binlogStartPos + } + if (opts.binlogEndPos !== undefined && opts.binlogEndPos !== null) { + postBody['binlogEndPos'] = opts.binlogEndPos + } + if (opts.version !== undefined && opts.version !== null) { + postBody['version'] = opts.version + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 backupFile 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}/backupFile', + '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 {object} opts.plan + * @param {string} opts.checkItem - 预检查任务项 + * @param {boolean} opts.success - 是否成功 + * @param {string} [opts.errorMessages] - 错误信息,仅sucess为false时返回 optional + * @param {string} opts.startTime + * @param {string} opts.endTime + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string jobId + */ + + reportPrecheck (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 reportPrecheck" + ) + } + + opts = opts || {} + + if (opts.plan === undefined || opts.plan === null) { + throw new Error( + "Missing the required parameter 'opts.plan' when calling reportPrecheck" + ) + } + if (opts.checkItem === undefined || opts.checkItem === null) { + throw new Error( + "Missing the required parameter 'opts.checkItem' when calling reportPrecheck" + ) + } + if (opts.success === undefined || opts.success === null) { + throw new Error( + "Missing the required parameter 'opts.success' when calling reportPrecheck" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling reportPrecheck" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling reportPrecheck" + ) + } + + let postBody = {} + if (opts.plan !== undefined && opts.plan !== null) { + postBody['plan'] = opts.plan + } + if (opts.checkItem !== undefined && opts.checkItem !== null) { + postBody['checkItem'] = opts.checkItem + } + if (opts.success !== undefined && opts.success !== null) { + postBody['success'] = opts.success + } + if (opts.errorMessages !== undefined && opts.errorMessages !== null) { + postBody['errorMessages'] = opts.errorMessages + } + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 reportPrecheck 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}/precheckPlan', + '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) + } + ) + } + + /** + * 查询已经注册的所有的 DBS agent + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageNumber为-1时,返回所有数据页码;超过总页数时,显示最后一页 optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[10,100],且为10的整数倍 optional + * @param {filter} [opts.filters] - 过滤参数,多个过滤参数之间的关系为“与”(and) +支持以下属性的过滤: +hostName, 支持operator选项:eq, like +hostIP, 支持operator选项:eq, like + optional + * @param {sort} [opts.sorts] - 排序参数 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount + * @param agent dbsAgents + */ + + describeAgents (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 describeAgents" + ) + } + + 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')) + Object.assign(queryParams, super.buildSortParam(opts.sorts, 'sorts')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 describeAgents 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}/agents', + '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) + } + ) + } + + /** + * 查询 agent 详细信息 + * @param {Object} opts - parameters + * @param {string} opts.agentId - Agent ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param agentAttributes agentAttributes + */ + + describeAgentAttributes (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 describeAgentAttributes" + ) + } + + opts = opts || {} + + if (opts.agentId === undefined || opts.agentId === null) { + throw new Error( + "Missing the required parameter 'opts.agentId' when calling describeAgentAttributes" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + agentId: opts.agentId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 describeAgentAttributes 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}/agents/{agentId}', + '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,∞)。pageNumber为-1时,返回所有数据页码;超过总页数时,显示最后一页 optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[10,100],且为10的整数倍 optional + * @param {filter} [opts.filters] - 过滤参数,多个过滤参数之间的关系为“与”(and) +支持以下属性的过滤: +instanceId, 支持operator选项:eq + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount + * @param backupPlan backupPlans + */ + + describeBackupPlans (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 describeBackupPlans" + ) + } + + 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 dbs/2.0.0' + } + + 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 describeBackupPlans 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}/backupPlans', + '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.name - 备份计划名称,支持中文、数字、大小写字母、英文下划线“_”、减号“-”,且不少于2字符不超过64字符 + * @param {string} opts.servicePackage - DBS服务包类型是枚举值, dbs.common.package 表示基础服务包,不含备份流量 + * @param {chargeSpec} opts.chargeSpec - 购买规格 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string buyId + * @param string orderNubmer + * @param string backupPlanId + */ + + createBackupPlan (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 createBackupPlan" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createBackupPlan" + ) + } + if (opts.servicePackage === undefined || opts.servicePackage === null) { + throw new Error( + "Missing the required parameter 'opts.servicePackage' when calling createBackupPlan" + ) + } + if (opts.chargeSpec === undefined || opts.chargeSpec === null) { + throw new Error( + "Missing the required parameter 'opts.chargeSpec' when calling createBackupPlan" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.servicePackage !== undefined && opts.servicePackage !== null) { + postBody['servicePackage'] = opts.servicePackage + } + if (opts.chargeSpec !== undefined && opts.chargeSpec !== null) { + postBody['chargeSpec'] = opts.chargeSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 createBackupPlan 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}/backupPlans', + '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.backupPlanId - 备份计划ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param backupPlanAttributes backupPlanAttributes + */ + + describeBackupPlanAttributes ( + 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 describeBackupPlanAttributes" + ) + } + + opts = opts || {} + + if (opts.backupPlanId === undefined || opts.backupPlanId === null) { + throw new Error( + "Missing the required parameter 'opts.backupPlanId' when calling describeBackupPlanAttributes" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + backupPlanId: opts.backupPlanId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 describeBackupPlanAttributes 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}/backupPlans/{backupPlanId}', + '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.backupPlanId - 备份计划ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteBackupPlan (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 deleteBackupPlan" + ) + } + + opts = opts || {} + + if (opts.backupPlanId === undefined || opts.backupPlanId === null) { + throw new Error( + "Missing the required parameter 'opts.backupPlanId' when calling deleteBackupPlan" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + backupPlanId: opts.backupPlanId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 deleteBackupPlan 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}/backupPlans/{backupPlanId}', + '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.backupPlanId - 备份计划ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 预检查任务状态 + * @param integer progress 预检查任务进度 + * @param precheckPlan preCheckDetails + */ + + describePreCheck (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 describePreCheck" + ) + } + + opts = opts || {} + + if (opts.backupPlanId === undefined || opts.backupPlanId === null) { + throw new Error( + "Missing the required parameter 'opts.backupPlanId' when calling describePreCheck" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + backupPlanId: opts.backupPlanId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 describePreCheck 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}/backupPlans/{backupPlanId}:describePreCheck', + '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.backupPlanId - 备份计划ID + * @param {string} opts.sourceEngine - 引擎类型 MySQL5 MySQL8 MariaDB Percona + * @param {string} opts.backupType - 备份方式,支持物理备份或逻辑备份 + * @param {boolean} [opts.enableBackupLogs] - 是否开启日志备份;true:开启;false:关闭 optional + * @param {integer} [opts.logBackupRetentionPeriod] - 日志备份保存天数,支持7-3650 天,默认7天 optional + * @param {integer} [opts.fullBackupRetentionPeriod] - 全量备份保存天数,支持7-3650 天,默认7天 optional + * @param {backupSchedule} opts.fullBackupSchedule - 全量备份的备份周期 + * @param {sourceEndpoint} opts.sourceEndpoint - 备份目标的详细信息 + * @param {backupObjects} [opts.backupObjects] - 逻辑备份中要备份的对象的信息,物理备份无须该信息 optional + * @param {boolean} opts.createNewEndpoint - 是否开启日志备份;true:开启;false:关闭 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + initBackupPlan (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 initBackupPlan" + ) + } + + opts = opts || {} + + if (opts.backupPlanId === undefined || opts.backupPlanId === null) { + throw new Error( + "Missing the required parameter 'opts.backupPlanId' when calling initBackupPlan" + ) + } + if (opts.sourceEngine === undefined || opts.sourceEngine === null) { + throw new Error( + "Missing the required parameter 'opts.sourceEngine' when calling initBackupPlan" + ) + } + if (opts.backupType === undefined || opts.backupType === null) { + throw new Error( + "Missing the required parameter 'opts.backupType' when calling initBackupPlan" + ) + } + if ( + opts.fullBackupSchedule === undefined || + opts.fullBackupSchedule === null + ) { + throw new Error( + "Missing the required parameter 'opts.fullBackupSchedule' when calling initBackupPlan" + ) + } + if (opts.sourceEndpoint === undefined || opts.sourceEndpoint === null) { + throw new Error( + "Missing the required parameter 'opts.sourceEndpoint' when calling initBackupPlan" + ) + } + if ( + opts.createNewEndpoint === undefined || + opts.createNewEndpoint === null + ) { + throw new Error( + "Missing the required parameter 'opts.createNewEndpoint' when calling initBackupPlan" + ) + } + + let postBody = {} + if (opts.sourceEngine !== undefined && opts.sourceEngine !== null) { + postBody['sourceEngine'] = opts.sourceEngine + } + if (opts.backupType !== undefined && opts.backupType !== null) { + postBody['backupType'] = opts.backupType + } + if (opts.enableBackupLogs !== undefined && opts.enableBackupLogs !== null) { + postBody['enableBackupLogs'] = opts.enableBackupLogs + } + if ( + opts.logBackupRetentionPeriod !== undefined && + opts.logBackupRetentionPeriod !== null + ) { + postBody['logBackupRetentionPeriod'] = opts.logBackupRetentionPeriod + } + if ( + opts.fullBackupRetentionPeriod !== undefined && + opts.fullBackupRetentionPeriod !== null + ) { + postBody['fullBackupRetentionPeriod'] = opts.fullBackupRetentionPeriod + } + if ( + opts.fullBackupSchedule !== undefined && + opts.fullBackupSchedule !== null + ) { + postBody['fullBackupSchedule'] = opts.fullBackupSchedule + } + if (opts.sourceEndpoint !== undefined && opts.sourceEndpoint !== null) { + postBody['sourceEndpoint'] = opts.sourceEndpoint + } + if (opts.backupObjects !== undefined && opts.backupObjects !== null) { + postBody['backupObjects'] = opts.backupObjects + } + if ( + opts.createNewEndpoint !== undefined && + opts.createNewEndpoint !== null + ) { + postBody['createNewEndpoint'] = opts.createNewEndpoint + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + backupPlanId: opts.backupPlanId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 initBackupPlan 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}/backupPlans/{backupPlanId}:initBackupPlan', + '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.backupPlanId - 备份计划ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + createLogicalBackup (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 createLogicalBackup" + ) + } + + opts = opts || {} + + if (opts.backupPlanId === undefined || opts.backupPlanId === null) { + throw new Error( + "Missing the required parameter 'opts.backupPlanId' when calling createLogicalBackup" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + backupPlanId: opts.backupPlanId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 createLogicalBackup 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}/backupPlans/{backupPlanId}:createLogicalBackup', + '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.backupPlanId - 备份计划ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + createPhysicalBackup (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 createPhysicalBackup" + ) + } + + opts = opts || {} + + if (opts.backupPlanId === undefined || opts.backupPlanId === null) { + throw new Error( + "Missing the required parameter 'opts.backupPlanId' when calling createPhysicalBackup" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + backupPlanId: opts.backupPlanId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 createPhysicalBackup 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}/backupPlans/{backupPlanId}:createPhysicalBackup', + '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) + } + ) + } + + /** + * 查询所有的binlog备份结果 + * @param {Object} opts - parameters + * @param {string} opts.backupPlanId - 备份计划ID + * @param {integer} [opts.pageNumber] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageNumber为-1时,返回所有数据页码;超过总页数时,显示最后一页 optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[10,100],且为10的整数倍 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount + * @param binlogBackup binlogBackups + */ + + describeBinlogBackups (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 describeBinlogBackups" + ) + } + + opts = opts || {} + + if (opts.backupPlanId === undefined || opts.backupPlanId === null) { + throw new Error( + "Missing the required parameter 'opts.backupPlanId' when calling describeBinlogBackups" + ) + } + + 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, + backupPlanId: opts.backupPlanId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 describeBinlogBackups 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}/backupPlans/{backupPlanId}:describeBinlogBackups', + '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.backupPlanId - 备份计划ID + * @param {integer} [opts.pageNumber] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageNumber为-1时,返回所有数据页码;超过总页数时,显示最后一页 optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[10,100],且为10的整数倍 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount + * @param logicalBackups logicalBackups + */ + + describeLogicalBackups (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 describeLogicalBackups" + ) + } + + opts = opts || {} + + if (opts.backupPlanId === undefined || opts.backupPlanId === null) { + throw new Error( + "Missing the required parameter 'opts.backupPlanId' when calling describeLogicalBackups" + ) + } + + 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, + backupPlanId: opts.backupPlanId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 describeLogicalBackups 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}/backupPlans/{backupPlanId}:describeLogicalBackups', + '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.backupPlanId - 备份计划ID + * @param {integer} [opts.pageNumber] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageNumber为-1时,返回所有数据页码;超过总页数时,显示最后一页 optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[10,100],且为10的整数倍 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount + * @param physicalBackups physicalBackups + */ + + describePhysicalBackups (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 describePhysicalBackups" + ) + } + + opts = opts || {} + + if (opts.backupPlanId === undefined || opts.backupPlanId === null) { + throw new Error( + "Missing the required parameter 'opts.backupPlanId' when calling describePhysicalBackups" + ) + } + + 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, + backupPlanId: opts.backupPlanId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 describePhysicalBackups 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}/backupPlans/{backupPlanId}:describePhysicalBackups', + '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.backupPlanId - 备份计划ID + * @param {string} opts.backupType - 备份的类型 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param shouldDelBackups shouldDelBackups + */ + + getShouldDelBackups (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 getShouldDelBackups" + ) + } + + opts = opts || {} + + if (opts.backupPlanId === undefined || opts.backupPlanId === null) { + throw new Error( + "Missing the required parameter 'opts.backupPlanId' when calling getShouldDelBackups" + ) + } + if (opts.backupType === undefined || opts.backupType === null) { + throw new Error( + "Missing the required parameter 'opts.backupType' when calling getShouldDelBackups" + ) + } + + let postBody = null + let queryParams = {} + if (opts.backupType !== undefined && opts.backupType !== null) { + queryParams['backupType'] = opts.backupType + } + + let pathParams = { + regionId: regionId, + backupPlanId: opts.backupPlanId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 getShouldDelBackups 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}/backupPlans/{backupPlanId}:shouldDelBackups', + '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.backupPlanId - 备份计划ID + * @param {string} [opts.backupType] optional + * @param {integer} [opts.totalCount] optional + * @param {array} [opts.backupFiles] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean ok + */ + + updateShouldDelBackups (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 updateShouldDelBackups" + ) + } + + opts = opts || {} + + if (opts.backupPlanId === undefined || opts.backupPlanId === null) { + throw new Error( + "Missing the required parameter 'opts.backupPlanId' when calling updateShouldDelBackups" + ) + } + + let postBody = {} + if (opts.backupType !== undefined && opts.backupType !== null) { + postBody['backupType'] = opts.backupType + } + if (opts.totalCount !== undefined && opts.totalCount !== null) { + postBody['totalCount'] = opts.totalCount + } + if (opts.backupFiles !== undefined && opts.backupFiles !== null) { + postBody['backupFiles'] = opts.backupFiles + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + backupPlanId: opts.backupPlanId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 updateShouldDelBackups 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}/backupPlans/{backupPlanId}:shouldDelBackups', + 'PATCH', + 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) + } + ) + } + + /** + * 获取该备份计划最近备份成功的 binlog 文件 + * @param {Object} opts - parameters + * @param {string} opts.backupPlanId - 备份计划ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param backupBriefInfo lastBackupBinlog + */ + + getLastBackupBinlog (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 getLastBackupBinlog" + ) + } + + opts = opts || {} + + if (opts.backupPlanId === undefined || opts.backupPlanId === null) { + throw new Error( + "Missing the required parameter 'opts.backupPlanId' when calling getLastBackupBinlog" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + backupPlanId: opts.backupPlanId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 getLastBackupBinlog 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}/backupPlans/{backupPlanId}:getLastBackupBinlog', + '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) + } + ) + } + + /** + * 查询当前备份计划下最近1年的恢复任务,按创建任务时间倒序排列 + * @param {Object} opts - parameters + * @param {string} opts.backupPlanId - 备份计划ID + * @param {integer} [opts.pageNumber] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageNumber为-1时,返回所有数据页码;超过总页数时,显示最后一页 optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[10,100],且为10的整数倍 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount + * @param restoreTask restoreTasks + */ + + describeRestoreTasks (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 describeRestoreTasks" + ) + } + + opts = opts || {} + + if (opts.backupPlanId === undefined || opts.backupPlanId === null) { + throw new Error( + "Missing the required parameter 'opts.backupPlanId' when calling describeRestoreTasks" + ) + } + + 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, + backupPlanId: opts.backupPlanId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 describeRestoreTasks 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}/backupPlans/{backupPlanId}:describeRestoreTasks', + '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.backupPlanId - 备份计划ID + * @param {string} opts.backupId - 用于恢复的备份Id,仅限于本备份计划生成的备份 + * @param {restoreSourceEndpoint} opts.sourceEndpoint - 备份实例的数据源信息 + * @param {boolean} opts.createNewEndpoint - 是否是新建数据源;true:是;false:不是 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + restoreLogicalBackup (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 restoreLogicalBackup" + ) + } + + opts = opts || {} + + if (opts.backupPlanId === undefined || opts.backupPlanId === null) { + throw new Error( + "Missing the required parameter 'opts.backupPlanId' when calling restoreLogicalBackup" + ) + } + if (opts.backupId === undefined || opts.backupId === null) { + throw new Error( + "Missing the required parameter 'opts.backupId' when calling restoreLogicalBackup" + ) + } + if (opts.sourceEndpoint === undefined || opts.sourceEndpoint === null) { + throw new Error( + "Missing the required parameter 'opts.sourceEndpoint' when calling restoreLogicalBackup" + ) + } + if ( + opts.createNewEndpoint === undefined || + opts.createNewEndpoint === null + ) { + throw new Error( + "Missing the required parameter 'opts.createNewEndpoint' when calling restoreLogicalBackup" + ) + } + + let postBody = {} + if (opts.backupId !== undefined && opts.backupId !== null) { + postBody['backupId'] = opts.backupId + } + if (opts.sourceEndpoint !== undefined && opts.sourceEndpoint !== null) { + postBody['sourceEndpoint'] = opts.sourceEndpoint + } + if ( + opts.createNewEndpoint !== undefined && + opts.createNewEndpoint !== null + ) { + postBody['createNewEndpoint'] = opts.createNewEndpoint + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + backupPlanId: opts.backupPlanId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 restoreLogicalBackup 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}/backupPlans/{backupPlanId}:restoreLogicalBackup', + '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.backupPlanId - 备份计划ID + * @param {string} opts.backupId - 用于恢复的备份Id,仅限于本备份计划生成的备份 + * @param {restoreSourceEndpoint} opts.sourceEndpoint - 备份实例的数据源信息 + * @param {boolean} opts.createNewEndpoint - 是否是新建数据源;true:是;false:不是 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + restorePhysicalBackup (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 restorePhysicalBackup" + ) + } + + opts = opts || {} + + if (opts.backupPlanId === undefined || opts.backupPlanId === null) { + throw new Error( + "Missing the required parameter 'opts.backupPlanId' when calling restorePhysicalBackup" + ) + } + if (opts.backupId === undefined || opts.backupId === null) { + throw new Error( + "Missing the required parameter 'opts.backupId' when calling restorePhysicalBackup" + ) + } + if (opts.sourceEndpoint === undefined || opts.sourceEndpoint === null) { + throw new Error( + "Missing the required parameter 'opts.sourceEndpoint' when calling restorePhysicalBackup" + ) + } + if ( + opts.createNewEndpoint === undefined || + opts.createNewEndpoint === null + ) { + throw new Error( + "Missing the required parameter 'opts.createNewEndpoint' when calling restorePhysicalBackup" + ) + } + + let postBody = {} + if (opts.backupId !== undefined && opts.backupId !== null) { + postBody['backupId'] = opts.backupId + } + if (opts.sourceEndpoint !== undefined && opts.sourceEndpoint !== null) { + postBody['sourceEndpoint'] = opts.sourceEndpoint + } + if ( + opts.createNewEndpoint !== undefined && + opts.createNewEndpoint !== null + ) { + postBody['createNewEndpoint'] = opts.createNewEndpoint + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + backupPlanId: opts.backupPlanId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 restorePhysicalBackup 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}/backupPlans/{backupPlanId}:restorePhysicalBackup', + '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) + } + ) + } + + /** + * 将数据库实例根据物理备份和binlog备份恢复到指定的时间点。 + * @param {Object} opts - parameters + * @param {string} opts.backupPlanId - 备份计划ID + * @param {string} opts.restoreTime - 数据库实例要恢复到的时间点,UTC时间格式:YYYY-MM-DDTHH:mm:ssZ + * @param {restoreSourceEndpoint} opts.sourceEndpoint - 备份实例的数据源信息 + * @param {boolean} opts.createNewEndpoint - 是否是新建数据源;true:是;false:不是 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + restoreToTime (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 restoreToTime" + ) + } + + opts = opts || {} + + if (opts.backupPlanId === undefined || opts.backupPlanId === null) { + throw new Error( + "Missing the required parameter 'opts.backupPlanId' when calling restoreToTime" + ) + } + if (opts.restoreTime === undefined || opts.restoreTime === null) { + throw new Error( + "Missing the required parameter 'opts.restoreTime' when calling restoreToTime" + ) + } + if (opts.sourceEndpoint === undefined || opts.sourceEndpoint === null) { + throw new Error( + "Missing the required parameter 'opts.sourceEndpoint' when calling restoreToTime" + ) + } + if ( + opts.createNewEndpoint === undefined || + opts.createNewEndpoint === null + ) { + throw new Error( + "Missing the required parameter 'opts.createNewEndpoint' when calling restoreToTime" + ) + } + + let postBody = {} + if (opts.restoreTime !== undefined && opts.restoreTime !== null) { + postBody['restoreTime'] = opts.restoreTime + } + if (opts.sourceEndpoint !== undefined && opts.sourceEndpoint !== null) { + postBody['sourceEndpoint'] = opts.sourceEndpoint + } + if ( + opts.createNewEndpoint !== undefined && + opts.createNewEndpoint !== null + ) { + postBody['createNewEndpoint'] = opts.createNewEndpoint + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + backupPlanId: opts.backupPlanId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 restoreToTime 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}/backupPlans/{backupPlanId}:restoreToTime', + '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.backupPlanId - 备份计划ID + * @param {string} opts.backupId - 备份文件ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteBackup (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 deleteBackup" + ) + } + + opts = opts || {} + + if (opts.backupPlanId === undefined || opts.backupPlanId === null) { + throw new Error( + "Missing the required parameter 'opts.backupPlanId' when calling deleteBackup" + ) + } + if (opts.backupId === undefined || opts.backupId === null) { + throw new Error( + "Missing the required parameter 'opts.backupId' when calling deleteBackup" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + backupPlanId: opts.backupPlanId, + backupId: opts.backupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 deleteBackup 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}/backupPlans/{backupPlanId}/backup/{backupId}', + '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.backupPlanId - 备份计划ID + * @param {string} [opts.database] - 数据库名称 optional + * @param {array} [opts.objects] - 表名, 如果不填或者为空,表示对整个数据库进行备份 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyBackupObjects (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 modifyBackupObjects" + ) + } + + opts = opts || {} + + if (opts.backupPlanId === undefined || opts.backupPlanId === null) { + throw new Error( + "Missing the required parameter 'opts.backupPlanId' when calling modifyBackupObjects" + ) + } + + let postBody = {} + if (opts.database !== undefined && opts.database !== null) { + postBody['database'] = opts.database + } + if (opts.objects !== undefined && opts.objects !== null) { + postBody['objects'] = opts.objects + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + backupPlanId: opts.backupPlanId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 modifyBackupObjects 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}/backupPlans/{backupPlanId}:modifyBackupObjects', + '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.backupPlanId - 备份计划ID + * @param {string} [opts.fullBackupPeriod] - 周期类型,目前仅支持weekly optional + * @param {array} [opts.fullBackupDays] - 进行全量备份的日期, 备份周期为 weekly 时可以取 0-6 分别对应的是周日到周六 optional + * @param {string} [opts.fullBackupStartTime] - 全量备份的开始时间,精确到分,UTC时间格式,例如:23:30Z optional + * @param {integer} [opts.fullBackupRetentionPeriod] - 全量备份保存天数,支持7-3650 天,默认7天 optional + * @param {integer} [opts.logBackupRetentionPeriod] - 日志备份保存天数,支持7-3650 天,默认7天 optional + * @param {boolean} [opts.enableBackupLogs] - 是否开启日志备份;true:开启;false:关闭 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyBackupPolicy (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 modifyBackupPolicy" + ) + } + + opts = opts || {} + + if (opts.backupPlanId === undefined || opts.backupPlanId === null) { + throw new Error( + "Missing the required parameter 'opts.backupPlanId' when calling modifyBackupPolicy" + ) + } + + let postBody = {} + if (opts.fullBackupPeriod !== undefined && opts.fullBackupPeriod !== null) { + postBody['fullBackupPeriod'] = opts.fullBackupPeriod + } + if (opts.fullBackupDays !== undefined && opts.fullBackupDays !== null) { + postBody['fullBackupDays'] = opts.fullBackupDays + } + if ( + opts.fullBackupStartTime !== undefined && + opts.fullBackupStartTime !== null + ) { + postBody['fullBackupStartTime'] = opts.fullBackupStartTime + } + if ( + opts.fullBackupRetentionPeriod !== undefined && + opts.fullBackupRetentionPeriod !== null + ) { + postBody['fullBackupRetentionPeriod'] = opts.fullBackupRetentionPeriod + } + if ( + opts.logBackupRetentionPeriod !== undefined && + opts.logBackupRetentionPeriod !== null + ) { + postBody['logBackupRetentionPeriod'] = opts.logBackupRetentionPeriod + } + if (opts.enableBackupLogs !== undefined && opts.enableBackupLogs !== null) { + postBody['enableBackupLogs'] = opts.enableBackupLogs + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + backupPlanId: opts.backupPlanId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 modifyBackupPolicy 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}/backupPlans/{backupPlanId}:modifyBackupPolicy', + '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.backupPlanId - 备份计划ID + * @param {string} [opts.accountName] - 源数据库的账号 optional + * @param {string} [opts.password] - 源数据库的密码 optional + * @param {engineRelatedConfig} [opts.engineRelatedConfig] - 不同数据库引擎独有的配置参数 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifySourceEndpoint (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 modifySourceEndpoint" + ) + } + + opts = opts || {} + + if (opts.backupPlanId === undefined || opts.backupPlanId === null) { + throw new Error( + "Missing the required parameter 'opts.backupPlanId' when calling modifySourceEndpoint" + ) + } + + let postBody = {} + if (opts.accountName !== undefined && opts.accountName !== null) { + postBody['accountName'] = opts.accountName + } + if (opts.password !== undefined && opts.password !== null) { + postBody['password'] = opts.password + } + if ( + opts.engineRelatedConfig !== undefined && + opts.engineRelatedConfig !== null + ) { + postBody['engineRelatedConfig'] = opts.engineRelatedConfig + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + backupPlanId: opts.backupPlanId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 modifySourceEndpoint 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}/backupPlans/{backupPlanId}:modifySourceEndpoint', + '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.backupPlanId - 备份计划ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + startBackupPlan (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 startBackupPlan" + ) + } + + opts = opts || {} + + if (opts.backupPlanId === undefined || opts.backupPlanId === null) { + throw new Error( + "Missing the required parameter 'opts.backupPlanId' when calling startBackupPlan" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + backupPlanId: opts.backupPlanId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 startBackupPlan 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}/backupPlans/{backupPlanId}:startBackupPlan', + '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.backupPlanId - 备份计划ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + stopBackupPlan (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 stopBackupPlan" + ) + } + + opts = opts || {} + + if (opts.backupPlanId === undefined || opts.backupPlanId === null) { + throw new Error( + "Missing the required parameter 'opts.backupPlanId' when calling stopBackupPlan" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + backupPlanId: opts.backupPlanId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dbs/2.0.0' + } + + 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 stopBackupPlan 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}/backupPlans/{backupPlanId}:stopBackupPlan', + '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 = DBS diff --git a/packages/libs/lib-jdcloud/src/repo/dcap/v1/dcap.js b/packages/libs/lib-jdcloud/src/repo/dcap/v1/dcap.js new file mode 100644 index 000000000..52027db61 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/dcap/v1/dcap.js @@ -0,0 +1,4501 @@ +/* + * 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. + * + * UserPackage + * 敏感数据保护-用户套餐相关接口 + * + * 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 = 'dcap' +Service._services[serviceId] = true + +/** + * dcap service. + * @version 1.0.1 + */ + +class DCAP extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'dcap.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 敏感数据分级列表 + * @param {Object} opts - parameters + * @param {string} callback - callback + @return {Object} result + * @param levelSpec list + * @param integer totalCount 总数量 + */ + + describeLevelList (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 describeLevelList 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( + '/level', + '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.levelId - 分级 ID + * @param {levelSpec} opts.levelSpec - 敏感数据分级描述 + * @param {string} callback - callback + @return {Object} result + */ + + modifyLevel (opts, callback) { + opts = opts || {} + + if (opts.levelId === undefined || opts.levelId === null) { + throw new Error( + "Missing the required parameter 'opts.levelId' when calling modifyLevel" + ) + } + if (opts.levelSpec === undefined || opts.levelSpec === null) { + throw new Error( + "Missing the required parameter 'opts.levelSpec' when calling modifyLevel" + ) + } + + let postBody = {} + if (opts.levelSpec !== undefined && opts.levelSpec !== null) { + postBody['levelSpec'] = opts.levelSpec + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + levelId: opts.levelId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 modifyLevel 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( + '/level/{levelId}', + 'PATCH', + 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} callback - callback + @return {Object} result + * @param categoryDesc list + */ + + describeCategoryList (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 describeCategoryList 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( + '/category', + '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 {categorySpec} opts.categorySpec - 敏感数据分类描述 + * @param {string} callback - callback + @return {Object} result + */ + + addCategory (opts, callback) { + opts = opts || {} + + if (opts.categorySpec === undefined || opts.categorySpec === null) { + throw new Error( + "Missing the required parameter 'opts.categorySpec' when calling addCategory" + ) + } + + let postBody = {} + if (opts.categorySpec !== undefined && opts.categorySpec !== null) { + postBody['categorySpec'] = opts.categorySpec + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 addCategory 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( + '/category', + '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.categoryId - 分类 ID + * @param {categorySpec} opts.categorySpec - 敏感数据分类描述 + * @param {string} callback - callback + @return {Object} result + */ + + modifyCategory (opts, callback) { + opts = opts || {} + + if (opts.categoryId === undefined || opts.categoryId === null) { + throw new Error( + "Missing the required parameter 'opts.categoryId' when calling modifyCategory" + ) + } + if (opts.categorySpec === undefined || opts.categorySpec === null) { + throw new Error( + "Missing the required parameter 'opts.categorySpec' when calling modifyCategory" + ) + } + + let postBody = {} + if (opts.categorySpec !== undefined && opts.categorySpec !== null) { + postBody['categorySpec'] = opts.categorySpec + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + categoryId: opts.categoryId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 modifyCategory 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( + '/category/{categoryId}', + 'PATCH', + 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.categoryId - 分类 ID + * @param {string} callback - callback + @return {Object} result + */ + + deleteCategory (opts, callback) { + opts = opts || {} + + if (opts.categoryId === undefined || opts.categoryId === null) { + throw new Error( + "Missing the required parameter 'opts.categoryId' when calling deleteCategory" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + categoryId: opts.categoryId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 deleteCategory 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( + '/category/{categoryId}', + '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.categoryId - 分类 ID + * @param {integer} opts.pageNumber - 页码;默认为1 + * @param {integer} opts.pageSize - 分页大小;默认为10;取值范围[10, 100] + * @param {string} callback - callback + @return {Object} result + * @param dataTypeDesc list + * @param integer totalCount 敏感数据类型总数量 + */ + + describeDataTypeList (opts, callback) { + opts = opts || {} + + if (opts.categoryId === undefined || opts.categoryId === null) { + throw new Error( + "Missing the required parameter 'opts.categoryId' when calling describeDataTypeList" + ) + } + if (opts.pageNumber === undefined || opts.pageNumber === null) { + throw new Error( + "Missing the required parameter 'opts.pageNumber' when calling describeDataTypeList" + ) + } + if (opts.pageSize === undefined || opts.pageSize === null) { + throw new Error( + "Missing the required parameter 'opts.pageSize' when calling describeDataTypeList" + ) + } + + 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: 'jdcloud', + categoryId: opts.categoryId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 describeDataTypeList 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( + '/category/{categoryId}/dataType', + '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.categoryId - 分类 ID + * @param {dataTypeSpec} opts.dataType - 新增敏感数据类型描述 + * @param {string} callback - callback + @return {Object} result + */ + + createDataType (opts, callback) { + opts = opts || {} + + if (opts.categoryId === undefined || opts.categoryId === null) { + throw new Error( + "Missing the required parameter 'opts.categoryId' when calling createDataType" + ) + } + if (opts.dataType === undefined || opts.dataType === null) { + throw new Error( + "Missing the required parameter 'opts.dataType' when calling createDataType" + ) + } + + let postBody = {} + if (opts.dataType !== undefined && opts.dataType !== null) { + postBody['dataType'] = opts.dataType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + categoryId: opts.categoryId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 createDataType 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( + '/category/{categoryId}/dataType', + '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.categoryId - 分类 ID + * @param {string} opts.typeId - 敏感数据类型ID + * @param {dataTypeSpec} opts.dataType - 敏感数据类型描述 + * @param {string} callback - callback + @return {Object} result + */ + + modifyDataType (opts, callback) { + opts = opts || {} + + if (opts.categoryId === undefined || opts.categoryId === null) { + throw new Error( + "Missing the required parameter 'opts.categoryId' when calling modifyDataType" + ) + } + if (opts.typeId === undefined || opts.typeId === null) { + throw new Error( + "Missing the required parameter 'opts.typeId' when calling modifyDataType" + ) + } + if (opts.dataType === undefined || opts.dataType === null) { + throw new Error( + "Missing the required parameter 'opts.dataType' when calling modifyDataType" + ) + } + + let postBody = {} + if (opts.dataType !== undefined && opts.dataType !== null) { + postBody['dataType'] = opts.dataType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + categoryId: opts.categoryId, + typeId: opts.typeId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 modifyDataType 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( + '/category/{categoryId}/dataType/{typeId}', + 'PATCH', + 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.categoryId - 分类 ID + * @param {string} opts.typeId - 敏感数据类型ID + * @param {string} callback - callback + @return {Object} result + */ + + deleteDataType (opts, callback) { + opts = opts || {} + + if (opts.categoryId === undefined || opts.categoryId === null) { + throw new Error( + "Missing the required parameter 'opts.categoryId' when calling deleteDataType" + ) + } + if (opts.typeId === undefined || opts.typeId === null) { + throw new Error( + "Missing the required parameter 'opts.typeId' when calling deleteDataType" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + categoryId: opts.categoryId, + typeId: opts.typeId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 deleteDataType 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( + '/category/{categoryId}/dataType/{typeId}', + '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 + * @param {integer} opts.pageSize - 分页大小;默认为10;取值范围[10, 100] + * @param {filter} [opts.filters] - "dataSourceId: 数据源ID,字符串数组,精确匹配" +"dataSourceName: 数据源名称,字符串,模糊匹配" + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dataSourceDesc list + * @param integer totalCount 总数量 + */ + + describeDataSourceList (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 describeDataSourceList" + ) + } + + opts = opts || {} + + if (opts.pageNumber === undefined || opts.pageNumber === null) { + throw new Error( + "Missing the required parameter 'opts.pageNumber' when calling describeDataSourceList" + ) + } + if (opts.pageSize === undefined || opts.pageSize === null) { + throw new Error( + "Missing the required parameter 'opts.pageSize' when calling describeDataSourceList" + ) + } + + 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 dcap/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 describeDataSourceList 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}/dataSources', + '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 {dataSourceSpec} opts.dataSourceSpec - 添加数据源需要的信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string dataSourceId 新建的数据源ID + */ + + createDataSource (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 createDataSource" + ) + } + + opts = opts || {} + + if (opts.dataSourceSpec === undefined || opts.dataSourceSpec === null) { + throw new Error( + "Missing the required parameter 'opts.dataSourceSpec' when calling createDataSource" + ) + } + + let postBody = {} + if (opts.dataSourceSpec !== undefined && opts.dataSourceSpec !== null) { + postBody['dataSourceSpec'] = opts.dataSourceSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 createDataSource 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}/dataSources', + '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.dataSourceId - 数据源 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dataSourceDesc dataSourceDesc + */ + + describeDataSource (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 describeDataSource" + ) + } + + opts = opts || {} + + if (opts.dataSourceId === undefined || opts.dataSourceId === null) { + throw new Error( + "Missing the required parameter 'opts.dataSourceId' when calling describeDataSource" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + dataSourceId: opts.dataSourceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 describeDataSource 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}/dataSources/{dataSourceId}', + '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.dataSourceId - 数据源 ID + * @param {string} opts.dataSourceName - 数据源名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateDataSourceName (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 updateDataSourceName" + ) + } + + opts = opts || {} + + if (opts.dataSourceId === undefined || opts.dataSourceId === null) { + throw new Error( + "Missing the required parameter 'opts.dataSourceId' when calling updateDataSourceName" + ) + } + if (opts.dataSourceName === undefined || opts.dataSourceName === null) { + throw new Error( + "Missing the required parameter 'opts.dataSourceName' when calling updateDataSourceName" + ) + } + + let postBody = {} + if (opts.dataSourceName !== undefined && opts.dataSourceName !== null) { + postBody['dataSourceName'] = opts.dataSourceName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + dataSourceId: opts.dataSourceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 updateDataSourceName 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}/dataSources/{dataSourceId}', + 'PATCH', + 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.dataSourceId - 数据源 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteDataSource (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 deleteDataSource" + ) + } + + opts = opts || {} + + if (opts.dataSourceId === undefined || opts.dataSourceId === null) { + throw new Error( + "Missing the required parameter 'opts.dataSourceId' when calling deleteDataSource" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + dataSourceId: opts.dataSourceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 deleteDataSource 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}/dataSources/{dataSourceId}', + '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.dataSourceId - 数据源 ID + * @param {kmsSpec} opts.kmsSpec - 添加数据源需要的信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + setDataSourceKms (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 setDataSourceKms" + ) + } + + opts = opts || {} + + if (opts.dataSourceId === undefined || opts.dataSourceId === null) { + throw new Error( + "Missing the required parameter 'opts.dataSourceId' when calling setDataSourceKms" + ) + } + if (opts.kmsSpec === undefined || opts.kmsSpec === null) { + throw new Error( + "Missing the required parameter 'opts.kmsSpec' when calling setDataSourceKms" + ) + } + + let postBody = {} + if (opts.kmsSpec !== undefined && opts.kmsSpec !== null) { + postBody['kmsSpec'] = opts.kmsSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + dataSourceId: opts.dataSourceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 setDataSourceKms 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}/dataSources/{dataSourceId}:setKms', + '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) + } + ) + } + + /** + * 生成DDL语句 + * @param {Object} opts - parameters + * @param {string} opts.dataSourceId - 数据源 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string ddl DDL语句 + */ + + generateDataSourceDDL (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 generateDataSourceDDL" + ) + } + + opts = opts || {} + + if (opts.dataSourceId === undefined || opts.dataSourceId === null) { + throw new Error( + "Missing the required parameter 'opts.dataSourceId' when calling generateDataSourceDDL" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + dataSourceId: opts.dataSourceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 generateDataSourceDDL 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}/dataSources/{dataSourceId}:generateDDL', + '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.dataSourceId - 数据源 ID + * @param {integer} opts.pageNumber - 页码;默认为1 + * @param {integer} opts.pageSize - 分页大小;默认为10;取值范围[10, 100] + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string list 表名称 + * @param integer totalCount 总数量 + */ + + describeDataSourceTableList (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 describeDataSourceTableList" + ) + } + + opts = opts || {} + + if (opts.dataSourceId === undefined || opts.dataSourceId === null) { + throw new Error( + "Missing the required parameter 'opts.dataSourceId' when calling describeDataSourceTableList" + ) + } + if (opts.pageNumber === undefined || opts.pageNumber === null) { + throw new Error( + "Missing the required parameter 'opts.pageNumber' when calling describeDataSourceTableList" + ) + } + if (opts.pageSize === undefined || opts.pageSize === null) { + throw new Error( + "Missing the required parameter 'opts.pageSize' when calling describeDataSourceTableList" + ) + } + + 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, + dataSourceId: opts.dataSourceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 describeDataSourceTableList 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}/dataSources/{dataSourceId}/tables', + '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.dataSourceId - 数据源 ID + * @param {string} opts.tableName - 表名 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + createDataSourceTable (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 createDataSourceTable" + ) + } + + opts = opts || {} + + if (opts.dataSourceId === undefined || opts.dataSourceId === null) { + throw new Error( + "Missing the required parameter 'opts.dataSourceId' when calling createDataSourceTable" + ) + } + if (opts.tableName === undefined || opts.tableName === null) { + throw new Error( + "Missing the required parameter 'opts.tableName' when calling createDataSourceTable" + ) + } + + let postBody = {} + if (opts.tableName !== undefined && opts.tableName !== null) { + postBody['tableName'] = opts.tableName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + dataSourceId: opts.dataSourceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 createDataSourceTable 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}/dataSources/{dataSourceId}/tables', + '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.dataSourceId - 数据源 ID + * @param {string} opts.tableName - 表-名称 + * @param {integer} opts.pageNumber - 页码;默认为1 + * @param {integer} opts.pageSize - 分页大小;默认为10;取值范围[10, 100] + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param fieldDesc list + * @param integer totalCount 总数量 + */ + + describeDataSourceTableFieldList ( + 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 describeDataSourceTableFieldList" + ) + } + + opts = opts || {} + + if (opts.dataSourceId === undefined || opts.dataSourceId === null) { + throw new Error( + "Missing the required parameter 'opts.dataSourceId' when calling describeDataSourceTableFieldList" + ) + } + if (opts.tableName === undefined || opts.tableName === null) { + throw new Error( + "Missing the required parameter 'opts.tableName' when calling describeDataSourceTableFieldList" + ) + } + if (opts.pageNumber === undefined || opts.pageNumber === null) { + throw new Error( + "Missing the required parameter 'opts.pageNumber' when calling describeDataSourceTableFieldList" + ) + } + if (opts.pageSize === undefined || opts.pageSize === null) { + throw new Error( + "Missing the required parameter 'opts.pageSize' when calling describeDataSourceTableFieldList" + ) + } + + 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, + dataSourceId: opts.dataSourceId, + tableName: opts.tableName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 describeDataSourceTableFieldList 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}/dataSources/{dataSourceId}/tables/{tableName}', + '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.dataSourceId - 数据源 ID + * @param {string} opts.tableName - 表-名称 + * @param {fieldSpec} opts.fieldSpec - 新建字段需要的信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + createDataSourceTableField (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 createDataSourceTableField" + ) + } + + opts = opts || {} + + if (opts.dataSourceId === undefined || opts.dataSourceId === null) { + throw new Error( + "Missing the required parameter 'opts.dataSourceId' when calling createDataSourceTableField" + ) + } + if (opts.tableName === undefined || opts.tableName === null) { + throw new Error( + "Missing the required parameter 'opts.tableName' when calling createDataSourceTableField" + ) + } + if (opts.fieldSpec === undefined || opts.fieldSpec === null) { + throw new Error( + "Missing the required parameter 'opts.fieldSpec' when calling createDataSourceTableField" + ) + } + + let postBody = {} + if (opts.fieldSpec !== undefined && opts.fieldSpec !== null) { + postBody['fieldSpec'] = opts.fieldSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + dataSourceId: opts.dataSourceId, + tableName: opts.tableName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 createDataSourceTableField 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}/dataSources/{dataSourceId}/tables/{tableName}', + '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.dataSourceId - 数据源 ID + * @param {string} opts.tableName - 表-名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteDataSourceTable (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 deleteDataSourceTable" + ) + } + + opts = opts || {} + + if (opts.dataSourceId === undefined || opts.dataSourceId === null) { + throw new Error( + "Missing the required parameter 'opts.dataSourceId' when calling deleteDataSourceTable" + ) + } + if (opts.tableName === undefined || opts.tableName === null) { + throw new Error( + "Missing the required parameter 'opts.tableName' when calling deleteDataSourceTable" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + dataSourceId: opts.dataSourceId, + tableName: opts.tableName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 deleteDataSourceTable 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}/dataSources/{dataSourceId}/tables/{tableName}', + '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.dataSourceId - 数据源 ID + * @param {string} opts.tableName - 表-名称 + * @param {string} opts.fieldName - 字段-名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param fieldDesc fieldDesc + */ + + describeDataSourceTableField ( + 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 describeDataSourceTableField" + ) + } + + opts = opts || {} + + if (opts.dataSourceId === undefined || opts.dataSourceId === null) { + throw new Error( + "Missing the required parameter 'opts.dataSourceId' when calling describeDataSourceTableField" + ) + } + if (opts.tableName === undefined || opts.tableName === null) { + throw new Error( + "Missing the required parameter 'opts.tableName' when calling describeDataSourceTableField" + ) + } + if (opts.fieldName === undefined || opts.fieldName === null) { + throw new Error( + "Missing the required parameter 'opts.fieldName' when calling describeDataSourceTableField" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + dataSourceId: opts.dataSourceId, + tableName: opts.tableName, + fieldName: opts.fieldName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 describeDataSourceTableField 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}/dataSources/{dataSourceId}/tables/{tableName}/fields/{fieldName}', + '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.dataSourceId - 数据源 ID + * @param {string} opts.tableName - 表-名称 + * @param {string} opts.fieldName - 字段-名称 + * @param {fieldSpec} opts.fieldSpec - 配置字段需要的信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyDataSourceTableField (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 modifyDataSourceTableField" + ) + } + + opts = opts || {} + + if (opts.dataSourceId === undefined || opts.dataSourceId === null) { + throw new Error( + "Missing the required parameter 'opts.dataSourceId' when calling modifyDataSourceTableField" + ) + } + if (opts.tableName === undefined || opts.tableName === null) { + throw new Error( + "Missing the required parameter 'opts.tableName' when calling modifyDataSourceTableField" + ) + } + if (opts.fieldName === undefined || opts.fieldName === null) { + throw new Error( + "Missing the required parameter 'opts.fieldName' when calling modifyDataSourceTableField" + ) + } + if (opts.fieldSpec === undefined || opts.fieldSpec === null) { + throw new Error( + "Missing the required parameter 'opts.fieldSpec' when calling modifyDataSourceTableField" + ) + } + + let postBody = {} + if (opts.fieldSpec !== undefined && opts.fieldSpec !== null) { + postBody['fieldSpec'] = opts.fieldSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + dataSourceId: opts.dataSourceId, + tableName: opts.tableName, + fieldName: opts.fieldName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 modifyDataSourceTableField 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}/dataSources/{dataSourceId}/tables/{tableName}/fields/{fieldName}', + 'PATCH', + 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.dataSourceId - 数据源 ID + * @param {string} opts.tableName - 表-名称 + * @param {string} opts.fieldName - 字段-名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteDataSourceTableField (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 deleteDataSourceTableField" + ) + } + + opts = opts || {} + + if (opts.dataSourceId === undefined || opts.dataSourceId === null) { + throw new Error( + "Missing the required parameter 'opts.dataSourceId' when calling deleteDataSourceTableField" + ) + } + if (opts.tableName === undefined || opts.tableName === null) { + throw new Error( + "Missing the required parameter 'opts.tableName' when calling deleteDataSourceTableField" + ) + } + if (opts.fieldName === undefined || opts.fieldName === null) { + throw new Error( + "Missing the required parameter 'opts.fieldName' when calling deleteDataSourceTableField" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + dataSourceId: opts.dataSourceId, + tableName: opts.tableName, + fieldName: opts.fieldName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 deleteDataSourceTableField 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}/dataSources/{dataSourceId}/tables/{tableName}/fields/{fieldName}', + '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.dataSourceId - 数据源 ID + * @param {string} opts.tableName - 表-名称 + * @param {string} opts.fieldName - 字段-名称 + * @param {fieldTagSpec} [opts.fieldTagSpec] - 配置字段标签需要的信息 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param fieldTagDesc fieldTagDesc + */ + + modifyDataSourceTableFieldTag ( + 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 modifyDataSourceTableFieldTag" + ) + } + + opts = opts || {} + + if (opts.dataSourceId === undefined || opts.dataSourceId === null) { + throw new Error( + "Missing the required parameter 'opts.dataSourceId' when calling modifyDataSourceTableFieldTag" + ) + } + if (opts.tableName === undefined || opts.tableName === null) { + throw new Error( + "Missing the required parameter 'opts.tableName' when calling modifyDataSourceTableFieldTag" + ) + } + if (opts.fieldName === undefined || opts.fieldName === null) { + throw new Error( + "Missing the required parameter 'opts.fieldName' when calling modifyDataSourceTableFieldTag" + ) + } + + let postBody = {} + if (opts.fieldTagSpec !== undefined && opts.fieldTagSpec !== null) { + postBody['fieldTagSpec'] = opts.fieldTagSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + dataSourceId: opts.dataSourceId, + tableName: opts.tableName, + fieldName: opts.fieldName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 modifyDataSourceTableFieldTag 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}/dataSources/{dataSourceId}/tables/{tableName}/fields/{fieldName}/tag', + 'PATCH', + 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 + * @param {integer} opts.pageSize - 分页大小;默认为10;取值范围[10, 100] + * @param {filter} [opts.filters] - "instanceId: 实例ID,字符串数组,精确匹配" +"instanceName: 实例名称,字符串,模糊匹配" + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instanceDesc list + * @param integer totalCount 总数量 + */ + + describeInstanceList (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 describeInstanceList" + ) + } + + opts = opts || {} + + if (opts.pageNumber === undefined || opts.pageNumber === null) { + throw new Error( + "Missing the required parameter 'opts.pageNumber' when calling describeInstanceList" + ) + } + if (opts.pageSize === undefined || opts.pageSize === null) { + throw new Error( + "Missing the required parameter 'opts.pageSize' when calling describeInstanceList" + ) + } + + 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 dcap/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 describeInstanceList 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}/instances', + '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 {instanceSpec} opts.instanceSpec - 创建实例的基本信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string instanceId 创建的实例ID + */ + + createInstance (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 createInstance" + ) + } + + opts = opts || {} + + if (opts.instanceSpec === undefined || opts.instanceSpec === null) { + throw new Error( + "Missing the required parameter 'opts.instanceSpec' when calling createInstance" + ) + } + + let postBody = {} + 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 dcap/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 createInstance 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}/instances', + '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 - 实例 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instanceDesc instanceDesc + */ + + 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 || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeInstance" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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}/instances/{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.instanceId - 实例 ID + * @param {string} opts.instanceName + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyInstanceName (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 modifyInstanceName" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyInstanceName" + ) + } + if (opts.instanceName === undefined || opts.instanceName === null) { + throw new Error( + "Missing the required parameter 'opts.instanceName' when calling modifyInstanceName" + ) + } + + let postBody = {} + if (opts.instanceName !== undefined && opts.instanceName !== null) { + postBody['instanceName'] = opts.instanceName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 modifyInstanceName 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}/instances/{instanceId}', + 'PATCH', + 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) + } + ) + } + + /** + * 删除实例 [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + 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 || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteInstance" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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}/instances/{instanceId}', + '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) + } + ) + } + + /** + * 设置实例的访问凭证 AK+SK + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例 ID + * @param {string} opts.accessKey + * @param {string} opts.secretKey + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + setInstanceAccessKey (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 setInstanceAccessKey" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling setInstanceAccessKey" + ) + } + if (opts.accessKey === undefined || opts.accessKey === null) { + throw new Error( + "Missing the required parameter 'opts.accessKey' when calling setInstanceAccessKey" + ) + } + if (opts.secretKey === undefined || opts.secretKey === null) { + throw new Error( + "Missing the required parameter 'opts.secretKey' when calling setInstanceAccessKey" + ) + } + + let postBody = {} + if (opts.accessKey !== undefined && opts.accessKey !== null) { + postBody['accessKey'] = opts.accessKey + } + if (opts.secretKey !== undefined && opts.secretKey !== null) { + postBody['secretKey'] = opts.secretKey + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 setInstanceAccessKey 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}/instances/{instanceId}:setAccessKey', + 'PATCH', + 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 {boolean} opts.byPassMode + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + setInstanceByPassMode (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 setInstanceByPassMode" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling setInstanceByPassMode" + ) + } + if (opts.byPassMode === undefined || opts.byPassMode === null) { + throw new Error( + "Missing the required parameter 'opts.byPassMode' when calling setInstanceByPassMode" + ) + } + + let postBody = {} + if (opts.byPassMode !== undefined && opts.byPassMode !== null) { + postBody['byPassMode'] = opts.byPassMode + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 setInstanceByPassMode 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}/instances/{instanceId}:setByPass', + 'PATCH', + 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} opts.appUuid + * @param {string} opts.appAddr + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string configuration 配置文件 + */ + + describeInstanceConfig (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 describeInstanceConfig" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeInstanceConfig" + ) + } + if (opts.appUuid === undefined || opts.appUuid === null) { + throw new Error( + "Missing the required parameter 'opts.appUuid' when calling describeInstanceConfig" + ) + } + if (opts.appAddr === undefined || opts.appAddr === null) { + throw new Error( + "Missing the required parameter 'opts.appAddr' when calling describeInstanceConfig" + ) + } + + let postBody = null + let queryParams = {} + if (opts.appUuid !== undefined && opts.appUuid !== null) { + queryParams['appUuid'] = opts.appUuid + } + if (opts.appAddr !== undefined && opts.appAddr !== null) { + queryParams['appAddr'] = opts.appAddr + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 describeInstanceConfig 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}/instances/{instanceId}:config', + '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 {integer} opts.pageNumber - 页码;默认为1 + * @param {integer} opts.pageSize - 分页大小;默认为10;取值范围[10, 100] + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param appDesc list + * @param integer totalCount 总数量 + */ + + describeAppList (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 describeAppList" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeAppList" + ) + } + if (opts.pageNumber === undefined || opts.pageNumber === null) { + throw new Error( + "Missing the required parameter 'opts.pageNumber' when calling describeAppList" + ) + } + if (opts.pageSize === undefined || opts.pageSize === null) { + throw new Error( + "Missing the required parameter 'opts.pageSize' when calling describeAppList" + ) + } + + 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 dcap/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 describeAppList 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}/instances/{instanceId}/applications', + '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白名单列表 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string list + * @param integer totalCount IP白名单数量 + */ + + describeIpWhiteList (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 describeIpWhiteList" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeIpWhiteList" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 describeIpWhiteList 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}/instances/{instanceId}/ipWhite', + '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白名单记录,CIDR 格式 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例 ID + * @param {string} opts.cidr - IP白名单记录,支持掩码 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + addIpWhiteItem (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 addIpWhiteItem" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling addIpWhiteItem" + ) + } + if (opts.cidr === undefined || opts.cidr === null) { + throw new Error( + "Missing the required parameter 'opts.cidr' when calling addIpWhiteItem" + ) + } + + let postBody = {} + if (opts.cidr !== undefined && opts.cidr !== null) { + postBody['cidr'] = opts.cidr + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 addIpWhiteItem 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}/instances/{instanceId}/ipWhite', + '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) + } + ) + } + + /** + * 删除一条IP白名单 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例 ID + * @param {string} opts.cidr - IP白名单记录,支持掩码 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteIpWhiteItem (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 deleteIpWhiteItem" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteIpWhiteItem" + ) + } + if (opts.cidr === undefined || opts.cidr === null) { + throw new Error( + "Missing the required parameter 'opts.cidr' when calling deleteIpWhiteItem" + ) + } + + let postBody = null + let queryParams = {} + if (opts.cidr !== undefined && opts.cidr !== null) { + queryParams['cidr'] = opts.cidr + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dcap/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 deleteIpWhiteItem 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}/instances/{instanceId}/ipWhite', + '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) + } + ) + } +} +module.exports = DCAP diff --git a/packages/libs/lib-jdcloud/src/repo/deploy/v1/deploy.js b/packages/libs/lib-jdcloud/src/repo/deploy/v1/deploy.js new file mode 100644 index 000000000..6ad3e37e4 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/deploy/v1/deploy.js @@ -0,0 +1,785 @@ +/* + * 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. + * + * 依赖 + * 云部署依赖相关接口 + * + * 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 = 'deploy' +Service._services[serviceId] = true + +/** + * deploy service. + * @version 1.0.0 + */ + +JDCloud.DEPLOY = class DEPLOY extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'deploy.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 批量查询应用的信息,此接口支持分页查询,默认每页20条 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 100] optional + * @param {filter} [opts.filters] - appId - 应用ID,精确匹配 +appName - 应用名,精确匹配 +platform - 部署平台,精确匹配 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param app apps + * @param number totalCount + */ + + describeApps (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 describeApps" + ) + } + + 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, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 deploy/1.0.0' + } + + 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 describeApps 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 = this.makeRequest( + '/regions/{regionId}/apps', + '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.appId - App Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param app app + */ + + describeApp (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 describeApp" + ) + } + + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling describeApp" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 deploy/1.0.0' + } + + 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 describeApp 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 = this.makeRequest( + '/regions/{regionId}/app/{appId}', + '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.groupId - 部署组ID,部署组的唯一标识 + * @param {string} [opts.desc] - 描述 optional + * @param {integer} opts.deploySource - 部署来源:1url,2云编译,3云存储 + * @param {string} [opts.deployCmd] - 部署操作 optional + * @param {integer} [opts.cmdSource] - 1使用输入的操作,2使用程序自带操作 optional + * @param {integer} [opts.cmdType] - 部署操作展示格式:1form,2ymal optional + * @param {integer} [opts.productType] - 项目类型 1tomcat,2 optional + * @param {string} [opts.downloadUrl] - 下载url optional + * @param {string} [opts.md5] - md5 optional + * @param {string} [opts.compileProject] - 云编译项目名 optional + * @param {string} [opts.compileSeries] - 云编译构建序号 optional + * @param {string} [opts.ossSpace] - 云存储空间 optional + * @param {string} [opts.ossDir] - 云存储目录 optional + * @param {integer} [opts.fileType] - 文件类型:1.tar,2.zip,3.tar.gz optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string deployId 上线单ID + */ + + createDeploy (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 createDeploy" + ) + } + + opts = opts || {} + + if (opts.groupId === undefined || opts.groupId === null) { + throw new Error( + "Missing the required parameter 'opts.groupId' when calling createDeploy" + ) + } + if (opts.deploySource === undefined || opts.deploySource === null) { + throw new Error( + "Missing the required parameter 'opts.deploySource' when calling createDeploy" + ) + } + + let postBody = {} + if (opts.groupId !== undefined && opts.groupId !== null) { + postBody['groupId'] = opts.groupId + } + if (opts.desc !== undefined && opts.desc !== null) { + postBody['desc'] = opts.desc + } + if (opts.deploySource !== undefined && opts.deploySource !== null) { + postBody['deploySource'] = opts.deploySource + } + if (opts.deployCmd !== undefined && opts.deployCmd !== null) { + postBody['deployCmd'] = opts.deployCmd + } + if (opts.cmdSource !== undefined && opts.cmdSource !== null) { + postBody['cmdSource'] = opts.cmdSource + } + if (opts.cmdType !== undefined && opts.cmdType !== null) { + postBody['cmdType'] = opts.cmdType + } + if (opts.productType !== undefined && opts.productType !== null) { + postBody['productType'] = opts.productType + } + if (opts.downloadUrl !== undefined && opts.downloadUrl !== null) { + postBody['downloadUrl'] = opts.downloadUrl + } + if (opts.md5 !== undefined && opts.md5 !== null) { + postBody['md5'] = opts.md5 + } + if (opts.compileProject !== undefined && opts.compileProject !== null) { + postBody['compileProject'] = opts.compileProject + } + if (opts.compileSeries !== undefined && opts.compileSeries !== null) { + postBody['compileSeries'] = opts.compileSeries + } + if (opts.ossSpace !== undefined && opts.ossSpace !== null) { + postBody['ossSpace'] = opts.ossSpace + } + if (opts.ossDir !== undefined && opts.ossDir !== null) { + postBody['ossDir'] = opts.ossDir + } + if (opts.fileType !== undefined && opts.fileType !== null) { + postBody['fileType'] = opts.fileType + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 deploy/1.0.0' + } + + 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 createDeploy 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 = this.makeRequest( + '/regions/{regionId}/deploy', + '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.deployId - Deploy Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param deploy deploy + */ + + describeDeploy (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 describeDeploy" + ) + } + + opts = opts || {} + + if (opts.deployId === undefined || opts.deployId === null) { + throw new Error( + "Missing the required parameter 'opts.deployId' when calling describeDeploy" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + deployId: opts.deployId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 deploy/1.0.0' + } + + 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 describeDeploy 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 = this.makeRequest( + '/regions/{regionId}/deploy/{deployId}', + '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) + } + ) + } + + /** + * 批量查询部署组的信息,此接口支持分页查询,默认每页20条 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 100] optional + * @param {filter} [opts.filters] - appId - 应用ID,精确匹配 +groupId - 部署组ID,精确匹配 +groupName - 部署组名,精确匹配 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param group groups + * @param number totalCount + */ + + describeGroups (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 describeGroups" + ) + } + + 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, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 deploy/1.0.0' + } + + 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 describeGroups 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 = this.makeRequest( + '/regions/{regionId}/groups', + '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.groupId - Group Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param group group + */ + + describeGroup (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 describeGroup" + ) + } + + opts = opts || {} + + if (opts.groupId === undefined || opts.groupId === null) { + throw new Error( + "Missing the required parameter 'opts.groupId' when calling describeGroup" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + groupId: opts.groupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 deploy/1.0.0' + } + + 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 describeGroup 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 = this.makeRequest( + '/regions/{regionId}/group/{groupId}', + '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 = JDCloud.DEPLOY diff --git a/packages/libs/lib-jdcloud/src/repo/detection/v2/detection.js b/packages/libs/lib-jdcloud/src/repo/detection/v2/detection.js new file mode 100644 index 000000000..01441e09a --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/detection/v2/detection.js @@ -0,0 +1,2401 @@ +/* + * 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. + * + * SiteMonitor APIs + * 站点监控相关接口,提供创建、查询、修改、删除站点监控等功能 + * + * 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 = 'detection' +Service._services[serviceId] = true + +/** + * detection service. + * @version 2.0.1 + */ + +JDCloud.DETECTION = class DETECTION extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'detection.jdcloud-api.com' + options.basePath = '/v2' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询可用性监控agent状态 + * @param {Object} opts - parameters + * @param {filter} [opts.filters] - agent id列表 +uuid - agent id,精确匹配,支持多个 optional + * @param {string} callback - callback + @return {Object} result + * @param agentStatus items + */ + + describeAgentStatus (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + Object.assign(queryParams, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 detection/2.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 describeAgentStatus 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 = this.makeRequest( + '/amAgentStatus', + '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.resourceId - 资源的uuid + * @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] - 时间间隔:1h,6h,12h,1d,3d,7d,14d,固定时间间隔,timeInterval 与 endTime 至少填一项 optional + * @param {string} callback - callback + @return {Object} result + * @param metricData metricDatas + */ + + describeMetricDataAm (opts, callback) { + opts = opts || {} + + if (opts.resourceId === undefined || opts.resourceId === null) { + throw new Error( + "Missing the required parameter 'opts.resourceId' when calling describeMetricDataAm" + ) + } + + let postBody = null + let queryParams = {} + 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 + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 detection/2.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 describeMetricDataAm 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 = this.makeRequest( + '/amMetricData', + '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位 + * @param {createProbeTaskParam} opts.createProbeTaskSpec + * @param {string} callback - callback + @return {Object} result + * @param boolean suc 是否创建成功 + * @param string taskId 创建成功的规则id列表 + */ + + createProbeTask (opts, callback) { + opts = opts || {} + + if (opts.clientToken === undefined || opts.clientToken === null) { + throw new Error( + "Missing the required parameter 'opts.clientToken' when calling createProbeTask" + ) + } + if ( + opts.createProbeTaskSpec === undefined || + opts.createProbeTaskSpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.createProbeTaskSpec' when calling createProbeTask" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if ( + opts.createProbeTaskSpec !== undefined && + opts.createProbeTaskSpec !== null + ) { + postBody['createProbeTaskSpec'] = opts.createProbeTaskSpec + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 detection/2.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 createProbeTask 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 = this.makeRequest( + '/probeTask', + '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.probeTaskIDs - 探测任务的task_id,多个taskId用|分隔 + * @param {string} callback - callback + @return {Object} result + * @param boolean suc 可用性监控任务是否删除成功 + */ + + deleteProbeTask (opts, callback) { + opts = opts || {} + + if (opts.probeTaskIDs === undefined || opts.probeTaskIDs === null) { + throw new Error( + "Missing the required parameter 'opts.probeTaskIDs' when calling deleteProbeTask" + ) + } + + let postBody = null + let queryParams = {} + if (opts.probeTaskIDs !== undefined && opts.probeTaskIDs !== null) { + queryParams['probeTaskIDs'] = opts.probeTaskIDs + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 detection/2.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 deleteProbeTask 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 = this.makeRequest( + '/probeTask', + '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.probeTaskID - 探测任务的task_id + * @param {string} callback - callback + @return {Object} result + * @param probe probes + * @param string address 探测地址 + * @param string createTime 创建时间 + * @param boolean deleted 是否被删除 + * @param boolean enable 是否启用 + * @param integer frequency 探测频率,单位秒 + * @param string httpBody http探测的body + * @param keyValue httpCookie + * @param keyValue httpHeader + * @param integer httpType http探测方式 + * @param string name 探测任务 名称 + * @param string pin pin + * @param integer port 探测端口 + * @param integer probeType 探测类型1:http、2:telnet + * @param string targetId 探测对象的uid(http探测方法无uid) + * @param string targetRegion 探测对象所在region,redis或RDS所在region + * @param string taskId 探测任务 id + * @param integer taskType 任务类型、1:url/ip、2:RDS、3:redis + * @param integer timeout 探测超时时间,单位秒 + * @param string updateTime 更新时间 + */ + + describeProbeTask (opts, callback) { + opts = opts || {} + + if (opts.probeTaskID === undefined || opts.probeTaskID === null) { + throw new Error( + "Missing the required parameter 'opts.probeTaskID' when calling describeProbeTask" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + probeTaskID: opts.probeTaskID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 detection/2.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 describeProbeTask 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 = this.makeRequest( + '/probeTask/{probeTaskID}', + '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.probeTaskID - 探测任务的task_id + * @param {string} [opts.httpBody] - http body:选择探测类型为1=http时有效,最长不超过1024字节 optional + * @param {array} [opts.httpCookie] - http cookie:选择探测类型为1=http时有效,最大允许20个key、value对,最长不超过1024字节 optional + * @param {array} [opts.httpHeader] - http header:选择探测类型为1=http时有效,最大允许20个key、value对,最长不超过1024字节 optional + * @param {integer} [opts.httpType] - http探测方法,可选值:1:get、2:post、3:head optional + * @param {string} [opts.name] - task名称,不允许重复,长度不超过32字符,只允许中英文、数字、下划线_、中划线-, [0-9][a-z] [A-Z] [- _ ] optional + * @param {array} [opts.probes] - 探测源(发起对探测目标探测的云主机,需安装相应的agent才能探测) optional + * @param {string} callback - callback + @return {Object} result + * @param boolean suc 是否更新成功 + */ + + updateProbeTask (opts, callback) { + opts = opts || {} + + if (opts.probeTaskID === undefined || opts.probeTaskID === null) { + throw new Error( + "Missing the required parameter 'opts.probeTaskID' when calling updateProbeTask" + ) + } + + let postBody = {} + if (opts.httpBody !== undefined && opts.httpBody !== null) { + postBody['httpBody'] = opts.httpBody + } + if (opts.httpCookie !== undefined && opts.httpCookie !== null) { + postBody['httpCookie'] = opts.httpCookie + } + if (opts.httpHeader !== undefined && opts.httpHeader !== null) { + postBody['httpHeader'] = opts.httpHeader + } + if (opts.httpType !== undefined && opts.httpType !== null) { + postBody['httpType'] = opts.httpType + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.probes !== undefined && opts.probes !== null) { + postBody['probes'] = opts.probes + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + probeTaskID: opts.probeTaskID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 detection/2.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 updateProbeTask 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 = this.makeRequest( + '/probeTask/{probeTaskID}', + 'PATCH', + 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.probeTaskID - 可用性监控task_id, id长度(0,50] + * @param {string} opts.probeID - 探测源id, id长度(0,50] + * @param {string} [opts.startTime] - 查询时间范围的开始时间, UTC时间,格式:2016-12-11T00:00:00+0800(默认为当前时间往前三天,早于3d时,将被重置为3d)(注意在url中+要转译为%2B故url中为2016-12-11T00:00:00%2B0800) optional + * @param {string} [opts.endTime] - 查询时间范围的结束时间, UTC时间,格式:2016-12-11T00:00:00+0800(为空时,默认为当前时间)(注意在url中+要转译为%2B故url中为2016-12-11T00:00:00%2B0800) optional + * @param {string} callback - callback + @return {Object} result + * @param event events + * @param string name 探测源名称 + * @param string uuid 探测源uuid + */ + + describeProbeHistory (opts, callback) { + opts = opts || {} + + if (opts.probeTaskID === undefined || opts.probeTaskID === null) { + throw new Error( + "Missing the required parameter 'opts.probeTaskID' when calling describeProbeHistory" + ) + } + if (opts.probeID === undefined || opts.probeID === null) { + throw new Error( + "Missing the required parameter 'opts.probeID' when calling describeProbeHistory" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: 'jdcloud', + probeTaskID: opts.probeTaskID, + probeID: opts.probeID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 detection/2.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 describeProbeHistory 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 = this.makeRequest( + '/probeTask/{probeTaskID}/probe/{probeID}', + '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.probeTaskID - 探测任务的task_id + * @param {filter} [opts.filters] - 自定义标签 optional + * @param {string} callback - callback + @return {Object} result + * @param probeInfo probeList + */ + + discribeProbes (opts, callback) { + opts = opts || {} + + if (opts.probeTaskID === undefined || opts.probeTaskID === null) { + throw new Error( + "Missing the required parameter 'opts.probeTaskID' when calling discribeProbes" + ) + } + + let postBody = null + let queryParams = {} + Object.assign(queryParams, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: 'jdcloud', + probeTaskID: opts.probeTaskID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 detection/2.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 discribeProbes 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 = this.makeRequest( + '/probeTask/{probeTaskID}/probeList', + '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 {boolean} [opts.enabled] - 默认:禁用; true:启用,false:禁用 optional + * @param {array} [opts.taskId] - 要启用或禁用的探测任务的task_id列表,列表长度[1,100) optional + * @param {string} callback - callback + @return {Object} result + * @param boolean suc 可用性监控任务 【启用|禁用】 是否成功 + */ + + probeTaskEnable (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.enabled !== undefined && opts.enabled !== null) { + postBody['enabled'] = opts.enabled + } + if (opts.taskId !== undefined && opts.taskId !== null) { + postBody['taskId'] = opts.taskId + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 detection/2.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 probeTaskEnable 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 = this.makeRequest( + '/probeTask:switch', + '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.pageNumber] - 当前所在页,默认为1 optional + * @param {integer} [opts.pageSize] - 页面大小,默认为20;取值范围[1, 100] optional + * @param {string} [opts.name] - 根据探测任务的名称查询,支持模糊查询 optional + * @param {integer} [opts.type] - 根据探测任务的类型查询,1、http 2、telnet optional + * @param {string} [opts.timeInterval] - 查询的可用率、响应时间的时间间隔,为空时默认查询最新点,最大不超过30天,支持分钟级别,小时级别,天级别,例如:1m、1h、1d optional + * @param {boolean} [opts.withStats] - 是否查询可用率、响应时间 optional + * @param {boolean} [opts.withDeleted] - 是否包含被删除的task optional + * @param {integer} [opts.enabled] - 任务状态:1为启用,0为禁用。默认为查所有的 optional + * @param {filter} [opts.filters] - taskId - taskId,精确匹配,支持多个 +name - task名称或探测地址,糊模匹配,支持单个 optional + * @param {string} callback - callback + @return {Object} result + * @param integer numberPages 总页数 + * @param integer numberRecords 总记录数 + * @param integer pageNumber 当前页码 + * @param integer pageSize 分页大小 + * @param taskInfo taskInfo + * @param integer totalCount 该用户的总task个数,不受查询的筛选条件影响 + */ + + describeProbeTasks (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 + } + if (opts.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + if (opts.type !== undefined && opts.type !== null) { + queryParams['type'] = opts.type + } + if (opts.timeInterval !== undefined && opts.timeInterval !== null) { + queryParams['timeInterval'] = opts.timeInterval + } + if (opts.withStats !== undefined && opts.withStats !== null) { + queryParams['withStats'] = opts.withStats + } + if (opts.withDeleted !== undefined && opts.withDeleted !== null) { + queryParams['withDeleted'] = opts.withDeleted + } + if (opts.enabled !== undefined && opts.enabled !== null) { + queryParams['enabled'] = opts.enabled + } + Object.assign(queryParams, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 detection/2.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 describeProbeTasks 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 = this.makeRequest( + '/probeTaskList', + '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.nameOrAddr] optional + * @param {string} [opts.name] optional + * @param {string} [opts.taskType] optional + * @param {integer} [opts.pageNumber] optional + * @param {integer} [opts.pageSize] optional + * @param {string} [opts.withStats] optional + * @param {string} [opts.withDeleted] - 1:包含删除对象,默认:0 optional + * @param {string} [opts.timeInterval] - 查询的可用率、响应时间的时间间隔,最大不超过30天,支持分钟级别,小时级别,天级别,例如:1m、1h、1d optional + * @param {filter} [opts.filters] - name为'id' - 站点监控id optional + * @param {string} [opts.id] optional + * @param {string} callback - callback + @return {Object} result + * @param siteMonitor list + * @param integer total + */ + + getSiteMonitor (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.nameOrAddr !== undefined && opts.nameOrAddr !== null) { + queryParams['nameOrAddr'] = opts.nameOrAddr + } + if (opts.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + if (opts.taskType !== undefined && opts.taskType !== null) { + queryParams['taskType'] = opts.taskType + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + queryParams['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.withStats !== undefined && opts.withStats !== null) { + queryParams['withStats'] = opts.withStats + } + if (opts.withDeleted !== undefined && opts.withDeleted !== null) { + queryParams['withDeleted'] = opts.withDeleted + } + if (opts.timeInterval !== undefined && opts.timeInterval !== null) { + queryParams['timeInterval'] = opts.timeInterval + } + Object.assign(queryParams, this.buildFilterParam(opts.filters, 'filters')) + Object.assign(queryParams, this.buildArrayParam(opts.id, 'id')) + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 detection/2.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 getSiteMonitor 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 = this.makeRequest( + '/siteMonitor', + '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.address - 地址 + * @param {string} [opts.advanceChecked] optional + * @param {integer} [opts.createdTime] optional + * @param {integer} opts.cycle - 探测频率 + * @param {string} [opts.defaultSource] optional + * @param {siteMonitorDnsOption} [opts.dnsOption] optional + * @param {string} [opts.enabled] optional + * @param {siteMonitorFtpOption} [opts.ftpOption] optional + * @param {integer} [opts.hawkeyeId] optional + * @param {siteMonitorHttpOption} [opts.httpOption] optional + * @param {string} [opts.id] optional + * @param {string} [opts.isDeleted] optional + * @param {string} opts.name - 任务名称 + * @param {string} [opts.pin] optional + * @param {siteMonitorPingOption} [opts.pingOption] optional + * @param {siteMonitorPop3Option} [opts.pop3Option] optional + * @param {string} [opts.port] - 端口 optional + * @param {siteMonitorSmtpOption} [opts.smtpOption] optional + * @param {array} [opts.source] - 探测源 optional + * @param {object} [opts.stats] optional + * @param {string} opts.taskType - 任务类型,可选值:HTTP、PING 、TCP 、UDP、DNS、SMTP、POP3和FTP + * @param {siteMonitorTcpOption} [opts.tcpOption] optional + * @param {siteMonitorUdpOption} [opts.udpOption] optional + * @param {integer} [opts.updatedTime] optional + * @param {string} callback - callback + @return {Object} result + * @param string id + */ + + createSiteMonitor (opts, callback) { + opts = opts || {} + + if (opts.address === undefined || opts.address === null) { + throw new Error( + "Missing the required parameter 'opts.address' when calling createSiteMonitor" + ) + } + if (opts.cycle === undefined || opts.cycle === null) { + throw new Error( + "Missing the required parameter 'opts.cycle' when calling createSiteMonitor" + ) + } + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createSiteMonitor" + ) + } + if (opts.taskType === undefined || opts.taskType === null) { + throw new Error( + "Missing the required parameter 'opts.taskType' when calling createSiteMonitor" + ) + } + + let postBody = {} + if (opts.address !== undefined && opts.address !== null) { + postBody['address'] = opts.address + } + if (opts.advanceChecked !== undefined && opts.advanceChecked !== null) { + postBody['advanceChecked'] = opts.advanceChecked + } + if (opts.createdTime !== undefined && opts.createdTime !== null) { + postBody['createdTime'] = opts.createdTime + } + if (opts.cycle !== undefined && opts.cycle !== null) { + postBody['cycle'] = opts.cycle + } + if (opts.defaultSource !== undefined && opts.defaultSource !== null) { + postBody['defaultSource'] = opts.defaultSource + } + if (opts.dnsOption !== undefined && opts.dnsOption !== null) { + postBody['dnsOption'] = opts.dnsOption + } + if (opts.enabled !== undefined && opts.enabled !== null) { + postBody['enabled'] = opts.enabled + } + if (opts.ftpOption !== undefined && opts.ftpOption !== null) { + postBody['ftpOption'] = opts.ftpOption + } + if (opts.hawkeyeId !== undefined && opts.hawkeyeId !== null) { + postBody['hawkeyeId'] = opts.hawkeyeId + } + if (opts.httpOption !== undefined && opts.httpOption !== null) { + postBody['httpOption'] = opts.httpOption + } + if (opts.id !== undefined && opts.id !== null) { + postBody['id'] = opts.id + } + if (opts.isDeleted !== undefined && opts.isDeleted !== null) { + postBody['isDeleted'] = opts.isDeleted + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.pin !== undefined && opts.pin !== null) { + postBody['pin'] = opts.pin + } + if (opts.pingOption !== undefined && opts.pingOption !== null) { + postBody['pingOption'] = opts.pingOption + } + if (opts.pop3Option !== undefined && opts.pop3Option !== null) { + postBody['pop3Option'] = opts.pop3Option + } + if (opts.port !== undefined && opts.port !== null) { + postBody['port'] = opts.port + } + if (opts.smtpOption !== undefined && opts.smtpOption !== null) { + postBody['smtpOption'] = opts.smtpOption + } + if (opts.source !== undefined && opts.source !== null) { + postBody['source'] = opts.source + } + if (opts.stats !== undefined && opts.stats !== null) { + postBody['stats'] = opts.stats + } + if (opts.taskType !== undefined && opts.taskType !== null) { + postBody['taskType'] = opts.taskType + } + if (opts.tcpOption !== undefined && opts.tcpOption !== null) { + postBody['tcpOption'] = opts.tcpOption + } + if (opts.udpOption !== undefined && opts.udpOption !== null) { + postBody['udpOption'] = opts.udpOption + } + if (opts.updatedTime !== undefined && opts.updatedTime !== null) { + postBody['updatedTime'] = opts.updatedTime + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 detection/2.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 createSiteMonitor 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 = this.makeRequest( + '/siteMonitor', + '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.address - 地址 + * @param {string} [opts.advanceChecked] optional + * @param {integer} [opts.createdTime] optional + * @param {integer} opts.cycle - 探测频率 + * @param {string} [opts.defaultSource] optional + * @param {siteMonitorDnsOption} [opts.dnsOption] optional + * @param {string} [opts.enabled] optional + * @param {siteMonitorFtpOption} [opts.ftpOption] optional + * @param {integer} [opts.hawkeyeId] optional + * @param {siteMonitorHttpOption} [opts.httpOption] optional + * @param {string} [opts.id] optional + * @param {string} [opts.isDeleted] optional + * @param {string} opts.name - 任务名称 + * @param {string} [opts.pin] optional + * @param {siteMonitorPingOption} [opts.pingOption] optional + * @param {siteMonitorPop3Option} [opts.pop3Option] optional + * @param {string} [opts.port] - 端口 optional + * @param {siteMonitorSmtpOption} [opts.smtpOption] optional + * @param {array} [opts.source] - 探测源 optional + * @param {object} [opts.stats] optional + * @param {string} opts.taskType - 任务类型,可选值:HTTP、PING 、TCP 、UDP、DNS、SMTP、POP3和FTP + * @param {siteMonitorTcpOption} [opts.tcpOption] optional + * @param {siteMonitorUdpOption} [opts.udpOption] optional + * @param {integer} [opts.updatedTime] optional + * @param {string} callback - callback + @return {Object} result + * @param boolean suc + */ + + updateSiteMonitor (opts, callback) { + opts = opts || {} + + if (opts.address === undefined || opts.address === null) { + throw new Error( + "Missing the required parameter 'opts.address' when calling updateSiteMonitor" + ) + } + if (opts.cycle === undefined || opts.cycle === null) { + throw new Error( + "Missing the required parameter 'opts.cycle' when calling updateSiteMonitor" + ) + } + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling updateSiteMonitor" + ) + } + if (opts.taskType === undefined || opts.taskType === null) { + throw new Error( + "Missing the required parameter 'opts.taskType' when calling updateSiteMonitor" + ) + } + + let postBody = {} + if (opts.address !== undefined && opts.address !== null) { + postBody['address'] = opts.address + } + if (opts.advanceChecked !== undefined && opts.advanceChecked !== null) { + postBody['advanceChecked'] = opts.advanceChecked + } + if (opts.createdTime !== undefined && opts.createdTime !== null) { + postBody['createdTime'] = opts.createdTime + } + if (opts.cycle !== undefined && opts.cycle !== null) { + postBody['cycle'] = opts.cycle + } + if (opts.defaultSource !== undefined && opts.defaultSource !== null) { + postBody['defaultSource'] = opts.defaultSource + } + if (opts.dnsOption !== undefined && opts.dnsOption !== null) { + postBody['dnsOption'] = opts.dnsOption + } + if (opts.enabled !== undefined && opts.enabled !== null) { + postBody['enabled'] = opts.enabled + } + if (opts.ftpOption !== undefined && opts.ftpOption !== null) { + postBody['ftpOption'] = opts.ftpOption + } + if (opts.hawkeyeId !== undefined && opts.hawkeyeId !== null) { + postBody['hawkeyeId'] = opts.hawkeyeId + } + if (opts.httpOption !== undefined && opts.httpOption !== null) { + postBody['httpOption'] = opts.httpOption + } + if (opts.id !== undefined && opts.id !== null) { + postBody['id'] = opts.id + } + if (opts.isDeleted !== undefined && opts.isDeleted !== null) { + postBody['isDeleted'] = opts.isDeleted + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.pin !== undefined && opts.pin !== null) { + postBody['pin'] = opts.pin + } + if (opts.pingOption !== undefined && opts.pingOption !== null) { + postBody['pingOption'] = opts.pingOption + } + if (opts.pop3Option !== undefined && opts.pop3Option !== null) { + postBody['pop3Option'] = opts.pop3Option + } + if (opts.port !== undefined && opts.port !== null) { + postBody['port'] = opts.port + } + if (opts.smtpOption !== undefined && opts.smtpOption !== null) { + postBody['smtpOption'] = opts.smtpOption + } + if (opts.source !== undefined && opts.source !== null) { + postBody['source'] = opts.source + } + if (opts.stats !== undefined && opts.stats !== null) { + postBody['stats'] = opts.stats + } + if (opts.taskType !== undefined && opts.taskType !== null) { + postBody['taskType'] = opts.taskType + } + if (opts.tcpOption !== undefined && opts.tcpOption !== null) { + postBody['tcpOption'] = opts.tcpOption + } + if (opts.udpOption !== undefined && opts.udpOption !== null) { + postBody['udpOption'] = opts.udpOption + } + if (opts.updatedTime !== undefined && opts.updatedTime !== null) { + postBody['updatedTime'] = opts.updatedTime + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 detection/2.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 updateSiteMonitor 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 = this.makeRequest( + '/siteMonitor', + '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) + } + ) + } + + /** + * 删除站点监控任务 + * @param {Object} opts - parameters + * @param {filter} [opts.filters] - name为'list' - 站点监控id optional + * @param {string} callback - callback + @return {Object} result + * @param boolean suc + */ + + deleteSiteMonitor (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + Object.assign(queryParams, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 detection/2.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 deleteSiteMonitor 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 = this.makeRequest( + '/siteMonitor', + '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 {array} [opts.list] optional + * @param {string} callback - callback + @return {Object} result + * @param boolean suc + */ + + enableSiteMonitor (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.list !== undefined && opts.list !== null) { + postBody['list'] = opts.list + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 detection/2.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 enableSiteMonitor 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 = this.makeRequest( + '/siteMonitor:switch', + '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) + } + ) + } + + /** + * 检测站点监控地址是否有效 + * @param {Object} opts - parameters + * @param {string} [opts.address] optional + * @param {string} callback - callback + @return {Object} result + * @param boolean suc + */ + + validateSiteMonitorAddress (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.address !== undefined && opts.address !== null) { + queryParams['address'] = opts.address + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 detection/2.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 validateSiteMonitorAddress 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 = this.makeRequest( + '/siteMonitorAddress:validate', + '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.id] optional + * @param {string} [opts.startTime] optional + * @param {string} [opts.endTime] optional + * @param {string} callback - callback + @return {Object} result + * @param statsItem metricData + * @param statsItem resTime + * @param statsItem successRatio + */ + + getSiteMonitorDataPoints (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.id !== undefined && opts.id !== null) { + queryParams['id'] = opts.id + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 detection/2.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 getSiteMonitorDataPoints 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 = this.makeRequest( + '/siteMonitorDataPoints', + '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} callback - callback + @return {Object} result + * @param ispLocation all + * @param ispLocation limited + */ + + getSiteMonitorSource (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 detection/2.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 getSiteMonitorSource 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 = this.makeRequest( + '/siteMonitorSource', + '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.address - 地址 + * @param {string} [opts.advanceChecked] optional + * @param {integer} [opts.createdTime] optional + * @param {integer} opts.cycle - 探测频率 + * @param {string} [opts.defaultSource] optional + * @param {siteMonitorDnsOption} [opts.dnsOption] optional + * @param {string} [opts.enabled] optional + * @param {siteMonitorFtpOption} [opts.ftpOption] optional + * @param {integer} [opts.hawkeyeId] optional + * @param {siteMonitorHttpOption} [opts.httpOption] optional + * @param {string} [opts.id] optional + * @param {string} [opts.isDeleted] optional + * @param {string} opts.name - 任务名称 + * @param {string} [opts.pin] optional + * @param {siteMonitorPingOption} [opts.pingOption] optional + * @param {siteMonitorPop3Option} [opts.pop3Option] optional + * @param {string} [opts.port] - 端口 optional + * @param {siteMonitorSmtpOption} [opts.smtpOption] optional + * @param {array} [opts.source] - 探测源 optional + * @param {object} [opts.stats] optional + * @param {string} opts.taskType - 任务类型,可选值:HTTP、PING 、TCP 、UDP、DNS、SMTP、POP3和FTP + * @param {siteMonitorTcpOption} [opts.tcpOption] optional + * @param {siteMonitorUdpOption} [opts.udpOption] optional + * @param {integer} [opts.updatedTime] optional + * @param {string} callback - callback + @return {Object} result + * @param string error 错误信息 + * @param string msg 提示信息 + * @param integer status 状态码 + */ + + testSiteMonitor (opts, callback) { + opts = opts || {} + + if (opts.address === undefined || opts.address === null) { + throw new Error( + "Missing the required parameter 'opts.address' when calling testSiteMonitor" + ) + } + if (opts.cycle === undefined || opts.cycle === null) { + throw new Error( + "Missing the required parameter 'opts.cycle' when calling testSiteMonitor" + ) + } + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling testSiteMonitor" + ) + } + if (opts.taskType === undefined || opts.taskType === null) { + throw new Error( + "Missing the required parameter 'opts.taskType' when calling testSiteMonitor" + ) + } + + let postBody = {} + if (opts.address !== undefined && opts.address !== null) { + postBody['address'] = opts.address + } + if (opts.advanceChecked !== undefined && opts.advanceChecked !== null) { + postBody['advanceChecked'] = opts.advanceChecked + } + if (opts.createdTime !== undefined && opts.createdTime !== null) { + postBody['createdTime'] = opts.createdTime + } + if (opts.cycle !== undefined && opts.cycle !== null) { + postBody['cycle'] = opts.cycle + } + if (opts.defaultSource !== undefined && opts.defaultSource !== null) { + postBody['defaultSource'] = opts.defaultSource + } + if (opts.dnsOption !== undefined && opts.dnsOption !== null) { + postBody['dnsOption'] = opts.dnsOption + } + if (opts.enabled !== undefined && opts.enabled !== null) { + postBody['enabled'] = opts.enabled + } + if (opts.ftpOption !== undefined && opts.ftpOption !== null) { + postBody['ftpOption'] = opts.ftpOption + } + if (opts.hawkeyeId !== undefined && opts.hawkeyeId !== null) { + postBody['hawkeyeId'] = opts.hawkeyeId + } + if (opts.httpOption !== undefined && opts.httpOption !== null) { + postBody['httpOption'] = opts.httpOption + } + if (opts.id !== undefined && opts.id !== null) { + postBody['id'] = opts.id + } + if (opts.isDeleted !== undefined && opts.isDeleted !== null) { + postBody['isDeleted'] = opts.isDeleted + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.pin !== undefined && opts.pin !== null) { + postBody['pin'] = opts.pin + } + if (opts.pingOption !== undefined && opts.pingOption !== null) { + postBody['pingOption'] = opts.pingOption + } + if (opts.pop3Option !== undefined && opts.pop3Option !== null) { + postBody['pop3Option'] = opts.pop3Option + } + if (opts.port !== undefined && opts.port !== null) { + postBody['port'] = opts.port + } + if (opts.smtpOption !== undefined && opts.smtpOption !== null) { + postBody['smtpOption'] = opts.smtpOption + } + if (opts.source !== undefined && opts.source !== null) { + postBody['source'] = opts.source + } + if (opts.stats !== undefined && opts.stats !== null) { + postBody['stats'] = opts.stats + } + if (opts.taskType !== undefined && opts.taskType !== null) { + postBody['taskType'] = opts.taskType + } + if (opts.tcpOption !== undefined && opts.tcpOption !== null) { + postBody['tcpOption'] = opts.tcpOption + } + if (opts.udpOption !== undefined && opts.udpOption !== null) { + postBody['udpOption'] = opts.udpOption + } + if (opts.updatedTime !== undefined && opts.updatedTime !== null) { + postBody['updatedTime'] = opts.updatedTime + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 detection/2.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 testSiteMonitor 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 = this.makeRequest( + '/testSiteMonitor', + '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 = JDCloud.DETECTION diff --git a/packages/libs/lib-jdcloud/src/repo/detection/v3/detection.js b/packages/libs/lib-jdcloud/src/repo/detection/v3/detection.js new file mode 100644 index 000000000..ae4a19774 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/detection/v3/detection.js @@ -0,0 +1,855 @@ +/* + * 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. + * + * Task related APIs + * 云拔测-任务相关接口 + * + * OpenAPI spec version: v3 + * 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 = 'detection' +Service._services[serviceId] = true + +/** + * detection service. + * @version 3.0.0 + */ + +class DETECTION extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'detection.jdcloud-api.com' + options.basePath = '/v3' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询任务列表 + * @param {Object} opts - parameters + * @param {integer} [opts.taskId] - 任务Id optional + * @param {string} [opts.taskName] - 任务名称 模糊匹配 optional + * @param {string} [opts.taskUrl] - 任务地址 模糊匹配 optional + * @param {integer} [opts.taskType] - 任务类型 1、协议 2、网络 optional + * @param {integer} [opts.protocolType] - 协议类型 1、TCP 2、UDP 3、SMTP 4、HTTP_HTTPS 5、FTP optional + * @param {integer} [opts.taskClassify] - 任务类别 1、定时拨测 2、即时拨测 默认定时拨测 optional + * @param {integer} [opts.taskGroupId] - 任务组ID optional + * @param {integer} opts.pageIndex - 当前页码 需大于等于1 + * @param {integer} opts.pageSize - 每页大小 取值范围1到100 + * @param {integer} [opts.status] - 任务状态 0开启 1禁用 optional + * @param {string} callback - callback + @return {Object} result + * @param boolean success + * @param string message + * @param integer total + * @param task data + */ + + queryTasks (opts, callback) { + opts = opts || {} + + if (opts.pageIndex === undefined || opts.pageIndex === null) { + throw new Error( + "Missing the required parameter 'opts.pageIndex' when calling queryTasks" + ) + } + if (opts.pageSize === undefined || opts.pageSize === null) { + throw new Error( + "Missing the required parameter 'opts.pageSize' when calling queryTasks" + ) + } + + let postBody = null + let queryParams = {} + if (opts.taskId !== undefined && opts.taskId !== null) { + queryParams['taskId'] = opts.taskId + } + if (opts.taskName !== undefined && opts.taskName !== null) { + queryParams['taskName'] = opts.taskName + } + if (opts.taskUrl !== undefined && opts.taskUrl !== null) { + queryParams['taskUrl'] = opts.taskUrl + } + if (opts.taskType !== undefined && opts.taskType !== null) { + queryParams['taskType'] = opts.taskType + } + if (opts.protocolType !== undefined && opts.protocolType !== null) { + queryParams['protocolType'] = opts.protocolType + } + if (opts.taskClassify !== undefined && opts.taskClassify !== null) { + queryParams['taskClassify'] = opts.taskClassify + } + if (opts.taskGroupId !== undefined && opts.taskGroupId !== null) { + queryParams['taskGroupId'] = opts.taskGroupId + } + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 detection/3.0.0' + } + + 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 queryTasks 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( + '/tasks', + '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.taskId - 任务Id + * @param {integer} opts.startTime - 开始时间 时间戳 需小于当前时间 + * @param {integer} opts.endTime - 结束时间 时间戳 需大于开始时间 + * @param {integer} opts.pageIndex - 当前页码 需大于等于1 + * @param {integer} opts.pageSize - 每页大小 取值范围1到500 + * @param {integer} [opts.status] - 结果状态 0成功 1失败 optional + * @param {string} callback - callback + @return {Object} result + * @param boolean success + * @param string message + * @param integer total + * @param net data + */ + + queryNetworkMonitorResults (opts, callback) { + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling queryNetworkMonitorResults" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling queryNetworkMonitorResults" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling queryNetworkMonitorResults" + ) + } + if (opts.pageIndex === undefined || opts.pageIndex === null) { + throw new Error( + "Missing the required parameter 'opts.pageIndex' when calling queryNetworkMonitorResults" + ) + } + if (opts.pageSize === undefined || opts.pageSize === null) { + throw new Error( + "Missing the required parameter 'opts.pageSize' when calling queryNetworkMonitorResults" + ) + } + + let postBody = null + let queryParams = {} + if (opts.taskId !== undefined && opts.taskId !== null) { + queryParams['taskId'] = opts.taskId + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 detection/3.0.0' + } + + 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 queryNetworkMonitorResults 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( + '/netMonitorResult', + '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.taskId - 任务Id + * @param {integer} opts.startTime - 开始时间 时间戳 需小于当前时间 + * @param {integer} opts.endTime - 结束时间 时间戳 需大于开始时间 + * @param {integer} opts.pageIndex - 当前页码 需大于等于1 + * @param {integer} opts.pageSize - 每页大小 取值范围1到500 + * @param {integer} [opts.status] - 结果状态 0成功 1失败 optional + * @param {string} callback - callback + @return {Object} result + * @param boolean success + * @param string message + * @param integer total + * @param protocol data + */ + + queryProtocolMonitorResults (opts, callback) { + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling queryProtocolMonitorResults" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling queryProtocolMonitorResults" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling queryProtocolMonitorResults" + ) + } + if (opts.pageIndex === undefined || opts.pageIndex === null) { + throw new Error( + "Missing the required parameter 'opts.pageIndex' when calling queryProtocolMonitorResults" + ) + } + if (opts.pageSize === undefined || opts.pageSize === null) { + throw new Error( + "Missing the required parameter 'opts.pageSize' when calling queryProtocolMonitorResults" + ) + } + + let postBody = null + let queryParams = {} + if (opts.taskId !== undefined && opts.taskId !== null) { + queryParams['taskId'] = opts.taskId + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 detection/3.0.0' + } + + 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 queryProtocolMonitorResults 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( + '/protocolMonitorResult', + '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.taskId - 任务Id + * @param {integer} opts.startTime - 开始时间 时间戳 需小于当前时间 + * @param {integer} opts.endTime - 结束时间 时间戳 需大于开始时间 + * @param {integer} [opts.duration] - 数据点间隔时间(分钟),可选5/10/15/30/60/120/180/240/300/480/720,默认为任务调度周期,需大于任务调度周期 optional + * @param {string} callback - callback + @return {Object} result + * @param boolean success + * @param string message + * @param protocolMetric data + */ + + queryProtocolAvgMetrics (opts, callback) { + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling queryProtocolAvgMetrics" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling queryProtocolAvgMetrics" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling queryProtocolAvgMetrics" + ) + } + + let postBody = null + let queryParams = {} + if (opts.taskId !== undefined && opts.taskId !== null) { + queryParams['taskId'] = opts.taskId + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.duration !== undefined && opts.duration !== null) { + queryParams['duration'] = opts.duration + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 detection/3.0.0' + } + + 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 queryProtocolAvgMetrics 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( + '/protocolAvgMetrics', + '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.taskId - 任务Id + * @param {integer} opts.startTime - 开始时间 时间戳 需小于当前时间 + * @param {integer} opts.endTime - 结束时间 时间戳 需大于开始时间 + * @param {integer} [opts.duration] - 数据点间隔时间(分钟),可选5/10/15/30/60/120/180/240/300/480/720,默认为任务调度周期,需大于任务调度周期 optional + * @param {string} callback - callback + @return {Object} result + * @param boolean success + * @param string message + * @param netMetric data + */ + + queryNetworkAvgMetrics (opts, callback) { + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling queryNetworkAvgMetrics" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling queryNetworkAvgMetrics" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling queryNetworkAvgMetrics" + ) + } + + let postBody = null + let queryParams = {} + if (opts.taskId !== undefined && opts.taskId !== null) { + queryParams['taskId'] = opts.taskId + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.duration !== undefined && opts.duration !== null) { + queryParams['duration'] = opts.duration + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 detection/3.0.0' + } + + 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 queryNetworkAvgMetrics 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( + '/netAvgMetrics', + '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.taskId - 任务Id + * @param {integer} opts.startTime - 开始时间 时间戳 需小于当前时间 + * @param {integer} opts.endTime - 结束时间 时间戳 需大于开始时间 + * @param {integer} [opts.duration] - 数据点间隔时间(分钟),可选5/10/15/30/60/120/180/240/300/480/720,默认为任务调度周期,需大于任务调度周期 optional + * @param {string} callback - callback + @return {Object} result + * @param boolean success + * @param string message + * @param successRateMetric data + */ + + querySuccessRateMetric (opts, callback) { + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling querySuccessRateMetric" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling querySuccessRateMetric" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling querySuccessRateMetric" + ) + } + + let postBody = null + let queryParams = {} + if (opts.taskId !== undefined && opts.taskId !== null) { + queryParams['taskId'] = opts.taskId + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.duration !== undefined && opts.duration !== null) { + queryParams['duration'] = opts.duration + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 detection/3.0.0' + } + + 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 querySuccessRateMetric 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( + '/successRateMetric', + '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 = DETECTION diff --git a/packages/libs/lib-jdcloud/src/repo/dh/v1/dh.js b/packages/libs/lib-jdcloud/src/repo/dh/v1/dh.js new file mode 100644 index 000000000..efc34603c --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/dh/v1/dh.js @@ -0,0 +1,1268 @@ +/* + * 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. + * + * Quota + * 与配额相关的接口 + * + * 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 = 'dh' +Service._services[serviceId] = true + +/** + * dh service. + * @version 1.1.3 + */ + +class DH extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'dh.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询专有宿主机列表。<br> +此接口支持分页查询,默认每页20条。 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 100] optional + * @param {filter} [opts.filters] - dedicatedHostId - 专有宿主机ID,精确匹配,支持多个 +az - 可用区,精确匹配,支持多个 +status - 专有宿主机状态,精确匹配,支持多个,<a href="http://docs.jdcloud.com/dedicated-hosts/api/dh_status">参考专有宿主机状态</a> +name - 专有宿主机名称,模糊匹配,支持单个 +dedicatedPoolId - 专有宿主机池ID,精确匹配,支持多个 +dedicatedHostType - 专有宿主机机型,精确匹配,支持多个 + optional + * @param {tagFilter} [opts.tags] - Tag筛选条件。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dedicatedHost dedicatedHosts + * @param number totalCount + */ + + describeDedicatedHosts (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 describeDedicatedHosts" + ) + } + + 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')) + Object.assign(queryParams, super.buildTagFilterParam(opts.tags, 'tags')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dh/1.1.3' + } + + 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 describeDedicatedHosts 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}/dedicatedHosts', + '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> +创建专有宿主机必须指定专有宿主机池。 + + * @param {Object} opts - parameters + * @param {dedicatedHostSpec} opts.dedicatedHostSpec - 描述专有宿主机配置 + + * @param {string} [opts.deployPolicy] - 是否支持AZ内专有宿主机强制均衡,默认为preferred--非强制,取值[preferred--非强制,required--强制] + optional + * @param {integer} [opts.maxCount] - 购买云主机的数量;取值范围:[1,100],默认为1。 + optional + * @param {string} [opts.clientToken] - 用于保证请求的幂等性。由客户端生成,长度不能超过64个字符。 + optional + * @param {boolean} [opts.enableCpuTopology] - 是否开启cpu拓扑,true:开启,false:关闭,只有宿主机是非超卖模式,且没有资源的时候才能开启;开启后,该宿主机上的虚机可以配置cpu拓扑和NUMA映射等。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string dedicatedHostIds + */ + + allocDedicatedHosts (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 allocDedicatedHosts" + ) + } + + opts = opts || {} + + if ( + opts.dedicatedHostSpec === undefined || + opts.dedicatedHostSpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.dedicatedHostSpec' when calling allocDedicatedHosts" + ) + } + + let postBody = {} + if ( + opts.dedicatedHostSpec !== undefined && + opts.dedicatedHostSpec !== null + ) { + postBody['dedicatedHostSpec'] = opts.dedicatedHostSpec + } + if (opts.deployPolicy !== undefined && opts.deployPolicy !== null) { + postBody['deployPolicy'] = opts.deployPolicy + } + if (opts.maxCount !== undefined && opts.maxCount !== null) { + postBody['maxCount'] = opts.maxCount + } + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if ( + opts.enableCpuTopology !== undefined && + opts.enableCpuTopology !== null + ) { + postBody['enableCpuTopology'] = opts.enableCpuTopology + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dh/1.1.3' + } + + 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 allocDedicatedHosts 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}/dedicatedHosts', + '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>available</b>、不可用<b>unavailable</b>、维护中<b>under-assessment</b>,同时专有宿主机上必须没有云主机实例才可删除。<br> + [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.dedicatedHostId - 专有宿主机ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + releaseDedicatedHost (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 releaseDedicatedHost" + ) + } + + opts = opts || {} + + if (opts.dedicatedHostId === undefined || opts.dedicatedHostId === null) { + throw new Error( + "Missing the required parameter 'opts.dedicatedHostId' when calling releaseDedicatedHost" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + dedicatedHostId: opts.dedicatedHostId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dh/1.1.3' + } + + 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 releaseDedicatedHost 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}/dedicatedHost/{dedicatedHostId}', + '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.dedicatedHostId - 专有宿主机ID + * @param {string} [opts.name] - 名称,<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a>。 optional + * @param {string} [opts.description] - 描述,<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a>。 optional + * @param {boolean} [opts.enableCpuTopology] - 是否开启cpu拓扑,true:开启,false:关闭,只有宿主机是非超卖模式,且没有资源的时候才能开启;开启后,该宿主机上的虚机可以配置cpu拓扑和NUMA映射等。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyDedicatedHostAttribute ( + 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 modifyDedicatedHostAttribute" + ) + } + + opts = opts || {} + + if (opts.dedicatedHostId === undefined || opts.dedicatedHostId === null) { + throw new Error( + "Missing the required parameter 'opts.dedicatedHostId' when calling modifyDedicatedHostAttribute" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if ( + opts.enableCpuTopology !== undefined && + opts.enableCpuTopology !== null + ) { + postBody['enableCpuTopology'] = opts.enableCpuTopology + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + dedicatedHostId: opts.dedicatedHostId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dh/1.1.3' + } + + 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 modifyDedicatedHostAttribute 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}/dedicatedHost/{dedicatedHostId}:modifyAttribute', + '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 {filter} [opts.filters] - dedicatedHostType - 专有宿主机机型,精确匹配,支持多个 +az - 可用区,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param hostType dedicatedHostTypes + * @param number totalCount + */ + + describeDedicatedHostType (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 describeDedicatedHostType" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dh/1.1.3' + } + + 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 describeDedicatedHostType 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}/dedicatedHostType', + '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 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 100] optional + * @param {filter} [opts.filters] - dedicatedPoolId - 专有宿主机池ID,精确匹配,支持多个 +name - 专有宿主机名称,模糊匹配,支持单个 +dedicatedHostType - 专有宿主机机型,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dedicatedPool dedicatedPools + * @param number totalCount + */ + + describeDedicatedPools (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 describeDedicatedPools" + ) + } + + 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 dh/1.1.3' + } + + 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 describeDedicatedPools 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}/dedicatedPools', + '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> +专有宿主机池为专有宿主机的集合,为用户提供独享且跨机架的宿主机资源池,基于资源独享及故障隔离实现业务安全、高可用部署。<br> +申请宿主机池需要指定机器类型,目前每一个专有宿主机池只能指定一种机器类型。可供选用的机器类型有通用性,内存性,高频计算型及GPU型。<br> +deployPolicy表示是否强制池中专有宿主机在每个AZ内数量均衡。可选值为prefered和required,默认为prefered。 + + * @param {Object} opts - parameters + * @param {string} [opts.dedicatedHostType] - 支持的专有宿主机机型,每个专有宿主机池只能且必须指定一个专有宿主机机型 + optional + * @param {string} [opts.name] - 专有宿主机池名称 + optional + * @param {array} [opts.az] - 指定专有宿主机池支持的可用区,可指定多个。 + optional + * @param {string} [opts.description] - 专有宿主机池的描述信息。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string dedicatedPoolId + */ + + allocDedicatedPool (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 allocDedicatedPool" + ) + } + + opts = opts || {} + + let postBody = {} + if ( + opts.dedicatedHostType !== undefined && + opts.dedicatedHostType !== null + ) { + postBody['dedicatedHostType'] = opts.dedicatedHostType + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.az !== undefined && opts.az !== null) { + postBody['az'] = opts.az + } + 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 dh/1.1.3' + } + + 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 allocDedicatedPool 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}/dedicatedPools', + '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.dedicatedPoolId - 专有宿主机ID + * @param {string} [opts.name] - 名称,<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a>。 optional + * @param {string} [opts.description] - 描述,<a href="http://docs.jdcloud.com/virtual-machines/api/general_parameters">参考公共参数规范</a>。 optional + * @param {array} [opts.az] - 指定宿主机池申请专有宿主机时默认继承的可用区。<br> +修改可用区时旧可用区必须是新可用区的子集,即可用区只能添加,不能减少。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyDedicatedPoolAttribute ( + 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 modifyDedicatedPoolAttribute" + ) + } + + opts = opts || {} + + if (opts.dedicatedPoolId === undefined || opts.dedicatedPoolId === null) { + throw new Error( + "Missing the required parameter 'opts.dedicatedPoolId' when calling modifyDedicatedPoolAttribute" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.az !== undefined && opts.az !== null) { + postBody['az'] = opts.az + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + dedicatedPoolId: opts.dedicatedPoolId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dh/1.1.3' + } + + 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 modifyDedicatedPoolAttribute 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}/dedicatedPool/{dedicatedPoolId}:modifyAttribute', + '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> +专有宿主机池中必须没有专有宿主机时才可释放。 + [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.dedicatedPoolId - 专有宿主机ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + releaseDedicatedPool (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 releaseDedicatedPool" + ) + } + + opts = opts || {} + + if (opts.dedicatedPoolId === undefined || opts.dedicatedPoolId === null) { + throw new Error( + "Missing the required parameter 'opts.dedicatedPoolId' when calling releaseDedicatedPool" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + dedicatedPoolId: opts.dedicatedPoolId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dh/1.1.3' + } + + 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 releaseDedicatedPool 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}/dedicatedPool/{dedicatedPoolId}', + '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 {filter} [opts.filters] - resourceTypes - 资源类型,支持多个[dedicatedHost,dedicatedPool] + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param quota quotas + */ + + describeQuotas (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 describeQuotas" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dh/1.1.3' + } + + 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 describeQuotas 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}/dhQuotas', + '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 = DH diff --git a/packages/libs/lib-jdcloud/src/repo/disk/v1/disk.js b/packages/libs/lib-jdcloud/src/repo/disk/v1/disk.js new file mode 100644 index 000000000..99707cc6c --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/disk/v1/disk.js @@ -0,0 +1,3273 @@ +/* + * 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. + * + * 售罄相关接口 + * 查询售罄情况 + * + * 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 = 'disk' +Service._services[serviceId] = true + +/** + * disk service. + * @version 0.12.8 + */ + +class DISK extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'disk.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * - 查询您已经创建的云硬盘。 +- filters多个过滤条件之间是逻辑与(AND),每个条件内部的多个取值是逻辑或(OR) + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞) optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {filter} [opts.filters] - diskId - 云硬盘ID,精确匹配,支持多个 +diskType - 云硬盘类型,精确匹配,支持多个,取值为 ssd,premium-hdd,ssd.io1,ssd.gp1,hdd.std1 +instanceId - 云硬盘所挂载主机的ID,精确匹配,支持多个 +instanceType - 云硬盘所挂载主机的类型,精确匹配,支持多个 +status - 云硬盘状态,精确匹配,支持多个 +az - 可用区,精确匹配,支持多个 +name - 云硬盘名称,模糊匹配,支持单个 +multiAttach - 云硬盘是否多点挂载,精确匹配,支持单个 +encrypted - 云硬盘是否加密,精确匹配,支持单个 +policyId - 绑定policyId的云硬盘,精确匹配,支持多个 +notPolicyId - 未绑定policyId的云硬盘,精确匹配,支持多个 + optional + * @param {tagFilter} [opts.tags] - Tag筛选条件 optional + * @param {sort} [opts.orders] - name - 排序字段,只支持create_time和trash_time字段 +direction - 排序规则 + optional + * @param {string} [opts.resourceGroupIds] - 资源组筛选条件 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param disk disks + * @param integer totalCount 查询的云硬盘数目 + */ + + describeDisks (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 describeDisks" + ) + } + + 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')) + Object.assign(queryParams, super.buildTagFilterParam(opts.tags, 'tags')) + Object.assign(queryParams, super.buildSortParam(opts.orders, 'orders')) + Object.assign( + queryParams, + super.buildArrayParam(opts.resourceGroupIds, 'resourceGroupIds') + ) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 disk/0.12.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 describeDisks 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}/disks', + '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) + } + ) + } + + /** + * - 创建一块或多块按配置或者按使用时长付费的云硬盘。 +- 云硬盘类型包括高效云盘(premium-hdd)、SSD云盘(ssd)、通用型SSD(ssd.gp1)、性能型SSD(ssd.io1)、容量型HDD(hdd.std1)。 +- 计费方式默认为按配置付费。 +- 创建完成后,云硬盘状态为 available。 +- 可选参数快照 ID用于从快照创建新盘。 +- 批量创建时,云硬盘的命名为 硬盘名称-数字,例如 myDisk-1,myDisk-2。 +- maxCount为最大努力,不保证一定能达到maxCount。 +- userTags 为创建云盘时打的标签 + + * @param {Object} opts - parameters + * @param {diskSpec} opts.diskSpec - 创建云硬盘规格 + * @param {integer} opts.maxCount - 购买实例数量;取值范围:[1,100] + * @param {array} [opts.userTags] - 用户标签,默认为空;tag标签的限制:每个资源最多允许绑定 10 个不同的标签,同一资源每个标签“键”上只能存在1个标签“值”;标签键/值只支持中文、数字、大小写字母、空格及特殊符号_.:/=+-@;当无tags时,reps结果返回中tagmsg为空 optional + * @param {string} opts.clientToken - 幂等性校验参数 + * @param {string} [opts.resourceGroupId] - 资源组ID optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param policyDiskRelationOpResult policyRelations + * @param string diskIds + * @param string tagmsg 标签结果信息 + */ + + createDisks (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 createDisks" + ) + } + + opts = opts || {} + + if (opts.diskSpec === undefined || opts.diskSpec === null) { + throw new Error( + "Missing the required parameter 'opts.diskSpec' when calling createDisks" + ) + } + if (opts.maxCount === undefined || opts.maxCount === null) { + throw new Error( + "Missing the required parameter 'opts.maxCount' when calling createDisks" + ) + } + if (opts.clientToken === undefined || opts.clientToken === null) { + throw new Error( + "Missing the required parameter 'opts.clientToken' when calling createDisks" + ) + } + + let postBody = {} + if (opts.diskSpec !== undefined && opts.diskSpec !== null) { + postBody['diskSpec'] = opts.diskSpec + } + if (opts.maxCount !== undefined && opts.maxCount !== null) { + postBody['maxCount'] = opts.maxCount + } + if (opts.userTags !== undefined && opts.userTags !== null) { + postBody['userTags'] = opts.userTags + } + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.resourceGroupId !== undefined && opts.resourceGroupId !== null) { + postBody['resourceGroupId'] = opts.resourceGroupId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 disk/0.12.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 createDisks 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}/disks', + '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.diskId - 云硬盘ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param disk disk + */ + + describeDisk (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 describeDisk" + ) + } + + opts = opts || {} + + if (opts.diskId === undefined || opts.diskId === null) { + throw new Error( + "Missing the required parameter 'opts.diskId' when calling describeDisk" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + diskId: opts.diskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 disk/0.12.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 describeDisk 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}/disks/{diskId}', + '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.diskId - 云硬盘ID + * @param {string} [opts.name] - 云硬盘名称,只允许输入中文、数字、大小写字母、英文下划线“_”及中划线“-”,不允许为空且不超过32字符。 optional + * @param {string} [opts.description] - 云硬盘描述,允许输入UTF-8编码下的全部字符,不超过256字符。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyDiskAttribute (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 modifyDiskAttribute" + ) + } + + opts = opts || {} + + if (opts.diskId === undefined || opts.diskId === null) { + throw new Error( + "Missing the required parameter 'opts.diskId' when calling modifyDiskAttribute" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + diskId: opts.diskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 disk/0.12.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 modifyDiskAttribute 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}/disks/{diskId}', + 'PATCH', + 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) + } + ) + } + + /** + * - 删除一块按配置计费的云硬盘,云盘类型包括高效云盘、SSD云盘、通用型SSD、性能型SSD和容量型HDD。 +- 删除云盘时,云盘的状态必须为 待挂载(Available)。 +- 云盘被删除后,云硬盘快照可以被保留。 + + * @param {Object} opts - parameters + * @param {string} opts.diskId - 云硬盘ID + * @param {boolean} [opts.putInRecycleBin] - true 加入回收站 false 或者不传直接删除 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteDisk (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 deleteDisk" + ) + } + + opts = opts || {} + + if (opts.diskId === undefined || opts.diskId === null) { + throw new Error( + "Missing the required parameter 'opts.diskId' when calling deleteDisk" + ) + } + + let postBody = null + let queryParams = {} + if (opts.putInRecycleBin !== undefined && opts.putInRecycleBin !== null) { + queryParams['putInRecycleBin'] = opts.putInRecycleBin + } + + let pathParams = { + regionId: regionId, + diskId: opts.diskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 disk/0.12.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 deleteDisk 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}/disks/{diskId}', + '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.diskId - 云硬盘ID + * @param {string} opts.snapshotId - 用于恢复云盘的快照ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + restoreDisk (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 restoreDisk" + ) + } + + opts = opts || {} + + if (opts.diskId === undefined || opts.diskId === null) { + throw new Error( + "Missing the required parameter 'opts.diskId' when calling restoreDisk" + ) + } + if (opts.snapshotId === undefined || opts.snapshotId === null) { + throw new Error( + "Missing the required parameter 'opts.snapshotId' when calling restoreDisk" + ) + } + + let postBody = {} + if (opts.snapshotId !== undefined && opts.snapshotId !== null) { + postBody['snapshotId'] = opts.snapshotId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + diskId: opts.diskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 disk/0.12.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 restoreDisk 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}/disks/{diskId}:restore', + '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) + } + ) + } + + /** + * - 扩容云硬盘到指定大小,云硬盘状态必须为 available。 +- 当云硬盘正在创建快照时,不允许扩容。 + + * @param {Object} opts - parameters + * @param {string} opts.diskId - 云硬盘ID + * @param {integer} opts.diskSizeGB - 扩容后的云硬盘大小,单位为GiB + * @param {integer} [opts.iops] - 修改ssd.io1型云硬盘的iops数量,当且仅当ssd.io1型的云盘类型有效,步长是10; 默认iops为云硬盘原有iops值 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + extendDisk (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 extendDisk" + ) + } + + opts = opts || {} + + if (opts.diskId === undefined || opts.diskId === null) { + throw new Error( + "Missing the required parameter 'opts.diskId' when calling extendDisk" + ) + } + if (opts.diskSizeGB === undefined || opts.diskSizeGB === null) { + throw new Error( + "Missing the required parameter 'opts.diskSizeGB' when calling extendDisk" + ) + } + + let postBody = {} + if (opts.diskSizeGB !== undefined && opts.diskSizeGB !== null) { + postBody['diskSizeGB'] = opts.diskSizeGB + } + if (opts.iops !== undefined && opts.iops !== null) { + postBody['iops'] = opts.iops + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + diskId: opts.diskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 disk/0.12.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 extendDisk 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}/disks/{diskId}:extend', + '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) + } + ) + } + + /** + * - 查询您已经创建的云硬盘。 +- filters多个过滤条件之间是逻辑与(AND),每个条件内部的多个取值是逻辑或(OR) + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞) optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {array} [opts.tags] - Tag筛选条件 optional + * @param {array} [opts.filterGroups] - diskId - 云硬盘ID,精确匹配,支持多个 +diskType - 云硬盘类型,精确匹配,支持多个,取值为 ssd,premium-hdd,ssd.io1,ssd.gp1,hdd.std1 +instanceId - 云硬盘所挂载主机的ID,精确匹配,支持多个 +instanceType - 云硬盘所挂载主机的类型,精确匹配,支持多个 +status - 可用区,精确匹配,支持多个 +az - 云硬盘状态,精确匹配,支持多个 +name - 云硬盘名称,模糊匹配,支持单个 +multiAttach - 云硬盘是否多点挂载,精确匹配,支持单个 +encrypted - 云硬盘是否加密,精确匹配,支持单个 +policyId - 绑定policyId的云硬盘,精确匹配,支持多个 +notPolicyId - 未绑定policyId的云硬盘,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param disk disks + * @param integer totalCount 查询的云硬盘数目 + */ + + describeVolumesIgnoreServiceCode ( + 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 describeVolumesIgnoreServiceCode" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + if (opts.tags !== undefined && opts.tags !== null) { + postBody['tags'] = opts.tags + } + if (opts.filterGroups !== undefined && opts.filterGroups !== null) { + postBody['filterGroups'] = opts.filterGroups + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 disk/0.12.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 describeVolumesIgnoreServiceCode 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}/disks:ignoreServiceCode', + '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) + } + ) + } + + /** + * - 从回收站中恢复云盘,云盘的状态必须为in-recyclebin。 + + * @param {Object} opts - parameters + * @param {string} opts.diskId - 云硬盘ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + recoverDisk (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 recoverDisk" + ) + } + + opts = opts || {} + + if (opts.diskId === undefined || opts.diskId === null) { + throw new Error( + "Missing the required parameter 'opts.diskId' when calling recoverDisk" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + diskId: opts.diskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 disk/0.12.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 recoverDisk 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}/disks/{diskId}:recover', + '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.type - 资源类型 disk:用户能创建的云盘的配额 snapshot: 用户能创建的快照的配额 snapshot_policy: 用户能创建的快照策略的配额 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param quota quota + */ + + describeQuota (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 describeQuota" + ) + } + + opts = opts || {} + + if (opts.type === undefined || opts.type === null) { + throw new Error( + "Missing the required parameter 'opts.type' when calling describeQuota" + ) + } + + let postBody = null + let queryParams = {} + if (opts.type !== undefined && opts.type !== null) { + queryParams['type'] = opts.type + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 disk/0.12.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 describeQuota 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}/quotas', + '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) + } + ) + } + + /** + * 查询云硬盘快照列表,filters多个过滤条件之间是逻辑与(AND),每个条件内部的多个取值是逻辑或(OR) + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞) optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {string} [opts.snapshotSource] - 查找快照的类型,可以为private,others,shared,默认为private optional + * @param {filter} [opts.filters] - snapshotId - 云硬盘快照ID,支持多个 +diskId - 生成快照的云硬盘ID,支持多个 +status - 快照状态,精确匹配,支持多个,取值为 creating、available、copying、deleting、error_create、error_delete +name - 快照名称,模糊匹配,支持单个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param snapshot snapshots + * @param integer totalCount 查询的快照数目 + */ + + describeSnapshots (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 describeSnapshots" + ) + } + + 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.snapshotSource !== undefined && opts.snapshotSource !== null) { + queryParams['snapshotSource'] = opts.snapshotSource + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 disk/0.12.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 describeSnapshots 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}/snapshots', + '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) + } + ) + } + + /** + * - 为指定云硬盘创建快照,新生成的快照的状态为creating。 +- 同一地域下单用户快照的配额为15块。 +- 为保证数据完整性,请您在创建快照之前,停止对云硬盘进行写入操作,以保证快照数据的完整性。 +- 在执行创建快照前,建议您对云硬盘进行卸载操作,创建快照后再重新挂载到云主机上。 +- 手动快照的生命周期独立于云硬盘,请您及时删除不需要的快照。 +- 创建快照所需时间取决于云硬盘容量的大小,云硬盘容量越大耗时越长。 + + * @param {Object} opts - parameters + * @param {snapshotSpec} opts.snapshotSpec - 创建快照规格 + * @param {string} opts.clientToken - 幂等性校验参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string snapshotId 创建的快照ID + */ + + createSnapshot (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 createSnapshot" + ) + } + + opts = opts || {} + + if (opts.snapshotSpec === undefined || opts.snapshotSpec === null) { + throw new Error( + "Missing the required parameter 'opts.snapshotSpec' when calling createSnapshot" + ) + } + if (opts.clientToken === undefined || opts.clientToken === null) { + throw new Error( + "Missing the required parameter 'opts.clientToken' when calling createSnapshot" + ) + } + + let postBody = {} + if (opts.snapshotSpec !== undefined && opts.snapshotSpec !== null) { + postBody['snapshotSpec'] = opts.snapshotSpec + } + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 disk/0.12.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 createSnapshot 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}/snapshots', + '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) + } + ) + } + + /** + * - 删除云硬盘快照:快照状态必须为 available 或 error 状态。 +- 快照独立于云硬盘生命周期,删除快照不会对创建快照的云硬盘有任何影响。 +- 快照删除后不可恢复,请谨慎操作。 + + * @param {Object} opts - parameters + * @param {string} [opts.snapshotIds] - 快照ID列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param delSnapshot snapshots + * @param integer successCount 删除快照成功的数量 + * @param integer failedCount 删除快照成功的数量 + */ + + deleteSnapshots (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 deleteSnapshots" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + Object.assign( + queryParams, + super.buildArrayParam(opts.snapshotIds, 'snapshotIds') + ) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 disk/0.12.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 deleteSnapshots 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}/snapshots', + '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.snapshotId - 快照ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param snapshot snapshot + */ + + describeSnapshot (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 describeSnapshot" + ) + } + + opts = opts || {} + + if (opts.snapshotId === undefined || opts.snapshotId === null) { + throw new Error( + "Missing the required parameter 'opts.snapshotId' when calling describeSnapshot" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + snapshotId: opts.snapshotId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 disk/0.12.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 describeSnapshot 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}/snapshots/{snapshotId}', + '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.snapshotId - 快照ID + * @param {string} [opts.name] - 快照名称 optional + * @param {string} [opts.description] - 快照描述 optional + * @param {string} [opts.expireTime] - 快照过期时间,三者至少指定一个 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifySnapshotAttribute (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 modifySnapshotAttribute" + ) + } + + opts = opts || {} + + if (opts.snapshotId === undefined || opts.snapshotId === null) { + throw new Error( + "Missing the required parameter 'opts.snapshotId' when calling modifySnapshotAttribute" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.expireTime !== undefined && opts.expireTime !== null) { + postBody['expireTime'] = opts.expireTime + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + snapshotId: opts.snapshotId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 disk/0.12.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 modifySnapshotAttribute 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}/snapshots/{snapshotId}', + 'PATCH', + 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) + } + ) + } + + /** + * - 删除单个云硬盘快照:快照状态必须为 available 或 error 状态。 +- 快照独立于云硬盘生命周期,删除快照不会对创建快照的云硬盘有任何影响。 +- 快照删除后不可恢复,请谨慎操作。 + + * @param {Object} opts - parameters + * @param {string} opts.snapshotId - 快照ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteSnapshot (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 deleteSnapshot" + ) + } + + opts = opts || {} + + if (opts.snapshotId === undefined || opts.snapshotId === null) { + throw new Error( + "Missing the required parameter 'opts.snapshotId' when calling deleteSnapshot" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + snapshotId: opts.snapshotId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 disk/0.12.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 deleteSnapshot 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}/snapshots/{snapshotId}', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param snapshotCapacity capacities + */ + + describeSnapshotsCapacity (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 describeSnapshotsCapacity" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 disk/0.12.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 describeSnapshotsCapacity 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}/snapshots:capacity', + '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.diskId] - 云硬盘ID optional + * @param {string} [opts.snapshotId] - 快照ID optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param object snapshotChain + */ + + describeSnapshotChain (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 describeSnapshotChain" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.diskId !== undefined && opts.diskId !== null) { + queryParams['diskId'] = opts.diskId + } + if (opts.snapshotId !== undefined && opts.snapshotId !== null) { + queryParams['snapshotId'] = opts.snapshotId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 disk/0.12.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 describeSnapshotChain 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}/snapshots:chain', + '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.name - 策略名称 + * @param {integer} opts.interval - 策略执行周期,单位:秒,不小于12小时 + * @param {string} opts.effectiveTime - 策略生效时间,格式`YYYY-MM-DDTHH:mm:ss+xx:xx`。如`2020-02-02T20:02:00+08:00` + * @param {integer} opts.snapshotLifecycle - 快照保留时间,单位:秒,0:表示不删除 + * @param {contactInfo} [opts.contactInfo] - 联系人信息 optional + * @param {integer} opts.status - 策略状态。1:启用 2:禁用 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string id 是否发送短信。0:不发送 1:发送 + * @param string name 是否发送短信。0:不发送 1:发送 + * @param string pin 用户pin + * @param integer interval 策略执行间隔,单位:秒 + * @param string effectiveTime 策略生效时间。格式`YYYY-MM-DDTHH:mm:ss+xx:xx`。如`2020-02-02T20:02:00+08:00` + * @param string lastTriggerTime 策略上次执行时间。格式`YYYY-MM-DDTHH:mm:ss+xx:xx`。如`2020-02-02T20:02:00+08:00` + * @param string nextTriggerTime 策略下次执行时间。格式`YYYY-MM-DDTHH:mm:ss+xx:xx`。如`2020-02-02T20:02:00+08:00` + * @param integer snapshotLifecycle 快照保留时间。单位:秒。0:永久保留 + * @param contactInfo contactInfo 联系人信息 + * @param string createTime 策略下次执行时间。格式`YYYY-MM-DDTHH:mm:ss+xx:xx`。如`2020-02-02T20:02:00+08:00` + * @param string updateTime 策略下次执行时间。格式`YYYY-MM-DDTHH:mm:ss+xx:xx`。如`2020-02-02T20:02:00+08:00` + * @param integer status 策略状态。1:启用 2:禁用 + * @param integer diskCount 策略绑定的disk数量 + */ + + createSnapshotPolicy (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 createSnapshotPolicy" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createSnapshotPolicy" + ) + } + if (opts.interval === undefined || opts.interval === null) { + throw new Error( + "Missing the required parameter 'opts.interval' when calling createSnapshotPolicy" + ) + } + if (opts.effectiveTime === undefined || opts.effectiveTime === null) { + throw new Error( + "Missing the required parameter 'opts.effectiveTime' when calling createSnapshotPolicy" + ) + } + if ( + opts.snapshotLifecycle === undefined || + opts.snapshotLifecycle === null + ) { + throw new Error( + "Missing the required parameter 'opts.snapshotLifecycle' when calling createSnapshotPolicy" + ) + } + if (opts.status === undefined || opts.status === null) { + throw new Error( + "Missing the required parameter 'opts.status' when calling createSnapshotPolicy" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.interval !== undefined && opts.interval !== null) { + postBody['interval'] = opts.interval + } + if (opts.effectiveTime !== undefined && opts.effectiveTime !== null) { + postBody['effectiveTime'] = opts.effectiveTime + } + if ( + opts.snapshotLifecycle !== undefined && + opts.snapshotLifecycle !== null + ) { + postBody['snapshotLifecycle'] = opts.snapshotLifecycle + } + if (opts.contactInfo !== undefined && opts.contactInfo !== null) { + postBody['contactInfo'] = opts.contactInfo + } + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 disk/0.12.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 createSnapshotPolicy 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}/snapshotPolicy', + '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.policyId - 策略ID + * @param {string} opts.name - 策略名称 + * @param {integer} opts.interval - 策略执行周期,单位:秒,不小于12小时 + * @param {string} opts.effectiveTime - 策略生效时间,格式`YYYY-MM-DDTHH:mm:ss+xx:xx`。如`2020-02-02T20:02:00+08:00` + * @param {integer} opts.snapshotLifecycle - 快照保留时间,单位:秒,0:表示不删除 + * @param {contactInfo} [opts.contactInfo] - 联系人信息 optional + * @param {integer} opts.status - 策略状态。1:启用 2:禁用 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string id 是否发送短信。0:不发送 1:发送 + * @param string name 是否发送短信。0:不发送 1:发送 + * @param string pin 用户pin + * @param integer interval 策略执行间隔,单位:秒 + * @param string effectiveTime 策略生效时间。格式`YYYY-MM-DDTHH:mm:ss+xx:xx`。如`2020-02-02T20:02:00+08:00` + * @param string lastTriggerTime 策略上次执行时间。格式`YYYY-MM-DDTHH:mm:ss+xx:xx`。如`2020-02-02T20:02:00+08:00` + * @param string nextTriggerTime 策略下次执行时间。格式`YYYY-MM-DDTHH:mm:ss+xx:xx`。如`2020-02-02T20:02:00+08:00` + * @param integer snapshotLifecycle 快照保留时间。单位:秒。0:永久保留 + * @param contactInfo contactInfo 联系人信息 + * @param string createTime 策略下次执行时间。格式`YYYY-MM-DDTHH:mm:ss+xx:xx`。如`2020-02-02T20:02:00+08:00` + * @param string updateTime 策略下次执行时间。格式`YYYY-MM-DDTHH:mm:ss+xx:xx`。如`2020-02-02T20:02:00+08:00` + * @param integer status 策略状态。1:启用 2:禁用 + * @param integer diskCount 策略绑定的disk数量 + */ + + updateSnapshotPolicy (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 updateSnapshotPolicy" + ) + } + + opts = opts || {} + + if (opts.policyId === undefined || opts.policyId === null) { + throw new Error( + "Missing the required parameter 'opts.policyId' when calling updateSnapshotPolicy" + ) + } + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling updateSnapshotPolicy" + ) + } + if (opts.interval === undefined || opts.interval === null) { + throw new Error( + "Missing the required parameter 'opts.interval' when calling updateSnapshotPolicy" + ) + } + if (opts.effectiveTime === undefined || opts.effectiveTime === null) { + throw new Error( + "Missing the required parameter 'opts.effectiveTime' when calling updateSnapshotPolicy" + ) + } + if ( + opts.snapshotLifecycle === undefined || + opts.snapshotLifecycle === null + ) { + throw new Error( + "Missing the required parameter 'opts.snapshotLifecycle' when calling updateSnapshotPolicy" + ) + } + if (opts.status === undefined || opts.status === null) { + throw new Error( + "Missing the required parameter 'opts.status' when calling updateSnapshotPolicy" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.interval !== undefined && opts.interval !== null) { + postBody['interval'] = opts.interval + } + if (opts.effectiveTime !== undefined && opts.effectiveTime !== null) { + postBody['effectiveTime'] = opts.effectiveTime + } + if ( + opts.snapshotLifecycle !== undefined && + opts.snapshotLifecycle !== null + ) { + postBody['snapshotLifecycle'] = opts.snapshotLifecycle + } + if (opts.contactInfo !== undefined && opts.contactInfo !== null) { + postBody['contactInfo'] = opts.contactInfo + } + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + policyId: opts.policyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 disk/0.12.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 updateSnapshotPolicy 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}/snapshotPolicy/{policyId}', + 'PATCH', + 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.policyId - 策略ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteSnapshotPolicy (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 deleteSnapshotPolicy" + ) + } + + opts = opts || {} + + if (opts.policyId === undefined || opts.policyId === null) { + throw new Error( + "Missing the required parameter 'opts.policyId' when calling deleteSnapshotPolicy" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + policyId: opts.policyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 disk/0.12.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 deleteSnapshotPolicy 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}/snapshotPolicy/{policyId}', + '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.name] - 策略名称,默认为空 optional + * @param {array} [opts.policyId] - 策略ID,默认为空 optional + * @param {array} [opts.status] - 策略状态。1: 启用 2:禁用 optional + * @param {orderItem} [opts.order] - 排序字段,只支持create_time和update_time字段 optional + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞) optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param snapshotPolicy policies + * @param integer totalCount 查询的快照策略数目 + */ + + describeSnapshotPolicies (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 describeSnapshotPolicies" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.policyId !== undefined && opts.policyId !== null) { + postBody['policyId'] = opts.policyId + } + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + if (opts.order !== undefined && opts.order !== null) { + postBody['order'] = opts.order + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 disk/0.12.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 describeSnapshotPolicies 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}/snapshotPolicies:describe', + '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) + } + ) + } + + /** + * - 查询您已经创建的快照策略。 +- filters多个过滤条件之间是逻辑与(AND),每个条件内部的多个取值是逻辑或(OR) + + * @param {Object} opts - parameters + * @param {array} [opts.filterGroups] - 过滤条件 optional + * @param {orderItem} [opts.order] - 排序字段,只支持create_time和update_time字段 optional + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞) optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param snapshotPolicy policies + * @param integer totalCount 查询的快照策略数目 + */ + + describeSnapPolices (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 describeSnapPolices" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.filterGroups !== undefined && opts.filterGroups !== null) { + postBody['filterGroups'] = opts.filterGroups + } + if (opts.order !== undefined && opts.order !== null) { + postBody['order'] = opts.order + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 disk/0.12.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 describeSnapPolices 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}/snapPolicies:describe', + '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 {array} [opts.relations] - 绑定/解绑操作 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param policyDiskRelationOpResult opResults + */ + + applySnapshotPolicies (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 applySnapshotPolicies" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.relations !== undefined && opts.relations !== null) { + postBody['relations'] = opts.relations + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 disk/0.12.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 applySnapshotPolicies 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}/snapshotPolicies:apply', + '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 {array} [opts.diskId] - 磁盘ID optional + * @param {array} [opts.diskRegion] - 磁盘地域ID optional + * @param {array} [opts.policyId] - 策略ID optional + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞) optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount 总数量 + * @param descSnapshotRelationsData relationResults + */ + + describeSnapshotPolicyDiskRelations ( + 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 describeSnapshotPolicyDiskRelations" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.diskId !== undefined && opts.diskId !== null) { + postBody['diskId'] = opts.diskId + } + if (opts.diskRegion !== undefined && opts.diskRegion !== null) { + postBody['diskRegion'] = opts.diskRegion + } + if (opts.policyId !== undefined && opts.policyId !== null) { + postBody['policyId'] = opts.policyId + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 disk/0.12.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 describeSnapshotPolicyDiskRelations 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}/snapshotPolicyDiskRelations:describe', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param soldout soldout + * @param integer totalCount 查询的可用区售罄情况数目 + */ + + describeSoldout (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 describeSoldout" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 disk/0.12.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 describeSoldout 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}/soldout', + '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 = DISK diff --git a/packages/libs/lib-jdcloud/src/repo/dms/v1/dms.js b/packages/libs/lib-jdcloud/src/repo/dms/v1/dms.js new file mode 100644 index 000000000..63f0b5867 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/dms/v1/dms.js @@ -0,0 +1,9853 @@ +/* + * 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. + * + * DmsView + * 视图相关接口 + * + * 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 = 'dms' +Service._services[serviceId] = true + +/** + * dms service. + * @version 1.4.0 + */ + +class DMS extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'dms.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 校验当前的用户是否允许访问DMS控制台 + * @param {Object} opts - parameters + * @param {string} callback - callback + @return {Object} result + * @param string strResult 允许访问 + */ + + dmsConsoleCheck (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 dmsConsoleCheck 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( + '/console:check', + '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) + } + ) + } + + /** + * 生产创建事件SQL语句,支持Mysql + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id。 optional + * @param {} [opts.dbName] - 数据库名称。 optional + * @param {} [opts.eventName] - 事件名称。 optional + * @param {} [opts.eventComment] - 注释。 optional + * @param {} [opts.eventStatus] - 状态,ENABLED,DISABLED, SLAVESIDE_DISABLED。 optional + * @param {} [opts.isPreserve] - 完成后是否保存。 optional + * @param {} [opts.eventDefinition] - 事件定义。 optional + * @param {} [opts.eventType] - 调度方式,ONE_TIME,RECURRING。 optional + * @param {} [opts.executeAt] - 执行一次的时间。 optional + * @param {} [opts.intervalValue] - 循环执行时间隔时间的值。 optional + * @param {} [opts.intervalField] - 循环执行时间隔时间的单位,YEAR,QUARTER,MONTH,WEEK,DAY,HOUR,MINUTE,SECOND,YEAR_MONTH,DAY_HOUR,DAY_MINUTE,DAY_SECOND,HOUR_MINUTE,HOUR_SECOND,MINUTE_SECOND。 optional + * @param {} [opts.starts] - 循环执行开始时间。 optional + * @param {} [opts.ends] - 循环执行结束时间。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dmsSql dmsSqls + */ + + generalCreateEvent (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 generalCreateEvent" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.eventName !== undefined && opts.eventName !== null) { + postBody['eventName'] = opts.eventName + } + if (opts.eventComment !== undefined && opts.eventComment !== null) { + postBody['eventComment'] = opts.eventComment + } + if (opts.eventStatus !== undefined && opts.eventStatus !== null) { + postBody['eventStatus'] = opts.eventStatus + } + if (opts.isPreserve !== undefined && opts.isPreserve !== null) { + postBody['isPreserve'] = opts.isPreserve + } + if (opts.eventDefinition !== undefined && opts.eventDefinition !== null) { + postBody['eventDefinition'] = opts.eventDefinition + } + if (opts.eventType !== undefined && opts.eventType !== null) { + postBody['eventType'] = opts.eventType + } + if (opts.executeAt !== undefined && opts.executeAt !== null) { + postBody['executeAt'] = opts.executeAt + } + if (opts.intervalValue !== undefined && opts.intervalValue !== null) { + postBody['intervalValue'] = opts.intervalValue + } + if (opts.intervalField !== undefined && opts.intervalField !== null) { + postBody['intervalField'] = opts.intervalField + } + if (opts.starts !== undefined && opts.starts !== null) { + postBody['starts'] = opts.starts + } + if (opts.ends !== undefined && opts.ends !== null) { + postBody['ends'] = opts.ends + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 generalCreateEvent 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}/event:generalCreate', + '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) + } + ) + } + + /** + * 生成修改事件sql语句,支持Mysql + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id。 optional + * @param {} [opts.dbName] - 数据库名称。 optional + * @param {} [opts.originEventName] - 原始事件名称。 optional + * @param {} [opts.eventName] - 新事件名称。 optional + * @param {} [opts.eventComment] - 注释。 optional + * @param {} [opts.eventStatus] - 状态,ENABLED,DISABLED, SLAVESIDE_DISABLED。 optional + * @param {} [opts.isPreserve] - 完成后是否保存。 optional + * @param {} [opts.eventDefinition] - 事件定义。 optional + * @param {} [opts.eventType] - 调度方式,ONE_TIME,RECURRING。 optional + * @param {} [opts.executeAt] - 执行一次的时间。 optional + * @param {} [opts.intervalValue] - 循环执行时间隔时间的值。 optional + * @param {} [opts.intervalField] - 循环执行时间隔时间的单位,YEAR,QUARTER,MONTH,WEEK,DAY,HOUR,MINUTE,SECOND,YEAR_MONTH,DAY_HOUR,DAY_MINUTE,DAY_SECOND,HOUR_MINUTE,HOUR_SECOND,MINUTE_SECOND。 optional + * @param {} [opts.starts] - 循环执行开始时间。 optional + * @param {} [opts.ends] - 循环执行结束时间。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dmsSql dmsSqls + */ + + generalAlterEvent (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 generalAlterEvent" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.originEventName !== undefined && opts.originEventName !== null) { + postBody['originEventName'] = opts.originEventName + } + if (opts.eventName !== undefined && opts.eventName !== null) { + postBody['eventName'] = opts.eventName + } + if (opts.eventComment !== undefined && opts.eventComment !== null) { + postBody['eventComment'] = opts.eventComment + } + if (opts.eventStatus !== undefined && opts.eventStatus !== null) { + postBody['eventStatus'] = opts.eventStatus + } + if (opts.isPreserve !== undefined && opts.isPreserve !== null) { + postBody['isPreserve'] = opts.isPreserve + } + if (opts.eventDefinition !== undefined && opts.eventDefinition !== null) { + postBody['eventDefinition'] = opts.eventDefinition + } + if (opts.eventType !== undefined && opts.eventType !== null) { + postBody['eventType'] = opts.eventType + } + if (opts.executeAt !== undefined && opts.executeAt !== null) { + postBody['executeAt'] = opts.executeAt + } + if (opts.intervalValue !== undefined && opts.intervalValue !== null) { + postBody['intervalValue'] = opts.intervalValue + } + if (opts.intervalField !== undefined && opts.intervalField !== null) { + postBody['intervalField'] = opts.intervalField + } + if (opts.starts !== undefined && opts.starts !== null) { + postBody['starts'] = opts.starts + } + if (opts.ends !== undefined && opts.ends !== null) { + postBody['ends'] = opts.ends + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 generalAlterEvent 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}/event:generalAlter', + '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) + } + ) + } + + /** + * 生成删除事件sql语句,支持Mysql + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 数据库名称。 optional + * @param {} [opts.eventName] - 事件名称。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dmsSql dmsSqls + */ + + generalDropEvent (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 generalDropEvent" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.eventName !== undefined && opts.eventName !== null) { + postBody['eventName'] = opts.eventName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 generalDropEvent 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}/event:generalDrop', + '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) + } + ) + } + + /** + * 获取事件详情,支持Mysql + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 数据库名称。 optional + * @param {} [opts.eventName] - 事件名称。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string dbName 数据库名称。 + * @param string eventName 事件名称。 + * @param string eventComment 注释。 + * @param string eventStatus 状态,ENABLED,DISABLED, SLAVESIDE_DISABLED。 + * @param boolean isPreserve 完成后是否保存。 + * @param string eventDefinition 事件定义。 + * @param string eventType 调度方式,ONE_TIME,RECURRING。 + * @param string executeAt 执行一次的时间。 + * @param string intervalValue 循环执行时间隔时间的值。 + * @param string intervalField 循环执行时间隔时间的单位,YEAR,QUARTER,MONTH,WEEK,DAY,HOUR,MINUTE,SECOND,YEAR_MONTH,DAY_HOUR,DAY_MINUTE,DAY_SECOND,HOUR_MINUTE,HOUR_SECOND,MINUTE_SECOND。 + * @param string starts 循环执行开始时间。 + * @param string ends 循环执行结束时间。 + */ + + eventInfo (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 eventInfo" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.eventName !== undefined && opts.eventName !== null) { + postBody['eventName'] = opts.eventName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 eventInfo 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}/event:info', + '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) + } + ) + } + + /** + * 创建导入文件任务,支持Stardb + * @param {Object} opts - parameters + * @param {} [opts.filename] - 文件名称 optional + * @param {} [opts.totalSize] - 文件总大小 optional + * @param {} [opts.chunkSize] - 文件分片大小 optional + * @param {} [opts.totalChunks] - 文件分片数 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string uploadId 导入文件任务id + */ + + createImportFileTask (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 createImportFileTask" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.filename !== undefined && opts.filename !== null) { + postBody['filename'] = opts.filename + } + if (opts.totalSize !== undefined && opts.totalSize !== null) { + postBody['totalSize'] = opts.totalSize + } + if (opts.chunkSize !== undefined && opts.chunkSize !== null) { + postBody['chunkSize'] = opts.chunkSize + } + if (opts.totalChunks !== undefined && opts.totalChunks !== null) { + postBody['totalChunks'] = opts.totalChunks + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 createImportFileTask 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}/importFileTask:create', + '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) + } + ) + } + + /** + * 上传文件,支持Stardb,只支持前端页面使用 + * @param {Object} opts - parameters + * @param {} [opts.taskId] - 上传文件任务id optional + * @param {} [opts.chunkNumber] - 上传文件分片号 optional + * @param {} [opts.identifier] - 分片文件MD5 optional + * @param {} [opts.file] - 分片文件 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param uploadImportFileResult uploadImportFileResult + */ + + uploadImportFileTask (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 uploadImportFileTask" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.taskId !== undefined && opts.taskId !== null) { + postBody['taskId'] = opts.taskId + } + if (opts.chunkNumber !== undefined && opts.chunkNumber !== null) { + postBody['chunkNumber'] = opts.chunkNumber + } + if (opts.identifier !== undefined && opts.identifier !== null) { + postBody['identifier'] = opts.identifier + } + if (opts.file !== undefined && opts.file !== null) { + postBody['file'] = opts.file + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 uploadImportFileTask 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}/importFileTask:upload', + '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) + } + ) + } + + /** + * 创建数据变更工单,支持Stardb + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据库id optional + * @param {} [opts.dbName] - 数据库名称 optional + * @param {} [opts.taskPlanTypeEnum] - 执行方式,AUTO("AUTO", 0), BY_CREATOR("BY_CREATOR", 1) optional + * @param {} [opts.dbaApproveTypeEnum] - DBA审批方式,AUTO("AUTO", 0), MANUAL("MANUAL", 1) optional + * @param {} [opts.memo] - 申请原因 optional + * @param {} [opts.sqlText] - SQL文本,变更SQL选择文本时,必填 optional + * @param {} [opts.sqlFileTaskId] - SQL附件导入任务Id optional + * @param {} [opts.rollbackSqlText] - 回滚SQL文本,选填 optional + * @param {} [opts.rollbackFileTaskId] - 回滚SQL附件导入任务Id optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string flowId 工单id + */ + + createDataFlow (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 createDataFlow" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.taskPlanTypeEnum !== undefined && opts.taskPlanTypeEnum !== null) { + postBody['taskPlanTypeEnum'] = opts.taskPlanTypeEnum + } + if ( + opts.dbaApproveTypeEnum !== undefined && + opts.dbaApproveTypeEnum !== null + ) { + postBody['dbaApproveTypeEnum'] = opts.dbaApproveTypeEnum + } + if (opts.memo !== undefined && opts.memo !== null) { + postBody['memo'] = opts.memo + } + if (opts.sqlText !== undefined && opts.sqlText !== null) { + postBody['sqlText'] = opts.sqlText + } + if (opts.sqlFileTaskId !== undefined && opts.sqlFileTaskId !== null) { + postBody['sqlFileTaskId'] = opts.sqlFileTaskId + } + if (opts.rollbackSqlText !== undefined && opts.rollbackSqlText !== null) { + postBody['rollbackSqlText'] = opts.rollbackSqlText + } + if ( + opts.rollbackFileTaskId !== undefined && + opts.rollbackFileTaskId !== null + ) { + postBody['rollbackFileTaskId'] = opts.rollbackFileTaskId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 createDataFlow 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}/dataFlow:create', + '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) + } + ) + } + + /** + * 创建结构变更工单,支持Stardb + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据库id optional + * @param {} [opts.dbName] - 数据库名称 optional + * @param {} [opts.taskPlanTypeEnum] - 执行方式,AUTO("AUTO", 0), BY_CREATOR("BY_CREATOR", 1) optional + * @param {} [opts.dbaApproveTypeEnum] - DBA审批方式,AUTO("AUTO", 0), MANUAL("MANUAL", 1) optional + * @param {} [opts.memo] - 申请原因 optional + * @param {} [opts.sqlText] - SQL文本,变更SQL选择文本时,必填 optional + * @param {} [opts.sqlFileTaskId] - SQL附件导入任务Id optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string flowId 工单id + */ + + createStructureFlow (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 createStructureFlow" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.taskPlanTypeEnum !== undefined && opts.taskPlanTypeEnum !== null) { + postBody['taskPlanTypeEnum'] = opts.taskPlanTypeEnum + } + if ( + opts.dbaApproveTypeEnum !== undefined && + opts.dbaApproveTypeEnum !== null + ) { + postBody['dbaApproveTypeEnum'] = opts.dbaApproveTypeEnum + } + if (opts.memo !== undefined && opts.memo !== null) { + postBody['memo'] = opts.memo + } + if (opts.sqlText !== undefined && opts.sqlText !== null) { + postBody['sqlText'] = opts.sqlText + } + if (opts.sqlFileTaskId !== undefined && opts.sqlFileTaskId !== null) { + postBody['sqlFileTaskId'] = opts.sqlFileTaskId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 createStructureFlow 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}/structureFlow:create', + '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) + } + ) + } + + /** + * 创建数据导出工单,支持Stardb + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据库id optional + * @param {} [opts.dbName] - 数据库名称 optional + * @param {} [opts.taskPlanTypeEnum] - 执行方式,AUTO("AUTO", 0), BY_CREATOR("BY_CREATOR", 1) optional + * @param {} [opts.dbaApproveTypeEnum] - DBA审批方式,AUTO("AUTO", 0), MANUAL("MANUAL", 1) optional + * @param {} [opts.memo] - 申请原因 optional + * @param {} [opts.exportTypeEnum] - 导出类型, RESULT_SET("RESULT_SET", 0), DB("DB", 1) optional + * @param {} [opts.exportFileTypeEnum] - 导出格式,CSV("CSV", 0), SQL("SQL", 1) optional + * @param {} [opts.rowsNum] - 影响行数,导出类型为结果集导出时,必填 optional + * @param {} [opts.ignoreError] - 是否跳过检验,导出类型为结果集导出时,必填 optional + * @param {} [opts.ignoreReason] - 跳过检验原因,ignoreError为true时,必填 optional + * @param {} [opts.exportSqlText] - 导出SQL文本,导出类型为结果集导出时,必填 optional + * @param {} [opts.tableFilters] - 导出表及过滤条件,为空时导出全部表。导出类型为数据库导出时,必填 optional + * @param {} [opts.exportContentTypeEnum] - 导出内容,DATA("DATA", 0), STRUCT("STRUCT", 1), STRUCT_DATA("STRUCT_DATA", 2),导出类型为数据库导出时,必填 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string flowId 工单id + */ + + createExportFlow (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 createExportFlow" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.taskPlanTypeEnum !== undefined && opts.taskPlanTypeEnum !== null) { + postBody['taskPlanTypeEnum'] = opts.taskPlanTypeEnum + } + if ( + opts.dbaApproveTypeEnum !== undefined && + opts.dbaApproveTypeEnum !== null + ) { + postBody['dbaApproveTypeEnum'] = opts.dbaApproveTypeEnum + } + if (opts.memo !== undefined && opts.memo !== null) { + postBody['memo'] = opts.memo + } + if (opts.exportTypeEnum !== undefined && opts.exportTypeEnum !== null) { + postBody['exportTypeEnum'] = opts.exportTypeEnum + } + if ( + opts.exportFileTypeEnum !== undefined && + opts.exportFileTypeEnum !== null + ) { + postBody['exportFileTypeEnum'] = opts.exportFileTypeEnum + } + if (opts.rowsNum !== undefined && opts.rowsNum !== null) { + postBody['rowsNum'] = opts.rowsNum + } + if (opts.ignoreError !== undefined && opts.ignoreError !== null) { + postBody['ignoreError'] = opts.ignoreError + } + if (opts.ignoreReason !== undefined && opts.ignoreReason !== null) { + postBody['ignoreReason'] = opts.ignoreReason + } + if (opts.exportSqlText !== undefined && opts.exportSqlText !== null) { + postBody['exportSqlText'] = opts.exportSqlText + } + if (opts.tableFilters !== undefined && opts.tableFilters !== null) { + postBody['tableFilters'] = opts.tableFilters + } + if ( + opts.exportContentTypeEnum !== undefined && + opts.exportContentTypeEnum !== null + ) { + postBody['exportContentTypeEnum'] = opts.exportContentTypeEnum + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 createExportFlow 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}/exportFlow:create', + '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) + } + ) + } + + /** + * 任务执行,支持Stardb + * @param {Object} opts - parameters + * @param {} [opts.flowOrderUniqId] - 流程id optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + startFlow (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 startFlow" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.flowOrderUniqId !== undefined && opts.flowOrderUniqId !== null) { + postBody['flowOrderUniqId'] = opts.flowOrderUniqId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 startFlow 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}/flow:start', + '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) + } + ) + } + + /** + * 生产创建函数过程SQL语句,支持Mysql + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id。 optional + * @param {} [opts.dbName] - 数据库名称。 optional + * @param {} [opts.functionName] - 函数名称。 optional + * @param {} [opts.functionSecurity] - 安全性,DEFAULT("DEFAULT", 1),DEFINER("DEFINER", 2), INVOKER("INVOKER", 3); optional + * @param {} [opts.dataAccess] - 数据访问,DEFAULT("DEFAULT", 1),NO_SQL("NO_SQL", 2), CONTAINS_SQL("CONTAINS_SQL", 3), READS_SQL_DATA("READS_SQL_DATA", 4), MODIFIES_SQL_DATA("MODIFIES_SQL_DATA", 5); optional + * @param {} [opts.deterministic] - 确定性。 optional + * @param {} [opts.definitionSql] - 函数定义SQL。 optional + * @param {} [opts.parameters] - 参数列表。 optional + * @param {} [opts.definer] - 定义者。 optional + * @param {} [opts.comment] - 注释。 optional + * @param {} [opts.returnType] - 返回值类型,TINYINT("TINYINT", 0), SMALLINT("SMALLINT", 1), MEDIUMINT("MEDIUMINT", 2), INT("INT", 3), BIGINT("BIGINT", 4), INTEGER("INTEGER", 5), FLOAT("FLOAT", 6), DOUBLE("DOUBLE", 7), REAL("REAL", 8), DECIMAL("DECIMAL", 9), CHAR("CHAR", 10), VARCHAR("VARCHAR", 11), TINYTEXT("TINYTEXT", 12), TEXT("TEXT", 13), MEDIUMTEXT("MEDIUMTEXT", 14), LONGTEXT("LONGTEXT", 15), DATE("DATE", 16), DATETIME("DATETIME", 17), TIMESTAMP("TIMESTAMP", 18), TIME("TIME", 19), YEAR("YEAR", 19), BINARY("BINARY", 20), VARBINARY("VARBINARY", 21), TINYBLOB("TINYBLOB", 22), BLOB("BLOB", 23), MEDIUMBLOB("MEDIUMBLOB", 24), LONGBLOB("LONGBLOB", 25); optional + * @param {} [opts.returnLength] - 返回值长度。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dmsSql dmsSqls + */ + + generalCreateFunction (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 generalCreateFunction" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.functionName !== undefined && opts.functionName !== null) { + postBody['functionName'] = opts.functionName + } + if (opts.functionSecurity !== undefined && opts.functionSecurity !== null) { + postBody['functionSecurity'] = opts.functionSecurity + } + if (opts.dataAccess !== undefined && opts.dataAccess !== null) { + postBody['dataAccess'] = opts.dataAccess + } + if (opts.deterministic !== undefined && opts.deterministic !== null) { + postBody['deterministic'] = opts.deterministic + } + if (opts.definitionSql !== undefined && opts.definitionSql !== null) { + postBody['definitionSql'] = opts.definitionSql + } + if (opts.parameters !== undefined && opts.parameters !== null) { + postBody['parameters'] = opts.parameters + } + if (opts.definer !== undefined && opts.definer !== null) { + postBody['definer'] = opts.definer + } + if (opts.comment !== undefined && opts.comment !== null) { + postBody['comment'] = opts.comment + } + if (opts.returnType !== undefined && opts.returnType !== null) { + postBody['returnType'] = opts.returnType + } + if (opts.returnLength !== undefined && opts.returnLength !== null) { + postBody['returnLength'] = opts.returnLength + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 generalCreateFunction 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}/function:generalCreate', + '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) + } + ) + } + + /** + * 生成修改函数sql语句,支持Mysql + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id。 optional + * @param {} [opts.dbName] - 数据库名称。 optional + * @param {} [opts.functionName] - 函数名称。 optional + * @param {} [opts.originFunctionName] - 函数名称。 optional + * @param {} [opts.functionSecurity] - 安全性,DEFAULT("DEFAULT", 1),DEFINER("DEFINER", 2), INVOKER("INVOKER", 3); optional + * @param {} [opts.dataAccess] - 数据访问,DEFAULT("DEFAULT", 1),NO_SQL("NO_SQL", 2), CONTAINS_SQL("CONTAINS_SQL", 3), READS_SQL_DATA("READS_SQL_DATA", 4), MODIFIES_SQL_DATA("MODIFIES_SQL_DATA", 5); optional + * @param {} [opts.deterministic] - 确定性。 optional + * @param {} [opts.definitionSql] - 函数定义SQL。 optional + * @param {} [opts.completeSql] - 函数定义SQL。 optional + * @param {} [opts.parameters] - 参数列表。 optional + * @param {} [opts.definer] - 定义者。 optional + * @param {} [opts.comment] - 注释。 optional + * @param {} [opts.returnType] - 返回值类型,TINYINT("TINYINT", 0), SMALLINT("SMALLINT", 1), MEDIUMINT("MEDIUMINT", 2), INT("INT", 3), BIGINT("BIGINT", 4), INTEGER("INTEGER", 5), FLOAT("FLOAT", 6), DOUBLE("DOUBLE", 7), REAL("REAL", 8), DECIMAL("DECIMAL", 9), CHAR("CHAR", 10), VARCHAR("VARCHAR", 11), TINYTEXT("TINYTEXT", 12), TEXT("TEXT", 13), MEDIUMTEXT("MEDIUMTEXT", 14), LONGTEXT("LONGTEXT", 15), DATE("DATE", 16), DATETIME("DATETIME", 17), TIMESTAMP("TIMESTAMP", 18), TIME("TIME", 19), YEAR("YEAR", 19), BINARY("BINARY", 20), VARBINARY("VARBINARY", 21), TINYBLOB("TINYBLOB", 22), BLOB("BLOB", 23), MEDIUMBLOB("MEDIUMBLOB", 24), LONGBLOB("LONGBLOB", 25); optional + * @param {} [opts.returnLength] - 返回值长度。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dmsSql dmsSqls + */ + + generalAlterFunction (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 generalAlterFunction" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.functionName !== undefined && opts.functionName !== null) { + postBody['functionName'] = opts.functionName + } + if ( + opts.originFunctionName !== undefined && + opts.originFunctionName !== null + ) { + postBody['originFunctionName'] = opts.originFunctionName + } + if (opts.functionSecurity !== undefined && opts.functionSecurity !== null) { + postBody['functionSecurity'] = opts.functionSecurity + } + if (opts.dataAccess !== undefined && opts.dataAccess !== null) { + postBody['dataAccess'] = opts.dataAccess + } + if (opts.deterministic !== undefined && opts.deterministic !== null) { + postBody['deterministic'] = opts.deterministic + } + if (opts.definitionSql !== undefined && opts.definitionSql !== null) { + postBody['definitionSql'] = opts.definitionSql + } + if (opts.completeSql !== undefined && opts.completeSql !== null) { + postBody['completeSql'] = opts.completeSql + } + if (opts.parameters !== undefined && opts.parameters !== null) { + postBody['parameters'] = opts.parameters + } + if (opts.definer !== undefined && opts.definer !== null) { + postBody['definer'] = opts.definer + } + if (opts.comment !== undefined && opts.comment !== null) { + postBody['comment'] = opts.comment + } + if (opts.returnType !== undefined && opts.returnType !== null) { + postBody['returnType'] = opts.returnType + } + if (opts.returnLength !== undefined && opts.returnLength !== null) { + postBody['returnLength'] = opts.returnLength + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 generalAlterFunction 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}/function:generalAlter', + '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) + } + ) + } + + /** + * 生成删除函数sql语句,支持Mysql + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 数据库名称。 optional + * @param {} [opts.functionName] - 函数名称。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dmsSql dmsSqls + */ + + generalDropFunction (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 generalDropFunction" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.functionName !== undefined && opts.functionName !== null) { + postBody['functionName'] = opts.functionName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 generalDropFunction 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}/function:generalDrop', + '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) + } + ) + } + + /** + * 获取函数列表,支持Mysql + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 数据库名称。 optional + * @param {} [opts.filter] - 过滤条件。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string functionNames 函数名称 + */ + + functionList (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 functionList" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.filter !== undefined && opts.filter !== null) { + postBody['filter'] = opts.filter + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 functionList 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}/function:list', + '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) + } + ) + } + + /** + * 获取函数详情,支持Mysql + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 数据库名称。 optional + * @param {} [opts.functionName] - 函数名称。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string dbName 数据库名称。 + * @param string functionName 函数名称。 + * @param string functionSecurity 安全性,DEFAULT("DEFAULT", 1),DEFINER("DEFINER", 2), INVOKER("INVOKER", 3); + * @param string dataAccess 数据访问,DEFAULT("DEFAULT", 1),NO_SQL("NO_SQL", 2), CONTAINS_SQL("CONTAINS_SQL", 3), READS_SQL_DATA("READS_SQL_DATA", 4), MODIFIES_SQL_DATA("MODIFIES_SQL_DATA", 5); + * @param boolean deterministic 确定性。 + * @param string definitionSql 函数定义SQL。 + * @param string completeSql 创建存储过程定义完整SQL。 + * @param parameter parameters + * @param string definer 定义者。 + * @param string comment 注释。 + * @param string returnType 返回值类型,TINYINT("TINYINT", 0), SMALLINT("SMALLINT", 1), MEDIUMINT("MEDIUMINT", 2), INT("INT", 3), BIGINT("BIGINT", 4), INTEGER("INTEGER", 5), FLOAT("FLOAT", 6), DOUBLE("DOUBLE", 7), REAL("REAL", 8), DECIMAL("DECIMAL", 9), CHAR("CHAR", 10), VARCHAR("VARCHAR", 11), TINYTEXT("TINYTEXT", 12), TEXT("TEXT", 13), MEDIUMTEXT("MEDIUMTEXT", 14), LONGTEXT("LONGTEXT", 15), DATE("DATE", 16), DATETIME("DATETIME", 17), TIMESTAMP("TIMESTAMP", 18), TIME("TIME", 19), YEAR("YEAR", 19), BINARY("BINARY", 20), VARBINARY("VARBINARY", 21), TINYBLOB("TINYBLOB", 22), BLOB("BLOB", 23), MEDIUMBLOB("MEDIUMBLOB", 24), LONGBLOB("LONGBLOB", 25); + * @param integer returnLength 返回值长度。 + * @param integer returnDecimal 返回值精度。 + */ + + functionInfo (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 functionInfo" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.functionName !== undefined && opts.functionName !== null) { + postBody['functionName'] = opts.functionName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 functionInfo 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}/function:info', + '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) + } + ) + } + + /** + * 调用函数,支持Mysql + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 数据库名称。 optional + * @param {} [opts.functionName] - 函数名称。 optional + * @param {} [opts.parameters] - 参数。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string returnValue 返回值 + * @param object outArgs 输出参数返回值 + */ + + functionInvoke (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 functionInvoke" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.functionName !== undefined && opts.functionName !== null) { + postBody['functionName'] = opts.functionName + } + if (opts.parameters !== undefined && opts.parameters !== null) { + postBody['parameters'] = opts.parameters + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 functionInvoke 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}/function:invoke', + '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) + } + ) + } + + /** + * 生成建表语句sql,支持Mysql,Stardb,OpenGauss + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 数据库名 optional + * @param {} [opts.tableName] - 表名 optional + * @param {} [opts.metaTableInfo] - 表元信息。 optional + * @param {} [opts.columnInfos] - 列信息。 optional + * @param {} [opts.indexInfos] - 索引信息。 optional + * @param {} [opts.extraTableInfo] - 分表信息,stardb数据源中使用。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string strResult 生成sql + */ + + generalCreateTableSql (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 generalCreateTableSql" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.tableName !== undefined && opts.tableName !== null) { + postBody['tableName'] = opts.tableName + } + if (opts.metaTableInfo !== undefined && opts.metaTableInfo !== null) { + postBody['metaTableInfo'] = opts.metaTableInfo + } + if (opts.columnInfos !== undefined && opts.columnInfos !== null) { + postBody['columnInfos'] = opts.columnInfos + } + if (opts.indexInfos !== undefined && opts.indexInfos !== null) { + postBody['indexInfos'] = opts.indexInfos + } + if (opts.extraTableInfo !== undefined && opts.extraTableInfo !== null) { + postBody['extraTableInfo'] = opts.extraTableInfo + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 generalCreateTableSql 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}/createSql:general', + '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) + } + ) + } + + /** + * 生成修改表结构语句sql,支持Mysql,Stardb + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源Id optional + * @param {} [opts.dbName] - 数据库名 optional + * @param {} [opts.tableName] - 表名 optional + * @param {} [opts.metaTableInfo] - 表元信息。 optional + * @param {} [opts.columnInfos] - 列信息。 optional + * @param {} [opts.indexInfos] - 索引信息。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string strResult 生成sql + */ + + generalAlterTableSql (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 generalAlterTableSql" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.tableName !== undefined && opts.tableName !== null) { + postBody['tableName'] = opts.tableName + } + if (opts.metaTableInfo !== undefined && opts.metaTableInfo !== null) { + postBody['metaTableInfo'] = opts.metaTableInfo + } + if (opts.columnInfos !== undefined && opts.columnInfos !== null) { + postBody['columnInfos'] = opts.columnInfos + } + if (opts.indexInfos !== undefined && opts.indexInfos !== null) { + postBody['indexInfos'] = opts.indexInfos + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 generalAlterTableSql 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}/alterSql:general', + '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) + } + ) + } + + /** + * 获取当前实例用户查询sql历史 + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.pageNumber] - 显示数据的页码,取值范围:[1,∞)。pageNumber为Null时,返回所有数据页码;超过总页数时,无数据。 optional + * @param {} [opts.pageSize] - 每页显示的数据条数,用于查询列表的接口。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer count 历史sql总量 + * @param dmsHistorySql historySqls + */ + + historySql (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 historySql" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 historySql 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}/historySql', + '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) + } + ) + } + + /** + * 获取当前实例用户查询导入数据sql历史 + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 数据库名称 optional + * @param {} [opts.pageNumber] - 显示数据的页码,取值范围:[1,∞)。pageNumber为Null时,返回所有数据页码;超过总页数时,无数据。 optional + * @param {} [opts.pageSize] - 每页显示的数据条数,用于查询列表的接口。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer count 历史sql总量 + * @param historySql historySqls + */ + + historyImportData (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 historyImportData" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 historyImportData 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}/historyImportData', + '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 {} [opts.instanceQueryTypeEnum] - 查询分类方式:LOGIN_STATUS,DB_TYPE。 optional + * @param {} [opts.instanceStatus] - 实例状态,参见[枚举参数定义](../Enum-Definitions/Enum-Definitions.md)。 optional + * @param {} [opts.dbInfoEnum] - 数据库类型:MYSQL_INS,DRDS_INS optional + * @param {} [opts.pageNumber] - 显示数据的页码,取值范围:[1,∞)。pageNumber为Null时,返回所有数据页码;超过总页数时,无数据。 optional + * @param {} [opts.pageSize] - 每页显示的数据条数,用于查询列表的接口。 optional + * @param {} [opts.uniqId] - 实例Id。 optional + * @param {} [opts.dbName] - 打开数据库名称。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string instanceQueryTypeEnum 查询分类方式:LOGIN_STATUS,DB_TYPE。 + * @param dmsInstance loginedInstance + * @param dmsInstance unloginedInstance + * @param dmsInstance noNeedLoginInstance + * @param dmsInstance rdsIntance + * @param dmsInstance drdsIntance + */ + + queryInstance (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 queryInstance" + ) + } + + opts = opts || {} + + let postBody = {} + if ( + opts.instanceQueryTypeEnum !== undefined && + opts.instanceQueryTypeEnum !== null + ) { + postBody['instanceQueryTypeEnum'] = opts.instanceQueryTypeEnum + } + if (opts.instanceStatus !== undefined && opts.instanceStatus !== null) { + postBody['instanceStatus'] = opts.instanceStatus + } + if (opts.dbInfoEnum !== undefined && opts.dbInfoEnum !== null) { + postBody['dbInfoEnum'] = opts.dbInfoEnum + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + if (opts.uniqId !== undefined && opts.uniqId !== null) { + postBody['uniqId'] = opts.uniqId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 queryInstance 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}/instances:query', + '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 {} [opts.dataSourceId] - 数据源id。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + open (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 open" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 open 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}/instance:open', + '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,drds登录实例 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - rds,drds的实例id。 + * @param {} [opts.dbType] - 数据源类型,CDS("CDS", 1), MYSQL("MYSQL", 2), ORACLE("ORACLE", 3), SQLSERVER("SQLSERVER", 4), CDSMYSQL("CDSMYSQL", 5), CDSORACLE("CDSORACLE", 6), CDSSQLSERVER("CDSSQLSERVER", 7), DATACENTER("DATACENTER", 8), HBASE("Hbase",9),MONGODB("MongoDb",10),ES("ES",11), MYSQL_INS("MYSQL_INS",12), DRDS_INS("DRDS_INS",13), STARDB_INS("STARDB_INS",14), STARDB_PROXY_INS("STARDB_PROXY_INS",15), CLICK_HOUSE_INS("CLICK_HOUSE_INS",16), TIDB_INS("TIDB_INS",17), OPEN_GAUSS_INS("OPEN_GAUSS_INS",18), SS_OPEN_GAUSS_INS("SS_OPEN_GAUSS_INS",19); optional + * @param {} [opts.addrMode] - CLASSIC("CLASSIC", 0), RDS("RDS", 1), ECS("ECS", 2), VPC("VPC", 3), 当前只支持rds模式。 optional + * @param {} [opts.dbUser] - 数据库用户名。 optional + * @param {} [opts.dbPassword] - 数据库用户密码。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + login (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 login" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling login" + ) + } + + let postBody = {} + if (opts.dbType !== undefined && opts.dbType !== null) { + postBody['dbType'] = opts.dbType + } + if (opts.addrMode !== undefined && opts.addrMode !== null) { + postBody['addrMode'] = opts.addrMode + } + if (opts.dbUser !== undefined && opts.dbUser !== null) { + postBody['dbUser'] = opts.dbUser + } + if (opts.dbPassword !== undefined && opts.dbPassword !== null) { + postBody['dbPassword'] = opts.dbPassword + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 login 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}/instances/{instanceId}:login', + '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 {} [opts.dataSourceId] - 数据源id。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + logout (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 logout" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 logout 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}/instance:logout', + '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 {} [opts.dbType] - 数据源类型,CDS("CDS", 1), MYSQL("MYSQL", 2), ORACLE("ORACLE", 3), SQLSERVER("SQLSERVER", 4), CDSMYSQL("CDSMYSQL", 5), CDSORACLE("CDSORACLE", 6), CDSSQLSERVER("CDSSQLSERVER", 7), DATACENTER("DATACENTER", 8), HBASE("Hbase",9),MONGODB("MongoDb",10),ES("ES",11), MYSQL_INS("MYSQL_INS",12), DRDS_INS("DRDS_INS",13), STARDB_INS("STARDB_INS",14), STARDB_PROXY_INS("STARDB_PROXY_INS",15), CLICK_HOUSE_INS("CLICK_HOUSE_INS",16), TIDB_INS("TIDB_INS",17), OPEN_GAUSS_INS("OPEN_GAUSS_INS",18), SS_OPEN_GAUSS_INS("SS_OPEN_GAUSS_INS",19); optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string regionId 查询分类方式:LOGIN_STATUS,DB_TYPE。 + * @param integer dbType 数据库类型。 + * @param dmsInstance loginedInstance + * @param dmsInstance unloginedInstance + */ + + queryTypeInstance (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 queryTypeInstance" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dbType !== undefined && opts.dbType !== null) { + postBody['dbType'] = opts.dbType + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 queryTypeInstance 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}/typeInstances:query', + '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 - 实例id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + checkInstance (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 checkInstance" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling checkInstance" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 checkInstance 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}/instances/{instanceId}:check', + '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) + } + ) + } + + /** + * 获取表元数据,支持Mysql,Stardb,Tidb,ClickHouse + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 库名。 optional + * @param {} [opts.tableName] - 表名。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dmsTableStruct dmsTableStruct + */ + + tableInfo (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 tableInfo" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.tableName !== undefined && opts.tableName !== null) { + postBody['tableName'] = opts.tableName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 tableInfo 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}/consoleTableInfo', + '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) + } + ) + } + + /** + * 获取数据库实例的库列表,支持Mysql,Stardb,Tidb,ClickHouse + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string databaseNames 数据库名称 + */ + + databaseList (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 databaseList" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 databaseList 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}/consoleDbList', + '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) + } + ) + } + + /** + * 获取数据库中的表列表,支持Mysql,Stardb,Tidb,ClickHouse + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 数据库名称 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string tableNames 表名称 + */ + + tableList (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 tableList" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 tableList 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}/consoleTableList', + '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) + } + ) + } + + /** + * 获取sql中建表语句,表中列信息,支持Mysql,Stardb,Tidb,ClickHouse + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 数据库名称 optional + * @param {} [opts.sqls] - sql语句 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dmsTableStruct dmsTableStructs + */ + + sqlTableInfo (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 sqlTableInfo" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.sqls !== undefined && opts.sqls !== null) { + postBody['sqls'] = opts.sqls + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 sqlTableInfo 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}/sqlTableInfo', + '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) + } + ) + } + + /** + * 获取Dms域名,仅供前端使用 + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param object domains 区域到域名映射,例{"cn-north-1":"http://10.222.49.154:8080", "cn-east-1":"http://10.222.49.154:8080"}。 + */ + + getDmsDomain (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 getDmsDomain" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 getDmsDomain 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}/getDmsDomain', + '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) + } + ) + } + + /** + * 获取Dms域名,仅供前端使用 + * @param {Object} opts - parameters + * @param {string} callback - callback + @return {Object} result + * @param object domains 区域到域名映射,例{"cn-north-1":"http://10.222.49.154:8080", "cn-east-1":"http://10.222.49.154:8080"}。 + */ + + getDmsDomains (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 getDmsDomains 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( + '/getDmsDomain', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer count 操作类型总量 + * @param dmsOperationType dmsOperationTypes + */ + + queryOperationType (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 queryOperationType" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 queryOperationType 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}/operationType:query', + '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 {} [opts.supType] - 操作类型 optional + * @param {} [opts.type] - 对应控制台功能 optional + * @param {} [opts.pin] - 操作人 optional + * @param {} [opts.instanceId] - 实例id optional + * @param {} [opts.dbName] - 数据库名称 optional + * @param {} [opts.startTime] - 起始时间(UTC) optional + * @param {} [opts.endTime] - 结束时间(UTC) optional + * @param {} [opts.pageNumber] - 显示数据的页码,取值范围:[1,∞)。pageNumber为Null时,返回所有数据页码;超过总页数时,无数据。 optional + * @param {} [opts.pageSize] - 每页显示的数据条数,用于查询列表的接口。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer count 操作日志总量 + * @param dmsOperationLog operationLogs + */ + + queryOperationLog (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 queryOperationLog" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.supType !== undefined && opts.supType !== null) { + postBody['supType'] = opts.supType + } + if (opts.type !== undefined && opts.type !== null) { + postBody['type'] = opts.type + } + if (opts.pin !== undefined && opts.pin !== null) { + postBody['pin'] = opts.pin + } + if (opts.instanceId !== undefined && opts.instanceId !== null) { + postBody['instanceId'] = opts.instanceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 queryOperationLog 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}/operationLog:query', + '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.operationId - 操作id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dmsOperationLog dmsOperationLog + */ + + operationDetail (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 operationDetail" + ) + } + + opts = opts || {} + + if (opts.operationId === undefined || opts.operationId === null) { + throw new Error( + "Missing the required parameter 'opts.operationId' when calling operationDetail" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + operationId: opts.operationId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 operationDetail 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}/operationDetail/{operationId}', + '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) + } + ) + } + + /** + * 获取当前实例用户收藏sql + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.pageNumber] - 显示数据的页码,取值范围:[1,∞)。pageNumber为Null时,返回所有数据页码;超过总页数时,无数据。 optional + * @param {} [opts.pageSize] - 每页显示的数据条数,用于查询列表的接口。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer count 收藏sql总量 + * @param personalSql personalSqls + */ + + queryPersonalSqls (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 queryPersonalSqls" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 queryPersonalSqls 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}/personalSql:query', + '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) + } + ) + } + + /** + * 收藏sql + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.sqlStr] - 收藏的sql语句。 optional + * @param {} [opts.hint] - 备注。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string strResult 返回消息 + */ + + addPersonalSql (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 addPersonalSql" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.sqlStr !== undefined && opts.sqlStr !== null) { + postBody['sqlStr'] = opts.sqlStr + } + if (opts.hint !== undefined && opts.hint !== null) { + postBody['hint'] = opts.hint + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 addPersonalSql 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}/personalSql:add', + '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) + } + ) + } + + /** + * 删除收藏sql + * @param {Object} opts - parameters + * @param {} [opts.id] - 主键id optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deletePersonalSql (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 deletePersonalSql" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.id !== undefined && opts.id !== null) { + postBody['id'] = opts.id + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 deletePersonalSql 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}/personalSql:delete', + '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) + } + ) + } + + /** + * 更新收藏sql + * @param {Object} opts - parameters + * @param {} [opts.id] - 主键id optional + * @param {} [opts.hint] - sql备注 optional + * @param {} [opts.sqlStr] - sql内容 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updatePersonalSql (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 updatePersonalSql" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.id !== undefined && opts.id !== null) { + postBody['id'] = opts.id + } + if (opts.hint !== undefined && opts.hint !== null) { + postBody['hint'] = opts.hint + } + if (opts.sqlStr !== undefined && opts.sqlStr !== null) { + postBody['sqlStr'] = opts.sqlStr + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 updatePersonalSql 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}/personalSql:update', + '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) + } + ) + } + + /** + * 生产创建存储过程SQL语句,支持Mysql + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id。 optional + * @param {} [opts.dbName] - 数据库名称。 optional + * @param {} [opts.procedureName] - 存储过程名称。 optional + * @param {} [opts.procedureSecurity] - 安全性,DEFAULT("DEFAULT", 1),DEFINER("DEFINER", 2), INVOKER("INVOKER", 3); optional + * @param {} [opts.dataAccess] - 数据访问,DEFAULT("DEFAULT", 1),NO_SQL("NO_SQL", 2), CONTAINS_SQL("CONTAINS_SQL", 3), READS_SQL_DATA("READS_SQL_DATA", 4), MODIFIES_SQL_DATA("MODIFIES_SQL_DATA", 5); optional + * @param {} [opts.deterministic] - 确定性。 optional + * @param {} [opts.definitionSql] - 存储过程定义SQL。 optional + * @param {} [opts.parameters] - 参数列表。 optional + * @param {} [opts.definer] - 定义者。 optional + * @param {} [opts.comment] - 注释。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dmsSql dmsSqls + */ + + generalCreateProcedure (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 generalCreateProcedure" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.procedureName !== undefined && opts.procedureName !== null) { + postBody['procedureName'] = opts.procedureName + } + if ( + opts.procedureSecurity !== undefined && + opts.procedureSecurity !== null + ) { + postBody['procedureSecurity'] = opts.procedureSecurity + } + if (opts.dataAccess !== undefined && opts.dataAccess !== null) { + postBody['dataAccess'] = opts.dataAccess + } + if (opts.deterministic !== undefined && opts.deterministic !== null) { + postBody['deterministic'] = opts.deterministic + } + if (opts.definitionSql !== undefined && opts.definitionSql !== null) { + postBody['definitionSql'] = opts.definitionSql + } + if (opts.parameters !== undefined && opts.parameters !== null) { + postBody['parameters'] = opts.parameters + } + if (opts.definer !== undefined && opts.definer !== null) { + postBody['definer'] = opts.definer + } + if (opts.comment !== undefined && opts.comment !== null) { + postBody['comment'] = opts.comment + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 generalCreateProcedure 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}/procedure:generalCreate', + '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) + } + ) + } + + /** + * 生成修改存储过程sql语句,支持Mysql + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 数据库名称。 optional + * @param {} [opts.originProcedureName] - 原存储过程名称。 optional + * @param {} [opts.procedureName] - 存储过程名称。 optional + * @param {} [opts.definer] - 定义者。 optional + * @param {} [opts.procedureSecurity] - 安全性,DEFAULT("DEFAULT", 1),DEFINER("DEFINER", 2), INVOKER("INVOKER", 3); optional + * @param {} [opts.dataAccess] - 数据访问,DEFAULT("DEFAULT", 1),NO_SQL("NO_SQL", 2), CONTAINS_SQL("CONTAINS_SQL", 3), READS_SQL_DATA("READS_SQL_DATA", 4), MODIFIES_SQL_DATA("MODIFIES_SQL_DATA", 5); optional + * @param {} [opts.deterministic] - 确定性。 optional + * @param {} [opts.definitionSql] - 存储过程定义SQL。 optional + * @param {} [opts.completeSql] - 创建存储过程定义完整SQL。 optional + * @param {} [opts.parameters] - 参数列表。 optional + * @param {} [opts.comment] - 注释 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dmsSql dmsSqls + */ + + generalAlterProcedure (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 generalAlterProcedure" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if ( + opts.originProcedureName !== undefined && + opts.originProcedureName !== null + ) { + postBody['originProcedureName'] = opts.originProcedureName + } + if (opts.procedureName !== undefined && opts.procedureName !== null) { + postBody['procedureName'] = opts.procedureName + } + if (opts.definer !== undefined && opts.definer !== null) { + postBody['definer'] = opts.definer + } + if ( + opts.procedureSecurity !== undefined && + opts.procedureSecurity !== null + ) { + postBody['procedureSecurity'] = opts.procedureSecurity + } + if (opts.dataAccess !== undefined && opts.dataAccess !== null) { + postBody['dataAccess'] = opts.dataAccess + } + if (opts.deterministic !== undefined && opts.deterministic !== null) { + postBody['deterministic'] = opts.deterministic + } + if (opts.definitionSql !== undefined && opts.definitionSql !== null) { + postBody['definitionSql'] = opts.definitionSql + } + if (opts.completeSql !== undefined && opts.completeSql !== null) { + postBody['completeSql'] = opts.completeSql + } + if (opts.parameters !== undefined && opts.parameters !== null) { + postBody['parameters'] = opts.parameters + } + if (opts.comment !== undefined && opts.comment !== null) { + postBody['comment'] = opts.comment + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 generalAlterProcedure 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}/procedure:generalAlter', + '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) + } + ) + } + + /** + * 生成删除存储过程sql语句,支持Mysql + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 数据库名称。 optional + * @param {} [opts.procedureName] - 存储过程名称。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dmsSql dmsSqls + */ + + generalDropProcedure (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 generalDropProcedure" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.procedureName !== undefined && opts.procedureName !== null) { + postBody['procedureName'] = opts.procedureName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 generalDropProcedure 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}/procedure:generalDrop', + '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) + } + ) + } + + /** + * 获取存储过程列表,支持Mysql + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 数据库名称。 optional + * @param {} [opts.filter] - 过滤条件。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string procedureNames 存储过程名称 + */ + + procedureList (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 procedureList" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.filter !== undefined && opts.filter !== null) { + postBody['filter'] = opts.filter + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 procedureList 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}/procedure:list', + '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) + } + ) + } + + /** + * 获取存储过程详情,支持Mysql + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 数据库名称。 optional + * @param {} [opts.procedureName] - 存储过程名称。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string dbName 数据库名称。 + * @param string procedureName 存储过程名称。 + * @param string definer 定义者。 + * @param string procedureSecurity 安全性,DEFAULT("DEFAULT", 1),DEFINER("DEFINER", 2), INVOKER("INVOKER", 3); + * @param string dataAccess 数据访问,DEFAULT("DEFAULT", 1),NO_SQL("NO_SQL", 2), CONTAINS_SQL("CONTAINS_SQL", 3), READS_SQL_DATA("READS_SQL_DATA", 4), MODIFIES_SQL_DATA("MODIFIES_SQL_DATA", 5); + * @param boolean deterministic 确定性。 + * @param string definitionSql 存储过程定义SQL。 + * @param string completeSql 创建存储过程定义完整SQL。 + * @param parameter parameters + * @param string comment 注释 + */ + + procedureInfo (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 procedureInfo" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.procedureName !== undefined && opts.procedureName !== null) { + postBody['procedureName'] = opts.procedureName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 procedureInfo 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}/procedure:info', + '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) + } + ) + } + + /** + * 执行存储过程,支持Mysql + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 数据库名称。 optional + * @param {} [opts.procedureName] - 存储过程名称。 optional + * @param {} [opts.parameters] - 参数。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param object returnValue 格式:{key:value} + */ + + procedureInvoke (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 procedureInvoke" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.procedureName !== undefined && opts.procedureName !== null) { + postBody['procedureName'] = opts.procedureName + } + if (opts.parameters !== undefined && opts.parameters !== null) { + postBody['parameters'] = opts.parameters + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 procedureInvoke 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}/procedure:invoke', + '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) + } + ) + } + + /** + * 获取视图列表,支持Mysql + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 数据库名称。 optional + * @param {} [opts.filter] - 过滤条件。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string viewNames 视图名称 + * @param string procedureNames 存储过程名称 + * @param string functionNames 函数名称 + * @param string triggerNames 触发器名称 + * @param string eventNames 事件名称 + */ + + programList (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 programList" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.filter !== undefined && opts.filter !== null) { + postBody['filter'] = opts.filter + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 programList 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}/program:list', + '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) + } + ) + } + + /** + * 执行编程对象sql,支持Mysql + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 数据库名称。 optional + * @param {} [opts.dmsSqls] - SQL列表。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + exeProgram (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 exeProgram" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.dmsSqls !== undefined && opts.dmsSqls !== null) { + postBody['dmsSqls'] = opts.dmsSqls + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 exeProgram 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}/program:exe', + '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) + } + ) + } + + /** + * 执行计划,支持Mysql,Stardb + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 数据库名称 optional + * @param {} [opts.sqls] - sql语句。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dmsSqlResult dmsSqlResults + */ + + consoleExplain (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 consoleExplain" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.sqls !== undefined && opts.sqls !== null) { + postBody['sqls'] = opts.sqls + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 consoleExplain 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}/console:explain', + '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) + } + ) + } + + /** + * 执行sql语句,支持Mysql,Stardb,Tidb,ClickHouse + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 数据库名称 optional + * @param {} [opts.sqls] - sql语句。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dmsSqlResult dmsSqlResults + */ + + consoleSql (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 consoleSql" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.sqls !== undefined && opts.sqls !== null) { + postBody['sqls'] = opts.sqls + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 consoleSql 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}/console:exeSql', + '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) + } + ) + } + + /** + * 生成数据,支持Mysql,Stardb + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 数据库名称 optional + * @param {} [opts.tableName] - 表名。 optional + * @param {} [opts.count] - 生成数据行数。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dmsSqlsResult dmsSqlsResult + */ + + consoleGeneralData (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 consoleGeneralData" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.tableName !== undefined && opts.tableName !== null) { + postBody['tableName'] = opts.tableName + } + if (opts.count !== undefined && opts.count !== null) { + postBody['count'] = opts.count + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 consoleGeneralData 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}/console:generalData', + '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) + } + ) + } + + /** + * sql格式化,支持Mysql,Stardb + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.sqlStr] - 需要格式化的sql optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string strResult 格式化后的SQL + */ + + formatSql (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 formatSql" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.sqlStr !== undefined && opts.sqlStr !== null) { + postBody['sqlStr'] = opts.sqlStr + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 formatSql 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}/sql:format', + '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) + } + ) + } + + /** + * 批量建表,支持Stardb + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 数据库名称 optional + * @param {} [opts.createTableInfos] - 查询结果。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dmsSqlsResult dmsSqlsResult + */ + + createTableBatch (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 createTableBatch" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.createTableInfos !== undefined && opts.createTableInfos !== null) { + postBody['createTableInfos'] = opts.createTableInfos + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 createTableBatch 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}/console:createTableBatch', + '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) + } + ) + } + + /** + * 获取批量建表sql,仅供前端使用,支持Stardb,OpenGauss + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 数据库名称 optional + * @param {} [opts.createTableInfos] - 查询结果。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string strResult 格式化后的SQL + */ + + getCreateTableBatchSql (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 getCreateTableBatchSql" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.createTableInfos !== undefined && opts.createTableInfos !== null) { + postBody['createTableInfos'] = opts.createTableInfos + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 getCreateTableBatchSql 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}/console:getCreateTableBatchSql', + '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) + } + ) + } + + /** + * 创建Sql任务 + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 数据库名称。 optional + * @param {} [opts.planTime] - 计划开始执行时间,stardb数据源固定为空。 optional + * @param {} [opts.sqls] - 执行SQL。 optional + * @param {} [opts.taskTypeEnum] - 任务类型:DDL, DML optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer intResult 任务id + */ + + createOnlineSqlTask (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 createOnlineSqlTask" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.planTime !== undefined && opts.planTime !== null) { + postBody['planTime'] = opts.planTime + } + if (opts.sqls !== undefined && opts.sqls !== null) { + postBody['sqls'] = opts.sqls + } + if (opts.taskTypeEnum !== undefined && opts.taskTypeEnum !== null) { + postBody['taskTypeEnum'] = opts.taskTypeEnum + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 createOnlineSqlTask 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}/sqltask:create', + '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) + } + ) + } + + /** + * 启动Sql任务 + * @param {Object} opts - parameters + * @param {} [opts.taskId] - 任务id optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + startOnlineSqlTask (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 startOnlineSqlTask" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.taskId !== undefined && opts.taskId !== null) { + postBody['taskId'] = opts.taskId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 startOnlineSqlTask 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}/sqltask:start', + '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) + } + ) + } + + /** + * 暂停Sql任务 + * @param {Object} opts - parameters + * @param {} [opts.taskId] - 任务id optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + suspendOnlineSqlTask (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 suspendOnlineSqlTask" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.taskId !== undefined && opts.taskId !== null) { + postBody['taskId'] = opts.taskId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 suspendOnlineSqlTask 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}/sqltask:suspend', + '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) + } + ) + } + + /** + * 重启Sql任务 + * @param {Object} opts - parameters + * @param {} [opts.taskId] - 任务id optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + restartOnlineSqlTask (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 restartOnlineSqlTask" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.taskId !== undefined && opts.taskId !== null) { + postBody['taskId'] = opts.taskId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 restartOnlineSqlTask 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}/sqltask:restart', + '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 {} [opts.taskId] - 任务id optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer id 主键id。 + * @param integer dataSourceId 数据源id。 + * @param string dbName 数据库名称。 + * @param string taskType 任务类型,DDL, DML。 + * @param string planTime 计划时间。 + * @param boolean transaction 是否为事务。 + * @param boolean parallel 是否为并行执行。 + * @param boolean ignoreError 是否忽略错误。 + * @param string runStatus 运行状态。CREATE("CREATE", 1),RUNNING("RUNNING", 2), SUCCESS("SUCCESS", 3), FAILED("FAILED", 4), SUSPEND("SUSPEND", 5); + * @param string createdDate 创建日期。 + * @param string finishDate 结束日期。 + * @param string createUser 创建用户。 + * @param string status 状态0有效,1无效。 + * @param string message 执行消息。 + * @param string runIp 运行ip。 + */ + + onlineSqlTaskQuery (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 onlineSqlTaskQuery" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.taskId !== undefined && opts.taskId !== null) { + postBody['taskId'] = opts.taskId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 onlineSqlTaskQuery 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}/sqltask:query', + '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) + } + ) + } + + /** + * 查询sql子任务状态 + * @param {Object} opts - parameters + * @param {} [opts.taskId] - 任务id optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dmsOnlineSubSqlTask dmsOnlineSubSqlTasks + */ + + onlineSubSqlTaskQuery (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 onlineSubSqlTaskQuery" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.taskId !== undefined && opts.taskId !== null) { + postBody['taskId'] = opts.taskId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 onlineSubSqlTaskQuery 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}/subsqltask:query', + '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) + } + ) + } + + /** + * 查询sql子任务状态 + * @param {Object} opts - parameters + * @param {} [opts.taskId] - dms任务id optional + * @param {} [opts.proxyTaskId] - proxy任务id optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dmsOnlineProxySubTask dmsOnlineProxySubTasks + */ + + onlineProxySubTaskQuery (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 onlineProxySubTaskQuery" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.taskId !== undefined && opts.taskId !== null) { + postBody['taskId'] = opts.taskId + } + if (opts.proxyTaskId !== undefined && opts.proxyTaskId !== null) { + postBody['proxyTaskId'] = opts.proxyTaskId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 onlineProxySubTaskQuery 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}/proxysubtask:query', + '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) + } + ) + } + + /** + * 生成创建触发器SQL语句,支持Mysql + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id。 optional + * @param {} [opts.dbName] - 数据库名称。 optional + * @param {} [opts.triggerName] - 触发器名称。 optional + * @param {} [opts.triggerTiming] - 触发时机,BEFORE("BEFORE", 1),AFTER("AFTER", 2)。 optional + * @param {} [opts.triggerEvent] - 激活触发器的事件,INSERT("INSERT", 1),UPDATE("UPDATE", 2), DELETE("DELETE", 3)。 optional + * @param {} [opts.triggerTable] - 触发表。 optional + * @param {} [opts.triggerStatement] - 触发器定义。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dmsSql dmsSqls + */ + + generalCreateTrigger (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 generalCreateTrigger" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.triggerName !== undefined && opts.triggerName !== null) { + postBody['triggerName'] = opts.triggerName + } + if (opts.triggerTiming !== undefined && opts.triggerTiming !== null) { + postBody['triggerTiming'] = opts.triggerTiming + } + if (opts.triggerEvent !== undefined && opts.triggerEvent !== null) { + postBody['triggerEvent'] = opts.triggerEvent + } + if (opts.triggerTable !== undefined && opts.triggerTable !== null) { + postBody['triggerTable'] = opts.triggerTable + } + if (opts.triggerStatement !== undefined && opts.triggerStatement !== null) { + postBody['triggerStatement'] = opts.triggerStatement + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 generalCreateTrigger 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}/trigger:generalCreate', + '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) + } + ) + } + + /** + * 生成修改触发器sql语句,支持Mysql + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 数据库名称。 optional + * @param {} [opts.originTriggerName] - 原触发器名称。 optional + * @param {} [opts.triggerName] - 触发器名称。 optional + * @param {} [opts.triggerTiming] - 触发时机,BEFORE("BEFORE", 1),AFTER("AFTER", 2)。 optional + * @param {} [opts.triggerEvent] - 激活触发器的事件,INSERT("INSERT", 1),UPDATE("UPDATE", 2), DELETE("DELETE", 3)。 optional + * @param {} [opts.triggerTable] - 触发表。 optional + * @param {} [opts.triggerStatement] - 触发器定义。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dmsSql dmsSqls + */ + + generalAlterTrigger (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 generalAlterTrigger" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if ( + opts.originTriggerName !== undefined && + opts.originTriggerName !== null + ) { + postBody['originTriggerName'] = opts.originTriggerName + } + if (opts.triggerName !== undefined && opts.triggerName !== null) { + postBody['triggerName'] = opts.triggerName + } + if (opts.triggerTiming !== undefined && opts.triggerTiming !== null) { + postBody['triggerTiming'] = opts.triggerTiming + } + if (opts.triggerEvent !== undefined && opts.triggerEvent !== null) { + postBody['triggerEvent'] = opts.triggerEvent + } + if (opts.triggerTable !== undefined && opts.triggerTable !== null) { + postBody['triggerTable'] = opts.triggerTable + } + if (opts.triggerStatement !== undefined && opts.triggerStatement !== null) { + postBody['triggerStatement'] = opts.triggerStatement + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 generalAlterTrigger 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}/trigger:generalAlter', + '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) + } + ) + } + + /** + * 生成删除触发器sql语句,支持Mysql + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 数据库名称。 optional + * @param {} [opts.triggerName] - 触发器名称。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dmsSql dmsSqls + */ + + generalDropTrigger (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 generalDropTrigger" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.triggerName !== undefined && opts.triggerName !== null) { + postBody['triggerName'] = opts.triggerName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 generalDropTrigger 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}/trigger:generalDrop', + '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) + } + ) + } + + /** + * 获取触发器列表,支持Mysql + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 数据库名称。 optional + * @param {} [opts.filter] - 过滤条件。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string triggerNames 触发器名称 + */ + + triggerList (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 triggerList" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.filter !== undefined && opts.filter !== null) { + postBody['filter'] = opts.filter + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 triggerList 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}/trigger:list', + '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) + } + ) + } + + /** + * 获取触发器详情,支持Mysql + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 数据库名称。 optional + * @param {} [opts.triggerName] - 触发器名称。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string dbName 数据库名称。 + * @param string triggerName 存储过程名称。 + * @param string triggerTiming 触发时机,BEFORE("BEFORE", 1),AFTER("AFTER", 2)。 + * @param string triggerEvent 激活触发器的事件,INSERT("INSERT", 1),UPDATE("UPDATE", 2), DELETE("DELETE", 3)。 + * @param string triggerTable 触发表 + * @param string triggerStatement 触发器定义。 + */ + + triggerInfo (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 triggerInfo" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.triggerName !== undefined && opts.triggerName !== null) { + postBody['triggerName'] = opts.triggerName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 triggerInfo 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}/trigger:info', + '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 {} [opts.activeStatus] - 查询的用户状态(启用(true),禁用(false)) optional + * @param {} [opts.role] - 查询的用户角色,枚举值(Admin("Admin","管理员"),DBA("DBA","DBA"),StructureReadOnly("StructureReadOnly","结构只读"),Normal("Normal","普通用户")) optional + * @param {} [opts.loginDateStart] - 查询的用户登录开始时间(yyyy-MM-dd'T'HH:mm:ss.SSS'Z') optional + * @param {} [opts.loginDateEnd] - 查询的用户登录结束时间(yyyy-MM-dd'T'HH:mm:ss.SSS'Z') optional + * @param {} [opts.username] - 查询用户的用户名称 optional + * @param {} [opts.pageNumber] - 显示数据的页码,取值范围:[1,∞)。pageNumber为Null时,返回所有数据页码;超过总页数时,无数据。 optional + * @param {} [opts.pageSize] - 每页显示的数据条数,用于查询列表的接口。 optional + * @param {string} callback - callback + @return {Object} result + * @param integer count 符合条件的用户的总数 + * @param dmsUserVO dmsUserVOList + */ + + queryUserList (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.activeStatus !== undefined && opts.activeStatus !== null) { + postBody['activeStatus'] = opts.activeStatus + } + if (opts.role !== undefined && opts.role !== null) { + postBody['role'] = opts.role + } + if (opts.loginDateStart !== undefined && opts.loginDateStart !== null) { + postBody['loginDateStart'] = opts.loginDateStart + } + if (opts.loginDateEnd !== undefined && opts.loginDateEnd !== null) { + postBody['loginDateEnd'] = opts.loginDateEnd + } + if (opts.username !== undefined && opts.username !== null) { + postBody['username'] = opts.username + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 queryUserList 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( + '/management:queryUserList', + '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 {} [opts.pageNumber] - 第几页,不传的话会将当前所有的未同步的账号都同步过来 optional + * @param {} [opts.pageSize] - 页大小。 optional + * @param {} [opts.keyword] - 关键字。 optional + * @param {} [opts.sort] - 排序规则:0-创建时间顺序排序,1-创建时间倒序排序。 optional + * @param {string} callback - callback + @return {Object} result + * @param integer total 子账号总数量 + * @param dmsSubUserVO subUserList + */ + + queryUserNotSync (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + if (opts.keyword !== undefined && opts.keyword !== null) { + postBody['keyword'] = opts.keyword + } + if (opts.sort !== undefined && opts.sort !== null) { + postBody['sort'] = opts.sort + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 queryUserNotSync 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( + '/management:queryUserNotSync', + '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 {} [opts.dmsSyncSubUserVOList] - 同步的子账号的列表信息 optional + * @param {string} callback - callback + @return {Object} result + */ + + syncSubUser (opts, callback) { + opts = opts || {} + + let postBody = {} + if ( + opts.dmsSyncSubUserVOList !== undefined && + opts.dmsSyncSubUserVOList !== null + ) { + postBody['dmsSyncSubUserVOList'] = opts.dmsSyncSubUserVOList + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 syncSubUser 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( + '/management:syncSubUser', + '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 {} [opts.pin] - 被更新用户的pin信息 optional + * @param {} [opts.phone] - 用户手机号码 optional + * @param {} [opts.email] - 用户邮箱 optional + * @param {} [opts.roleList] - 用户角色列表信息 optional + * @param {string} callback - callback + @return {Object} result + */ + + updateUserInfo (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.pin !== undefined && opts.pin !== null) { + postBody['pin'] = opts.pin + } + if (opts.phone !== undefined && opts.phone !== null) { + postBody['phone'] = opts.phone + } + if (opts.email !== undefined && opts.email !== null) { + postBody['email'] = opts.email + } + if (opts.roleList !== undefined && opts.roleList !== null) { + postBody['roleList'] = opts.roleList + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 updateUserInfo 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( + '/management:updateUserInfo', + '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 {} [opts.dmsUserEnableVOList] - 启用/禁用的用户列表信息 optional + * @param {string} callback - callback + @return {Object} result + */ + + enableUser (opts, callback) { + opts = opts || {} + + let postBody = {} + if ( + opts.dmsUserEnableVOList !== undefined && + opts.dmsUserEnableVOList !== null + ) { + postBody['dmsUserEnableVOList'] = opts.dmsUserEnableVOList + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 enableUser 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( + '/management:enableUser', + '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 {} [opts.dmsUserDeleteList] - 删除用户的pin信息 optional + * @param {string} callback - callback + @return {Object} result + */ + + deleteUser (opts, callback) { + opts = opts || {} + + let postBody = {} + if ( + opts.dmsUserDeleteList !== undefined && + opts.dmsUserDeleteList !== null + ) { + postBody['dmsUserDeleteList'] = opts.dmsUserDeleteList + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 deleteUser 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( + '/management:deleteUser', + '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} callback - callback + @return {Object} result + * @param boolean isMaster 是否是主账号 + * @param string username 用户名 + * @param string pin 用户pin + * @param string masterPin 用户主账号pin + * @param integer accountId 用户账号Id + * @param string roleList + */ + + getUserInfo (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 getUserInfo 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( + '/management:getUserInfo', + '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 {} [opts.instanceId] - 实例ID optional + * @param {} [opts.instanceName] - 实例名称 optional + * @param {} [opts.pin] - 用户账号 optional + * @param {} [opts.showNormal] - 是否只显示生效中的授权信息 optional + * @param {} [opts.releaseStatus] - 是否只显示释放的记录,true展示释放权限的记录 optional + * @param {} [opts.pageNumber] - 显示数据的页码,取值范围:[1,∞)。pageNumber为Null时,返回所有数据页码;超过总页数时,无数据。 optional + * @param {} [opts.pageSize] - 每页显示的数据条数,用于查询列表的接口。 optional + * @param {string} callback - callback + @return {Object} result + * @param integer count 符合条件的用户的总数 + * @param boolean isAdmin 如果为真则表示这个账号默认就拥有所有的实例登录权限 + * @param dmsPrivilegeVO dmsPrivilegeVOList + */ + + queryPrivilegeList (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.instanceId !== undefined && opts.instanceId !== null) { + postBody['instanceId'] = opts.instanceId + } + if (opts.instanceName !== undefined && opts.instanceName !== null) { + postBody['instanceName'] = opts.instanceName + } + if (opts.pin !== undefined && opts.pin !== null) { + postBody['pin'] = opts.pin + } + if (opts.showNormal !== undefined && opts.showNormal !== null) { + postBody['showNormal'] = opts.showNormal + } + if (opts.releaseStatus !== undefined && opts.releaseStatus !== null) { + postBody['releaseStatus'] = opts.releaseStatus + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 queryPrivilegeList 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( + '/management:queryPrivilegeList', + '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 {} [opts.instanceId] - 实例ID optional + * @param {} [opts.instanceName] - 实例名称 optional + * @param {} [opts.showNormal] - 是否只显示生效中的授权信息 optional + * @param {} [opts.releaseStatus] - 是否只显示释放的记录,true展示释放权限的记录 optional + * @param {} [opts.pageNumber] - 显示数据的页码,取值范围:[1,∞)。pageNumber为Null时,返回所有数据页码;超过总页数时,无数据。 optional + * @param {} [opts.pageSize] - 每页显示的数据条数,用于查询列表的接口。 optional + * @param {string} callback - callback + @return {Object} result + * @param integer count 符合条件的用户的总数 + * @param boolean isAdmin 如果为真则表示这个账号默认就拥有所有的实例登录权限 + * @param dmsPrivilegeVO dmsPrivilegeVOList + */ + + queryPrivilegeSelfList (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.instanceId !== undefined && opts.instanceId !== null) { + postBody['instanceId'] = opts.instanceId + } + if (opts.instanceName !== undefined && opts.instanceName !== null) { + postBody['instanceName'] = opts.instanceName + } + if (opts.showNormal !== undefined && opts.showNormal !== null) { + postBody['showNormal'] = opts.showNormal + } + if (opts.releaseStatus !== undefined && opts.releaseStatus !== null) { + postBody['releaseStatus'] = opts.releaseStatus + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 queryPrivilegeSelfList 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( + '/management:queryPrivilegeSelfList', + '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 {} [opts.idList] - 授权实例记录对应的主键ID optional + * @param {string} callback - callback + @return {Object} result + */ + + releasePrivilege (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.idList !== undefined && opts.idList !== null) { + postBody['idList'] = opts.idList + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 releasePrivilege 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( + '/management:releasePrivilege', + '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 {} [opts.pinList] - 用户pin列表信息 optional + * @param {} [opts.privilegeName] - 权限名称,枚举值:PrivilegeLogin(实例登录权限) optional + * @param {} [opts.expireDate] - 授权过期时间(yyyy-MM-dd'T'HH:mm:ss.SSS'Z') optional + * @param {} [opts.dmsPrivilegeInstanceParamList] - 授权实例的信息,主要包括用户实例ID和实例名称 optional + * @param {string} callback - callback + @return {Object} result + */ + + authPrivilege (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.pinList !== undefined && opts.pinList !== null) { + postBody['pinList'] = opts.pinList + } + if (opts.privilegeName !== undefined && opts.privilegeName !== null) { + postBody['privilegeName'] = opts.privilegeName + } + if (opts.expireDate !== undefined && opts.expireDate !== null) { + postBody['expireDate'] = opts.expireDate + } + if ( + opts.dmsPrivilegeInstanceParamList !== undefined && + opts.dmsPrivilegeInstanceParamList !== null + ) { + postBody['dmsPrivilegeInstanceParamList'] = + opts.dmsPrivilegeInstanceParamList + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 authPrivilege 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( + '/management:authPrivilege', + '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 {} [opts.idList] - 授权实例记录对应的主键ID optional + * @param {} [opts.expireDate] - 授权过期时间(yyyy-MM-dd'T'HH:mm:ss.SSS'Z') optional + * @param {string} callback - callback + @return {Object} result + */ + + modifyPrivilegeExpireDate (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.idList !== undefined && opts.idList !== null) { + postBody['idList'] = opts.idList + } + if (opts.expireDate !== undefined && opts.expireDate !== null) { + postBody['expireDate'] = opts.expireDate + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 modifyPrivilegeExpireDate 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( + '/management:modifyPrivilegeExpireDate', + '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) + } + ) + } + + /** + * 生产创建视图SQL语句,支持Mysql + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id。 optional + * @param {} [opts.dbName] - 数据库名称。 optional + * @param {} [opts.viewName] - 视图名称。 optional + * @param {} [opts.viewAlgorithm] - 视图算法,DEFAULT("DEFAULT", 1),UNDEFINED("UNDEFINED", 2), MERGE("MERGE", 3), TEMPTABLE("TEMPTABLE", 4); optional + * @param {} [opts.definer] - 定义者。 optional + * @param {} [opts.viewSecurity] - 安全性,DEFAULT("DEFAULT", 1),DEFINER("DEFINER", 2), INVOKER("INVOKER", 3); optional + * @param {} [opts.viewCheckOption] - 检查选项,DEFAULT("DEFAULT", 1),LOCAL("LOCAL", 2), CASCADED("CASCADED", 3);; optional + * @param {} [opts.definitionSql] - 视图定义。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dmsSql dmsSqls + */ + + generalCreateView (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 generalCreateView" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.viewName !== undefined && opts.viewName !== null) { + postBody['viewName'] = opts.viewName + } + if (opts.viewAlgorithm !== undefined && opts.viewAlgorithm !== null) { + postBody['viewAlgorithm'] = opts.viewAlgorithm + } + if (opts.definer !== undefined && opts.definer !== null) { + postBody['definer'] = opts.definer + } + if (opts.viewSecurity !== undefined && opts.viewSecurity !== null) { + postBody['viewSecurity'] = opts.viewSecurity + } + if (opts.viewCheckOption !== undefined && opts.viewCheckOption !== null) { + postBody['viewCheckOption'] = opts.viewCheckOption + } + if (opts.definitionSql !== undefined && opts.definitionSql !== null) { + postBody['definitionSql'] = opts.definitionSql + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 generalCreateView 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}/view:generalCreate', + '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) + } + ) + } + + /** + * 生成修改视图sql语句,支持Mysql + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 数据库名称。 optional + * @param {} [opts.viewName] - 视图名称。 optional + * @param {} [opts.originViewName] - 原始视图名称。 optional + * @param {} [opts.viewAlgorithm] - 视图算法,DEFAULT("DEFAULT", 1),UNDEFINED("UNDEFINED", 2), MERGE("MERGE", 3), TEMPTABLE("TEMPTABLE", 4); optional + * @param {} [opts.definer] - 定义者。 optional + * @param {} [opts.viewSecurity] - 安全性,DEFAULT("DEFAULT", 1),DEFINER("DEFINER", 2), INVOKER("INVOKER", 3); optional + * @param {} [opts.viewCheckOption] - 检查选项,DEFAULT("DEFAULT", 1),LOCAL("LOCAL", 2), CASCADED("CASCADED", 3);; optional + * @param {} [opts.definitionSql] - 视图定义。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dmsSql dmsSqls + */ + + generalAlterView (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 generalAlterView" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.viewName !== undefined && opts.viewName !== null) { + postBody['viewName'] = opts.viewName + } + if (opts.originViewName !== undefined && opts.originViewName !== null) { + postBody['originViewName'] = opts.originViewName + } + if (opts.viewAlgorithm !== undefined && opts.viewAlgorithm !== null) { + postBody['viewAlgorithm'] = opts.viewAlgorithm + } + if (opts.definer !== undefined && opts.definer !== null) { + postBody['definer'] = opts.definer + } + if (opts.viewSecurity !== undefined && opts.viewSecurity !== null) { + postBody['viewSecurity'] = opts.viewSecurity + } + if (opts.viewCheckOption !== undefined && opts.viewCheckOption !== null) { + postBody['viewCheckOption'] = opts.viewCheckOption + } + if (opts.definitionSql !== undefined && opts.definitionSql !== null) { + postBody['definitionSql'] = opts.definitionSql + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 generalAlterView 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}/view:generalAlter', + '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) + } + ) + } + + /** + * 生成删除视图sql语句,支持Mysql + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 数据库名称。 optional + * @param {} [opts.viewName] - 视图名称。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dmsSql dmsSqls + */ + + generalDropView (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 generalDropView" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.viewName !== undefined && opts.viewName !== null) { + postBody['viewName'] = opts.viewName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 generalDropView 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}/view:generalDrop', + '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) + } + ) + } + + /** + * 获取视图详情,支持Mysql + * @param {Object} opts - parameters + * @param {} [opts.dataSourceId] - 数据源id optional + * @param {} [opts.dbName] - 数据库名称。 optional + * @param {} [opts.viewName] - 视图名称。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string dbName 数据库名称。 + * @param string viewName 视图名称。 + * @param string definer 定义者。 + * @param string viewAlgorithm 算法。 + * @param string viewCheckOption 检查选项。 + * @param string viewSecurity 安全性。 + * @param string definitionSql 视图定义。 + */ + + viewInfo (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 viewInfo" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.dataSourceId !== undefined && opts.dataSourceId !== null) { + postBody['dataSourceId'] = opts.dataSourceId + } + if (opts.dbName !== undefined && opts.dbName !== null) { + postBody['dbName'] = opts.dbName + } + if (opts.viewName !== undefined && opts.viewName !== null) { + postBody['viewName'] = opts.viewName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dms/1.4.0' + } + + 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 viewInfo 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}/view:info', + '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 = DMS diff --git a/packages/libs/lib-jdcloud/src/repo/domain/v1/domain.js b/packages/libs/lib-jdcloud/src/repo/domain/v1/domain.js new file mode 100644 index 000000000..162b8ee3d --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/domain/v1/domain.js @@ -0,0 +1,2307 @@ +/* + * 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. + * + * Domain-Template + * 域名模板相关接口 + * + * 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 = 'domain' +Service._services[serviceId] = true + +/** + * domain service. + * @version 1.0.0 + */ + +class DOMAIN extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'domain.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 检查域名是否可以注册 + * @param {Object} opts - parameters + * @param {string} opts.domainName - 要检查的域名 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param checkDomain data 检查域名的返回结果 + */ + + checkDomain (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 checkDomain" + ) + } + + opts = opts || {} + + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling checkDomain" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domain/1.0.0' + } + + 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 checkDomain 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}/domain:check', + '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) + } + ) + } + + /** + * 查询域名的whois信息 + * @param {Object} opts - parameters + * @param {string} opts.domainName - 要检查的域名 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param domainWhoisInfo data 域名Whois返回结果 + */ + + queryWhoisInfo (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 queryWhoisInfo" + ) + } + + opts = opts || {} + + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling queryWhoisInfo" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domain/1.0.0' + } + + 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 queryWhoisInfo 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}/domain:whoisInfo', + '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.domainName - 要注册的域名 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param domainInfo data 域名信息返回结果 + */ + + domainInfo (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 domainInfo" + ) + } + + opts = opts || {} + + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling domainInfo" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domain/1.0.0' + } + + 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 domainInfo 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}/domain', + '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) + } + ) + } + + /** + * 域名注册 +域名注册前,请确保用户的京东云账户有足够的资金支付,Openapi接口回返回订单号,可以用此订单号向计费系统查阅详情 + + * @param {Object} opts - parameters + * @param {string} opts.domainName - 域名 + * @param {integer} opts.term - 注册年限,最多10年 + * @param {integer} opts.templateId - 模板ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param domainOrder data 域名购买返回结果,后续需要调用订单支付接口 + */ + + createDomain (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 createDomain" + ) + } + + opts = opts || {} + + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling createDomain" + ) + } + if (opts.term === undefined || opts.term === null) { + throw new Error( + "Missing the required parameter 'opts.term' when calling createDomain" + ) + } + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling createDomain" + ) + } + + let postBody = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + postBody['domainName'] = opts.domainName + } + if (opts.term !== undefined && opts.term !== null) { + postBody['term'] = opts.term + } + if (opts.templateId !== undefined && opts.templateId !== null) { + postBody['templateId'] = opts.templateId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domain/1.0.0' + } + + 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 createDomain 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}/domain', + '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) + } + ) + } + + /** + * 针对用户的域名进行续费 +域名续费前,请确保用户的京东云账户有足够的资金支付,Openapi接口回返回订单号,可以用此订单号向计费系统查阅详情 + + * @param {Object} opts - parameters + * @param {string} opts.domainName - 域名 + * @param {integer} opts.term - 续费年限,最多10年 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param domainOrder data 域名续费返回结果,后续需要调用订单支付接口 + */ + + renewDomain (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 renewDomain" + ) + } + + opts = opts || {} + + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling renewDomain" + ) + } + if (opts.term === undefined || opts.term === null) { + throw new Error( + "Missing the required parameter 'opts.term' when calling renewDomain" + ) + } + + let postBody = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + postBody['domainName'] = opts.domainName + } + if (opts.term !== undefined && opts.term !== null) { + postBody['term'] = opts.term + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domain/1.0.0' + } + + 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 renewDomain 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}/renew', + '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.domainName - 要转入的域名 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer transferInState 转入状态:0转入失败 1验证邮箱 2转入处理中 3转入成功 + */ + + transferinDomainState (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 transferinDomainState" + ) + } + + opts = opts || {} + + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling transferinDomainState" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domain/1.0.0' + } + + 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 transferinDomainState 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}/transferin', + '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) + } + ) + } + + /** + * 用于提交域名转入操作 +要转入域名前,请确保用户的京东云账户有足够的资金支付,Openapi接口回返回订单号,可以用此订单号向计费系统查阅详情 + + * @param {Object} opts - parameters + * @param {string} opts.domainName - 域名 + * @param {string} opts.passWord - 域名转移密码 + * @param {integer} opts.templateId - 模板ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param domainOrder data 域名转入返回结果,后续需要调用订单支付接口,待支付完成后,查询域名转入进度 + */ + + transferinDomain (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 transferinDomain" + ) + } + + opts = opts || {} + + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling transferinDomain" + ) + } + if (opts.passWord === undefined || opts.passWord === null) { + throw new Error( + "Missing the required parameter 'opts.passWord' when calling transferinDomain" + ) + } + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling transferinDomain" + ) + } + + let postBody = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + postBody['domainName'] = opts.domainName + } + if (opts.passWord !== undefined && opts.passWord !== null) { + postBody['passWord'] = opts.passWord + } + if (opts.templateId !== undefined && opts.templateId !== null) { + postBody['templateId'] = opts.templateId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domain/1.0.0' + } + + 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 transferinDomain 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}/transferin', + '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) + } + ) + } + + /** + * 根据域名修改域名对应的 DNS 信息 + * @param {Object} opts - parameters + * @param {string} opts.domainName - 要修改的域名 + * @param {array} [opts.dns] - 要修改的DNS,个数要求再2个-6个之间 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyDns (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 modifyDns" + ) + } + + opts = opts || {} + + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling modifyDns" + ) + } + + let postBody = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + postBody['domainName'] = opts.domainName + } + if (opts.dns !== undefined && opts.dns !== null) { + postBody['dns'] = opts.dns + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domain/1.0.0' + } + + 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 modifyDns 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}/domain:dns', + '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) + } + ) + } + + /** + * 通过已实名的信息模板,完成域名的快速过户 + * @param {Object} opts - parameters + * @param {string} opts.domainName - 要修改的域名 + * @param {integer} opts.templateId - 要过户的模板ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + domainTemplateAssigned (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 domainTemplateAssigned" + ) + } + + opts = opts || {} + + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling domainTemplateAssigned" + ) + } + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling domainTemplateAssigned" + ) + } + + let postBody = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + postBody['domainName'] = opts.domainName + } + if (opts.templateId !== undefined && opts.templateId !== null) { + postBody['templateId'] = opts.templateId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domain/1.0.0' + } + + 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 domainTemplateAssigned 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}/domain:assigned', + '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.domainName - 要修改的域名 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + domainLock (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 domainLock" + ) + } + + opts = opts || {} + + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling domainLock" + ) + } + + let postBody = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + postBody['domainName'] = opts.domainName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domain/1.0.0' + } + + 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 domainLock 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}/domain:lock', + '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.domainName - 要修改的域名 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + domainUnLock (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 domainUnLock" + ) + } + + opts = opts || {} + + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling domainUnLock" + ) + } + + let postBody = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + postBody['domainName'] = opts.domainName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domain/1.0.0' + } + + 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 domainUnLock 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}/domain:unlock', + '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.domainName - 要修改的域名 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string passWord 获取的转移密码,如果转移密码为空,则表示邮件已发送至域名对应的模板中的邮箱中 + */ + + getDomainTransferOutPassWord ( + 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 getDomainTransferOutPassWord" + ) + } + + opts = opts || {} + + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling getDomainTransferOutPassWord" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domain/1.0.0' + } + + 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 getDomainTransferOutPassWord 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}/domain:transferOut', + '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.userNameCh] - 联系人姓名(中文),必填,必须含有中文,只允许输入特殊字符(.,、·()()-""“”/\'),最多可输入64 字符 optional + * @param {string} [opts.userNameEn1] - 联系人姓(英文),必填,必须含有英文,只允许输入特殊字符(.,、·()()-""“”/\'),最多可输入64 字符 optional + * @param {string} [opts.userNameEn2] - 联系人名(英文),必填,必须含有英文,只允许输入特殊字符(.,、·()()-""“”/\'),最多可输入64 字符 optional + * @param {string} [opts.ownerNameCh] - 域名所有者或所有者单位名称(中文),必填,必须含有中文,只允许输入特殊字符(.,、·()()-""“”/\'),最多可输入64 字符 optional + * @param {string} [opts.ownerNameEn] - 域名所有者或所有者单位名称(英文),必填,必须含有中文,只允许输入特殊字符(.,、·()()-""“”/\'),最多可输入64 字符 optional + * @param {string} [opts.nationCodeCh] - 国家及地区(中文) optional + * @param {string} [opts.nationCodeEn] - 国家及地区(英文) optional + * @param {string} [opts.provinceCodeCh] - 省份(中文) optional + * @param {string} [opts.provinceCodeEn] - 省份(英文) optional + * @param {string} [opts.cityCodeCh] - 城市(中文) optional + * @param {string} [opts.cityCodeEn] - 城市(英文) optional + * @param {string} [opts.addressCh] - 通信地址(中文) optional + * @param {string} [opts.addressEn] - 通信地址(英文) optional + * @param {string} [opts.zipCode] - 邮编 6位数字 optional + * @param {string} [opts.phone] - 联系电话,国家区号-地区区号(或手机号码前3位)-电话号码(或手机号码后8位) 例:86-138-12345678 optional + * @param {string} [opts.fax] - 传真,国家区号-地区区号(或手机号码前3位)-电话号码(或手机号码后8位) 例:86-138-12345678 optional + * @param {string} [opts.email] - 邮件 optional + * @param {integer} [opts.ownerType] - 所有者类型 1个人 2企业 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer templateId 模板Id + */ + + createTemplate (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 createTemplate" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.userNameCh !== undefined && opts.userNameCh !== null) { + postBody['userNameCh'] = opts.userNameCh + } + if (opts.userNameEn1 !== undefined && opts.userNameEn1 !== null) { + postBody['userNameEn1'] = opts.userNameEn1 + } + if (opts.userNameEn2 !== undefined && opts.userNameEn2 !== null) { + postBody['userNameEn2'] = opts.userNameEn2 + } + if (opts.ownerNameCh !== undefined && opts.ownerNameCh !== null) { + postBody['ownerNameCh'] = opts.ownerNameCh + } + if (opts.ownerNameEn !== undefined && opts.ownerNameEn !== null) { + postBody['ownerNameEn'] = opts.ownerNameEn + } + if (opts.nationCodeCh !== undefined && opts.nationCodeCh !== null) { + postBody['nationCodeCh'] = opts.nationCodeCh + } + if (opts.nationCodeEn !== undefined && opts.nationCodeEn !== null) { + postBody['nationCodeEn'] = opts.nationCodeEn + } + if (opts.provinceCodeCh !== undefined && opts.provinceCodeCh !== null) { + postBody['provinceCodeCh'] = opts.provinceCodeCh + } + if (opts.provinceCodeEn !== undefined && opts.provinceCodeEn !== null) { + postBody['provinceCodeEn'] = opts.provinceCodeEn + } + if (opts.cityCodeCh !== undefined && opts.cityCodeCh !== null) { + postBody['cityCodeCh'] = opts.cityCodeCh + } + if (opts.cityCodeEn !== undefined && opts.cityCodeEn !== null) { + postBody['cityCodeEn'] = opts.cityCodeEn + } + if (opts.addressCh !== undefined && opts.addressCh !== null) { + postBody['addressCh'] = opts.addressCh + } + if (opts.addressEn !== undefined && opts.addressEn !== null) { + postBody['addressEn'] = opts.addressEn + } + if (opts.zipCode !== undefined && opts.zipCode !== null) { + postBody['zipCode'] = opts.zipCode + } + if (opts.phone !== undefined && opts.phone !== null) { + postBody['phone'] = opts.phone + } + if (opts.fax !== undefined && opts.fax !== null) { + postBody['fax'] = opts.fax + } + if (opts.email !== undefined && opts.email !== null) { + postBody['email'] = opts.email + } + if (opts.ownerType !== undefined && opts.ownerType !== null) { + postBody['ownerType'] = opts.ownerType + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domain/1.0.0' + } + + 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 createTemplate 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}/template', + '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.templateId - 模板ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param templateInfo data 模板信息返回结果 + */ + + queryTemplateInfo (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 queryTemplateInfo" + ) + } + + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling queryTemplateInfo" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domain/1.0.0' + } + + 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 queryTemplateInfo 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}/template/{templateId}', + '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.templateId - 模板ID + * @param {string} [opts.nationCodeCh] - 国家及地区(中文) optional + * @param {string} [opts.nationCodeEn] - 国家及地区(英文)中国:china optional + * @param {string} [opts.provinceCodeCh] - 省份(中文) optional + * @param {string} [opts.provinceCodeEn] - 省份(英文) optional + * @param {string} [opts.cityCodeCh] - 城市(中文) optional + * @param {string} [opts.cityCodeEn] - 城市(英文) optional + * @param {string} [opts.addressCh] - 通信地址(中文) optional + * @param {string} [opts.addressEn] - 通信地址(英文) optional + * @param {string} [opts.zipCode] - 邮编 6位数字 optional + * @param {string} [opts.phone] - 联系电话,国家区号-地区区号(或手机号码前3位)-电话号码(或手机号码后8位) 例:86-138-12345678 optional + * @param {string} [opts.fax] - 传真,国家区号-地区区号(或手机号码前3位)-电话号码(或手机号码后8位) 例:86-138-12345678 optional + * @param {string} [opts.email] - 邮件 optional + * @param {integer} [opts.ownerType] - 所有者类型 1个人 2企业 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer templateId 模板Id + */ + + modifyTemplateInfo (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 modifyTemplateInfo" + ) + } + + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling modifyTemplateInfo" + ) + } + + let postBody = {} + if (opts.nationCodeCh !== undefined && opts.nationCodeCh !== null) { + postBody['nationCodeCh'] = opts.nationCodeCh + } + if (opts.nationCodeEn !== undefined && opts.nationCodeEn !== null) { + postBody['nationCodeEn'] = opts.nationCodeEn + } + if (opts.provinceCodeCh !== undefined && opts.provinceCodeCh !== null) { + postBody['provinceCodeCh'] = opts.provinceCodeCh + } + if (opts.provinceCodeEn !== undefined && opts.provinceCodeEn !== null) { + postBody['provinceCodeEn'] = opts.provinceCodeEn + } + if (opts.cityCodeCh !== undefined && opts.cityCodeCh !== null) { + postBody['cityCodeCh'] = opts.cityCodeCh + } + if (opts.cityCodeEn !== undefined && opts.cityCodeEn !== null) { + postBody['cityCodeEn'] = opts.cityCodeEn + } + if (opts.addressCh !== undefined && opts.addressCh !== null) { + postBody['addressCh'] = opts.addressCh + } + if (opts.addressEn !== undefined && opts.addressEn !== null) { + postBody['addressEn'] = opts.addressEn + } + if (opts.zipCode !== undefined && opts.zipCode !== null) { + postBody['zipCode'] = opts.zipCode + } + if (opts.phone !== undefined && opts.phone !== null) { + postBody['phone'] = opts.phone + } + if (opts.fax !== undefined && opts.fax !== null) { + postBody['fax'] = opts.fax + } + if (opts.email !== undefined && opts.email !== null) { + postBody['email'] = opts.email + } + if (opts.ownerType !== undefined && opts.ownerType !== null) { + postBody['ownerType'] = opts.ownerType + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domain/1.0.0' + } + + 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 modifyTemplateInfo 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}/template/{templateId}', + '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) + } + ) + } + + /** + * 删除域名信息模板 + * @param {Object} opts - parameters + * @param {integer} opts.templateId - 模板ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer templateId 模板Id + */ + + deleteTemplate (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 deleteTemplate" + ) + } + + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling deleteTemplate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domain/1.0.0' + } + + 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 deleteTemplate 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}/template/{templateId}', + '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.templateId - 模板ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer certificateState 实名认证状态 0未实名认证 1已实名认证 2审核中 3审核失败 4实名资料上传注册局失败 + * @param string certificateUnpassReason 实名认证失败原因 + */ + + certificateTemplateState (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 certificateTemplateState" + ) + } + + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling certificateTemplateState" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domain/1.0.0' + } + + 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 certificateTemplateState 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}/template/{templateId}/certificate', + '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.templateId - 模板ID + * @param {string} opts.identityNo - 所有人证件号码 + * @param {string} opts.identityType - 注册人证件类型 +1.个人 + (1)身份证 SFZ +2.企业 + (1)组织机构代码证 ORG + (2)工商营业执照 YYZZ + (3)统一社会信用代码证书 TYDMZ + (4)部队代号 BDDH + (5)军队单位对外有偿服务许可证 JDXKZ + (6)事业单位法人证书 SYZS + (7)社会团体法人登记证书 STDJZ + (8)宗教活动场所登记证 ZJDJZ + (9)民办非企业单位登记证书 MBDJZ + (10)基金会法人登记证书 JJDJZ + (11)律师事务所执业许可证 LSXKZ + (12)登记证 GWLYDJZ + (13)司法鉴定许可证 SFXKZ + (14)社会服务机构登记证书 SHFWJGZ + (15)民办学校办学许可证 MBXXXKZ + (16)医疗机构执业许可证 YLJGXKZ + + * @param {string} opts.file - 所有人证件,jpg 图片的 base64 编码,必填(大小 55KB~1MB) + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer templateId 模板Id + */ + + certificateTemplate (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 certificateTemplate" + ) + } + + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling certificateTemplate" + ) + } + if (opts.identityNo === undefined || opts.identityNo === null) { + throw new Error( + "Missing the required parameter 'opts.identityNo' when calling certificateTemplate" + ) + } + if (opts.identityType === undefined || opts.identityType === null) { + throw new Error( + "Missing the required parameter 'opts.identityType' when calling certificateTemplate" + ) + } + if (opts.file === undefined || opts.file === null) { + throw new Error( + "Missing the required parameter 'opts.file' when calling certificateTemplate" + ) + } + + let postBody = {} + if (opts.identityNo !== undefined && opts.identityNo !== null) { + postBody['identityNo'] = opts.identityNo + } + if (opts.identityType !== undefined && opts.identityType !== null) { + postBody['identityType'] = opts.identityType + } + if (opts.file !== undefined && opts.file !== null) { + postBody['file'] = opts.file + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domain/1.0.0' + } + + 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 certificateTemplate 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}/template/{templateId}/certificate', + '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 = DOMAIN diff --git a/packages/libs/lib-jdcloud/src/repo/domainservice/v2/domainservice.js b/packages/libs/lib-jdcloud/src/repo/domainservice/v2/domainservice.js new file mode 100644 index 000000000..047d27ea4 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/domainservice/v2/domainservice.js @@ -0,0 +1,3623 @@ +/* + * 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. + * + * 实例信息 + * 云解析OpenAPI实例信息接口 + * + * 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 = 'domainservice' +Service._services[serviceId] = true + +/** + * domainservice service. + * @version 2.0.3 + */ + +JDCloud.DOMAINSERVICE = class DOMAINSERVICE extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'domainservice.jdcloud-api.com' + options.basePath = '/v2' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查看用户在云解析服务下的操作记录 + * @param {Object} opts - parameters + * @param {integer} opts.pageNumber - 分页参数,页的序号,默认是1 + * @param {integer} opts.pageSize - 分页参数,每页含有的结果的数目,默认是10 + * @param {string} opts.startTime - 记录的起始时间,格式:UTC时间例如2017-11-10T23:00:00Z + * @param {string} opts.endTime - 记录的终止时间,格式:UTC时间例如2017-11-10T23:00:00Z + * @param {string} [opts.keyWord] - 日志需要匹配的关键词 optional + * @param {boolean} [opts.success] - 日志里面的结果是成功还是失败 optional + * @param {integer} [opts.type] - 日志的类型 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param actionlog dataList + * @param integer currentCount 当前页的操作记录列表里的个数 + * @param integer totalCount 所有操作记录的个数 + * @param integer totalPage 操作记录列表按照分页参数一共的页数 + */ + + describeActionLog (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 describeActionLog" + ) + } + + opts = opts || {} + + if (opts.pageNumber === undefined || opts.pageNumber === null) { + throw new Error( + "Missing the required parameter 'opts.pageNumber' when calling describeActionLog" + ) + } + if (opts.pageSize === undefined || opts.pageSize === null) { + throw new Error( + "Missing the required parameter 'opts.pageSize' when calling describeActionLog" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeActionLog" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeActionLog" + ) + } + + 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.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.keyWord !== undefined && opts.keyWord !== null) { + queryParams['keyWord'] = opts.keyWord + } + if (opts.success !== undefined && opts.success !== null) { + queryParams['success'] = opts.success + } + if (opts.type !== undefined && opts.type !== null) { + queryParams['type'] = opts.type + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domainservice/2.0.3' + } + + 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 describeActionLog 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 = this.makeRequest( + '/regions/{regionId}/actionLog', + '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) + } + ) + } + + /** + * 获取用户所属的主域名列表。 +请在调用域名相关的接口之前,调用此接口获取相关的domainId和domainName。 +主域名的相关概念,请查阅<a href="https://docs.jdcloud.com/cn/jd-cloud-dns/product-overview">云解析文档</a> + + * @param {Object} opts - parameters + * @param {integer} opts.pageNumber - 分页查询时查询的每页的序号,起始值为1,默认为1 + * @param {integer} opts.pageSize - 分页查询时设置的每页行数,默认为10 + * @param {string} [opts.domainName] - 关键字,按照”%domainName%”模式匹配主域名 optional + * @param {integer} [opts.domainId] - 域名ID。不为0时,只查此domainId的域名 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param domainInfo dataList + * @param integer currentCount 当前页的域名列表里域名的个数 + * @param integer totalCount 所有匹配的域名列表的个数 + * @param integer totalPage 所有匹配的域名列表按照分页参数一共的页数 + */ + + describeDomains (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 describeDomains" + ) + } + + opts = opts || {} + + if (opts.pageNumber === undefined || opts.pageNumber === null) { + throw new Error( + "Missing the required parameter 'opts.pageNumber' when calling describeDomains" + ) + } + if (opts.pageSize === undefined || opts.pageSize === null) { + throw new Error( + "Missing the required parameter 'opts.pageSize' when calling describeDomains" + ) + } + + 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.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + if (opts.domainId !== undefined && opts.domainId !== null) { + queryParams['domainId'] = opts.domainId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domainservice/2.0.3' + } + + 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 describeDomains 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 = this.makeRequest( + '/regions/{regionId}/domain', + '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) + } + ) + } + + /** + * 添加主域名 +如何添加免费域名,详细情况请查阅<a href="https://docs.jdcloud.com/cn/jd-cloud-dns/domainadd">文档</a> +添加收费域名,请查阅<a href="https://docs.jdcloud.com/cn/jd-cloud-dns/purchase-process">文档</a>, +添加收费域名前,请确保用户的京东云账户有足够的资金支付,Openapi接口回返回订单号,可以用此订单号向计费系统查阅详情。 + + * @param {Object} opts - parameters + * @param {integer} opts.packId - 主域名的套餐类型, 免费:0 企业版:1 企业高级版:2 + * @param {string} opts.domainName - 要添加的主域名 + * @param {integer} [opts.domainId] - 主域名的ID,升级套餐必填,请使用describeDomains获取 optional + * @param {integer} [opts.buyType] - 新购买:1、升级:3,收费套餐的域名必填 optional + * @param {integer} [opts.timeSpan] - 取值1,2,3 ,含义:时长,收费套餐的域名必填 optional + * @param {integer} [opts.timeUnit] - 时间单位,收费套餐的域名必填,1:小时,2:天,3:月,4:年 optional + * @param {integer} [opts.billingType] - 计费类型,可以不传此参数。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param domainAdded data 新添加的的域名结构 + * @param string order 添加收费版域名的订单号 + */ + + createDomain (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 createDomain" + ) + } + + opts = opts || {} + + if (opts.packId === undefined || opts.packId === null) { + throw new Error( + "Missing the required parameter 'opts.packId' when calling createDomain" + ) + } + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling createDomain" + ) + } + + let postBody = {} + if (opts.packId !== undefined && opts.packId !== null) { + postBody['packId'] = opts.packId + } + if (opts.domainName !== undefined && opts.domainName !== null) { + postBody['domainName'] = opts.domainName + } + if (opts.domainId !== undefined && opts.domainId !== null) { + postBody['domainId'] = opts.domainId + } + if (opts.buyType !== undefined && opts.buyType !== null) { + postBody['buyType'] = opts.buyType + } + if (opts.timeSpan !== undefined && opts.timeSpan !== null) { + postBody['timeSpan'] = opts.timeSpan + } + if (opts.timeUnit !== undefined && opts.timeUnit !== null) { + postBody['timeUnit'] = opts.timeUnit + } + if (opts.billingType !== undefined && opts.billingType !== null) { + postBody['billingType'] = opts.billingType + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domainservice/2.0.3' + } + + 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 createDomain 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 = this.makeRequest( + '/regions/{regionId}/domain', + '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.domainId - 域名ID,请使用describeDomains接口获取。 + * @param {string} opts.domainName - 需要修改的主域名,请使用describeDomains接口获取 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyDomain (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 modifyDomain" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling modifyDomain" + ) + } + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling modifyDomain" + ) + } + + let postBody = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + postBody['domainName'] = opts.domainName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domainservice/2.0.3' + } + + 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 modifyDomain 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}', + '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) + } + ) + } + + /** + * 删除主域名 + * @param {Object} opts - parameters + * @param {string} opts.domainId - 域名ID,请使用describeDomains接口获取。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteDomain (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 deleteDomain" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling deleteDomain" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domainservice/2.0.3' + } + + 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 deleteDomain 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}', + '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.domainId - 域名ID,请使用describeDomains接口获取。 + * @param {string} opts.domainName - 查询的主域名,请使用describeDomains接口获取 + * @param {string} opts.start - 查询时间段的起始时间, UTC时间格式,例如2017-11-10T23:00:00Z + * @param {string} opts.end - 查询时间段的终止时间, UTC时间格式,例如2017-11-10T23:00:00Z + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer time + * @param integer traffic + */ + + describeDomainQueryCount (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 describeDomainQueryCount" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling describeDomainQueryCount" + ) + } + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling describeDomainQueryCount" + ) + } + if (opts.start === undefined || opts.start === null) { + throw new Error( + "Missing the required parameter 'opts.start' when calling describeDomainQueryCount" + ) + } + if (opts.end === undefined || opts.end === null) { + throw new Error( + "Missing the required parameter 'opts.end' when calling describeDomainQueryCount" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + if (opts.start !== undefined && opts.start !== null) { + queryParams['start'] = opts.start + } + if (opts.end !== undefined && opts.end !== null) { + queryParams['end'] = opts.end + } + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domainservice/2.0.3' + } + + 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 describeDomainQueryCount 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/queryCount', + '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.domainId - 域名ID,请使用describeDomains接口获取。 + * @param {string} opts.domainName - 主域名,请使用describeDomains接口获取 + * @param {string} opts.start - 时间段的起始时间, UTC时间格式,例如2017-11-10T23:00:00Z + * @param {string} opts.end - 时间段的终止时间, UTC时间格式,例如2017-11-10T23:00:00Z + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer time + * @param string unit 数据序列的单位 + * @param number traffic + */ + + describeDomainQueryTraffic (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 describeDomainQueryTraffic" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling describeDomainQueryTraffic" + ) + } + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling describeDomainQueryTraffic" + ) + } + if (opts.start === undefined || opts.start === null) { + throw new Error( + "Missing the required parameter 'opts.start' when calling describeDomainQueryTraffic" + ) + } + if (opts.end === undefined || opts.end === null) { + throw new Error( + "Missing the required parameter 'opts.end' when calling describeDomainQueryTraffic" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + if (opts.start !== undefined && opts.start !== null) { + queryParams['start'] = opts.start + } + if (opts.end !== undefined && opts.end !== null) { + queryParams['end'] = opts.end + } + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domainservice/2.0.3' + } + + 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 describeDomainQueryTraffic 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/queryTraffic', + '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.domainId - 域名ID,请使用describeDomains接口获取。 + * @param {integer} [opts.pageNumber] - 当前页数,起始值为1,默认为1 optional + * @param {integer} [opts.pageSize] - 分页查询时设置的每页行数, 默认为10 optional + * @param {string} [opts.search] - 关键字,按照”%search%”模式匹配解析记录的主机记录 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param rRInfo dataList + * @param integer totalCount 所有解析记录的个数 + * @param integer totalPage 所有解析记录的页数 + * @param integer currentCount 当前页解析记录的个数 + */ + + describeResourceRecord (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 describeResourceRecord" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling describeResourceRecord" + ) + } + + 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.search !== undefined && opts.search !== null) { + queryParams['search'] = opts.search + } + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domainservice/2.0.3' + } + + 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 describeResourceRecord 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/ResourceRecord', + '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.domainId - 域名ID,请使用describeDomains接口获取。 + * @param {addRR} opts.req - RR参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param rR dataList 添加成功后的解析记录结果 + */ + + createResourceRecord (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 createResourceRecord" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling createResourceRecord" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling createResourceRecord" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domainservice/2.0.3' + } + + 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 createResourceRecord 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/ResourceRecord', + '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.domainId - 域名ID,请使用describeDomains接口获取。 + * @param {string} opts.resourceRecordId - 解析记录ID,请使用describeResourceRecord接口获取。 + * @param {updateRR} opts.req - updateRR参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyResourceRecord (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 modifyResourceRecord" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling modifyResourceRecord" + ) + } + if (opts.resourceRecordId === undefined || opts.resourceRecordId === null) { + throw new Error( + "Missing the required parameter 'opts.resourceRecordId' when calling modifyResourceRecord" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling modifyResourceRecord" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + domainId: opts.domainId, + resourceRecordId: opts.resourceRecordId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domainservice/2.0.3' + } + + 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 modifyResourceRecord 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/ResourceRecord/{resourceRecordId}', + '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) + } + ) + } + + /** + * 删除主域名下的解析记录 + * @param {Object} opts - parameters + * @param {string} opts.domainId - 域名ID,请使用describeDomains接口获取。 + * @param {string} opts.resourceRecordId - 解析记录ID,请使用describeResourceRecord接口获取。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteResourceRecord (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 deleteResourceRecord" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling deleteResourceRecord" + ) + } + if (opts.resourceRecordId === undefined || opts.resourceRecordId === null) { + throw new Error( + "Missing the required parameter 'opts.resourceRecordId' when calling deleteResourceRecord" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + domainId: opts.domainId, + resourceRecordId: opts.resourceRecordId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domainservice/2.0.3' + } + + 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 deleteResourceRecord 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/ResourceRecord/{resourceRecordId}', + '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.domainId - 域名ID,请使用describeDomains接口获取。 + * @param {string} opts.resourceRecordId - 解析记录ID,请使用describeResourceRecord接口获取。 + * @param {string} opts.action - 要修改的状态,enable:启用 disable:停用 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyResourceRecordStatus (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 modifyResourceRecordStatus" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling modifyResourceRecordStatus" + ) + } + if (opts.resourceRecordId === undefined || opts.resourceRecordId === null) { + throw new Error( + "Missing the required parameter 'opts.resourceRecordId' when calling modifyResourceRecordStatus" + ) + } + if (opts.action === undefined || opts.action === null) { + throw new Error( + "Missing the required parameter 'opts.action' when calling modifyResourceRecordStatus" + ) + } + + let postBody = {} + if (opts.action !== undefined && opts.action !== null) { + postBody['action'] = opts.action + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + domainId: opts.domainId, + resourceRecordId: opts.resourceRecordId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domainservice/2.0.3' + } + + 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 modifyResourceRecordStatus 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/ResourceRecord/{resourceRecordId}/status', + '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) + } + ) + } + + /** + * 查询云解析所有的基础解析线路。 +在使用解析线路的参数之前,请调用此接口获取解析线路的ID。 + + * @param {Object} opts - parameters + * @param {string} opts.domainId - 域名ID,请使用describeDomains接口获取。 + * @param {integer} [opts.loadMode] - 展示方式,暂时不使用 optional + * @param {integer} opts.packId - 套餐ID,0->免费版 1->企业版 2->企业高级版 + * @param {integer} opts.viewId - view ID,默认为-1 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param viewTree data + */ + + describeViewTree (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 describeViewTree" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling describeViewTree" + ) + } + if (opts.packId === undefined || opts.packId === null) { + throw new Error( + "Missing the required parameter 'opts.packId' when calling describeViewTree" + ) + } + if (opts.viewId === undefined || opts.viewId === null) { + throw new Error( + "Missing the required parameter 'opts.viewId' when calling describeViewTree" + ) + } + + let postBody = null + let queryParams = {} + if (opts.loadMode !== undefined && opts.loadMode !== null) { + queryParams['loadMode'] = opts.loadMode + } + if (opts.packId !== undefined && opts.packId !== null) { + queryParams['packId'] = opts.packId + } + if (opts.viewId !== undefined && opts.viewId !== null) { + queryParams['viewId'] = opts.viewId + } + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domainservice/2.0.3' + } + + 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 describeViewTree 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/viewTree', + '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) + } + ) + } + + /** + * 同一个主域名下,批量新增或者批量更新导入解析记录。 +如果解析记录的ID为0,是新增解析记录,如果不为0,则是更新解析记录。 + + * @param {Object} opts - parameters + * @param {string} opts.domainId - 域名ID,请使用describeDomains接口获取。 + * @param {array} [opts.req] - 需要设置的解析记录列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string data + */ + + batchSetResourceRecords (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 batchSetResourceRecords" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling batchSetResourceRecords" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domainservice/2.0.3' + } + + 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 batchSetResourceRecords 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/BatchSetResourceRecords', + '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.domainId - 域名ID,请使用describeDomains接口获取。 + * @param {integer} opts.viewId - 自定义线路ID + * @param {string} [opts.viewName] - 自定义线路名称, 最多64个字节,允许:数字、字母、下划线,-,中文 optional + * @param {integer} opts.pageNumber - 分页参数,页的序号 + * @param {integer} opts.pageSize - 分页参数,每页含有的结果的数目 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param userViewInput dataList + * @param integer currentCount 当前页的自定义线路列表里的个数 + * @param integer totalCount 所有自定义线路列表的个数 + * @param integer totalPage 所有自定义线路列表按照分页参数一共的页数 + */ + + describeUserView (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 describeUserView" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling describeUserView" + ) + } + if (opts.viewId === undefined || opts.viewId === null) { + throw new Error( + "Missing the required parameter 'opts.viewId' when calling describeUserView" + ) + } + if (opts.pageNumber === undefined || opts.pageNumber === null) { + throw new Error( + "Missing the required parameter 'opts.pageNumber' when calling describeUserView" + ) + } + if (opts.pageSize === undefined || opts.pageSize === null) { + throw new Error( + "Missing the required parameter 'opts.pageSize' when calling describeUserView" + ) + } + + let postBody = null + let queryParams = {} + if (opts.viewId !== undefined && opts.viewId !== null) { + queryParams['viewId'] = opts.viewId + } + if (opts.viewName !== undefined && opts.viewName !== null) { + queryParams['viewName'] = opts.viewName + } + 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, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domainservice/2.0.3' + } + + 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 describeUserView 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/UserView', + '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.domainId - 域名ID,请使用describeDomains接口获取。 + * @param {addView} opts.req - 添加自定义线路的参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param userview data 添加成功后返回的自定义线路的结构 + */ + + createUserView (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 createUserView" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling createUserView" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling createUserView" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domainservice/2.0.3' + } + + 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 createUserView 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/UserView', + '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.domainId - 域名ID,请使用describeDomains接口获取。 + * @param {delView} opts.req - 删除自定义线路的参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteUserView (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 deleteUserView" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling deleteUserView" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling deleteUserView" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domainservice/2.0.3' + } + + 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 deleteUserView 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/DeleteUserView', + '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) + } + ) + } + + /** + * 查询主域名的自定义解析线路的IP段 + * @param {Object} opts - parameters + * @param {string} opts.domainId - 域名ID,请使用describeDomains接口获取。 + * @param {integer} opts.viewId - 自定义线路ID + * @param {string} [opts.viewName] - 自定义线路名称, 最多64个字节,允许:数字、字母、下划线,-,中文 optional + * @param {integer} opts.pageNumber - 分页参数,页的序号, 默认为1 + * @param {integer} opts.pageSize - 分页参数,每页含有的结果的数目,默认为10 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string dataList + * @param integer currentCount 当前页的IP列表里的个数 + * @param integer totalCount IP列表里的IP段的个数 + * @param integer totalPage IP列表按照分页参数一共的页数 + */ + + describeUserViewIP (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 describeUserViewIP" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling describeUserViewIP" + ) + } + if (opts.viewId === undefined || opts.viewId === null) { + throw new Error( + "Missing the required parameter 'opts.viewId' when calling describeUserViewIP" + ) + } + if (opts.pageNumber === undefined || opts.pageNumber === null) { + throw new Error( + "Missing the required parameter 'opts.pageNumber' when calling describeUserViewIP" + ) + } + if (opts.pageSize === undefined || opts.pageSize === null) { + throw new Error( + "Missing the required parameter 'opts.pageSize' when calling describeUserViewIP" + ) + } + + let postBody = null + let queryParams = {} + if (opts.viewId !== undefined && opts.viewId !== null) { + queryParams['viewId'] = opts.viewId + } + if (opts.viewName !== undefined && opts.viewName !== null) { + queryParams['viewName'] = opts.viewName + } + 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, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domainservice/2.0.3' + } + + 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 describeUserViewIP 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/UserViewIP', + '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段 + * @param {Object} opts - parameters + * @param {string} opts.domainId - 域名ID,请使用describeDomains接口获取。 + * @param {addViewIP} opts.req - 添加域名的自定义解析线路的IP段的参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + createUserViewIP (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 createUserViewIP" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling createUserViewIP" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling createUserViewIP" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domainservice/2.0.3' + } + + 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 createUserViewIP 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/UserViewIP', + '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) + } + ) + } + + /** + * 删除主域名的自定义解析线路的IP段 + * @param {Object} opts - parameters + * @param {string} opts.domainId - 域名ID,请使用describeDomains接口获取。 + * @param {delViewIP} opts.req - 删除域名的自定义解析线路的IP段的参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteUserViewIP (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 deleteUserViewIP" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling deleteUserViewIP" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling deleteUserViewIP" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domainservice/2.0.3' + } + + 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 deleteUserViewIP 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/DeleteUserViewIP', + '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.domainId - 域名ID,请使用describeDomains接口获取。 + * @param {integer} [opts.pageIndex] - 当前页数,起始值为1,默认为1 optional + * @param {integer} [opts.pageSize] - 分页查询时设置的每页行数 optional + * @param {string} [opts.searchValue] - 查询的值 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer currentCount 当前页面网站监控项的个数 + * @param integer totalCount 所有网站监控项的个数 + * @param integer totalPage 所有网站监控项的页数 + * @param monitor dataList + */ + + describeMonitor (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 describeMonitor" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling describeMonitor" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.searchValue !== undefined && opts.searchValue !== null) { + queryParams['searchValue'] = opts.searchValue + } + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domainservice/2.0.3' + } + + 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 describeMonitor 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/monitor', + '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.domainId - 域名ID,请使用describeDomains接口获取。 + * @param {string} opts.subDomainName - 子域名 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + createMonitor (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 createMonitor" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling createMonitor" + ) + } + if (opts.subDomainName === undefined || opts.subDomainName === null) { + throw new Error( + "Missing the required parameter 'opts.subDomainName' when calling createMonitor" + ) + } + + let postBody = {} + if (opts.subDomainName !== undefined && opts.subDomainName !== null) { + postBody['subDomainName'] = opts.subDomainName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domainservice/2.0.3' + } + + 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 createMonitor 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/monitor', + '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.domainId - 域名ID,请使用describeDomains接口获取。 + * @param {updateMonitor} opts.updateMonitor - 监控项设置信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyMonitor (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 modifyMonitor" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling modifyMonitor" + ) + } + if (opts.updateMonitor === undefined || opts.updateMonitor === null) { + throw new Error( + "Missing the required parameter 'opts.updateMonitor' when calling modifyMonitor" + ) + } + + let postBody = {} + if (opts.updateMonitor !== undefined && opts.updateMonitor !== null) { + postBody['updateMonitor'] = opts.updateMonitor + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domainservice/2.0.3' + } + + 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 modifyMonitor 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/monitor', + '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) + } + ) + } + + /** + * 查询子域名的可用监控对象 + * @param {Object} opts - parameters + * @param {string} opts.domainId - 域名ID,请使用describeDomains接口获取。 + * @param {string} opts.subDomainName - 子域名 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string data + */ + + describeMonitorTarget (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 describeMonitorTarget" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling describeMonitorTarget" + ) + } + if (opts.subDomainName === undefined || opts.subDomainName === null) { + throw new Error( + "Missing the required parameter 'opts.subDomainName' when calling describeMonitorTarget" + ) + } + + let postBody = null + let queryParams = {} + if (opts.subDomainName !== undefined && opts.subDomainName !== null) { + queryParams['subDomainName'] = opts.subDomainName + } + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domainservice/2.0.3' + } + + 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 describeMonitorTarget 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/monitorTarget', + '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.domainId - 域名ID,请使用describeDomains接口获取。 + * @param {string} opts.subDomainName - 子域名 + * @param {array} [opts.targets] - 子域名可用监控对象的数组 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + createMonitorTarget (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 createMonitorTarget" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling createMonitorTarget" + ) + } + if (opts.subDomainName === undefined || opts.subDomainName === null) { + throw new Error( + "Missing the required parameter 'opts.subDomainName' when calling createMonitorTarget" + ) + } + + let postBody = {} + if (opts.subDomainName !== undefined && opts.subDomainName !== null) { + postBody['subDomainName'] = opts.subDomainName + } + if (opts.targets !== undefined && opts.targets !== null) { + postBody['targets'] = opts.targets + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domainservice/2.0.3' + } + + 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 createMonitorTarget 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/monitorTarget', + '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.domainId - 域名ID,请使用describeDomains接口获取。 + * @param {string} opts.monitorId - 监控项ID,请使用describeMonitor接口获取。 + * @param {string} opts.action - 暂停stop, 开启start, 手动恢复recover,手动切换switch,手动恢复和手动切换时候不支持批量操作 + * @param {string} [opts.switchTarget] - 监控项的主机值, 手动切换时必填 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyMonitorStatus (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 modifyMonitorStatus" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling modifyMonitorStatus" + ) + } + if (opts.monitorId === undefined || opts.monitorId === null) { + throw new Error( + "Missing the required parameter 'opts.monitorId' when calling modifyMonitorStatus" + ) + } + if (opts.action === undefined || opts.action === null) { + throw new Error( + "Missing the required parameter 'opts.action' when calling modifyMonitorStatus" + ) + } + + let postBody = {} + if (opts.action !== undefined && opts.action !== null) { + postBody['action'] = opts.action + } + if (opts.switchTarget !== undefined && opts.switchTarget !== null) { + postBody['switchTarget'] = opts.switchTarget + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + domainId: opts.domainId, + monitorId: opts.monitorId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domainservice/2.0.3' + } + + 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 modifyMonitorStatus 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/monitor/{monitorId}/status', + '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) + } + ) + } + + /** + * 监控项的删除 + * @param {Object} opts - parameters + * @param {string} opts.domainId - 域名ID,请使用describeDomains接口获取。 + * @param {string} opts.monitorId - 监控项ID,请使用describeMonitor接口获取。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteMonitor (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 deleteMonitor" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling deleteMonitor" + ) + } + if (opts.monitorId === undefined || opts.monitorId === null) { + throw new Error( + "Missing the required parameter 'opts.monitorId' when calling deleteMonitor" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + domainId: opts.domainId, + monitorId: opts.monitorId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domainservice/2.0.3' + } + + 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 deleteMonitor 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/monitor/{monitorId}', + '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.domainId - 域名ID,请使用describeDomains接口获取。 + * @param {integer} [opts.pageIndex] - 当前页数,起始值为1,默认为1 optional + * @param {integer} [opts.pageSize] - 分页查询时设置的每页行数 optional + * @param {string} [opts.searchValue] - 关键字 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer currentCount 当前页面报警信息的个数 + * @param integer totalCount 所有报警信息的个数 + * @param integer totalPage 所有报警信息的页数 + * @param monitorAlarmInfo dataList + */ + + describeMonitorAlarm (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 describeMonitorAlarm" + ) + } + + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling describeMonitorAlarm" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.searchValue !== undefined && opts.searchValue !== null) { + queryParams['searchValue'] = opts.searchValue + } + + let pathParams = { + regionId: regionId, + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 domainservice/2.0.3' + } + + 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 describeMonitorAlarm 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 = this.makeRequest( + '/regions/{regionId}/domain/{domainId}/monitorAlarm', + '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 = JDCloud.DOMAINSERVICE diff --git a/packages/libs/lib-jdcloud/src/repo/dts/v2/dts.js b/packages/libs/lib-jdcloud/src/repo/dts/v2/dts.js new file mode 100644 index 000000000..0dbe53766 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/dts/v2/dts.js @@ -0,0 +1,3319 @@ +/* + * 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. + * + * 数据传输服务 + * 数据传输服务相关接口 + * + * 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 = 'dts' +Service._services[serviceId] = true + +/** + * dts service. + * @version 2.2.0 + */ + +class DTS extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'dts.jdcloud-api.com' + options.basePath = '/v2' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 批量操作数据传输任务 + * @param {Object} opts - parameters + * @param {} [opts.operateType] - 操作类型:start - 启动任务,stop - 停止任务,delete - 删除任务,resume - 恢复任务,suspend - 暂停任务 optional + * @param {} [opts.ids] - 任务ID列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param object details + * @param string orderId 订单ID + */ + + batchOperateTasks (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 batchOperateTasks" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.operateType !== undefined && opts.operateType !== null) { + postBody['operateType'] = opts.operateType + } + if (opts.ids !== undefined && opts.ids !== null) { + postBody['ids'] = opts.ids + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dts/2.2.0' + } + + 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 batchOperateTasks 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}/dtsbatch', + '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.pageNumber] - 页码;默认为1,取值范围:-1,[1,∞);-1时返回全部页码。 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[1, 100] optional + * @param {filter} [opts.filters] optional + * @param {tagFilter} [opts.tagFilters] - Tag筛选条件 optional + * @param {sort} [opts.sorts] - createTime - 创建时间,asc(正序),desc(倒序) + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param transmissionTask dts + * @param integer totalCount 总记录数 + */ + + describeTransmissionTasks (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 describeTransmissionTasks" + ) + } + + 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')) + Object.assign( + queryParams, + super.buildTagFilterParam(opts.tagFilters, 'tagFilters') + ) + Object.assign(queryParams, super.buildSortParam(opts.sorts, 'sorts')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dts/2.2.0' + } + + 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 describeTransmissionTasks 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}/dts', + '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 {} [opts.transmissionMethod] - 实例类型,取值为:Sync:同步、Subscribe:订阅、Migration:迁移、DisasterRecovery 灾备,默认取值为:Sync optional + * @param {} [opts.topology] - 数据传输拓扑,支持:oneway - 单向数据传输、bidirectional - 双向数据传输,默认取值为:oneway optional + * @param {} opts.vpc - 数据传输实例所属VPC。 + * @param {} opts.subnet - 数据传输实例所属子网。 + * @param {} [opts.availableZone] - 数据传输实例所属可用区,可选 optional + * @param {} opts.instanceClass - 数据传输实例规格,支持:dts.m1.medium、dts.m1.large、dts.m1.xlarge + * @param {} opts.chargeSpec - 计费方式,数据传输支持包年包月、按配置计费。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string id 任务ID + * @param string orderId 订单ID + */ + + createTransmissionTask (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 createTransmissionTask" + ) + } + + opts = opts || {} + + if (opts.vpc === undefined || opts.vpc === null) { + throw new Error( + "Missing the required parameter 'opts.vpc' when calling createTransmissionTask" + ) + } + if (opts.subnet === undefined || opts.subnet === null) { + throw new Error( + "Missing the required parameter 'opts.subnet' when calling createTransmissionTask" + ) + } + if (opts.instanceClass === undefined || opts.instanceClass === null) { + throw new Error( + "Missing the required parameter 'opts.instanceClass' when calling createTransmissionTask" + ) + } + if (opts.chargeSpec === undefined || opts.chargeSpec === null) { + throw new Error( + "Missing the required parameter 'opts.chargeSpec' when calling createTransmissionTask" + ) + } + + let postBody = {} + if ( + opts.transmissionMethod !== undefined && + opts.transmissionMethod !== null + ) { + postBody['transmissionMethod'] = opts.transmissionMethod + } + if (opts.topology !== undefined && opts.topology !== null) { + postBody['topology'] = opts.topology + } + if (opts.vpc !== undefined && opts.vpc !== null) { + postBody['vpc'] = opts.vpc + } + if (opts.subnet !== undefined && opts.subnet !== null) { + postBody['subnet'] = opts.subnet + } + if (opts.availableZone !== undefined && opts.availableZone !== null) { + postBody['availableZone'] = opts.availableZone + } + if (opts.instanceClass !== undefined && opts.instanceClass !== null) { + postBody['instanceClass'] = opts.instanceClass + } + if (opts.chargeSpec !== undefined && opts.chargeSpec !== null) { + postBody['chargeSpec'] = opts.chargeSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dts/2.2.0' + } + + 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 createTransmissionTask 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}/dts', + '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.taskId - DTS数据传输任务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param transmissionTaskAttribute dts + */ + + describeTransmissionTaskAttributes ( + 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 describeTransmissionTaskAttributes" + ) + } + + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling describeTransmissionTaskAttributes" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dts/2.2.0' + } + + 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 describeTransmissionTaskAttributes 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}/dts/{taskId}', + '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.taskId - DTS数据传输任务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteTransmissionTask (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 deleteTransmissionTask" + ) + } + + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling deleteTransmissionTask" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dts/2.2.0' + } + + 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 deleteTransmissionTask 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}/dts/{taskId}', + '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.taskId - DTS数据传输任务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 任务状态 + * @param object items + */ + + describePreCheckResult (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 describePreCheckResult" + ) + } + + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling describePreCheckResult" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dts/2.2.0' + } + + 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 describePreCheckResult 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}/dts/{taskId}/precheck', + '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.taskId - DTS数据传输任务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + preCheckTransmissionTask (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 preCheckTransmissionTask" + ) + } + + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling preCheckTransmissionTask" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dts/2.2.0' + } + + 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 preCheckTransmissionTask 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}/dts/{taskId}/precheck', + '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.taskId - DTS数据传输任务ID + * @param {string} opts.itemName - 跳过的项目名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 数据传输任务状态 + * @param preCheckItem items + */ + + skipPreCheckItem (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 skipPreCheckItem" + ) + } + + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling skipPreCheckItem" + ) + } + if (opts.itemName === undefined || opts.itemName === null) { + throw new Error( + "Missing the required parameter 'opts.itemName' when calling skipPreCheckItem" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + taskId: opts.taskId, + itemName: opts.itemName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dts/2.2.0' + } + + 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 skipPreCheckItem 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}/dts/{taskId}/precheck/{itemName}/skip', + '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) + } + ) + } + + /** + * 配置数据传输任务 + * @param {Object} opts - parameters + * @param {string} opts.taskId - DTS数据传输任务ID + * @param {} [opts.transmissionMode] - 传输任务模式:可选值:structureInitialization、dataInitialization、dataSynchronization,分别对应结构初始化,全量数据初始化,增量数据传输 optional + * @param {} [opts.destExecutionStrategy] - 目标端执行策略,对于目标MySQL,支持:覆盖写入 mysql-replace-engine,冲突检测 conflict-detect-engine optional + * @param {} [opts.options] - 任务设置 optional + * @param {} opts.transmissionObject - 待传输的对象 + * @param {} opts.taskName - 任务名称,名称只支持中文、数字、大小写字母及英文下划线“_”及中划线“-”,不超过32字符 + * @param {} opts.source - 源端连接信息 + * @param {} opts.destination - 目标端连接信息 + * @param {} [opts.checkPoint] - 增量数据传输的启动位点 optional + * @param {} [opts.customOptions] - 任务自定义设置 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string id 任务ID + */ + + configureTransmissionTask (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 configureTransmissionTask" + ) + } + + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling configureTransmissionTask" + ) + } + if ( + opts.transmissionObject === undefined || + opts.transmissionObject === null + ) { + throw new Error( + "Missing the required parameter 'opts.transmissionObject' when calling configureTransmissionTask" + ) + } + if (opts.taskName === undefined || opts.taskName === null) { + throw new Error( + "Missing the required parameter 'opts.taskName' when calling configureTransmissionTask" + ) + } + if (opts.source === undefined || opts.source === null) { + throw new Error( + "Missing the required parameter 'opts.source' when calling configureTransmissionTask" + ) + } + if (opts.destination === undefined || opts.destination === null) { + throw new Error( + "Missing the required parameter 'opts.destination' when calling configureTransmissionTask" + ) + } + + let postBody = {} + if (opts.transmissionMode !== undefined && opts.transmissionMode !== null) { + postBody['transmissionMode'] = opts.transmissionMode + } + if ( + opts.destExecutionStrategy !== undefined && + opts.destExecutionStrategy !== null + ) { + postBody['destExecutionStrategy'] = opts.destExecutionStrategy + } + if (opts.options !== undefined && opts.options !== null) { + postBody['options'] = opts.options + } + if ( + opts.transmissionObject !== undefined && + opts.transmissionObject !== null + ) { + postBody['transmissionObject'] = opts.transmissionObject + } + if (opts.taskName !== undefined && opts.taskName !== null) { + postBody['taskName'] = opts.taskName + } + if (opts.source !== undefined && opts.source !== null) { + postBody['source'] = opts.source + } + if (opts.destination !== undefined && opts.destination !== null) { + postBody['destination'] = opts.destination + } + if (opts.checkPoint !== undefined && opts.checkPoint !== null) { + postBody['checkPoint'] = opts.checkPoint + } + if (opts.customOptions !== undefined && opts.customOptions !== null) { + postBody['customOptions'] = opts.customOptions + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dts/2.2.0' + } + + 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 configureTransmissionTask 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}/dts/{taskId}/configure', + '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.taskId - DTS数据传输任务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + startTransmissionTask (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 startTransmissionTask" + ) + } + + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling startTransmissionTask" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dts/2.2.0' + } + + 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 startTransmissionTask 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}/dts/{taskId}/start', + '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.taskId - DTS数据传输任务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + stopTransmissionTask (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 stopTransmissionTask" + ) + } + + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling stopTransmissionTask" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dts/2.2.0' + } + + 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 stopTransmissionTask 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}/dts/{taskId}/stop', + '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.taskId - DTS数据传输任务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + suspendTransmissionTask (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 suspendTransmissionTask" + ) + } + + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling suspendTransmissionTask" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dts/2.2.0' + } + + 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 suspendTransmissionTask 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}/dts/{taskId}/suspend', + '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.taskId - DTS数据传输任务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + resumeTransmissionTask (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 resumeTransmissionTask" + ) + } + + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling resumeTransmissionTask" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dts/2.2.0' + } + + 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 resumeTransmissionTask 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}/dts/{taskId}/resume', + '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.taskId - DTS数据传输任务ID + * @param {} [opts.name] - 任务名称,名称只支持中文、数字、大小写字母及英文下划线“_”及中划线“-”,不超过32字符 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyTransmissionTaskName (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 modifyTransmissionTaskName" + ) + } + + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling modifyTransmissionTaskName" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dts/2.2.0' + } + + 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 modifyTransmissionTaskName 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}/dts/{taskId}/rename', + '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.taskId - DTS数据传输任务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param object transmissionObject + */ + + describeTransmissionObject (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 describeTransmissionObject" + ) + } + + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling describeTransmissionObject" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dts/2.2.0' + } + + 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 describeTransmissionObject 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}/dts/{taskId}/transmissionobject', + '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.taskId - DTS数据传输任务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param logDetail details + * @param integer totalCount 总数 + */ + + describeTransmissionLog (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 describeTransmissionLog" + ) + } + + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling describeTransmissionLog" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dts/2.2.0' + } + + 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 describeTransmissionLog 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}/dts/{taskId}/log', + '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.taskId - DTS数据传输任务ID + * @param {} opts.endpoint - 实例信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param connectivityTestResult items + */ + + connectivityTest (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 connectivityTest" + ) + } + + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling connectivityTest" + ) + } + if (opts.endpoint === undefined || opts.endpoint === null) { + throw new Error( + "Missing the required parameter 'opts.endpoint' when calling connectivityTest" + ) + } + + let postBody = {} + if (opts.endpoint !== undefined && opts.endpoint !== null) { + postBody['endpoint'] = opts.endpoint + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dts/2.2.0' + } + + 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 connectivityTest 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}/dts/{taskId}/connectivitytest', + '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.instanceType - 实例类型 + * @param {string} [opts.instanceRegion] - 实例地域 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param cloudInstanceSpec instances 实例信息 + */ + + listCloudInstances (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 listCloudInstances" + ) + } + + opts = opts || {} + + if (opts.instanceType === undefined || opts.instanceType === null) { + throw new Error( + "Missing the required parameter 'opts.instanceType' when calling listCloudInstances" + ) + } + + let postBody = null + let queryParams = {} + if (opts.instanceRegion !== undefined && opts.instanceRegion !== null) { + queryParams['instanceRegion'] = opts.instanceRegion + } + + let pathParams = { + regionId: regionId, + instanceType: opts.instanceType + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dts/2.2.0' + } + + 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 listCloudInstances 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}/cloudinstance/{instanceType}', + '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.instanceType - 实例类型 + * @param {string} opts.instanceId - 实例ID + * @param {string} [opts.instanceRegion] - 实例地域 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param cloudInstanceSpec instance 实例信息 + */ + + getCloudInstance (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 getCloudInstance" + ) + } + + opts = opts || {} + + if (opts.instanceType === undefined || opts.instanceType === null) { + throw new Error( + "Missing the required parameter 'opts.instanceType' when calling getCloudInstance" + ) + } + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling getCloudInstance" + ) + } + + let postBody = null + let queryParams = {} + if (opts.instanceRegion !== undefined && opts.instanceRegion !== null) { + queryParams['instanceRegion'] = opts.instanceRegion + } + + let pathParams = { + regionId: regionId, + instanceType: opts.instanceType, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dts/2.2.0' + } + + 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 getCloudInstance 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}/cloudinstance/{instanceType}/id/{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) + } + ) + } + + /** + * 获取Schema列表 + * @param {Object} opts - parameters + * @param {string} opts.endpointId - DTS连接模板ID + * @param {} [opts.taskId] - 订阅任务ID,配置订阅任务时,此项必填。 optional + * @param {} [opts.databaseName] - 数据库名称,此项选填。 optional + * @param {} opts.endpoint - 实例信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param schema schemas + */ + + listSchemas (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 listSchemas" + ) + } + + opts = opts || {} + + if (opts.endpointId === undefined || opts.endpointId === null) { + throw new Error( + "Missing the required parameter 'opts.endpointId' when calling listSchemas" + ) + } + if (opts.endpoint === undefined || opts.endpoint === null) { + throw new Error( + "Missing the required parameter 'opts.endpoint' when calling listSchemas" + ) + } + + let postBody = {} + if (opts.taskId !== undefined && opts.taskId !== null) { + postBody['taskId'] = opts.taskId + } + if (opts.databaseName !== undefined && opts.databaseName !== null) { + postBody['databaseName'] = opts.databaseName + } + if (opts.endpoint !== undefined && opts.endpoint !== null) { + postBody['endpoint'] = opts.endpoint + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + endpointId: opts.endpointId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dts/2.2.0' + } + + 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 listSchemas 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}/endpoint/{endpointId}/schema', + '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) + } + ) + } + + /** + * 获取Table列表 + * @param {Object} opts - parameters + * @param {string} opts.endpointId - DTS连接模板ID + * @param {} [opts.taskId] - 数据传输任务ID optional + * @param {} [opts.databaseName] - 数据库名称,此项选填。 optional + * @param {} [opts.schemaName] - 模式名称,此项选填。 optional + * @param {} opts.endpoint - 连接模板信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param table tables + */ + + listTables (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 listTables" + ) + } + + opts = opts || {} + + if (opts.endpointId === undefined || opts.endpointId === null) { + throw new Error( + "Missing the required parameter 'opts.endpointId' when calling listTables" + ) + } + if (opts.endpoint === undefined || opts.endpoint === null) { + throw new Error( + "Missing the required parameter 'opts.endpoint' when calling listTables" + ) + } + + let postBody = {} + if (opts.taskId !== undefined && opts.taskId !== null) { + postBody['taskId'] = opts.taskId + } + if (opts.databaseName !== undefined && opts.databaseName !== null) { + postBody['databaseName'] = opts.databaseName + } + if (opts.schemaName !== undefined && opts.schemaName !== null) { + postBody['schemaName'] = opts.schemaName + } + if (opts.endpoint !== undefined && opts.endpoint !== null) { + postBody['endpoint'] = opts.endpoint + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + endpointId: opts.endpointId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dts/2.2.0' + } + + 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 listTables 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}/endpoint/{endpointId}/table', + '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) + } + ) + } + + /** + * 获取Topic列表 + * @param {Object} opts - parameters + * @param {string} opts.endpointId - DTS连接模板ID + * @param {} [opts.taskId] - 数据传输任务ID optional + * @param {} opts.endpoint - 连接模板信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param topic tables + */ + + listTopics (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 listTopics" + ) + } + + opts = opts || {} + + if (opts.endpointId === undefined || opts.endpointId === null) { + throw new Error( + "Missing the required parameter 'opts.endpointId' when calling listTopics" + ) + } + if (opts.endpoint === undefined || opts.endpoint === null) { + throw new Error( + "Missing the required parameter 'opts.endpoint' when calling listTopics" + ) + } + + let postBody = {} + if (opts.taskId !== undefined && opts.taskId !== null) { + postBody['taskId'] = opts.taskId + } + if (opts.endpoint !== undefined && opts.endpoint !== null) { + postBody['endpoint'] = opts.endpoint + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + endpointId: opts.endpointId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dts/2.2.0' + } + + 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 listTopics 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}/endpoint/{endpointId}/topic', + '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) + } + ) + } + + /** + * 获取Table详情 + * @param {Object} opts - parameters + * @param {string} opts.endpointId - DTS连接模板ID + * @param {string} opts.tableName - table名称 + * @param {} [opts.taskId] - 数据传输任务ID optional + * @param {} [opts.databaseName] - 数据库名称,此项选填。 optional + * @param {} [opts.schemaName] - 模式名称,此项选填。 optional + * @param {} [opts.tableName] - 表名称,此项必填。 optional + * @param {} opts.endpoint - 连接模板信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param table table + */ + + getTable (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 getTable" + ) + } + + opts = opts || {} + + if (opts.endpointId === undefined || opts.endpointId === null) { + throw new Error( + "Missing the required parameter 'opts.endpointId' when calling getTable" + ) + } + if (opts.tableName === undefined || opts.tableName === null) { + throw new Error( + "Missing the required parameter 'opts.tableName' when calling getTable" + ) + } + if (opts.endpoint === undefined || opts.endpoint === null) { + throw new Error( + "Missing the required parameter 'opts.endpoint' when calling getTable" + ) + } + + let postBody = {} + if (opts.taskId !== undefined && opts.taskId !== null) { + postBody['taskId'] = opts.taskId + } + if (opts.databaseName !== undefined && opts.databaseName !== null) { + postBody['databaseName'] = opts.databaseName + } + if (opts.schemaName !== undefined && opts.schemaName !== null) { + postBody['schemaName'] = opts.schemaName + } + if (opts.tableName !== undefined && opts.tableName !== null) { + postBody['tableName'] = opts.tableName + } + if (opts.endpoint !== undefined && opts.endpoint !== null) { + postBody['endpoint'] = opts.endpoint + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + endpointId: opts.endpointId, + tableName: opts.tableName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dts/2.2.0' + } + + 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 getTable 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}/endpoint/{endpointId}/table/{tableName}', + '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.transmissionMethod] - 传输任务类型:Migration(迁移)、Sync(同步)、Subscribe(订阅)、DisasterRecovery(灾备) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instanceClass instanceClass + */ + + listInstanceClasses (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 listInstanceClasses" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if ( + opts.transmissionMethod !== undefined && + opts.transmissionMethod !== null + ) { + queryParams['transmissionMethod'] = opts.transmissionMethod + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dts/2.2.0' + } + + 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 listInstanceClasses 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}/instanceclass', + '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,[1,∞);-1时返回全部页码。 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[1, 100] optional + * @param {filter} [opts.filters] optional + * @param {sort} [opts.sorts] - createTime - 创建时间,asc(正序),desc(倒序) + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param taskProgress progress + * @param integer totalCount 总记录数 + */ + + listTaskProgress (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 listTaskProgress" + ) + } + + 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')) + Object.assign(queryParams, super.buildSortParam(opts.sorts, 'sorts')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dts/2.2.0' + } + + 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 listTaskProgress 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}/taskprogress', + '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.taskId - DTS数据传输任务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param taskProgress progress + */ + + getTaskProgress (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 getTaskProgress" + ) + } + + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling getTaskProgress" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dts/2.2.0' + } + + 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 getTaskProgress 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}/taskprogress/{taskId}', + '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) + } + ) + } + + /** + * 获取Process + * @param {Object} opts - parameters + * @param {string} opts.id - 获取Process列表的资源ID + * @param {string} [opts.resourceType] - 获取Process列表的资源类型 optional + * @param {integer} [opts.pageNumber] - 页码;默认为1,取值范围:-1,[1,∞);-1时返回全部页码。 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[1, 100] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param process process + * @param integer totalCount 总记录数 + */ + + listProcesses (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 listProcesses" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling listProcesses" + ) + } + + let postBody = null + let queryParams = {} + if (opts.id !== undefined && opts.id !== null) { + queryParams['id'] = opts.id + } + if (opts.resourceType !== undefined && opts.resourceType !== null) { + queryParams['resourceType'] = opts.resourceType + } + 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 + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 dts/2.2.0' + } + + 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 listProcesses 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}/process', + '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 = DTS diff --git a/packages/libs/lib-jdcloud/src/repo/edcps/v1/edcps.js b/packages/libs/lib-jdcloud/src/repo/edcps/v1/edcps.js new file mode 100644 index 000000000..62be74d27 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/edcps/v1/edcps.js @@ -0,0 +1,7044 @@ +/* + * 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. + * + * Distributed-Cloud-Physical-Server + * 分布式云物理服务器私有网络操作相关的接口 + * + * 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 = 'edcps' +Service._services[serviceId] = true + +/** + * edcps service. + * @version 1.3.0 + */ + +class EDCPS extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'edcps.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询别名IP列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[20, 100] optional + * @param {string} [opts.subnetId] - 子网ID optional + * @param {string} [opts.instanceId] - 实例ID optional + * @param {string} [opts.cidr] - CIDR段,模糊搜索 optional + * @param {filter} [opts.filters] - aliasIpId - 别名IP id<br/> + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param aliasIp aliasIps + * @param integer pageNumber 页码;默认为1 + * @param integer pageSize 分页大小;默认为20;取值范围[20, 100] + * @param integer totalCount 查询结果总数 + */ + + describeAliasIps (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 describeAliasIps" + ) + } + + 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.subnetId !== undefined && opts.subnetId !== null) { + queryParams['subnetId'] = opts.subnetId + } + if (opts.instanceId !== undefined && opts.instanceId !== null) { + queryParams['instanceId'] = opts.instanceId + } + if (opts.cidr !== undefined && opts.cidr !== null) { + queryParams['cidr'] = opts.cidr + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 describeAliasIps 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}/aliasIps', + '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 + * @param {Object} opts - parameters + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {aliasIpSpec} opts.aliasIpSpec - 别名IP配置 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param aliasIpSuccessInfo successList + * @param aliasIpErrorInfo errorList + */ + + createAliasIp (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 createAliasIp" + ) + } + + opts = opts || {} + + if (opts.aliasIpSpec === undefined || opts.aliasIpSpec === null) { + throw new Error( + "Missing the required parameter 'opts.aliasIpSpec' when calling createAliasIp" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.aliasIpSpec !== undefined && opts.aliasIpSpec !== null) { + postBody['aliasIpSpec'] = opts.aliasIpSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 createAliasIp 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}/aliasIps', + '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) + } + ) + } + + /** + * 删除别名IP + * @param {Object} opts - parameters + * @param {string} opts.aliasIpId - 别名IP ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 删除操作是否成功 + */ + + deleteAliasIp (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 deleteAliasIp" + ) + } + + opts = opts || {} + + if (opts.aliasIpId === undefined || opts.aliasIpId === null) { + throw new Error( + "Missing the required parameter 'opts.aliasIpId' when calling deleteAliasIp" + ) + } + + let postBody = null + let queryParams = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + queryParams['clientToken'] = opts.clientToken + } + + let pathParams = { + regionId: regionId, + aliasIpId: opts.aliasIpId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 deleteAliasIp 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}/aliasIps/{aliasIpId}', + '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) + } + ) + } + + /** + * 查询弹性公网IP列表<br/> +支持分页查询,默认每页20条<br/> + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[20, 100] optional + * @param {string} [opts.name] - 共享带宽名称 optional + * @param {filter} [opts.filters] - bandwidthPackageId - 共享带宽ID,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param bandwidthPackage bandwidthPackages + * @param integer pageNumber 页码;默认为1 + * @param integer pageSize 分页大小;默认为20;取值范围[20, 100] + * @param integer totalCount 查询结果总数 + */ + + describeBandwidthPackages (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 describeBandwidthPackages" + ) + } + + 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.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 describeBandwidthPackages 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}/bandwidthPackages', + '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 {bandwidthPackageSpec} opts.bandwidthPackageSpec - 共享带宽配置 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string bandwidthPackageIds + */ + + applyBandwidthPackages (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 applyBandwidthPackages" + ) + } + + opts = opts || {} + + if ( + opts.bandwidthPackageSpec === undefined || + opts.bandwidthPackageSpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.bandwidthPackageSpec' when calling applyBandwidthPackages" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if ( + opts.bandwidthPackageSpec !== undefined && + opts.bandwidthPackageSpec !== null + ) { + postBody['bandwidthPackageSpec'] = opts.bandwidthPackageSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 applyBandwidthPackages 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}/bandwidthPackages', + '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) + } + ) + } + + /** + * 查询共享带宽详情 + * @param {Object} opts - parameters + * @param {string} opts.bandwidthPackageId - 共享带宽ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param bandwidthPackage bandwidthPackage 共享带宽详细信息 + */ + + describeBandwidthPackage (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 describeBandwidthPackage" + ) + } + + opts = opts || {} + + if ( + opts.bandwidthPackageId === undefined || + opts.bandwidthPackageId === null + ) { + throw new Error( + "Missing the required parameter 'opts.bandwidthPackageId' when calling describeBandwidthPackage" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + bandwidthPackageId: opts.bandwidthPackageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 describeBandwidthPackage 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}/bandwidthPackages/{bandwidthPackageId}', + '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.bandwidthPackageId - 共享带宽ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} [opts.name] - 名称 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param bandwidthPackage bandwidthPackage 共享带宽详细信息 + */ + + modifyBandwidthPackage (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 modifyBandwidthPackage" + ) + } + + opts = opts || {} + + if ( + opts.bandwidthPackageId === undefined || + opts.bandwidthPackageId === null + ) { + throw new Error( + "Missing the required parameter 'opts.bandwidthPackageId' when calling modifyBandwidthPackage" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + bandwidthPackageId: opts.bandwidthPackageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 modifyBandwidthPackage 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}/bandwidthPackages/{bandwidthPackageId}', + '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.bandwidthPackageId - 共享带宽ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 删除操作是否成功 + */ + + deleteBandwidthPackage (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 deleteBandwidthPackage" + ) + } + + opts = opts || {} + + if ( + opts.bandwidthPackageId === undefined || + opts.bandwidthPackageId === null + ) { + throw new Error( + "Missing the required parameter 'opts.bandwidthPackageId' when calling deleteBandwidthPackage" + ) + } + + let postBody = null + let queryParams = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + queryParams['clientToken'] = opts.clientToken + } + + let pathParams = { + regionId: regionId, + bandwidthPackageId: opts.bandwidthPackageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 deleteBandwidthPackage 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}/bandwidthPackages/{bandwidthPackageId}', + '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.bandwidthPackageId - 共享带宽ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {integer} opts.bandwidth - 带宽,单位Mbps,取值范围[1,10240] + * @param {integer} [opts.extraUplinkBandwidth] - 额外上行带宽,单位Mbps,取值范围[0,10240] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 修改带宽是否成功 + */ + + modifyBandwidthPackageBandwidth ( + 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 modifyBandwidthPackageBandwidth" + ) + } + + opts = opts || {} + + if ( + opts.bandwidthPackageId === undefined || + opts.bandwidthPackageId === null + ) { + throw new Error( + "Missing the required parameter 'opts.bandwidthPackageId' when calling modifyBandwidthPackageBandwidth" + ) + } + if (opts.bandwidth === undefined || opts.bandwidth === null) { + throw new Error( + "Missing the required parameter 'opts.bandwidth' when calling modifyBandwidthPackageBandwidth" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.bandwidth !== undefined && opts.bandwidth !== null) { + postBody['bandwidth'] = opts.bandwidth + } + if ( + opts.extraUplinkBandwidth !== undefined && + opts.extraUplinkBandwidth !== null + ) { + postBody['extraUplinkBandwidth'] = opts.extraUplinkBandwidth + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + bandwidthPackageId: opts.bandwidthPackageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 modifyBandwidthPackageBandwidth 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}/bandwidthPackages/{bandwidthPackageId}:modifyBandwidthPackageBandwidth', + '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) + } + ) + } + + /** + * 添加共享带宽IP + + * @param {Object} opts - parameters + * @param {string} opts.bandwidthPackageId - 共享带宽ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {array} [opts.elasticIpIds] - 弹性公网IP ID optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 添加结果 + */ + + addBandwidthPackageIp (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 addBandwidthPackageIp" + ) + } + + opts = opts || {} + + if ( + opts.bandwidthPackageId === undefined || + opts.bandwidthPackageId === null + ) { + throw new Error( + "Missing the required parameter 'opts.bandwidthPackageId' when calling addBandwidthPackageIp" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.elasticIpIds !== undefined && opts.elasticIpIds !== null) { + postBody['elasticIpIds'] = opts.elasticIpIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + bandwidthPackageId: opts.bandwidthPackageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 addBandwidthPackageIp 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}/bandwidthPackages/{bandwidthPackageId}:addBandwidthPackageIp', + '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) + } + ) + } + + /** + * 移除共享带宽IP + + * @param {Object} opts - parameters + * @param {string} opts.bandwidthPackageId - 共享带宽ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} opts.elasticIpId - 弹性公网IP Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 解绑结果 + */ + + removeBandwidthPackageIp (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 removeBandwidthPackageIp" + ) + } + + opts = opts || {} + + if ( + opts.bandwidthPackageId === undefined || + opts.bandwidthPackageId === null + ) { + throw new Error( + "Missing the required parameter 'opts.bandwidthPackageId' when calling removeBandwidthPackageIp" + ) + } + if (opts.elasticIpId === undefined || opts.elasticIpId === null) { + throw new Error( + "Missing the required parameter 'opts.elasticIpId' when calling removeBandwidthPackageIp" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.elasticIpId !== undefined && opts.elasticIpId !== null) { + postBody['elasticIpId'] = opts.elasticIpId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + bandwidthPackageId: opts.bandwidthPackageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 removeBandwidthPackageIp 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}/bandwidthPackages/{bandwidthPackageId}:removeBandwidthPackageIp', + '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) + } + ) + } + + /** + * 查询共享带宽库存 + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string region 地域 + * @param integer availableBandwidth 可用带宽库存 + * @param integer availableExtraUplinkBandwidth 可用额外上行带宽库存 + */ + + describeBandwidthPackageStock ( + 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 describeBandwidthPackageStock" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 describeBandwidthPackageStock 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}/bandwidthPackageStock', + '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列表<br/> +支持分页查询,默认每页20条<br/> + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[20, 100] optional + * @param {string} [opts.status] - 弹性公网IP状态,取值范围:associate、disassociate optional + * @param {string} [opts.hasJoinBandwidthPackage] - 弹性公网IP是否加入共享带宽,取值范围:yes、no optional + * @param {string} [opts.chargeMode] - 支付模式,取值为:prepaid_by_duration表示预付费,postpaid_by_duration表示按配置后付费 optional + * @param {string} [opts.instanceId] - 实例Id optional + * @param {string} [opts.subnetId] - 子网Id optional + * @param {filter} [opts.filters] - elasticIpId - 弹性公网IPID,精确匹配,支持多个<br/> +elasticIp - 弹性公网IP,精确匹配,支持多个<br/> +bandwidthPackageId - 共享带宽ID,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param elasticIp elasticIps + * @param integer pageNumber 页码;默认为1 + * @param integer pageSize 分页大小;默认为20;取值范围[20, 100] + * @param integer totalCount 查询结果总数 + */ + + describeElasticIps (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 describeElasticIps" + ) + } + + 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.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + if ( + opts.hasJoinBandwidthPackage !== undefined && + opts.hasJoinBandwidthPackage !== null + ) { + queryParams['hasJoinBandwidthPackage'] = opts.hasJoinBandwidthPackage + } + if (opts.chargeMode !== undefined && opts.chargeMode !== null) { + queryParams['chargeMode'] = opts.chargeMode + } + if (opts.instanceId !== undefined && opts.instanceId !== null) { + queryParams['instanceId'] = opts.instanceId + } + if (opts.subnetId !== undefined && opts.subnetId !== null) { + queryParams['subnetId'] = opts.subnetId + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 describeElasticIps 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}/elasticIps', + '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 + + * @param {Object} opts - parameters + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {elasticIpSpec} opts.elasticIpSpec - 弹性公网IP配置 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string elasticIpIds + */ + + applyElasticIps (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 applyElasticIps" + ) + } + + opts = opts || {} + + if (opts.elasticIpSpec === undefined || opts.elasticIpSpec === null) { + throw new Error( + "Missing the required parameter 'opts.elasticIpSpec' when calling applyElasticIps" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.elasticIpSpec !== undefined && opts.elasticIpSpec !== null) { + postBody['elasticIpSpec'] = opts.elasticIpSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 applyElasticIps 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}/elasticIps', + '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) + } + ) + } + + /** + * 查询弹性公网IP详情 + * @param {Object} opts - parameters + * @param {string} opts.elasticIpId - 弹性公网IPID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param elasticIp elasticIp 弹性公网IP详细信息 + */ + + describeElasticIp (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 describeElasticIp" + ) + } + + opts = opts || {} + + if (opts.elasticIpId === undefined || opts.elasticIpId === null) { + throw new Error( + "Missing the required parameter 'opts.elasticIpId' when calling describeElasticIp" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + elasticIpId: opts.elasticIpId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 describeElasticIp 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}/elasticIps/{elasticIpId}', + '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 + + * @param {Object} opts - parameters + * @param {string} opts.elasticIpId - 弹性公网IPID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 删除操作是否成功 + */ + + deleteelasticIp (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 deleteelasticIp" + ) + } + + opts = opts || {} + + if (opts.elasticIpId === undefined || opts.elasticIpId === null) { + throw new Error( + "Missing the required parameter 'opts.elasticIpId' when calling deleteelasticIp" + ) + } + + let postBody = null + let queryParams = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + queryParams['clientToken'] = opts.clientToken + } + + let pathParams = { + regionId: regionId, + elasticIpId: opts.elasticIpId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 deleteelasticIp 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}/elasticIps/{elasticIpId}', + '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) + } + ) + } + + /** + * 修改弹性公网IP带宽 + + * @param {Object} opts - parameters + * @param {string} opts.elasticIpId - 弹性公网IPID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {integer} opts.bandwidth - 带宽,单位Mbps,取值范围[1,10240] + * @param {integer} [opts.extraUplinkBandwidth] - 额外上行带宽,单位Mbps,取值范围[0,10240] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 修改带宽是否成功 + */ + + modifyElasticIpBandwidth (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 modifyElasticIpBandwidth" + ) + } + + opts = opts || {} + + if (opts.elasticIpId === undefined || opts.elasticIpId === null) { + throw new Error( + "Missing the required parameter 'opts.elasticIpId' when calling modifyElasticIpBandwidth" + ) + } + if (opts.bandwidth === undefined || opts.bandwidth === null) { + throw new Error( + "Missing the required parameter 'opts.bandwidth' when calling modifyElasticIpBandwidth" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.bandwidth !== undefined && opts.bandwidth !== null) { + postBody['bandwidth'] = opts.bandwidth + } + if ( + opts.extraUplinkBandwidth !== undefined && + opts.extraUplinkBandwidth !== null + ) { + postBody['extraUplinkBandwidth'] = opts.extraUplinkBandwidth + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + elasticIpId: opts.elasticIpId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 modifyElasticIpBandwidth 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}/elasticIps/{elasticIpId}:modifyElasticIpBandwidth', + '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) + } + ) + } + + /** + * 查询弹性公网IP库存 + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string region 地域 + * @param integer available 可用弹性公网IP库存 + * @param integer availableBandwidth 可用带宽库存 + * @param integer availableExtraUplinkBandwidth 可用额外上行带宽库存 + */ + + describeElasticIpStock (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 describeElasticIpStock" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 describeElasticIpStock 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}/elasticIpStock', + '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.az] - 可用区,精确匹配 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param deviceType deviceTypes + */ + + describeDeviceTypes (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 describeDeviceTypes" + ) + } + + 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 edcps/1.3.0' + } + + 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 describeDeviceTypes 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}/deviceTypes', + '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.deviceType - 实例类型,可调用接口(describeDeviceTypes)获取指定地域的实例类型,例如:edcps.c.normal1 + * @param {string} [opts.osType] - 操作系统类型,取值范围:CentOS、Ubuntu optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param os oss + */ + + describeOS (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 describeOS" + ) + } + + opts = opts || {} + + if (opts.deviceType === undefined || opts.deviceType === null) { + throw new Error( + "Missing the required parameter 'opts.deviceType' when calling describeOS" + ) + } + + let postBody = null + let queryParams = {} + if (opts.deviceType !== undefined && opts.deviceType !== null) { + queryParams['deviceType'] = opts.deviceType + } + if (opts.osType !== undefined && opts.osType !== null) { + queryParams['osType'] = opts.osType + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 describeOS 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}/os', + '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) + } + ) + } + + /** + * 查询某种实例类型的分布式云物理服务器支持的RAID类型,可查询系统盘RAID类型和数据盘RAID类型 + * @param {Object} opts - parameters + * @param {string} opts.deviceType - 实例类型,可调用(describeDeviceTypes)接口获取指定地域的实例类型,例如:edcps.c.normal1 + * @param {string} [opts.volumeType] - 磁盘类型,取值范围:system、data optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param raid raids + */ + + describeDeviceRaids (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 describeDeviceRaids" + ) + } + + opts = opts || {} + + if (opts.deviceType === undefined || opts.deviceType === null) { + throw new Error( + "Missing the required parameter 'opts.deviceType' when calling describeDeviceRaids" + ) + } + + let postBody = null + let queryParams = {} + if (opts.deviceType !== undefined && opts.deviceType !== null) { + queryParams['deviceType'] = opts.deviceType + } + if (opts.volumeType !== undefined && opts.volumeType !== null) { + queryParams['volumeType'] = opts.volumeType + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 describeDeviceRaids 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}/raids', + '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.deviceType] - 实例类型,调用接口(describeDeviceTypes)获取实例类型 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param resourceStock devicesStock + */ + + describeDeviceStock (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 describeDeviceStock" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.deviceType !== undefined && opts.deviceType !== null) { + queryParams['deviceType'] = opts.deviceType + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 describeDeviceStock 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}/deviceStock', + '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 + */ + + 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 || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeInstance" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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}/instances/{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) + } + ) + } + + /** + * 删除单台云物理物理服务器,只能删除运行running、停止stopped、错误error状态的服务器<br/> +不能删除没有计费信息的服务器<br/> + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 分布式云物理服务器ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + 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 || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteInstance" + ) + } + + let postBody = null + let queryParams = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + queryParams['clientToken'] = opts.clientToken + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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}/instances/{instanceId}', + '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条<br/> + + * @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.name] - 分布式云物理服务器名称,支持模糊匹配 optional + * @param {string} [opts.networkType] - 网络类型,精确匹配,支持vpc optional + * @param {string} [opts.deviceType] - 实例类型,精确匹配,调用接口(describeDeviceTypes)获取实例类型 optional + * @param {string} [opts.subnetId] - 子网ID optional + * @param {string} [opts.enableInternet] - 是否启用外网, yes/no optional + * @param {string} [opts.privateIp] - 主网口内网ip optional + * @param {string} [opts.extensionPrivateIp] - 辅网口内网ip optional + * @param {string} [opts.keypairId] - 密钥对id optional + * @param {string} [opts.interfaceMode] - 网口模式 单网口:bond,双网口:dual optional + * @param {filter} [opts.filters] - instanceId - 分布式云物理服务器ID,精确匹配,支持多个<br/> +status - 分布式云物理服务器状态,参考分布式云物理服务器状态,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instance instances + * @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.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + if (opts.networkType !== undefined && opts.networkType !== null) { + queryParams['networkType'] = opts.networkType + } + if (opts.deviceType !== undefined && opts.deviceType !== null) { + queryParams['deviceType'] = opts.deviceType + } + if (opts.subnetId !== undefined && opts.subnetId !== null) { + queryParams['subnetId'] = opts.subnetId + } + if (opts.enableInternet !== undefined && opts.enableInternet !== null) { + queryParams['enableInternet'] = opts.enableInternet + } + if (opts.privateIp !== undefined && opts.privateIp !== null) { + queryParams['privateIp'] = opts.privateIp + } + if ( + opts.extensionPrivateIp !== undefined && + opts.extensionPrivateIp !== null + ) { + queryParams['extensionPrivateIp'] = opts.extensionPrivateIp + } + if (opts.keypairId !== undefined && opts.keypairId !== null) { + queryParams['keypairId'] = opts.keypairId + } + if (opts.interfaceMode !== undefined && opts.interfaceMode !== null) { + queryParams['interfaceMode'] = opts.interfaceMode + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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}/instances', + '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/> +- 地域与可用区<br/> + - 调用接口(queryEdCPSRegions)获取分布式云物理服务器支持的地域与可用区<br/> +- 实例类型<br/> + - 调用接口(describeDeviceTypes)获取物理实例类型列表<br/> + - 不能使用已下线、或已售馨的实例类型<br/> +- 操作系统<br/> + - 可调用接口(describeOS)获取分布式云物理服务器支持的操作系统列表<br/> +- 存储<br/> + - 数据盘多种RAID可选,可调用接口(describeDeviceRaids)获取服务器支持的RAID列表<br/> +- 网络<br/> + - 网络类型目前支持vpc<br/> + - 线路目前支持联通un、电信ct、移动cm<br/> + - 支持不启用外网,如果启用外网,带宽范围[1,200] 单位Mbps<br/> +- 其他<br/> + - 购买时长,可按年或月购买:月取值范围[1,9], 年取值范围[1,3]<br/> + - 密码设置参考公共参数规范<br/> + + * @param {Object} opts - parameters + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {instanceSpec} opts.instanceSpec - 描述分布式云物理服务器配置 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string 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 edcps/1.3.0' + } + + 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}/instances', + '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) + } + ) + } + + /** + * 查询分布式云物理服务器名称 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 分布式云物理服务器ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string name 分布式云物理服务器名称 + */ + + describeInstanceName (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 describeInstanceName" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeInstanceName" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 describeInstanceName 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}/instances/{instanceId}:describeInstanceName', + '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} [opts.name] - 分布式云物理服务器名称 optional + * @param {string} [opts.description] - 分布式云物理服务器描述 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string name 分布式云物理服务器名称 + * @param string description 分布式云物理服务器描述 + */ + + 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" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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}/instances/{instanceId}: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) + } + ) + } + + /** + * 查询单个分布式云物理服务器已安装的RAID信息,包括系统盘RAID信息和数据盘RAID信息 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 分布式云物理服务器ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string sysRaidTypeId 系统盘RAID类型ID + * @param string sysRaidType 系统盘RAID类型 + * @param string dataRaidTypeId 数据盘RAID类型ID + * @param string dataRaidType 数据盘RAID类型 + */ + + describeInstanceRaid (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 describeInstanceRaid" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeInstanceRaid" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 describeInstanceRaid 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}/instances/{instanceId}:describeInstanceRaid', + '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 boolean cpus CPU状态是否正常 + * @param boolean mems 内存状态是否正常 + * @param boolean disks 硬盘状态是否正常 + * @param boolean nics 网卡状态是否正常 + */ + + describeInstanceStatus (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 describeInstanceStatus" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeInstanceStatus" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 describeInstanceStatus 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}/instances/{instanceId}:describeInstanceStatus', + '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) + } + ) + } + + /** + * 重启单台分布式云物理服务器,只能重启running状态的服务器 [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 分布式云物理服务器ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 重启操作是否成功 + */ + + restartInstance (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 restartInstance" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling restartInstance" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 restartInstance 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}/instances/{instanceId}:restartInstance', + '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) + } + ) + } + + /** + * 对单台分布式云物理服务器执行关机操作,只能停止running状态的服务器 [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 分布式云物理服务器ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + 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 + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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}/instances/{instanceId}:stopInstance', + '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) + } + ) + } + + /** + * 对单台分布式云物理服务器执行开机操作,只能启动stopped状态的服务器 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 分布式云物理服务器ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @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 + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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}/instances/{instanceId}:startInstance', + '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) + } + ) + } + + /** + * 重装分布式云物理服务器,只能重装stopped状态的服务器<br/> +- 可调用接口(describeOS)获取分布式云物理服务器支持的操作系统列表 + [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 分布式云物理服务器ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {reinstallInstanceSpec} opts.instanceSpec - 分布式云物理服务器配置 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 重装操作是否成功 + */ + + reinstallInstance (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 reinstallInstance" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling reinstallInstance" + ) + } + if (opts.instanceSpec === undefined || opts.instanceSpec === null) { + throw new Error( + "Missing the required parameter 'opts.instanceSpec' when calling reinstallInstance" + ) + } + + 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, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 reinstallInstance 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}/instances/{instanceId}:reinstallInstance', + '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) + } + ) + } + + /** + * 绑定弹性公网IP + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 分布式云物理服务器ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} opts.elasticIpId - 弹性公网IPID + * @param {string} [opts.targetIp] - 私有IP optional + * @param {string} [opts.subnetId] - 主网口或辅网口的子网ID,多网口实例必填 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 绑定结果 + */ + + associateElasticIp (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 associateElasticIp" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling associateElasticIp" + ) + } + if (opts.elasticIpId === undefined || opts.elasticIpId === null) { + throw new Error( + "Missing the required parameter 'opts.elasticIpId' when calling associateElasticIp" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.elasticIpId !== undefined && opts.elasticIpId !== null) { + postBody['elasticIpId'] = opts.elasticIpId + } + if (opts.targetIp !== undefined && opts.targetIp !== null) { + postBody['targetIp'] = opts.targetIp + } + if (opts.subnetId !== undefined && opts.subnetId !== null) { + postBody['subnetId'] = opts.subnetId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 associateElasticIp 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}/instances/{instanceId}:associateElasticIp', + '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) + } + ) + } + + /** + * 解绑弹性公网IP + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 分布式云物理服务器ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} opts.elasticIpId - 弹性公网IPId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 解绑结果 + */ + + disassociateElasticIp (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 disassociateElasticIp" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling disassociateElasticIp" + ) + } + if (opts.elasticIpId === undefined || opts.elasticIpId === null) { + throw new Error( + "Missing the required parameter 'opts.elasticIpId' when calling disassociateElasticIp" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.elasticIpId !== undefined && opts.elasticIpId !== null) { + postBody['elasticIpId'] = opts.elasticIpId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 disassociateElasticIp 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}/instances/{instanceId}:disassociateElasticIp', + '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) + } + ) + } + + /** + * 重置分布式云物理服务器密码 + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 分布式云物理服务器ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} opts.password - 密码 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 重置结果 + */ + + resetPassword (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 resetPassword" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling resetPassword" + ) + } + if (opts.password === undefined || opts.password === null) { + throw new Error( + "Missing the required parameter 'opts.password' when calling resetPassword" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.password !== undefined && opts.password !== null) { + postBody['password'] = opts.password + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 resetPassword 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}/instances/{instanceId}:resetPassword', + '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) + } + ) + } + + /** + * 查询可用的私有IP列表 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 分布式云物理服务器ID + * @param {string} opts.subnetId - 主网口或者辅网口的子网id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string availablePrivateIps + */ + + describeAvailablePrivateIp (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 describeAvailablePrivateIp" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeAvailablePrivateIp" + ) + } + if (opts.subnetId === undefined || opts.subnetId === null) { + throw new Error( + "Missing the required parameter 'opts.subnetId' when calling describeAvailablePrivateIp" + ) + } + + let postBody = null + let queryParams = {} + if (opts.subnetId !== undefined && opts.subnetId !== null) { + queryParams['subnetId'] = opts.subnetId + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 describeAvailablePrivateIp 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}/instances/{instanceId}/availablePrivateIps', + '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 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[20, 100] optional + * @param {string} [opts.name] - 密钥对名称 optional + * @param {filter} [opts.filters] - keypairId - 密钥对ID,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param keypair keypairs + * @param integer pageNumber 页码;默认为1 + * @param integer pageSize 分页大小;默认为20;取值范围[20, 100] + * @param integer totalCount 查询结果总数 + */ + + describeKeypairs (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 describeKeypairs" + ) + } + + 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.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 describeKeypairs 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}/keypairs', + '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.name - 密钥对名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string keypairId 密钥对id + * @param string region 地域 + * @param string name 密钥对名称 + * @param string publicKey 公钥 + * @param string fingerPrint 指纹 + * @param string createTime 创建时间 + * @param string updateTime 更新时间 + * @param string privateKey 私钥 + */ + + createKeypairs (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 createKeypairs" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createKeypairs" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 createKeypairs 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}/keypairs', + '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) + } + ) + } + + /** + * 导入密钥对 + * @param {Object} opts - parameters + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} opts.name - 密钥对名称 + * @param {string} opts.publicKey - 公钥 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string keypairId 密钥对id + * @param string region 地域 + * @param string name 密钥对名称 + * @param string publicKey 公钥 + * @param string fingerPrint 指纹 + * @param string createTime 创建时间 + * @param string updateTime 更新时间 + */ + + importKeypairs (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 importKeypairs" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling importKeypairs" + ) + } + if (opts.publicKey === undefined || opts.publicKey === null) { + throw new Error( + "Missing the required parameter 'opts.publicKey' when calling importKeypairs" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.publicKey !== undefined && opts.publicKey !== null) { + postBody['publicKey'] = opts.publicKey + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 importKeypairs 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}/keypairs:import', + '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) + } + ) + } + + /** + * 查询密钥对详情 + * @param {Object} opts - parameters + * @param {string} opts.keypairId - 密钥对ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param keypair keypair 密钥对详细信息 + */ + + describeKeypair (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 describeKeypair" + ) + } + + opts = opts || {} + + if (opts.keypairId === undefined || opts.keypairId === null) { + throw new Error( + "Missing the required parameter 'opts.keypairId' when calling describeKeypair" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + keypairId: opts.keypairId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 describeKeypair 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}/keypairs/{keypairId}', + '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.keypairId - 密钥对ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 删除操作是否成功 + */ + + deleteKeypairs (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 deleteKeypairs" + ) + } + + opts = opts || {} + + if (opts.keypairId === undefined || opts.keypairId === null) { + throw new Error( + "Missing the required parameter 'opts.keypairId' when calling deleteKeypairs" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + keypairId: opts.keypairId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 deleteKeypairs 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}/keypairs/{keypairId}', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param lineType lineType 链路类型信息 + */ + + describeLineTypes (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 describeLineTypes" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 describeLineTypes 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}/lineTypes', + '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} callback - callback + @return {Object} result + * @param region regions + */ + + describeEdCPSRegions (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 describeEdCPSRegions 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( + '/edgeRegions', + '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) + } + ) + } + + /** + * 查询次要CIDR列表 + * @param {Object} opts - parameters + * @param {string} opts.subnetId - 子网ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param secondaryCidr secondaryCidrs + */ + + describeSecondaryCidrs (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 describeSecondaryCidrs" + ) + } + + opts = opts || {} + + if (opts.subnetId === undefined || opts.subnetId === null) { + throw new Error( + "Missing the required parameter 'opts.subnetId' when calling describeSecondaryCidrs" + ) + } + + let postBody = null + let queryParams = {} + if (opts.subnetId !== undefined && opts.subnetId !== null) { + queryParams['subnetId'] = opts.subnetId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 describeSecondaryCidrs 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}/secondaryCidrs', + '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) + } + ) + } + + /** + * 添加次要CIDR + * @param {Object} opts - parameters + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {secondaryCidrSpec} opts.secondaryCidrSpec - 次要cidr配置 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string secondaryCidrId 次要cidr的ID + */ + + createSecondaryCidr (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 createSecondaryCidr" + ) + } + + opts = opts || {} + + if ( + opts.secondaryCidrSpec === undefined || + opts.secondaryCidrSpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.secondaryCidrSpec' when calling createSecondaryCidr" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if ( + opts.secondaryCidrSpec !== undefined && + opts.secondaryCidrSpec !== null + ) { + postBody['secondaryCidrSpec'] = opts.secondaryCidrSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 createSecondaryCidr 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}/secondaryCidrs', + '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) + } + ) + } + + /** + * 删除次要CIDR + * @param {Object} opts - parameters + * @param {string} opts.secondaryCidrId - 次要CIDR ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 删除操作是否成功 + */ + + deleteSecondaryCidr (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 deleteSecondaryCidr" + ) + } + + opts = opts || {} + + if (opts.secondaryCidrId === undefined || opts.secondaryCidrId === null) { + throw new Error( + "Missing the required parameter 'opts.secondaryCidrId' when calling deleteSecondaryCidr" + ) + } + + let postBody = null + let queryParams = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + queryParams['clientToken'] = opts.clientToken + } + + let pathParams = { + regionId: regionId, + secondaryCidrId: opts.secondaryCidrId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 deleteSecondaryCidr 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}/secondaryCidrs/{secondaryCidrId}', + '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 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[20, 100] optional + * @param {string} [opts.az] - 可用区,精确匹配 optional + * @param {string} [opts.name] - 子网名称 optional + * @param {string} [opts.vpcId] - 私有网络ID,精确匹配 optional + * @param {filter} [opts.filters] - subnetId - 子网ID,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param subnet subnets + * @param integer pageNumber 页码;默认为1 + * @param integer pageSize 分页大小;默认为20;取值范围[20, 100] + * @param integer 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.az !== undefined && opts.az !== null) { + queryParams['az'] = opts.az + } + if (opts.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + if (opts.vpcId !== undefined && opts.vpcId !== null) { + queryParams['vpcId'] = opts.vpcId + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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}/subnets', + '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 {subnetSpec} opts.subnetSpec - 子网配置 + * @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.subnetSpec === undefined || opts.subnetSpec === null) { + throw new Error( + "Missing the required parameter 'opts.subnetSpec' when calling createSubnet" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.subnetSpec !== undefined && opts.subnetSpec !== null) { + postBody['subnetSpec'] = opts.subnetSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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}/subnets', + '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) + } + ) + } + + /** + * 查询子网详情 + * @param {Object} opts - parameters + * @param {string} opts.subnetId - 子网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 edcps/1.3.0' + } + + 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}/subnets/{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 - 子网ID + * @param {string} [opts.name] - 名称 optional + * @param {string} [opts.description] - 描述 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param subnet subnet 子网详细信息 + */ + + modifySubnet (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 modifySubnet" + ) + } + + opts = opts || {} + + if (opts.subnetId === undefined || opts.subnetId === null) { + throw new Error( + "Missing the required parameter 'opts.subnetId' when calling modifySubnet" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + subnetId: opts.subnetId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 modifySubnet 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}/subnets/{subnetId}', + '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 - 子网ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 删除操作是否成功 + */ + + 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 = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + queryParams['clientToken'] = opts.clientToken + } + + let pathParams = { + regionId: regionId, + subnetId: opts.subnetId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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}/subnets/{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) + } + ) + } + + /** + * 查询私有网络详情 + * @param {Object} opts - parameters + * @param {string} opts.vpcId - 私有网络ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param vpc vpc 私有网络详细信息 + */ + + describeVpc (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 describeVpc" + ) + } + + opts = opts || {} + + if (opts.vpcId === undefined || opts.vpcId === null) { + throw new Error( + "Missing the required parameter 'opts.vpcId' when calling describeVpc" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + vpcId: opts.vpcId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 describeVpc 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}/vpcs/{vpcId}', + '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 - 私有网络ID + * @param {string} [opts.name] - 名称 optional + * @param {string} [opts.description] - 描述 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param vpc vpc 私有网络详细信息 + */ + + modifyVpc (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 modifyVpc" + ) + } + + opts = opts || {} + + if (opts.vpcId === undefined || opts.vpcId === null) { + throw new Error( + "Missing the required parameter 'opts.vpcId' when calling modifyVpc" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + vpcId: opts.vpcId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 modifyVpc 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}/vpcs/{vpcId}', + '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.vpcId - 私有网络ID + * @param {string} [opts.clientToken] - 由客户端生成,用于保证请求的幂等性,长度不能超过36个字符;<br/> +如果多个请求使用了相同的clientToken,只会执行第一个请求,之后的请求直接返回第一个请求的结果<br/> + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 删除操作是否成功 + */ + + deleteVpc (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 deleteVpc" + ) + } + + opts = opts || {} + + if (opts.vpcId === undefined || opts.vpcId === null) { + throw new Error( + "Missing the required parameter 'opts.vpcId' when calling deleteVpc" + ) + } + + let postBody = null + let queryParams = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + queryParams['clientToken'] = opts.clientToken + } + + let pathParams = { + regionId: regionId, + vpcId: opts.vpcId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 deleteVpc 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}/vpcs/{vpcId}', + '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 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[20, 100] optional + * @param {string} [opts.name] - 私有网络名称 optional + * @param {filter} [opts.filters] - vpcId - 私有网络ID,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param vpc vpcs + * @param integer pageNumber 页码;默认为1 + * @param integer pageSize 分页大小;默认为20;取值范围[20, 100] + * @param integer totalCount 查询结果总数 + */ + + describeVpcs (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 describeVpcs" + ) + } + + 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.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 describeVpcs 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}/vpcs', + '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 {vpcSpec} opts.vpcSpec - 子网配置 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string vpcId 私有网络ID + */ + + createVpc (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 createVpc" + ) + } + + opts = opts || {} + + if (opts.vpcSpec === undefined || opts.vpcSpec === null) { + throw new Error( + "Missing the required parameter 'opts.vpcSpec' when calling createVpc" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.vpcSpec !== undefined && opts.vpcSpec !== null) { + postBody['vpcSpec'] = opts.vpcSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 edcps/1.3.0' + } + + 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 createVpc 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}/vpcs', + '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) + } + ) + } +} +module.exports = EDCPS diff --git a/packages/libs/lib-jdcloud/src/repo/eid/v1/eid.js b/packages/libs/lib-jdcloud/src/repo/eid/v1/eid.js new file mode 100644 index 000000000..3922ef6f1 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/eid/v1/eid.js @@ -0,0 +1,333 @@ +/* + * 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. + * + * 页面测试检测接口 + * 京东云信用评分-OpenAPI页面测试检测接口 + * + * 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 = 'eid' +Service._services[serviceId] = true + +/** + * eid service. + * @version 1.0.0 + */ + +class EID extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'bio-web.jdcloud.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 获取设备评分 + * @param {Object} opts - parameters + * @param {} [opts.tasks] - 检测任务列表,包含一个或多个元素。每个元素是个结构体,最多可添加100元素,即最多对100个设备数据进行评分。每个元素的具体结构描述见creditTask。 optional + * @param {string} callback - callback + @return {Object} result + * @param eidScoreResult data + */ + + eidScore (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.tasks !== undefined && opts.tasks !== null) { + postBody['tasks'] = opts.tasks + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 eid/1.0.0' + } + + 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 eidScore 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( + '/eidScore:check', + '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.data] optional + * @param {string} callback - callback + @return {Object} result + */ + + vttok (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.data !== undefined && opts.data !== null) { + postBody['data'] = opts.data + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 eid/1.0.0' + } + + 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 vttok 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( + '/sdk:vttok', + '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.data] optional + * @param {string} callback - callback + @return {Object} result + */ + + device (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.data !== undefined && opts.data !== null) { + postBody['data'] = opts.data + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 eid/1.0.0' + } + + 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 device 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( + '/sdk:device', + '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 = EID diff --git a/packages/libs/lib-jdcloud/src/repo/elite/v1/elite.js b/packages/libs/lib-jdcloud/src/repo/elite/v1/elite.js new file mode 100644 index 000000000..c09a88bfe --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/elite/v1/elite.js @@ -0,0 +1,1141 @@ +/* + * 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. + * + * elite云存服务相关接口 + * elite云存服务相关接口 + * + * 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 = 'elite' +Service._services[serviceId] = true + +/** + * elite service. + * @version 1.0.8 + */ + +JDCloud.ELITE = class ELITE extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'elite.cn-south-1.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询交付信息接口 + * @param {Object} opts - parameters + * @param {string} opts.orderNumber - 订单号 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status true为成功,false为失败 + * @param string message 描述信息 + * @param queryDeliveryInfoResultVo data 查询数据结果 + */ + + jdxQueryDeliveryInfo (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 jdxQueryDeliveryInfo" + ) + } + + opts = opts || {} + + if (opts.orderNumber === undefined || opts.orderNumber === null) { + throw new Error( + "Missing the required parameter 'opts.orderNumber' when calling jdxQueryDeliveryInfo" + ) + } + + let postBody = null + let queryParams = {} + if (opts.orderNumber !== undefined && opts.orderNumber !== null) { + queryParams['orderNumber'] = opts.orderNumber + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 elite/1.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 jdxQueryDeliveryInfo 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 = this.makeRequest( + '/regions/{regionId}/jdxQueryDeliveryInfo', + '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 {reportOrderInfo} opts.reportOrderInfo - 上报订单信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status true为成功,false为失败 + * @param string message 描述信息 + */ + + jdxReportOrder (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 jdxReportOrder" + ) + } + + opts = opts || {} + + if (opts.reportOrderInfo === undefined || opts.reportOrderInfo === null) { + throw new Error( + "Missing the required parameter 'opts.reportOrderInfo' when calling jdxReportOrder" + ) + } + + let postBody = {} + if (opts.reportOrderInfo !== undefined && opts.reportOrderInfo !== null) { + postBody['reportOrderInfo'] = opts.reportOrderInfo + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 elite/1.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 jdxReportOrder 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 = this.makeRequest( + '/regions/{regionId}/jdxReportOrder', + '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 {createOrderInfo} opts.createOrderInfo - 下单信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status true为成功,false为失败 + * @param string message 描述信息 + * @param createOrderResultVo data 下单后生成的订单号 + */ + + jdxCreateOrder (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 jdxCreateOrder" + ) + } + + opts = opts || {} + + if (opts.createOrderInfo === undefined || opts.createOrderInfo === null) { + throw new Error( + "Missing the required parameter 'opts.createOrderInfo' when calling jdxCreateOrder" + ) + } + + let postBody = {} + if (opts.createOrderInfo !== undefined && opts.createOrderInfo !== null) { + postBody['createOrderInfo'] = opts.createOrderInfo + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 elite/1.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 jdxCreateOrder 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 = this.makeRequest( + '/regions/{regionId}/jdxCreateOrder', + '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 {queryPriceParam} opts.queryPriceParam - 查询价格参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status true为成功,false为失败 + * @param string message 描述信息 + * @param queryPriceResultVo data 查询数据结果 + */ + + jdxQueryPrice (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 jdxQueryPrice" + ) + } + + opts = opts || {} + + if (opts.queryPriceParam === undefined || opts.queryPriceParam === null) { + throw new Error( + "Missing the required parameter 'opts.queryPriceParam' when calling jdxQueryPrice" + ) + } + + let postBody = {} + if (opts.queryPriceParam !== undefined && opts.queryPriceParam !== null) { + postBody['queryPriceParam'] = opts.queryPriceParam + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 elite/1.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 jdxQueryPrice 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 = this.makeRequest( + '/regions/{regionId}/jdxQueryPrice', + '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.pageNo - 页码(最小1) + * @param {integer} opts.pageSize - 每页记录数(最小10,最大100) + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status true为成功,false为失败 + * @param string message 描述信息 + * @param jdxProductVoListData data 查询数据结果 + */ + + jdxQueryProduct (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 jdxQueryProduct" + ) + } + + opts = opts || {} + + if (opts.pageNo === undefined || opts.pageNo === null) { + throw new Error( + "Missing the required parameter 'opts.pageNo' when calling jdxQueryProduct" + ) + } + if (opts.pageSize === undefined || opts.pageSize === null) { + throw new Error( + "Missing the required parameter 'opts.pageSize' when calling jdxQueryProduct" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pageNo !== undefined && opts.pageNo !== null) { + queryParams['pageNo'] = opts.pageNo + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 elite/1.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 jdxQueryProduct 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 = this.makeRequest( + '/regions/{regionId}/jdxQueryProduct', + '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.pageNo - 页码(最小1) + * @param {integer} opts.pageSize - 每页记录数(最小10,最大100) + * @param {string} [opts.deliverNumber] - 交付单号 optional + * @param {integer} [opts.deliverStatus] - 交付状态 optional + * @param {string} [opts.createDtStart] - 交付单创建起始时间,格式:yyyy-MM-dd HH:mm:ss optional + * @param {string} [opts.createDtEnd] - 交付单创建结束时间,格式:yyyy-MM-dd HH:mm:ss optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status true为成功,false为失败 + * @param string message 描述信息 + * @param productServiceVoListData data 查询数据结果 + */ + + listSaleService (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 listSaleService" + ) + } + + opts = opts || {} + + if (opts.pageNo === undefined || opts.pageNo === null) { + throw new Error( + "Missing the required parameter 'opts.pageNo' when calling listSaleService" + ) + } + if (opts.pageSize === undefined || opts.pageSize === null) { + throw new Error( + "Missing the required parameter 'opts.pageSize' when calling listSaleService" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pageNo !== undefined && opts.pageNo !== null) { + queryParams['pageNo'] = opts.pageNo + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.deliverNumber !== undefined && opts.deliverNumber !== null) { + queryParams['deliverNumber'] = opts.deliverNumber + } + if (opts.deliverStatus !== undefined && opts.deliverStatus !== null) { + queryParams['deliverStatus'] = opts.deliverStatus + } + if (opts.createDtStart !== undefined && opts.createDtStart !== null) { + queryParams['createDtStart'] = opts.createDtStart + } + if (opts.createDtEnd !== undefined && opts.createDtEnd !== null) { + queryParams['createDtEnd'] = opts.createDtEnd + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 elite/1.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 listSaleService 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 = this.makeRequest( + '/regions/{regionId}/listSaleService', + '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.deliverNumber - 交付单号 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status true为成功,false为失败 + * @param string message 描述信息 + * @param productServiceVo data 查询数据结果 + */ + + getSaleServiceByDeliverNumber ( + 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 getSaleServiceByDeliverNumber" + ) + } + + opts = opts || {} + + if (opts.deliverNumber === undefined || opts.deliverNumber === null) { + throw new Error( + "Missing the required parameter 'opts.deliverNumber' when calling getSaleServiceByDeliverNumber" + ) + } + + let postBody = null + let queryParams = {} + if (opts.deliverNumber !== undefined && opts.deliverNumber !== null) { + queryParams['deliverNumber'] = opts.deliverNumber + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 elite/1.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 getSaleServiceByDeliverNumber 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 = this.makeRequest( + '/regions/{regionId}/getSaleServiceByDeliverNumber', + '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 {confirmDeliveryInfo} opts.confirmDeliveryInfo - 交付信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status true为成功,false为失败 + * @param string message 描述信息 + */ + + confirmSaleServiceDelivery (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 confirmSaleServiceDelivery" + ) + } + + opts = opts || {} + + if ( + opts.confirmDeliveryInfo === undefined || + opts.confirmDeliveryInfo === null + ) { + throw new Error( + "Missing the required parameter 'opts.confirmDeliveryInfo' when calling confirmSaleServiceDelivery" + ) + } + + let postBody = {} + if ( + opts.confirmDeliveryInfo !== undefined && + opts.confirmDeliveryInfo !== null + ) { + postBody['confirmDeliveryInfo'] = opts.confirmDeliveryInfo + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 elite/1.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 confirmSaleServiceDelivery 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 = this.makeRequest( + '/regions/{regionId}/confirmSaleServiceDelivery', + '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.buyerPin - 购买用户pin + * @param {string} opts.businessData - 业务数据,与下单时的业务数据一致 + * @param {boolean} [opts.queryAll] - 是否查询全部,如果传入false,则只查询当前时间有效的,否则查询所有的 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status true为成功,false为失败 + * @param string message 描述信息 + * @param storeServiceVo data 查询数据结果 + */ + + getStoreService (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 getStoreService" + ) + } + + opts = opts || {} + + if (opts.buyerPin === undefined || opts.buyerPin === null) { + throw new Error( + "Missing the required parameter 'opts.buyerPin' when calling getStoreService" + ) + } + if (opts.businessData === undefined || opts.businessData === null) { + throw new Error( + "Missing the required parameter 'opts.businessData' when calling getStoreService" + ) + } + + let postBody = null + let queryParams = {} + if (opts.buyerPin !== undefined && opts.buyerPin !== null) { + queryParams['buyerPin'] = opts.buyerPin + } + if (opts.businessData !== undefined && opts.businessData !== null) { + queryParams['businessData'] = opts.businessData + } + if (opts.queryAll !== undefined && opts.queryAll !== null) { + queryParams['queryAll'] = opts.queryAll + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 elite/1.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 getStoreService 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 = this.makeRequest( + '/regions/{regionId}/getStoreService', + '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 = JDCloud.ELITE diff --git a/packages/libs/lib-jdcloud/src/repo/es/v1/es.js b/packages/libs/lib-jdcloud/src/repo/es/v1/es.js new file mode 100644 index 000000000..6e70ad0db --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/es/v1/es.js @@ -0,0 +1,771 @@ +/* + * 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. + * + * ES Snapshot API + * es快照创建、查询,自动快照的设置、查询接口 + * + * 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 = 'es' +Service._services[serviceId] = true + +/** + * es service. + * @version 1.0.1 + */ + +JDCloud.ES = class ES extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'es.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 关闭自定义字典。同时清除用户已上传的字典 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string instanceId 实例ID + */ + + disableDicts (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 disableDicts" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling disableDicts" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 es/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 disableDicts 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}/instances/{instanceId}/dicts', + '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) + } + ) + } + + /** + * 查询es实例列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码,默认1 optional + * @param {integer} [opts.pageSize] - 分页大小,默认10 optional + * @param {filter} [opts.filters] - 过滤条件: +instanceId -实例Id,精确匹配,支持多个 +instanceVersion -实例版本,精确匹配,支持单个 +azId -azId,精确匹配,支持单个 +instanceName - 实例名称,模糊匹配,支持单个 +instanceStatus - 实例状态,精确匹配,支持多个(running:运行,error:错误,creating:创建中,changing:变配中,stop:已停止,processing:处理中) +chargeMode - 计费类型,按配置postpaid_by_duration或者包年包月prepaid_by_duration + optional + * @param {tagFilter} [opts.tagFilters] - 标签过滤条件 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instance instances + * @param integer totalCount es实例总数 + */ + + 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 + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + Object.assign( + queryParams, + super.buildTagFilterParam(opts.tagFilters, 'tagFilters') + ) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 es/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}/instances', + '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) + } + ) + } + + /** + * 创建一个指定配置的es实例 + * @param {Object} opts - parameters + * @param {instanceSpec} opts.instance - es实例的相关配置 + * @param {chargeSpec} [opts.charge] - 计费信息的相关配置,es只有prepaid_by_duration和postpaid_by_duration 2种计费模式 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string orderNum 订单编号 + * @param string instanceId es实例编号 + */ + + createInstance (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 createInstance" + ) + } + + opts = opts || {} + + if (opts.instance === undefined || opts.instance === null) { + throw new Error( + "Missing the required parameter 'opts.instance' when calling createInstance" + ) + } + + let postBody = {} + if (opts.instance !== undefined && opts.instance !== null) { + postBody['instance'] = opts.instance + } + if (opts.charge !== undefined && opts.charge !== null) { + postBody['charge'] = opts.charge + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 es/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 createInstance 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}/instances', + '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) + } + ) + } + + /** + * 查询es实例的详细信息 + * @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 es实例详细信息 + */ + + 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 || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeInstance" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 es/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}/instances/{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) + } + ) + } + + /** + * 删除按配置计费或包年包月已到期的es实例,包年包月未到期不可删除。 +状态为创建中和变配中的不可删除。 + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + 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 || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteInstance" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 es/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}/instances/{instanceId}', + '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) + } + ) + } + + /** + * 变更es实例的配置,实例为running状态才可变更配置,每次只能变更一种且不可与原来的相同。 +实例配置(cpu核数、内存、磁盘容量、节点数量)目前只允许变大 + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {string} [opts.nodeClass] - data节点规格 optional + * @param {integer} [opts.nodeDiskGB] - data节点磁盘 optional + * @param {integer} [opts.nodeCount] - data节点数 optional + * @param {string} [opts.masterClass] - master节点规格 optional + * @param {string} [opts.coordinatingClass] - coordinating节点规格 optional + * @param {integer} [opts.coordinatingCount] - coordinating节点数 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string orderNum 订单编号 + * @param string instanceId es实例编号 + */ + + 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" + ) + } + + let postBody = {} + if (opts.nodeClass !== undefined && opts.nodeClass !== null) { + postBody['nodeClass'] = opts.nodeClass + } + if (opts.nodeDiskGB !== undefined && opts.nodeDiskGB !== null) { + postBody['nodeDiskGB'] = opts.nodeDiskGB + } + if (opts.nodeCount !== undefined && opts.nodeCount !== null) { + postBody['nodeCount'] = opts.nodeCount + } + if (opts.masterClass !== undefined && opts.masterClass !== null) { + postBody['masterClass'] = opts.masterClass + } + if ( + opts.coordinatingClass !== undefined && + opts.coordinatingClass !== null + ) { + postBody['coordinatingClass'] = opts.coordinatingClass + } + if ( + opts.coordinatingCount !== undefined && + opts.coordinatingCount !== null + ) { + postBody['coordinatingCount'] = opts.coordinatingCount + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 es/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}/instances/{instanceId}: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) + } + ) + } +} +module.exports = JDCloud.ES diff --git a/packages/libs/lib-jdcloud/src/repo/fc/v1/fc.js b/packages/libs/lib-jdcloud/src/repo/fc/v1/fc.js new file mode 100644 index 000000000..d02cf66b5 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/fc/v1/fc.js @@ -0,0 +1,2392 @@ +/* + * 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. + * + * Trigger + * Trigger 相关接口 + * + * 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 = 'fc' +Service._services[serviceId] = true + +/** + * fc service. + * @version 1.0.2 + */ + +class FC extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'fc.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 批量查询 function 的详细信息<br> +此接口支持分页查询,默认每页20条。 + + * @param {Object} opts - parameters + * @param {string} opts.serviceName - Service Name + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 100] optional + * @param {filter} [opts.filters] - name - 实例名称,模糊匹配,支持单个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param function functions + * @param number totalCount + */ + + describeFunctions (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 describeFunctions" + ) + } + + opts = opts || {} + + if (opts.serviceName === undefined || opts.serviceName === null) { + throw new Error( + "Missing the required parameter 'opts.serviceName' when calling describeFunctions" + ) + } + + 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, + serviceName: opts.serviceName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 fc/1.0.2' + } + + 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 describeFunctions 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}/services/{serviceName}/functions', + '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.serviceName - Service Name + * @param {functionSpec} opts.functionSpec - 函数 创建参数 + * @param {string} [opts.clientToken] - 保证请求幂等性的字符串;最大长度64个ASCII字符 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string functionName + */ + + createFunction (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 createFunction" + ) + } + + opts = opts || {} + + if (opts.serviceName === undefined || opts.serviceName === null) { + throw new Error( + "Missing the required parameter 'opts.serviceName' when calling createFunction" + ) + } + if (opts.functionSpec === undefined || opts.functionSpec === null) { + throw new Error( + "Missing the required parameter 'opts.functionSpec' when calling createFunction" + ) + } + + let postBody = {} + if (opts.functionSpec !== undefined && opts.functionSpec !== null) { + postBody['functionSpec'] = opts.functionSpec + } + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + serviceName: opts.serviceName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 fc/1.0.2' + } + + 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 createFunction 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}/services/{serviceName}/functions', + '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.serviceName - Service Name + * @param {string} opts.functionName - Function Name + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param function function + */ + + describeFunction (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 describeFunction" + ) + } + + opts = opts || {} + + if (opts.serviceName === undefined || opts.serviceName === null) { + throw new Error( + "Missing the required parameter 'opts.serviceName' when calling describeFunction" + ) + } + if (opts.functionName === undefined || opts.functionName === null) { + throw new Error( + "Missing the required parameter 'opts.functionName' when calling describeFunction" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + serviceName: opts.serviceName, + functionName: opts.functionName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 fc/1.0.2' + } + + 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 describeFunction 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}/services/{serviceName}/functions/{functionName}', + '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) + } + ) + } + + /** + * 修改 function + + * @param {Object} opts - parameters + * @param {string} opts.serviceName - Service Name + * @param {string} opts.functionName - Function Name + * @param {code} [opts.code] - 修改后的代码 optional + * @param {integer} [opts.timeout] - 修改后的超时时间 optional + * @param {string} [opts.runtime] - 修改后的运行时语言 optional + * @param {string} [opts.handler] - 修改后的函数执行入口 optional + * @param {string} [opts.description] - 修改后的描述 optional + * @param {array} [opts.envs] - 修改后的环境变量 optional + * @param {number} [opts.cpu] - 修改后的cpu optional + * @param {integer} [opts.memorySize] - 修改后的内存 optional + * @param {integer} [opts.diskSize] - 修改后的磁盘 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateFunction (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 updateFunction" + ) + } + + opts = opts || {} + + if (opts.serviceName === undefined || opts.serviceName === null) { + throw new Error( + "Missing the required parameter 'opts.serviceName' when calling updateFunction" + ) + } + if (opts.functionName === undefined || opts.functionName === null) { + throw new Error( + "Missing the required parameter 'opts.functionName' when calling updateFunction" + ) + } + + let postBody = {} + if (opts.code !== undefined && opts.code !== null) { + postBody['code'] = opts.code + } + if (opts.timeout !== undefined && opts.timeout !== null) { + postBody['timeout'] = opts.timeout + } + if (opts.runtime !== undefined && opts.runtime !== null) { + postBody['runtime'] = opts.runtime + } + if (opts.handler !== undefined && opts.handler !== null) { + postBody['handler'] = opts.handler + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.envs !== undefined && opts.envs !== null) { + postBody['envs'] = opts.envs + } + if (opts.cpu !== undefined && opts.cpu !== null) { + postBody['cpu'] = opts.cpu + } + if (opts.memorySize !== undefined && opts.memorySize !== null) { + postBody['memorySize'] = opts.memorySize + } + if (opts.diskSize !== undefined && opts.diskSize !== null) { + postBody['diskSize'] = opts.diskSize + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + serviceName: opts.serviceName, + functionName: opts.functionName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 fc/1.0.2' + } + + 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 updateFunction 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}/services/{serviceName}/functions/{functionName}', + 'PATCH', + 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) + } + ) + } + + /** + * 删除function + [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.serviceName - Service Name + * @param {string} opts.functionName - Function Name + * @param {boolean} [opts.deleteTrigger] - 触发器是否随函数删除 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteFunction (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 deleteFunction" + ) + } + + opts = opts || {} + + if (opts.serviceName === undefined || opts.serviceName === null) { + throw new Error( + "Missing the required parameter 'opts.serviceName' when calling deleteFunction" + ) + } + if (opts.functionName === undefined || opts.functionName === null) { + throw new Error( + "Missing the required parameter 'opts.functionName' when calling deleteFunction" + ) + } + + let postBody = null + let queryParams = {} + if (opts.deleteTrigger !== undefined && opts.deleteTrigger !== null) { + queryParams['deleteTrigger'] = opts.deleteTrigger + } + + let pathParams = { + regionId: regionId, + serviceName: opts.serviceName, + functionName: opts.functionName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 fc/1.0.2' + } + + 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 deleteFunction 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}/services/{serviceName}/functions/{functionName}', + '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) + } + ) + } + + /** + * 查询一个 function 的代码地址 + + * @param {Object} opts - parameters + * @param {string} opts.serviceName - Service Name + * @param {string} opts.functionName - Function Name + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string checkSum 函数部署包的 SHA256 哈希 + * @param string url 代码地址 + */ + + describeFunctionCode (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 describeFunctionCode" + ) + } + + opts = opts || {} + + if (opts.serviceName === undefined || opts.serviceName === null) { + throw new Error( + "Missing the required parameter 'opts.serviceName' when calling describeFunctionCode" + ) + } + if (opts.functionName === undefined || opts.functionName === null) { + throw new Error( + "Missing the required parameter 'opts.functionName' when calling describeFunctionCode" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + serviceName: opts.serviceName, + functionName: opts.functionName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 fc/1.0.2' + } + + 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 describeFunctionCode 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}/services/{serviceName}/functions/{functionName}/code', + '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) + } + ) + } + + /** + * 获取所有的runtime + + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string runtimes + * @param integer totalCount 总数量 + */ + + describeRuntimes (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 describeRuntimes" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 fc/1.0.2' + } + + 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 describeRuntimes 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}/runtimes', + '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) + } + ) + } + + /** + * 触发函数执行 + +可以添加header参数 `x-fc-invocation-type`指定调用方式。 +- Async 异步调用 +- Sync 同步调用(暂不支持) + +异步调用函数时,请求会立即返回 requestId。 <br> + + * @param {Object} opts - parameters + * @param {string} opts.serviceName - Service Name + * @param {string} opts.functionName - Function Name + * @param {string} [opts.body] - 事件信息,以json格式表示,会在函数执行时作为参数传入,默认为{} optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + invokeFunction (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 invokeFunction" + ) + } + + opts = opts || {} + + if (opts.serviceName === undefined || opts.serviceName === null) { + throw new Error( + "Missing the required parameter 'opts.serviceName' when calling invokeFunction" + ) + } + if (opts.functionName === undefined || opts.functionName === null) { + throw new Error( + "Missing the required parameter 'opts.functionName' when calling invokeFunction" + ) + } + + let postBody = {} + if (opts.body !== undefined && opts.body !== null) { + postBody['body'] = opts.body + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + serviceName: opts.serviceName, + functionName: opts.functionName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 fc/1.0.2' + } + + 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 invokeFunction 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}/services/{serviceName}/functions/{functionName}/invocations', + '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) + } + ) + } + + /** + * 批量查询 instanceTypes 的详细信息<br>` +此接口支持分页查询,默认每页20条。 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 100] optional + * @param {filter} [opts.filters] - cpu - vCpu,支持多个 +memorySize: - 内存,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instanceType instanceTypes + * @param number totalCount + */ + + describeInstanceTypes (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 describeInstanceTypes" + ) + } + + 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 fc/1.0.2' + } + + 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 describeInstanceTypes 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}/instanceTypes', + '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) + } + ) + } + + /** + * 批量查询 service 的详细信息<br> +此接口支持分页查询,默认每页20条。 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 100] optional + * @param {filter} [opts.filters] - name - 服务名称,模糊匹配,支持单个 +serviceId - 服务 ID, 精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param service services + * @param number totalCount + */ + + describeServices (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 describeServices" + ) + } + + 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 fc/1.0.2' + } + + 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( + '/regions/{regionId}/services', + '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 {serviceSpec} opts.serviceSpec - 服务 创建参数 + * @param {string} [opts.clientToken] - 保证请求幂等性的字符串;最大长度64个ASCII字符 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string serviceName + */ + + createService (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 createService" + ) + } + + opts = opts || {} + + if (opts.serviceSpec === undefined || opts.serviceSpec === null) { + throw new Error( + "Missing the required parameter 'opts.serviceSpec' when calling createService" + ) + } + + let postBody = {} + if (opts.serviceSpec !== undefined && opts.serviceSpec !== null) { + postBody['serviceSpec'] = opts.serviceSpec + } + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 fc/1.0.2' + } + + 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 createService 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}/services', + '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) + } + ) + } + + /** + * 查询一个 service 的详细信息 + + * @param {Object} opts - parameters + * @param {string} opts.serviceName - Service Name + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param service service + */ + + describeService (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 describeService" + ) + } + + opts = opts || {} + + if (opts.serviceName === undefined || opts.serviceName === null) { + throw new Error( + "Missing the required parameter 'opts.serviceName' when calling describeService" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + serviceName: opts.serviceName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 fc/1.0.2' + } + + 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 describeService 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}/services/{serviceName}', + '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) + } + ) + } + + /** + * 修改 service + + * @param {Object} opts - parameters + * @param {string} opts.serviceName - Service Name + * @param {string} [opts.description] - 修改后的描述 optional + * @param {logConfig} [opts.logConfig] - 修改后的日志配置,不修改的话传空值,关闭日志集logTopicUid传空值。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateService (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 updateService" + ) + } + + opts = opts || {} + + if (opts.serviceName === undefined || opts.serviceName === null) { + throw new Error( + "Missing the required parameter 'opts.serviceName' when calling updateService" + ) + } + + let postBody = {} + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.logConfig !== undefined && opts.logConfig !== null) { + postBody['logConfig'] = opts.logConfig + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + serviceName: opts.serviceName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 fc/1.0.2' + } + + 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 updateService 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}/services/{serviceName}', + 'PATCH', + 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) + } + ) + } + + /** + * 删除service + [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.serviceName - Service Name + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteService (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 deleteService" + ) + } + + opts = opts || {} + + if (opts.serviceName === undefined || opts.serviceName === null) { + throw new Error( + "Missing the required parameter 'opts.serviceName' when calling deleteService" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + serviceName: opts.serviceName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 fc/1.0.2' + } + + 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 deleteService 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}/services/{serviceName}', + '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.serviceName - 服务名称。 + * @param {string} opts.functionName - 函数名称。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param trigger triggers + * @param integer totalCount + */ + + describeTriggers (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 describeTriggers" + ) + } + + opts = opts || {} + + if (opts.serviceName === undefined || opts.serviceName === null) { + throw new Error( + "Missing the required parameter 'opts.serviceName' when calling describeTriggers" + ) + } + if (opts.functionName === undefined || opts.functionName === null) { + throw new Error( + "Missing the required parameter 'opts.functionName' when calling describeTriggers" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + serviceName: opts.serviceName, + functionName: opts.functionName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 fc/1.0.2' + } + + 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 describeTriggers 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}/services/{serviceName}/functions/{functionName}/triggers', + '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) + } + ) + } + + /** + * 创建触发器。 +目前支持的触发器类型有: +- oss + +## 注意事项 +- 一个函数下最多同时存在10个触发器。 +- oss类型触发器会在对应的bucket中添加一个事件通知,若该bucket中已存在相同事件类型的事件通知,触发器可能无法生效。 +- 创建多个相同类型的oss触发器,当对应的事件发生时,只有一个触发器会被调用。 +- 若人为修改或删除了bucket中的事件通知,可能导致oss触发器失效。 + + * @param {Object} opts - parameters + * @param {string} opts.serviceName - 服务名称。 + * @param {string} opts.functionName - 函数名称。 + * @param {triggerSpec} opts.triggerSpec - 触发器创建参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string triggerName + */ + + createTrigger (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 createTrigger" + ) + } + + opts = opts || {} + + if (opts.serviceName === undefined || opts.serviceName === null) { + throw new Error( + "Missing the required parameter 'opts.serviceName' when calling createTrigger" + ) + } + if (opts.functionName === undefined || opts.functionName === null) { + throw new Error( + "Missing the required parameter 'opts.functionName' when calling createTrigger" + ) + } + if (opts.triggerSpec === undefined || opts.triggerSpec === null) { + throw new Error( + "Missing the required parameter 'opts.triggerSpec' when calling createTrigger" + ) + } + + let postBody = {} + if (opts.triggerSpec !== undefined && opts.triggerSpec !== null) { + postBody['triggerSpec'] = opts.triggerSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + serviceName: opts.serviceName, + functionName: opts.functionName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 fc/1.0.2' + } + + 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 createTrigger 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}/services/{serviceName}/functions/{functionName}/triggers', + '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.serviceName - 服务名称。 + * @param {string} opts.functionName - 函数名称。 + * @param {string} opts.triggerName - 触发器名称。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param trigger trigger + */ + + describeTrigger (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 describeTrigger" + ) + } + + opts = opts || {} + + if (opts.serviceName === undefined || opts.serviceName === null) { + throw new Error( + "Missing the required parameter 'opts.serviceName' when calling describeTrigger" + ) + } + if (opts.functionName === undefined || opts.functionName === null) { + throw new Error( + "Missing the required parameter 'opts.functionName' when calling describeTrigger" + ) + } + if (opts.triggerName === undefined || opts.triggerName === null) { + throw new Error( + "Missing the required parameter 'opts.triggerName' when calling describeTrigger" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + serviceName: opts.serviceName, + functionName: opts.functionName, + triggerName: opts.triggerName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 fc/1.0.2' + } + + 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 describeTrigger 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}/services/{serviceName}/functions/{functionName}/triggers/{triggerName}', + '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.serviceName - 服务名称。 + * @param {string} opts.functionName - 函数名称。 + * @param {string} opts.triggerName - 触发器名称。 + * @param {string} [opts.description] - 修改后的描述 optional + * @param {string} [opts.triggerConfig] - 修改后的配置 optional + * @param {boolean} [opts.enable] - 是否启用或禁用触发器,默认为不更改触发器状态 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateTrigger (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 updateTrigger" + ) + } + + opts = opts || {} + + if (opts.serviceName === undefined || opts.serviceName === null) { + throw new Error( + "Missing the required parameter 'opts.serviceName' when calling updateTrigger" + ) + } + if (opts.functionName === undefined || opts.functionName === null) { + throw new Error( + "Missing the required parameter 'opts.functionName' when calling updateTrigger" + ) + } + if (opts.triggerName === undefined || opts.triggerName === null) { + throw new Error( + "Missing the required parameter 'opts.triggerName' when calling updateTrigger" + ) + } + + let postBody = {} + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.triggerConfig !== undefined && opts.triggerConfig !== null) { + postBody['triggerConfig'] = opts.triggerConfig + } + if (opts.enable !== undefined && opts.enable !== null) { + postBody['enable'] = opts.enable + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + serviceName: opts.serviceName, + functionName: opts.functionName, + triggerName: opts.triggerName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 fc/1.0.2' + } + + 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 updateTrigger 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}/services/{serviceName}/functions/{functionName}/triggers/{triggerName}', + 'PATCH', + 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) + } + ) + } + + /** + * 删除触发器。 + [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.serviceName - 服务名称。 + * @param {string} opts.functionName - 函数名称。 + * @param {string} opts.triggerName - 触发器名称。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteTrigger (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 deleteTrigger" + ) + } + + opts = opts || {} + + if (opts.serviceName === undefined || opts.serviceName === null) { + throw new Error( + "Missing the required parameter 'opts.serviceName' when calling deleteTrigger" + ) + } + if (opts.functionName === undefined || opts.functionName === null) { + throw new Error( + "Missing the required parameter 'opts.functionName' when calling deleteTrigger" + ) + } + if (opts.triggerName === undefined || opts.triggerName === null) { + throw new Error( + "Missing the required parameter 'opts.triggerName' when calling deleteTrigger" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + serviceName: opts.serviceName, + functionName: opts.functionName, + triggerName: opts.triggerName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 fc/1.0.2' + } + + 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 deleteTrigger 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}/services/{serviceName}/functions/{functionName}/triggers/{triggerName}', + '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) + } + ) + } +} +module.exports = FC diff --git a/packages/libs/lib-jdcloud/src/repo/flowlog/v1/flowlog.js b/packages/libs/lib-jdcloud/src/repo/flowlog/v1/flowlog.js new file mode 100644 index 000000000..1bc67b622 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/flowlog/v1/flowlog.js @@ -0,0 +1,1387 @@ +/* + * 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. + * + * Quota + * 配额的相关接口 + * + * 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 = 'flowlog' +Service._services[serviceId] = true + +/** + * flowlog service. + * @version 1.1.0 + */ + +class FLOWLOG extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'flowlog.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 本接口用于查询流日志资源列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞), 页码超过总页数时, 显示最后一页 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {filter} [opts.filters] - flowLogStatus - 流日志状态,支持单个 + flowLogType - 流日志类型,支持单个 + flowLogIds - 流日志ID,支持多个 + flowLogNames - 流日志名称,模糊查询支持单个,精确查询支持多个 + storageId - 流日志的存储服务ID,支持单个 + collectResourceIds - 流日志的采集资源ID列表,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param flowLog flowLogs + * @param number totalCount 总数量 + */ + + describeFlowLogs (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 describeFlowLogs" + ) + } + + 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 flowlog/1.1.0' + } + + 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 describeFlowLogs 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}/flowLogs', + '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.flowLogName - 流日志名称,只允许输入中文、数字、大小写字母、英文下划线“_”及中划线“-”,不允许为空且不超过32字符 + * @param {string} [opts.description] - 描述,允许输入UTF-8编码下的全部字符,不超过256字符 optional + * @param {string} opts.flowLogType - 流日志类型 +PORT:采集资源可为云主机、弹性网卡 + + * @param {array} [opts.collectResources] - 采集资源列表 optional + * @param {string} [opts.collectTrafficType] - 采集流量类型 +ALL:记录指定资源的全部流量 +ACCEPT:记录指定资源被安全组、网络ACL均接受的流量 +REJECT:记录指定资源被安全组或网络ACL拒绝的流量 + optional + * @param {integer} [opts.collectInterval] - 流日志采集时间间隔。单位:分钟。取值:1、5、10 optional + * @param {string} [opts.storageType] - 流日志的存储服务类型,支持存储到日志服务,日志服务取值:LOG optional + * @param {string} opts.storageRegionId - 流日志的存储服务所在地域,如日志服务所属地域,如cn-north-1 + * @param {string} opts.storageId - 流日志的存储服务ID +若storageType = LOG时,值取日志主题ID,如logtopic-xxxx +当flowLogType = PORT时,值需取 templateUID = eniflowlogs 的日志主题ID + + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string flowLogId 流日志ID + */ + + createFlowLog (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 createFlowLog" + ) + } + + opts = opts || {} + + if (opts.flowLogName === undefined || opts.flowLogName === null) { + throw new Error( + "Missing the required parameter 'opts.flowLogName' when calling createFlowLog" + ) + } + if (opts.flowLogType === undefined || opts.flowLogType === null) { + throw new Error( + "Missing the required parameter 'opts.flowLogType' when calling createFlowLog" + ) + } + if (opts.storageRegionId === undefined || opts.storageRegionId === null) { + throw new Error( + "Missing the required parameter 'opts.storageRegionId' when calling createFlowLog" + ) + } + if (opts.storageId === undefined || opts.storageId === null) { + throw new Error( + "Missing the required parameter 'opts.storageId' when calling createFlowLog" + ) + } + + let postBody = {} + if (opts.flowLogName !== undefined && opts.flowLogName !== null) { + postBody['flowLogName'] = opts.flowLogName + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.flowLogType !== undefined && opts.flowLogType !== null) { + postBody['flowLogType'] = opts.flowLogType + } + if (opts.collectResources !== undefined && opts.collectResources !== null) { + postBody['collectResources'] = opts.collectResources + } + if ( + opts.collectTrafficType !== undefined && + opts.collectTrafficType !== null + ) { + postBody['collectTrafficType'] = opts.collectTrafficType + } + if (opts.collectInterval !== undefined && opts.collectInterval !== null) { + postBody['collectInterval'] = opts.collectInterval + } + if (opts.storageType !== undefined && opts.storageType !== null) { + postBody['storageType'] = opts.storageType + } + if (opts.storageRegionId !== undefined && opts.storageRegionId !== null) { + postBody['storageRegionId'] = opts.storageRegionId + } + if (opts.storageId !== undefined && opts.storageId !== null) { + postBody['storageId'] = opts.storageId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 flowlog/1.1.0' + } + + 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 createFlowLog 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}/flowLogs', + '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.flowLogId - 流日志ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param flowLog flowLog 流日志信息 + */ + + describeFlowLog (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 describeFlowLog" + ) + } + + opts = opts || {} + + if (opts.flowLogId === undefined || opts.flowLogId === null) { + throw new Error( + "Missing the required parameter 'opts.flowLogId' when calling describeFlowLog" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + flowLogId: opts.flowLogId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 flowlog/1.1.0' + } + + 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 describeFlowLog 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}/flowLogs/{flowLogId}', + '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.flowLogId - 流日志ID + * @param {string} [opts.flowLogName] - 流日志名称,只允许输入中文、数字、大小写字母、英文下划线“_”及中划线“-”,不允许为空且不超过32字符 optional + * @param {string} [opts.description] - 描述,允许输入UTF-8编码下的全部字符,不超过256字符 optional + * @param {integer} [opts.collectInterval] - 流日志采集时间间隔。单位:分钟。取值:1、5、10 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyFlowLog (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 modifyFlowLog" + ) + } + + opts = opts || {} + + if (opts.flowLogId === undefined || opts.flowLogId === null) { + throw new Error( + "Missing the required parameter 'opts.flowLogId' when calling modifyFlowLog" + ) + } + + let postBody = {} + if (opts.flowLogName !== undefined && opts.flowLogName !== null) { + postBody['flowLogName'] = opts.flowLogName + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.collectInterval !== undefined && opts.collectInterval !== null) { + postBody['collectInterval'] = opts.collectInterval + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + flowLogId: opts.flowLogId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 flowlog/1.1.0' + } + + 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 modifyFlowLog 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}/flowLogs/{flowLogId}', + 'PATCH', + 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) + } + ) + } + + /** + * 本接口用于删除流日志,删除前请先停止流日志(stopFlowlog) + * @param {Object} opts - parameters + * @param {string} opts.flowLogId - 流日志ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteFlowLog (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 deleteFlowLog" + ) + } + + opts = opts || {} + + if (opts.flowLogId === undefined || opts.flowLogId === null) { + throw new Error( + "Missing the required parameter 'opts.flowLogId' when calling deleteFlowLog" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + flowLogId: opts.flowLogId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 flowlog/1.1.0' + } + + 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 deleteFlowLog 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}/flowLogs/{flowLogId}', + '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.flowLogId - 流日志ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + startFlowLog (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 startFlowLog" + ) + } + + opts = opts || {} + + if (opts.flowLogId === undefined || opts.flowLogId === null) { + throw new Error( + "Missing the required parameter 'opts.flowLogId' when calling startFlowLog" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + flowLogId: opts.flowLogId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 flowlog/1.1.0' + } + + 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 startFlowLog 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}/flowLogs/{flowLogId}:startFlowLog', + '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.flowLogId - 流日志ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + stopFlowLog (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 stopFlowLog" + ) + } + + opts = opts || {} + + if (opts.flowLogId === undefined || opts.flowLogId === null) { + throw new Error( + "Missing the required parameter 'opts.flowLogId' when calling stopFlowLog" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + flowLogId: opts.flowLogId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 flowlog/1.1.0' + } + + 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 stopFlowLog 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}/flowLogs/{flowLogId}:stopFlowLog', + '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.flowLogId - 流日志ID + * @param {array} [opts.collectResources] - 采集资源列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + addCollectResources (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 addCollectResources" + ) + } + + opts = opts || {} + + if (opts.flowLogId === undefined || opts.flowLogId === null) { + throw new Error( + "Missing the required parameter 'opts.flowLogId' when calling addCollectResources" + ) + } + + let postBody = {} + if (opts.collectResources !== undefined && opts.collectResources !== null) { + postBody['collectResources'] = opts.collectResources + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + flowLogId: opts.flowLogId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 flowlog/1.1.0' + } + + 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 addCollectResources 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}/flowLogs/{flowLogId}:addCollectResources', + '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.flowLogId - 流日志ID + * @param {array} [opts.collectResourceIds] - 采集资源ID列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + removeCollectResources (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 removeCollectResources" + ) + } + + opts = opts || {} + + if (opts.flowLogId === undefined || opts.flowLogId === null) { + throw new Error( + "Missing the required parameter 'opts.flowLogId' when calling removeCollectResources" + ) + } + + let postBody = {} + if ( + opts.collectResourceIds !== undefined && + opts.collectResourceIds !== null + ) { + postBody['collectResourceIds'] = opts.collectResourceIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + flowLogId: opts.flowLogId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 flowlog/1.1.0' + } + + 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 removeCollectResources 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}/flowLogs/{flowLogId}:removeCollectResources', + '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.flowLogId - 流日志ID + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞), 页码超过总页数时, 显示最后一页 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {array} [opts.filters] - collectResourceType:采集的资源类型,支持单个 +collectResourceIds: 流日志采集的资源ID,支持多个 +vpcId:采集资源所属私有网络(VPC)的ID,支持单个 +subnetId:采集资源所属子网的ID,支持单个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param collectResource collectResources + * @param number totalCount 总数量 + */ + + describeCollectResources (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 describeCollectResources" + ) + } + + opts = opts || {} + + if (opts.flowLogId === undefined || opts.flowLogId === null) { + throw new Error( + "Missing the required parameter 'opts.flowLogId' when calling describeCollectResources" + ) + } + + let postBody = {} + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + if (opts.filters !== undefined && opts.filters !== null) { + postBody['filters'] = opts.filters + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + flowLogId: opts.flowLogId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 flowlog/1.1.0' + } + + 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 describeCollectResources 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}/flowLogs/{flowLogId}:describeCollectResources', + '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.type - 资源类型,取值范围:flowLog、flowLogResource + * @param {string} [opts.parentResourceId] - type为flowLog不设置, +flowLogResource设置为flowLogId + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param quota quota + */ + + describeQuota (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 describeQuota" + ) + } + + opts = opts || {} + + if (opts.type === undefined || opts.type === null) { + throw new Error( + "Missing the required parameter 'opts.type' when calling describeQuota" + ) + } + + let postBody = null + let queryParams = {} + if (opts.type !== undefined && opts.type !== null) { + queryParams['type'] = opts.type + } + if (opts.parentResourceId !== undefined && opts.parentResourceId !== null) { + queryParams['parentResourceId'] = opts.parentResourceId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 flowlog/1.1.0' + } + + 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 describeQuota 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}/quotas/', + '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 = FLOWLOG diff --git a/packages/libs/lib-jdcloud/src/repo/function/v1/function.js b/packages/libs/lib-jdcloud/src/repo/function/v1/function.js new file mode 100644 index 000000000..8749eaedd --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/function/v1/function.js @@ -0,0 +1,2165 @@ +/* + * 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. + * + * Function OpenAPI + * + * + * 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 = 'function' +Service._services[serviceId] = true + +/** + * function service. + * @version 1.0.3 + */ + +JDCloud.FUNCTION = class FUNCTION extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'function.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询别名列表 + * @param {Object} opts - parameters + * @param {string} opts.functionName - 别名所属函数名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param alias data + */ + + listAlias (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 listAlias" + ) + } + + opts = opts || {} + + if (opts.functionName === undefined || opts.functionName === null) { + throw new Error( + "Missing the required parameter 'opts.functionName' when calling listAlias" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + functionName: opts.functionName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 function/1.0.3' + } + + 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 listAlias 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 = this.makeRequest( + '/regions/{regionId}/functions/{functionName}/aliases', + '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.functionName - 别名所属函数名称 + * @param {string} opts.aliasName - 别名名称 + * @param {string} [opts.description] - 别名描述信息 optional + * @param {string} [opts.version] - 别名对应的版本名称 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param alias data + */ + + createAlias (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 createAlias" + ) + } + + opts = opts || {} + + if (opts.functionName === undefined || opts.functionName === null) { + throw new Error( + "Missing the required parameter 'opts.functionName' when calling createAlias" + ) + } + if (opts.aliasName === undefined || opts.aliasName === null) { + throw new Error( + "Missing the required parameter 'opts.aliasName' when calling createAlias" + ) + } + + let postBody = {} + if (opts.aliasName !== undefined && opts.aliasName !== null) { + postBody['aliasName'] = opts.aliasName + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.version !== undefined && opts.version !== null) { + postBody['version'] = opts.version + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + functionName: opts.functionName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 function/1.0.3' + } + + 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 createAlias 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 = this.makeRequest( + '/regions/{regionId}/functions/{functionName}/aliases', + '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.functionName - 别名所属函数名称 + * @param {string} opts.aliasName - 别名名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param alias data + */ + + getAlias (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 getAlias" + ) + } + + opts = opts || {} + + if (opts.functionName === undefined || opts.functionName === null) { + throw new Error( + "Missing the required parameter 'opts.functionName' when calling getAlias" + ) + } + if (opts.aliasName === undefined || opts.aliasName === null) { + throw new Error( + "Missing the required parameter 'opts.aliasName' when calling getAlias" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + functionName: opts.functionName, + aliasName: opts.aliasName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 function/1.0.3' + } + + 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 getAlias 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 = this.makeRequest( + '/regions/{regionId}/functions/{functionName}/aliases/{aliasName}', + '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.functionName - 别名所属函数名称 + * @param {string} opts.aliasName - 别名名称 + * @param {string} opts.description - 别名描述信息 + * @param {string} opts.version - 别名对应版本 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param alias data + */ + + updateAlias (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 updateAlias" + ) + } + + opts = opts || {} + + if (opts.functionName === undefined || opts.functionName === null) { + throw new Error( + "Missing the required parameter 'opts.functionName' when calling updateAlias" + ) + } + if (opts.aliasName === undefined || opts.aliasName === null) { + throw new Error( + "Missing the required parameter 'opts.aliasName' when calling updateAlias" + ) + } + if (opts.description === undefined || opts.description === null) { + throw new Error( + "Missing the required parameter 'opts.description' when calling updateAlias" + ) + } + if (opts.version === undefined || opts.version === null) { + throw new Error( + "Missing the required parameter 'opts.version' when calling updateAlias" + ) + } + + let postBody = {} + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.version !== undefined && opts.version !== null) { + postBody['version'] = opts.version + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + functionName: opts.functionName, + aliasName: opts.aliasName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 function/1.0.3' + } + + 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 updateAlias 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 = this.makeRequest( + '/regions/{regionId}/functions/{functionName}/aliases/{aliasName}', + '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) + } + ) + } + + /** + * 删除别名 + * @param {Object} opts - parameters + * @param {string} opts.functionName - 别名所属函数名称 + * @param {string} opts.aliasName - 别名名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteAlias (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 deleteAlias" + ) + } + + opts = opts || {} + + if (opts.functionName === undefined || opts.functionName === null) { + throw new Error( + "Missing the required parameter 'opts.functionName' when calling deleteAlias" + ) + } + if (opts.aliasName === undefined || opts.aliasName === null) { + throw new Error( + "Missing the required parameter 'opts.aliasName' when calling deleteAlias" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + functionName: opts.functionName, + aliasName: opts.aliasName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 function/1.0.3' + } + + 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 deleteAlias 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 = this.makeRequest( + '/regions/{regionId}/functions/{functionName}/aliases/{aliasName}', + '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 {boolean} opts.listAll - 是否返回所有函数 + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 分页大小 optional + * @param {filter} [opts.filters] - functionId -函数ID,精确匹配,支持多个 +functionName - 函数名称,模糊匹配,支持单个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param listFunctionResult data + */ + + listFunction (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 listFunction" + ) + } + + opts = opts || {} + + if (opts.listAll === undefined || opts.listAll === null) { + throw new Error( + "Missing the required parameter 'opts.listAll' when calling listFunction" + ) + } + + let postBody = null + let queryParams = {} + if (opts.listAll !== undefined && opts.listAll !== null) { + queryParams['listAll'] = opts.listAll + } + 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, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 function/1.0.3' + } + + 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 listFunction 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 = this.makeRequest( + '/regions/{regionId}/functions', + '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.name] - 函数名称 optional + * @param {string} [opts.description] - 函数描述信息 optional + * @param {string} [opts.entrance] - 函数入口,格式为入口文件.入口函数名 optional + * @param {integer} [opts.memory] - 函数运行最大内存 optional + * @param {string} [opts.runTime] - 函数运行环境 optional + * @param {integer} [opts.overTime] - 函数运行超时时间 optional + * @param {string} [opts.version] - 函数版本,默认为LATEST optional + * @param {code} [opts.code] - 函数代码包 optional + * @param {env} [opts.environment] - 函数运行时环境变量 optional + * @param {string} [opts.logSetId] - 函数指定的日志集Id optional + * @param {string} [opts.logTopicId] - 函数指定的日志主题Id optional + * @param {string} [opts.vpcId] - 函数配置的VPCId optional + * @param {string} [opts.subnetId] - 函数配置的子网Id optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param function data + */ + + createFunction (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 createFunction" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.entrance !== undefined && opts.entrance !== null) { + postBody['entrance'] = opts.entrance + } + if (opts.memory !== undefined && opts.memory !== null) { + postBody['memory'] = opts.memory + } + if (opts.runTime !== undefined && opts.runTime !== null) { + postBody['runTime'] = opts.runTime + } + if (opts.overTime !== undefined && opts.overTime !== null) { + postBody['overTime'] = opts.overTime + } + if (opts.version !== undefined && opts.version !== null) { + postBody['version'] = opts.version + } + if (opts.code !== undefined && opts.code !== null) { + postBody['code'] = opts.code + } + if (opts.environment !== undefined && opts.environment !== null) { + postBody['environment'] = opts.environment + } + if (opts.logSetId !== undefined && opts.logSetId !== null) { + postBody['logSetId'] = opts.logSetId + } + if (opts.logTopicId !== undefined && opts.logTopicId !== null) { + postBody['logTopicId'] = opts.logTopicId + } + if (opts.vpcId !== undefined && opts.vpcId !== null) { + postBody['vpcId'] = opts.vpcId + } + if (opts.subnetId !== undefined && opts.subnetId !== null) { + postBody['subnetId'] = opts.subnetId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 function/1.0.3' + } + + 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 createFunction 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 = this.makeRequest( + '/regions/{regionId}/functions', + '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.functionName - 函数名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param function data + */ + + getFunction (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 getFunction" + ) + } + + opts = opts || {} + + if (opts.functionName === undefined || opts.functionName === null) { + throw new Error( + "Missing the required parameter 'opts.functionName' when calling getFunction" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + functionName: opts.functionName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 function/1.0.3' + } + + 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 getFunction 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 = this.makeRequest( + '/regions/{regionId}/functions/{functionName}', + '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.functionName - 函数名称 + * @param {string} [opts.description] - 函数描述信息 optional + * @param {string} [opts.entrance] - 函数入口,格式为入口文件.入口函数名 optional + * @param {integer} [opts.memory] - 函数运行最大内存 optional + * @param {string} [opts.runTime] - 函数运行环境 optional + * @param {integer} [opts.overTime] - 函数运行超时时间 optional + * @param {string} [opts.version] - 函数版本 optional + * @param {code} [opts.code] - 函数代码包 optional + * @param {env} [opts.environment] - 函数运行时环境变量 optional + * @param {string} [opts.logSetId] - 函数指定的日志集Id optional + * @param {string} [opts.logTopicId] - 函数指定的日志主题Id optional + * @param {string} [opts.vpcId] - 函数配置的VPCId optional + * @param {string} [opts.subnetId] - 函数配置的子网Id optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param function data + */ + + updateFunction (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 updateFunction" + ) + } + + opts = opts || {} + + if (opts.functionName === undefined || opts.functionName === null) { + throw new Error( + "Missing the required parameter 'opts.functionName' when calling updateFunction" + ) + } + + let postBody = {} + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.entrance !== undefined && opts.entrance !== null) { + postBody['entrance'] = opts.entrance + } + if (opts.memory !== undefined && opts.memory !== null) { + postBody['memory'] = opts.memory + } + if (opts.runTime !== undefined && opts.runTime !== null) { + postBody['runTime'] = opts.runTime + } + if (opts.overTime !== undefined && opts.overTime !== null) { + postBody['overTime'] = opts.overTime + } + if (opts.version !== undefined && opts.version !== null) { + postBody['version'] = opts.version + } + if (opts.code !== undefined && opts.code !== null) { + postBody['code'] = opts.code + } + if (opts.environment !== undefined && opts.environment !== null) { + postBody['environment'] = opts.environment + } + if (opts.logSetId !== undefined && opts.logSetId !== null) { + postBody['logSetId'] = opts.logSetId + } + if (opts.logTopicId !== undefined && opts.logTopicId !== null) { + postBody['logTopicId'] = opts.logTopicId + } + if (opts.vpcId !== undefined && opts.vpcId !== null) { + postBody['vpcId'] = opts.vpcId + } + if (opts.subnetId !== undefined && opts.subnetId !== null) { + postBody['subnetId'] = opts.subnetId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + functionName: opts.functionName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 function/1.0.3' + } + + 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 updateFunction 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 = this.makeRequest( + '/regions/{regionId}/functions/{functionName}', + '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) + } + ) + } + + /** + * 删除函数 + * @param {Object} opts - parameters + * @param {string} opts.functionName - 函数名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteFunction (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 deleteFunction" + ) + } + + opts = opts || {} + + if (opts.functionName === undefined || opts.functionName === null) { + throw new Error( + "Missing the required parameter 'opts.functionName' when calling deleteFunction" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + functionName: opts.functionName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 function/1.0.3' + } + + 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 deleteFunction 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 = this.makeRequest( + '/regions/{regionId}/functions/{functionName}', + '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.functionName - 函数名称 + * @param {string} opts.versionName - 版本名称 + * @param {string} opts.event - 执行函数的输入事件 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param functionInvokeResult data + */ + + invoke (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 invoke" + ) + } + + opts = opts || {} + + if (opts.functionName === undefined || opts.functionName === null) { + throw new Error( + "Missing the required parameter 'opts.functionName' when calling invoke" + ) + } + if (opts.versionName === undefined || opts.versionName === null) { + throw new Error( + "Missing the required parameter 'opts.versionName' when calling invoke" + ) + } + if (opts.event === undefined || opts.event === null) { + throw new Error( + "Missing the required parameter 'opts.event' when calling invoke" + ) + } + + let postBody = {} + if (opts.event !== undefined && opts.event !== null) { + postBody['event'] = opts.event + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + functionName: opts.functionName, + versionName: opts.versionName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 function/1.0.3' + } + + 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 invoke 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 = this.makeRequest( + '/regions/{regionId}/functions/{functionName}/versions/{versionName}:invoke', + '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.functionName - 函数名称 + * @param {string} opts.versionName - 版本名称 + * @param {string} opts.event - 异步执行函数的输入事件 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + asyncInvoke (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 asyncInvoke" + ) + } + + opts = opts || {} + + if (opts.functionName === undefined || opts.functionName === null) { + throw new Error( + "Missing the required parameter 'opts.functionName' when calling asyncInvoke" + ) + } + if (opts.versionName === undefined || opts.versionName === null) { + throw new Error( + "Missing the required parameter 'opts.versionName' when calling asyncInvoke" + ) + } + if (opts.event === undefined || opts.event === null) { + throw new Error( + "Missing the required parameter 'opts.event' when calling asyncInvoke" + ) + } + + let postBody = {} + if (opts.event !== undefined && opts.event !== null) { + postBody['event'] = opts.event + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + functionName: opts.functionName, + versionName: opts.versionName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 function/1.0.3' + } + + 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 asyncInvoke 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 = this.makeRequest( + '/regions/{regionId}/functions/{functionName}/versions/{versionName}:asyncinvoke', + '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.functionName - 函数名称 + * @param {string} opts.versionName - 版本名称 + * @param {string} opts.triggerId - 触发器Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param trigger data + */ + + getTrigger (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 getTrigger" + ) + } + + opts = opts || {} + + if (opts.functionName === undefined || opts.functionName === null) { + throw new Error( + "Missing the required parameter 'opts.functionName' when calling getTrigger" + ) + } + if (opts.versionName === undefined || opts.versionName === null) { + throw new Error( + "Missing the required parameter 'opts.versionName' when calling getTrigger" + ) + } + if (opts.triggerId === undefined || opts.triggerId === null) { + throw new Error( + "Missing the required parameter 'opts.triggerId' when calling getTrigger" + ) + } + + let postBody = null + let queryParams = {} + if (opts.triggerId !== undefined && opts.triggerId !== null) { + queryParams['triggerId'] = opts.triggerId + } + + let pathParams = { + regionId: regionId, + functionName: opts.functionName, + versionName: opts.versionName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 function/1.0.3' + } + + 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 getTrigger 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 = this.makeRequest( + '/regions/{regionId}/functions/{functionName}/versions/{versionName}:gettrigger', + '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.functionName - 函数名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param functionSpec data + */ + + listVersion (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 listVersion" + ) + } + + opts = opts || {} + + if (opts.functionName === undefined || opts.functionName === null) { + throw new Error( + "Missing the required parameter 'opts.functionName' when calling listVersion" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + functionName: opts.functionName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 function/1.0.3' + } + + 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 listVersion 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 = this.makeRequest( + '/regions/{regionId}/functions/{functionName}/versions', + '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.functionName - 函数名称 + * @param {string} [opts.description] - 版本描述 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param function data + */ + + createVersion (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 createVersion" + ) + } + + opts = opts || {} + + if (opts.functionName === undefined || opts.functionName === null) { + throw new Error( + "Missing the required parameter 'opts.functionName' when calling createVersion" + ) + } + + let postBody = {} + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + functionName: opts.functionName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 function/1.0.3' + } + + 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 createVersion 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 = this.makeRequest( + '/regions/{regionId}/functions/{functionName}/versions', + '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.functionName - 函数名称 + * @param {string} opts.versionName - 版本名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param function data + */ + + getVersion (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 getVersion" + ) + } + + opts = opts || {} + + if (opts.functionName === undefined || opts.functionName === null) { + throw new Error( + "Missing the required parameter 'opts.functionName' when calling getVersion" + ) + } + if (opts.versionName === undefined || opts.versionName === null) { + throw new Error( + "Missing the required parameter 'opts.versionName' when calling getVersion" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + functionName: opts.functionName, + versionName: opts.versionName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 function/1.0.3' + } + + 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 getVersion 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 = this.makeRequest( + '/regions/{regionId}/functions/{functionName}/versions/{versionName}', + '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.functionName - 函数名称 + * @param {string} opts.versionName - 版本名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteVersion (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 deleteVersion" + ) + } + + opts = opts || {} + + if (opts.functionName === undefined || opts.functionName === null) { + throw new Error( + "Missing the required parameter 'opts.functionName' when calling deleteVersion" + ) + } + if (opts.versionName === undefined || opts.versionName === null) { + throw new Error( + "Missing the required parameter 'opts.versionName' when calling deleteVersion" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + functionName: opts.functionName, + versionName: opts.versionName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 function/1.0.3' + } + + 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 deleteVersion 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 = this.makeRequest( + '/regions/{regionId}/functions/{functionName}/versions/{versionName}', + '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) + } + ) + } +} +module.exports = JDCloud.FUNCTION diff --git a/packages/libs/lib-jdcloud/src/repo/gcs/v1/gcs.js b/packages/libs/lib-jdcloud/src/repo/gcs/v1/gcs.js new file mode 100644 index 000000000..3aaaf6e07 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/gcs/v1/gcs.js @@ -0,0 +1,2312 @@ +/* + * 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 diff --git a/packages/libs/lib-jdcloud/src/repo/httpdns/v1/httpdns.js b/packages/libs/lib-jdcloud/src/repo/httpdns/v1/httpdns.js new file mode 100644 index 000000000..1d8d915ee --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/httpdns/v1/httpdns.js @@ -0,0 +1,822 @@ +/* + * 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. + * + * 域名 + * httpdns OpenAPI域名接口 + * + * 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 = 'httpdns' +Service._services[serviceId] = true + +/** + * httpdns service. + * @version 1.0.0 + */ + +JDCloud.HTTPDNS = class HTTPDNS extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'httpdns.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询用户名下httpdns的账户ID + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param accountId data 查询得到的账户ID结构 + */ + + getAccountId (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 getAccountId" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 httpdns/1.0.0' + } + + 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 getAccountId 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 = this.makeRequest( + '/regions/{regionId}/account', + '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) + } + ) + } + + /** + * 创建httpdns账户 + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param account data 开户成功后得到的账户结构 + */ + + createAccount (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 createAccount" + ) + } + + opts = opts || {} + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 httpdns/1.0.0' + } + + 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 createAccount 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 = this.makeRequest( + '/regions/{regionId}/account/createAccount', + '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) + } + ) + } + + /** + * 查询httpdns账户的基本信息 + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param account data 查询得到的账户结构 + */ + + getAccountInfo (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 getAccountInfo" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 httpdns/1.0.0' + } + + 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 getAccountInfo 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 = this.makeRequest( + '/regions/{regionId}/accountInfo', + '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) + } + ) + } + + /** + * 创建,启用,禁用httpdns服务密钥 + * @param {Object} opts - parameters + * @param {} [opts.action] - 操作类型, create创建, enable启用, disable禁用 optional + * @param {} [opts.key] - 操作的密钥 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + operateKey (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 operateKey" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.action !== undefined && opts.action !== null) { + postBody['action'] = opts.action + } + if (opts.key !== undefined && opts.key !== null) { + postBody['key'] = opts.key + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 httpdns/1.0.0' + } + + 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 operateKey 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 = this.makeRequest( + '/regions/{regionId}/account/operateKey', + '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) + } + ) + } + + /** + * 查询使用httpdns服务的域名 + * @param {Object} opts - parameters + * @param {integer} opts.pageIndex - 当前页数,起始值为1 + * @param {integer} opts.pageSize - 分页查询时设置的每页行数 + * @param {string} [opts.domainName] - 关键字,按照”%domainName%”模式搜索域名 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param domainData data 分页查询返回的域名数据结构 + */ + + getDomains (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 getDomains" + ) + } + + opts = opts || {} + + if (opts.pageIndex === undefined || opts.pageIndex === null) { + throw new Error( + "Missing the required parameter 'opts.pageIndex' when calling getDomains" + ) + } + if (opts.pageSize === undefined || opts.pageSize === null) { + throw new Error( + "Missing the required parameter 'opts.pageSize' when calling getDomains" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 httpdns/1.0.0' + } + + 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 getDomains 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 = this.makeRequest( + '/regions/{regionId}/domain', + '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> +可以添加顶级域名除外的多级域名。 + + * @param {Object} opts - parameters + * @param {array} opts.domainNames - 需要添加的域名数组 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + addDomains (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 addDomains" + ) + } + + opts = opts || {} + + if (opts.domainNames === undefined || opts.domainNames === null) { + throw new Error( + "Missing the required parameter 'opts.domainNames' when calling addDomains" + ) + } + + let postBody = {} + if (opts.domainNames !== undefined && opts.domainNames !== null) { + postBody['domainNames'] = opts.domainNames + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 httpdns/1.0.0' + } + + 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 addDomains 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 = this.makeRequest( + '/regions/{regionId}/domain/addDomain', + '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 {array} opts.domainNames - 需要删除的域名数组 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + delDomains (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 delDomains" + ) + } + + opts = opts || {} + + if (opts.domainNames === undefined || opts.domainNames === null) { + throw new Error( + "Missing the required parameter 'opts.domainNames' when calling delDomains" + ) + } + + let postBody = {} + if (opts.domainNames !== undefined && opts.domainNames !== null) { + postBody['domainNames'] = opts.domainNames + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 httpdns/1.0.0' + } + + 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 delDomains 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 = this.makeRequest( + '/regions/{regionId}/domain/delDomain', + '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 = JDCloud.HTTPDNS diff --git a/packages/libs/lib-jdcloud/src/repo/hufu/v1/hufu.js b/packages/libs/lib-jdcloud/src/repo/hufu/v1/hufu.js new file mode 100644 index 000000000..2a5034ab8 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/hufu/v1/hufu.js @@ -0,0 +1,628 @@ +/* + * 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. + * + * hufu-wx + * 虎符商业化相关接口 + * + * 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 = 'hufu' +Service._services[serviceId] = true + +/** + * hufu service. + * @version 1.0.7 + */ + +class HUFU extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'hufu.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 发布版本 + * @param {Object} opts - parameters + * @param {integer} opts.sceneId - 场景ID + * @param {string} opts.revision - 发布的修订版本号 + * @param {string} opts.environment - 环境:test、preview、online + * @param {string} [opts.backendServiceType] - 后端服务类型:mock、unique、vpc optional + * @param {string} [opts.backendUrl] - 后端地址 optional + * @param {string} [opts.description] - 描述 optional + * @param {string} [opts.jdsfName] - 微服务网关名称 optional + * @param {string} [opts.jdsfRegistryName] - 微服务注册中心ID optional + * @param {string} [opts.jdsfId] - 微服务ID optional + * @param {string} callback - callback + @return {Object} result + */ + + deploy (opts, callback) { + opts = opts || {} + + if (opts.sceneId === undefined || opts.sceneId === null) { + throw new Error( + "Missing the required parameter 'opts.sceneId' when calling deploy" + ) + } + if (opts.revision === undefined || opts.revision === null) { + throw new Error( + "Missing the required parameter 'opts.revision' when calling deploy" + ) + } + if (opts.environment === undefined || opts.environment === null) { + throw new Error( + "Missing the required parameter 'opts.environment' when calling deploy" + ) + } + + let postBody = {} + if (opts.revision !== undefined && opts.revision !== null) { + postBody['revision'] = opts.revision + } + if (opts.environment !== undefined && opts.environment !== null) { + postBody['environment'] = opts.environment + } + if ( + opts.backendServiceType !== undefined && + opts.backendServiceType !== null + ) { + postBody['backendServiceType'] = opts.backendServiceType + } + if (opts.backendUrl !== undefined && opts.backendUrl !== null) { + postBody['backendUrl'] = opts.backendUrl + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.jdsfName !== undefined && opts.jdsfName !== null) { + postBody['jdsfName'] = opts.jdsfName + } + if (opts.jdsfRegistryName !== undefined && opts.jdsfRegistryName !== null) { + postBody['jdsfRegistryName'] = opts.jdsfRegistryName + } + if (opts.jdsfId !== undefined && opts.jdsfId !== null) { + postBody['jdsfId'] = opts.jdsfId + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + sceneId: opts.sceneId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 hufu/1.0.7' + } + + 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 deploy 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( + '/scenes/{sceneId}/deployments', + '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.sceneId - 场景ID + * @param {string} opts.deploymentId - 部署ID + * @param {string} callback - callback + @return {Object} result + * @param deployment apiGroup + */ + + describeDeployment (opts, callback) { + opts = opts || {} + + if (opts.sceneId === undefined || opts.sceneId === null) { + throw new Error( + "Missing the required parameter 'opts.sceneId' when calling describeDeployment" + ) + } + if (opts.deploymentId === undefined || opts.deploymentId === null) { + throw new Error( + "Missing the required parameter 'opts.deploymentId' when calling describeDeployment" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + sceneId: opts.sceneId, + deploymentId: opts.deploymentId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 hufu/1.0.7' + } + + 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 describeDeployment 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( + '/scenes/{sceneId}/deployments/{deploymentId}', + '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.plaintext] - 明文 optional + * @param {string} callback - callback + @return {Object} result + * @param string ciphertext 密文 + */ + + encrypt (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.plaintext !== undefined && opts.plaintext !== null) { + postBody['plaintext'] = opts.plaintext + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 hufu/1.0.7' + } + + 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 encrypt 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( + '/encrypt', + '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.cipher] - 密文 optional + * @param {string} callback - callback + @return {Object} result + * @param boolean encryptData 是否是虎符密文 + */ + + isEncryptData (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.cipher !== undefined && opts.cipher !== null) { + postBody['cipher'] = opts.cipher + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 hufu/1.0.7' + } + + 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 isEncryptData 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( + '/isEncryptData', + '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) + } + ) + } + + /** + * 查询access日志 + * @param {Object} opts - parameters + * @param {string} [opts.call_pin] - 调用者pin optional + * @param {string} [opts.response_status] - 响应码 optional + * @param {string} [opts.api_name] - api名称 optional + * @param {string} [opts.access_key] - 调用者accessKey optional + * @param {string} [opts.host] - 请求虎符网关的域名 optional + * @param {string} opts.startTime - 开始时间,utc格式,例如:2020-05-19T00:00:05+0800 + * @param {string} opts.endTime - 结束时间,utc格式,例如:2020-05-19T00:00:05+0800 + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 分页大小 optional + * @param {string} callback - callback + @return {Object} result + * @param accessLog data + * @param integer total + */ + + queryAccessLog (opts, callback) { + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling queryAccessLog" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling queryAccessLog" + ) + } + + let postBody = null + let queryParams = {} + if (opts.call_pin !== undefined && opts.call_pin !== null) { + queryParams['call_pin'] = opts.call_pin + } + if (opts.response_status !== undefined && opts.response_status !== null) { + queryParams['response_status'] = opts.response_status + } + if (opts.api_name !== undefined && opts.api_name !== null) { + queryParams['api_name'] = opts.api_name + } + if (opts.access_key !== undefined && opts.access_key !== null) { + queryParams['access_key'] = opts.access_key + } + if (opts.host !== undefined && opts.host !== null) { + queryParams['host'] = opts.host + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + 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: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 hufu/1.0.7' + } + + 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 queryAccessLog 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( + '/access', + '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 = HUFU diff --git a/packages/libs/lib-jdcloud/src/repo/iam/v1/iam.js b/packages/libs/lib-jdcloud/src/repo/iam/v1/iam.js new file mode 100644 index 000000000..ce9dd4af7 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/iam/v1/iam.js @@ -0,0 +1,6762 @@ +/* + * 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. + * + * User Management + * User Management API + * + * 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 = 'iam' +Service._services[serviceId] = true + +/** + * iam service. + * @version 0.3.6 + */ + +class IAM extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'iam.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 启用子用户AccessKey <br>, 启用后accessKey 的状态变成 1 <b>启用</b> + + * @param {Object} opts - parameters + * @param {string} opts.subUser - 子用户名称 + * @param {string} opts.accessKey - accessKey + * @param {string} callback - callback + @return {Object} result + */ + + enableSubUserAccessKey (opts, callback) { + opts = opts || {} + + if (opts.subUser === undefined || opts.subUser === null) { + throw new Error( + "Missing the required parameter 'opts.subUser' when calling enableSubUserAccessKey" + ) + } + if (opts.accessKey === undefined || opts.accessKey === null) { + throw new Error( + "Missing the required parameter 'opts.accessKey' when calling enableSubUserAccessKey" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + subUser: opts.subUser, + accessKey: opts.accessKey + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 enableSubUserAccessKey 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( + '/subUser/{subUser}/accessKey/{accessKey}:enable', + '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) + } + ) + } + + /** + * 禁用子用户的AccessKey <br>, 禁用后accessKey 的状态变成 0 <b>禁用</b> + + * @param {Object} opts - parameters + * @param {string} opts.subUser - 子用户名称 + * @param {string} opts.accessKey - accessKey + * @param {string} callback - callback + @return {Object} result + */ + + disableSubUserAccessKey (opts, callback) { + opts = opts || {} + + if (opts.subUser === undefined || opts.subUser === null) { + throw new Error( + "Missing the required parameter 'opts.subUser' when calling disableSubUserAccessKey" + ) + } + if (opts.accessKey === undefined || opts.accessKey === null) { + throw new Error( + "Missing the required parameter 'opts.accessKey' when calling disableSubUserAccessKey" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + subUser: opts.subUser, + accessKey: opts.accessKey + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 disableSubUserAccessKey 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( + '/subUser/{subUser}/accessKey/{accessKey}:disable', + '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) + } + ) + } + + /** + * 删除子用户的AccessKey + + * @param {Object} opts - parameters + * @param {string} opts.subUser - 子用户名称 + * @param {string} opts.accessKey - accessKey + * @param {string} callback - callback + @return {Object} result + */ + + deleteSubUserAccessKey (opts, callback) { + opts = opts || {} + + if (opts.subUser === undefined || opts.subUser === null) { + throw new Error( + "Missing the required parameter 'opts.subUser' when calling deleteSubUserAccessKey" + ) + } + if (opts.accessKey === undefined || opts.accessKey === null) { + throw new Error( + "Missing the required parameter 'opts.accessKey' when calling deleteSubUserAccessKey" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + subUser: opts.subUser, + accessKey: opts.accessKey + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 deleteSubUserAccessKey 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( + '/subUser/{subUser}/accessKey/{accessKey}', + '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> +可访问<a href="https://docs.jdcloud.com/cn/iam/group-management">用户组管理</a>了解更多<br> + + * @param {Object} opts - parameters + * @param {createGroupInfo} opts.createGroupInfo + * @param {string} callback - callback + @return {Object} result + * @param createGroupRes group 用户组信息 + */ + + createGroup (opts, callback) { + opts = opts || {} + + if (opts.createGroupInfo === undefined || opts.createGroupInfo === null) { + throw new Error( + "Missing the required parameter 'opts.createGroupInfo' when calling createGroup" + ) + } + + let postBody = {} + if (opts.createGroupInfo !== undefined && opts.createGroupInfo !== null) { + postBody['createGroupInfo'] = opts.createGroupInfo + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 createGroup 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( + '/group', + '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.groupName - 用户组名称 + * @param {string} callback - callback + @return {Object} result + * @param groupDetail group 用户组信息 + */ + + describeGroup (opts, callback) { + opts = opts || {} + + if (opts.groupName === undefined || opts.groupName === null) { + throw new Error( + "Missing the required parameter 'opts.groupName' when calling describeGroup" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + groupName: opts.groupName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 describeGroup 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( + '/group/{groupName}', + '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.groupName - 用户组名称 + * @param {updateGroupInfo} opts.updateGroupInfo + * @param {string} callback - callback + @return {Object} result + */ + + updateGroup (opts, callback) { + opts = opts || {} + + if (opts.groupName === undefined || opts.groupName === null) { + throw new Error( + "Missing the required parameter 'opts.groupName' when calling updateGroup" + ) + } + if (opts.updateGroupInfo === undefined || opts.updateGroupInfo === null) { + throw new Error( + "Missing the required parameter 'opts.updateGroupInfo' when calling updateGroup" + ) + } + + let postBody = {} + if (opts.updateGroupInfo !== undefined && opts.updateGroupInfo !== null) { + postBody['updateGroupInfo'] = opts.updateGroupInfo + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + groupName: opts.groupName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 updateGroup 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( + '/group/{groupName}', + '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) + } + ) + } + + /** + * 删除用户组 + * @param {Object} opts - parameters + * @param {string} opts.groupName - 用户组名称 + * @param {string} callback - callback + @return {Object} result + */ + + deleteGroup (opts, callback) { + opts = opts || {} + + if (opts.groupName === undefined || opts.groupName === null) { + throw new Error( + "Missing the required parameter 'opts.groupName' when calling deleteGroup" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + groupName: opts.groupName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 deleteGroup 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( + '/group/{groupName}', + '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.groupName - 用户组名称 + * @param {integer} [opts.pageNumber] - 页码,默认1 optional + * @param {integer} [opts.pageSize] - 分页大小,默认50,取值范围[10, 100] optional + * @param {string} callback - callback + @return {Object} result + * @param integer total 用户总数 + * @param subUserInfo subUsers + */ + + describeGroupSubUsers (opts, callback) { + opts = opts || {} + + if (opts.groupName === undefined || opts.groupName === null) { + throw new Error( + "Missing the required parameter 'opts.groupName' when calling describeGroupSubUsers" + ) + } + + 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: 'jdcloud', + groupName: opts.groupName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 describeGroupSubUsers 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( + '/group/{groupName}/subUsers', + '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 optional + * @param {integer} [opts.pageSize] - 分页大小,默认50,取值范围[10, 100] optional + * @param {string} [opts.keyword] - 关键字 optional + * @param {integer} [opts.sort] - 排序规则:0-创建时间顺序排序,1-创建时间倒序排序 optional + * @param {string} callback - callback + @return {Object} result + * @param integer total 总数 + * @param group groups + */ + + describeGroups (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 + } + if (opts.keyword !== undefined && opts.keyword !== null) { + queryParams['keyword'] = opts.keyword + } + if (opts.sort !== undefined && opts.sort !== null) { + queryParams['sort'] = opts.sort + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 describeGroups 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( + '/groups', + '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.groupName - 用户组名称 + * @param {string} callback - callback + @return {Object} result + * @param integer total 总数 + * @param policy policies + */ + + describeAttachedGroupPolicies (opts, callback) { + opts = opts || {} + + if (opts.groupName === undefined || opts.groupName === null) { + throw new Error( + "Missing the required parameter 'opts.groupName' when calling describeAttachedGroupPolicies" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + groupName: opts.groupName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 describeAttachedGroupPolicies 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( + '/group/{groupName}/policies', + '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.groupName - 用户组名称 + * @param {string} opts.policyID - 策略ID + * @param {string} [opts.filterBindResGroup] - 滤绑定策略资源组:"Deny" 不允许,Allow 允许,空情况默认不允许,兼容历史数据 optional + * @param {string} callback - callback + @return {Object} result + * @param integer total 总数 + * @param resourceGroup policies + */ + + describeAttachedGroupPoliciesScope (opts, callback) { + opts = opts || {} + + if (opts.groupName === undefined || opts.groupName === null) { + throw new Error( + "Missing the required parameter 'opts.groupName' when calling describeAttachedGroupPoliciesScope" + ) + } + if (opts.policyID === undefined || opts.policyID === null) { + throw new Error( + "Missing the required parameter 'opts.policyID' when calling describeAttachedGroupPoliciesScope" + ) + } + + let postBody = null + let queryParams = {} + if (opts.policyID !== undefined && opts.policyID !== null) { + queryParams['policyID'] = opts.policyID + } + if ( + opts.filterBindResGroup !== undefined && + opts.filterBindResGroup !== null + ) { + queryParams['filterBindResGroup'] = opts.filterBindResGroup + } + + let pathParams = { + regionId: 'jdcloud', + groupName: opts.groupName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 describeAttachedGroupPoliciesScope 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( + '/group/{groupName}/policiesScope', + '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.groupName - 用户组名称 + * @param {string} opts.policyName - 策略名称 + * @param {string} [opts.scopeId] - 资源组id optional + * @param {string} [opts.allowDetachAddPolicy] - 允许解除策略:"Deny" 不允许,Allow 允许,空情况默认允许,兼容历史数据 optional + * @param {string} callback - callback + @return {Object} result + */ + + detachGroupPolicy (opts, callback) { + opts = opts || {} + + if (opts.groupName === undefined || opts.groupName === null) { + throw new Error( + "Missing the required parameter 'opts.groupName' when calling detachGroupPolicy" + ) + } + if (opts.policyName === undefined || opts.policyName === null) { + throw new Error( + "Missing the required parameter 'opts.policyName' when calling detachGroupPolicy" + ) + } + + let postBody = null + let queryParams = {} + if (opts.policyName !== undefined && opts.policyName !== null) { + queryParams['policyName'] = opts.policyName + } + if (opts.scopeId !== undefined && opts.scopeId !== null) { + queryParams['scopeId'] = opts.scopeId + } + if ( + opts.allowDetachAddPolicy !== undefined && + opts.allowDetachAddPolicy !== null + ) { + queryParams['allowDetachAddPolicy'] = opts.allowDetachAddPolicy + } + + let pathParams = { + regionId: 'jdcloud', + groupName: opts.groupName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 detachGroupPolicy 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( + '/group/{groupName}:detachGroupPolicy', + '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.groupName - 用户组名称 + * @param {string} opts.policyName - 策略名称 + * @param {string} [opts.scopeId] - 资源组id optional + * @param {string} [opts.allowAddPolicy] - 允许添加策略绑定:"Deny" 不允许,Allow 允许,空情况默认允许,兼容历史数据 optional + * @param {string} callback - callback + @return {Object} result + */ + + attachGroupPolicy (opts, callback) { + opts = opts || {} + + if (opts.groupName === undefined || opts.groupName === null) { + throw new Error( + "Missing the required parameter 'opts.groupName' when calling attachGroupPolicy" + ) + } + if (opts.policyName === undefined || opts.policyName === null) { + throw new Error( + "Missing the required parameter 'opts.policyName' when calling attachGroupPolicy" + ) + } + + let postBody = {} + if (opts.policyName !== undefined && opts.policyName !== null) { + postBody['policyName'] = opts.policyName + } + if (opts.scopeId !== undefined && opts.scopeId !== null) { + postBody['scopeId'] = opts.scopeId + } + if (opts.allowAddPolicy !== undefined && opts.allowAddPolicy !== null) { + postBody['allowAddPolicy'] = opts.allowAddPolicy + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + groupName: opts.groupName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 attachGroupPolicy 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( + '/group/{groupName}:attachGroupPolicy', + '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.groupName - 用户组名称 + * @param {string} opts.subUser - 子用户名 + * @param {string} callback - callback + @return {Object} result + */ + + removeSubUserFromGroup (opts, callback) { + opts = opts || {} + + if (opts.groupName === undefined || opts.groupName === null) { + throw new Error( + "Missing the required parameter 'opts.groupName' when calling removeSubUserFromGroup" + ) + } + if (opts.subUser === undefined || opts.subUser === null) { + throw new Error( + "Missing the required parameter 'opts.subUser' when calling removeSubUserFromGroup" + ) + } + + let postBody = null + let queryParams = {} + if (opts.subUser !== undefined && opts.subUser !== null) { + queryParams['subUser'] = opts.subUser + } + + let pathParams = { + regionId: 'jdcloud', + groupName: opts.groupName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 removeSubUserFromGroup 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( + '/group/{groupName}:removeSubUserFromGroup', + '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.groupName - 用户组名称 + * @param {string} opts.subUser - 子用户名 + * @param {string} callback - callback + @return {Object} result + */ + + addSubUserToGroup (opts, callback) { + opts = opts || {} + + if (opts.groupName === undefined || opts.groupName === null) { + throw new Error( + "Missing the required parameter 'opts.groupName' when calling addSubUserToGroup" + ) + } + if (opts.subUser === undefined || opts.subUser === null) { + throw new Error( + "Missing the required parameter 'opts.subUser' when calling addSubUserToGroup" + ) + } + + let postBody = {} + if (opts.subUser !== undefined && opts.subUser !== null) { + postBody['subUser'] = opts.subUser + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + groupName: opts.groupName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 addSubUserToGroup 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( + '/group/{groupName}:addSubUserToGroup', + '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) + } + ) + } + + /** + * 初始化虚拟MFA设备 + * @param {Object} opts - parameters + * @param {string} [opts.boundAccount] - 初始化的账号(目前支持:默认不填的情况表示为自己初始化,填写子用户名表示为子用户化初始) optional + * @param {string} callback - callback + @return {Object} result + * @param virtualMFADevice virtualMFADevice + */ + + createVirtualMFADevice (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.boundAccount !== undefined && opts.boundAccount !== null) { + postBody['boundAccount'] = opts.boundAccount + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 createVirtualMFADevice 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( + '/virtualMFADevice', + '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) + } + ) + } + + /** + * 查询虚拟MFA设备状态 + * @param {Object} opts - parameters + * @param {string} [opts.queriedAccount] - 被查询的账号(目前支持:默认不填的情况表示查询自己,填写子用户名表示查询子用户) optional + * @param {string} callback - callback + @return {Object} result + * @param integer status 0-关闭,1-启用 + */ + + describeVirtualMFA (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.queriedAccount !== undefined && opts.queriedAccount !== null) { + queryParams['queriedAccount'] = opts.queriedAccount + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 describeVirtualMFA 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( + '/virtualMFA', + '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) + } + ) + } + + /** + * 绑定虚拟MFA设备 + * @param {Object} opts - parameters + * @param {string} [opts.boundAccount] - 被绑定的账号(目前支持:默认不填的情况表示给自己绑定,填写子用户名表示主账号给子用户绑定) optional + * @param {string} opts.authenticationCode1 - 第一组动态密码(连续的两组) + * @param {string} opts.authenticationCode2 - 第二组动态密码(连续的两组) + * @param {string} callback - callback + @return {Object} result + */ + + bindMFADevice (opts, callback) { + opts = opts || {} + + if ( + opts.authenticationCode1 === undefined || + opts.authenticationCode1 === null + ) { + throw new Error( + "Missing the required parameter 'opts.authenticationCode1' when calling bindMFADevice" + ) + } + if ( + opts.authenticationCode2 === undefined || + opts.authenticationCode2 === null + ) { + throw new Error( + "Missing the required parameter 'opts.authenticationCode2' when calling bindMFADevice" + ) + } + + let postBody = {} + if (opts.boundAccount !== undefined && opts.boundAccount !== null) { + postBody['boundAccount'] = opts.boundAccount + } + if ( + opts.authenticationCode1 !== undefined && + opts.authenticationCode1 !== null + ) { + postBody['authenticationCode1'] = opts.authenticationCode1 + } + if ( + opts.authenticationCode2 !== undefined && + opts.authenticationCode2 !== null + ) { + postBody['authenticationCode2'] = opts.authenticationCode2 + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 bindMFADevice 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( + '/virtualMFADevice:bind', + '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) + } + ) + } + + /** + * 绑定虚拟MFA设备(一组动态密码) + * @param {Object} opts - parameters + * @param {string} [opts.boundAccount] - 被绑定的账号(目前支持:默认不填的情况表示给自己绑定,填写子用户名表示主账号给子用户绑定) optional + * @param {string} opts.authenticationCode - 一组动态密码 + * @param {string} callback - callback + @return {Object} result + */ + + bindMFADeviceByOneCode (opts, callback) { + opts = opts || {} + + if ( + opts.authenticationCode === undefined || + opts.authenticationCode === null + ) { + throw new Error( + "Missing the required parameter 'opts.authenticationCode' when calling bindMFADeviceByOneCode" + ) + } + + let postBody = {} + if (opts.boundAccount !== undefined && opts.boundAccount !== null) { + postBody['boundAccount'] = opts.boundAccount + } + if ( + opts.authenticationCode !== undefined && + opts.authenticationCode !== null + ) { + postBody['authenticationCode'] = opts.authenticationCode + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 bindMFADeviceByOneCode 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( + '/virtualMFADevice:bindByOneCode', + '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) + } + ) + } + + /** + * 解绑虚拟MFA设备 + * @param {Object} opts - parameters + * @param {string} [opts.unboundAccount] - 被解绑的账号(目前支持:默认不填的情况表示给自己解绑,填写子用户名表示为子用户解绑) optional + * @param {string} callback - callback + @return {Object} result + */ + + unbindMFADevice (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.unboundAccount !== undefined && opts.unboundAccount !== null) { + queryParams['unboundAccount'] = opts.unboundAccount + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 unbindMFADevice 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( + '/virtualMFADevice:unbind', + '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.orgId - 组织ID + * @param {addOrganizationUserRelationInfo} opts.addOrganizationUserRelationInfo - 新建组织用户关联子用户关系参数 + * @param {string} callback - callback + @return {Object} result + */ + + addOrganizationUserRelation (opts, callback) { + opts = opts || {} + + if (opts.orgId === undefined || opts.orgId === null) { + throw new Error( + "Missing the required parameter 'opts.orgId' when calling addOrganizationUserRelation" + ) + } + if ( + opts.addOrganizationUserRelationInfo === undefined || + opts.addOrganizationUserRelationInfo === null + ) { + throw new Error( + "Missing the required parameter 'opts.addOrganizationUserRelationInfo' when calling addOrganizationUserRelation" + ) + } + + let postBody = {} + if ( + opts.addOrganizationUserRelationInfo !== undefined && + opts.addOrganizationUserRelationInfo !== null + ) { + postBody['addOrganizationUserRelationInfo'] = + opts.addOrganizationUserRelationInfo + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + orgId: opts.orgId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 addOrganizationUserRelation 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( + '/organization/{orgId}/userRelation:add', + '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> +关于策略的详细介绍,可以查询<a href="https://docs.jdcloud.com/cn/iam/policy-overview">策略概览</a> <br> + + * @param {Object} opts - parameters + * @param {createPermissionInfo} opts.createPermissionInfo - 权限信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + createPermission (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 createPermission" + ) + } + + opts = opts || {} + + if ( + opts.createPermissionInfo === undefined || + opts.createPermissionInfo === null + ) { + throw new Error( + "Missing the required parameter 'opts.createPermissionInfo' when calling createPermission" + ) + } + + let postBody = {} + if ( + opts.createPermissionInfo !== undefined && + opts.createPermissionInfo !== null + ) { + postBody['createPermissionInfo'] = opts.createPermissionInfo + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 createPermission 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}/permission', + '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.permissionId - 权限id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param permission permission 权限信息 + */ + + describePermissionDetail (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 describePermissionDetail" + ) + } + + opts = opts || {} + + if (opts.permissionId === undefined || opts.permissionId === null) { + throw new Error( + "Missing the required parameter 'opts.permissionId' when calling describePermissionDetail" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + permissionId: opts.permissionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 describePermissionDetail 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}/permission/{permissionId}', + '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.permissionId - 权限id + * @param {updatePermissionInfo} opts.updatePermissionInfo - 权限信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updatePermission (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 updatePermission" + ) + } + + opts = opts || {} + + if (opts.permissionId === undefined || opts.permissionId === null) { + throw new Error( + "Missing the required parameter 'opts.permissionId' when calling updatePermission" + ) + } + if ( + opts.updatePermissionInfo === undefined || + opts.updatePermissionInfo === null + ) { + throw new Error( + "Missing the required parameter 'opts.updatePermissionInfo' when calling updatePermission" + ) + } + + let postBody = {} + if ( + opts.updatePermissionInfo !== undefined && + opts.updatePermissionInfo !== null + ) { + postBody['updatePermissionInfo'] = opts.updatePermissionInfo + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + permissionId: opts.permissionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 updatePermission 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}/permission/{permissionId}', + '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) + } + ) + } + + /** + * 查询策略列表 + * @param {Object} opts - parameters + * @param {integer} opts.pageNumber - 页码 + * @param {integer} opts.pageSize - 每页显示数目 + * @param {string} [opts.keyword] - 关键字 optional + * @param {integer} opts.queryType - 权限类型,0-全部,1-系统权限,2-自定义权限 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer total 总数 + * @param permission permissions + */ + + describePermissions (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 describePermissions" + ) + } + + opts = opts || {} + + if (opts.pageNumber === undefined || opts.pageNumber === null) { + throw new Error( + "Missing the required parameter 'opts.pageNumber' when calling describePermissions" + ) + } + if (opts.pageSize === undefined || opts.pageSize === null) { + throw new Error( + "Missing the required parameter 'opts.pageSize' when calling describePermissions" + ) + } + if (opts.queryType === undefined || opts.queryType === null) { + throw new Error( + "Missing the required parameter 'opts.queryType' when calling describePermissions" + ) + } + + 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.keyword !== undefined && opts.keyword !== null) { + queryParams['keyword'] = opts.keyword + } + if (opts.queryType !== undefined && opts.queryType !== null) { + queryParams['queryType'] = opts.queryType + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 describePermissions 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}/permissions', + '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.subUser - 子用户用户名 + * @param {integer} opts.pageNumber - 页码 + * @param {integer} opts.pageSize - 每页显示数目 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer total 总数 + * @param permission permissions + */ + + describeSubUserPermissions (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 describeSubUserPermissions" + ) + } + + opts = opts || {} + + if (opts.subUser === undefined || opts.subUser === null) { + throw new Error( + "Missing the required parameter 'opts.subUser' when calling describeSubUserPermissions" + ) + } + if (opts.pageNumber === undefined || opts.pageNumber === null) { + throw new Error( + "Missing the required parameter 'opts.pageNumber' when calling describeSubUserPermissions" + ) + } + if (opts.pageSize === undefined || opts.pageSize === null) { + throw new Error( + "Missing the required parameter 'opts.pageSize' when calling describeSubUserPermissions" + ) + } + + 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, + subUser: opts.subUser + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 describeSubUserPermissions 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}/subUser/{subUser}/permisssions', + '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.subUser - 子用户用户名 + * @param {addPermissionsInfo} opts.addPermissionsInfo - 权限信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + addPermissionsToSubUser (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 addPermissionsToSubUser" + ) + } + + opts = opts || {} + + if (opts.subUser === undefined || opts.subUser === null) { + throw new Error( + "Missing the required parameter 'opts.subUser' when calling addPermissionsToSubUser" + ) + } + if ( + opts.addPermissionsInfo === undefined || + opts.addPermissionsInfo === null + ) { + throw new Error( + "Missing the required parameter 'opts.addPermissionsInfo' when calling addPermissionsToSubUser" + ) + } + + let postBody = {} + if ( + opts.addPermissionsInfo !== undefined && + opts.addPermissionsInfo !== null + ) { + postBody['addPermissionsInfo'] = opts.addPermissionsInfo + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + subUser: opts.subUser + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 addPermissionsToSubUser 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}/subUser/{subUser}/permisssions', + '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.permissionId - 权限id + * @param {string} opts.subUser - 子用户用户名 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + removePermissionOfSubUser (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 removePermissionOfSubUser" + ) + } + + opts = opts || {} + + if (opts.permissionId === undefined || opts.permissionId === null) { + throw new Error( + "Missing the required parameter 'opts.permissionId' when calling removePermissionOfSubUser" + ) + } + if (opts.subUser === undefined || opts.subUser === null) { + throw new Error( + "Missing the required parameter 'opts.subUser' when calling removePermissionOfSubUser" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + permissionId: opts.permissionId, + subUser: opts.subUser + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 removePermissionOfSubUser 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}/subUser/{subUser}/permissions/{permissionId}', + '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> +访问 <a href="https://docs.jdcloud.com/cn/iam/policy-overview">策略管理</a> 了解更多内容 <br> + + * @param {Object} opts - parameters + * @param {createPolicyInfo} opts.createPolicyInfo - 策略信息 + * @param {string} callback - callback + @return {Object} result + * @param policy policy 策略信息 + */ + + createPolicy (opts, callback) { + opts = opts || {} + + if (opts.createPolicyInfo === undefined || opts.createPolicyInfo === null) { + throw new Error( + "Missing the required parameter 'opts.createPolicyInfo' when calling createPolicy" + ) + } + + let postBody = {} + if (opts.createPolicyInfo !== undefined && opts.createPolicyInfo !== null) { + postBody['createPolicyInfo'] = opts.createPolicyInfo + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 createPolicy 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( + '/policy', + '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.policyName - 策略名称 + * @param {string} callback - callback + @return {Object} result + * @param policyDetail policy 权限策略信息 + * @param policyEdition defaultPolicyEdition 权限策略的默认版本信息 + */ + + describePolicy (opts, callback) { + opts = opts || {} + + if (opts.policyName === undefined || opts.policyName === null) { + throw new Error( + "Missing the required parameter 'opts.policyName' when calling describePolicy" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + policyName: opts.policyName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 describePolicy 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( + '/policy/{policyName}', + '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.policyName - 策略名称 + * @param {updatePolicyInfo} opts.updatePolicyInfo - 策略文档信息 + * @param {string} callback - callback + @return {Object} result + */ + + updatePolicy (opts, callback) { + opts = opts || {} + + if (opts.policyName === undefined || opts.policyName === null) { + throw new Error( + "Missing the required parameter 'opts.policyName' when calling updatePolicy" + ) + } + if (opts.updatePolicyInfo === undefined || opts.updatePolicyInfo === null) { + throw new Error( + "Missing the required parameter 'opts.updatePolicyInfo' when calling updatePolicy" + ) + } + + let postBody = {} + if (opts.updatePolicyInfo !== undefined && opts.updatePolicyInfo !== null) { + postBody['updatePolicyInfo'] = opts.updatePolicyInfo + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + policyName: opts.policyName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 updatePolicy 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( + '/policy/{policyName}', + '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) + } + ) + } + + /** + * 删除策略 + * @param {Object} opts - parameters + * @param {string} opts.policyName - 策略名称 + * @param {string} callback - callback + @return {Object} result + */ + + deletePolicy (opts, callback) { + opts = opts || {} + + if (opts.policyName === undefined || opts.policyName === null) { + throw new Error( + "Missing the required parameter 'opts.policyName' when calling deletePolicy" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + policyName: opts.policyName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 deletePolicy 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( + '/policy/{policyName}', + '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.policyName - 策略名称 + * @param {updatePolicyDescriptionInfo} opts.updatePolicyDescriptionInfo - 策略描述信息 + * @param {string} callback - callback + @return {Object} result + */ + + updatePolicyDescription (opts, callback) { + opts = opts || {} + + if (opts.policyName === undefined || opts.policyName === null) { + throw new Error( + "Missing the required parameter 'opts.policyName' when calling updatePolicyDescription" + ) + } + if ( + opts.updatePolicyDescriptionInfo === undefined || + opts.updatePolicyDescriptionInfo === null + ) { + throw new Error( + "Missing the required parameter 'opts.updatePolicyDescriptionInfo' when calling updatePolicyDescription" + ) + } + + let postBody = {} + if ( + opts.updatePolicyDescriptionInfo !== undefined && + opts.updatePolicyDescriptionInfo !== null + ) { + postBody['updatePolicyDescriptionInfo'] = opts.updatePolicyDescriptionInfo + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + policyName: opts.policyName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 updatePolicyDescription 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( + '/policy/{policyName}/description', + '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) + } + ) + } + + /** + * 查询策略列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码,默认1 optional + * @param {integer} [opts.pageSize] - 分页大小,默认50,取值范围[10, 100] optional + * @param {string} [opts.keyword] - 关键字 optional + * @param {integer} [opts.queryType] - 策略类型:0-全部(默认),1-系统策略,2-自定义策略 optional + * @param {integer} [opts.sort] - 排序规则:0-创建时间顺序排序,1-创建时间倒序排序 optional + * @param {string} callback - callback + @return {Object} result + * @param integer total 总数 + * @param policy policies + */ + + describePolicies (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 + } + if (opts.keyword !== undefined && opts.keyword !== null) { + queryParams['keyword'] = opts.keyword + } + if (opts.queryType !== undefined && opts.queryType !== null) { + queryParams['queryType'] = opts.queryType + } + if (opts.sort !== undefined && opts.sort !== null) { + queryParams['sort'] = opts.sort + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 describePolicies 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( + '/policies', + '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> +关于角色的详细介绍,请请参考 <a href="https://docs.jdcloud.com/cn/iam/role-overview">角色概览</a> <br> + + * @param {Object} opts - parameters + * @param {createRoleInfo} opts.createRoleInfo - 角色信息 + * @param {string} callback - callback + @return {Object} result + * @param roleInfo roleInfo 角色信息 + */ + + createRole (opts, callback) { + opts = opts || {} + + if (opts.createRoleInfo === undefined || opts.createRoleInfo === null) { + throw new Error( + "Missing the required parameter 'opts.createRoleInfo' when calling createRole" + ) + } + + let postBody = {} + if (opts.createRoleInfo !== undefined && opts.createRoleInfo !== null) { + postBody['createRoleInfo'] = opts.createRoleInfo + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 createRole 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( + '/role', + '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 {copyRoleInfo} opts.copyRoleInfo - 角色信息 + * @param {string} callback - callback + @return {Object} result + * @param roleInfo roleInfo 角色信息 + */ + + copyRole (opts, callback) { + opts = opts || {} + + if (opts.copyRoleInfo === undefined || opts.copyRoleInfo === null) { + throw new Error( + "Missing the required parameter 'opts.copyRoleInfo' when calling copyRole" + ) + } + + let postBody = {} + if (opts.copyRoleInfo !== undefined && opts.copyRoleInfo !== null) { + postBody['copyRoleInfo'] = opts.copyRoleInfo + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 copyRole 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( + '/copyRole', + '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.roleName - 角色名称 + * @param {string} callback - callback + @return {Object} result + * @param roleInfo roleInfo 角色信息 + */ + + describeRole (opts, callback) { + opts = opts || {} + + if (opts.roleName === undefined || opts.roleName === null) { + throw new Error( + "Missing the required parameter 'opts.roleName' when calling describeRole" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + roleName: opts.roleName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 describeRole 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( + '/role/{roleName}', + '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.roleName - 角色名称 + * @param {string} callback - callback + @return {Object} result + */ + + deleteRole (opts, callback) { + opts = opts || {} + + if (opts.roleName === undefined || opts.roleName === null) { + throw new Error( + "Missing the required parameter 'opts.roleName' when calling deleteRole" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + roleName: opts.roleName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 deleteRole 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( + '/role/{roleName}', + '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) + } + ) + } + + /** + * 修改角色内置policy + * @param {Object} opts - parameters + * @param {string} opts.roleName - 角色名称 + * @param {updateAssumeRolePolicyInfo} opts.updateAssumeRolePolicyInfo - 角色权限信息 + * @param {string} callback - callback + @return {Object} result + */ + + updateAssumeRolePolicy (opts, callback) { + opts = opts || {} + + if (opts.roleName === undefined || opts.roleName === null) { + throw new Error( + "Missing the required parameter 'opts.roleName' when calling updateAssumeRolePolicy" + ) + } + if ( + opts.updateAssumeRolePolicyInfo === undefined || + opts.updateAssumeRolePolicyInfo === null + ) { + throw new Error( + "Missing the required parameter 'opts.updateAssumeRolePolicyInfo' when calling updateAssumeRolePolicy" + ) + } + + let postBody = {} + if ( + opts.updateAssumeRolePolicyInfo !== undefined && + opts.updateAssumeRolePolicyInfo !== null + ) { + postBody['updateAssumeRolePolicyInfo'] = opts.updateAssumeRolePolicyInfo + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + roleName: opts.roleName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 updateAssumeRolePolicy 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( + '/role/{roleName}/assumeRolePolicy', + '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) + } + ) + } + + /** + * 查询角色列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码,默认1 optional + * @param {integer} [opts.pageSize] - 分页大小,默认50,取值范围[10, 100] optional + * @param {string} [opts.roleName] - 角色名称关键词 optional + * @param {integer} [opts.type] - 角色类型,默认查找所有类型,2-服务相关角色,3-服务角色,4-用户角色 optional + * @param {integer} [opts.sort] - 排序策略,0-按创建时间顺序排序,1-按创建时间倒序排序 optional + * @param {string} callback - callback + @return {Object} result + * @param integer total 总数 + * @param listRoleInfo roles + */ + + describeRoles (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 + } + if (opts.roleName !== undefined && opts.roleName !== null) { + queryParams['roleName'] = opts.roleName + } + if (opts.type !== undefined && opts.type !== null) { + queryParams['type'] = opts.type + } + if (opts.sort !== undefined && opts.sort !== null) { + queryParams['sort'] = opts.sort + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 describeRoles 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( + '/roles', + '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.roleName - 角色名称 + * @param {string} opts.policyName - 策略名称 + * @param {string} [opts.scopeId] - 资源组id optional + * @param {string} [opts.allowAddPolicy] - 允许添加策略绑定:"Deny" 不允许,Allow 允许,空情况默认允许,兼容历史数据 optional + * @param {string} callback - callback + @return {Object} result + */ + + attachRolePolicy (opts, callback) { + opts = opts || {} + + if (opts.roleName === undefined || opts.roleName === null) { + throw new Error( + "Missing the required parameter 'opts.roleName' when calling attachRolePolicy" + ) + } + if (opts.policyName === undefined || opts.policyName === null) { + throw new Error( + "Missing the required parameter 'opts.policyName' when calling attachRolePolicy" + ) + } + + let postBody = {} + if (opts.policyName !== undefined && opts.policyName !== null) { + postBody['policyName'] = opts.policyName + } + if (opts.scopeId !== undefined && opts.scopeId !== null) { + postBody['scopeId'] = opts.scopeId + } + if (opts.allowAddPolicy !== undefined && opts.allowAddPolicy !== null) { + postBody['allowAddPolicy'] = opts.allowAddPolicy + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + roleName: opts.roleName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 attachRolePolicy 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( + '/role/{roleName}:attachRolePolicy', + '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.roleName - 角色名称 + * @param {string} opts.policyName - 策略名称 + * @param {string} [opts.scopeId] - 资源组id optional + * @param {string} [opts.allowDetachAddPolicy] - 允许解除策略:"Deny" 不允许,Allow 允许,空情况默认允许,兼容历史数据 optional + * @param {string} callback - callback + @return {Object} result + */ + + detachRolePolicy (opts, callback) { + opts = opts || {} + + if (opts.roleName === undefined || opts.roleName === null) { + throw new Error( + "Missing the required parameter 'opts.roleName' when calling detachRolePolicy" + ) + } + if (opts.policyName === undefined || opts.policyName === null) { + throw new Error( + "Missing the required parameter 'opts.policyName' when calling detachRolePolicy" + ) + } + + let postBody = null + let queryParams = {} + if (opts.policyName !== undefined && opts.policyName !== null) { + queryParams['policyName'] = opts.policyName + } + if (opts.scopeId !== undefined && opts.scopeId !== null) { + queryParams['scopeId'] = opts.scopeId + } + if ( + opts.allowDetachAddPolicy !== undefined && + opts.allowDetachAddPolicy !== null + ) { + queryParams['allowDetachAddPolicy'] = opts.allowDetachAddPolicy + } + + let pathParams = { + regionId: 'jdcloud', + roleName: opts.roleName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 detachRolePolicy 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( + '/role/{roleName}:detachRolePolicy', + '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.roleName - 角色名称 + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 每页显示数目[10~100] 默认50条 optional + * @param {string} [opts.keyword] - 关键字 optional + * @param {integer} opts.sort - 排序策略,0-按创建时间顺序排序 1-按创建时间倒序 + * @param {string} callback - callback + @return {Object} result + * @param integer total 总数 + * @param rolePolicy policies + */ + + describeRolePolicies (opts, callback) { + opts = opts || {} + + if (opts.roleName === undefined || opts.roleName === null) { + throw new Error( + "Missing the required parameter 'opts.roleName' when calling describeRolePolicies" + ) + } + if (opts.sort === undefined || opts.sort === null) { + throw new Error( + "Missing the required parameter 'opts.sort' when calling describeRolePolicies" + ) + } + + 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.keyword !== undefined && opts.keyword !== null) { + queryParams['keyword'] = opts.keyword + } + if (opts.sort !== undefined && opts.sort !== null) { + queryParams['sort'] = opts.sort + } + + let pathParams = { + regionId: 'jdcloud', + roleName: opts.roleName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 describeRolePolicies 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( + '/role/{roleName}/policies', + '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.roleName - 角色名称 + * @param {string} opts.policyID - 策略ID + * @param {string} [opts.filterBindResGroup] - 滤绑定策略资源组:"Deny" 不允许,Allow 允许,空情况默认不允许,兼容历史数据 optional + * @param {string} callback - callback + @return {Object} result + * @param integer total 总数 + * @param rolePolicy policies + */ + + describeRolePoliciesScope (opts, callback) { + opts = opts || {} + + if (opts.roleName === undefined || opts.roleName === null) { + throw new Error( + "Missing the required parameter 'opts.roleName' when calling describeRolePoliciesScope" + ) + } + if (opts.policyID === undefined || opts.policyID === null) { + throw new Error( + "Missing the required parameter 'opts.policyID' when calling describeRolePoliciesScope" + ) + } + + let postBody = null + let queryParams = {} + if (opts.policyID !== undefined && opts.policyID !== null) { + queryParams['policyID'] = opts.policyID + } + if ( + opts.filterBindResGroup !== undefined && + opts.filterBindResGroup !== null + ) { + queryParams['filterBindResGroup'] = opts.filterBindResGroup + } + + let pathParams = { + regionId: 'jdcloud', + roleName: opts.roleName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 describeRolePoliciesScope 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( + '/role/{roleName}/policiesScope', + '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> +请访问<a href="https://docs.jdcloud.com/cn/iam/subuser-management">子用户管理</a>了解更多 <br> + + * @param {Object} opts - parameters + * @param {createSubUserInfo} opts.createSubUserInfo - 子用户信息 + * @param {string} callback - callback + @return {Object} result + * @param createSubUserRes subUser + */ + + createSubUser (opts, callback) { + opts = opts || {} + + if ( + opts.createSubUserInfo === undefined || + opts.createSubUserInfo === null + ) { + throw new Error( + "Missing the required parameter 'opts.createSubUserInfo' when calling createSubUser" + ) + } + + let postBody = {} + if ( + opts.createSubUserInfo !== undefined && + opts.createSubUserInfo !== null + ) { + postBody['createSubUserInfo'] = opts.createSubUserInfo + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 createSubUser 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( + '/subUser', + '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.subUser - 子用户名 + * @param {string} callback - callback + @return {Object} result + * @param subUser subUser + */ + + describeSubUser (opts, callback) { + opts = opts || {} + + if (opts.subUser === undefined || opts.subUser === null) { + throw new Error( + "Missing the required parameter 'opts.subUser' when calling describeSubUser" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + subUser: opts.subUser + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 describeSubUser 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( + '/subUser/{subUser}', + '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.subUser - 子用户名 + * @param {updateSubUserInfo} opts.updateSubUserInfo - 子用户信息 + * @param {string} callback - callback + @return {Object} result + * @param createSubUserRes subUser + */ + + updateSubUser (opts, callback) { + opts = opts || {} + + if (opts.subUser === undefined || opts.subUser === null) { + throw new Error( + "Missing the required parameter 'opts.subUser' when calling updateSubUser" + ) + } + if ( + opts.updateSubUserInfo === undefined || + opts.updateSubUserInfo === null + ) { + throw new Error( + "Missing the required parameter 'opts.updateSubUserInfo' when calling updateSubUser" + ) + } + + let postBody = {} + if ( + opts.updateSubUserInfo !== undefined && + opts.updateSubUserInfo !== null + ) { + postBody['updateSubUserInfo'] = opts.updateSubUserInfo + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + subUser: opts.subUser + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 updateSubUser 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( + '/subUser/{subUser}', + '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) + } + ) + } + + /** + * 删除子用户信息 + * @param {Object} opts - parameters + * @param {string} opts.subUser - 子用户名 + * @param {string} callback - callback + @return {Object} result + */ + + deleteSubUser (opts, callback) { + opts = opts || {} + + if (opts.subUser === undefined || opts.subUser === null) { + throw new Error( + "Missing the required parameter 'opts.subUser' when calling deleteSubUser" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + subUser: opts.subUser + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 deleteSubUser 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( + '/subUser/{subUser}', + '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 optional + * @param {integer} [opts.pageSize] - 分页大小,默认50,取值范围[10, 100] optional + * @param {string} [opts.keyword] - 关键字 optional + * @param {integer} [opts.sort] - 排序规则:0-创建时间顺序排序,1-创建时间倒序排序 optional + * @param {string} [opts.phone] - 手机号,和keyword互斥,不要都传 optional + * @param {string} [opts.email] - 邮箱,和keyword互斥,不要都传 optional + * @param {string} [opts.description] - 用户姓名,和keyword互斥,不要都传 optional + * @param {string} [opts.nickName] - 子用户别名 optional + * @param {string} [opts.name] - 子用户姓名 optional + * @param {string} callback - callback + @return {Object} result + * @param subUser subUsers + * @param integer total + */ + + describeSubUsers (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 + } + if (opts.keyword !== undefined && opts.keyword !== null) { + queryParams['keyword'] = opts.keyword + } + if (opts.sort !== undefined && opts.sort !== null) { + queryParams['sort'] = opts.sort + } + if (opts.phone !== undefined && opts.phone !== null) { + queryParams['phone'] = opts.phone + } + if (opts.email !== undefined && opts.email !== null) { + queryParams['email'] = opts.email + } + if (opts.description !== undefined && opts.description !== null) { + queryParams['description'] = opts.description + } + if (opts.nickName !== undefined && opts.nickName !== null) { + queryParams['nickName'] = opts.nickName + } + if (opts.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 describeSubUsers 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( + '/subUsers', + '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.subUser - 子用户名 + * @param {string} callback - callback + @return {Object} result + * @param groupInfo groups + * @param integer total + */ + + describeSubUserGroups (opts, callback) { + opts = opts || {} + + if (opts.subUser === undefined || opts.subUser === null) { + throw new Error( + "Missing the required parameter 'opts.subUser' when calling describeSubUserGroups" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + subUser: opts.subUser + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 describeSubUserGroups 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( + '/subUser/{subUser}/groups', + '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.subUser - 子用户名 + * @param {string} callback - callback + @return {Object} result + * @param integer total 总数 + * @param policy policies + */ + + describeAttachedSubUserPolicies (opts, callback) { + opts = opts || {} + + if (opts.subUser === undefined || opts.subUser === null) { + throw new Error( + "Missing the required parameter 'opts.subUser' when calling describeAttachedSubUserPolicies" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + subUser: opts.subUser + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 describeAttachedSubUserPolicies 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( + '/subUser/{subUser}/policies', + '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.subUser - 子用户名 + * @param {string} opts.policyID - 策略ID + * @param {string} [opts.filterBindResGroup] - 滤绑定策略资源组:"Deny" 不允许,Allow 允许,空情况默认不允许,兼容历史数据 optional + * @param {string} callback - callback + @return {Object} result + * @param integer total 总数 + * @param resourceGroup policies + */ + + describeAttachedSubUserPoliciesScope (opts, callback) { + opts = opts || {} + + if (opts.subUser === undefined || opts.subUser === null) { + throw new Error( + "Missing the required parameter 'opts.subUser' when calling describeAttachedSubUserPoliciesScope" + ) + } + if (opts.policyID === undefined || opts.policyID === null) { + throw new Error( + "Missing the required parameter 'opts.policyID' when calling describeAttachedSubUserPoliciesScope" + ) + } + + let postBody = null + let queryParams = {} + if (opts.policyID !== undefined && opts.policyID !== null) { + queryParams['policyID'] = opts.policyID + } + if ( + opts.filterBindResGroup !== undefined && + opts.filterBindResGroup !== null + ) { + queryParams['filterBindResGroup'] = opts.filterBindResGroup + } + + let pathParams = { + regionId: 'jdcloud', + subUser: opts.subUser + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 describeAttachedSubUserPoliciesScope 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( + '/subUser/{subUser}/policiesScope', + '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.subUser - 子用户名 + * @param {string} opts.policyName - 策略名称 + * @param {string} [opts.scopeId] - 资源组id optional + * @param {string} [opts.allowDetachAddPolicy] - 允许解除策略:"Deny" 不允许,Allow 允许,空情况默认允许,兼容历史数据 optional + * @param {string} callback - callback + @return {Object} result + */ + + detachSubUserPolicy (opts, callback) { + opts = opts || {} + + if (opts.subUser === undefined || opts.subUser === null) { + throw new Error( + "Missing the required parameter 'opts.subUser' when calling detachSubUserPolicy" + ) + } + if (opts.policyName === undefined || opts.policyName === null) { + throw new Error( + "Missing the required parameter 'opts.policyName' when calling detachSubUserPolicy" + ) + } + + let postBody = null + let queryParams = {} + if (opts.policyName !== undefined && opts.policyName !== null) { + queryParams['policyName'] = opts.policyName + } + if (opts.scopeId !== undefined && opts.scopeId !== null) { + queryParams['scopeId'] = opts.scopeId + } + if ( + opts.allowDetachAddPolicy !== undefined && + opts.allowDetachAddPolicy !== null + ) { + queryParams['allowDetachAddPolicy'] = opts.allowDetachAddPolicy + } + + let pathParams = { + regionId: 'jdcloud', + subUser: opts.subUser + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 detachSubUserPolicy 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( + '/subUser/{subUser}:detachSubUserPolicy', + '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.subUser - 子用户名 + * @param {string} opts.policyName - 策略名称 + * @param {string} [opts.scopeId] - 资源组id optional + * @param {string} [opts.allowAddPolicy] - 允许添加策略绑定:"Deny" 不允许,Allow 允许,空情况默认允许,兼容历史数据 optional + * @param {string} callback - callback + @return {Object} result + */ + + attachSubUserPolicy (opts, callback) { + opts = opts || {} + + if (opts.subUser === undefined || opts.subUser === null) { + throw new Error( + "Missing the required parameter 'opts.subUser' when calling attachSubUserPolicy" + ) + } + if (opts.policyName === undefined || opts.policyName === null) { + throw new Error( + "Missing the required parameter 'opts.policyName' when calling attachSubUserPolicy" + ) + } + + let postBody = {} + if (opts.policyName !== undefined && opts.policyName !== null) { + postBody['policyName'] = opts.policyName + } + if (opts.scopeId !== undefined && opts.scopeId !== null) { + postBody['scopeId'] = opts.scopeId + } + if (opts.allowAddPolicy !== undefined && opts.allowAddPolicy !== null) { + postBody['allowAddPolicy'] = opts.allowAddPolicy + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + subUser: opts.subUser + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 attachSubUserPolicy 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( + '/subUser/{subUser}:attachSubUserPolicy', + '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> +请访问<a href="https://docs.jdcloud.com/cn/iam/subuser-management">子用户管理</a>了解更多 <br> + + * @param {Object} opts - parameters + * @param {createSubUserInfoInner} opts.createSubUserInfo - 子用户信息 + * @param {string} callback - callback + @return {Object} result + * @param createSubUserRes subUser + */ + + createSubUserInner (opts, callback) { + opts = opts || {} + + if ( + opts.createSubUserInfo === undefined || + opts.createSubUserInfo === null + ) { + throw new Error( + "Missing the required parameter 'opts.createSubUserInfo' when calling createSubUserInner" + ) + } + + let postBody = {} + if ( + opts.createSubUserInfo !== undefined && + opts.createSubUserInfo !== null + ) { + postBody['createSubUserInfo'] = opts.createSubUserInfo + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 createSubUserInner 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( + '/subUserInner', + '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) + } + ) + } + + /** + * 查询主账号AccessKey列表 <br> +关于AccessKey的介绍和使用,请参考 <a href="https://docs.jdcloud.com/cn/account-management/accesskey-management">Accesskey管理</a> <br> + + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param userAccessKey userAccessKeys + */ + + describeUserAccessKeys (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 describeUserAccessKeys" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 describeUserAccessKeys 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}/userAccessKeys', + '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) + } + ) + } + + /** + * 创建主账号AccessKey, <br> 最多可创建5个 + + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + createUserAccessKey (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 createUserAccessKey" + ) + } + + opts = opts || {} + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 createUserAccessKey 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}/userAccessKey', + '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) + } + ) + } + + /** + * 启用主账号AccessKey, <br> 启用后accessKey的状态变成 1 <b>启用</b> + + * @param {Object} opts - parameters + * @param {string} opts.accessKey - accessKey + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + enabledUserAccessKey (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 enabledUserAccessKey" + ) + } + + opts = opts || {} + + if (opts.accessKey === undefined || opts.accessKey === null) { + throw new Error( + "Missing the required parameter 'opts.accessKey' when calling enabledUserAccessKey" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + accessKey: opts.accessKey + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 enabledUserAccessKey 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}/userAccessKey/{accessKey}:enabled', + '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) + } + ) + } + + /** + * 禁用主账号AccessKey, <br> 禁用后accessKey的状态变成 0 <b>禁用</b> + + * @param {Object} opts - parameters + * @param {string} opts.accessKey - accessKey + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + disabledUserAccessKey (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 disabledUserAccessKey" + ) + } + + opts = opts || {} + + if (opts.accessKey === undefined || opts.accessKey === null) { + throw new Error( + "Missing the required parameter 'opts.accessKey' when calling disabledUserAccessKey" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + accessKey: opts.accessKey + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 disabledUserAccessKey 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}/userAccessKey/{accessKey}:disabled', + '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) + } + ) + } + + /** + * 删除主账号AccessKey, <br> + + * @param {Object} opts - parameters + * @param {string} opts.accessKey - accessKey + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteUserAccessKey (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 deleteUserAccessKey" + ) + } + + opts = opts || {} + + if (opts.accessKey === undefined || opts.accessKey === null) { + throw new Error( + "Missing the required parameter 'opts.accessKey' when calling deleteUserAccessKey" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + accessKey: opts.accessKey + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 deleteUserAccessKey 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}/userAccessKey/{accessKey}', + '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) + } + ) + } + + /** + * 根据AccessKey或者AccountId获取用户Pin + * @param {Object} opts - parameters + * @param {string} [opts.accessKey] - 用户accessKey optional + * @param {string} [opts.accountId] - 用户唯一id optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string pin 用户pin,如果是子账号,则格式为主账号pin @ 子账号pin + */ + + describeUserPin (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 describeUserPin" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.accessKey !== undefined && opts.accessKey !== null) { + queryParams['accessKey'] = opts.accessKey + } + if (opts.accountId !== undefined && opts.accountId !== null) { + queryParams['accountId'] = opts.accountId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iam/0.3.6' + } + + 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 describeUserPin 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}/user:describeUserPin', + '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 = IAM diff --git a/packages/libs/lib-jdcloud/src/repo/ias/v1/ias.js b/packages/libs/lib-jdcloud/src/repo/ias/v1/ias.js new file mode 100644 index 000000000..eeed2ec25 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/ias/v1/ias.js @@ -0,0 +1,1266 @@ +/* + * 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. + * + * JDCLOUD IAS Services API + * 京东云联合登陆Api + * + * 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 = 'ias' +Service._services[serviceId] = true + +/** + * ias service. + * @version 0.2.1 + */ + +JDCloud.IAS = class IAS extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'ias.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 运营后台查询app + * @param {Object} opts - parameters + * @param {string} opts.pin - pin + * @param {string} opts.appName - appName + * @param {string} opts.clientId - clientId + * @param {boolean} opts.multiTenant - multiTenant + * @param {string} opts.state - state + * @param {string} opts.scope - scope + * @param {integer} opts.startTime - startTime + * @param {integer} opts.endTime - endTime + * @param {string} opts.accountType - accountType + * @param {integer} opts.pageIndex - pageIndex + * @param {integer} opts.pageSize - pageSize + * @param {integer} opts.offset - offset + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param pagination pagination + * @param appQueryResultItem result + */ + + apps (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 apps" + ) + } + + opts = opts || {} + + if (opts.pin === undefined || opts.pin === null) { + throw new Error( + "Missing the required parameter 'opts.pin' when calling apps" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling apps" + ) + } + if (opts.clientId === undefined || opts.clientId === null) { + throw new Error( + "Missing the required parameter 'opts.clientId' when calling apps" + ) + } + if (opts.multiTenant === undefined || opts.multiTenant === null) { + throw new Error( + "Missing the required parameter 'opts.multiTenant' when calling apps" + ) + } + if (opts.state === undefined || opts.state === null) { + throw new Error( + "Missing the required parameter 'opts.state' when calling apps" + ) + } + if (opts.scope === undefined || opts.scope === null) { + throw new Error( + "Missing the required parameter 'opts.scope' when calling apps" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling apps" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling apps" + ) + } + if (opts.accountType === undefined || opts.accountType === null) { + throw new Error( + "Missing the required parameter 'opts.accountType' when calling apps" + ) + } + if (opts.pageIndex === undefined || opts.pageIndex === null) { + throw new Error( + "Missing the required parameter 'opts.pageIndex' when calling apps" + ) + } + if (opts.pageSize === undefined || opts.pageSize === null) { + throw new Error( + "Missing the required parameter 'opts.pageSize' when calling apps" + ) + } + if (opts.offset === undefined || opts.offset === null) { + throw new Error( + "Missing the required parameter 'opts.offset' when calling apps" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pin !== undefined && opts.pin !== null) { + queryParams['pin'] = opts.pin + } + if (opts.appName !== undefined && opts.appName !== null) { + queryParams['appName'] = opts.appName + } + if (opts.clientId !== undefined && opts.clientId !== null) { + queryParams['clientId'] = opts.clientId + } + if (opts.multiTenant !== undefined && opts.multiTenant !== null) { + queryParams['multiTenant'] = opts.multiTenant + } + if (opts.state !== undefined && opts.state !== null) { + queryParams['state'] = opts.state + } + if (opts.scope !== undefined && opts.scope !== null) { + queryParams['scope'] = opts.scope + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.accountType !== undefined && opts.accountType !== null) { + queryParams['accountType'] = opts.accountType + } + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.offset !== undefined && opts.offset !== null) { + queryParams['offset'] = opts.offset + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ias/0.2.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 apps 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 = this.makeRequest( + '/regions/{regionId}/operate_backend/apps', + '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.clientId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string clientId 应用 + * @param string clientName 应用名 + * @param string tokenEndpointAuthMethod tokenEndpointAuthMethod + * @param string grantTypes grantTypes + * @param string responseTypes responseTypes + * @param string redirectUris redirectUris + * @param string clientUri clientUri + * @param string logoUri logoUri + * @param string tosUri tosUri + * @param string policyUri policyUri + * @param string scope scope + * @param string jwksUri jwksUri + * @param string jwks jwks + * @param string contacts contacts + * @param string extension extension + * @param integer accessTokenValiditySeconds accessTokenValiditySeconds + * @param integer refreshTokenValiditySeconds refreshTokenValiditySeconds + * @param boolean multiTenant multiTenant + * @param integer secretUpdateTime secretUpdateTime + * @param integer updateTime updateTime + * @param integer createTime createTime + * @param string account account + * @param string userType userType + * @param string state state + */ + + appDetail (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 appDetail" + ) + } + + opts = opts || {} + + if (opts.clientId === undefined || opts.clientId === null) { + throw new Error( + "Missing the required parameter 'opts.clientId' when calling appDetail" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + clientId: opts.clientId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ias/0.2.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 appDetail 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 = this.makeRequest( + '/regions/{regionId}/operate_backend/app/{clientId}', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param state states + */ + + state (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 state" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ias/0.2.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 state 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 = this.makeRequest( + '/regions/{regionId}/operate_backend/state', + '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.clientName] - 应用名 optional + * @param {string} [opts.tokenEndpointAuthMethod] - 客户端认证方式<br> - none:不设置客户端密码(不推荐)<br> - client_secret_post:客户端必须设置密码,且该密码需要在OAuth2 Token Endpoint提供于请求的body<br> - client_secret_basic:客户端必须设置密码,且该密码需要在OAuth2 Token Endpoint提供于请求的header<br> 支持以下值:<br> (1)none<br> (2)client_secret_post<br> (3)client_secret_basic optional + * @param {string} [opts.grantTypes] - 支持的OAuth类型:<br> - authorization_code:OAuth2授权码模式<br> - implicit:OAuth2隐式授权模式<br> - refresh_token:启用刷新令牌 支持以下值:<br> (1)authorization_code<br> (2)authorization_code,refresh_token<br> (3)authorization_code,implicit<br> (4)authorization_code,implicit,refresh_token<br> (5)implicit<br> 注:如果grantTypes指定了refresh_token,应用将可以使用刷新令牌;如果在创建应用时未指定,则应用不能使用刷新令牌;任何时候应用都可以调用“更新应用”接口更改grantTypes设置 optional + * @param {string} [opts.redirectUris] - 回调地址,最多4个,多个url之间用逗号,分隔,每个url长度不超过1000,url不支持#符号 optional + * @param {string} [opts.clientUri] - 应用介绍地址,url不支持#符号 optional + * @param {string} [opts.logoUri] - 应用logo地址,url不支持#符号 optional + * @param {string} [opts.tosUri] - 应用服务协议地址,url不支持#符号 optional + * @param {string} [opts.policyUri] - 应用隐私政策地址,url不支持#符号 optional + * @param {string} [opts.scope] - OAuth scope范围,支持的值为:<br/> (1)openid:用OpenID Connect协议进行身份认证<br/> 指定scope为openid,并在Authorization Endpoint请求该scope,京东云将返回用户的OpenID令牌;如果在创建应用时未指明该值,则应用不能请求OpenID令牌;任何时候应用都可以调用“更新应用”更改该设置 optional + * @param {string} [opts.jwksUri] - JWKS地址,url不支持#符号<br/>jwksUri和jwks传一个即可 optional + * @param {string} [opts.jwks] - JWKS optional + * @param {string} [opts.contacts] - 应用联系信息 optional + * @param {string} [opts.extension] - 应用扩展信息 optional + * @param {integer} [opts.accessTokenValiditySeconds] - 访问令牌有效期,值的范围为 600 秒到 6x3600=21,600 秒,即10分钟-6小时 optional + * @param {integer} [opts.refreshTokenValiditySeconds] - 刷新令牌有效期,值的范围为 30x24x3600=2,592,000 秒到 365x24x3600=31,536,000 秒,即30天-365天<br/><br/> 注:当 GrantTypes 包含 refresh_token 时,refreshTokenValiditySeconds 为必传参数 optional + * @param {boolean} [opts.multiTenant] - 是否为多租户应用<br/> "false":该应用仅支持当前创建应用的租户访问,其他京东云租户无法访问<br/> "true":该应用支持其他京东云租户访问,但当前创建应用的租户不能访问 optional + * @param {string} [opts.secret] - 应用的密码,支持8-255位长度的ASCII可打印字符,建议使用足够复杂的密码策略<br/><br/> 注:当TokenEndpointAuthMethod不等于none时,secret为必传参数;反之,当指定了secret时,TokenEndpointAuthMethod不能等于none<br/>京东云将不可逆加密secret,因此您无法再次从京东云查看该密码,但您可以随时通过更新应用重新设置secret optional + * @param {string} [opts.userType] - 能访问应用的账号类型,支持以下值:<br/> (1)root:支持主账号访问,子用户无法访问<br/> (2)sub:子用户账号,使用主账号不能访问<br/><br/> 注:multiTenant和userType的组合指定了应用的用户人群,典型的应用场景如:<br/> (1)应用向当前租户下的子用户开放(2)应用向京东云其他租户主账号开放 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string clientId 应用ID,由京东云分配的16位数字ID + * @param string clientName clientName参数值 + * @param string tokenEndpointAuthMethod tokenEndpointAuthMethod参数值 + * @param string grantTypes grantTypes参数值 + * @param string responseTypes 当grantTypes为authorization_code时,responseTypes为code;当grantTypes为implicit时,responseTypes为token + * @param string redirectUris redirectUris参数值 + * @param string clientUri clientUri参数值 + * @param string logoUri logoUri参数值 + * @param string tosUri tosUri参数值 + * @param string policyUri policyUri参数值 + * @param string scope scope参数值 + * @param string jwksUri jwksUri参数值 + * @param string jwks jwks参数值 + * @param string contacts contacts参数值 + * @param string extension extension参数值 + * @param integer accessTokenValiditySeconds accessTokenValiditySeconds参数值 + * @param integer refreshTokenValiditySeconds refreshTokenValiditySeconds参数值 + * @param boolean multiTenant multiTenant参数值 + * @param integer secretUpdateTime secretUpdateTime参数值 + * @param integer updateTime updateTime参数值 + * @param integer createTime createTime参数值 + * @param string account 创建应用的账户用户名 + * @param string userType userType参数值 + */ + + createApp (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 createApp" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.clientName !== undefined && opts.clientName !== null) { + postBody['clientName'] = opts.clientName + } + if ( + opts.tokenEndpointAuthMethod !== undefined && + opts.tokenEndpointAuthMethod !== null + ) { + postBody['tokenEndpointAuthMethod'] = opts.tokenEndpointAuthMethod + } + if (opts.grantTypes !== undefined && opts.grantTypes !== null) { + postBody['grantTypes'] = opts.grantTypes + } + if (opts.redirectUris !== undefined && opts.redirectUris !== null) { + postBody['redirectUris'] = opts.redirectUris + } + if (opts.clientUri !== undefined && opts.clientUri !== null) { + postBody['clientUri'] = opts.clientUri + } + if (opts.logoUri !== undefined && opts.logoUri !== null) { + postBody['logoUri'] = opts.logoUri + } + if (opts.tosUri !== undefined && opts.tosUri !== null) { + postBody['tosUri'] = opts.tosUri + } + if (opts.policyUri !== undefined && opts.policyUri !== null) { + postBody['policyUri'] = opts.policyUri + } + if (opts.scope !== undefined && opts.scope !== null) { + postBody['scope'] = opts.scope + } + if (opts.jwksUri !== undefined && opts.jwksUri !== null) { + postBody['jwksUri'] = opts.jwksUri + } + if (opts.jwks !== undefined && opts.jwks !== null) { + postBody['jwks'] = opts.jwks + } + if (opts.contacts !== undefined && opts.contacts !== null) { + postBody['contacts'] = opts.contacts + } + if (opts.extension !== undefined && opts.extension !== null) { + postBody['extension'] = opts.extension + } + if ( + opts.accessTokenValiditySeconds !== undefined && + opts.accessTokenValiditySeconds !== null + ) { + postBody['accessTokenValiditySeconds'] = opts.accessTokenValiditySeconds + } + if ( + opts.refreshTokenValiditySeconds !== undefined && + opts.refreshTokenValiditySeconds !== null + ) { + postBody['refreshTokenValiditySeconds'] = opts.refreshTokenValiditySeconds + } + if (opts.multiTenant !== undefined && opts.multiTenant !== null) { + postBody['multiTenant'] = opts.multiTenant + } + if (opts.secret !== undefined && opts.secret !== null) { + postBody['secret'] = opts.secret + } + if (opts.userType !== undefined && opts.userType !== null) { + postBody['userType'] = opts.userType + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ias/0.2.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 createApp 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 = this.makeRequest( + '/regions/{regionId}/app', + '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.clientId - 应用ID,应用创建时由京东云分配的16位数字ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string clientId 应用ID,由京东云分配的16位数字ID + * @param string clientName 应用名 + * @param string tokenEndpointAuthMethod 客户端认证方式 + * @param string grantTypes 支持的OAuth类型 + * @param string responseTypes 当grantTypes为authorization_code时,responseTypes为code;当grantTypes为implicit时,responseTypes为token + * @param string redirectUris 回调地址 + * @param string clientUri 应用介绍地址 + * @param string logoUri 应用logo地址 + * @param string tosUri 应用服务协议地址 + * @param string policyUri 应用隐私条款地址 + * @param string scope OAuth scope授权范围 + * @param string jwksUri JWKS地址 + * @param string jwks JWKS + * @param string contacts 应用联系信息 + * @param string extension 应用扩展信息 + * @param integer accessTokenValiditySeconds 访问令牌有效期 + * @param integer refreshTokenValiditySeconds 刷新令牌有效期 + * @param boolean multiTenant 是否为多租户应用 + * @param integer secretUpdateTime 应用密码更新时间 + * @param integer updateTime 应用更新时间 + * @param integer createTime 应用创建时间 + * @param string account 创建应用的账户用户名 + * @param string userType 允许登录应用的账号类型 + */ + + getApp (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 getApp" + ) + } + + opts = opts || {} + + if (opts.clientId === undefined || opts.clientId === null) { + throw new Error( + "Missing the required parameter 'opts.clientId' when calling getApp" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + clientId: opts.clientId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ias/0.2.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 getApp 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 = this.makeRequest( + '/regions/{regionId}/app/{clientId}', + '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.clientId - 应用ID,应用创建时由京东云分配的16位数字ID + * @param {string} [opts.clientName] - 应用名 optional + * @param {string} [opts.tokenEndpointAuthMethod] - 客户端认证方式:<br/> none:不设置客户端密码(不推荐)<br/> client_secret_post:客户端必须设置密码,且该密码需要在OAuth2 Token Endpoint提供于请求的body<br/> client_secret_basic:客户端必须设置密码,且该密码需要在OAuth2 Token Endpoint提供于请求的header<br/><br/> 支持以下值:<br/> (1)none<br/> (2)client_secret_post<br/> (3)client_secret_basic optional + * @param {string} [opts.grantTypes] - 支持的OAuth类型:<br/> authorization_code:OAuth2授权码模式<br/> implicit:OAuth2隐式授权模式<br/> refresh_token:启用刷新令牌<br/><br/> 支持以下值:<br/> (1)authorization_code<br/> (2)authorization_code,refresh_token<br/> (3)authorization_code,implicit<br/> (4)authorization_code,implicit,refresh_token<br/> (5)implicit<br/><br/> 注:如果grantTypes指定了refresh_token,应用将可以使用刷新令牌;如果在创建应用时未指定,则应用不能使用刷新令牌;任何时候应用都可以调用“更新应用”接口更改grantTypes设置 optional + * @param {string} [opts.redirectUris] - 回调地址,最多4个,多个url之间用逗号,分隔,每个url长度不超过1000,url不支持#符号 optional + * @param {string} [opts.clientUri] - 应用介绍地址,url不支持#符号 optional + * @param {string} [opts.logoUri] - 应用logo地址,url不支持#符号 optional + * @param {string} [opts.tosUri] - 应用服务协议地址,url不支持#符号 optional + * @param {string} [opts.policyUri] - 应用隐私政策地址,url不支持#符号 optional + * @param {string} [opts.scope] - OAuth scope范围,支持的值为:<br/> (1)openid:用OpenID Connect协议进行身份认证<br/> 指定scope为openid,并在Authorization Endpoint请求该scope,京东云将返回用户的OpenID令牌;如果在创建应用时未指明该值,则应用不能请求OpenID令牌;任何时候应用都可以调用“更新应用”更改该设置 optional + * @param {string} [opts.jwksUri] - JWKS地址,url不支持#符号<br/> jwksUri和jwks传一个即可 optional + * @param {string} [opts.jwks] - JWKS optional + * @param {string} [opts.contacts] - 应用联系信息 optional + * @param {string} [opts.extension] - 应用扩展信息 optional + * @param {integer} [opts.accessTokenValiditySeconds] - 访问令牌有效期,值的范围为 600 秒到 6x3600=21,600 秒,即10分钟-6小时 optional + * @param {integer} [opts.refreshTokenValiditySeconds] - 刷新令牌有效期,值的范围为 30x24x3600=2,592,000 秒到 365x24x3600=31,536,000 秒,即30天-365天<br/><br/> 注:当 GrantTypes 包含 refresh_token 时,refreshTokenValiditySeconds 为必传参数 optional + * @param {boolean} [opts.multiTenant] - 是否为多租户应用<br/> "false":该应用仅支持当前创建应用的租户访问,其他京东云租户无法访问<br/> "true":该应用支持其他京东云租户访问,但当前创建应用的租户不能访问 optional + * @param {string} [opts.secret] - 应用的密码,支持8-255位长度的ASCII可打印字符,建议使用足够复杂的密码策略<br/><br/> 注:当TokenEndpointAuthMethod不等于none时,secret为必传参数;反之,当指定了secret时,TokenEndpointAuthMethod不能等于none<br/> 京东云将不可逆加密secret,因此您无法再次从京东云查看该密码,但您可以随时通过更新应用重新设置secret optional + * @param {string} [opts.userType] - 能访问应用的账号类型,支持以下值:<br/> (1)root:支持主账号访问,子用户无法访问<br/> (2)sub:子用户账号,使用主账号不能访问<br/><br/> 注:multiTenant和userType的组合指定了应用的用户人群,典型的应用场景如:<br/> (1)应用向当前租户下的子用户开放(2)应用向京东云其他租户主账号开放 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string clientId 应用ID,由京东云分配的16位数字ID + * @param string clientName clientName参数值 + * @param string tokenEndpointAuthMethod tokenEndpointAuthMethod参数值 + * @param string grantTypes grantTypes参数值 + * @param string responseTypes 当grantTypes为authorization_code时,responseTypes为code;当grantTypes为implicit时,responseTypes为token + * @param string redirectUris redirectUris参数值 + * @param string clientUri clientUri参数值 + * @param string logoUri logoUri参数值 + * @param string tosUri tosUri参数值 + * @param string policyUri policyUri参数值 + * @param string scope scope参数值 + * @param string jwksUri jwksUri参数值 + * @param string jwks jwks参数值 + * @param string contacts contacts参数值 + * @param string extension extension参数值 + * @param integer accessTokenValiditySeconds accessTokenValiditySeconds参数值 + * @param integer refreshTokenValiditySeconds refreshTokenValiditySeconds参数值 + * @param boolean multiTenant multiTenant参数值 + * @param integer secretUpdateTime secretUpdateTime参数值 + * @param integer updateTime updateTime参数值 + * @param integer createTime createTime参数值 + * @param string account 创建应用的账户用户名 + * @param string userType userType参数值 + */ + + updateApp (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 updateApp" + ) + } + + opts = opts || {} + + if (opts.clientId === undefined || opts.clientId === null) { + throw new Error( + "Missing the required parameter 'opts.clientId' when calling updateApp" + ) + } + + let postBody = {} + if (opts.clientName !== undefined && opts.clientName !== null) { + postBody['clientName'] = opts.clientName + } + if ( + opts.tokenEndpointAuthMethod !== undefined && + opts.tokenEndpointAuthMethod !== null + ) { + postBody['tokenEndpointAuthMethod'] = opts.tokenEndpointAuthMethod + } + if (opts.grantTypes !== undefined && opts.grantTypes !== null) { + postBody['grantTypes'] = opts.grantTypes + } + if (opts.redirectUris !== undefined && opts.redirectUris !== null) { + postBody['redirectUris'] = opts.redirectUris + } + if (opts.clientUri !== undefined && opts.clientUri !== null) { + postBody['clientUri'] = opts.clientUri + } + if (opts.logoUri !== undefined && opts.logoUri !== null) { + postBody['logoUri'] = opts.logoUri + } + if (opts.tosUri !== undefined && opts.tosUri !== null) { + postBody['tosUri'] = opts.tosUri + } + if (opts.policyUri !== undefined && opts.policyUri !== null) { + postBody['policyUri'] = opts.policyUri + } + if (opts.scope !== undefined && opts.scope !== null) { + postBody['scope'] = opts.scope + } + if (opts.jwksUri !== undefined && opts.jwksUri !== null) { + postBody['jwksUri'] = opts.jwksUri + } + if (opts.jwks !== undefined && opts.jwks !== null) { + postBody['jwks'] = opts.jwks + } + if (opts.contacts !== undefined && opts.contacts !== null) { + postBody['contacts'] = opts.contacts + } + if (opts.extension !== undefined && opts.extension !== null) { + postBody['extension'] = opts.extension + } + if ( + opts.accessTokenValiditySeconds !== undefined && + opts.accessTokenValiditySeconds !== null + ) { + postBody['accessTokenValiditySeconds'] = opts.accessTokenValiditySeconds + } + if ( + opts.refreshTokenValiditySeconds !== undefined && + opts.refreshTokenValiditySeconds !== null + ) { + postBody['refreshTokenValiditySeconds'] = opts.refreshTokenValiditySeconds + } + if (opts.multiTenant !== undefined && opts.multiTenant !== null) { + postBody['multiTenant'] = opts.multiTenant + } + if (opts.secret !== undefined && opts.secret !== null) { + postBody['secret'] = opts.secret + } + if (opts.userType !== undefined && opts.userType !== null) { + postBody['userType'] = opts.userType + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + clientId: opts.clientId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ias/0.2.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 updateApp 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 = this.makeRequest( + '/regions/{regionId}/app/{clientId}', + '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) + } + ) + } + + /** + * 删除应用 + * @param {Object} opts - parameters + * @param {string} opts.clientId - 应用ID,应用创建时由京东云分配的16位数字ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer count 删除结果[1:删除成功,0:删除失败] + */ + + deleteApp (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 deleteApp" + ) + } + + opts = opts || {} + + if (opts.clientId === undefined || opts.clientId === null) { + throw new Error( + "Missing the required parameter 'opts.clientId' when calling deleteApp" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + clientId: opts.clientId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ias/0.2.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 deleteApp 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 = this.makeRequest( + '/regions/{regionId}/app/{clientId}', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param applicationRes apps + */ + + getApps (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 getApps" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ias/0.2.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 getApps 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 = this.makeRequest( + '/regions/{regionId}/apps', + '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 = JDCloud.IAS diff --git a/packages/libs/lib-jdcloud/src/repo/industrydata/v1/industrydata.js b/packages/libs/lib-jdcloud/src/repo/industrydata/v1/industrydata.js new file mode 100644 index 000000000..82fd06f6c --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/industrydata/v1/industrydata.js @@ -0,0 +1,202 @@ +/* + * 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. + * + * 大屏数据查询接口 + * 陕西苹果大屏数据查询接口 + * + * 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 = 'industrydata' +Service._services[serviceId] = true + +/** + * industrydata service. + * @version 1.0.0 + */ + +JDCloud.INDUSTRYDATA = class INDUSTRYDATA extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'industrydata.cn-south-1.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 根据区域、行业、一级指标、二级指标、起始时间等条件查询数据 + * @param {Object} opts - parameters + * @param {string} opts.region - 查询区域,比如某某省或某某市(可选区域以最终授权为准) + * @param {string} opts.industry - 查询行业,比如某个水果或者农作物(可选行业以最终授权为准) + * @param {string} opts.startDate - 查询起始时间,格式如下:yyyy-MM-dd + * @param {string} opts.endDate - 查询结束时间,格式如下:yyyy-MM-dd + * @param {string} opts.firstIndex - 数据对应的第一级分析指标(可选一级指标以最终授权为准) + * @param {string} [opts.secondIndex] - 数据对应的第二级分析指标,如不填写,则默认把一级指标下的所有二级指标都查询出来(可选二级指标以最终授权为准) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status true为成功,false为失败 + * @param string message 描述信息 + * @param regionIndustryDataList data 查询数据结果 + */ + + getLargeScreenData (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 getLargeScreenData" + ) + } + + opts = opts || {} + + if (opts.region === undefined || opts.region === null) { + throw new Error( + "Missing the required parameter 'opts.region' when calling getLargeScreenData" + ) + } + if (opts.industry === undefined || opts.industry === null) { + throw new Error( + "Missing the required parameter 'opts.industry' when calling getLargeScreenData" + ) + } + if (opts.startDate === undefined || opts.startDate === null) { + throw new Error( + "Missing the required parameter 'opts.startDate' when calling getLargeScreenData" + ) + } + if (opts.endDate === undefined || opts.endDate === null) { + throw new Error( + "Missing the required parameter 'opts.endDate' when calling getLargeScreenData" + ) + } + if (opts.firstIndex === undefined || opts.firstIndex === null) { + throw new Error( + "Missing the required parameter 'opts.firstIndex' when calling getLargeScreenData" + ) + } + + let postBody = null + let queryParams = {} + if (opts.region !== undefined && opts.region !== null) { + queryParams['region'] = opts.region + } + if (opts.industry !== undefined && opts.industry !== null) { + queryParams['industry'] = opts.industry + } + if (opts.startDate !== undefined && opts.startDate !== null) { + queryParams['startDate'] = opts.startDate + } + if (opts.endDate !== undefined && opts.endDate !== null) { + queryParams['endDate'] = opts.endDate + } + if (opts.firstIndex !== undefined && opts.firstIndex !== null) { + queryParams['firstIndex'] = opts.firstIndex + } + if (opts.secondIndex !== undefined && opts.secondIndex !== null) { + queryParams['secondIndex'] = opts.secondIndex + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 industrydata/1.0.0' + } + + 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 getLargeScreenData 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 = this.makeRequest( + '/regions/{regionId}/getData', + '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 = JDCloud.INDUSTRYDATA diff --git a/packages/libs/lib-jdcloud/src/repo/instancevoucher/v1/instancevoucher.js b/packages/libs/lib-jdcloud/src/repo/instancevoucher/v1/instancevoucher.js new file mode 100644 index 000000000..2c064bf78 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/instancevoucher/v1/instancevoucher.js @@ -0,0 +1,883 @@ +/* + * 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. + * + * Instance-Voucher + * 实例抵扣券相关接口 + * + * 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 = 'instancevoucher' +Service._services[serviceId] = true + +/** + * instancevoucher service. + * @version 0.0.3 + */ + +class INSTANCEVOUCHER extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'instancevoucher.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询实例规格信息列表 + + * @param {Object} opts - parameters + * @param {string} [opts.resourceType] - 产品类型 支持[vm, nativecontainer, pod],默认为vm optional + * @param {string} [opts.reservedType] - 资源分配方式,支持[nonReserved] optional + * @param {filter} [opts.filters] - Filter names: (仅支持eq) +instanceType - 实例规格,精确匹配,支持多个 +instanceTypeFamily - 实例规格族,精确匹配,支持多个 +az - 可用区,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instanceVoucherType instanceVoucherTypes + */ + + describeInstanceVoucherTypes ( + 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 describeInstanceVoucherTypes" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.resourceType !== undefined && opts.resourceType !== null) { + queryParams['resourceType'] = opts.resourceType + } + if (opts.reservedType !== undefined && opts.reservedType !== null) { + queryParams['reservedType'] = opts.reservedType + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 instancevoucher/0.0.3' + } + + 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 describeInstanceVoucherTypes 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}/instanceVoucherTypes', + '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 {filter} [opts.filters] - Filter names: (仅支持eq) +resourceType - 产品类型,精确匹配,支持多个 支持[vm, nativecontainer, pod] +reservedType - 资源分配方式,精确匹配,支持多个 支持[nonReserved] + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param quota quotas + */ + + describeQuotas (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 describeQuotas" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 instancevoucher/0.0.3' + } + + 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 describeQuotas 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}/quotas', + '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> +此接口支持分页查询,默认每页20条。 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 100] optional + * @param {filter} [opts.filters] - Filter names: (仅支持eq) +instanceVoucherId - 实例ID,精确匹配,支持多个 +name - 实例名称,模糊匹配,支持多个 +resourceType - 产品类型,精确匹配,支持多个 支持[vm nativecontainer pod] +reservedType - 资源分配方式,精确匹配,支持多个 支持[nonReserved] +status - 实例抵扣券状态,精确匹配,支持多个 +instanceTypeFamily - 实例规格族,精确匹配,支持多个(适用于非预留型) + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instanceVoucher instanceVouchers + * @param integer totalCount + */ + + describeInstanceVouchers (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 describeInstanceVouchers" + ) + } + + 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 instancevoucher/0.0.3' + } + + 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 describeInstanceVouchers 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}/instanceVouchers', + '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 {instanceVoucherSpec} opts.instanceVoucherSpec - 创建实例抵扣券规格 + * @param {string} [opts.clientToken] - 保证请求幂等性 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string instanceVoucherId 实例抵扣券 ID + */ + + createInstanceVoucher (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 createInstanceVoucher" + ) + } + + opts = opts || {} + + if ( + opts.instanceVoucherSpec === undefined || + opts.instanceVoucherSpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.instanceVoucherSpec' when calling createInstanceVoucher" + ) + } + + let postBody = {} + if ( + opts.instanceVoucherSpec !== undefined && + opts.instanceVoucherSpec !== null + ) { + postBody['instanceVoucherSpec'] = opts.instanceVoucherSpec + } + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 instancevoucher/0.0.3' + } + + 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 createInstanceVoucher 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}/instanceVouchers', + '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.instanceVoucherId - 实例抵扣券 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instanceVoucher instanceVoucher + */ + + describeInstanceVoucher (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 describeInstanceVoucher" + ) + } + + opts = opts || {} + + if ( + opts.instanceVoucherId === undefined || + opts.instanceVoucherId === null + ) { + throw new Error( + "Missing the required parameter 'opts.instanceVoucherId' when calling describeInstanceVoucher" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceVoucherId: opts.instanceVoucherId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 instancevoucher/0.0.3' + } + + 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 describeInstanceVoucher 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}/instanceVouchers/{instanceVoucherId}', + '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.instanceVoucherId - 实例抵扣券 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteInstanceVoucher (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 deleteInstanceVoucher" + ) + } + + opts = opts || {} + + if ( + opts.instanceVoucherId === undefined || + opts.instanceVoucherId === null + ) { + throw new Error( + "Missing the required parameter 'opts.instanceVoucherId' when calling deleteInstanceVoucher" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceVoucherId: opts.instanceVoucherId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 instancevoucher/0.0.3' + } + + 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 deleteInstanceVoucher 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}/instanceVouchers/{instanceVoucherId}', + '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> +name 和 description 必须要指定一个 + + * @param {Object} opts - parameters + * @param {string} opts.instanceVoucherId - 实例抵扣券 ID + * @param {string} [opts.name] - 实例抵扣券名称 optional + * @param {string} [opts.description] - 实例抵扣券描述 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyInstanceVoucherAttribute ( + 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 modifyInstanceVoucherAttribute" + ) + } + + opts = opts || {} + + if ( + opts.instanceVoucherId === undefined || + opts.instanceVoucherId === null + ) { + throw new Error( + "Missing the required parameter 'opts.instanceVoucherId' when calling modifyInstanceVoucherAttribute" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceVoucherId: opts.instanceVoucherId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 instancevoucher/0.0.3' + } + + 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 modifyInstanceVoucherAttribute 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}/instanceVouchers/{instanceVoucherId}:modifyInstanceVoucherAttribute', + 'PATCH', + 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 = INSTANCEVOUCHER diff --git a/packages/libs/lib-jdcloud/src/repo/invoice/v2/invoice.js b/packages/libs/lib-jdcloud/src/repo/invoice/v2/invoice.js new file mode 100644 index 000000000..d8a316a5e --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/invoice/v2/invoice.js @@ -0,0 +1,4708 @@ +/* + * 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. + * + * JDCLOUD Invoice API + * 京东云发票 + * + * 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 = 'invoice' +Service._services[serviceId] = true + +/** + * invoice service. + * @version 0.4.11 + */ + +class INVOICE extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'ivoice.jdcloud-api.com' + options.basePath = '/v2' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询发票邮寄地址列表 + * @param {Object} opts - parameters + * @param {string} [opts.pin] - 用户pin(运营后台必传) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param postAddress addresses + */ + + describeAddresses (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 describeAddresses" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.pin !== undefined && opts.pin !== null) { + queryParams['pin'] = opts.pin + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 describeAddresses 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}/addresses', + '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.parentId + * @param {string} [opts.pin] - 用户pin optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param area addresses + */ + + describeChildrenArea (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 describeChildrenArea" + ) + } + + opts = opts || {} + + if (opts.parentId === undefined || opts.parentId === null) { + throw new Error( + "Missing the required parameter 'opts.parentId' when calling describeChildrenArea" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pin !== undefined && opts.pin !== null) { + queryParams['pin'] = opts.pin + } + + let pathParams = { + regionId: regionId, + parentId: opts.parentId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 describeChildrenArea 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}/areas/{parentId}', + '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.id + * @param {string} [opts.pin] - 用户pin(运营后台必传) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer id id + * @param string name 收件人姓名 + * @param string phone 收件人电话 + * @param string province 省 + * @param string city 市 + * @param string county 区 + * @param string town 县 + * @param string address 邮编 + * @param integer isDefault 是否默认收货地址 + * @param string updateTime 更新时间 + * @param string pin 用户pin + * @param string createTime 创建时间 + * @param string zipCode 邮编 + * @param integer provinceId 省id + * @param integer cityId 市id + * @param integer countyId 区县id + * @param integer townId 乡镇id + */ + + describeAddress (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 describeAddress" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling describeAddress" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pin !== undefined && opts.pin !== null) { + queryParams['pin'] = opts.pin + } + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 describeAddress 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}/address/{id}', + '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.id + * @param {integer} [opts.id] - id optional + * @param {string} [opts.name] - 收件人姓名 optional + * @param {string} [opts.phone] - 收件人电话 optional + * @param {string} [opts.province] - 省 optional + * @param {string} [opts.city] - 市 optional + * @param {string} [opts.county] - 区 optional + * @param {string} [opts.town] - 县 optional + * @param {string} [opts.address] - 邮编 optional + * @param {integer} [opts.isDefault] - 是否默认收货地址 optional + * @param {string} [opts.updateTime] - 更新时间 optional + * @param {string} [opts.pin] - 用户pin optional + * @param {string} [opts.createTime] - 创建时间 optional + * @param {string} [opts.zipCode] - 邮编 optional + * @param {integer} [opts.provinceId] - 省id optional + * @param {integer} [opts.cityId] - 市id optional + * @param {integer} [opts.countyId] - 区县id optional + * @param {integer} [opts.townId] - 乡镇id optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code [0成功] + * @param string msg [msg=success成功] + */ + + modifyAddress (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 modifyAddress" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling modifyAddress" + ) + } + + let postBody = {} + if (opts.id !== undefined && opts.id !== null) { + postBody['id'] = opts.id + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.phone !== undefined && opts.phone !== null) { + postBody['phone'] = opts.phone + } + if (opts.province !== undefined && opts.province !== null) { + postBody['province'] = opts.province + } + if (opts.city !== undefined && opts.city !== null) { + postBody['city'] = opts.city + } + if (opts.county !== undefined && opts.county !== null) { + postBody['county'] = opts.county + } + if (opts.town !== undefined && opts.town !== null) { + postBody['town'] = opts.town + } + if (opts.address !== undefined && opts.address !== null) { + postBody['address'] = opts.address + } + if (opts.isDefault !== undefined && opts.isDefault !== null) { + postBody['isDefault'] = opts.isDefault + } + if (opts.updateTime !== undefined && opts.updateTime !== null) { + postBody['updateTime'] = opts.updateTime + } + if (opts.pin !== undefined && opts.pin !== null) { + postBody['pin'] = opts.pin + } + if (opts.createTime !== undefined && opts.createTime !== null) { + postBody['createTime'] = opts.createTime + } + if (opts.zipCode !== undefined && opts.zipCode !== null) { + postBody['zipCode'] = opts.zipCode + } + if (opts.provinceId !== undefined && opts.provinceId !== null) { + postBody['provinceId'] = opts.provinceId + } + if (opts.cityId !== undefined && opts.cityId !== null) { + postBody['cityId'] = opts.cityId + } + if (opts.countyId !== undefined && opts.countyId !== null) { + postBody['countyId'] = opts.countyId + } + if (opts.townId !== undefined && opts.townId !== null) { + postBody['townId'] = opts.townId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 modifyAddress 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}/address/{id}', + '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) + } + ) + } + + /** + * 删除发票邮寄地址 + * @param {Object} opts - parameters + * @param {integer} opts.id + * @param {string} [opts.pin] - 用户pin(运营后台必传) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code [0成功] + * @param string msg [msg=success成功] + */ + + deleteAddress (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 deleteAddress" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling deleteAddress" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pin !== undefined && opts.pin !== null) { + queryParams['pin'] = opts.pin + } + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 deleteAddress 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}/address/{id}', + '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.id] - id optional + * @param {string} [opts.name] - 收件人姓名 optional + * @param {string} [opts.phone] - 收件人电话 optional + * @param {string} [opts.province] - 省 optional + * @param {string} [opts.city] - 市 optional + * @param {string} [opts.county] - 区 optional + * @param {string} [opts.town] - 县 optional + * @param {string} [opts.address] - 邮编 optional + * @param {integer} [opts.isDefault] - 是否默认收货地址 optional + * @param {string} [opts.updateTime] - 更新时间 optional + * @param {string} [opts.pin] - 用户pin optional + * @param {string} [opts.createTime] - 创建时间 optional + * @param {string} [opts.zipCode] - 邮编 optional + * @param {integer} [opts.provinceId] - 省id optional + * @param {integer} [opts.cityId] - 市id optional + * @param {integer} [opts.countyId] - 区县id optional + * @param {integer} [opts.townId] - 乡镇id optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code [0成功] + * @param string msg [msg=success成功] + */ + + createAddress (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 createAddress" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.id !== undefined && opts.id !== null) { + postBody['id'] = opts.id + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.phone !== undefined && opts.phone !== null) { + postBody['phone'] = opts.phone + } + if (opts.province !== undefined && opts.province !== null) { + postBody['province'] = opts.province + } + if (opts.city !== undefined && opts.city !== null) { + postBody['city'] = opts.city + } + if (opts.county !== undefined && opts.county !== null) { + postBody['county'] = opts.county + } + if (opts.town !== undefined && opts.town !== null) { + postBody['town'] = opts.town + } + if (opts.address !== undefined && opts.address !== null) { + postBody['address'] = opts.address + } + if (opts.isDefault !== undefined && opts.isDefault !== null) { + postBody['isDefault'] = opts.isDefault + } + if (opts.updateTime !== undefined && opts.updateTime !== null) { + postBody['updateTime'] = opts.updateTime + } + if (opts.pin !== undefined && opts.pin !== null) { + postBody['pin'] = opts.pin + } + if (opts.createTime !== undefined && opts.createTime !== null) { + postBody['createTime'] = opts.createTime + } + if (opts.zipCode !== undefined && opts.zipCode !== null) { + postBody['zipCode'] = opts.zipCode + } + if (opts.provinceId !== undefined && opts.provinceId !== null) { + postBody['provinceId'] = opts.provinceId + } + if (opts.cityId !== undefined && opts.cityId !== null) { + postBody['cityId'] = opts.cityId + } + if (opts.countyId !== undefined && opts.countyId !== null) { + postBody['countyId'] = opts.countyId + } + if (opts.townId !== undefined && opts.townId !== null) { + postBody['townId'] = opts.townId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 createAddress 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}/address:add', + '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.pin - 用户pin + * @param {string} [opts.orderNumber] - 订单号 optional + * @param {integer} opts.pageIndex - 页码(默认1) + * @param {integer} opts.pageSize - 每页展示数据量(默认:10) + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param number enableInvoiceFee 可开票金额 + * @param number oweInvoiceFee 发票金额 + * @param boolean isSetInvoiceMSGTemplate 是否设置过有效的发票信息 + * @param invoiceOrderItem invoiceOrderList + */ + + describeInvoiceOrderList (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 describeInvoiceOrderList" + ) + } + + opts = opts || {} + + if (opts.pin === undefined || opts.pin === null) { + throw new Error( + "Missing the required parameter 'opts.pin' when calling describeInvoiceOrderList" + ) + } + if (opts.pageIndex === undefined || opts.pageIndex === null) { + throw new Error( + "Missing the required parameter 'opts.pageIndex' when calling describeInvoiceOrderList" + ) + } + if (opts.pageSize === undefined || opts.pageSize === null) { + throw new Error( + "Missing the required parameter 'opts.pageSize' when calling describeInvoiceOrderList" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pin !== undefined && opts.pin !== null) { + queryParams['pin'] = opts.pin + } + if (opts.orderNumber !== undefined && opts.orderNumber !== null) { + queryParams['orderNumber'] = opts.orderNumber + } + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 describeInvoiceOrderList 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}/describeInvoiceOrderList', + '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.orderIds] - 需要开票的订单号列表,以逗号分隔 optional + * @param {string} [opts.deductOrderIds] - 抵扣单据单号列表,以逗号分隔 optional + * @param {string} [opts.mediumType] - 发票类型[电子-electronic] optional + * @param {string} [opts.createInvoiceType] - 开票类型[按明细开票-consume,按月账单开票-month,指定金额开票-money(mediumType=paper生效)] optional + * @param {integer} [opts.invoiceAll] - 是否全部开票[全部开票-1 不需要传orderIds 需要传 开始、结束时间] optional + * @param {string} [opts.orderStartTime] - 开票订单的开始时间(开票标识为 全部开票 时不需要传) optional + * @param {string} [opts.orderEndTime] - 开票订单的结束时间(开票标识为 全部开票 时不需要传) optional + * @param {string} [opts.monthGroups] - 开票月份 仅按月账单开票生效 例(202407,202406)多个月份用逗号分隔 optional + * @param {number} [opts.amount] - 指定金额开票时 传入金额 开票类型=money时必传 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code [0成功] + * @param string msg [msg=success成功] + */ + + createInvoiceAgent (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 createInvoiceAgent" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.orderIds !== undefined && opts.orderIds !== null) { + postBody['orderIds'] = opts.orderIds + } + if (opts.deductOrderIds !== undefined && opts.deductOrderIds !== null) { + postBody['deductOrderIds'] = opts.deductOrderIds + } + if (opts.mediumType !== undefined && opts.mediumType !== null) { + postBody['mediumType'] = opts.mediumType + } + if ( + opts.createInvoiceType !== undefined && + opts.createInvoiceType !== null + ) { + postBody['createInvoiceType'] = opts.createInvoiceType + } + if (opts.invoiceAll !== undefined && opts.invoiceAll !== null) { + postBody['invoiceAll'] = opts.invoiceAll + } + if (opts.orderStartTime !== undefined && opts.orderStartTime !== null) { + postBody['orderStartTime'] = opts.orderStartTime + } + if (opts.orderEndTime !== undefined && opts.orderEndTime !== null) { + postBody['orderEndTime'] = opts.orderEndTime + } + if (opts.monthGroups !== undefined && opts.monthGroups !== null) { + postBody['monthGroups'] = opts.monthGroups + } + if (opts.amount !== undefined && opts.amount !== null) { + postBody['amount'] = opts.amount + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 createInvoiceAgent 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}/createInvoiceAgent', + '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.invoiceType] - 发票类型:[个人增值税普通发票-Personal_VAT_Ordinary_Invoice,企业增值税专用发票-Enterprise_VAT_Special_Invoice,企业增值税普通发票-Enterprise_VAT_Ordinary_Invoice] optional + * @param {string} [opts.invoiceTitle] - 发票抬头 optional + * @param {string} [opts.invoiceContent] - 开票内容(按类别开票/按明细开票) optional + * @param {string} [opts.taxId] - 纳税人识别码(发票类型为企业增值税专用发票和企业增值税普通发票时必填) optional + * @param {string} [opts.company] - 单位名称(发票类型为企业增值税专用发票时必填) optional + * @param {string} [opts.phone] - 注册电话(发票类型为个人增值税普通发票和企业增值税普通发票时作为收票人手机号) optional + * @param {string} [opts.bank] - 开户银行(发票类型为企业增值税专用发票时必填) optional + * @param {string} [opts.account] - 银行账户(发票类型为企业增值税专用发票时必填) optional + * @param {string} [opts.address] - 注册地址(发票类型为企业增值税专用发票时必填) optional + * @param {string} [opts.email] - 邮箱 optional + * @param {string} [opts.mediumType] - [电子-electronic] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code + * @param string msg + */ + + editInvoiceTemplate (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 editInvoiceTemplate" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.invoiceType !== undefined && opts.invoiceType !== null) { + postBody['invoiceType'] = opts.invoiceType + } + if (opts.invoiceTitle !== undefined && opts.invoiceTitle !== null) { + postBody['invoiceTitle'] = opts.invoiceTitle + } + if (opts.invoiceContent !== undefined && opts.invoiceContent !== null) { + postBody['invoiceContent'] = opts.invoiceContent + } + if (opts.taxId !== undefined && opts.taxId !== null) { + postBody['taxId'] = opts.taxId + } + if (opts.company !== undefined && opts.company !== null) { + postBody['company'] = opts.company + } + if (opts.phone !== undefined && opts.phone !== null) { + postBody['phone'] = opts.phone + } + if (opts.bank !== undefined && opts.bank !== null) { + postBody['bank'] = opts.bank + } + if (opts.account !== undefined && opts.account !== null) { + postBody['account'] = opts.account + } + if (opts.address !== undefined && opts.address !== null) { + postBody['address'] = opts.address + } + if (opts.email !== undefined && opts.email !== null) { + postBody['email'] = opts.email + } + if (opts.mediumType !== undefined && opts.mediumType !== null) { + postBody['mediumType'] = opts.mediumType + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 editInvoiceTemplate 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}/editInvoiceTemplate', + '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) + } + ) + } + + /** + * 查询已开票的子单 + * @param {Object} opts - parameters + * @param {string} [opts.pin] - 用户pin optional + * @param {array} [opts.childOrderList] - 子单列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string result + */ + + decribeInvoicedChildOrders (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 decribeInvoicedChildOrders" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.pin !== undefined && opts.pin !== null) { + postBody['pin'] = opts.pin + } + if (opts.childOrderList !== undefined && opts.childOrderList !== null) { + postBody['childOrderList'] = opts.childOrderList + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 decribeInvoicedChildOrders 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}/invoices:decribeInvoicedChildOrders', + '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.status] - 发票状态[已申请-applied ,处理中-processing ,已开票-invoiced ,已邮寄-mailed ,已驳回-dismissed ,已作废-obsolete ,已取消-cancelled,退票中-refund,已退票-refunded,退票驳回-refund_rejected] optional + * @param {string} [opts.searchStartDate] - 开始时间 optional + * @param {string} [opts.searchEndDate] - 结束时间 optional + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 页大小 optional + * @param {integer} [opts.invoiceType] - 按明细开票 1 按月结算单开票 2 按指定金额开票 3 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param number enableInvoiceFee 可开票金额 + * @param number invoicedFee 发票金额 + * @param boolean isSetInvoiceMSGTemplate 是否设置过有效的发票信息 + * @param invoiceList invoiceList + * @param boolean isApplyInvoice 是否可开票 + * @param invoices invoiceSearch + */ + + describeInvoices (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 describeInvoices" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + if (opts.searchStartDate !== undefined && opts.searchStartDate !== null) { + postBody['searchStartDate'] = opts.searchStartDate + } + if (opts.searchEndDate !== undefined && opts.searchEndDate !== null) { + postBody['searchEndDate'] = opts.searchEndDate + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + if (opts.invoiceType !== undefined && opts.invoiceType !== null) { + postBody['invoiceType'] = opts.invoiceType + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 describeInvoices 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}/invoices', + '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.invoiceNumber - 发票申请单号 + * @param {integer} opts.pageIndex - 页码(默认1) + * @param {integer} opts.pageSize - 每页展示数据量(默认:20) + * @param {integer} [opts.invoiceType] - 发票类型 1详情 2按月 optional + * @param {string} [opts.pin] - 用户pin optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer id id + * @param string invoiceNumber 发票申请单号 + * @param string pin 用户pin + * @param string invoiceType 发票类型[个人增值税普通发票-Personal_VAT_Ordinary_Invoice,企业增值税专用发票-Enterprise_VAT_Special_Invoice,企业增值税普通发票-Enterprise_VAT_Ordinary_Invoice] + * @param string invoiceTitle 发票抬头 + * @param string taxNo 税号 + * @param number totalPrice 总价 + * @param string remark remark + * @param string invoiceContent 发票内容 + * @param integer userType 用户类型 + * @param integer addressId 地址ID + * @param integer transportId transportId + * @param string createTime 创建日期 + * @param string updateTime 更新日期 + * @param string status 状态[已申请-applied ,处理中-processing ,已开票-invoiced ,已邮寄-mailed ,已驳回-dismissed ,已作废-obsolete ,已取消-cancelled] + * @param string billingTime 计费日期 + * @param string reason 原因 + * @param string invoiceOrg invoiceOrg + * @param string registerAddress 注册地址 + * @param string registerPhone 注册电话 + * @param string accountBank 账户银行 + * @param string account 账户 + * @param string mediumType 类型[纸质-paper,电子-electronic, digital-数电发票] + * @param string pdfUrl 发票PDF文件链接地址 + * @param string xmlUrl 发票xml文件链接地址 + * @param string ofdUrl 发票ofd文件链接地址 + * @param logistics logistics 物流信息 + * @param postAddress postAddress 邮寄地址 + * @param invoiceOrder invoiceOrders + * @param monthGroupOrder monthGroupOrders + * @param integer isHistoryData 区分是否历史数据(1-是 0-否) + */ + + describeInvoice (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 describeInvoice" + ) + } + + opts = opts || {} + + if (opts.invoiceNumber === undefined || opts.invoiceNumber === null) { + throw new Error( + "Missing the required parameter 'opts.invoiceNumber' when calling describeInvoice" + ) + } + if (opts.pageIndex === undefined || opts.pageIndex === null) { + throw new Error( + "Missing the required parameter 'opts.pageIndex' when calling describeInvoice" + ) + } + if (opts.pageSize === undefined || opts.pageSize === null) { + throw new Error( + "Missing the required parameter 'opts.pageSize' when calling describeInvoice" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.invoiceType !== undefined && opts.invoiceType !== null) { + queryParams['invoiceType'] = opts.invoiceType + } + if (opts.pin !== undefined && opts.pin !== null) { + queryParams['pin'] = opts.pin + } + + let pathParams = { + regionId: regionId, + invoiceNumber: opts.invoiceNumber + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 describeInvoice 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}/invoice/{invoiceNumber}', + '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.billId - 计费账单编号 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param billDataList billDataList + */ + + billDetail (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 billDetail" + ) + } + + opts = opts || {} + + if (opts.billId === undefined || opts.billId === null) { + throw new Error( + "Missing the required parameter 'opts.billId' when calling billDetail" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + billId: opts.billId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 billDetail 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}/billDetail/{billId}', + '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.enterpriseName - 企业名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string creditCode 统一社会信用代码 + * @param string registerAddress 注册地址 + * @param string registerPhone 注册电话 + * @param string entName 企业名称 + * @param string entType 企业类型 + */ + + getCompanyCreditInfo (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 getCompanyCreditInfo" + ) + } + + opts = opts || {} + + if (opts.enterpriseName === undefined || opts.enterpriseName === null) { + throw new Error( + "Missing the required parameter 'opts.enterpriseName' when calling getCompanyCreditInfo" + ) + } + + let postBody = null + let queryParams = {} + if (opts.enterpriseName !== undefined && opts.enterpriseName !== null) { + queryParams['enterpriseName'] = opts.enterpriseName + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 getCompanyCreditInfo 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}/getCompanyCreditInfo', + '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.orderId - 订单号 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean existed 是否存在关联发票 + * @param string invoiceNumbers 关联发票号 + */ + + getOrderRelateInvoice (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 getOrderRelateInvoice" + ) + } + + opts = opts || {} + + if (opts.orderId === undefined || opts.orderId === null) { + throw new Error( + "Missing the required parameter 'opts.orderId' when calling getOrderRelateInvoice" + ) + } + + let postBody = null + let queryParams = {} + if (opts.orderId !== undefined && opts.orderId !== null) { + queryParams['orderId'] = opts.orderId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 getOrderRelateInvoice 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}/getOrderRelateInvoice', + '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.orderId - 订单号 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean hasInvoice 是否存在关联发票 + * @param string invoiceNumbers 关联发票号 + * @param boolean hasOweTicket 是否关联欠票 + */ + + getOrderRelateInfo (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 getOrderRelateInfo" + ) + } + + opts = opts || {} + + if (opts.orderId === undefined || opts.orderId === null) { + throw new Error( + "Missing the required parameter 'opts.orderId' when calling getOrderRelateInfo" + ) + } + + let postBody = null + let queryParams = {} + if (opts.orderId !== undefined && opts.orderId !== null) { + queryParams['orderId'] = opts.orderId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 getOrderRelateInfo 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}/getOrderRelateInfo', + '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.orderIds] - 需要开票的订单号列表,以逗号分隔 optional + * @param {string} [opts.deductOrderIds] - 抵扣单据单号列表,以逗号分隔 optional + * @param {string} [opts.mediumType] - 发票类型[电子-electronic] optional + * @param {string} [opts.createInvoiceType] - 开票类型[按明细开票-consume,按月账单开票-month,指定金额开票-money(mediumType=paper生效)] optional + * @param {integer} [opts.invoiceAll] - 是否全部开票[全部开票-1 不需要传orderIds 需要传 开始、结束时间] optional + * @param {string} [opts.orderStartTime] - 开票订单的开始时间(开票标识为 全部开票 时不需要传) optional + * @param {string} [opts.orderEndTime] - 开票订单的结束时间(开票标识为 全部开票 时不需要传) optional + * @param {string} [opts.monthGroups] - 开票月份 仅按月账单开票生效 例(202407,202406)多个月份用逗号分隔 optional + * @param {number} [opts.amount] - 指定金额开票时 传入金额 开票类型=money时必传 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code [0成功] + * @param string msg [msg=success成功] + */ + + createInvoice (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 createInvoice" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.orderIds !== undefined && opts.orderIds !== null) { + postBody['orderIds'] = opts.orderIds + } + if (opts.deductOrderIds !== undefined && opts.deductOrderIds !== null) { + postBody['deductOrderIds'] = opts.deductOrderIds + } + if (opts.mediumType !== undefined && opts.mediumType !== null) { + postBody['mediumType'] = opts.mediumType + } + if ( + opts.createInvoiceType !== undefined && + opts.createInvoiceType !== null + ) { + postBody['createInvoiceType'] = opts.createInvoiceType + } + if (opts.invoiceAll !== undefined && opts.invoiceAll !== null) { + postBody['invoiceAll'] = opts.invoiceAll + } + if (opts.orderStartTime !== undefined && opts.orderStartTime !== null) { + postBody['orderStartTime'] = opts.orderStartTime + } + if (opts.orderEndTime !== undefined && opts.orderEndTime !== null) { + postBody['orderEndTime'] = opts.orderEndTime + } + if (opts.monthGroups !== undefined && opts.monthGroups !== null) { + postBody['monthGroups'] = opts.monthGroups + } + if (opts.amount !== undefined && opts.amount !== null) { + postBody['amount'] = opts.amount + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 createInvoice 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}/invoice', + '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.invoiceNumber - 发票申请单号 + * @param {string} [opts.refundReason] - 退票原因 optional + * @param {string} [opts.remark] - 备注信息 optional + * @param {string} [opts.logisticsCompany] - 物流公司 optional + * @param {string} [opts.logisticsOrderNumber] - 物流单号 optional + * @param {string} [opts.mediumType] - [纸质-paper,电子-electronic] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code [0成功] + * @param string msg [msg=success成功] + */ + + refundInvoice (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 refundInvoice" + ) + } + + opts = opts || {} + + if (opts.invoiceNumber === undefined || opts.invoiceNumber === null) { + throw new Error( + "Missing the required parameter 'opts.invoiceNumber' when calling refundInvoice" + ) + } + + let postBody = {} + if (opts.refundReason !== undefined && opts.refundReason !== null) { + postBody['refundReason'] = opts.refundReason + } + if (opts.remark !== undefined && opts.remark !== null) { + postBody['remark'] = opts.remark + } + if (opts.logisticsCompany !== undefined && opts.logisticsCompany !== null) { + postBody['logisticsCompany'] = opts.logisticsCompany + } + if ( + opts.logisticsOrderNumber !== undefined && + opts.logisticsOrderNumber !== null + ) { + postBody['logisticsOrderNumber'] = opts.logisticsOrderNumber + } + if (opts.mediumType !== undefined && opts.mediumType !== null) { + postBody['mediumType'] = opts.mediumType + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + invoiceNumber: opts.invoiceNumber + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 refundInvoice 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}/invoice/{invoiceNumber}:refund', + '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.orderId] - 退款订单号 optional + * @param {string} [opts.refundAmount] - 退款金额 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code [0成功] + * @param string msg [msg=success成功] + */ + + artificialRefund (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 artificialRefund" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.orderId !== undefined && opts.orderId !== null) { + postBody['orderId'] = opts.orderId + } + if (opts.refundAmount !== undefined && opts.refundAmount !== null) { + postBody['refundAmount'] = opts.refundAmount + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 artificialRefund 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}/invoiceorder:artificialRefund', + '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.invoiceNumber - 发票申请单号 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code [0成功] + * @param string msg [msg=success成功] + */ + + cancelInvoice (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 cancelInvoice" + ) + } + + opts = opts || {} + + if (opts.invoiceNumber === undefined || opts.invoiceNumber === null) { + throw new Error( + "Missing the required parameter 'opts.invoiceNumber' when calling cancelInvoice" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + invoiceNumber: opts.invoiceNumber + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 cancelInvoice 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}/invoice/{invoiceNumber}:cancel', + '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.businessId] - 订单号或者申请单号 optional + * @param {string} [opts.ivcCode] - 发票代码 optional + * @param {string} [opts.ivcNo] - 发票号码 optional + * @param {string} [opts.wid] - 商品编号 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code + * @param string msg + * @param string result + */ + + describeInvoiceUrl (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 describeInvoiceUrl" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.businessId !== undefined && opts.businessId !== null) { + postBody['businessId'] = opts.businessId + } + if (opts.ivcCode !== undefined && opts.ivcCode !== null) { + postBody['ivcCode'] = opts.ivcCode + } + if (opts.ivcNo !== undefined && opts.ivcNo !== null) { + postBody['ivcNo'] = opts.ivcNo + } + if (opts.wid !== undefined && opts.wid !== null) { + postBody['wid'] = opts.wid + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 describeInvoiceUrl 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}/invoice:downloadurl', + '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.searchStartTime] - 开始时间 optional + * @param {string} [opts.searchEndTime] - 结束时间 optional + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 页大小 optional + * @param {string} [opts.receiptType] - 单据类型[订单-order,账单-bill 月结算单-month] optional + * @param {integer} [opts.payType] - 交易(支付)类型 1-代付 2-自付 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param number enableInvoiceFee 可开票金额 + * @param number enableAllInvoiceFee 可开票总金额 + * @param number oweInvoiceFee 发票金额 + * @param boolean isSetInvoiceMSGTemplate 是否设置过有效的发票信息 + * @param invoiceOrderItem invoiceOrderList + */ + + describeInvoiceOrders (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 describeInvoiceOrders" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.searchStartTime !== undefined && opts.searchStartTime !== null) { + postBody['searchStartTime'] = opts.searchStartTime + } + if (opts.searchEndTime !== undefined && opts.searchEndTime !== null) { + postBody['searchEndTime'] = opts.searchEndTime + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + if (opts.receiptType !== undefined && opts.receiptType !== null) { + postBody['receiptType'] = opts.receiptType + } + if (opts.payType !== undefined && opts.payType !== null) { + postBody['payType'] = opts.payType + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 describeInvoiceOrders 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}/invoiceorder:list', + '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.pin] - 用户pin optional + * @param {integer} [opts.pageIndex] - 页码 optional + * @param {integer} [opts.pageSize] - 页大小 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param number oweFee 欠票总金额 + * @param invoiceOweList invoiceOweList + */ + + invoiceOweList (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 invoiceOweList" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.pin !== undefined && opts.pin !== null) { + postBody['pin'] = opts.pin + } + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + postBody['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 invoiceOweList 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}/invoiceOweList', + '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.orderIds] - 抵扣订单号 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code [0成功] + * @param string msg [msg=success成功] + */ + + deductOweFee (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 deductOweFee" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.orderIds !== undefined && opts.orderIds !== null) { + postBody['orderIds'] = opts.orderIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 deductOweFee 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}/deductOweFee', + '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.serviceCode - 产品线 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param taxInfo result + */ + + getTaxInfo (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 getTaxInfo" + ) + } + + opts = opts || {} + + if (opts.serviceCode === undefined || opts.serviceCode === null) { + throw new Error( + "Missing the required parameter 'opts.serviceCode' when calling getTaxInfo" + ) + } + + let postBody = null + let queryParams = {} + if (opts.serviceCode !== undefined && opts.serviceCode !== null) { + queryParams['serviceCode'] = opts.serviceCode + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 getTaxInfo 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}/getTaxInfo', + '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.pin] - 用户pin optional + * @param {string} [opts.orderIds] - 订单号 多个用逗号,分开 optional + * @param {array} [opts.deductInfoList] - 欠票抵扣的订单信息 optional + * @param {number} [opts.amount] - 指定开票金额 optional + * @param {string} [opts.monthGroups] - 开票月份 仅按月开票生效 optional + * @param {string} [opts.mediumType] - 发票类型[电子-electronic, 数电-digital] optional + * @param {integer} [opts.invoiceAll] - 全部开票标识 1-全部开票 全部开票, 不需要传orderIds 需要传 开始、结束时间 optional + * @param {string} [opts.orderStartTime] - 开票订单的开始时间(yyyy-MM-dd HH:mm:ss) optional + * @param {string} [opts.orderEndTime] - 开票订单的结束时间(yyyy-MM-dd HH:mm:ss) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param invoicePreviewRespVo result + */ + + getInvoicePreview (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 getInvoicePreview" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.pin !== undefined && opts.pin !== null) { + postBody['pin'] = opts.pin + } + if (opts.orderIds !== undefined && opts.orderIds !== null) { + postBody['orderIds'] = opts.orderIds + } + if (opts.deductInfoList !== undefined && opts.deductInfoList !== null) { + postBody['deductInfoList'] = opts.deductInfoList + } + if (opts.amount !== undefined && opts.amount !== null) { + postBody['amount'] = opts.amount + } + if (opts.monthGroups !== undefined && opts.monthGroups !== null) { + postBody['monthGroups'] = opts.monthGroups + } + if (opts.mediumType !== undefined && opts.mediumType !== null) { + postBody['mediumType'] = opts.mediumType + } + if (opts.invoiceAll !== undefined && opts.invoiceAll !== null) { + postBody['invoiceAll'] = opts.invoiceAll + } + if (opts.orderStartTime !== undefined && opts.orderStartTime !== null) { + postBody['orderStartTime'] = opts.orderStartTime + } + if (opts.orderEndTime !== undefined && opts.orderEndTime !== null) { + postBody['orderEndTime'] = opts.orderEndTime + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 getInvoicePreview 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}/getInvoicePreview', + '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 {number} [opts.amount] - 预开票总金额(不传则简单计算金额) optional + * @param {array} [opts.orderInfo] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param orderInfoRes result + */ + + calculateInvoicePrice (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 calculateInvoicePrice" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.amount !== undefined && opts.amount !== null) { + postBody['amount'] = opts.amount + } + if (opts.orderInfo !== undefined && opts.orderInfo !== null) { + postBody['orderInfo'] = opts.orderInfo + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 calculateInvoicePrice 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}/calculateInvoicePrice', + '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.month - 发票月份 yyyy-MM + * @param {string} [opts.pin] - 用户pin optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param invoiceDetails result + */ + + describeMonthDetail (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 describeMonthDetail" + ) + } + + opts = opts || {} + + if (opts.month === undefined || opts.month === null) { + throw new Error( + "Missing the required parameter 'opts.month' when calling describeMonthDetail" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pin !== undefined && opts.pin !== null) { + queryParams['pin'] = opts.pin + } + + let pathParams = { + regionId: regionId, + month: opts.month + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 describeMonthDetail 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}/invoiceorder/{month}', + '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.pin] - 用户pin(运营后台必传) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param vat vat vat + * @param invoiceMsgTemplate invoiceMsgTemplate 发票抬头信息 + */ + + describeInvoiceTemplate (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 describeInvoiceTemplate" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.pin !== undefined && opts.pin !== null) { + queryParams['pin'] = opts.pin + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 describeInvoiceTemplate 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}/invoiceTemplate', + '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.invoiceType] - 发票类型:[个人增值税普通发票-Personal_VAT_Ordinary_Invoice,企业增值税专用发票-Enterprise_VAT_Special_Invoice,企业增值税普通发票-Enterprise_VAT_Ordinary_Invoice] optional + * @param {string} [opts.invoiceTitle] - 发票抬头 optional + * @param {string} [opts.invoiceContent] - 开票内容(按类别开票/按明细开票) optional + * @param {string} [opts.taxId] - 纳税人识别码(发票类型为企业增值税专用发票和企业增值税普通发票时必填) optional + * @param {string} [opts.company] - 单位名称(发票类型为企业增值税专用发票时必填) optional + * @param {string} [opts.phone] - 注册电话(发票类型为个人增值税普通发票和企业增值税普通发票时作为收票人手机号) optional + * @param {string} [opts.bank] - 开户银行(发票类型为企业增值税专用发票时必填) optional + * @param {string} [opts.account] - 银行账户(发票类型为企业增值税专用发票时必填) optional + * @param {string} [opts.address] - 注册地址(发票类型为企业增值税专用发票时必填) optional + * @param {string} [opts.email] - 邮箱 optional + * @param {string} [opts.mediumType] - [电子-electronic] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code + * @param string msg + */ + + createInvoiceTemplate (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 createInvoiceTemplate" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.invoiceType !== undefined && opts.invoiceType !== null) { + postBody['invoiceType'] = opts.invoiceType + } + if (opts.invoiceTitle !== undefined && opts.invoiceTitle !== null) { + postBody['invoiceTitle'] = opts.invoiceTitle + } + if (opts.invoiceContent !== undefined && opts.invoiceContent !== null) { + postBody['invoiceContent'] = opts.invoiceContent + } + if (opts.taxId !== undefined && opts.taxId !== null) { + postBody['taxId'] = opts.taxId + } + if (opts.company !== undefined && opts.company !== null) { + postBody['company'] = opts.company + } + if (opts.phone !== undefined && opts.phone !== null) { + postBody['phone'] = opts.phone + } + if (opts.bank !== undefined && opts.bank !== null) { + postBody['bank'] = opts.bank + } + if (opts.account !== undefined && opts.account !== null) { + postBody['account'] = opts.account + } + if (opts.address !== undefined && opts.address !== null) { + postBody['address'] = opts.address + } + if (opts.email !== undefined && opts.email !== null) { + postBody['email'] = opts.email + } + if (opts.mediumType !== undefined && opts.mediumType !== null) { + postBody['mediumType'] = opts.mediumType + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 createInvoiceTemplate 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}/invoiceTemplate', + '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.invoiceType] - 发票类型:[个人增值税普通发票-Personal_VAT_Ordinary_Invoice,企业增值税专用发票-Enterprise_VAT_Special_Invoice,企业增值税普通发票-Enterprise_VAT_Ordinary_Invoice] optional + * @param {string} [opts.invoiceTitle] - 发票抬头 optional + * @param {string} [opts.invoiceContent] - 开票内容(按类别开票/按明细开票) optional + * @param {string} [opts.taxId] - 纳税人识别码(发票类型为企业增值税专用发票和企业增值税普通发票时必填) optional + * @param {string} [opts.company] - 单位名称(发票类型为企业增值税专用发票时必填) optional + * @param {string} [opts.phone] - 注册电话(发票类型为个人增值税普通发票和企业增值税普通发票时作为收票人手机号) optional + * @param {string} [opts.bank] - 开户银行(发票类型为企业增值税专用发票时必填) optional + * @param {string} [opts.account] - 银行账户(发票类型为企业增值税专用发票时必填) optional + * @param {string} [opts.address] - 注册地址(发票类型为企业增值税专用发票时必填) optional + * @param {string} [opts.email] - 邮箱 optional + * @param {string} [opts.mediumType] - [电子-electronic] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code + * @param string msg + */ + + modifyInvoiceTemplate (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 modifyInvoiceTemplate" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.invoiceType !== undefined && opts.invoiceType !== null) { + postBody['invoiceType'] = opts.invoiceType + } + if (opts.invoiceTitle !== undefined && opts.invoiceTitle !== null) { + postBody['invoiceTitle'] = opts.invoiceTitle + } + if (opts.invoiceContent !== undefined && opts.invoiceContent !== null) { + postBody['invoiceContent'] = opts.invoiceContent + } + if (opts.taxId !== undefined && opts.taxId !== null) { + postBody['taxId'] = opts.taxId + } + if (opts.company !== undefined && opts.company !== null) { + postBody['company'] = opts.company + } + if (opts.phone !== undefined && opts.phone !== null) { + postBody['phone'] = opts.phone + } + if (opts.bank !== undefined && opts.bank !== null) { + postBody['bank'] = opts.bank + } + if (opts.account !== undefined && opts.account !== null) { + postBody['account'] = opts.account + } + if (opts.address !== undefined && opts.address !== null) { + postBody['address'] = opts.address + } + if (opts.email !== undefined && opts.email !== null) { + postBody['email'] = opts.email + } + if (opts.mediumType !== undefined && opts.mediumType !== null) { + postBody['mediumType'] = opts.mediumType + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 modifyInvoiceTemplate 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}/invoiceTemplate', + '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) + } + ) + } + + /** + * 删除发票模版 + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code + * @param string msg + */ + + deleteInvoiceTemplate (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 deleteInvoiceTemplate" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 deleteInvoiceTemplate 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}/invoiceTemplate', + '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.pin] - pin optional + * @param {array} [opts.refundInfoList] - 退款订单信息 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param checkResult result true-有欠票, false-无欠票 + */ + + checkInvoiceOwedInfo (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 checkInvoiceOwedInfo" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.pin !== undefined && opts.pin !== null) { + postBody['pin'] = opts.pin + } + if (opts.refundInfoList !== undefined && opts.refundInfoList !== null) { + postBody['refundInfoList'] = opts.refundInfoList + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 checkInvoiceOwedInfo 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}/checkInvoiceOwedInfo', + '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.pin] - pin optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean result true-更新成功, false-更新失败 + */ + + batchUpdateInvoiceRefundOrder ( + 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 batchUpdateInvoiceRefundOrder" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.pin !== undefined && opts.pin !== null) { + postBody['pin'] = opts.pin + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 batchUpdateInvoiceRefundOrder 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}/batchUpdateInvoiceRefundOrder', + '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 {array} [opts.invoiceOweInfoList] - 退款欠票信息 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean result true-更新成功, false-更新失败 + */ + + refundOwedInvoice (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 refundOwedInvoice" + ) + } + + opts = opts || {} + + let postBody = {} + if ( + opts.invoiceOweInfoList !== undefined && + opts.invoiceOweInfoList !== null + ) { + postBody['invoiceOweInfoList'] = opts.invoiceOweInfoList + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 refundOwedInvoice 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}/refundOwedInvoice', + '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.pin - 用户pin + * @param {array} [opts.orderNumberList] - 订单列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param orderInvoiceInfo result 订单开票信息 + */ + + describeOrderInvoice (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 describeOrderInvoice" + ) + } + + opts = opts || {} + + if (opts.pin === undefined || opts.pin === null) { + throw new Error( + "Missing the required parameter 'opts.pin' when calling describeOrderInvoice" + ) + } + + let postBody = {} + if (opts.pin !== undefined && opts.pin !== null) { + postBody['pin'] = opts.pin + } + if (opts.orderNumberList !== undefined && opts.orderNumberList !== null) { + postBody['orderNumberList'] = opts.orderNumberList + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 describeOrderInvoice 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}/describeOrderInvoice', + '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 {array} [opts.refundInfoList] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean result true-更新成功 false-更新失败 + * @param string message 结果消息 + */ + + updateInvoiceRefundAmount (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 updateInvoiceRefundAmount" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.refundInfoList !== undefined && opts.refundInfoList !== null) { + postBody['refundInfoList'] = opts.refundInfoList + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 invoice/0.4.11' + } + + 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 updateInvoiceRefundAmount 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}/updateInvoiceRefundAmount', + '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 = INVOICE diff --git a/packages/libs/lib-jdcloud/src/repo/iotcard/v1/iotcard.js b/packages/libs/lib-jdcloud/src/repo/iotcard/v1/iotcard.js new file mode 100644 index 000000000..f42ce8d60 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/iotcard/v1/iotcard.js @@ -0,0 +1,947 @@ +/* + * 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. + * + * iot-card-Related-API + * 物联网卡服务相关API + * + * 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 = 'iotcard' +Service._services[serviceId] = true + +/** + * iotcard service. + * @version 1.0.0 + */ + +JDCloud.IOTCARD = class IOTCARD extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'openapi.myiot.jdcloud.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 根据物联网卡iccid查询该卡的gprs状态信息 + * @param {Object} opts - parameters + * @param {string} opts.iccid - 物联网卡iccid + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;1:失败) + * @param string message 消息描述 + * @param gprsStatusResp result 指定物联网卡的gprs状态信息 + */ + + gprsStatus (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 gprsStatus" + ) + } + + opts = opts || {} + + if (opts.iccid === undefined || opts.iccid === null) { + throw new Error( + "Missing the required parameter 'opts.iccid' when calling gprsStatus" + ) + } + + let postBody = null + let queryParams = {} + if (opts.iccid !== undefined && opts.iccid !== null) { + queryParams['iccid'] = opts.iccid + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcard/1.0.0' + } + + 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 gprsStatus 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 = this.makeRequest( + '/regions/{regionId}/gprsStatus', + '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) + } + ) + } + + /** + * 根据物联网卡iccid查询该卡的开关机状态信息 + * @param {Object} opts - parameters + * @param {string} opts.iccid - 物联网卡iccid + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;1:失败) + * @param string message 消息描述 + * @param onOffStatusResp result 指定物联网卡的开关机状态信息 + */ + + onOffStatus (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 onOffStatus" + ) + } + + opts = opts || {} + + if (opts.iccid === undefined || opts.iccid === null) { + throw new Error( + "Missing the required parameter 'opts.iccid' when calling onOffStatus" + ) + } + + let postBody = null + let queryParams = {} + if (opts.iccid !== undefined && opts.iccid !== null) { + queryParams['iccid'] = opts.iccid + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcard/1.0.0' + } + + 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 onOffStatus 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 = this.makeRequest( + '/regions/{regionId}/onOffStatus', + '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) + } + ) + } + + /** + * 根据物联网卡iccid查询该卡的生命周期信息 + * @param {Object} opts - parameters + * @param {string} opts.iccid - 物联网卡iccid + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;1:失败) + * @param string message 消息描述 + * @param lifeStatusResp result 指定物联网卡的生命周期信息 + */ + + lifeStatus (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 lifeStatus" + ) + } + + opts = opts || {} + + if (opts.iccid === undefined || opts.iccid === null) { + throw new Error( + "Missing the required parameter 'opts.iccid' when calling lifeStatus" + ) + } + + let postBody = null + let queryParams = {} + if (opts.iccid !== undefined && opts.iccid !== null) { + queryParams['iccid'] = opts.iccid + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcard/1.0.0' + } + + 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 lifeStatus 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 = this.makeRequest( + '/regions/{regionId}/lifeStatus', + '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) + } + ) + } + + /** + * 根据物联网卡iccid查询该卡的当月套餐内的GPRS实时使用量 + * @param {Object} opts - parameters + * @param {string} opts.iccid - 物联网卡iccid + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;1:失败) + * @param string message 消息描述 + * @param gprsRealtimeInfoResp result 指定物联网卡的当月套餐内的GPRS实时使用量 + */ + + gprsRealtimeInfo (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 gprsRealtimeInfo" + ) + } + + opts = opts || {} + + if (opts.iccid === undefined || opts.iccid === null) { + throw new Error( + "Missing the required parameter 'opts.iccid' when calling gprsRealtimeInfo" + ) + } + + let postBody = null + let queryParams = {} + if (opts.iccid !== undefined && opts.iccid !== null) { + queryParams['iccid'] = opts.iccid + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcard/1.0.0' + } + + 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 gprsRealtimeInfo 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 = this.makeRequest( + '/regions/{regionId}/gprsRealtimeInfo', + '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 {array} [opts.iccids] - 物联网卡号码列表(单次提交最多不超过200个号码) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;1:失败) + * @param string message 消息描述 + * @param operationIotCardResp result + */ + + openIotCard (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 openIotCard" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.iccids !== undefined && opts.iccids !== null) { + postBody['iccids'] = opts.iccids + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcard/1.0.0' + } + + 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 openIotCard 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 = this.makeRequest( + '/regions/{regionId}/openIotCard', + '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 {array} [opts.iccids] - 物联网卡号码列表(单次提交最多不超过200个号码) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;1:失败) + * @param string message 消息描述 + * @param operationIotCardResp result + */ + + closeIotCard (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 closeIotCard" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.iccids !== undefined && opts.iccids !== null) { + postBody['iccids'] = opts.iccids + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcard/1.0.0' + } + + 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 closeIotCard 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 = this.makeRequest( + '/regions/{regionId}/closeIotCard', + '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 {array} [opts.iccids] - 物联网卡号码列表(单次提交最多不超过200个号码) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;1:失败) + * @param string message 消息描述 + * @param operationIotCardResp result + */ + + openIotFlow (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 openIotFlow" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.iccids !== undefined && opts.iccids !== null) { + postBody['iccids'] = opts.iccids + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcard/1.0.0' + } + + 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 openIotFlow 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 = this.makeRequest( + '/regions/{regionId}/openIotFlow', + '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 {array} [opts.iccids] - 物联网卡号码列表(单次提交最多不超过200个号码) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;1:失败) + * @param string message 消息描述 + * @param operationIotCardResp result + */ + + closeIotFlow (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 closeIotFlow" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.iccids !== undefined && opts.iccids !== null) { + postBody['iccids'] = opts.iccids + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcard/1.0.0' + } + + 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 closeIotFlow 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 = this.makeRequest( + '/regions/{regionId}/closeIotFlow', + '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 = JDCloud.IOTCARD diff --git a/packages/libs/lib-jdcloud/src/repo/iotcloudgateway/v1/iotcloudgateway.js b/packages/libs/lib-jdcloud/src/repo/iotcloudgateway/v1/iotcloudgateway.js new file mode 100644 index 000000000..e4c0a097e --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/iotcloudgateway/v1/iotcloudgateway.js @@ -0,0 +1,616 @@ +/* + * 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. + * + * iotcloudgateway开通接口 + * 用户开通iotcloudgateway服务相关接口 + * + * 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 = 'iotcloudgateway' +Service._services[serviceId] = true + +/** + * iotcloudgateway service. + * @version 1.0.1 + */ + +JDCloud.IOTCLOUDGATEWAY = class IOTCLOUDGATEWAY extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'iotcloudgateway.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询iotcloudgateway实例列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 分页大小 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instance instances + * @param integer totalCount iotcloudgateway实例总数 + */ + + 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 + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcloudgateway/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 = this.makeRequest( + '/regions/{regionId}/instances', + '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) + } + ) + } + + /** + * 查询iotcloudgateway实例详情 + * @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 实例相关信息 + */ + + 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 || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeInstance" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcloudgateway/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 = this.makeRequest( + '/regions/{regionId}/instances/{instanceId}:describeInstance', + '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) + } + ) + } + + /** + * 查询instance绑定的ExposedDomain + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string iotgwd 实例对应下行域名 + * @param string iotgwu 实例对应上行域名 + */ + + queryInstanceExposeDomain (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 queryInstanceExposeDomain" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling queryInstanceExposeDomain" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcloudgateway/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 queryInstanceExposeDomain 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 = this.makeRequest( + '/regions/{regionId}/instances/{instanceId}:queryInstanceExposeDomain', + '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) + } + ) + } + + /** + * 查询instance当前状态 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status iotcloudgateway实例状态 + */ + + queryInstanceStatus (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 queryInstanceStatus" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling queryInstanceStatus" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcloudgateway/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 queryInstanceStatus 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 = this.makeRequest( + '/regions/{regionId}/instances/{instanceId}:queryInstanceStatus', + '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 - 实例ID + * @param {deviceControlSpec} opts.devicecmd - iotcloudgateway实例下发设备控制指令 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deviceControl (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 deviceControl" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deviceControl" + ) + } + if (opts.devicecmd === undefined || opts.devicecmd === null) { + throw new Error( + "Missing the required parameter 'opts.devicecmd' when calling deviceControl" + ) + } + + let postBody = {} + if (opts.devicecmd !== undefined && opts.devicecmd !== null) { + postBody['devicecmd'] = opts.devicecmd + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcloudgateway/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 deviceControl 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 = this.makeRequest( + '/regions/{regionId}/instances/{instanceId}:deviceControl', + '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 = JDCloud.IOTCLOUDGATEWAY diff --git a/packages/libs/lib-jdcloud/src/repo/iotcore/v2/iotcore.js b/packages/libs/lib-jdcloud/src/repo/iotcore/v2/iotcore.js new file mode 100644 index 000000000..c2222f04a --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/iotcore/v2/iotcore.js @@ -0,0 +1,7504 @@ +/* + * 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. + * + * IoTHubInstance + * IoT Hub共享模式和独享模式共用接口 + * + * 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 = 'iotcore' +Service._services[serviceId] = true + +/** + * iotcore service. + * @version 1.1.25 + */ + +class IOTCORE extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'iotcore.jdcloud-api.com' + options.basePath = '/v2' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 设备注册接口 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例Id + * @param {deviceInfoVO} opts.deviceInfoVO - 物模型ID编号 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string deviceId 注册设备返回的设备ID + */ + + registerDevice (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 registerDevice" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling registerDevice" + ) + } + if (opts.deviceInfoVO === undefined || opts.deviceInfoVO === null) { + throw new Error( + "Missing the required parameter 'opts.deviceInfoVO' when calling registerDevice" + ) + } + + let postBody = {} + if (opts.deviceInfoVO !== undefined && opts.deviceInfoVO !== null) { + postBody['deviceInfoVO'] = opts.deviceInfoVO + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 registerDevice 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}/coreinstances/{instanceId}/device:register', + '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 - 实例Id + * @param {string} opts.deviceId - 设备ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string deviceId 证书对应deviceId + * @param string deviceCertUrl 证书zip包对应链接,默认有效时长10分钟 + */ + + downloadDeviceCertificate (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 downloadDeviceCertificate" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling downloadDeviceCertificate" + ) + } + if (opts.deviceId === undefined || opts.deviceId === null) { + throw new Error( + "Missing the required parameter 'opts.deviceId' when calling downloadDeviceCertificate" + ) + } + + let postBody = null + let queryParams = {} + if (opts.deviceId !== undefined && opts.deviceId !== null) { + queryParams['deviceId'] = opts.deviceId + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 downloadDeviceCertificate 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}/coreinstances/{instanceId}/device:downloadCertificate', + '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} opts.deviceId - 设备ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 是否删除成功 + */ + + deleteDevice (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 deleteDevice" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteDevice" + ) + } + if (opts.deviceId === undefined || opts.deviceId === null) { + throw new Error( + "Missing the required parameter 'opts.deviceId' when calling deleteDevice" + ) + } + + let postBody = null + let queryParams = {} + if (opts.deviceId !== undefined && opts.deviceId !== null) { + queryParams['deviceId'] = opts.deviceId + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 deleteDevice 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}/coreinstances/{instanceId}/device:delete', + '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.instanceId - 实例Id + * @param {string} opts.deviceId - 设备ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param deviceInfoVO deviceInfoVO + */ + + describeDevice (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 describeDevice" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeDevice" + ) + } + if (opts.deviceId === undefined || opts.deviceId === null) { + throw new Error( + "Missing the required parameter 'opts.deviceId' when calling describeDevice" + ) + } + + let postBody = null + let queryParams = {} + if (opts.deviceId !== undefined && opts.deviceId !== null) { + queryParams['deviceId'] = opts.deviceId + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 describeDevice 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}/coreinstances/{instanceId}/device:describe', + '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} [opts.deviceMetaId] - 设备型号标识 optional + * @param {string} [opts.deviceMetaName] - 设备型号名称 optional + * @param {integer} [opts.nodeType] - 节点类型 optional + * @param {integer} [opts.pageNo] - 页码 optional + * @param {integer} [opts.pageSize] - 每页显示条数 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer pageSize + * @param integer currentPage + * @param integer totalCount + * @param thingTypeInfoVO list + */ + + describeThingTypeList (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 describeThingTypeList" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeThingTypeList" + ) + } + + let postBody = null + let queryParams = {} + if (opts.deviceMetaId !== undefined && opts.deviceMetaId !== null) { + queryParams['deviceMetaId'] = opts.deviceMetaId + } + if (opts.deviceMetaName !== undefined && opts.deviceMetaName !== null) { + queryParams['deviceMetaName'] = opts.deviceMetaName + } + if (opts.nodeType !== undefined && opts.nodeType !== null) { + queryParams['nodeType'] = opts.nodeType + } + if (opts.pageNo !== undefined && opts.pageNo !== null) { + queryParams['pageNo'] = opts.pageNo + } + 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 iotcore/1.1.25' + } + + 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 describeThingTypeList 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}/coreinstances/{instanceId}/thingType:list', + '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} [opts.deviceMetaId] - 设备型号标识 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param thingTypeInfoVO thingTypeInfoVO + */ + + describeThingType (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 describeThingType" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeThingType" + ) + } + + let postBody = null + let queryParams = {} + if (opts.deviceMetaId !== undefined && opts.deviceMetaId !== null) { + queryParams['deviceMetaId'] = opts.deviceMetaId + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 describeThingType 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}/coreinstances/{instanceId}/thingType:describe', + '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) + } + ) + } + + /** + * 根据物类型Code查看物模型完整信息 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例Id + * @param {string} opts.thingTypeCode - 物类型Code + * @param {string} [opts.thingModelVersion] - 版本号。如果为空,则返回最新版本 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param thingModelRespTO thingModelRespTO + */ + + describeThingModel (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 describeThingModel" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeThingModel" + ) + } + if (opts.thingTypeCode === undefined || opts.thingTypeCode === null) { + throw new Error( + "Missing the required parameter 'opts.thingTypeCode' when calling describeThingModel" + ) + } + + let postBody = null + let queryParams = {} + if (opts.thingTypeCode !== undefined && opts.thingTypeCode !== null) { + queryParams['thingTypeCode'] = opts.thingTypeCode + } + if ( + opts.thingModelVersion !== undefined && + opts.thingModelVersion !== null + ) { + queryParams['thingModelVersion'] = opts.thingModelVersion + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 describeThingModel 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}/coreinstances/{instanceId}/thingModel:describe', + '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 {devicePropertyVO} opts.devicePropertyVO - 设备ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 是否设置成功 + */ + + setDeviceProperty (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 setDeviceProperty" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling setDeviceProperty" + ) + } + if (opts.devicePropertyVO === undefined || opts.devicePropertyVO === null) { + throw new Error( + "Missing the required parameter 'opts.devicePropertyVO' when calling setDeviceProperty" + ) + } + + let postBody = {} + if (opts.devicePropertyVO !== undefined && opts.devicePropertyVO !== null) { + postBody['devicePropertyVO'] = opts.devicePropertyVO + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 setDeviceProperty 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}/coreinstances/{instanceId}/deviceProperty:set', + '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 - 实例Id + * @param {deviceFunctionVO} opts.deviceFunctionVO - 设备方法 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code + * @param string message + * @param boolean success + * @param deviceFunctionVO returnValues + */ + + invokeFunction (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 invokeFunction" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling invokeFunction" + ) + } + if (opts.deviceFunctionVO === undefined || opts.deviceFunctionVO === null) { + throw new Error( + "Missing the required parameter 'opts.deviceFunctionVO' when calling invokeFunction" + ) + } + + let postBody = {} + if (opts.deviceFunctionVO !== undefined && opts.deviceFunctionVO !== null) { + postBody['deviceFunctionVO'] = opts.deviceFunctionVO + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 invokeFunction 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}/coreinstances/{instanceId}/function:invokeFunction', + '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 - 实例Id + * @param {eventReportPageBo} opts.eventReportPageBo - 事件查询请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer pageSize + * @param integer currentPage + * @param integer totalCount + * @param eventReportVo list + */ + + describeEventList (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 describeEventList" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeEventList" + ) + } + if ( + opts.eventReportPageBo === undefined || + opts.eventReportPageBo === null + ) { + throw new Error( + "Missing the required parameter 'opts.eventReportPageBo' when calling describeEventList" + ) + } + + let postBody = {} + if ( + opts.eventReportPageBo !== undefined && + opts.eventReportPageBo !== null + ) { + postBody['eventReportPageBo'] = opts.eventReportPageBo + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 describeEventList 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}/coreinstances/{instanceId}/event:list', + '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 - 实例Id + * @param {functionCallPageBo} opts.functionCallPageBo - 方法查询请求对象 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer pageSize + * @param integer currentPage + * @param integer totalCount + * @param functionCallRecordVo list + */ + + describeFunctionList (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 describeFunctionList" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeFunctionList" + ) + } + if ( + opts.functionCallPageBo === undefined || + opts.functionCallPageBo === null + ) { + throw new Error( + "Missing the required parameter 'opts.functionCallPageBo' when calling describeFunctionList" + ) + } + + let postBody = {} + if ( + opts.functionCallPageBo !== undefined && + opts.functionCallPageBo !== null + ) { + postBody['functionCallPageBo'] = opts.functionCallPageBo + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 describeFunctionList 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}/coreinstances/{instanceId}/function:list', + '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 - 实例Id + * @param {string} opts.deviceId - 设备ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param propertyAcquireVo propertyAcquireVo + */ + + describeProperty (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 describeProperty" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeProperty" + ) + } + if (opts.deviceId === undefined || opts.deviceId === null) { + throw new Error( + "Missing the required parameter 'opts.deviceId' when calling describeProperty" + ) + } + + let postBody = null + let queryParams = {} + if (opts.deviceId !== undefined && opts.deviceId !== null) { + queryParams['deviceId'] = opts.deviceId + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 describeProperty 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}/coreinstances/{instanceId}/property:describe', + '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 {deviceSnapshotRequestVO} opts.deviceSnapshotRequestVO - 方法查询请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string snapShot JSON字符串格式属性结果 + */ + + describePropertySnapshot (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 describePropertySnapshot" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describePropertySnapshot" + ) + } + if ( + opts.deviceSnapshotRequestVO === undefined || + opts.deviceSnapshotRequestVO === null + ) { + throw new Error( + "Missing the required parameter 'opts.deviceSnapshotRequestVO' when calling describePropertySnapshot" + ) + } + + let postBody = {} + if ( + opts.deviceSnapshotRequestVO !== undefined && + opts.deviceSnapshotRequestVO !== null + ) { + postBody['deviceSnapshotRequestVO'] = opts.deviceSnapshotRequestVO + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 describePropertySnapshot 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}/coreinstances/{instanceId}/property:describeSnapshot', + '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 - 实例Id + * @param {deviceTopoInfoVO} opts.deviceTopoInfoVO - 方法查询请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param deviceTopoResult deviceTopoResult + */ + + createDeviceTopo (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 createDeviceTopo" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createDeviceTopo" + ) + } + if (opts.deviceTopoInfoVO === undefined || opts.deviceTopoInfoVO === null) { + throw new Error( + "Missing the required parameter 'opts.deviceTopoInfoVO' when calling createDeviceTopo" + ) + } + + let postBody = {} + if (opts.deviceTopoInfoVO !== undefined && opts.deviceTopoInfoVO !== null) { + postBody['deviceTopoInfoVO'] = opts.deviceTopoInfoVO + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 createDeviceTopo 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}/coreinstances/{instanceId}/deviceTopo:create', + '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 - 实例Id + * @param {deviceTopoPageBO} opts.deviceTopoPageBO - 方法查询请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer pageSize + * @param integer currentPage + * @param integer totalCount + * @param deviceTopoRecordVO list + */ + + describeDeviceTopo (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 describeDeviceTopo" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeDeviceTopo" + ) + } + if (opts.deviceTopoPageBO === undefined || opts.deviceTopoPageBO === null) { + throw new Error( + "Missing the required parameter 'opts.deviceTopoPageBO' when calling describeDeviceTopo" + ) + } + + let postBody = {} + if (opts.deviceTopoPageBO !== undefined && opts.deviceTopoPageBO !== null) { + postBody['deviceTopoPageBO'] = opts.deviceTopoPageBO + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 describeDeviceTopo 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}/coreinstances/{instanceId}/deviceTopo:describe', + '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 - 实例Id + * @param {deviceTopoInfoVO} opts.deviceTopoInfoVO - 方法查询请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param deviceTopoResult deviceTopoResult + */ + + updateDeviceTopo (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 updateDeviceTopo" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling updateDeviceTopo" + ) + } + if (opts.deviceTopoInfoVO === undefined || opts.deviceTopoInfoVO === null) { + throw new Error( + "Missing the required parameter 'opts.deviceTopoInfoVO' when calling updateDeviceTopo" + ) + } + + let postBody = {} + if (opts.deviceTopoInfoVO !== undefined && opts.deviceTopoInfoVO !== null) { + postBody['deviceTopoInfoVO'] = opts.deviceTopoInfoVO + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 updateDeviceTopo 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}/coreinstances/{instanceId}/deviceTopo:update', + '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 - 实例Id + * @param {deviceTopoInfoVO} opts.deviceTopoInfoVO - 方法查询请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param deviceTopoResult deviceTopoResult + */ + + deleteDeviceTopo (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 deleteDeviceTopo" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteDeviceTopo" + ) + } + if (opts.deviceTopoInfoVO === undefined || opts.deviceTopoInfoVO === null) { + throw new Error( + "Missing the required parameter 'opts.deviceTopoInfoVO' when calling deleteDeviceTopo" + ) + } + + let postBody = {} + if (opts.deviceTopoInfoVO !== undefined && opts.deviceTopoInfoVO !== null) { + postBody['deviceTopoInfoVO'] = opts.deviceTopoInfoVO + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 deleteDeviceTopo 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}/coreinstances/{instanceId}/deviceTopo:delete', + '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) + } + ) + } + + /** + * 设备Topic调用 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 设备归属的实例ID + * @param {string} opts.identifier - 设备唯一标识 + * @param {string} opts.productKey - 产品Key + * @param {string} opts.topicShortName - Topic如/user/{productKey}/{identifier}/topicShortName +不支持系统Topic + + * @param {string} opts.topicMessage - 要发送的消息主体 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string msgId 消息唯一标识 + */ + + invokeThingTopic (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 invokeThingTopic" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling invokeThingTopic" + ) + } + if (opts.identifier === undefined || opts.identifier === null) { + throw new Error( + "Missing the required parameter 'opts.identifier' when calling invokeThingTopic" + ) + } + if (opts.productKey === undefined || opts.productKey === null) { + throw new Error( + "Missing the required parameter 'opts.productKey' when calling invokeThingTopic" + ) + } + if (opts.topicShortName === undefined || opts.topicShortName === null) { + throw new Error( + "Missing the required parameter 'opts.topicShortName' when calling invokeThingTopic" + ) + } + if (opts.topicMessage === undefined || opts.topicMessage === null) { + throw new Error( + "Missing the required parameter 'opts.topicMessage' when calling invokeThingTopic" + ) + } + + let postBody = {} + if (opts.topicShortName !== undefined && opts.topicShortName !== null) { + postBody['topicShortName'] = opts.topicShortName + } + if (opts.topicMessage !== undefined && opts.topicMessage !== null) { + postBody['topicMessage'] = opts.topicMessage + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + identifier: opts.identifier, + productKey: opts.productKey + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 invokeThingTopic 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}/instances/{instanceId}/products/{productKey}/devices/{identifier}/topic', + '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 - 设备归属的实例ID + * @param {string} opts.identifier - 设备唯一标识 + * @param {string} opts.productKey - 产品Key + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param object state 设备状态 + * @param object metadata 当用户更新设备状态文档后,设备影子服务会自动更新metadata的值。设备状态的元数据的信息包含以 Epoch 时间表示的每个属性的时间戳,用来获取准确的更新时间。 + * @param integer version 设备影子版本 + * @param integer timestamp 设备影子更新时间 + */ + + describeThingShadow (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 describeThingShadow" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeThingShadow" + ) + } + if (opts.identifier === undefined || opts.identifier === null) { + throw new Error( + "Missing the required parameter 'opts.identifier' when calling describeThingShadow" + ) + } + if (opts.productKey === undefined || opts.productKey === null) { + throw new Error( + "Missing the required parameter 'opts.productKey' when calling describeThingShadow" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + identifier: opts.identifier, + productKey: opts.productKey + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 describeThingShadow 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}/instances/{instanceId}/products/{productKey}/devices/{identifier}/shadow', + '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} opts.identifier - 设备唯一标识 + * @param {string} opts.productKey - 产品Key + * @param {object} [opts.state] - 运行状态 optional + * @param {integer} [opts.version] - 设备影子版本,当前版本加1,当前版本默认其实版本为-1 +用户主动更新版本号时,设备影子会检查请求中的主动更新版本号是否大于当前版本号。 +如果大于当前版本号,则更新设备影子,并将影子版本值更新到请求的版本中,反之则会拒绝更新设备影子。 +影子版本参数为Integer型 +取值范围:0到2147483647(2的31次方-1) +当取值达到最大值2147483647(2的31次方-1)时,请求中的主动更新版本号应为-1 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateThingShadow (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 updateThingShadow" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling updateThingShadow" + ) + } + if (opts.identifier === undefined || opts.identifier === null) { + throw new Error( + "Missing the required parameter 'opts.identifier' when calling updateThingShadow" + ) + } + if (opts.productKey === undefined || opts.productKey === null) { + throw new Error( + "Missing the required parameter 'opts.productKey' when calling updateThingShadow" + ) + } + + let postBody = {} + if (opts.state !== undefined && opts.state !== null) { + postBody['state'] = opts.state + } + if (opts.version !== undefined && opts.version !== null) { + postBody['version'] = opts.version + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + identifier: opts.identifier, + productKey: opts.productKey + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 updateThingShadow 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}/instances/{instanceId}/products/{productKey}/devices/{identifier}/shadow', + 'PATCH', + 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} opts.identifier - 设备唯一标识 + * @param {string} opts.productKey - 产品Key + * @param {string} opts.name - 服务名称 + * @param {object} [opts.input] - 输入参数,object的key为参数名称,value为参数值 optional + * @param {string} [opts.callbackBeanName] - 回调spring的bean的名称 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string msgId 消息唯一标识 + */ + + invokeThingService (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 invokeThingService" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling invokeThingService" + ) + } + if (opts.identifier === undefined || opts.identifier === null) { + throw new Error( + "Missing the required parameter 'opts.identifier' when calling invokeThingService" + ) + } + if (opts.productKey === undefined || opts.productKey === null) { + throw new Error( + "Missing the required parameter 'opts.productKey' when calling invokeThingService" + ) + } + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling invokeThingService" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.input !== undefined && opts.input !== null) { + postBody['input'] = opts.input + } + if (opts.callbackBeanName !== undefined && opts.callbackBeanName !== null) { + postBody['callbackBeanName'] = opts.callbackBeanName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + identifier: opts.identifier, + productKey: opts.productKey + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 invokeThingService 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}/instances/{instanceId}/products/{productKey}/devices/{identifier}/services', + '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 - 设备归属的实例ID + * @param {string} opts.parentId - 父级设备Id,只允许网关设备作为父级设备 + * @param {string} [opts.productKey] - 将此产品下所有设备都设置为parentId的子设备,只允许普通设备类型的productKey optional + * @param {array} [opts.children] - 子设备Id集合,children和productKey二者至少填一个,二者都填写则同时生效,只允许普通设备类型的deviceId optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + addDeviceLinks (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 addDeviceLinks" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling addDeviceLinks" + ) + } + if (opts.parentId === undefined || opts.parentId === null) { + throw new Error( + "Missing the required parameter 'opts.parentId' when calling addDeviceLinks" + ) + } + + let postBody = {} + if (opts.parentId !== undefined && opts.parentId !== null) { + postBody['parentId'] = opts.parentId + } + if (opts.productKey !== undefined && opts.productKey !== null) { + postBody['productKey'] = opts.productKey + } + if (opts.children !== undefined && opts.children !== null) { + postBody['children'] = opts.children + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 addDeviceLinks 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}/instances/{instanceId}/devices:addLinks', + '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 - 设备归属的实例ID + * @param {string} [opts.deviceName] - 设备名称,模糊匹配 optional + * @param {integer} [opts.status] - 设备状态 0-未激活,1-激活离线,2-激活在线 optional + * @param {string} [opts.productKey] - 设备所归属的产品Key optional + * @param {integer} [opts.deviceType] - 设备类型,同产品类型,0-设备,1-网关 optional + * @param {integer} [opts.nowPage] - 当前页数 optional + * @param {integer} [opts.pageSize] - 每页的数据条数 optional + * @param {string} [opts.order] - 排序关键字--name,type,productKey,status--最多支持一个字段 optional + * @param {string} [opts.direction] - 顺序,升序降序--asc,desc optional + * @param {string} [opts.parentId] - 父设备Id optional + * @param {integer} [opts.orderId] - 订单号 optional + * @param {string} [opts.deviceCollectorType] - 设备采集器类型 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer pageSize + * @param integer nowPage + * @param integer totalSize + * @param integer totalPage + * @param deviceVO data + */ + + queryDevicePage (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 queryDevicePage" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling queryDevicePage" + ) + } + + let postBody = null + let queryParams = {} + if (opts.deviceName !== undefined && opts.deviceName !== null) { + queryParams['deviceName'] = opts.deviceName + } + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + if (opts.productKey !== undefined && opts.productKey !== null) { + queryParams['productKey'] = opts.productKey + } + if (opts.deviceType !== undefined && opts.deviceType !== null) { + queryParams['deviceType'] = opts.deviceType + } + if (opts.nowPage !== undefined && opts.nowPage !== null) { + queryParams['nowPage'] = opts.nowPage + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.order !== undefined && opts.order !== null) { + queryParams['order'] = opts.order + } + if (opts.direction !== undefined && opts.direction !== null) { + queryParams['direction'] = opts.direction + } + if (opts.parentId !== undefined && opts.parentId !== null) { + queryParams['parentId'] = opts.parentId + } + if (opts.orderId !== undefined && opts.orderId !== null) { + queryParams['orderId'] = opts.orderId + } + if ( + opts.deviceCollectorType !== undefined && + opts.deviceCollectorType !== null + ) { + queryParams['deviceCollectorType'] = opts.deviceCollectorType + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 queryDevicePage 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}/instances/{instanceId}/devices:queryPage', + '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} opts.deviceId - 设备Id + * @param {string} [opts.model] - 设备型号 optional + * @param {string} [opts.manufacturer] - 设备厂商 optional + * @param {string} [opts.description] - 设备描述 optional + * @param {integer} [opts.status] - 设备状态 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param deviceVO device 设备详情 + */ + + updateDevice (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 updateDevice" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling updateDevice" + ) + } + if (opts.deviceId === undefined || opts.deviceId === null) { + throw new Error( + "Missing the required parameter 'opts.deviceId' when calling updateDevice" + ) + } + + let postBody = {} + if (opts.model !== undefined && opts.model !== null) { + postBody['model'] = opts.model + } + if (opts.manufacturer !== undefined && opts.manufacturer !== null) { + postBody['manufacturer'] = opts.manufacturer + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + deviceId: opts.deviceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 updateDevice 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}/instances/{instanceId}/device/{deviceId}:update', + '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 - 设备归属的实例ID + * @param {string} [opts.deviceName] - 设备名称 optional + * @param {string} [opts.productKey] - 设备所归属的产品 optional + * @param {string} [opts.model] - 设备型号 optional + * @param {string} [opts.manufacturer] - 厂商 optional + * @param {string} [opts.description] - 设备描述 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string deviceName 设备名称 + * @param string identifier 设备标识符 + * @param string secret 设备秘钥 + */ + + addDevice (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 addDevice" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling addDevice" + ) + } + + let postBody = {} + if (opts.deviceName !== undefined && opts.deviceName !== null) { + postBody['deviceName'] = opts.deviceName + } + if (opts.productKey !== undefined && opts.productKey !== null) { + postBody['productKey'] = opts.productKey + } + if (opts.model !== undefined && opts.model !== null) { + postBody['model'] = opts.model + } + if (opts.manufacturer !== undefined && opts.manufacturer !== null) { + postBody['manufacturer'] = opts.manufacturer + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 addDevice 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}/instances/{instanceId}/device:add', + '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.deviceName - 设备名称 + * @param {string} opts.instanceId - 设备归属的实例ID + * @param {string} opts.productKey - 产品Key + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string deviceId 设备ID + * @param string deviceName 设备名称 + * @param string parentId 父级设备Id + * @param string deviceType 设备类型,同产品类型,0-普通设备,1-网关,2-Edge + * @param integer status 设备状态,0-未激活,1-激活离线,2-激活在线 + * @param string productKey 产品Key + * @param string identifier 设备标识符 + * @param string secret 设备秘钥 + * @param string description 设备描述 + * @param integer activatedTime 激活时间 + * @param integer lastConnectedTime 最后连接时间 + * @param integer createdTime 注册时间 + * @param integer updatedTime 修改时间 + * @param string productName 产品名称 + * @param string model 设备型号 + * @param string manufacturer 设备厂商 + * @param integer dynamicRegister 动态注册,0:关闭,1:开启 + */ + + queryDeviceDetail (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 queryDeviceDetail" + ) + } + + opts = opts || {} + + if (opts.deviceName === undefined || opts.deviceName === null) { + throw new Error( + "Missing the required parameter 'opts.deviceName' when calling queryDeviceDetail" + ) + } + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling queryDeviceDetail" + ) + } + if (opts.productKey === undefined || opts.productKey === null) { + throw new Error( + "Missing the required parameter 'opts.productKey' when calling queryDeviceDetail" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + deviceName: opts.deviceName, + instanceId: opts.instanceId, + productKey: opts.productKey + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 queryDeviceDetail 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}/instances/{instanceId}/products/{productKey}/device/{deviceName}:detail', + '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.deviceName - 设备名称 + * @param {string} opts.instanceId - 设备归属的实例ID + * @param {string} opts.productKey - 产品Key + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + removeDevice (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 removeDevice" + ) + } + + opts = opts || {} + + if (opts.deviceName === undefined || opts.deviceName === null) { + throw new Error( + "Missing the required parameter 'opts.deviceName' when calling removeDevice" + ) + } + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling removeDevice" + ) + } + if (opts.productKey === undefined || opts.productKey === null) { + throw new Error( + "Missing the required parameter 'opts.productKey' when calling removeDevice" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + deviceName: opts.deviceName, + instanceId: opts.instanceId, + productKey: opts.productKey + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 removeDevice 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}/instances/{instanceId}/products/{productKey}/device/{deviceName}:delete', + '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.instanceId - 设备归属的实例ID + * @param {string} [opts.groupName] - 组名称 optional + * @param {string} [opts.queryUserPin] - 查询的用户组 optional + * @param {string} [opts.tag] - 组标签 optional + * @param {integer} [opts.pageNumber] - 当前页号 optional + * @param {integer} [opts.pageSize] - 每页大小 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer pageSize + * @param integer nowPage + * @param integer totalSize + * @param integer totalPage + * @param deviceGroupResp data + */ + + getDeviceGroup (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 getDeviceGroup" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling getDeviceGroup" + ) + } + + let postBody = null + let queryParams = {} + if (opts.groupName !== undefined && opts.groupName !== null) { + queryParams['groupName'] = opts.groupName + } + if (opts.queryUserPin !== undefined && opts.queryUserPin !== null) { + queryParams['queryUserPin'] = opts.queryUserPin + } + if (opts.tag !== undefined && opts.tag !== null) { + queryParams['tag'] = opts.tag + } + 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 iotcore/1.1.25' + } + + 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 getDeviceGroup 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}/instances/{instanceId}/devicegroup:get', + '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} [opts.queryUserPin] - 获取用户 NULL为当前用户 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param deviceGroupResp data + */ + + getDeviceGroupList (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 getDeviceGroupList" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling getDeviceGroupList" + ) + } + + let postBody = null + let queryParams = {} + if (opts.queryUserPin !== undefined && opts.queryUserPin !== null) { + queryParams['queryUserPin'] = opts.queryUserPin + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 getDeviceGroupList 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}/instances/{instanceId}/devicegrouplist', + '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} [opts.productKey] - 产品Key optional + * @param {string} [opts.deviceName] - 设备名称 optional + * @param {string} [opts.deviceCollectorType] - 采集器类型 optional + * @param {string} [opts.groupName] - 组名称 optional + * @param {string} [opts.userPin] - 查询的用户组 optional + * @param {string} [opts.tag] - 组标签 optional + * @param {string} [opts.groupId] - 组ID optional + * @param {string} [opts.manufacturer] - 厂商名称 optional + * @param {string} [opts.model] - 设备型号 optional + * @param {integer} [opts.orderId] - 订单号 optional + * @param {integer} [opts.status] - 设备状态 optional + * @param {integer} [opts.pageNumber] - 当前页码 optional + * @param {integer} [opts.pageSize] - 每页大小 optional + * @param {string} [opts.order] - 排序字段 optional + * @param {string} [opts.direction] - 排序方式(asc desc) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer pageSize + * @param integer nowPage + * @param integer totalSize + * @param integer totalPage + * @param deviceGroupInfo data + */ + + findDeviceGroupLinkPage (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 findDeviceGroupLinkPage" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling findDeviceGroupLinkPage" + ) + } + + let postBody = null + let queryParams = {} + if (opts.productKey !== undefined && opts.productKey !== null) { + queryParams['productKey'] = opts.productKey + } + if (opts.deviceName !== undefined && opts.deviceName !== null) { + queryParams['deviceName'] = opts.deviceName + } + if ( + opts.deviceCollectorType !== undefined && + opts.deviceCollectorType !== null + ) { + queryParams['deviceCollectorType'] = opts.deviceCollectorType + } + if (opts.groupName !== undefined && opts.groupName !== null) { + queryParams['groupName'] = opts.groupName + } + if (opts.userPin !== undefined && opts.userPin !== null) { + queryParams['userPin'] = opts.userPin + } + if (opts.tag !== undefined && opts.tag !== null) { + queryParams['tag'] = opts.tag + } + if (opts.groupId !== undefined && opts.groupId !== null) { + queryParams['groupId'] = opts.groupId + } + if (opts.manufacturer !== undefined && opts.manufacturer !== null) { + queryParams['manufacturer'] = opts.manufacturer + } + if (opts.model !== undefined && opts.model !== null) { + queryParams['model'] = opts.model + } + if (opts.orderId !== undefined && opts.orderId !== null) { + queryParams['orderId'] = opts.orderId + } + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + queryParams['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.order !== undefined && opts.order !== null) { + queryParams['order'] = opts.order + } + if (opts.direction !== undefined && opts.direction !== null) { + queryParams['direction'] = opts.direction + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 findDeviceGroupLinkPage 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}/instances/{instanceId}/devicegrouplink:get', + '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 - Hub实例Id + * @param {string} [opts.identifier] - 电梯连接码 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param registerValue data + * @param integer totalCount 统计数据 + */ + + elevatorOperatingStatus (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 elevatorOperatingStatus" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling elevatorOperatingStatus" + ) + } + + let postBody = null + let queryParams = {} + if (opts.identifier !== undefined && opts.identifier !== null) { + queryParams['identifier'] = opts.identifier + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 elevatorOperatingStatus 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}/loongrayinstances/{instanceId}/registerElevatorOperatingStatus', + '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 - Hub实例Id + * @param {string} opts.identifier - 当前的链接码 + * @param {string} opts.protocol - 当前的协议类型: +语音播报控制器-输入端子,0X00000~X0007:inputTerminal +语音播报控制器-播放信息,0X00024~X0027:playInfo +LR001-516-5B边缘数据采集器-传感器管理:sensor +LR001-516-5B边缘数据采集器-采集器属性:collectorProperty +LR001-516-5B边缘数据采集器-电梯属性:elevatorProperty +LR001-516-5A边缘数据采集器-水质酸碱度(PH):waterQualityPh +LR001-516-5A水质监测采集器-水质电导率:waterQualityElectroConductivity + + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param object readData 读取寄存器值,key:寄存器地址 value:寄存器值 +如读取语音播报控制器-输入端子的响应为 +{ + "0":0, + "1":0, + "2":0, + "3":0, + "4":0, + "5":0, + "6":0, + "7":0 +} +如读取语音播报控制器-播放信息的响应为 +{ + "36":0, + "37":0, + "38":0, + "39":0, + "40":0, + "41":0, + "42":0, + "43":0, + "44":1, + "45":3, + "46":0, + "47":0 +} +如读取LR001-516-5B边缘数据采集器-传感器管理的响应为 +{ + "40426":1, + "40427":1, + "40428":2, + "40429":1, + "40430":1, + "40431":1, + "40432":1, + "40433":2, + "40434":1, + "40435":1, + "40436":1, + "40437":1, + "40438":1, + "40439":1, + "40440":1 +} +如读取LR001-516-5A边缘数据采集器-水质酸碱度(PH)响应为 +{ + "40301": 0, + "40302": 225, + "40304": 28.071838, + "40306": 12.9, + "40308": 0, + "40309": 37376, + "40311": 2000, + "40313": -2000, + "40315": 60, + "40317": 0, + "40319": 0, + "40321": 0, + "40323": 0, + "40324": 1, + "40325": 4, + "40326": 0, + "40327": 256, + "40329": -0.1984, + "40331": 0, + "40333": 1, + "40335": 25, + "40337": 0, + "40338": 0, + "40339": 2622 +} +如读取LR001-516-5A水质监测采集器-水质电导率响应为 +{ + "40340": 0, + "40342": 0, + "40344": 29.816881, + "40346": 0, + "40348": 0, + "40350": 10, + "40352": 0.018, + "40354": 25, + "40356": 0, + "40358": 38400, + "40360": 2, + "40362": 1663480.8, + "40364": 1, + "40366": 0, + "40368": 50, + "40370": 20 +} + + */ + + collectorReadMessage (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 collectorReadMessage" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling collectorReadMessage" + ) + } + if (opts.identifier === undefined || opts.identifier === null) { + throw new Error( + "Missing the required parameter 'opts.identifier' when calling collectorReadMessage" + ) + } + if (opts.protocol === undefined || opts.protocol === null) { + throw new Error( + "Missing the required parameter 'opts.protocol' when calling collectorReadMessage" + ) + } + + let postBody = null + let queryParams = {} + if (opts.identifier !== undefined && opts.identifier !== null) { + queryParams['identifier'] = opts.identifier + } + if (opts.protocol !== undefined && opts.protocol !== null) { + queryParams['protocol'] = opts.protocol + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 collectorReadMessage 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}/loongrayinstances/{instanceId}/readCollectorProperty', + '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) + } + ) + } + + /** + * (0x03)读保持寄存器 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - Hub实例Id + * @param {string} opts.identifier - 连接码 + * @param {integer} opts.addressOfFirstRegister - 起始地址,如40301 + * @param {integer} opts.numberOfRegisters - 寄存器数量 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param object readData 读取寄存器值,key:寄存器地址 value:寄存器值 + */ + + readHoldingRegisters (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 readHoldingRegisters" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling readHoldingRegisters" + ) + } + if (opts.identifier === undefined || opts.identifier === null) { + throw new Error( + "Missing the required parameter 'opts.identifier' when calling readHoldingRegisters" + ) + } + if ( + opts.addressOfFirstRegister === undefined || + opts.addressOfFirstRegister === null + ) { + throw new Error( + "Missing the required parameter 'opts.addressOfFirstRegister' when calling readHoldingRegisters" + ) + } + if ( + opts.numberOfRegisters === undefined || + opts.numberOfRegisters === null + ) { + throw new Error( + "Missing the required parameter 'opts.numberOfRegisters' when calling readHoldingRegisters" + ) + } + + let postBody = null + let queryParams = {} + if (opts.identifier !== undefined && opts.identifier !== null) { + queryParams['identifier'] = opts.identifier + } + if ( + opts.addressOfFirstRegister !== undefined && + opts.addressOfFirstRegister !== null + ) { + queryParams['addressOfFirstRegister'] = opts.addressOfFirstRegister + } + if ( + opts.numberOfRegisters !== undefined && + opts.numberOfRegisters !== null + ) { + queryParams['numberOfRegisters'] = opts.numberOfRegisters + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 readHoldingRegisters 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}/loongrayinstances/{instanceId}/readHoldingRegisters', + '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 - Hub实例Id + * @param {string} opts.identifier - 当前的链接码 + * @param {string} [opts.protocol] - 当前的协议类型,非必填项 + optional + * @param {object} opts.data - 当前待写入的数据 +如语音播报控制器-指定播放设备,寄存地址:13对应16进制0x0D,寄存器值:2 +{ + "13":2 +} +如语音播报控制器-播放控制,寄存地址:14对应16进制0x0E,寄存器值:1 +{ + "14": 1 +} +如语音播报控制器-音量设置,寄存地址:15对应16进制0x0F,寄存器值:10,取值范围0~30 +{ + "15": 10 +} +如语音播报控制器-指定文件夹和文件播放,寄存地址:16对应16进制0x10,寄存器值:1 +寄存器值为两字节,第一个字节为文件夹,第二个字节为文件名 +如0x01文件夹,0x03文件名,0x0103换算为10进制为259 +{ + "16": 259 +} +如语音播报控制器-组合播放,寄存器地址:17、18和19,寄存器值:257、258和259,寄存器值的算法和指定文件夹和文件播放是一致的,如259可换算为0x01文件夹,0x03文件名 +{ + "17": 257, + "18": 258, + "19": 259 +} +如语音播报控制器-播放广告,寄存地址:32对应16进制0x20,寄存器值:259,寄存器值的算法和指定文件夹和文件播放是一致的,如259可换算为0x01文件夹,0x03文件名 +{ + "32": 259 +} +如语音播报控制器-指定文件夹循环播放,寄存地址:33对应16进制0x21,寄存器值:256,寄存器值的算法,如256可换算为0x0100文件夹 +{ + "33": 256 +} +如语音播报控制器-指定文件夹随机播放,寄存地址:34对应16进制0x22,寄存器值:256,寄存器值的算法,如256可换算为0x0100文件夹 +{ + "34": 256 +} +如语音播报控制器-指定曲目播放,寄存地址:35对应16进制0x23,寄存器值:13,歌曲选择范围为0~3000 +{ + "35": 13 +} +如电梯数据采集器-传感器管理数据更新 +{ + "40426": 1, + "40427": 1, + "40428": 1, + "40429": 1, + "40430": 1, + "40431": 1, + "40432": 1, + "40433": 1, + "40434": 1, + "40435": 1, + "40436": 1, + "40437": 1, + "40438": 1, + "40439": 1, + "40440": 1 +} +如电梯数据采集器-采集器属性数据更新 +{ + "40441": 40441, + "40443": 40443, + "40444": 40444, + "40445": 40445, + "40446": 40446, + "40447": 40447, + "40448": 40448, + "40449": 40449, + "40450": 40450 +} +如电梯数据采集器-电梯属性数据更新 +{ + "40801": 1, + "40802": 1, + "40803": 1, + "40804": 1, + "40805": 1, + "40806": 1, + "40807": 1, + "40808": 1, + "40809": 1, + "40810": 1 +} +如电梯数据采集器-楼层数据更新 +{ + "40797": 1, + "40798": 1, + "40799": 1 +} + + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string writeStatus + */ + + collectorWriteMessage (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 collectorWriteMessage" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling collectorWriteMessage" + ) + } + if (opts.identifier === undefined || opts.identifier === null) { + throw new Error( + "Missing the required parameter 'opts.identifier' when calling collectorWriteMessage" + ) + } + if (opts.data === undefined || opts.data === null) { + throw new Error( + "Missing the required parameter 'opts.data' when calling collectorWriteMessage" + ) + } + + let postBody = {} + if (opts.identifier !== undefined && opts.identifier !== null) { + postBody['identifier'] = opts.identifier + } + if (opts.protocol !== undefined && opts.protocol !== null) { + postBody['protocol'] = opts.protocol + } + if (opts.data !== undefined && opts.data !== null) { + postBody['data'] = opts.data + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 collectorWriteMessage 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}/loongrayinstances/{instanceId}/writeCollectorProperty', + '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 - 设备归属的实例ID + * @param {string} opts.deviceId - 设备Id + * @param {string} [opts.model] - 设备型号 optional + * @param {string} [opts.manufacturer] - 设备厂商 optional + * @param {string} [opts.description] - 设备名 optional + * @param {integer} [opts.status] - 设备状态 optional + * @param {string} [opts.identifier] - 连接码 optional + * @param {string} [opts.deviceName] - 心跳 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param deviceVO device 设备详情 + */ + + updateLooDevice (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 updateLooDevice" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling updateLooDevice" + ) + } + if (opts.deviceId === undefined || opts.deviceId === null) { + throw new Error( + "Missing the required parameter 'opts.deviceId' when calling updateLooDevice" + ) + } + + let postBody = {} + if (opts.model !== undefined && opts.model !== null) { + postBody['model'] = opts.model + } + if (opts.manufacturer !== undefined && opts.manufacturer !== null) { + postBody['manufacturer'] = opts.manufacturer + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + if (opts.identifier !== undefined && opts.identifier !== null) { + postBody['identifier'] = opts.identifier + } + if (opts.deviceName !== undefined && opts.deviceName !== null) { + postBody['deviceName'] = opts.deviceName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + deviceId: opts.deviceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 updateLooDevice 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}/instances/{instanceId}/device/{deviceId}:looupdate', + '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 - 设备归属的实例ID + * @param {string} opts.preOrderId - 申请单编号 + * @param {string} opts.userPinParam - 用户Pin + * @param {string} [opts.deviceName] - 心跳 optional + * @param {string} [opts.productKey] - 设备所归属的产品 optional + * @param {string} [opts.model] - 设备型号 optional + * @param {string} [opts.manufacturer] - 厂商 optional + * @param {string} [opts.identifier] - 连接码 optional + * @param {string} [opts.description] - 设备名 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string deviceName 设备名称 + * @param string identifier 设备标识符 + * @param string secret 设备秘钥 + */ + + addLooDevice (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 addLooDevice" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling addLooDevice" + ) + } + if (opts.preOrderId === undefined || opts.preOrderId === null) { + throw new Error( + "Missing the required parameter 'opts.preOrderId' when calling addLooDevice" + ) + } + if (opts.userPinParam === undefined || opts.userPinParam === null) { + throw new Error( + "Missing the required parameter 'opts.userPinParam' when calling addLooDevice" + ) + } + + let postBody = {} + if (opts.userPinParam !== undefined && opts.userPinParam !== null) { + postBody['userPinParam'] = opts.userPinParam + } + if (opts.deviceName !== undefined && opts.deviceName !== null) { + postBody['deviceName'] = opts.deviceName + } + if (opts.productKey !== undefined && opts.productKey !== null) { + postBody['productKey'] = opts.productKey + } + if (opts.model !== undefined && opts.model !== null) { + postBody['model'] = opts.model + } + if (opts.manufacturer !== undefined && opts.manufacturer !== null) { + postBody['manufacturer'] = opts.manufacturer + } + if (opts.identifier !== undefined && opts.identifier !== null) { + postBody['identifier'] = opts.identifier + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + preOrderId: opts.preOrderId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 addLooDevice 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}/instances/{instanceId}/preOrderId/{preOrderId}/device_loongray:add', + '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 - 设备归属的实例ID + * @param {string} [opts.deviceName] - 设备名称,模糊匹配 optional + * @param {string} [opts.manufacturer] - 设备厂商,模糊匹配 optional + * @param {string} [opts.model] - 设备型号,模糊匹配 optional + * @param {integer} [opts.status] - 设备状态 0-未激活,1-激活离线,2-激活在线 optional + * @param {string} [opts.productKey] - 设备所归属的产品Key optional + * @param {integer} [opts.deviceType] - 设备类型,同产品类型,0-设备,1-网关 optional + * @param {integer} [opts.nowPage] - 当前页数 optional + * @param {integer} [opts.pageSize] - 每页的数据条数 optional + * @param {string} [opts.order] - 排序关键字--name,type,productKey,status--最多支持一个字段 optional + * @param {string} [opts.direction] - 顺序,升序降序--asc,desc optional + * @param {string} [opts.parentId] - 父设备Id optional + * @param {integer} [opts.orderId] - 订单号 optional + * @param {string} [opts.deviceCollectorType] - 设备采集器类型 optional + * @param {string} [opts.queryUserPin] - 查询的userPin optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer pageSize + * @param integer nowPage + * @param integer totalSize + * @param integer totalPage + * @param deviceVO data + */ + + loongrayQueryPage (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 loongrayQueryPage" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling loongrayQueryPage" + ) + } + + let postBody = null + let queryParams = {} + if (opts.deviceName !== undefined && opts.deviceName !== null) { + queryParams['deviceName'] = opts.deviceName + } + if (opts.manufacturer !== undefined && opts.manufacturer !== null) { + queryParams['manufacturer'] = opts.manufacturer + } + if (opts.model !== undefined && opts.model !== null) { + queryParams['model'] = opts.model + } + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + if (opts.productKey !== undefined && opts.productKey !== null) { + queryParams['productKey'] = opts.productKey + } + if (opts.deviceType !== undefined && opts.deviceType !== null) { + queryParams['deviceType'] = opts.deviceType + } + if (opts.nowPage !== undefined && opts.nowPage !== null) { + queryParams['nowPage'] = opts.nowPage + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.order !== undefined && opts.order !== null) { + queryParams['order'] = opts.order + } + if (opts.direction !== undefined && opts.direction !== null) { + queryParams['direction'] = opts.direction + } + if (opts.parentId !== undefined && opts.parentId !== null) { + queryParams['parentId'] = opts.parentId + } + if (opts.orderId !== undefined && opts.orderId !== null) { + queryParams['orderId'] = opts.orderId + } + if ( + opts.deviceCollectorType !== undefined && + opts.deviceCollectorType !== null + ) { + queryParams['deviceCollectorType'] = opts.deviceCollectorType + } + if (opts.queryUserPin !== undefined && opts.queryUserPin !== null) { + queryParams['queryUserPin'] = opts.queryUserPin + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 loongrayQueryPage 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}/instances/{instanceId}/devices:loongrayQueryPage', + '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} [opts.productKey] - 过滤条件,产品Key optional + * @param {string} [opts.parentId] - 针对parentId下的子设备进行统计 optional + * @param {string} [opts.deviceCollectorType] - 采集器类型 optional + * @param {string} [opts.queryUserPin] - 查询的用户信息 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer devices 用户的设备数 + * @param integer activatedDevices 已激活的设备数 + * @param integer onlineDevices 在线的设备数 + * @param integer monthMessages 当月消息数 + * @param integer monthDuration 当月设备在线时长 + * @param integer products 产品数 + */ + + queryAdminStatistics (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 queryAdminStatistics" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling queryAdminStatistics" + ) + } + + let postBody = null + let queryParams = {} + if (opts.productKey !== undefined && opts.productKey !== null) { + queryParams['productKey'] = opts.productKey + } + if (opts.parentId !== undefined && opts.parentId !== null) { + queryParams['parentId'] = opts.parentId + } + if ( + opts.deviceCollectorType !== undefined && + opts.deviceCollectorType !== null + ) { + queryParams['deviceCollectorType'] = opts.deviceCollectorType + } + if (opts.queryUserPin !== undefined && opts.queryUserPin !== null) { + queryParams['queryUserPin'] = opts.queryUserPin + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 queryAdminStatistics 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}/instances/{instanceId}/device:queryAdminStatistics', + '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.deviceName - 设备名称 + * @param {string} opts.instanceId - 设备归属的实例ID + * @param {string} opts.productKey - 产品Key + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + removeLoongrayDevice (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 removeLoongrayDevice" + ) + } + + opts = opts || {} + + if (opts.deviceName === undefined || opts.deviceName === null) { + throw new Error( + "Missing the required parameter 'opts.deviceName' when calling removeLoongrayDevice" + ) + } + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling removeLoongrayDevice" + ) + } + if (opts.productKey === undefined || opts.productKey === null) { + throw new Error( + "Missing the required parameter 'opts.productKey' when calling removeLoongrayDevice" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + deviceName: opts.deviceName, + instanceId: opts.instanceId, + productKey: opts.productKey + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 removeLoongrayDevice 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}/instances/{instanceId}/products/{productKey}/device/{deviceName}:loongraydelete', + '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.instanceId - IoT Engine实例ID信息 + * @param {string} opts.productKey - 产品Key + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string productName 产品名称 + * @param integer productType 节点类型,取值: +0:设备。设备不能挂载子设备。可以直连物联网平台,也可以作为网关的子设备连接物联网平台 +1:网关。网关可以挂载子设备,具有子设备管理模块,维持子设备的拓扑关系,和将拓扑关系同步到物联网平台 + + * @param string productKey 产品key + * @param string productSecret 产品秘钥 + * @param integer createdTime 创建时间,时间为东八区(UTC/GMT+08:00) + * @param integer deviceCount 包含设备数 + * @param integer dynamicRegister 动态注册,0:关闭,1:开启 + * @param string productDescription 产品描述信息 + * @param string templateName 产品类型,如自定义等 + */ + + describeProductWithAdmin (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 describeProductWithAdmin" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeProductWithAdmin" + ) + } + if (opts.productKey === undefined || opts.productKey === null) { + throw new Error( + "Missing the required parameter 'opts.productKey' when calling describeProductWithAdmin" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + productKey: opts.productKey + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 describeProductWithAdmin 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}/loongrayinstances/{instanceId}/products/{productKey}/admin', + '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 - IoT Engine实例ID信息 + * @param {string} opts.productKey - 产品Key + * @param {string} [opts.productName] - 产品名称,名称不可为空,3-30个字符,只支持汉字、英文字母、数字、下划线“_”及中划线“-”,必须以汉字、英文字母及数字开头结尾 optional + * @param {string} [opts.productDescription] - 产品描述,80字符以内 optional + * @param {integer} [opts.dynamicRegister] - 动态注册,0:关闭,1:开启 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateProductWithAdmin (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 updateProductWithAdmin" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling updateProductWithAdmin" + ) + } + if (opts.productKey === undefined || opts.productKey === null) { + throw new Error( + "Missing the required parameter 'opts.productKey' when calling updateProductWithAdmin" + ) + } + + let postBody = {} + if (opts.productName !== undefined && opts.productName !== null) { + postBody['productName'] = opts.productName + } + if ( + opts.productDescription !== undefined && + opts.productDescription !== null + ) { + postBody['productDescription'] = opts.productDescription + } + if (opts.dynamicRegister !== undefined && opts.dynamicRegister !== null) { + postBody['dynamicRegister'] = opts.dynamicRegister + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + productKey: opts.productKey + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 updateProductWithAdmin 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}/loongrayinstances/{instanceId}/products/{productKey}/admin', + 'PATCH', + 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 - IoT Engine实例ID信息 + * @param {string} opts.productKey - 产品Key + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteProductWithAdmin (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 deleteProductWithAdmin" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteProductWithAdmin" + ) + } + if (opts.productKey === undefined || opts.productKey === null) { + throw new Error( + "Missing the required parameter 'opts.productKey' when calling deleteProductWithAdmin" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + productKey: opts.productKey + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 deleteProductWithAdmin 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}/loongrayinstances/{instanceId}/products/{productKey}/admin', + '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.instanceId - IoT Engine实例ID信息 + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞) optional + * @param {integer} [opts.pageSize] - 分页大小,默认为10,取值范围:[10,100] optional + * @param {filter} [opts.filters] - productName-产品名称,模糊匹配,支持单个 +productKey-产品key,精确匹配,支持单个 +productType-产品类型,精确匹配,支持单个 +templateName-模板名称,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param pageinfoVO page 分页信息 + * @param product products + */ + + listProductsWithAdmin (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 listProductsWithAdmin" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling listProductsWithAdmin" + ) + } + + 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, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 listProductsWithAdmin 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}/loongrayinstances/{instanceId}/products:describeAll', + '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 - IoT Engine实例ID信息 + * @param {string} opts.productName - 产品名称,名称不可为空,3-30个字符,只支持汉字、英文字母、数字、下划线“_”及中划线“-”,必须以汉字、英文字母及数字开头结尾 + * @param {integer} opts.productType - 节点类型,取值: +0:设备。设备不能挂载子设备。可以直连物联网平台,也可以作为网关的子设备连接物联网平台 +1:网关。网关可以挂载子设备,具有子设备管理模块,维持子设备的拓扑关系,和将拓扑关系同步到物联网平台 + + * @param {string} [opts.productDescription] - 产品描述,80字符以内 optional + * @param {string} [opts.templateId] - 物模型模板ID,内部参数,用户不可见,默认为自定义 optional + * @param {object} [opts.internalTags] - 内部标签,内部参数,用户不可见,隐藏标签:hidden:true optional + * @param {string} opts.collDeviceType - 产品名下所有设备的采集器类型 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string productKey + */ + + createAdminProduct (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 createAdminProduct" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createAdminProduct" + ) + } + if (opts.productName === undefined || opts.productName === null) { + throw new Error( + "Missing the required parameter 'opts.productName' when calling createAdminProduct" + ) + } + if (opts.productType === undefined || opts.productType === null) { + throw new Error( + "Missing the required parameter 'opts.productType' when calling createAdminProduct" + ) + } + if (opts.collDeviceType === undefined || opts.collDeviceType === null) { + throw new Error( + "Missing the required parameter 'opts.collDeviceType' when calling createAdminProduct" + ) + } + + let postBody = {} + if (opts.productName !== undefined && opts.productName !== null) { + postBody['productName'] = opts.productName + } + if (opts.productType !== undefined && opts.productType !== null) { + postBody['productType'] = opts.productType + } + if ( + opts.productDescription !== undefined && + opts.productDescription !== null + ) { + postBody['productDescription'] = opts.productDescription + } + if (opts.templateId !== undefined && opts.templateId !== null) { + postBody['templateId'] = opts.templateId + } + if (opts.internalTags !== undefined && opts.internalTags !== null) { + postBody['internalTags'] = opts.internalTags + } + if (opts.collDeviceType !== undefined && opts.collDeviceType !== null) { + postBody['collDeviceType'] = opts.collDeviceType + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 createAdminProduct 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}/loongrayinstances/{instanceId}/productsAdmin', + '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 - IoT Engine实例ID信息 + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞) optional + * @param {integer} [opts.pageSize] - 分页大小,默认为10,取值范围:[10,100] optional + * @param {filter} [opts.filters] - productName-产品名称,模糊匹配,支持单个 +productKey-产品key,精确匹配,支持单个 +productType-产品类型,精确匹配,支持单个 +templateName-模板名称,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param pageinfoVO page 分页信息 + * @param product products + */ + + listProducts (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 listProducts" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling listProducts" + ) + } + + 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, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 listProducts 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}/instances/{instanceId}/products', + '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 - IoT Engine实例ID信息 + * @param {string} opts.productName - 产品名称,名称不可为空,3-30个字符,只支持汉字、英文字母、数字、下划线“_”及中划线“-”,必须以汉字、英文字母及数字开头结尾 + * @param {integer} opts.productType - 节点类型,取值: +0:设备。设备不能挂载子设备。可以直连物联网平台,也可以作为网关的子设备连接物联网平台 +1:网关。网关可以挂载子设备,具有子设备管理模块,维持子设备的拓扑关系,和将拓扑关系同步到物联网平台 + + * @param {string} [opts.productDescription] - 产品描述,80字符以内 optional + * @param {string} [opts.templateId] - 物模型模板ID,内部参数,用户不可见,默认为自定义 optional + * @param {object} [opts.internalTags] - 内部标签,内部参数,用户不可见,隐藏标签:hidden:true optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string productKey + */ + + createProduct (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 createProduct" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createProduct" + ) + } + if (opts.productName === undefined || opts.productName === null) { + throw new Error( + "Missing the required parameter 'opts.productName' when calling createProduct" + ) + } + if (opts.productType === undefined || opts.productType === null) { + throw new Error( + "Missing the required parameter 'opts.productType' when calling createProduct" + ) + } + + let postBody = {} + if (opts.productName !== undefined && opts.productName !== null) { + postBody['productName'] = opts.productName + } + if (opts.productType !== undefined && opts.productType !== null) { + postBody['productType'] = opts.productType + } + if ( + opts.productDescription !== undefined && + opts.productDescription !== null + ) { + postBody['productDescription'] = opts.productDescription + } + if (opts.templateId !== undefined && opts.templateId !== null) { + postBody['templateId'] = opts.templateId + } + if (opts.internalTags !== undefined && opts.internalTags !== null) { + postBody['internalTags'] = opts.internalTags + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 createProduct 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}/instances/{instanceId}/products', + '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 - IoT Engine实例ID信息 + * @param {string} opts.productKey - 产品Key + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string productName 产品名称 + * @param integer productType 节点类型,取值: +0:设备。设备不能挂载子设备。可以直连物联网平台,也可以作为网关的子设备连接物联网平台 +1:网关。网关可以挂载子设备,具有子设备管理模块,维持子设备的拓扑关系,和将拓扑关系同步到物联网平台 + + * @param string productKey 产品key + * @param string productSecret 产品秘钥 + * @param integer createdTime 创建时间,时间为东八区(UTC/GMT+08:00) + * @param integer deviceCount 包含设备数 + * @param integer dynamicRegister 动态注册,0:关闭,1:开启 + * @param string productDescription 产品描述信息 + * @param string templateName 产品类型,如自定义等 + */ + + describeProduct (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 describeProduct" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeProduct" + ) + } + if (opts.productKey === undefined || opts.productKey === null) { + throw new Error( + "Missing the required parameter 'opts.productKey' when calling describeProduct" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + productKey: opts.productKey + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 describeProduct 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}/instances/{instanceId}/products/{productKey}', + '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 - IoT Engine实例ID信息 + * @param {string} opts.productKey - 产品Key + * @param {string} [opts.productName] - 产品名称,名称不可为空,3-30个字符,只支持汉字、英文字母、数字、下划线“_”及中划线“-”,必须以汉字、英文字母及数字开头结尾 optional + * @param {string} [opts.productDescription] - 产品描述,80字符以内 optional + * @param {integer} [opts.dynamicRegister] - 动态注册,0:关闭,1:开启 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateProduct (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 updateProduct" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling updateProduct" + ) + } + if (opts.productKey === undefined || opts.productKey === null) { + throw new Error( + "Missing the required parameter 'opts.productKey' when calling updateProduct" + ) + } + + let postBody = {} + if (opts.productName !== undefined && opts.productName !== null) { + postBody['productName'] = opts.productName + } + if ( + opts.productDescription !== undefined && + opts.productDescription !== null + ) { + postBody['productDescription'] = opts.productDescription + } + if (opts.dynamicRegister !== undefined && opts.dynamicRegister !== null) { + postBody['dynamicRegister'] = opts.dynamicRegister + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + productKey: opts.productKey + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 updateProduct 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}/instances/{instanceId}/products/{productKey}', + 'PATCH', + 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 - IoT Engine实例ID信息 + * @param {string} opts.productKey - 产品Key + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteProduct (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 deleteProduct" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteProduct" + ) + } + if (opts.productKey === undefined || opts.productKey === null) { + throw new Error( + "Missing the required parameter 'opts.productKey' when calling deleteProduct" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + productKey: opts.productKey + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 deleteProduct 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}/instances/{instanceId}/products/{productKey}', + '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.instanceId - IoT Hub实例ID信息 + * @param {string} opts.productKey - 产品Key + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞) optional + * @param {integer} [opts.pageSize] - 分页大小,默认为10,取值范围:[10,100] optional + * @param {filter} [opts.filters] - abilityName-功能名称,精确匹配 +abilityType-功能类型,精确匹配 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param pageinfoVO page 分页信息 + * @param productAbility abilities + */ + + listProductAbilities (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 listProductAbilities" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling listProductAbilities" + ) + } + if (opts.productKey === undefined || opts.productKey === null) { + throw new Error( + "Missing the required parameter 'opts.productKey' when calling listProductAbilities" + ) + } + + 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, + instanceId: opts.instanceId, + productKey: opts.productKey + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 listProductAbilities 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}/instances/{instanceId}/products/{productKey}/abilities', + '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 - IoT Hub实例ID信息 + * @param {string} opts.productKey - 产品Key + * @param {object} opts.thingModel - 物模型JSON + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + importThingModel (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 importThingModel" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling importThingModel" + ) + } + if (opts.productKey === undefined || opts.productKey === null) { + throw new Error( + "Missing the required parameter 'opts.productKey' when calling importThingModel" + ) + } + if (opts.thingModel === undefined || opts.thingModel === null) { + throw new Error( + "Missing the required parameter 'opts.thingModel' when calling importThingModel" + ) + } + + let postBody = {} + if (opts.thingModel !== undefined && opts.thingModel !== null) { + postBody['thingModel'] = opts.thingModel + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + productKey: opts.productKey + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 importThingModel 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}/instances/{instanceId}/products/{productKey}/abilities:importThingModel', + '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) + } + ) + } + + /** + * 导出物模型 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - IoT Hub实例ID信息 + * @param {string} opts.productKey - 产品Key + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param object thingModel + */ + + exportThingModel (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 exportThingModel" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling exportThingModel" + ) + } + if (opts.productKey === undefined || opts.productKey === null) { + throw new Error( + "Missing the required parameter 'opts.productKey' when calling exportThingModel" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + productKey: opts.productKey + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 exportThingModel 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}/instances/{instanceId}/products/{productKey}/abilities:exportThingModel', + '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) + } + ) + } + + /** + * 查看产品自定义Topic列表 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - IoTCore实例ID信息 + * @param {string} opts.productKey - 产品Key + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞) optional + * @param {integer} [opts.pageSize] - 分页大小,默认为10,取值范围:[10,100] optional + * @param {filter} [opts.filters] - topicShortName-topic名称,模糊匹配,支持单个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param pageinfoVO page 分页信息 + * @param productTopic productTopics + */ + + describeProductTopics (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 describeProductTopics" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeProductTopics" + ) + } + if (opts.productKey === undefined || opts.productKey === null) { + throw new Error( + "Missing the required parameter 'opts.productKey' when calling describeProductTopics" + ) + } + + 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, + instanceId: opts.instanceId, + productKey: opts.productKey + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 describeProductTopics 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}/instances/{instanceId}/products/{productKey}/topics', + '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) + } + ) + } + + /** + * 新建产品自定义Topic + * @param {Object} opts - parameters + * @param {string} opts.instanceId - IoTCore实例ID信息 + * @param {string} opts.productKey - 产品Key + * @param {string} opts.topicShortName - Topic名称为必填,同一个产品下的Topic名称不能重复 +只能包含字母,数字和下划线,最多64个字符,每个层级都不能为空 +不能以/结尾 + + * @param {string} opts.topicOperation - 操作权限,设备对该Topic类的操作权限,取值 +pub:发布 +sub:订阅 + + * @param {string} [opts.topicDescription] - 描述, 0-50个字符 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string topicId + */ + + createProductTopic (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 createProductTopic" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createProductTopic" + ) + } + if (opts.productKey === undefined || opts.productKey === null) { + throw new Error( + "Missing the required parameter 'opts.productKey' when calling createProductTopic" + ) + } + if (opts.topicShortName === undefined || opts.topicShortName === null) { + throw new Error( + "Missing the required parameter 'opts.topicShortName' when calling createProductTopic" + ) + } + if (opts.topicOperation === undefined || opts.topicOperation === null) { + throw new Error( + "Missing the required parameter 'opts.topicOperation' when calling createProductTopic" + ) + } + + let postBody = {} + if (opts.topicShortName !== undefined && opts.topicShortName !== null) { + postBody['topicShortName'] = opts.topicShortName + } + if (opts.topicOperation !== undefined && opts.topicOperation !== null) { + postBody['topicOperation'] = opts.topicOperation + } + if (opts.topicDescription !== undefined && opts.topicDescription !== null) { + postBody['topicDescription'] = opts.topicDescription + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + productKey: opts.productKey + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 createProductTopic 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}/instances/{instanceId}/products/{productKey}/topics', + '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) + } + ) + } + + /** + * 查看产品自定义Topic + * @param {Object} opts - parameters + * @param {string} opts.instanceId - IoTCore实例ID信息 + * @param {string} opts.productKey - 产品Key + * @param {string} opts.topicId - 自定义topic唯一标识 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string topicShortName Topic名称为必填,同一个产品下的Topic名称不能重复 +只能包含字母,数字和下划线,最多64个字符,每个层级都不能为空 +不能以/结尾 + + * @param string topicOperation 操作权限,设备对该Topic类的操作权限,取值 +pub:发布 +sub:订阅 + + * @param string topicDescription 描述, 0-50个字符 + * @param integer createdTime 创建时间,时间为东八区(UTC/GMT+08:00) + * @param integer udpatedTime 修改时间,时间为东八区(UTC/GMT+08:00) + */ + + describeProductTopic (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 describeProductTopic" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeProductTopic" + ) + } + if (opts.productKey === undefined || opts.productKey === null) { + throw new Error( + "Missing the required parameter 'opts.productKey' when calling describeProductTopic" + ) + } + if (opts.topicId === undefined || opts.topicId === null) { + throw new Error( + "Missing the required parameter 'opts.topicId' when calling describeProductTopic" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + productKey: opts.productKey, + topicId: opts.topicId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotcore/1.1.25' + } + + 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 describeProductTopic 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}/instances/{instanceId}/products/{productKey}/topics/{topicId}', + '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 = IOTCORE diff --git a/packages/libs/lib-jdcloud/src/repo/iotedge/v2/iotedge.js b/packages/libs/lib-jdcloud/src/repo/iotedge/v2/iotedge.js new file mode 100644 index 000000000..621906ca6 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/iotedge/v2/iotedge.js @@ -0,0 +1,1606 @@ +/* + * 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. + * + * EdgeSubDeviceManager + * iotcore-Edge子设备管理 + * + * 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 = 'iotedge' +Service._services[serviceId] = true + +/** + * iotedge service. + * @version 1.0.0 + */ + +JDCloud.IOTEDGE = class IOTEDGE extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'console-be.iotedge.jdcloud.com' + options.basePath = '/v2' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 部署APP应用 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 设备归属的实例ID + * @param {string} opts.hardwareId - 硬件版本 + * @param {string} opts.osId - OSID + * @param {string} opts.appName - App内部名称 + * @param {string} opts.appVersion - App版本 + * @param {string} opts.edgeName - edge名称 + * @param {string} [opts.env] - App安装变量(默认为空字符串) optional + * @param {integer} opts.privileged - 是否特权模式运行(0-否 1-是) + * @param {string} [opts.volume] - 硬盘操作卷 optional + * @param {integer} opts.appType - App类型(1-设备服务 2-边缘应用) + * @param {integer} opts.useHost - 是否使用Edge系统的Host配置(0-否 1-是) + * @param {integer} opts.cpuShares - CPU权重(低-128 中-256 高-512) + * @param {string} opts.memoryLimit - 内存限制(0-无限 低-128 中-256 高-512) + * @param {string} opts.restartPolicy - 重启策略(0-never 1-always 2-onFailure) + * @param {integer} opts.deployAppStatus - 部署APP状态(3-更新 其余都是安装) + * @param {integer} [opts.appStatus] - App状态 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer deployStatus 部署状态 + */ + + deployApp (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 deployApp" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deployApp" + ) + } + if (opts.hardwareId === undefined || opts.hardwareId === null) { + throw new Error( + "Missing the required parameter 'opts.hardwareId' when calling deployApp" + ) + } + if (opts.osId === undefined || opts.osId === null) { + throw new Error( + "Missing the required parameter 'opts.osId' when calling deployApp" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling deployApp" + ) + } + if (opts.appVersion === undefined || opts.appVersion === null) { + throw new Error( + "Missing the required parameter 'opts.appVersion' when calling deployApp" + ) + } + if (opts.edgeName === undefined || opts.edgeName === null) { + throw new Error( + "Missing the required parameter 'opts.edgeName' when calling deployApp" + ) + } + if (opts.privileged === undefined || opts.privileged === null) { + throw new Error( + "Missing the required parameter 'opts.privileged' when calling deployApp" + ) + } + if (opts.appType === undefined || opts.appType === null) { + throw new Error( + "Missing the required parameter 'opts.appType' when calling deployApp" + ) + } + if (opts.useHost === undefined || opts.useHost === null) { + throw new Error( + "Missing the required parameter 'opts.useHost' when calling deployApp" + ) + } + if (opts.cpuShares === undefined || opts.cpuShares === null) { + throw new Error( + "Missing the required parameter 'opts.cpuShares' when calling deployApp" + ) + } + if (opts.memoryLimit === undefined || opts.memoryLimit === null) { + throw new Error( + "Missing the required parameter 'opts.memoryLimit' when calling deployApp" + ) + } + if (opts.restartPolicy === undefined || opts.restartPolicy === null) { + throw new Error( + "Missing the required parameter 'opts.restartPolicy' when calling deployApp" + ) + } + if (opts.deployAppStatus === undefined || opts.deployAppStatus === null) { + throw new Error( + "Missing the required parameter 'opts.deployAppStatus' when calling deployApp" + ) + } + + let postBody = {} + if (opts.appName !== undefined && opts.appName !== null) { + postBody['appName'] = opts.appName + } + if (opts.appVersion !== undefined && opts.appVersion !== null) { + postBody['appVersion'] = opts.appVersion + } + if (opts.edgeName !== undefined && opts.edgeName !== null) { + postBody['edgeName'] = opts.edgeName + } + if (opts.env !== undefined && opts.env !== null) { + postBody['env'] = opts.env + } + if (opts.privileged !== undefined && opts.privileged !== null) { + postBody['privileged'] = opts.privileged + } + if (opts.volume !== undefined && opts.volume !== null) { + postBody['volume'] = opts.volume + } + if (opts.appType !== undefined && opts.appType !== null) { + postBody['appType'] = opts.appType + } + if (opts.useHost !== undefined && opts.useHost !== null) { + postBody['useHost'] = opts.useHost + } + if (opts.cpuShares !== undefined && opts.cpuShares !== null) { + postBody['cpuShares'] = opts.cpuShares + } + if (opts.memoryLimit !== undefined && opts.memoryLimit !== null) { + postBody['memoryLimit'] = opts.memoryLimit + } + if (opts.restartPolicy !== undefined && opts.restartPolicy !== null) { + postBody['restartPolicy'] = opts.restartPolicy + } + if (opts.deployAppStatus !== undefined && opts.deployAppStatus !== null) { + postBody['deployAppStatus'] = opts.deployAppStatus + } + if (opts.appStatus !== undefined && opts.appStatus !== null) { + postBody['appStatus'] = opts.appStatus + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + hardwareId: opts.hardwareId, + osId: opts.osId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotedge/1.0.0' + } + + 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 deployApp 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}/instances/{instanceId}/hardwareId/{hardwareId}/os/{osId}/edgeApp:deployApp', + '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) + } + ) + } + + /** + * 查询已经部署的App应用 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 设备归属的实例ID + * @param {string} opts.hardwareId - 硬件版本 + * @param {string} opts.osId - OSID + * @param {string} opts.edgeName - Edge名称 + * @param {string} opts.productKey - Edge对应的产品Key + * @param {integer} opts.appType - App类型(1-设备服务 2-边缘应用) + * @param {integer} [opts.nowPage] - 当前的规则位置 optional + * @param {integer} [opts.pageSize] - 显示多少个数据 optional + * @param {integer} [opts.order] - 排序方式 optional + * @param {integer} [opts.property] - 排序依据的关键词 optional + * @param {string} [opts.searchText] - 模糊搜索关键字 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param describeAppsRespVO appsResp + * @param object page 分页信息 + */ + + describeDeployApp (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 describeDeployApp" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeDeployApp" + ) + } + if (opts.hardwareId === undefined || opts.hardwareId === null) { + throw new Error( + "Missing the required parameter 'opts.hardwareId' when calling describeDeployApp" + ) + } + if (opts.osId === undefined || opts.osId === null) { + throw new Error( + "Missing the required parameter 'opts.osId' when calling describeDeployApp" + ) + } + if (opts.edgeName === undefined || opts.edgeName === null) { + throw new Error( + "Missing the required parameter 'opts.edgeName' when calling describeDeployApp" + ) + } + if (opts.productKey === undefined || opts.productKey === null) { + throw new Error( + "Missing the required parameter 'opts.productKey' when calling describeDeployApp" + ) + } + if (opts.appType === undefined || opts.appType === null) { + throw new Error( + "Missing the required parameter 'opts.appType' when calling describeDeployApp" + ) + } + + let postBody = {} + if (opts.edgeName !== undefined && opts.edgeName !== null) { + postBody['edgeName'] = opts.edgeName + } + if (opts.productKey !== undefined && opts.productKey !== null) { + postBody['productKey'] = opts.productKey + } + if (opts.appType !== undefined && opts.appType !== null) { + postBody['appType'] = opts.appType + } + if (opts.nowPage !== undefined && opts.nowPage !== null) { + postBody['nowPage'] = opts.nowPage + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + if (opts.order !== undefined && opts.order !== null) { + postBody['order'] = opts.order + } + if (opts.property !== undefined && opts.property !== null) { + postBody['property'] = opts.property + } + if (opts.searchText !== undefined && opts.searchText !== null) { + postBody['searchText'] = opts.searchText + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + hardwareId: opts.hardwareId, + osId: opts.osId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotedge/1.0.0' + } + + 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 describeDeployApp 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}/instances/{instanceId}/hardwareId/{hardwareId}/os/{osId}/edgeApp:describeDeployApp', + '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) + } + ) + } + + /** + * 查询APP部署列表 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 设备归属的实例ID + * @param {string} opts.hardwareId - 硬件版本 + * @param {string} opts.osId - OSID + * @param {string} opts.appName - Edge名称 + * @param {integer} [opts.nowPage] - 当前的规则位置 optional + * @param {integer} [opts.pageSize] - 显示多少个数据 optional + * @param {integer} [opts.order] - 排序方式 optional + * @param {integer} [opts.property] - 排序依据的关键词 optional + * @param {string} [opts.searchText] - 模糊搜索关键字 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param describeDeployDetailsRespVO deployDetails + * @param object page 分页信息 + */ + + describeDeployDetails (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 describeDeployDetails" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeDeployDetails" + ) + } + if (opts.hardwareId === undefined || opts.hardwareId === null) { + throw new Error( + "Missing the required parameter 'opts.hardwareId' when calling describeDeployDetails" + ) + } + if (opts.osId === undefined || opts.osId === null) { + throw new Error( + "Missing the required parameter 'opts.osId' when calling describeDeployDetails" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling describeDeployDetails" + ) + } + + let postBody = {} + if (opts.appName !== undefined && opts.appName !== null) { + postBody['appName'] = opts.appName + } + if (opts.nowPage !== undefined && opts.nowPage !== null) { + postBody['nowPage'] = opts.nowPage + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + if (opts.order !== undefined && opts.order !== null) { + postBody['order'] = opts.order + } + if (opts.property !== undefined && opts.property !== null) { + postBody['property'] = opts.property + } + if (opts.searchText !== undefined && opts.searchText !== null) { + postBody['searchText'] = opts.searchText + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + hardwareId: opts.hardwareId, + osId: opts.osId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotedge/1.0.0' + } + + 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 describeDeployDetails 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}/instances/{instanceId}/hardwareId/{hardwareId}/os/{osId}/edgeApp:describeDeployDetails', + '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) + } + ) + } + + /** + * 卸载安装的APP + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 设备归属的实例ID + * @param {string} opts.hardwareId - 硬件版本 + * @param {string} opts.osId - OSID + * @param {string} opts.edgeName - Edge名称 + * @param {string} opts.appName - APP名称 + * @param {string} opts.deployAppId - 部署ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer unInstallStatus 删除状态 + */ + + unInstallApp (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 unInstallApp" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling unInstallApp" + ) + } + if (opts.hardwareId === undefined || opts.hardwareId === null) { + throw new Error( + "Missing the required parameter 'opts.hardwareId' when calling unInstallApp" + ) + } + if (opts.osId === undefined || opts.osId === null) { + throw new Error( + "Missing the required parameter 'opts.osId' when calling unInstallApp" + ) + } + if (opts.edgeName === undefined || opts.edgeName === null) { + throw new Error( + "Missing the required parameter 'opts.edgeName' when calling unInstallApp" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling unInstallApp" + ) + } + if (opts.deployAppId === undefined || opts.deployAppId === null) { + throw new Error( + "Missing the required parameter 'opts.deployAppId' when calling unInstallApp" + ) + } + + let postBody = {} + if (opts.edgeName !== undefined && opts.edgeName !== null) { + postBody['edgeName'] = opts.edgeName + } + if (opts.appName !== undefined && opts.appName !== null) { + postBody['appName'] = opts.appName + } + if (opts.deployAppId !== undefined && opts.deployAppId !== null) { + postBody['deployAppId'] = opts.deployAppId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + hardwareId: opts.hardwareId, + osId: opts.osId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotedge/1.0.0' + } + + 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 unInstallApp 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}/instances/{instanceId}/hardwareId/{hardwareId}/os/{osId}/edgeApp:unInstallApp', + '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) + } + ) + } + + /** + * APP启动/停止服务 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 设备归属的实例ID + * @param {string} opts.hardwareId - 硬件版本 + * @param {string} opts.osId - OSID + * @param {string} opts.appName - App名称 + * @param {integer} opts.status - APP状态(0停止 1启动) + * @param {string} opts.edgeName - Edge名称 + * @param {string} opts.appVersion - App版本 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer appStatus app状态 + */ + + setAppStatus (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 setAppStatus" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling setAppStatus" + ) + } + if (opts.hardwareId === undefined || opts.hardwareId === null) { + throw new Error( + "Missing the required parameter 'opts.hardwareId' when calling setAppStatus" + ) + } + if (opts.osId === undefined || opts.osId === null) { + throw new Error( + "Missing the required parameter 'opts.osId' when calling setAppStatus" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling setAppStatus" + ) + } + if (opts.status === undefined || opts.status === null) { + throw new Error( + "Missing the required parameter 'opts.status' when calling setAppStatus" + ) + } + if (opts.edgeName === undefined || opts.edgeName === null) { + throw new Error( + "Missing the required parameter 'opts.edgeName' when calling setAppStatus" + ) + } + if (opts.appVersion === undefined || opts.appVersion === null) { + throw new Error( + "Missing the required parameter 'opts.appVersion' when calling setAppStatus" + ) + } + + let postBody = {} + if (opts.appName !== undefined && opts.appName !== null) { + postBody['appName'] = opts.appName + } + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + if (opts.edgeName !== undefined && opts.edgeName !== null) { + postBody['edgeName'] = opts.edgeName + } + if (opts.appVersion !== undefined && opts.appVersion !== null) { + postBody['appVersion'] = opts.appVersion + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + hardwareId: opts.hardwareId, + osId: opts.osId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotedge/1.0.0' + } + + 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 setAppStatus 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}/instances/{instanceId}/hardwareId/{hardwareId}/os/{osId}/edgeApp:setAppStatus', + '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 - 设备归属的实例ID + * @param {string} opts.hardwareId - 硬件版本 + * @param {string} opts.osId - OSID + * @param {string} opts.appName - App名称 + * @param {string} opts.appVersion - app版本 + * @param {string} opts.edgeName - edge名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param describeDeployConfigResp describeConfig App部署信息 + */ + + describeConfig (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 describeConfig" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeConfig" + ) + } + if (opts.hardwareId === undefined || opts.hardwareId === null) { + throw new Error( + "Missing the required parameter 'opts.hardwareId' when calling describeConfig" + ) + } + if (opts.osId === undefined || opts.osId === null) { + throw new Error( + "Missing the required parameter 'opts.osId' when calling describeConfig" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling describeConfig" + ) + } + if (opts.appVersion === undefined || opts.appVersion === null) { + throw new Error( + "Missing the required parameter 'opts.appVersion' when calling describeConfig" + ) + } + if (opts.edgeName === undefined || opts.edgeName === null) { + throw new Error( + "Missing the required parameter 'opts.edgeName' when calling describeConfig" + ) + } + + let postBody = {} + if (opts.appName !== undefined && opts.appName !== null) { + postBody['appName'] = opts.appName + } + if (opts.appVersion !== undefined && opts.appVersion !== null) { + postBody['appVersion'] = opts.appVersion + } + if (opts.edgeName !== undefined && opts.edgeName !== null) { + postBody['edgeName'] = opts.edgeName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + hardwareId: opts.hardwareId, + osId: opts.osId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotedge/1.0.0' + } + + 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 describeConfig 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}/instances/{instanceId}/hardwareId/{hardwareId}/os/{osId}/edgeApp:describeConfig', + '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) + } + ) + } + + /** + * 删除Edge接口 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - IoTCore实例编号 + * @param {string} opts.edgeName - Edge名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteEdgeWithCore (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 deleteEdgeWithCore" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteEdgeWithCore" + ) + } + if (opts.edgeName === undefined || opts.edgeName === null) { + throw new Error( + "Missing the required parameter 'opts.edgeName' when calling deleteEdgeWithCore" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + edgeName: opts.edgeName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotedge/1.0.0' + } + + 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 deleteEdgeWithCore 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}/instances/{instanceId}/edges/{edgeName}', + '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) + } + ) + } + + /** + * 添加Edge设备 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - IoTCore实例编号 + * @param {string} opts.edgeName - Edge名称 + * @param {string} opts.architecture - 硬件平台编号,具体参数参见硬件平台参数文档 + * @param {string} opts.os - 操作系统编号,具体参数参见操作系统参数文档 + * @param {string} opts.manufacturer - Edge厂家信息 + * @param {string} opts.edgeModel - Edge型号信息 + * @param {string} [opts.edgeDesc] - Edge描述 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + addEdgeWithCore (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 addEdgeWithCore" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling addEdgeWithCore" + ) + } + if (opts.edgeName === undefined || opts.edgeName === null) { + throw new Error( + "Missing the required parameter 'opts.edgeName' when calling addEdgeWithCore" + ) + } + if (opts.architecture === undefined || opts.architecture === null) { + throw new Error( + "Missing the required parameter 'opts.architecture' when calling addEdgeWithCore" + ) + } + if (opts.os === undefined || opts.os === null) { + throw new Error( + "Missing the required parameter 'opts.os' when calling addEdgeWithCore" + ) + } + if (opts.manufacturer === undefined || opts.manufacturer === null) { + throw new Error( + "Missing the required parameter 'opts.manufacturer' when calling addEdgeWithCore" + ) + } + if (opts.edgeModel === undefined || opts.edgeModel === null) { + throw new Error( + "Missing the required parameter 'opts.edgeModel' when calling addEdgeWithCore" + ) + } + + let postBody = {} + if (opts.architecture !== undefined && opts.architecture !== null) { + postBody['architecture'] = opts.architecture + } + if (opts.os !== undefined && opts.os !== null) { + postBody['os'] = opts.os + } + if (opts.manufacturer !== undefined && opts.manufacturer !== null) { + postBody['manufacturer'] = opts.manufacturer + } + if (opts.edgeModel !== undefined && opts.edgeModel !== null) { + postBody['edgeModel'] = opts.edgeModel + } + if (opts.edgeDesc !== undefined && opts.edgeDesc !== null) { + postBody['edgeDesc'] = opts.edgeDesc + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + edgeName: opts.edgeName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotedge/1.0.0' + } + + 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 addEdgeWithCore 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}/instances/{instanceId}/edges/{edgeName}:addEdge', + '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 - IoTCore实例编号 + * @param {string} opts.edgeName - Edge名称 + * @param {string} opts.productKey - Edge的ProductKey + * @param {array} [opts.devices] - 待添加的子设备列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + addSubDeviceWithCore (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 addSubDeviceWithCore" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling addSubDeviceWithCore" + ) + } + if (opts.edgeName === undefined || opts.edgeName === null) { + throw new Error( + "Missing the required parameter 'opts.edgeName' when calling addSubDeviceWithCore" + ) + } + if (opts.productKey === undefined || opts.productKey === null) { + throw new Error( + "Missing the required parameter 'opts.productKey' when calling addSubDeviceWithCore" + ) + } + + let postBody = {} + if (opts.devices !== undefined && opts.devices !== null) { + postBody['devices'] = opts.devices + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + edgeName: opts.edgeName, + productKey: opts.productKey + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotedge/1.0.0' + } + + 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 addSubDeviceWithCore 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}/instances/{instanceId}/products/{productKey}/edges/{edgeName}:addSubDevice', + '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 - IoTCore实例编号 + * @param {string} opts.edgeName - Edge名称 + * @param {string} opts.productKey - Edge对应的产品key + * @param {array} [opts.delDevices] - 设备名称 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + delSubDeviceWithCore (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 delSubDeviceWithCore" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling delSubDeviceWithCore" + ) + } + if (opts.edgeName === undefined || opts.edgeName === null) { + throw new Error( + "Missing the required parameter 'opts.edgeName' when calling delSubDeviceWithCore" + ) + } + if (opts.productKey === undefined || opts.productKey === null) { + throw new Error( + "Missing the required parameter 'opts.productKey' when calling delSubDeviceWithCore" + ) + } + + let postBody = {} + if (opts.delDevices !== undefined && opts.delDevices !== null) { + postBody['delDevices'] = opts.delDevices + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + edgeName: opts.edgeName, + productKey: opts.productKey + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotedge/1.0.0' + } + + 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 delSubDeviceWithCore 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}/instances/{instanceId}/products/{productKey}/edges/{edgeName}:delSubDevice', + '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 = JDCloud.IOTEDGE diff --git a/packages/libs/lib-jdcloud/src/repo/iothub/v1/iothub.js b/packages/libs/lib-jdcloud/src/repo/iothub/v1/iothub.js new file mode 100644 index 000000000..d08b2cb75 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/iothub/v1/iothub.js @@ -0,0 +1,1497 @@ +/* + * 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. + * + * RuleEngineAPI + * 规则引擎API + * + * 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 = 'iothub' +Service._services[serviceId] = true + +/** + * iothub service. + * @version 0.6.6 + */ + +JDCloud.IOTHUB = class IOTHUB extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'iothub.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 删除设备 + * @param {Object} opts - parameters + * @param {string} [opts.deviceId] - 设备Id optional + * @param {string} [opts.instanceId] - hub实例instanceId optional + * @param {string} callback - callback + @return {Object} result + */ + + deleteDevice (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.deviceId !== undefined && opts.deviceId !== null) { + queryParams['deviceId'] = opts.deviceId + } + if (opts.instanceId !== undefined && opts.instanceId !== null) { + queryParams['instanceId'] = opts.instanceId + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iothub/0.6.6' + } + + 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 deleteDevice 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 = this.makeRequest( + '/device', + '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 {array} [opts.deviceIds] - 设备Id集合 optional + * @param {string} callback - callback + @return {Object} result + * @param onlineInfo onlineInfos + */ + + queryDeviceOnlineInfos (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.deviceIds !== undefined && opts.deviceIds !== null) { + postBody['deviceIds'] = opts.deviceIds + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iothub/0.6.6' + } + + 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 queryDeviceOnlineInfos 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 = this.makeRequest( + '/device:queryOnlineInfos', + '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) + } + ) + } + + /** + * 激活一个设备,包括Edge、Dragon和普通设备 + + * @param {Object} opts - parameters + * @param {string} opts.deviceId - Device 唯一标识 + * @param {string} callback - callback + @return {Object} result + * @param string data + */ + + deviceActivate (opts, callback) { + opts = opts || {} + + if (opts.deviceId === undefined || opts.deviceId === null) { + throw new Error( + "Missing the required parameter 'opts.deviceId' when calling deviceActivate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + deviceId: opts.deviceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iothub/0.6.6' + } + + 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 deviceActivate 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 = this.makeRequest( + '/device/{deviceId}/activate', + '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] optional + * @param {deviceEnrollVO} [opts.device] optional + * @param {string} callback - callback + @return {Object} result + * @param string data + */ + + devicesEnroll (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.instanceId !== undefined && opts.instanceId !== null) { + postBody['instanceId'] = opts.instanceId + } + if (opts.device !== undefined && opts.device !== null) { + postBody['device'] = opts.device + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iothub/0.6.6' + } + + 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 devicesEnroll 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 = this.makeRequest( + '/device', + '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.deviceId - Device 唯一标识 + * @param {string} callback - callback + @return {Object} result + * @param string commands + */ + + queryDeviceCommands (opts, callback) { + opts = opts || {} + + if (opts.deviceId === undefined || opts.deviceId === null) { + throw new Error( + "Missing the required parameter 'opts.deviceId' when calling queryDeviceCommands" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + deviceId: opts.deviceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iothub/0.6.6' + } + + 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 queryDeviceCommands 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 = this.makeRequest( + '/device/{deviceId}/command', + '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.deviceId - Device 唯一标识 + * @param {deviceCommandVO} [opts.commands] optional + * @param {string} callback - callback + @return {Object} result + * @param string data + */ + + deviceCommand (opts, callback) { + opts = opts || {} + + if (opts.deviceId === undefined || opts.deviceId === null) { + throw new Error( + "Missing the required parameter 'opts.deviceId' when calling deviceCommand" + ) + } + + let postBody = {} + if (opts.commands !== undefined && opts.commands !== null) { + postBody['commands'] = opts.commands + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + deviceId: opts.deviceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iothub/0.6.6' + } + + 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 deviceCommand 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 = this.makeRequest( + '/device/{deviceId}/command', + '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.deviceId - Device 唯一标识 + * @param {string} callback - callback + @return {Object} result + * @param string state + */ + + queryDeviceStates (opts, callback) { + opts = opts || {} + + if (opts.deviceId === undefined || opts.deviceId === null) { + throw new Error( + "Missing the required parameter 'opts.deviceId' when calling queryDeviceStates" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + deviceId: opts.deviceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iothub/0.6.6' + } + + 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 queryDeviceStates 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 = this.makeRequest( + '/device/{deviceId}/state', + '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.deviceId - Device 唯一标识 + * @param {string} [opts.states] optional + * @param {string} callback - callback + @return {Object} result + * @param string data + */ + + deviceState (opts, callback) { + opts = opts || {} + + if (opts.deviceId === undefined || opts.deviceId === null) { + throw new Error( + "Missing the required parameter 'opts.deviceId' when calling deviceState" + ) + } + + let postBody = {} + if (opts.states !== undefined && opts.states !== null) { + postBody['states'] = opts.states + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + deviceId: opts.deviceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iothub/0.6.6' + } + + 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 deviceState 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 = this.makeRequest( + '/device/{deviceId}/state', + '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) + } + ) + } + + /** + * 验证DeviceId是否可用 + + * @param {Object} opts - parameters + * @param {string} opts.deviceId - Device 唯一标识 + * @param {string} callback - callback + @return {Object} result + */ + + checkDeviceId (opts, callback) { + opts = opts || {} + + if (opts.deviceId === undefined || opts.deviceId === null) { + throw new Error( + "Missing the required parameter 'opts.deviceId' when calling checkDeviceId" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + deviceId: opts.deviceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iothub/0.6.6' + } + + 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 checkDeviceId 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 = this.makeRequest( + '/device/{deviceId}:check', + '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.moduleName - moduleName 唯一标识 + * @param {string} [opts.instanceId] optional + * @param {string} [opts.modelName] optional + * @param {string} [opts.parentDeviceName] optional + * @param {string} [opts.name] optional + * @param {string} callback - callback + @return {Object} result + * @param string data + */ + + moduleEnrollment (opts, callback) { + opts = opts || {} + + if (opts.moduleName === undefined || opts.moduleName === null) { + throw new Error( + "Missing the required parameter 'opts.moduleName' when calling moduleEnrollment" + ) + } + + let postBody = {} + if (opts.instanceId !== undefined && opts.instanceId !== null) { + postBody['instanceId'] = opts.instanceId + } + if (opts.modelName !== undefined && opts.modelName !== null) { + postBody['modelName'] = opts.modelName + } + if (opts.parentDeviceName !== undefined && opts.parentDeviceName !== null) { + postBody['parentDeviceName'] = opts.parentDeviceName + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + moduleName: opts.moduleName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iothub/0.6.6' + } + + 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 moduleEnrollment 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 = this.makeRequest( + '/module/{moduleName}/enroll', + '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.moduleName - moduleName 唯一标识 + * @param {string} [opts.states] optional + * @param {string} callback - callback + @return {Object} result + * @param string data + */ + + moduleState (opts, callback) { + opts = opts || {} + + if (opts.moduleName === undefined || opts.moduleName === null) { + throw new Error( + "Missing the required parameter 'opts.moduleName' when calling moduleState" + ) + } + + let postBody = {} + if (opts.states !== undefined && opts.states !== null) { + postBody['states'] = opts.states + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + moduleName: opts.moduleName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iothub/0.6.6' + } + + 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 moduleState 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 = this.makeRequest( + '/module/{moduleName}/state', + '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) + } + ) + } + + /** + * 获取下载物模型的外链地址 + + * @param {Object} opts - parameters + * @param {string} opts.deviceId + * @param {string} [opts.instanceId] optional + * @param {string} callback - callback + @return {Object} result + * @param string privateUrl + */ + + getOMPrivateURL (opts, callback) { + opts = opts || {} + + if (opts.deviceId === undefined || opts.deviceId === null) { + throw new Error( + "Missing the required parameter 'opts.deviceId' when calling getOMPrivateURL" + ) + } + + let postBody = {} + if (opts.instanceId !== undefined && opts.instanceId !== null) { + postBody['instanceId'] = opts.instanceId + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + deviceId: opts.deviceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iothub/0.6.6' + } + + 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 getOMPrivateURL 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 = this.makeRequest( + '/om/{deviceId}/privateurl', + '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.fileName - 物模型文件名称 + * @param {string} opts.instanceId - 待上传物模型的IoT Hub实例编号 + * @param {string} callback - callback + @return {Object} result + * @param string data + */ + + omEnrollbyFile (opts, callback) { + opts = opts || {} + + if (opts.fileName === undefined || opts.fileName === null) { + throw new Error( + "Missing the required parameter 'opts.fileName' when calling omEnrollbyFile" + ) + } + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling omEnrollbyFile" + ) + } + + let postBody = {} + if (opts.instanceId !== undefined && opts.instanceId !== null) { + postBody['instanceId'] = opts.instanceId + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + fileName: opts.fileName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iothub/0.6.6' + } + + 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 omEnrollbyFile 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 = this.makeRequest( + '/file/{fileName}/om', + '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.omName - 物模型唯一标识 + * @param {string} [opts.instanceId] optional + * @param {string} [opts.payload] optional + * @param {string} callback - callback + @return {Object} result + * @param string data + */ + + omEnroll (opts, callback) { + opts = opts || {} + + if (opts.omName === undefined || opts.omName === null) { + throw new Error( + "Missing the required parameter 'opts.omName' when calling omEnroll" + ) + } + + let postBody = {} + if (opts.instanceId !== undefined && opts.instanceId !== null) { + postBody['instanceId'] = opts.instanceId + } + if (opts.payload !== undefined && opts.payload !== null) { + postBody['payload'] = opts.payload + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + omName: opts.omName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iothub/0.6.6' + } + + 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 omEnroll 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 = this.makeRequest( + '/om/{omName}', + '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 = JDCloud.IOTHUB diff --git a/packages/libs/lib-jdcloud/src/repo/iotlink/v1/iotlink.js b/packages/libs/lib-jdcloud/src/repo/iotlink/v1/iotlink.js new file mode 100644 index 000000000..8a040a852 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/iotlink/v1/iotlink.js @@ -0,0 +1,2813 @@ +/* + * 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. + * + * Iotlink-Related-API + * 物联网卡服务相关API + * + * 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 = 'iotlink' +Service._services[serviceId] = true + +/** + * iotlink service. + * @version 1.0.8 + */ + +class IOTLINK extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'iotlink.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 物联网卡实名制信息清除 + * @param {Object} opts - parameters + * @param {string} opts.requestParam - 物联网卡实名制信息清除请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;其他:失败) + * @param string message 消息描述 + * @param boolean result 物联网卡实名制信息清除返回结果集 + */ + + ordinaryRealNameClear (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 ordinaryRealNameClear" + ) + } + + opts = opts || {} + + if (opts.requestParam === undefined || opts.requestParam === null) { + throw new Error( + "Missing the required parameter 'opts.requestParam' when calling ordinaryRealNameClear" + ) + } + + let postBody = {} + if (opts.requestParam !== undefined && opts.requestParam !== null) { + postBody['requestParam'] = opts.requestParam + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotlink/1.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 ordinaryRealNameClear 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}/ordinaryRealNameClear', + '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.iccid - 物联网卡iccid + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;1:失败) + * @param string message 消息描述 + * @param cardBindStatusResp result 机卡分离状态查询结果 + */ + + cardBindStatus (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 cardBindStatus" + ) + } + + opts = opts || {} + + if (opts.iccid === undefined || opts.iccid === null) { + throw new Error( + "Missing the required parameter 'opts.iccid' when calling cardBindStatus" + ) + } + + let postBody = null + let queryParams = {} + if (opts.iccid !== undefined && opts.iccid !== null) { + queryParams['iccid'] = opts.iccid + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotlink/1.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 cardBindStatus 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}/cardBindStatus', + '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.iccid - 物联网卡iccid + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;1:失败) + * @param string message 消息描述 + * @param getOnlineStatusResp result 在线状态和会话信息查询结果 + */ + + getOnlineStatus (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 getOnlineStatus" + ) + } + + opts = opts || {} + + if (opts.iccid === undefined || opts.iccid === null) { + throw new Error( + "Missing the required parameter 'opts.iccid' when calling getOnlineStatus" + ) + } + + let postBody = null + let queryParams = {} + if (opts.iccid !== undefined && opts.iccid !== null) { + queryParams['iccid'] = opts.iccid + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotlink/1.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 getOnlineStatus 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}/getOnlineStatus', + '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) + } + ) + } + + /** + * NB卡有效期查询 + * @param {Object} opts - parameters + * @param {string} opts.requestParam - 物联网卡NB卡有效期查询请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;其他:失败) + * @param string message 消息描述 + * @param queryValidPeriodForNBResp result + */ + + queryValidPeriodForNB (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 queryValidPeriodForNB" + ) + } + + opts = opts || {} + + if (opts.requestParam === undefined || opts.requestParam === null) { + throw new Error( + "Missing the required parameter 'opts.requestParam' when calling queryValidPeriodForNB" + ) + } + + let postBody = {} + if (opts.requestParam !== undefined && opts.requestParam !== null) { + postBody['requestParam'] = opts.requestParam + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotlink/1.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 queryValidPeriodForNB 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}/queryValidPeriodForNB', + '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.requestParam - 物联网卡日历史流量查询请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;其他:失败) + * @param string message 消息描述 + * @param object result + */ + + queryDayHistoryTraffic (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 queryDayHistoryTraffic" + ) + } + + opts = opts || {} + + if (opts.requestParam === undefined || opts.requestParam === null) { + throw new Error( + "Missing the required parameter 'opts.requestParam' when calling queryDayHistoryTraffic" + ) + } + + let postBody = {} + if (opts.requestParam !== undefined && opts.requestParam !== null) { + postBody['requestParam'] = opts.requestParam + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotlink/1.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 queryDayHistoryTraffic 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}/queryDayHistoryTraffic', + '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.requestParam - 物联网卡移动实名登记请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;其他:失败) + * @param string message 消息描述 + * @param simRealNameRegResp result 物联网卡移动实名登记信息 + */ + + simRealNameReg (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 simRealNameReg" + ) + } + + opts = opts || {} + + if (opts.requestParam === undefined || opts.requestParam === null) { + throw new Error( + "Missing the required parameter 'opts.requestParam' when calling simRealNameReg" + ) + } + + let postBody = {} + if (opts.requestParam !== undefined && opts.requestParam !== null) { + postBody['requestParam'] = opts.requestParam + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotlink/1.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 simRealNameReg 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}/simRealNameReg', + '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.requestParam - 物联网卡流量查询(时间段)查询请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;其他:失败) + * @param string message 消息描述 + * @param string result 物联网卡时间段总使用流量 + */ + + queryTrafficByDate (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 queryTrafficByDate" + ) + } + + opts = opts || {} + + if (opts.requestParam === undefined || opts.requestParam === null) { + throw new Error( + "Missing the required parameter 'opts.requestParam' when calling queryTrafficByDate" + ) + } + + let postBody = {} + if (opts.requestParam !== undefined && opts.requestParam !== null) { + postBody['requestParam'] = opts.requestParam + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotlink/1.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 queryTrafficByDate 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}/queryTrafficByDate', + '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.requestParam - 物联网卡自主限速请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;其他:失败) + * @param string message 消息描述 + * @param boolean result 物联网卡自主限速返回结果集 + */ + + speedLimitAction (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 speedLimitAction" + ) + } + + opts = opts || {} + + if (opts.requestParam === undefined || opts.requestParam === null) { + throw new Error( + "Missing the required parameter 'opts.requestParam' when calling speedLimitAction" + ) + } + + let postBody = {} + if (opts.requestParam !== undefined && opts.requestParam !== null) { + postBody['requestParam'] = opts.requestParam + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotlink/1.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 speedLimitAction 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}/speedLimitAction', + '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) + } + ) + } + + /** + * 根据物联网卡iccid查询该卡的基本信息 + * @param {Object} opts - parameters + * @param {string} opts.iccid - 物联网卡iccid + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;1:失败) + * @param string message 消息描述 + * @param cardInfoResp result 指定物联网卡的卡基本信息 + */ + + cardInfo (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 cardInfo" + ) + } + + opts = opts || {} + + if (opts.iccid === undefined || opts.iccid === null) { + throw new Error( + "Missing the required parameter 'opts.iccid' when calling cardInfo" + ) + } + + let postBody = null + let queryParams = {} + if (opts.iccid !== undefined && opts.iccid !== null) { + queryParams['iccid'] = opts.iccid + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotlink/1.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 cardInfo 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}/cardInfo', + '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) + } + ) + } + + /** + * 根据物联网卡iccid查询该卡的实名认证信息 + * @param {Object} opts - parameters + * @param {string} opts.iccid - 物联网卡iccid + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;1:失败) + * @param string message 消息描述 + * @param realNameQueryIotResp result 指定物联网卡的实名认证状态信息 + */ + + realNameQueryIot (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 realNameQueryIot" + ) + } + + opts = opts || {} + + if (opts.iccid === undefined || opts.iccid === null) { + throw new Error( + "Missing the required parameter 'opts.iccid' when calling realNameQueryIot" + ) + } + + let postBody = null + let queryParams = {} + if (opts.iccid !== undefined && opts.iccid !== null) { + queryParams['iccid'] = opts.iccid + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotlink/1.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 realNameQueryIot 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}/realNameQueryIot', + '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) + } + ) + } + + /** + * 根据物联网卡IMSI查询该卡的GPRS状态信息 + * @param {Object} opts - parameters + * @param {string} opts.imsi - 物联网卡IMSI + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;1:失败) + * @param string message 消息描述 + * @param gprsStatusResp result 指定物联网卡的gprs状态信息 + */ + + gprsStatusByIMSI (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 gprsStatusByIMSI" + ) + } + + opts = opts || {} + + if (opts.imsi === undefined || opts.imsi === null) { + throw new Error( + "Missing the required parameter 'opts.imsi' when calling gprsStatusByIMSI" + ) + } + + let postBody = null + let queryParams = {} + if (opts.imsi !== undefined && opts.imsi !== null) { + queryParams['imsi'] = opts.imsi + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotlink/1.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 gprsStatusByIMSI 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}/gprsStatusByIMSI', + '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) + } + ) + } + + /** + * 根据物联网卡imsi查询该卡的开关机状态信息 + * @param {Object} opts - parameters + * @param {string} opts.imsi - 物联网卡imsi + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;1:失败) + * @param string message 消息描述 + * @param onOffStatusResp result 指定物联网卡的开关机状态信息 + */ + + onOffStatusByIMSI (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 onOffStatusByIMSI" + ) + } + + opts = opts || {} + + if (opts.imsi === undefined || opts.imsi === null) { + throw new Error( + "Missing the required parameter 'opts.imsi' when calling onOffStatusByIMSI" + ) + } + + let postBody = null + let queryParams = {} + if (opts.imsi !== undefined && opts.imsi !== null) { + queryParams['imsi'] = opts.imsi + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotlink/1.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 onOffStatusByIMSI 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}/onOffStatusByIMSI', + '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) + } + ) + } + + /** + * 根据物联网卡imsi查询该卡的生命周期信息 + * @param {Object} opts - parameters + * @param {string} opts.imsi - 物联网卡imsi + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;1:失败) + * @param string message 消息描述 + * @param lifeStatusResp result 指定物联网卡的生命周期信息 + */ + + lifeStatusByIMSI (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 lifeStatusByIMSI" + ) + } + + opts = opts || {} + + if (opts.imsi === undefined || opts.imsi === null) { + throw new Error( + "Missing the required parameter 'opts.imsi' when calling lifeStatusByIMSI" + ) + } + + let postBody = null + let queryParams = {} + if (opts.imsi !== undefined && opts.imsi !== null) { + queryParams['imsi'] = opts.imsi + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotlink/1.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 lifeStatusByIMSI 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}/lifeStatusByIMSI', + '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) + } + ) + } + + /** + * 根据物联网卡imsi查询该卡的当月套餐内的GPRS实时使用量 + * @param {Object} opts - parameters + * @param {string} opts.imsi - 物联网卡imsi + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;1:失败) + * @param string message 消息描述 + * @param gprsRealtimeInfoResp result 指定物联网卡的当月套餐内的GPRS实时使用量 + */ + + gprsRealtimeInfoByIMSI (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 gprsRealtimeInfoByIMSI" + ) + } + + opts = opts || {} + + if (opts.imsi === undefined || opts.imsi === null) { + throw new Error( + "Missing the required parameter 'opts.imsi' when calling gprsRealtimeInfoByIMSI" + ) + } + + let postBody = null + let queryParams = {} + if (opts.imsi !== undefined && opts.imsi !== null) { + queryParams['imsi'] = opts.imsi + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotlink/1.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 gprsRealtimeInfoByIMSI 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}/gprsRealtimeInfoByIMSI', + '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) + } + ) + } + + /** + * 根据物联网卡iccid查询该卡的gprs状态信息 + * @param {Object} opts - parameters + * @param {string} opts.iccid - 物联网卡iccid + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;1:失败) + * @param string message 消息描述 + * @param gprsStatusResp result 指定物联网卡的gprs状态信息 + */ + + gprsStatus (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 gprsStatus" + ) + } + + opts = opts || {} + + if (opts.iccid === undefined || opts.iccid === null) { + throw new Error( + "Missing the required parameter 'opts.iccid' when calling gprsStatus" + ) + } + + let postBody = null + let queryParams = {} + if (opts.iccid !== undefined && opts.iccid !== null) { + queryParams['iccid'] = opts.iccid + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotlink/1.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 gprsStatus 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}/gprsStatus', + '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) + } + ) + } + + /** + * 根据物联网卡iccid查询该卡的开关机状态信息 + * @param {Object} opts - parameters + * @param {string} opts.iccid - 物联网卡iccid + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;1:失败) + * @param string message 消息描述 + * @param onOffStatusResp result 指定物联网卡的开关机状态信息 + */ + + onOffStatus (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 onOffStatus" + ) + } + + opts = opts || {} + + if (opts.iccid === undefined || opts.iccid === null) { + throw new Error( + "Missing the required parameter 'opts.iccid' when calling onOffStatus" + ) + } + + let postBody = null + let queryParams = {} + if (opts.iccid !== undefined && opts.iccid !== null) { + queryParams['iccid'] = opts.iccid + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotlink/1.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 onOffStatus 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}/onOffStatus', + '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) + } + ) + } + + /** + * 根据物联网卡iccid查询该卡的生命周期信息 + * @param {Object} opts - parameters + * @param {string} opts.iccid - 物联网卡iccid + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;1:失败) + * @param string message 消息描述 + * @param lifeStatusResp result 指定物联网卡的生命周期信息 + */ + + lifeStatus (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 lifeStatus" + ) + } + + opts = opts || {} + + if (opts.iccid === undefined || opts.iccid === null) { + throw new Error( + "Missing the required parameter 'opts.iccid' when calling lifeStatus" + ) + } + + let postBody = null + let queryParams = {} + if (opts.iccid !== undefined && opts.iccid !== null) { + queryParams['iccid'] = opts.iccid + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotlink/1.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 lifeStatus 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}/lifeStatus', + '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) + } + ) + } + + /** + * 根据物联网卡iccid查询该卡的当月套餐内的GPRS实时使用量 + * @param {Object} opts - parameters + * @param {string} opts.iccid - 物联网卡iccid + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;1:失败) + * @param string message 消息描述 + * @param gprsRealtimeInfoResp result 指定物联网卡的当月套餐内的GPRS实时使用量 + */ + + gprsRealtimeInfo (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 gprsRealtimeInfo" + ) + } + + opts = opts || {} + + if (opts.iccid === undefined || opts.iccid === null) { + throw new Error( + "Missing the required parameter 'opts.iccid' when calling gprsRealtimeInfo" + ) + } + + let postBody = null + let queryParams = {} + if (opts.iccid !== undefined && opts.iccid !== null) { + queryParams['iccid'] = opts.iccid + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotlink/1.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 gprsRealtimeInfo 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}/gprsRealtimeInfo', + '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 {array} [opts.iccids] - 物联网卡号码列表(单次提交最多不超过200个号码) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;1:失败) + * @param string message 消息描述 + * @param operationIotlinkResp result + */ + + openIotCard (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 openIotCard" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.iccids !== undefined && opts.iccids !== null) { + postBody['iccids'] = opts.iccids + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotlink/1.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 openIotCard 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}/openIotCard', + '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 {array} [opts.iccids] - 物联网卡号码列表(单次提交最多不超过200个号码) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;1:失败) + * @param string message 消息描述 + * @param operationIotlinkResp result + */ + + closeIotCard (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 closeIotCard" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.iccids !== undefined && opts.iccids !== null) { + postBody['iccids'] = opts.iccids + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotlink/1.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 closeIotCard 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}/closeIotCard', + '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 {array} [opts.iccids] - 物联网卡号码列表(单次提交最多不超过200个号码) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;1:失败) + * @param string message 消息描述 + * @param operationIotlinkResp result + */ + + openIotFlow (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 openIotFlow" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.iccids !== undefined && opts.iccids !== null) { + postBody['iccids'] = opts.iccids + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotlink/1.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 openIotFlow 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}/openIotFlow', + '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 {array} [opts.iccids] - 物联网卡号码列表(单次提交最多不超过200个号码) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;1:失败) + * @param string message 消息描述 + * @param operationIotlinkResp result + */ + + closeIotFlow (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 closeIotFlow" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.iccids !== undefined && opts.iccids !== null) { + postBody['iccids'] = opts.iccids + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotlink/1.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 closeIotFlow 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}/closeIotFlow', + '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.requestType - 物联网卡查询请求类型 + * @param {string} opts.requestParam - 物联网卡查询请求参数json串 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;1:失败) + * @param string message 消息描述 + * @param string result 物联网卡查询返回结果集 + */ + + search (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 search" + ) + } + + opts = opts || {} + + if (opts.requestType === undefined || opts.requestType === null) { + throw new Error( + "Missing the required parameter 'opts.requestType' when calling search" + ) + } + if (opts.requestParam === undefined || opts.requestParam === null) { + throw new Error( + "Missing the required parameter 'opts.requestParam' when calling search" + ) + } + + let postBody = {} + if (opts.requestType !== undefined && opts.requestType !== null) { + postBody['requestType'] = opts.requestType + } + if (opts.requestParam !== undefined && opts.requestParam !== null) { + postBody['requestParam'] = opts.requestParam + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotlink/1.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 search 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}/search', + '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.requestType - 物联网卡操作请求类型 + * @param {string} opts.requestParam - 物联网卡操作请求参数json串 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 请求状态(0:成功;1:失败) + * @param string message 消息描述 + * @param string result 物联网卡操作返回结果集 + */ + + operate (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 operate" + ) + } + + opts = opts || {} + + if (opts.requestType === undefined || opts.requestType === null) { + throw new Error( + "Missing the required parameter 'opts.requestType' when calling operate" + ) + } + if (opts.requestParam === undefined || opts.requestParam === null) { + throw new Error( + "Missing the required parameter 'opts.requestParam' when calling operate" + ) + } + + let postBody = {} + if (opts.requestType !== undefined && opts.requestType !== null) { + postBody['requestType'] = opts.requestType + } + if (opts.requestParam !== undefined && opts.requestParam !== null) { + postBody['requestParam'] = opts.requestParam + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iotlink/1.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 operate 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}/operate', + '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 = IOTLINK diff --git a/packages/libs/lib-jdcloud/src/repo/ipanti/v1/ipanti.js b/packages/libs/lib-jdcloud/src/repo/ipanti/v1/ipanti.js new file mode 100644 index 000000000..fc6a9dcfb --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/ipanti/v1/ipanti.js @@ -0,0 +1,16167 @@ +/* + * 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. + * + * Anti DDoS Pro Web Rule Configuration APIs + * Anti DDoS Pro Web Rule Configuration APIs + * + * 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 = 'ipanti' +Service._services[serviceId] = true + +/** + * ipanti service. + * @version 1.12.0 + */ + +class IPANTI extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'ipanti.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询 DDoS 攻击日志, 仅能查询非BGP实例的攻击记录, 同时查询BGP和非BGP实例请使用 <a href='http://docs.jdcloud.com/anti-ddos-pro/api/describeDDoSIpAttackLogs'>describeDDoSIpAttackLogs</a> + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码, 默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小, 默认为10, 取值范围[10, 100] optional + * @param {string} opts.startTime - 开始时间, 只能查询最近 90 天以内的数据, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ + * @param {string} [opts.endTime] - 查询的结束时间, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ optional + * @param {string} [opts.instanceId] - 高防实例 ID optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dDoSAttackLog dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 实例总数 + * @param integer totalPage 总页数 + */ + + describeDDoSAttackLogs (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 describeDDoSAttackLogs" + ) + } + + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeDDoSAttackLogs" + ) + } + + 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.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + Object.assign( + queryParams, + super.buildArrayParam(opts.instanceId, 'instanceId') + ) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeDDoSAttackLogs 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}/attacklog:describeDDoSAttackLogs', + '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的 DDoS 攻击日志, 仅BGP实例返回的是IP级别的攻击记录, 非BGP实例返回的仍是实例级别的攻击记录(serviceIp 字段为空) +参数 serviceIp 优先级大于 instanceId. +- 指定 serviceIp 参数时, 忽略 instanceId 参数, 查询 ip 相关攻击记录. +- 未指定 serviceIp 时, 查询 instanceId 指定实例相关攻击记录. +- serviceIp 和 instanceId 均未指定时, 查询用户所有攻击记录 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码, 默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小, 默认为10, 取值范围[10, 100] optional + * @param {string} opts.startTime - 开始时间, 只能查询最近 90 天以内的数据, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ + * @param {string} [opts.endTime] - 查询的结束时间, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ optional + * @param {string} [opts.instanceId] - 高防实例 ID optional + * @param {string} [opts.serviceIp] - 高防IP列表. <br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-pro/api/describeServiceIpList'>describeServiceIpList</a> 接口查询实例的高防 IP optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dDoSIpAttackLog dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 实例总数 + * @param integer totalPage 总页数 + */ + + describeDDoSIpAttackLogs (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 describeDDoSIpAttackLogs" + ) + } + + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeDDoSIpAttackLogs" + ) + } + + 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.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + Object.assign( + queryParams, + super.buildArrayParam(opts.instanceId, 'instanceId') + ) + Object.assign( + queryParams, + super.buildArrayParam(opts.serviceIp, 'serviceIp') + ) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeDDoSIpAttackLogs 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}/attacklog:describeDDoSIpAttackLogs', + '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) + } + ) + } + + /** + * 查询 CC 攻击日志 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码, 默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小, 默认为10, 取值范围[10, 100] optional + * @param {string} opts.startTime - 开始时间, 只能查询最近 90 天以内的数据, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ + * @param {string} [opts.endTime] - 查询的结束时间, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ optional + * @param {string} [opts.instanceId] - 高防实例 ID optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param cCAttackLog dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 实例总数 + * @param integer totalPage 总页数 + */ + + describeCCAttackLogs (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 describeCCAttackLogs" + ) + } + + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeCCAttackLogs" + ) + } + + 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.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + Object.assign( + queryParams, + super.buildArrayParam(opts.instanceId, 'instanceId') + ) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeCCAttackLogs 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}/attacklog:describeCCAttackLogs', + '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) + } + ) + } + + /** + * 查询 CC 攻击日志详情. +- 参数 attackId 优先级高于 instanceId, attackId 不为空时, 忽略 instanceId + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码, 默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小, 默认为10, 取值范围[10, 100] optional + * @param {string} [opts.startTime] - 开始时间, 只能查询最近 90 天以内的数据, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ, attackId 为空时必传 optional + * @param {string} [opts.endTime] - 查询的结束时间, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ optional + * @param {string} [opts.instanceId] - 高防实例 ID optional + * @param {string} [opts.attackId] - CC 攻击记录 Id, 不为空时忽略 startTime, endTime optional + * @param {string} [opts.subDomain] - 查询的子域名, 只有选中某一个实例后才能多选子域名 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param cCAttackLogDetail dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 实例总数 + * @param integer totalPage 总页数 + */ + + describeCCAttackLogDetails (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 describeCCAttackLogDetails" + ) + } + + 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.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.instanceId !== undefined && opts.instanceId !== null) { + queryParams['instanceId'] = opts.instanceId + } + if (opts.attackId !== undefined && opts.attackId !== null) { + queryParams['attackId'] = opts.attackId + } + Object.assign( + queryParams, + super.buildArrayParam(opts.subDomain, 'subDomain') + ) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeCCAttackLogDetails 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}/attacklog:describeCCAttackLogDetails', + '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) + } + ) + } + + /** + * 查询攻击次数及流量峰值 +参数 serviceIp 优先级大于 instanceId. +- 指定 serviceIp 参数时, 忽略 instanceId 参数, 统计 ip 相关攻击 +- 未指定 serviceIp 时, 统计 instanceId 指定实例相关攻击 +- serviceIp 和 instanceId 均未指定时, 统计用户所有攻击记录 +CC攻击为实例级别, 查询类型 type 为 cc 时, 参数 serviceIp 无效 + + * @param {Object} opts - parameters + * @param {string} opts.startTime - 开始时间, 只能查询最近 90 天以内的数据, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ + * @param {string} [opts.endTime] - 查询的结束时间, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ optional + * @param {integer} opts.type - 攻击类型, 0 为 DDoS, 1 为 CC + * @param {string} [opts.instanceId] - 高防实例 ID optional + * @param {string} [opts.serviceIp] - 高防IP列表. <br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-pro/api/describeServiceIpList'>describeServiceIpList</a> 接口查询实例的高防 IP optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param number flow 攻击流量峰值 + * @param integer count 攻击次数 + * @param string unit 流量单位, bps、Kbps、Mbps、Gbps + */ + + describeAttackStatistics (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 describeAttackStatistics" + ) + } + + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeAttackStatistics" + ) + } + if (opts.type === undefined || opts.type === null) { + throw new Error( + "Missing the required parameter 'opts.type' when calling describeAttackStatistics" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.type !== undefined && opts.type !== null) { + queryParams['type'] = opts.type + } + Object.assign( + queryParams, + super.buildArrayParam(opts.instanceId, 'instanceId') + ) + Object.assign( + queryParams, + super.buildArrayParam(opts.serviceIp, 'serviceIp') + ) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeAttackStatistics 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}/attacklog:describeAttackStatistics', + '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) + } + ) + } + + /** + * 查询各类型攻击次数 +参数 serviceIp 优先级大于 instanceId. +- 指定 serviceIp 参数时, 忽略 instanceId 参数, 统计 ip 相关攻击 +- 未指定 serviceIp 时, 统计 instanceId 指定实例相关攻击 +- serviceIp 和 instanceId 均未指定时, 统计用户所有攻击记录 + + * @param {Object} opts - parameters + * @param {string} opts.startTime - 开始时间, 只能查询最近 90 天以内的数据, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ + * @param {string} [opts.endTime] - 查询的结束时间, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ optional + * @param {string} [opts.instanceId] - 高防实例 ID optional + * @param {string} [opts.serviceIp] - 高防IP列表. <br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-pro/api/describeServiceIpList'>describeServiceIpList</a> 接口查询实例的高防 IP optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param attackTypeCount dataList + */ + + describeAttackTypeCount (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 describeAttackTypeCount" + ) + } + + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeAttackTypeCount" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + Object.assign( + queryParams, + super.buildArrayParam(opts.instanceId, 'instanceId') + ) + Object.assign( + queryParams, + super.buildArrayParam(opts.serviceIp, 'serviceIp') + ) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeAttackTypeCount 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}/attacklog:describeAttackTypeCount', + '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) + } + ) + } + + /** + * DDos 防护流量报表 +参数 serviceIp 优先级大于 instanceId. +- 指定 serviceIp 参数时, 忽略 instanceId 参数, 查询 ip 相关报表 +- 未指定 serviceIp 时, 查询 instanceId 指定实例相关报表 +- serviceIp 和 instanceId 均未指定时, 查询用户所有实例报表 + + * @param {Object} opts - parameters + * @param {string} opts.startTime - 开始时间, 只能查询最近 90 天以内的数据, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ + * @param {string} [opts.endTime] - 查询的结束时间, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ optional + * @param {string} [opts.instanceId] - 高防实例 Id 列表 optional + * @param {string} [opts.serviceIp] - 高防IP列表. <br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-pro/api/describeServiceIpList'>describeServiceIpList</a> 接口查询实例的高防 IP optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param number preProtect + * @param number postProtect + * @param string time + * @param string unit 流量单位, bps, Kbps, Mbps, Gbps + */ + + describeDDoSGraph (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 describeDDoSGraph" + ) + } + + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeDDoSGraph" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + Object.assign( + queryParams, + super.buildArrayParam(opts.instanceId, 'instanceId') + ) + Object.assign( + queryParams, + super.buildArrayParam(opts.serviceIp, 'serviceIp') + ) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeDDoSGraph 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}/charts:DDoSGraph', + '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.startTime - 开始时间, 只能查询最近 90 天以内的数据, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ + * @param {string} [opts.endTime] - 查询的结束时间, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ optional + * @param {string} [opts.instanceId] - 高防实例 Id 列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param number forwardRecord + * @param string time + * @param string unit 流量单位, bps, Kbps, Mbps, Gbps + */ + + describeFwdGraph (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 describeFwdGraph" + ) + } + + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeFwdGraph" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + Object.assign( + queryParams, + super.buildArrayParam(opts.instanceId, 'instanceId') + ) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeFwdGraph 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}/charts:fwdGraph', + '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) + } + ) + } + + /** + * 业务流量报表 +参数 serviceIp 优先级大于 instanceId. +- 指定 serviceIp 参数时, 忽略 instanceId 参数, 查询 ip 相关报表 +- 未指定 serviceIp 时, 查询 instanceId 指定实例相关报表 +- serviceIp 和 instanceId 均未指定时, 查询用户所有实例报表 + + * @param {Object} opts - parameters + * @param {string} opts.startTime - 开始时间, 只能查询最近 90 天以内的数据, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ + * @param {string} [opts.endTime] - 查询的结束时间, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ optional + * @param {string} [opts.instanceId] - 高防实例 Id 列表 optional + * @param {string} [opts.serviceIp] - 高防IP列表. <br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-pro/api/describeServiceIpList'>describeServiceIpList</a> 接口查询实例的高防 IP optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param number inTraffic + * @param number outTraffic + * @param string time + * @param string unit 流量单位, bps, Kbps, Mbps, Gbps + */ + + describeBusinessGraph (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 describeBusinessGraph" + ) + } + + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeBusinessGraph" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + Object.assign( + queryParams, + super.buildArrayParam(opts.instanceId, 'instanceId') + ) + Object.assign( + queryParams, + super.buildArrayParam(opts.serviceIp, 'serviceIp') + ) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeBusinessGraph 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}/charts:businessGraph', + '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) + } + ) + } + + /** + * CC 防护流量报表 + * @param {Object} opts - parameters + * @param {string} opts.startTime - 开始时间, 只能查询最近 90 天以内的数据, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ + * @param {string} [opts.endTime] - 查询的结束时间, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ optional + * @param {string} [opts.instanceId] - 高防实例 Id 列表 optional + * @param {string} [opts.subDomain] - 规则域名列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer postProtect + * @param integer preProtect + * @param string time + * @param string unit 流量单位 + */ + + describeCCGraph (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 describeCCGraph" + ) + } + + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeCCGraph" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + Object.assign( + queryParams, + super.buildArrayParam(opts.instanceId, 'instanceId') + ) + Object.assign( + queryParams, + super.buildArrayParam(opts.subDomain, 'subDomain') + ) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeCCGraph 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}/charts:CCGraph', + '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.startTime - 开始时间, 只能查询最近 7 天以内的数据, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ + * @param {string} [opts.endTime] - 查询的结束时间, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ optional + * @param {string} [opts.instanceId] - 高防实例 Id 列表 optional + * @param {string} [opts.subDomain] - 规则域名列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer status500 + * @param integer status502 + * @param integer status504 + * @param integer status590 + * @param integer status592 + * @param integer status594 + * @param integer status5xx + * @param string time + */ + + describeStatusGraph (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 describeStatusGraph" + ) + } + + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeStatusGraph" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + Object.assign( + queryParams, + super.buildArrayParam(opts.instanceId, 'instanceId') + ) + Object.assign( + queryParams, + super.buildArrayParam(opts.subDomain, 'subDomain') + ) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeStatusGraph 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}/charts:statusGraph', + '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) + } + ) + } + + /** + * 新建与并发连接数统计报表 +参数 serviceIp 优先级大于 instanceId. +- 指定 serviceIp 参数时, 忽略 instanceId 参数, 查询 ip 相关报表 +- 未指定 serviceIp 时, 查询 instanceId 指定实例相关报表 +- serviceIp 和 instanceId 均未指定时, 查询用户所有实例报表 + + * @param {Object} opts - parameters + * @param {string} opts.startTime - 开始时间, 只能查询最近 90 天以内的数据, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ + * @param {string} [opts.endTime] - 查询的结束时间, UTC 时间, 格式: yyyy-MM-dd'T'HH:mm:ssZ optional + * @param {string} [opts.instanceId] - 高防实例 Id 列表 optional + * @param {string} [opts.serviceIp] - 高防IP列表. <br>- 使用 <a href='http://docs.jdcloud.com/anti-ddos-pro/api/describeServiceIpList'>describeServiceIpList</a> 接口查询实例的高防 IP optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer newConn + * @param integer activeConn + * @param integer inactiveConn + * @param string time + */ + + describeConnStatGraph (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 describeConnStatGraph" + ) + } + + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeConnStatGraph" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + Object.assign( + queryParams, + super.buildArrayParam(opts.instanceId, 'instanceId') + ) + Object.assign( + queryParams, + super.buildArrayParam(opts.serviceIp, 'serviceIp') + ) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeConnStatGraph 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}/charts:connStatGraph', + '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 {integer} [opts.pageNumber] - 页码, 默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小, 默认为10, 取值范围[10, 100] optional + * @param {string} [opts.name] - 实例名称, 可模糊匹配 optional + * @param {string} [opts.innerIp] - 云内IP, 可模糊匹配 optional + * @param {string} [opts.serviceIp] - 高防IP, 可模糊匹配 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dispatchRule dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 总数 + * @param integer totalPage 总页数 + */ + + describeDispatchRules (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 describeDispatchRules" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeDispatchRules" + ) + } + + 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.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + if (opts.innerIp !== undefined && opts.innerIp !== null) { + queryParams['innerIp'] = opts.innerIp + } + if (opts.serviceIp !== undefined && opts.serviceIp !== null) { + queryParams['serviceIp'] = opts.serviceIp + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeDispatchRules 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}/instances/{instanceId}/dispatchRules', + '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 {createDispatchRuleSpec} opts.createDispatchRuleSpec - 添加防护调度规则请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 添加规则失败, 1: 添加规则成功 + * @param string message 添加规则失败时给出具体原因 + */ + + createDispatchRule (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 createDispatchRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createDispatchRule" + ) + } + if ( + opts.createDispatchRuleSpec === undefined || + opts.createDispatchRuleSpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.createDispatchRuleSpec' when calling createDispatchRule" + ) + } + + let postBody = {} + if ( + opts.createDispatchRuleSpec !== undefined && + opts.createDispatchRuleSpec !== null + ) { + postBody['createDispatchRuleSpec'] = opts.createDispatchRuleSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 createDispatchRule 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}/instances/{instanceId}/dispatchRules', + '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 - 高防实例 Id + * @param {array} opts.dispatchRuleSpecList - 批量添加防护调度规则请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string dispatchRuleIds + * @param failedRule failRules + */ + + createDispatchRules (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 createDispatchRules" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createDispatchRules" + ) + } + if ( + opts.dispatchRuleSpecList === undefined || + opts.dispatchRuleSpecList === null + ) { + throw new Error( + "Missing the required parameter 'opts.dispatchRuleSpecList' when calling createDispatchRules" + ) + } + + let postBody = {} + if ( + opts.dispatchRuleSpecList !== undefined && + opts.dispatchRuleSpecList !== null + ) { + postBody['dispatchRuleSpecList'] = opts.dispatchRuleSpecList + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 createDispatchRules 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}/instances/{instanceId}:createDispatchRules', + '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 - 高防实例 Id + * @param {string} opts.dispatchRuleId - 防护调度规则 Id + * @param {modifyDispatchRuleSpec} opts.modifyDispatchRuleSpec - 更新防护调度规则请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 更新规则失败, 1: 更新规则成功 + * @param string message 更新规则失败时给出具体原因 + */ + + modifyDispatchRule (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 modifyDispatchRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyDispatchRule" + ) + } + if (opts.dispatchRuleId === undefined || opts.dispatchRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.dispatchRuleId' when calling modifyDispatchRule" + ) + } + if ( + opts.modifyDispatchRuleSpec === undefined || + opts.modifyDispatchRuleSpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.modifyDispatchRuleSpec' when calling modifyDispatchRule" + ) + } + + let postBody = {} + if ( + opts.modifyDispatchRuleSpec !== undefined && + opts.modifyDispatchRuleSpec !== null + ) { + postBody['modifyDispatchRuleSpec'] = opts.modifyDispatchRuleSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + dispatchRuleId: opts.dispatchRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 modifyDispatchRule 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}/instances/{instanceId}/dispatchRules/{dispatchRuleId}', + 'PATCH', + 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} opts.dispatchRuleId - 防护调度规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 删除规则失败, 1: 删除规则成功 + * @param string message 删除规则失败时给出具体原因 + */ + + deleteDispatchRule (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 deleteDispatchRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteDispatchRule" + ) + } + if (opts.dispatchRuleId === undefined || opts.dispatchRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.dispatchRuleId' when calling deleteDispatchRule" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + dispatchRuleId: opts.dispatchRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 deleteDispatchRule 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}/instances/{instanceId}/dispatchRules/{dispatchRuleId}', + '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.instanceId - 高防实例 Id + * @param {string} opts.dispatchRuleId - 防护调度规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 规则切换成防御失败, 1: 规则切换成防御成功 + * @param string message 规则切换成防御失败时给出具体原因 + */ + + switchDispatchRuleProtect (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 switchDispatchRuleProtect" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling switchDispatchRuleProtect" + ) + } + if (opts.dispatchRuleId === undefined || opts.dispatchRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.dispatchRuleId' when calling switchDispatchRuleProtect" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + dispatchRuleId: opts.dispatchRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 switchDispatchRuleProtect 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}/instances/{instanceId}/dispatchRules/{dispatchRuleId}:protect', + '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 - 高防实例 Id + * @param {string} opts.dispatchRuleId - 防护调度规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 规则切换成回源失败, 1: 规则切换成回源成功 + * @param string message 规则切换成回源失败时给出具体原因 + */ + + switchDispatchRuleOrigin (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 switchDispatchRuleOrigin" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling switchDispatchRuleOrigin" + ) + } + if (opts.dispatchRuleId === undefined || opts.dispatchRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.dispatchRuleId' when calling switchDispatchRuleOrigin" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + dispatchRuleId: opts.dispatchRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 switchDispatchRuleOrigin 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}/instances/{instanceId}/dispatchRules/{dispatchRuleId}:origin', + '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 - 高防实例 Id + * @param {integer} [opts.pageNumber] - 页码, 默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小, 默认为10, 取值范围[10, 100] optional + * @param {string} [opts.searchType] - 查询类型名称, domain:源站域名, ip:源站 IP, port: 转发端口, originPort: 源站端口, serviceIp: 高防IP(仅支持BGP线路的实例) optional + * @param {string} [opts.searchValue] - 查询类型值 optional + * @param {sort} [opts.sorts] - 排序属性: +port - 按转发端口排序,默认不排序,asc表示按转发端口升序,desc表示按转发端口降序 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param forwardRule dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 总数 + * @param integer totalPage 总页数 + */ + + describeForwardRules (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 describeForwardRules" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeForwardRules" + ) + } + + 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.searchType !== undefined && opts.searchType !== null) { + queryParams['searchType'] = opts.searchType + } + if (opts.searchValue !== undefined && opts.searchValue !== null) { + queryParams['searchValue'] = opts.searchValue + } + Object.assign(queryParams, super.buildSortParam(opts.sorts, 'sorts')) + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeForwardRules 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}/instances/{instanceId}/forwardRules', + '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 {forwardRuleSpec} opts.forwardRuleSpec - 添加非网站类规则请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 添加规则失败, 1: 添加规则成功 + * @param string message 添加规则失败时给出具体原因 + */ + + createForwardRule (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 createForwardRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createForwardRule" + ) + } + if (opts.forwardRuleSpec === undefined || opts.forwardRuleSpec === null) { + throw new Error( + "Missing the required parameter 'opts.forwardRuleSpec' when calling createForwardRule" + ) + } + + let postBody = {} + if (opts.forwardRuleSpec !== undefined && opts.forwardRuleSpec !== null) { + postBody['forwardRuleSpec'] = opts.forwardRuleSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 createForwardRule 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}/instances/{instanceId}/forwardRules', + '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 - 高防实例 Id + * @param {array} opts.forwardRuleSpecList - 批量添加非网站类规则请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string forwardRuleIds + * @param failedPort failedPorts + */ + + createForwardRules (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 createForwardRules" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createForwardRules" + ) + } + if ( + opts.forwardRuleSpecList === undefined || + opts.forwardRuleSpecList === null + ) { + throw new Error( + "Missing the required parameter 'opts.forwardRuleSpecList' when calling createForwardRules" + ) + } + + let postBody = {} + if ( + opts.forwardRuleSpecList !== undefined && + opts.forwardRuleSpecList !== null + ) { + postBody['forwardRuleSpecList'] = opts.forwardRuleSpecList + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 createForwardRules 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}/instances/{instanceId}:createForwardRules', + '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 - 高防实例 Id + * @param {string} opts.forwardRuleId - 转发规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param forwardRule data + */ + + describeForwardRule (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 describeForwardRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeForwardRule" + ) + } + if (opts.forwardRuleId === undefined || opts.forwardRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.forwardRuleId' when calling describeForwardRule" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + forwardRuleId: opts.forwardRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeForwardRule 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}/instances/{instanceId}/forwardRules/{forwardRuleId}', + '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} opts.forwardRuleId - 转发规则 Id + * @param {forwardRuleSpec} opts.forwardRuleSpec - 更新非网站类规则请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 更新规则失败, 1: 更新规则成功 + * @param string message 更新规则失败时给出具体原因 + */ + + modifyForwardRule (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 modifyForwardRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyForwardRule" + ) + } + if (opts.forwardRuleId === undefined || opts.forwardRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.forwardRuleId' when calling modifyForwardRule" + ) + } + if (opts.forwardRuleSpec === undefined || opts.forwardRuleSpec === null) { + throw new Error( + "Missing the required parameter 'opts.forwardRuleSpec' when calling modifyForwardRule" + ) + } + + let postBody = {} + if (opts.forwardRuleSpec !== undefined && opts.forwardRuleSpec !== null) { + postBody['forwardRuleSpec'] = opts.forwardRuleSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + forwardRuleId: opts.forwardRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 modifyForwardRule 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}/instances/{instanceId}/forwardRules/{forwardRuleId}', + 'PATCH', + 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) + } + ) + } + + /** + * 删除非网站规则, 批量操作时, 返回 result.code 为 1 表示操作成功, 为 0 时可能全部失败, 也可能部分失败 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.forwardRuleId - 转发规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 删除规则失败, 1: 删除规则成功 + * @param string message 删除规则失败时给出具体原因 + */ + + deleteForwardRule (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 deleteForwardRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteForwardRule" + ) + } + if (opts.forwardRuleId === undefined || opts.forwardRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.forwardRuleId' when calling deleteForwardRule" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + forwardRuleId: opts.forwardRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 deleteForwardRule 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}/instances/{instanceId}/forwardRules/{forwardRuleId}', + '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) + } + ) + } + + /** + * 非网站类规则切换成防御状态。支持批量操作, 批量操作时 forwardRuleId 传多个, 以 ',' 分隔, 返回 result.code 为 1 表示操作成功, 为 0 时可能全部失败, 也可能部分失败 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.forwardRuleId - 转发规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 切换失败, 1: 切换成功 + * @param string message 切换失败时给出具体原因 + */ + + switchForwardRuleProtect (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 switchForwardRuleProtect" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling switchForwardRuleProtect" + ) + } + if (opts.forwardRuleId === undefined || opts.forwardRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.forwardRuleId' when calling switchForwardRuleProtect" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + forwardRuleId: opts.forwardRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 switchForwardRuleProtect 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}/instances/{instanceId}/forwardRules/{forwardRuleId}:protect', + '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) + } + ) + } + + /** + * 非网站类规则切换成回源状态。支持批量操作, 批量操作时 forwardRuleId 传多个, 以 ',' 分隔, 返回 result.code 为 1 表示操作成功, 为 0 时可能全部失败, 也可能部分失败 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.forwardRuleId - 转发规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 切换失败, 1: 切换成功 + * @param string message 切换失败时给出具体原因 + */ + + switchForwardRuleOrigin (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 switchForwardRuleOrigin" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling switchForwardRuleOrigin" + ) + } + if (opts.forwardRuleId === undefined || opts.forwardRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.forwardRuleId' when calling switchForwardRuleOrigin" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + forwardRuleId: opts.forwardRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 switchForwardRuleOrigin 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}/instances/{instanceId}/forwardRules/{forwardRuleId}:origin', + '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 - 高防实例 Id + * @param {string} opts.forwardRuleId - 转发规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param forwardProtectionRule protectionRule + */ + + describeProtectionRuleOfForwardRule ( + 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 describeProtectionRuleOfForwardRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeProtectionRuleOfForwardRule" + ) + } + if (opts.forwardRuleId === undefined || opts.forwardRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.forwardRuleId' when calling describeProtectionRuleOfForwardRule" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + forwardRuleId: opts.forwardRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeProtectionRuleOfForwardRule 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}/instances/{instanceId}/forwardRules/{forwardRuleId}:describeProtectionRule', + '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} opts.forwardRuleId - 转发规则 Id + * @param {forwardProtectionRuleSpec} opts.forwardProtectionRuleSpec - 修改非网站类转发规则的防护规则请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 修改规则失败, 1: 修改规则成功 + * @param string message 修改规则失败时给出具体原因 + */ + + modifyProtectionRuleOfForwardRule ( + 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 modifyProtectionRuleOfForwardRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyProtectionRuleOfForwardRule" + ) + } + if (opts.forwardRuleId === undefined || opts.forwardRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.forwardRuleId' when calling modifyProtectionRuleOfForwardRule" + ) + } + if ( + opts.forwardProtectionRuleSpec === undefined || + opts.forwardProtectionRuleSpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.forwardProtectionRuleSpec' when calling modifyProtectionRuleOfForwardRule" + ) + } + + let postBody = {} + if ( + opts.forwardProtectionRuleSpec !== undefined && + opts.forwardProtectionRuleSpec !== null + ) { + postBody['forwardProtectionRuleSpec'] = opts.forwardProtectionRuleSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + forwardRuleId: opts.forwardRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 modifyProtectionRuleOfForwardRule 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}/instances/{instanceId}/forwardRules/{forwardRuleId}:modifyProtectionRule', + '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) + } + ) + } + + /** + * 查询非网站类转发规则的防护规则 Geo 拦截可设置区域编码 + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param country dataList + */ + + describeGeoAreas (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 describeGeoAreas" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeGeoAreas 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}/describeGeoAreas', + '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} opts.forwardRuleId - 转发规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param forwardBlackListRule data + */ + + describeBlackListRuleOfForwardRule ( + 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 describeBlackListRuleOfForwardRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeBlackListRuleOfForwardRule" + ) + } + if (opts.forwardRuleId === undefined || opts.forwardRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.forwardRuleId' when calling describeBlackListRuleOfForwardRule" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + forwardRuleId: opts.forwardRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeBlackListRuleOfForwardRule 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}/instances/{instanceId}/forwardRules/{forwardRuleId}/forwardBlackListRule', + '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} opts.forwardRuleId - 转发规则 Id + * @param {modifyBlackListRuleOfForwardRuleSpec} opts.modifySpec - 修改转发规则的黑名单规则请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 修改结果, 0: 修改失败, 1: 修改成功 + * @param string message 修改失败时给出具体原因 + */ + + modifyBlackListRuleOfForwardRule ( + 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 modifyBlackListRuleOfForwardRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyBlackListRuleOfForwardRule" + ) + } + if (opts.forwardRuleId === undefined || opts.forwardRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.forwardRuleId' when calling modifyBlackListRuleOfForwardRule" + ) + } + if (opts.modifySpec === undefined || opts.modifySpec === null) { + throw new Error( + "Missing the required parameter 'opts.modifySpec' when calling modifyBlackListRuleOfForwardRule" + ) + } + + let postBody = {} + if (opts.modifySpec !== undefined && opts.modifySpec !== null) { + postBody['modifySpec'] = opts.modifySpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + forwardRuleId: opts.forwardRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 modifyBlackListRuleOfForwardRule 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}/instances/{instanceId}/forwardRules/{forwardRuleId}/forwardBlackListRule', + 'PATCH', + 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} opts.forwardRuleId - 转发规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 开启结果, 0: 开启失败, 1: 开启成功 + * @param string message 开启失败时给出具体原因 + */ + + enableBlackListRuleOfForwardRule ( + 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 enableBlackListRuleOfForwardRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling enableBlackListRuleOfForwardRule" + ) + } + if (opts.forwardRuleId === undefined || opts.forwardRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.forwardRuleId' when calling enableBlackListRuleOfForwardRule" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + forwardRuleId: opts.forwardRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 enableBlackListRuleOfForwardRule 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}/instances/{instanceId}/forwardRules/{forwardRuleId}:enableBlackListRuleOfForwardRule', + '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 - 高防实例 Id + * @param {string} opts.forwardRuleId - 转发规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 关闭结果, 0: 关闭失败, 1: 关闭成功 + * @param string message 关闭失败时给出具体原因 + */ + + disableBlackListRuleOfForwardRule ( + 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 disableBlackListRuleOfForwardRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling disableBlackListRuleOfForwardRule" + ) + } + if (opts.forwardRuleId === undefined || opts.forwardRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.forwardRuleId' when calling disableBlackListRuleOfForwardRule" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + forwardRuleId: opts.forwardRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 disableBlackListRuleOfForwardRule 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}/instances/{instanceId}/forwardRules/{forwardRuleId}:disableBlackListRuleOfForwardRule', + '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 - 高防实例 Id + * @param {string} opts.forwardRuleId - 转发规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param forwardWhiteListRule data + */ + + describeWhiteListRuleOfForwardRule ( + 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 describeWhiteListRuleOfForwardRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeWhiteListRuleOfForwardRule" + ) + } + if (opts.forwardRuleId === undefined || opts.forwardRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.forwardRuleId' when calling describeWhiteListRuleOfForwardRule" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + forwardRuleId: opts.forwardRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeWhiteListRuleOfForwardRule 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}/instances/{instanceId}/forwardRules/{forwardRuleId}/forwardWhiteListRule', + '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} opts.forwardRuleId - 转发规则 Id + * @param {modifyWhiteListRuleOfForwardRuleSpec} opts.modifySpec - 修改转发规则的黑名单规则请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 修改结果, 0: 修改失败, 1: 修改成功 + * @param string message 修改失败时给出具体原因 + */ + + modifyWhiteListRuleOfForwardRule ( + 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 modifyWhiteListRuleOfForwardRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyWhiteListRuleOfForwardRule" + ) + } + if (opts.forwardRuleId === undefined || opts.forwardRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.forwardRuleId' when calling modifyWhiteListRuleOfForwardRule" + ) + } + if (opts.modifySpec === undefined || opts.modifySpec === null) { + throw new Error( + "Missing the required parameter 'opts.modifySpec' when calling modifyWhiteListRuleOfForwardRule" + ) + } + + let postBody = {} + if (opts.modifySpec !== undefined && opts.modifySpec !== null) { + postBody['modifySpec'] = opts.modifySpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + forwardRuleId: opts.forwardRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 modifyWhiteListRuleOfForwardRule 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}/instances/{instanceId}/forwardRules/{forwardRuleId}/forwardWhiteListRule', + 'PATCH', + 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} opts.forwardRuleId - 转发规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 开启结果, 0: 开启失败, 1: 开启成功 + * @param string message 开启失败时给出具体原因 + */ + + enableWhiteListRuleOfForwardRule ( + 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 enableWhiteListRuleOfForwardRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling enableWhiteListRuleOfForwardRule" + ) + } + if (opts.forwardRuleId === undefined || opts.forwardRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.forwardRuleId' when calling enableWhiteListRuleOfForwardRule" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + forwardRuleId: opts.forwardRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 enableWhiteListRuleOfForwardRule 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}/instances/{instanceId}/forwardRules/{forwardRuleId}:enableWhiteListRuleOfForwardRule', + '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 - 高防实例 Id + * @param {string} opts.forwardRuleId - 转发规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 关闭结果, 0: 关闭失败, 1: 关闭成功 + * @param string message 关闭失败时给出具体原因 + */ + + disableWhiteListRuleOfForwardRule ( + 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 disableWhiteListRuleOfForwardRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling disableWhiteListRuleOfForwardRule" + ) + } + if (opts.forwardRuleId === undefined || opts.forwardRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.forwardRuleId' when calling disableWhiteListRuleOfForwardRule" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + forwardRuleId: opts.forwardRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 disableWhiteListRuleOfForwardRule 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}/instances/{instanceId}/forwardRules/{forwardRuleId}:disableWhiteListRuleOfForwardRule', + '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) + } + ) + } + + /** + * 查询实例全局访问控制配置,包括全局的IP黑白名单和geo拦截配置 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instanceAcl data + */ + + describeInstanceAcl (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 describeInstanceAcl" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeInstanceAcl" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeInstanceAcl 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}/instances/{instanceId}:describeInstanceAcl', + '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黑白名单和geo拦截配置 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例 ID + * @param {instanceAclSpec} opts.instanceAclSpec - 修改实例全局访问控制配置参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 修改是否下发成功 + * @param boolean canRecover 是否可以恢复到上一次的配置 + */ + + modifyInstanceAcl (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 modifyInstanceAcl" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyInstanceAcl" + ) + } + if (opts.instanceAclSpec === undefined || opts.instanceAclSpec === null) { + throw new Error( + "Missing the required parameter 'opts.instanceAclSpec' when calling modifyInstanceAcl" + ) + } + + let postBody = {} + if (opts.instanceAclSpec !== undefined && opts.instanceAclSpec !== null) { + postBody['instanceAclSpec'] = opts.instanceAclSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 modifyInstanceAcl 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}/instances/{instanceId}:modifyInstanceAcl', + '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 - 实例 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success 是否回滚成功 + */ + + recoverInstanceAcl (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 recoverInstanceAcl" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling recoverInstanceAcl" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 recoverInstanceAcl 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}/instances/{instanceId}:recoverInstanceAcl', + '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 - 实例 ID + * @param {string} [opts.status] - 自定义页面状态, 可取值approving: 审批中, refused: 审批不通过, approved: 审批通过, 为空时查询全部 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param customPage dataList + */ + + describeCustomPages (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 describeCustomPages" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeCustomPages" + ) + } + + let postBody = null + let queryParams = {} + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeCustomPages 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}/instances/{instanceId}/customPages', + '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 {customPageSpec} opts.customPageSpec - 添加自定义页面请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 添加失败, 1: 添加成功 + * @param string message 添加失败时给出具体原因 + */ + + createCustomPage (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 createCustomPage" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createCustomPage" + ) + } + if (opts.customPageSpec === undefined || opts.customPageSpec === null) { + throw new Error( + "Missing the required parameter 'opts.customPageSpec' when calling createCustomPage" + ) + } + + let postBody = {} + if (opts.customPageSpec !== undefined && opts.customPageSpec !== null) { + postBody['customPageSpec'] = opts.customPageSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 createCustomPage 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}/instances/{instanceId}/customPages', + '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 - 实例 ID + * @param {string} opts.pageId - 自定义页面Id + * @param {customPageSpec} opts.customPageSpec - 修改自定义页面请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 修改失败, 1: 修改成功 + * @param string message 修改失败时给出具体原因 + */ + + modifyCustomPage (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 modifyCustomPage" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyCustomPage" + ) + } + if (opts.pageId === undefined || opts.pageId === null) { + throw new Error( + "Missing the required parameter 'opts.pageId' when calling modifyCustomPage" + ) + } + if (opts.customPageSpec === undefined || opts.customPageSpec === null) { + throw new Error( + "Missing the required parameter 'opts.customPageSpec' when calling modifyCustomPage" + ) + } + + let postBody = {} + if (opts.customPageSpec !== undefined && opts.customPageSpec !== null) { + postBody['customPageSpec'] = opts.customPageSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + pageId: opts.pageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 modifyCustomPage 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}/instances/{instanceId}/customPages/{pageId}', + '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) + } + ) + } + + /** + * 删除自定义页面, 使用中的不允许删除 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例 ID + * @param {string} opts.pageId - 自定义页面Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 删除失败, 1: 删除成功 + * @param string message 删除失败时给出具体原因 + */ + + deleteCustomPage (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 deleteCustomPage" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteCustomPage" + ) + } + if (opts.pageId === undefined || opts.pageId === null) { + throw new Error( + "Missing the required parameter 'opts.pageId' when calling deleteCustomPage" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + pageId: opts.pageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 deleteCustomPage 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}/instances/{instanceId}/customPages/{pageId}', + '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.instanceId - 实例 ID + * @param {string} opts.pageId - 自定义页面Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 修改失败, 1: 修改成功 + * @param string message 修改失败时给出具体原因 + */ + + modifyInstanceCustomPage (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 modifyInstanceCustomPage" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyInstanceCustomPage" + ) + } + if (opts.pageId === undefined || opts.pageId === null) { + throw new Error( + "Missing the required parameter 'opts.pageId' when calling modifyInstanceCustomPage" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + pageId: opts.pageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 modifyInstanceCustomPage 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}/instances/{instanceId}/customPages/{pageId}:modifyInstanceCustomPage', + '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 - 实例 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 修改失败, 1: 修改成功 + * @param string message 修改失败时给出具体原因 + */ + + modifyInstanceCustomPageDefault ( + 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 modifyInstanceCustomPageDefault" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyInstanceCustomPageDefault" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 modifyInstanceCustomPageDefault 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}/instances/{instanceId}:modifyInstanceCustomPageDefault', + '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 - 实例 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 修改失败, 1: 修改成功 + * @param string message 修改失败时给出具体原因 + */ + + enableInstanceCustomPage (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 enableInstanceCustomPage" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling enableInstanceCustomPage" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 enableInstanceCustomPage 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}/instances/{instanceId}:enableInstanceCustomPage', + '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 - 实例 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 修改失败, 1: 修改成功 + * @param string message 修改失败时给出具体原因 + */ + + disableInstanceCustomPage (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 disableInstanceCustomPage" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling disableInstanceCustomPage" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 disableInstanceCustomPage 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}/instances/{instanceId}:disableInstanceCustomPage', + '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.pageNumber] - 页码, 默认为 1 optional + * @param {integer} [opts.pageSize] - 分页大小, 默认为 10, 取值范围[10, 100], 0 表示全量 optional + * @param {string} [opts.name] - 实例名称, 可模糊匹配 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instance dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 总数 + * @param integer totalPage 总页数 + */ + + 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.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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}/instances', + '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 {createInstanceSpec} opts.createInstanceSpec - 新购或升级实例请求参数 + * @param {autoRenewalSpec} [opts.autoRenewalSpec] - 自动续费配置, 默认不开通, 仅新购实例时可设置 optional + * @param {boolean} [opts.autoPay] - 自动支付标识 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 新购或升级实例失败, 1: 新购或升级实例成功 + * @param string message 新购或升级成功时为计费资源ID, 创建实例失败时给出具体原因 + * @param string orderNumber 新购或升级实例成功, 且设置了自动支付时, 为订单号。否则为空 + */ + + createInstance (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 createInstance" + ) + } + + opts = opts || {} + + if ( + opts.createInstanceSpec === undefined || + opts.createInstanceSpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.createInstanceSpec' when calling createInstance" + ) + } + + let postBody = {} + if ( + opts.createInstanceSpec !== undefined && + opts.createInstanceSpec !== null + ) { + postBody['createInstanceSpec'] = opts.createInstanceSpec + } + if (opts.autoRenewalSpec !== undefined && opts.autoRenewalSpec !== null) { + postBody['autoRenewalSpec'] = opts.autoRenewalSpec + } + if (opts.autoPay !== undefined && opts.autoPay !== null) { + postBody['autoPay'] = opts.autoPay + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 createInstance 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}/instances', + '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 - 实例 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instance data + */ + + 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 || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeInstance" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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}/instances/{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.instanceId - 实例 ID + * @param {renameInstanceSpec} opts.renameInstanceSpec - 修改实例名称请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 修改实例名称失败, 1: 修改实例名称成功 + * @param string message 修改失败时给出具体原因 + */ + + modifyInstanceName (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 modifyInstanceName" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyInstanceName" + ) + } + if ( + opts.renameInstanceSpec === undefined || + opts.renameInstanceSpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.renameInstanceSpec' when calling modifyInstanceName" + ) + } + + let postBody = {} + if ( + opts.renameInstanceSpec !== undefined && + opts.renameInstanceSpec !== null + ) { + postBody['renameInstanceSpec'] = opts.renameInstanceSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 modifyInstanceName 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}/instances/{instanceId}:rename', + '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 - 实例 ID + * @param {modifyInstanceEPBSpec} opts.modifyInstanceEPBSpec - 修改实例名称请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 修改失败, 1: 修改成功 + * @param string message 修改失败时给出具体原因 + */ + + modifyEPB (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 modifyEPB" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyEPB" + ) + } + if ( + opts.modifyInstanceEPBSpec === undefined || + opts.modifyInstanceEPBSpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.modifyInstanceEPBSpec' when calling modifyEPB" + ) + } + + let postBody = {} + if ( + opts.modifyInstanceEPBSpec !== undefined && + opts.modifyInstanceEPBSpec !== null + ) { + postBody['modifyInstanceEPBSpec'] = opts.modifyInstanceEPBSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 modifyEPB 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}/instances/{instanceId}:modifyEPB', + '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 - 实例 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param alarmConfig data + */ + + describeAlarmConfig (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 describeAlarmConfig" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeAlarmConfig" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeAlarmConfig 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}/instances/{instanceId}:describeAlarmConfig', + '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 {alarmConfigSpec} opts.alarmConfigSpec - 更新告警配置请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 修改失败, 1: 修改成功 + * @param string message 修改失败时给出具体原因 + */ + + modifyAlarmConfig (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 modifyAlarmConfig" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyAlarmConfig" + ) + } + if (opts.alarmConfigSpec === undefined || opts.alarmConfigSpec === null) { + throw new Error( + "Missing the required parameter 'opts.alarmConfigSpec' when calling modifyAlarmConfig" + ) + } + + let postBody = {} + if (opts.alarmConfigSpec !== undefined && opts.alarmConfigSpec !== null) { + postBody['alarmConfigSpec'] = opts.alarmConfigSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 modifyAlarmConfig 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}/instances/{instanceId}:modifyAlarmConfig', + '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) + } + ) + } + + /** + * 查询高防实例回源 IP 白名单列表 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string data + */ + + describeOriginWhiteIpList (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 describeOriginWhiteIpList" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeOriginWhiteIpList" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeOriginWhiteIpList 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}/instances/{instanceId}:describeOriginWhiteIpList', + '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 列表 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例 ID + * @param {integer} [opts.pageNumber] - 页码, 默认为 1 optional + * @param {integer} [opts.pageSize] - 分页大小, 默认为 10, 取值范围[10, 100] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param serviceIp dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 总数 + * @param integer totalPage 总页数 + */ + + describeServiceIpList (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 describeServiceIpList" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeServiceIpList" + ) + } + + 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 ipanti/1.12.0' + } + + 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 describeServiceIpList 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}/instances/{instanceId}:describeServiceIpList', + '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) + } + ) + } + + /** + * 根据高防计费资源ID查询对应的实例Id, 调用 <a href='http://docs.jdcloud.com/anti-ddos-pro/api/createInstance'>createInstance</a> 接口成功后,跟据message字段返回的计费资源Id查询对应的高防实例ID, 需要高防实例实际创建成功以后才可查询得到 + * @param {Object} opts - parameters + * @param {string} opts.resourceId - 高防实例计费资源ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instanceIdVo data + */ + + describeInstanceIdByResourceId ( + 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 describeInstanceIdByResourceId" + ) + } + + opts = opts || {} + + if (opts.resourceId === undefined || opts.resourceId === null) { + throw new Error( + "Missing the required parameter 'opts.resourceId' when calling describeInstanceIdByResourceId" + ) + } + + let postBody = null + let queryParams = {} + if (opts.resourceId !== undefined && opts.resourceId !== null) { + queryParams['resourceId'] = opts.resourceId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeInstanceIdByResourceId 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}/describeInstanceIdByResourceId', + '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.id] - 高防实例 ID, 为空则查询所有实例名称 optional + * @param {string} [opts.name] - 实例名称, 可模糊匹配 optional + * @param {integer} [opts.pageNumber] - 页码, 默认为 1 optional + * @param {integer} [opts.pageSize] - 分页大小, 默认为 10, 取值范围 [10, 100] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instanceIdName dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 总数 + * @param integer totalPage 总页数 + */ + + describeNameList (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 describeNameList" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.id !== undefined && opts.id !== null) { + queryParams['id'] = opts.id + } + if (opts.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + 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 + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeNameList 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}/describeNameList', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param protectionStatistics data + */ + + describeProtectionStatistics ( + 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 describeProtectionStatistics" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeProtectionStatistics 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}/describeProtectionStatistics', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param protectionOutline data + */ + + describeProtectionOutline (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 describeProtectionOutline" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeProtectionOutline 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}/describeProtectionOutline', + '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.name - 待检测实例名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 检测结果 code, 0: 不可用, 1: 可用 + * @param string message 检测结果, 不可用时给出具体原因 + */ + + checkName (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 checkName" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling checkName" + ) + } + + let postBody = null + let queryParams = {} + if (opts.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 checkName 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}/checkName', + '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 资源 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码, 默认为 1 optional + * @param {integer} [opts.pageSize] - 分页大小, 默认为 10, 取值范围 [0, 100], 0 表示全量 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param vpcIpResource dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 总数 + * @param integer totalPage 总页数 + */ + + describeVpcIpList (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 describeVpcIpList" + ) + } + + 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 + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeVpcIpList 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}/describeVpcIpList', + '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 资源 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码, 默认为 1 optional + * @param {integer} [opts.pageSize] - 分页大小, 默认为 10, 取值范围 [0, 100], 0 表示全量 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param cpsIpResource dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 总数 + * @param integer totalPage 总页数 + */ + + describeCpsIpList (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 describeCpsIpList" + ) + } + + 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 + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeCpsIpList 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}/cpsIpResources', + '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 资源 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码, 默认为 1 optional + * @param {integer} [opts.pageSize] - 分页大小, 默认为 10, 取值范围 [0, 100], 0 表示全量 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param ccsIpResource dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 总数 + * @param integer totalPage 总页数 + */ + + describeCcsIpList (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 describeCcsIpList" + ) + } + + 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 + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeCcsIpList 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}/ccsIpResources', + '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 黑白名单库列表 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {integer} [opts.pageNumber] - 页码, 默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小, 默认为10, 取值范围[10, 100] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param ipSet dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 总数 + * @param integer totalPage 总页数 + */ + + describeIpSets (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 describeIpSets" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeIpSets" + ) + } + + 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 ipanti/1.12.0' + } + + 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 describeIpSets 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}/instances/{instanceId}/ipSets', + '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 黑白名单绑定到转发规则的黑名单或白名单后生效 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {ipSetSpec} opts.ipSetSpec - 添加实例的 IP 黑白名单请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 添加失败, 1: 添加成功 + * @param string message 添加失败时给出具体原因 + */ + + createIpSet (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 createIpSet" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createIpSet" + ) + } + if (opts.ipSetSpec === undefined || opts.ipSetSpec === null) { + throw new Error( + "Missing the required parameter 'opts.ipSetSpec' when calling createIpSet" + ) + } + + let postBody = {} + if (opts.ipSetSpec !== undefined && opts.ipSetSpec !== null) { + postBody['ipSetSpec'] = opts.ipSetSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 createIpSet 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}/instances/{instanceId}/ipSets', + '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) + } + ) + } + + /** + * 查询实例的 IP 黑白名单 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.ipSetId - IP 黑白名单 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param ipSet data + */ + + describeIpSet (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 describeIpSet" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeIpSet" + ) + } + if (opts.ipSetId === undefined || opts.ipSetId === null) { + throw new Error( + "Missing the required parameter 'opts.ipSetId' when calling describeIpSet" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + ipSetId: opts.ipSetId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeIpSet 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}/instances/{instanceId}/ipSets/{ipSetId}', + '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 黑白名单. 支持批量操作, 批量操作时 ipSetId 传多个, 以 ',' 分隔. IP 黑白名单规则被引用时不允许删除 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.ipSetId - IP 黑白名单 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param batchResultDetail data + */ + + deleteIpSet (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 deleteIpSet" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteIpSet" + ) + } + if (opts.ipSetId === undefined || opts.ipSetId === null) { + throw new Error( + "Missing the required parameter 'opts.ipSetId' when calling deleteIpSet" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + ipSetId: opts.ipSetId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 deleteIpSet 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}/instances/{instanceId}/ipSets/{ipSetId}', + '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) + } + ) + } + + /** + * 查询实例的 IP 黑白名单用量信息 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer allocatedNum 实例已添加的 IP 黑白名单数量 + * @param integer surplusAllocateNum 实例还可添加的 IP 黑白名单数量 + * @param integer maxAllocateNum 实例最多可添加的 IP 黑白名单数量 + */ + + describeIpSetUsage (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 describeIpSetUsage" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeIpSetUsage" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeIpSetUsage 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}/instances/{instanceId}:describeIpSetUsage', + '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 {integer} [opts.pageNumber] - 页码, 默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小, 默认为10, 取值范围[10, 100] optional + * @param {string} [opts.searchType] - 查询类型名称, domain:源站域名, ip:源站 IP, rawDomain: 域名, serviceIp: 高防IP(仅支持BGP线路的实例) optional + * @param {string} [opts.searchValue] - 查询类型值 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param webRule dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 总数 + * @param integer totalPage 总页数 + */ + + describeWebRules (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 describeWebRules" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeWebRules" + ) + } + + 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.searchType !== undefined && opts.searchType !== null) { + queryParams['searchType'] = opts.searchType + } + if (opts.searchValue !== undefined && opts.searchValue !== null) { + queryParams['searchValue'] = opts.searchValue + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeWebRules 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}/instances/{instanceId}/webRules', + '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 {webRuleSpec} opts.webRuleSpec - 添加网站类规则请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 添加失败, 1: 添加成功 + * @param string message 添加失败时给出具体原因 + */ + + createWebRule (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 createWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createWebRule" + ) + } + if (opts.webRuleSpec === undefined || opts.webRuleSpec === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleSpec' when calling createWebRule" + ) + } + + let postBody = {} + if (opts.webRuleSpec !== undefined && opts.webRuleSpec !== null) { + postBody['webRuleSpec'] = opts.webRuleSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 createWebRule 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}/instances/{instanceId}/webRules', + '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 - 高防实例 Id + * @param {array} opts.webRuleSpecList - 批量添加网站类规则请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string webRuleIdIds + * @param failedDomain failedDomains + */ + + createWebRules (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 createWebRules" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createWebRules" + ) + } + if (opts.webRuleSpecList === undefined || opts.webRuleSpecList === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleSpecList' when calling createWebRules" + ) + } + + let postBody = {} + if (opts.webRuleSpecList !== undefined && opts.webRuleSpecList !== null) { + postBody['webRuleSpecList'] = opts.webRuleSpecList + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 createWebRules 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}/instances/{instanceId}:createWebRules', + '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 - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param webRule data + */ + + describeWebRule (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 describeWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling describeWebRule" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeWebRule 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}/instances/{instanceId}/webRules/{webRuleId}', + '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} opts.webRuleId - 网站规则 Id + * @param {webRuleSpec} opts.webRuleSpec - 更新网站类规则请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 修改网站类规则结果, 0: 修改失败, 1: 修改成功 + * @param string message 修改失败时给出具体原因 + */ + + modifyWebRule (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 modifyWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling modifyWebRule" + ) + } + if (opts.webRuleSpec === undefined || opts.webRuleSpec === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleSpec' when calling modifyWebRule" + ) + } + + let postBody = {} + if (opts.webRuleSpec !== undefined && opts.webRuleSpec !== null) { + postBody['webRuleSpec'] = opts.webRuleSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 modifyWebRule 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}/instances/{instanceId}/webRules/{webRuleId}', + 'PATCH', + 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) + } + ) + } + + /** + * 删除网站规则。支持批量操作, 批量操作时 webRuleId 传多个, 以 ',' 分隔, 返回 result.code 为 1 表示操作成功, 为 0 时可能全部失败, 也可能部分失败 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 删除网站类规则结果, 0: 删除失败, 1: 删除成功 + * @param string message 删除失败时给出具体原因 + */ + + deleteWebRule (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 deleteWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling deleteWebRule" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 deleteWebRule 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}/instances/{instanceId}/webRules/{webRuleId}', + '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) + } + ) + } + + /** + * 网站类规则绑定 SSL 证书 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} opts.certId - 证书 Id. 使用 <a href='https://docs.jdcloud.com/cn/ssl-certificate/api/describecerts'>describeCerts</a> 接口, 按照域名检索可绑定的证书, 域名不匹配将导致证书配置失败 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 绑定失败, 1: 绑定成功 + * @param string message 绑定失败时给出具体原因 + */ + + bindCert (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 bindCert" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling bindCert" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling bindCert" + ) + } + if (opts.certId === undefined || opts.certId === null) { + throw new Error( + "Missing the required parameter 'opts.certId' when calling bindCert" + ) + } + + let postBody = {} + if (opts.certId !== undefined && opts.certId !== null) { + postBody['certId'] = opts.certId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 bindCert 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}/instances/{instanceId}/webRules/{webRuleId}:bindCert', + '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) + } + ) + } + + /** + * 网站类规则切换成防御状态。支持批量操作, 批量操作时 webRuleId 传多个, 以 ',' 分隔, 返回 result.code 为 1 表示操作成功, 为 0 时可能全部失败, 也可能部分失败 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 规则切换成防御失败, 1: 规则切换成防御成功 + * @param string message 规则切换成防御失败时给出具体原因 + */ + + switchWebRuleProtect (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 switchWebRuleProtect" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling switchWebRuleProtect" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling switchWebRuleProtect" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 switchWebRuleProtect 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}/instances/{instanceId}/webRules/{webRuleId}:protect', + '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) + } + ) + } + + /** + * 网站类规则切换成回源状态。支持批量操作, 批量操作时 webRuleId 传多个, 以 ',' 分隔, 返回 result.code 为 1 表示操作成功, 为 0 时可能全部失败, 也可能部分失败 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 规则切换成回源失败, 1: 规则切换成回源成功 + * @param string message 规则切换成回源失败时给出具体原因 + */ + + switchWebRuleOrigin (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 switchWebRuleOrigin" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling switchWebRuleOrigin" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling switchWebRuleOrigin" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 switchWebRuleOrigin 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}/instances/{instanceId}/webRules/{webRuleId}:origin', + '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) + } + ) + } + + /** + * 网站类规则开启 CC 防护, 开启后网站类规则已配置的防护规则和 CC 防护配置生效, 若没有配置过 CC 防护, 默认的 CC 防护配置生效。支持批量操作, 批量操作时 webRuleId 传多个, 以 ',' 分隔, 返回 result.code 为 1 表示操作成功, 为 0 时可能全部失败, 也可能部分失败 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 开启 CC 失败, 1: 开启 CC 成功 + * @param string message 开启 CC 失败时给出具体原因 + */ + + enableWebRuleCC (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 enableWebRuleCC" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling enableWebRuleCC" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling enableWebRuleCC" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 enableWebRuleCC 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}/instances/{instanceId}/webRules/{webRuleId}:enableCC', + '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) + } + ) + } + + /** + * 关闭网站类规则 CC 防护, 网站类规则的 CC 防护规则和 CC 防护配置失效。支持批量操作, 批量操作时 webRuleId 传多个, 以 ',' 分隔, 返回 result.code 为 1 表示操作成功, 为 0 时可能全部失败, 也可能部分失败 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 禁用 CC 失败, 1: 禁用 CC 成功 + * @param string message 禁用 CC 失败时给出具体原因 + */ + + disableWebRuleCC (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 disableWebRuleCC" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling disableWebRuleCC" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling disableWebRuleCC" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 disableWebRuleCC 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}/instances/{instanceId}/webRules/{webRuleId}:disableCC', + '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) + } + ) + } + + /** + * 开启网站类规则 CC 观察者模式, 观察模式下, CC 防护只告警不防御。支持批量操作, 批量操作时 webRuleId 传多个, 以 ',' 分隔, 返回 result.code 为 1 表示操作成功, 为 0 时可能全部失败, 也可能部分失败 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 开启 CC 观察者模式失败, 1: 开启 CC 观察者模式成功 + * @param string message 开启 CC 观察者模式失败时给出具体原因 + */ + + enableWebRuleCCObserverMode (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 enableWebRuleCCObserverMode" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling enableWebRuleCCObserverMode" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling enableWebRuleCCObserverMode" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 enableWebRuleCCObserverMode 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}/instances/{instanceId}/webRules/{webRuleId}:enableCCObserverMode', + '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) + } + ) + } + + /** + * 关闭网站类规则 CC 观察者模式, 观察模式下, CC 防护只告警不防御。支持批量操作, 批量操作时 webRuleId 传多个, 以 ',' 分隔, 返回 result.code 为 1 表示操作成功, 为 0 时可能全部失败, 也可能部分失败 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 关闭 CC 观察者模式失败, 1: 关闭 CC 观察者模式成功 + * @param string message 关闭 CC 观察者模式失败时给出具体原因 + */ + + disableWebRuleCCObserverMode ( + 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 disableWebRuleCCObserverMode" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling disableWebRuleCCObserverMode" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling disableWebRuleCCObserverMode" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 disableWebRuleCCObserverMode 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}/instances/{instanceId}/webRules/{webRuleId}:disableCCObserverMode', + '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) + } + ) + } + + /** + * 查询网站类规则允许插入JS指纹的页面 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {integer} [opts.pageNumber] - 页码, 默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小, 默认为10, 取值范围[10, 100] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param jsPage dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 总数 + * @param integer totalPage 总页数 + */ + + describeJsPagesOfWebRule (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 describeJsPagesOfWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeJsPagesOfWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling describeJsPagesOfWebRule" + ) + } + + 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, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeJsPagesOfWebRule 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}/instances/{instanceId}/webRules/{webRuleId}/jsPages', + '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) + } + ) + } + + /** + * 添加网站类规则允许插入JS指纹的页面 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {jsPageSpec} opts.jsPageSpec - 添加 JS 指纹页面请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 添加失败, 1: 添加成功 + * @param string message 添加失败时给出具体原因 + */ + + createJsPageOfWebRule (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 createJsPageOfWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createJsPageOfWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling createJsPageOfWebRule" + ) + } + if (opts.jsPageSpec === undefined || opts.jsPageSpec === null) { + throw new Error( + "Missing the required parameter 'opts.jsPageSpec' when calling createJsPageOfWebRule" + ) + } + + let postBody = {} + if (opts.jsPageSpec !== undefined && opts.jsPageSpec !== null) { + postBody['jsPageSpec'] = opts.jsPageSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 createJsPageOfWebRule 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}/instances/{instanceId}/webRules/{webRuleId}/jsPages', + '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) + } + ) + } + + /** + * 批量添加网站类规则允许插入JS指纹的页面 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {jsPagesSpec} opts.jsPagesSpec - 添加 JS 指纹页面请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 添加失败, 1: 添加成功 + * @param string message 添加失败时给出具体原因 + */ + + createJsPagesOfWebRule (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 createJsPagesOfWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createJsPagesOfWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling createJsPagesOfWebRule" + ) + } + if (opts.jsPagesSpec === undefined || opts.jsPagesSpec === null) { + throw new Error( + "Missing the required parameter 'opts.jsPagesSpec' when calling createJsPagesOfWebRule" + ) + } + + let postBody = {} + if (opts.jsPagesSpec !== undefined && opts.jsPagesSpec !== null) { + postBody['jsPagesSpec'] = opts.jsPagesSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 createJsPagesOfWebRule 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}/instances/{instanceId}/webRules/{webRuleId}:createJsPagesOfWebRule', + '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) + } + ) + } + + /** + * 修改网站类规则允许插入 JS 指纹的页面 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} opts.jsPageId - 支持插入JS指纹的页面 Id + * @param {jsPageSpec} opts.jsPageSpec - 修改网站类规则允许插入 JS 指纹的页面请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 修改失败, 1: 修改成功 + * @param string message 修改失败时给出具体原因 + */ + + modifyJsPageOfWebRule (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 modifyJsPageOfWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyJsPageOfWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling modifyJsPageOfWebRule" + ) + } + if (opts.jsPageId === undefined || opts.jsPageId === null) { + throw new Error( + "Missing the required parameter 'opts.jsPageId' when calling modifyJsPageOfWebRule" + ) + } + if (opts.jsPageSpec === undefined || opts.jsPageSpec === null) { + throw new Error( + "Missing the required parameter 'opts.jsPageSpec' when calling modifyJsPageOfWebRule" + ) + } + + let postBody = {} + if (opts.jsPageSpec !== undefined && opts.jsPageSpec !== null) { + postBody['jsPageSpec'] = opts.jsPageSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId, + jsPageId: opts.jsPageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 modifyJsPageOfWebRule 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}/instances/{instanceId}/webRules/{webRuleId}/jsPages/{jsPageId}', + 'PATCH', + 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) + } + ) + } + + /** + * 删除网站类规则允许插入 JS 指纹的页面。支持批量操作, 批量操作时 jsPageId 传多个, 以 ',' 分隔 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} opts.jsPageId - 支持插入JS指纹的页面 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 删除失败, 1: 删除成功 + * @param string message 删除失败时给出具体原因 + */ + + deleteJsPageOfWebRule (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 deleteJsPageOfWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteJsPageOfWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling deleteJsPageOfWebRule" + ) + } + if (opts.jsPageId === undefined || opts.jsPageId === null) { + throw new Error( + "Missing the required parameter 'opts.jsPageId' when calling deleteJsPageOfWebRule" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId, + jsPageId: opts.jsPageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 deleteJsPageOfWebRule 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}/instances/{instanceId}/webRules/{webRuleId}/jsPages/{jsPageId}', + '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) + } + ) + } + + /** + * 关闭网站类规则的JS指纹开关 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 关闭失败, 1: 关闭成功 + * @param string message 关闭失败时给出具体原因 + */ + + disableWebRuleJsPage (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 disableWebRuleJsPage" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling disableWebRuleJsPage" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling disableWebRuleJsPage" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 disableWebRuleJsPage 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}/instances/{instanceId}/webRules/{webRuleId}:disableWebRuleJsPage', + '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) + } + ) + } + + /** + * 打开网站类规则的JS指纹开关 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 打开失败, 1: 打开成功 + * @param string message 打开失败时给出具体原因 + */ + + enableWebRuleJsPage (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 enableWebRuleJsPage" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling enableWebRuleJsPage" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling enableWebRuleJsPage" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 enableWebRuleJsPage 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}/instances/{instanceId}/webRules/{webRuleId}:enableWebRuleJsPage', + '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) + } + ) + } + + /** + * 插入JS指纹到所有页面, 需要打开网站类规则的JS指纹开关 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 修改失败, 1: 修改成功 + * @param string message 修改失败时给出具体原因 + */ + + modifyWebRuleJsPageToAll (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 modifyWebRuleJsPageToAll" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyWebRuleJsPageToAll" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling modifyWebRuleJsPageToAll" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 modifyWebRuleJsPageToAll 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}/instances/{instanceId}/webRules/{webRuleId}:modifyWebRuleJsPageToAll', + '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) + } + ) + } + + /** + * 插入JS指纹到配置的自定义页面, 需要打开网站类规则的JS指纹开关 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 修改失败, 1: 修改成功 + * @param string message 修改失败时给出具体原因 + */ + + modifyWebRuleJsPageToCustom (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 modifyWebRuleJsPageToCustom" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyWebRuleJsPageToCustom" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling modifyWebRuleJsPageToCustom" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 modifyWebRuleJsPageToCustom 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}/instances/{instanceId}/webRules/{webRuleId}:modifyWebRuleJsPageToCustom', + '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) + } + ) + } + + /** + * 查询网站类规则的 CC 防护规则列表 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param cCProtectionRule dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 总数 + * @param integer totalPage 总页数 + */ + + describeCCProtectionRulesOfWebRule ( + 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 describeCCProtectionRulesOfWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeCCProtectionRulesOfWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling describeCCProtectionRulesOfWebRule" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeCCProtectionRulesOfWebRule 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}/instances/{instanceId}/webRules/{webRuleId}/ccProtectionRules', + '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) + } + ) + } + + /** + * 添加网站类规则的 CC 防护规则 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {cCProtectionRuleSpec} opts.ccProtectionRuleSpec - 添加 CC 防护规则请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 添加失败, 1: 添加成功 + * @param string message 添加失败时给出具体原因 + */ + + createCCProtectionRuleOfWebRule ( + 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 createCCProtectionRuleOfWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createCCProtectionRuleOfWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling createCCProtectionRuleOfWebRule" + ) + } + if ( + opts.ccProtectionRuleSpec === undefined || + opts.ccProtectionRuleSpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.ccProtectionRuleSpec' when calling createCCProtectionRuleOfWebRule" + ) + } + + let postBody = {} + if ( + opts.ccProtectionRuleSpec !== undefined && + opts.ccProtectionRuleSpec !== null + ) { + postBody['ccProtectionRuleSpec'] = opts.ccProtectionRuleSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 createCCProtectionRuleOfWebRule 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}/instances/{instanceId}/webRules/{webRuleId}/ccProtectionRules', + '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) + } + ) + } + + /** + * 查询网站类规则的 CC 防护规则 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} opts.ccProtectionRuleId - 网站类规则的 CC 防护规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param cCProtectionRule data + */ + + describeCCProtectionRuleOfWebRule ( + 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 describeCCProtectionRuleOfWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeCCProtectionRuleOfWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling describeCCProtectionRuleOfWebRule" + ) + } + if ( + opts.ccProtectionRuleId === undefined || + opts.ccProtectionRuleId === null + ) { + throw new Error( + "Missing the required parameter 'opts.ccProtectionRuleId' when calling describeCCProtectionRuleOfWebRule" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId, + ccProtectionRuleId: opts.ccProtectionRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeCCProtectionRuleOfWebRule 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}/instances/{instanceId}/webRules/{webRuleId}/ccProtectionRules/{ccProtectionRuleId}', + '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) + } + ) + } + + /** + * 修改网站类规则的 CC 防护规则 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} opts.ccProtectionRuleId - 网站类规则的 CC 防护规则 Id + * @param {cCProtectionRuleSpec} opts.ccProtectionRuleSpec - 修改 CC 防护规则请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 修改失败, 1: 修改成功 + * @param string message 修改失败时给出具体原因 + */ + + modifyCCProtectionRuleOfWebRule ( + 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 modifyCCProtectionRuleOfWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyCCProtectionRuleOfWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling modifyCCProtectionRuleOfWebRule" + ) + } + if ( + opts.ccProtectionRuleId === undefined || + opts.ccProtectionRuleId === null + ) { + throw new Error( + "Missing the required parameter 'opts.ccProtectionRuleId' when calling modifyCCProtectionRuleOfWebRule" + ) + } + if ( + opts.ccProtectionRuleSpec === undefined || + opts.ccProtectionRuleSpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.ccProtectionRuleSpec' when calling modifyCCProtectionRuleOfWebRule" + ) + } + + let postBody = {} + if ( + opts.ccProtectionRuleSpec !== undefined && + opts.ccProtectionRuleSpec !== null + ) { + postBody['ccProtectionRuleSpec'] = opts.ccProtectionRuleSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId, + ccProtectionRuleId: opts.ccProtectionRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 modifyCCProtectionRuleOfWebRule 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}/instances/{instanceId}/webRules/{webRuleId}/ccProtectionRules/{ccProtectionRuleId}', + 'PATCH', + 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) + } + ) + } + + /** + * 删除网站规则的 CC 防护规则 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} opts.ccProtectionRuleId - 网站类规则的 CC 防护规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 删除失败, 1: 删除成功 + * @param string message 删除失败时给出具体原因 + */ + + deleteCCProtectionRuleOfWebRule ( + 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 deleteCCProtectionRuleOfWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteCCProtectionRuleOfWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling deleteCCProtectionRuleOfWebRule" + ) + } + if ( + opts.ccProtectionRuleId === undefined || + opts.ccProtectionRuleId === null + ) { + throw new Error( + "Missing the required parameter 'opts.ccProtectionRuleId' when calling deleteCCProtectionRuleOfWebRule" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId, + ccProtectionRuleId: opts.ccProtectionRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 deleteCCProtectionRuleOfWebRule 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}/instances/{instanceId}/webRules/{webRuleId}/ccProtectionRules/{ccProtectionRuleId}', + '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) + } + ) + } + + /** + * 开启网站类规则的 CC 防护规则 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} opts.ccProtectionRuleId - 网站类规则的 CC 防护规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 开启失败, 1: 开启成功 + * @param string message 开启失败时给出具体原因 + */ + + enableCCProtectionRuleOfWebRule ( + 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 enableCCProtectionRuleOfWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling enableCCProtectionRuleOfWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling enableCCProtectionRuleOfWebRule" + ) + } + if ( + opts.ccProtectionRuleId === undefined || + opts.ccProtectionRuleId === null + ) { + throw new Error( + "Missing the required parameter 'opts.ccProtectionRuleId' when calling enableCCProtectionRuleOfWebRule" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId, + ccProtectionRuleId: opts.ccProtectionRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 enableCCProtectionRuleOfWebRule 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}/instances/{instanceId}/webRules/{webRuleId}/ccProtectionRules/{ccProtectionRuleId}:enable', + '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) + } + ) + } + + /** + * 关闭网站类规则的 CC 防护规则 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} opts.ccProtectionRuleId - 网站类规则的 CC 防护规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 关闭失败, 1: 关闭成功 + * @param string message 关闭失败时给出具体原因 + */ + + disableCCProtectionRuleOfWebRule ( + 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 disableCCProtectionRuleOfWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling disableCCProtectionRuleOfWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling disableCCProtectionRuleOfWebRule" + ) + } + if ( + opts.ccProtectionRuleId === undefined || + opts.ccProtectionRuleId === null + ) { + throw new Error( + "Missing the required parameter 'opts.ccProtectionRuleId' when calling disableCCProtectionRuleOfWebRule" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId, + ccProtectionRuleId: opts.ccProtectionRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 disableCCProtectionRuleOfWebRule 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}/instances/{instanceId}/webRules/{webRuleId}/ccProtectionRules/{ccProtectionRuleId}:disable', + '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) + } + ) + } + + /** + * 开启网站类规则的自定义 CC 防护规则总开关, 状态为开启的自定义 CC 防护规则生效 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 开启失败, 1: 开启成功 + * @param string message 开启失败时给出具体原因 + */ + + enableWebRuleCCProtectionRule ( + 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 enableWebRuleCCProtectionRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling enableWebRuleCCProtectionRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling enableWebRuleCCProtectionRule" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 enableWebRuleCCProtectionRule 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}/instances/{instanceId}/webRules/{webRuleId}:enableWebRuleCCProtectionRule', + '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) + } + ) + } + + /** + * 关闭网站类规则的自定义 CC 防护规则总开关, 所有自定义 CC 防护规则失效 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 关闭失败, 1: 关闭成功 + * @param string message 关闭失败时给出具体原因 + */ + + disableWebRuleCCProtectionRule ( + 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 disableWebRuleCCProtectionRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling disableWebRuleCCProtectionRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling disableWebRuleCCProtectionRule" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 disableWebRuleCCProtectionRule 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}/instances/{instanceId}/webRules/{webRuleId}:disableWebRuleCCProtectionRule', + '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) + } + ) + } + + /** + * 查询网站类规则的 CC 防护配置 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param cCProtectionConfig data + */ + + describeCCProtectionConfigOfWebRule ( + 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 describeCCProtectionConfigOfWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeCCProtectionConfigOfWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling describeCCProtectionConfigOfWebRule" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeCCProtectionConfigOfWebRule 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}/instances/{instanceId}/webRules/{webRuleId}:ccProtectionConfig', + '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) + } + ) + } + + /** + * 修改网站类规则的 CC 防护配置 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {cCProtectionConfigSpec} opts.ccProtectionConfigSpec - 修改 CC 防护配置请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 修改失败, 1: 修改成功 + * @param string message 修改失败时给出具体原因 + */ + + modifyCCProtectionConfigOfWebRule ( + 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 modifyCCProtectionConfigOfWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyCCProtectionConfigOfWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling modifyCCProtectionConfigOfWebRule" + ) + } + if ( + opts.ccProtectionConfigSpec === undefined || + opts.ccProtectionConfigSpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.ccProtectionConfigSpec' when calling modifyCCProtectionConfigOfWebRule" + ) + } + + let postBody = {} + if ( + opts.ccProtectionConfigSpec !== undefined && + opts.ccProtectionConfigSpec !== null + ) { + postBody['ccProtectionConfigSpec'] = opts.ccProtectionConfigSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 modifyCCProtectionConfigOfWebRule 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}/instances/{instanceId}/webRules/{webRuleId}:ccProtectionConfig', + 'PATCH', + 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) + } + ) + } + + /** + * 查询网站类规则的 CC 防护默认配置 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param cCProtectionDefaultConfig data + */ + + describeCCProtectionDefaultConfigOfWebRule ( + 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 describeCCProtectionDefaultConfigOfWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeCCProtectionDefaultConfigOfWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling describeCCProtectionDefaultConfigOfWebRule" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeCCProtectionDefaultConfigOfWebRule 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}/instances/{instanceId}/webRules/{webRuleId}:ccProtectionDefaultConfig', + '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} opts.webRuleId - 网站规则 Id + * @param {certInfoModifySpec} opts.certInfoModifySpec - 编辑网站规则证书信息请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 上传 SSL 证书结果, 0: 删除证书失败, 1: 删除证书成功 + * @param string message 上传成功时为证书 Id, 失败时给出具体原因 + */ + + modifyCertInfo (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 modifyCertInfo" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyCertInfo" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling modifyCertInfo" + ) + } + if ( + opts.certInfoModifySpec === undefined || + opts.certInfoModifySpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.certInfoModifySpec' when calling modifyCertInfo" + ) + } + + let postBody = {} + if ( + opts.certInfoModifySpec !== undefined && + opts.certInfoModifySpec !== null + ) { + postBody['certInfoModifySpec'] = opts.certInfoModifySpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 modifyCertInfo 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}/instances/{instanceId}/webRules/{webRuleId}:modifyCertInfo', + '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 - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer allocatedNum 已配置的黑名单规则数量 + * @param integer activeNum 开启的黑名单规则数量 + * @param integer surplusAllocateNum 还可添加的黑名单规则数量 + * @param integer maxAllocateNum 最多可添加的黑名单规则数量 + */ + + describeWebRuleBlackListUsage ( + 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 describeWebRuleBlackListUsage" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeWebRuleBlackListUsage" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling describeWebRuleBlackListUsage" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeWebRuleBlackListUsage 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}/instances/{instanceId}/webRules/{webRuleId}:describeWebRuleBlackListUsage', + '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} opts.webRuleId - 网站规则 Id + * @param {integer} [opts.pageNumber] - 页码, 默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小, 默认为10, 取值范围[10, 100] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param webBlackListRule dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 总数 + * @param integer totalPage 总页数 + */ + + describeBlackListRulesOfWebRule ( + 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 describeBlackListRulesOfWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeBlackListRulesOfWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling describeBlackListRulesOfWebRule" + ) + } + + 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, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeBlackListRulesOfWebRule 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}/instances/{instanceId}/webRules/{webRuleId}/webBlackListRules', + '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} opts.webRuleId - 网站规则 Id + * @param {webBlackListRuleSpec} opts.webBlackListRuleSpec - 添加网站类规则的黑名单规则请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 添加失败, 1: 添加成功 + * @param string message 添加失败时给出具体原因 + */ + + createBlackListRuleOfWebRule ( + 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 createBlackListRuleOfWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createBlackListRuleOfWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling createBlackListRuleOfWebRule" + ) + } + if ( + opts.webBlackListRuleSpec === undefined || + opts.webBlackListRuleSpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.webBlackListRuleSpec' when calling createBlackListRuleOfWebRule" + ) + } + + let postBody = {} + if ( + opts.webBlackListRuleSpec !== undefined && + opts.webBlackListRuleSpec !== null + ) { + postBody['webBlackListRuleSpec'] = opts.webBlackListRuleSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 createBlackListRuleOfWebRule 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}/instances/{instanceId}/webRules/{webRuleId}/webBlackListRules', + '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 - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} opts.webBlackListRuleId - 网站类规则的黑名单规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param webBlackListRule data + */ + + describeBlackListRuleOfWebRule ( + 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 describeBlackListRuleOfWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeBlackListRuleOfWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling describeBlackListRuleOfWebRule" + ) + } + if ( + opts.webBlackListRuleId === undefined || + opts.webBlackListRuleId === null + ) { + throw new Error( + "Missing the required parameter 'opts.webBlackListRuleId' when calling describeBlackListRuleOfWebRule" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId, + webBlackListRuleId: opts.webBlackListRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeBlackListRuleOfWebRule 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}/instances/{instanceId}/webRules/{webRuleId}/webBlackListRules/{webBlackListRuleId}', + '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} opts.webRuleId - 网站规则 Id + * @param {string} opts.webBlackListRuleId - 网站类规则的黑名单规则 Id + * @param {webBlackListRuleSpec} opts.webBlackListRuleSpec - 修改网站类规则的黑名单规则请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 修改结果, 0: 修改失败, 1: 修改成功 + * @param string message 修改失败时给出具体原因 + */ + + modifyBlackListRuleOfWebRule ( + 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 modifyBlackListRuleOfWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyBlackListRuleOfWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling modifyBlackListRuleOfWebRule" + ) + } + if ( + opts.webBlackListRuleId === undefined || + opts.webBlackListRuleId === null + ) { + throw new Error( + "Missing the required parameter 'opts.webBlackListRuleId' when calling modifyBlackListRuleOfWebRule" + ) + } + if ( + opts.webBlackListRuleSpec === undefined || + opts.webBlackListRuleSpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.webBlackListRuleSpec' when calling modifyBlackListRuleOfWebRule" + ) + } + + let postBody = {} + if ( + opts.webBlackListRuleSpec !== undefined && + opts.webBlackListRuleSpec !== null + ) { + postBody['webBlackListRuleSpec'] = opts.webBlackListRuleSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId, + webBlackListRuleId: opts.webBlackListRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 modifyBlackListRuleOfWebRule 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}/instances/{instanceId}/webRules/{webRuleId}/webBlackListRules/{webBlackListRuleId}', + 'PATCH', + 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) + } + ) + } + + /** + * 删除网站类规则的黑名单规则, 批量操作时 webBlackListRuleId 传多个, 以 ',' 分隔, 返回 result.code 为 1 表示操作成功, 为 0 时可能全部失败, 也可能部分失败 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} opts.webBlackListRuleId - 网站类规则的黑名单规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 删除结果, 0: 删除失败, 1: 删除成功 + * @param string message 删除失败时给出具体原因 + */ + + deleteBlackListRuleOfWebRule ( + 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 deleteBlackListRuleOfWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteBlackListRuleOfWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling deleteBlackListRuleOfWebRule" + ) + } + if ( + opts.webBlackListRuleId === undefined || + opts.webBlackListRuleId === null + ) { + throw new Error( + "Missing the required parameter 'opts.webBlackListRuleId' when calling deleteBlackListRuleOfWebRule" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId, + webBlackListRuleId: opts.webBlackListRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 deleteBlackListRuleOfWebRule 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}/instances/{instanceId}/webRules/{webRuleId}/webBlackListRules/{webBlackListRuleId}', + '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.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 开启结果, 0: 开启失败, 1: 开启成功 + * @param string message 开启失败时给出具体原因 + */ + + enableWebRuleBlackList (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 enableWebRuleBlackList" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling enableWebRuleBlackList" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling enableWebRuleBlackList" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 enableWebRuleBlackList 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}/instances/{instanceId}/webRules/{webRuleId}:enableWebRuleBlackList', + '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) + } + ) + } + + /** + * 开启网站类规则的黑名单规则, 批量操作时 webBlackListRuleId 传多个, 以 ',' 分隔, 返回 result.code 为 1 表示操作成功, 为 0 时可能全部失败, 也可能部分失败 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} opts.webBlackListRuleId - 网站类规则的黑名单规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 开启结果, 0: 开启失败, 1: 开启成功 + * @param string message 开启失败时给出具体原因 + */ + + enableBlackListRuleOfWebRule ( + 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 enableBlackListRuleOfWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling enableBlackListRuleOfWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling enableBlackListRuleOfWebRule" + ) + } + if ( + opts.webBlackListRuleId === undefined || + opts.webBlackListRuleId === null + ) { + throw new Error( + "Missing the required parameter 'opts.webBlackListRuleId' when calling enableBlackListRuleOfWebRule" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId, + webBlackListRuleId: opts.webBlackListRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 enableBlackListRuleOfWebRule 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}/instances/{instanceId}/webRules/{webRuleId}/webBlackListRules/{webBlackListRuleId}:enable', + '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 - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 关闭结果, 0: 关闭失败, 1: 关闭成功 + * @param string message 关闭失败时给出具体原因 + */ + + disableWebRuleBlackList (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 disableWebRuleBlackList" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling disableWebRuleBlackList" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling disableWebRuleBlackList" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 disableWebRuleBlackList 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}/instances/{instanceId}/webRules/{webRuleId}:disableWebRuleBlackList', + '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) + } + ) + } + + /** + * 关闭网站类规则的黑名单规则, 批量操作时 webBlackListRuleId 传多个, 以 ',' 分隔, 返回 result.code 为 1 表示操作成功, 为 0 时可能全部失败, 也可能部分失败 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} opts.webBlackListRuleId - 网站类规则的黑名单规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 关闭结果, 0: 关闭失败, 1: 关闭成功 + * @param string message 关闭失败时给出具体原因 + */ + + disableBlackListRuleOfWebRule ( + 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 disableBlackListRuleOfWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling disableBlackListRuleOfWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling disableBlackListRuleOfWebRule" + ) + } + if ( + opts.webBlackListRuleId === undefined || + opts.webBlackListRuleId === null + ) { + throw new Error( + "Missing the required parameter 'opts.webBlackListRuleId' when calling disableBlackListRuleOfWebRule" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId, + webBlackListRuleId: opts.webBlackListRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 disableBlackListRuleOfWebRule 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}/instances/{instanceId}/webRules/{webRuleId}/webBlackListRules/{webBlackListRuleId}:disable', + '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 - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer allocatedNum 已配置的白名单规则数量 + * @param integer activeNum 开启的白名单规则数量 + * @param integer surplusAllocateNum 还可添加的白名单规则数量 + * @param integer maxAllocateNum 最多可添加的白名单规则数量 + */ + + describeWebRuleWhiteListUsage ( + 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 describeWebRuleWhiteListUsage" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeWebRuleWhiteListUsage" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling describeWebRuleWhiteListUsage" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeWebRuleWhiteListUsage 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}/instances/{instanceId}/webRules/{webRuleId}:describeWebRuleWhiteListUsage', + '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} opts.webRuleId - 网站规则 Id + * @param {integer} [opts.pageNumber] - 页码, 默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小, 默认为10, 取值范围[10, 100] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param webWhiteListRule dataList + * @param integer currentCount 当前页数量 + * @param integer totalCount 总数 + * @param integer totalPage 总页数 + */ + + describeWhiteListRulesOfWebRule ( + 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 describeWhiteListRulesOfWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeWhiteListRulesOfWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling describeWhiteListRulesOfWebRule" + ) + } + + 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, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeWhiteListRulesOfWebRule 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}/instances/{instanceId}/webRules/{webRuleId}/webWhiteListRules', + '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} opts.webRuleId - 网站规则 Id + * @param {webWhiteListRuleSpec} opts.webWhiteListRuleSpec - 添加网站类规则的白名单规则请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 0: 添加失败, 1: 添加成功 + * @param string message 添加失败时给出具体原因 + */ + + createWhiteListRuleOfWebRule ( + 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 createWhiteListRuleOfWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createWhiteListRuleOfWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling createWhiteListRuleOfWebRule" + ) + } + if ( + opts.webWhiteListRuleSpec === undefined || + opts.webWhiteListRuleSpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.webWhiteListRuleSpec' when calling createWhiteListRuleOfWebRule" + ) + } + + let postBody = {} + if ( + opts.webWhiteListRuleSpec !== undefined && + opts.webWhiteListRuleSpec !== null + ) { + postBody['webWhiteListRuleSpec'] = opts.webWhiteListRuleSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 createWhiteListRuleOfWebRule 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}/instances/{instanceId}/webRules/{webRuleId}/webWhiteListRules', + '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 - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} opts.webWhiteListRuleId - 网站类规则的白名单规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param webWhiteListRule data + */ + + describeWhiteListRuleOfWebRule ( + 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 describeWhiteListRuleOfWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeWhiteListRuleOfWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling describeWhiteListRuleOfWebRule" + ) + } + if ( + opts.webWhiteListRuleId === undefined || + opts.webWhiteListRuleId === null + ) { + throw new Error( + "Missing the required parameter 'opts.webWhiteListRuleId' when calling describeWhiteListRuleOfWebRule" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId, + webWhiteListRuleId: opts.webWhiteListRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeWhiteListRuleOfWebRule 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}/instances/{instanceId}/webRules/{webRuleId}/webWhiteListRules/{webWhiteListRuleId}', + '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} opts.webRuleId - 网站规则 Id + * @param {string} opts.webWhiteListRuleId - 网站类规则的白名单规则 Id + * @param {webWhiteListRuleSpec} opts.webWhiteListRuleSpec - 修改网站类规则的白名单规则请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 修改结果, 0: 修改失败, 1: 修改成功 + * @param string message 修改失败时给出具体原因 + */ + + modifyWhiteListRuleOfWebRule ( + 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 modifyWhiteListRuleOfWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyWhiteListRuleOfWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling modifyWhiteListRuleOfWebRule" + ) + } + if ( + opts.webWhiteListRuleId === undefined || + opts.webWhiteListRuleId === null + ) { + throw new Error( + "Missing the required parameter 'opts.webWhiteListRuleId' when calling modifyWhiteListRuleOfWebRule" + ) + } + if ( + opts.webWhiteListRuleSpec === undefined || + opts.webWhiteListRuleSpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.webWhiteListRuleSpec' when calling modifyWhiteListRuleOfWebRule" + ) + } + + let postBody = {} + if ( + opts.webWhiteListRuleSpec !== undefined && + opts.webWhiteListRuleSpec !== null + ) { + postBody['webWhiteListRuleSpec'] = opts.webWhiteListRuleSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId, + webWhiteListRuleId: opts.webWhiteListRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 modifyWhiteListRuleOfWebRule 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}/instances/{instanceId}/webRules/{webRuleId}/webWhiteListRules/{webWhiteListRuleId}', + 'PATCH', + 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) + } + ) + } + + /** + * 删除网站类规则的白名单规则, 批量操作时 webWhiteListRuleId 传多个, 以 ',' 分隔, 返回 result.code 为 1 表示操作成功, 为 0 时可能全部失败, 也可能部分失败 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} opts.webWhiteListRuleId - 网站类规则的白名单规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 删除结果, 0: 删除失败, 1: 删除成功 + * @param string message 删除失败时给出具体原因 + */ + + deleteWhiteListRuleOfWebRule ( + 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 deleteWhiteListRuleOfWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteWhiteListRuleOfWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling deleteWhiteListRuleOfWebRule" + ) + } + if ( + opts.webWhiteListRuleId === undefined || + opts.webWhiteListRuleId === null + ) { + throw new Error( + "Missing the required parameter 'opts.webWhiteListRuleId' when calling deleteWhiteListRuleOfWebRule" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId, + webWhiteListRuleId: opts.webWhiteListRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 deleteWhiteListRuleOfWebRule 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}/instances/{instanceId}/webRules/{webRuleId}/webWhiteListRules/{webWhiteListRuleId}', + '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.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 开启结果, 0: 开启失败, 1: 开启成功 + * @param string message 开启失败时给出具体原因 + */ + + enableWebRuleWhiteList (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 enableWebRuleWhiteList" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling enableWebRuleWhiteList" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling enableWebRuleWhiteList" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 enableWebRuleWhiteList 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}/instances/{instanceId}/webRules/{webRuleId}:enableWebRuleWhiteList', + '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) + } + ) + } + + /** + * 开启网站类规则的白名单规则, 批量操作时 webWhiteListRuleId 传多个, 以 ',' 分隔, 返回 result.code 为 1 表示操作成功, 为 0 时可能全部失败, 也可能部分失败 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} opts.webWhiteListRuleId - 网站类规则的白名单规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 开启结果, 0: 开启失败, 1: 开启成功 + * @param string message 开启失败时给出具体原因 + */ + + enableWhiteListRuleOfWebRule ( + 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 enableWhiteListRuleOfWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling enableWhiteListRuleOfWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling enableWhiteListRuleOfWebRule" + ) + } + if ( + opts.webWhiteListRuleId === undefined || + opts.webWhiteListRuleId === null + ) { + throw new Error( + "Missing the required parameter 'opts.webWhiteListRuleId' when calling enableWhiteListRuleOfWebRule" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId, + webWhiteListRuleId: opts.webWhiteListRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 enableWhiteListRuleOfWebRule 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}/instances/{instanceId}/webRules/{webRuleId}/webWhiteListRules/{webWhiteListRuleId}:enable', + '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 - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 关闭结果, 0: 关闭失败, 1: 关闭成功 + * @param string message 关闭失败时给出具体原因 + */ + + disableWebRuleWhiteList (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 disableWebRuleWhiteList" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling disableWebRuleWhiteList" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling disableWebRuleWhiteList" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 disableWebRuleWhiteList 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}/instances/{instanceId}/webRules/{webRuleId}:disableWebRuleWhiteList', + '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) + } + ) + } + + /** + * 关闭网站类规则的白名单规则, 批量操作时 webWhiteListRuleId 传多个, 以 ',' 分隔, 返回 result.code 为 1 表示操作成功, 为 0 时可能全部失败, 也可能部分失败 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 高防实例 Id + * @param {string} opts.webRuleId - 网站规则 Id + * @param {string} opts.webWhiteListRuleId - 网站类规则的白名单规则 Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 关闭结果, 0: 关闭失败, 1: 关闭成功 + * @param string message 关闭失败时给出具体原因 + */ + + disableWhiteListRuleOfWebRule ( + 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 disableWhiteListRuleOfWebRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling disableWhiteListRuleOfWebRule" + ) + } + if (opts.webRuleId === undefined || opts.webRuleId === null) { + throw new Error( + "Missing the required parameter 'opts.webRuleId' when calling disableWhiteListRuleOfWebRule" + ) + } + if ( + opts.webWhiteListRuleId === undefined || + opts.webWhiteListRuleId === null + ) { + throw new Error( + "Missing the required parameter 'opts.webWhiteListRuleId' when calling disableWhiteListRuleOfWebRule" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + webRuleId: opts.webRuleId, + webWhiteListRuleId: opts.webWhiteListRuleId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 disableWhiteListRuleOfWebRule 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}/instances/{instanceId}/webRules/{webRuleId}/webWhiteListRules/{webWhiteListRuleId}:disable', + '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) + } + ) + } + + /** + * 查询网站类转发规则 Geo 模式的黑名单可设置区域编码 + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param country dataList + */ + + describeWebRuleBlackListGeoAreas ( + 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 describeWebRuleBlackListGeoAreas" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeWebRuleBlackListGeoAreas 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}/describeWebRuleBlackListGeoAreas', + '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) + } + ) + } + + /** + * 查询网站类转发规则 Geo 模式的白名单可设置区域编码 + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param country dataList + */ + + describeWebRuleWhiteListGeoAreas ( + 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 describeWebRuleWhiteListGeoAreas" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeWebRuleWhiteListGeoAreas 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}/describeWebRuleWhiteListGeoAreas', + '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) + } + ) + } + + /** + * 查询网站类转发规则按地域回源配置 geoRsRoute 可设置的区域 + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param country dataList + */ + + describeWebRuleRSGeoAreas (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 describeWebRuleRSGeoAreas" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ipanti/1.12.0' + } + + 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 describeWebRuleRSGeoAreas 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}/describeWebRuleRSGeoAreas', + '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 = IPANTI diff --git a/packages/libs/lib-jdcloud/src/repo/iv/v1/iv.js b/packages/libs/lib-jdcloud/src/repo/iv/v1/iv.js new file mode 100644 index 000000000..363aa17c4 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/iv/v1/iv.js @@ -0,0 +1,851 @@ +/* + * 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. + * + * Vi Template + * 视频审查模板管理相关接口 + * + * 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 = 'iv' +Service._services[serviceId] = true + +/** + * iv service. + * @version 0.0.1 + */ + +class IV extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'iv.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 提交视频审查作业 + * @param {Object} opts - parameters + * @param {string} opts.templateId - 视频审查模板ID + * @param {string} opts.region - 对象存储区域,输入和输入同区域 + * @param {string} [opts.inputBucket] - 输入空间 optional + * @param {string} [opts.inputFileKey] - 输入文件 optional + * @param {string} [opts.outputBucket] - 输入空间 optional + * @param {string} [opts.outputFilePath] - 输入路径 optional + * @param {string} callback - callback + @return {Object} result + * @param viJobSummary resultObject + */ + + submitViJob (opts, callback) { + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling submitViJob" + ) + } + if (opts.region === undefined || opts.region === null) { + throw new Error( + "Missing the required parameter 'opts.region' when calling submitViJob" + ) + } + + let postBody = {} + if (opts.templateId !== undefined && opts.templateId !== null) { + postBody['templateId'] = opts.templateId + } + if (opts.region !== undefined && opts.region !== null) { + postBody['region'] = opts.region + } + if (opts.inputBucket !== undefined && opts.inputBucket !== null) { + postBody['inputBucket'] = opts.inputBucket + } + if (opts.inputFileKey !== undefined && opts.inputFileKey !== null) { + postBody['inputFileKey'] = opts.inputFileKey + } + if (opts.outputBucket !== undefined && opts.outputBucket !== null) { + postBody['outputBucket'] = opts.outputBucket + } + if (opts.outputFilePath !== undefined && opts.outputFilePath !== null) { + postBody['outputFilePath'] = opts.outputFilePath + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iv/0.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 submitViJob 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( + '/viJobs:submit', + '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.jobId - 作业ID,路径参数 + * @param {string} callback - callback + @return {Object} result + * @param viJobSummary resultObject + */ + + getViJobSummary (opts, callback) { + opts = opts || {} + + if (opts.jobId === undefined || opts.jobId === null) { + throw new Error( + "Missing the required parameter 'opts.jobId' when calling getViJobSummary" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + jobId: opts.jobId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iv/0.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 getViJobSummary 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( + '/viJobs/{jobId}', + '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) + } + ) + } + + /** + * 查询视频审查模板列表。 +支持过滤查询: + - templateId,eq 精确匹配模板ID,非必选 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认值为 1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认值为 10;取值范围 [10, 100] optional + * @param {filter} [opts.filters] optional + * @param {string} callback - callback + @return {Object} result + * @param viTemplatePageInfo resultObject + */ + + listViTemplates (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 iv/0.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 listViTemplates 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( + '/viTemplates', + '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.templateName - 模板名称。长度不超过128个字符。UTF-8编码。 + + * @param {integer} [opts.shotInterval] - 截图间隔 optional + * @param {string} [opts.shotIntervalType] - 间隔类型:time, percent optional + * @param {string} [opts.shotFormat] - 截图格式:png, jpg optional + * @param {string} [opts.shotFrameType] - 截图帧类型:any, key optional + * @param {integer} [opts.shotWidth] - 截图宽度 optional + * @param {integer} [opts.shotHeight] - 截图高度 optional + * @param {string} [opts.shotFillType] - 截图填充类型:stretch, gauss, black, white optional + * @param {string} opts.inspectItems - 审查配置,JSON格式 + * @param {string} callback - callback + @return {Object} result + * @param viTemplateInfo resultObject + */ + + createViTemplate (opts, callback) { + opts = opts || {} + + if (opts.templateName === undefined || opts.templateName === null) { + throw new Error( + "Missing the required parameter 'opts.templateName' when calling createViTemplate" + ) + } + if (opts.inspectItems === undefined || opts.inspectItems === null) { + throw new Error( + "Missing the required parameter 'opts.inspectItems' when calling createViTemplate" + ) + } + + let postBody = {} + if (opts.templateName !== undefined && opts.templateName !== null) { + postBody['templateName'] = opts.templateName + } + if (opts.shotInterval !== undefined && opts.shotInterval !== null) { + postBody['shotInterval'] = opts.shotInterval + } + if (opts.shotIntervalType !== undefined && opts.shotIntervalType !== null) { + postBody['shotIntervalType'] = opts.shotIntervalType + } + if (opts.shotFormat !== undefined && opts.shotFormat !== null) { + postBody['shotFormat'] = opts.shotFormat + } + if (opts.shotFrameType !== undefined && opts.shotFrameType !== null) { + postBody['shotFrameType'] = opts.shotFrameType + } + if (opts.shotWidth !== undefined && opts.shotWidth !== null) { + postBody['shotWidth'] = opts.shotWidth + } + if (opts.shotHeight !== undefined && opts.shotHeight !== null) { + postBody['shotHeight'] = opts.shotHeight + } + if (opts.shotFillType !== undefined && opts.shotFillType !== null) { + postBody['shotFillType'] = opts.shotFillType + } + if (opts.inspectItems !== undefined && opts.inspectItems !== null) { + postBody['inspectItems'] = opts.inspectItems + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iv/0.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 createViTemplate 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( + '/viTemplates', + '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.templateId - 模板ID,路径参数 + * @param {string} callback - callback + @return {Object} result + * @param viTemplateInfo resultObject + */ + + getViTemplate (opts, callback) { + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling getViTemplate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iv/0.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 getViTemplate 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( + '/viTemplates/{templateId}', + '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.templateId - 模板ID,路径参数 + * @param {string} [opts.templateName] - 模板名称。长度不超过128个字符。UTF-8编码。 + optional + * @param {integer} [opts.shotInterval] - 截图间隔 optional + * @param {string} [opts.shotIntervalType] - 间隔类型:time, percent optional + * @param {string} [opts.shotFormat] - 截图格式:png, jpg optional + * @param {string} [opts.shotFrameType] - 截图帧类型:any, key optional + * @param {integer} [opts.shotWidth] - 截图宽度 optional + * @param {integer} [opts.shotHeight] - 截图高度 optional + * @param {string} [opts.shotFillType] - 截图填充类型:stretch, gauss, black, white optional + * @param {string} [opts.inspectItems] - 审查配置,JSON格式 optional + * @param {string} callback - callback + @return {Object} result + * @param viTemplateInfo resultObject + */ + + updateViTemplate (opts, callback) { + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling updateViTemplate" + ) + } + + let postBody = {} + if (opts.templateName !== undefined && opts.templateName !== null) { + postBody['templateName'] = opts.templateName + } + if (opts.shotInterval !== undefined && opts.shotInterval !== null) { + postBody['shotInterval'] = opts.shotInterval + } + if (opts.shotIntervalType !== undefined && opts.shotIntervalType !== null) { + postBody['shotIntervalType'] = opts.shotIntervalType + } + if (opts.shotFormat !== undefined && opts.shotFormat !== null) { + postBody['shotFormat'] = opts.shotFormat + } + if (opts.shotFrameType !== undefined && opts.shotFrameType !== null) { + postBody['shotFrameType'] = opts.shotFrameType + } + if (opts.shotWidth !== undefined && opts.shotWidth !== null) { + postBody['shotWidth'] = opts.shotWidth + } + if (opts.shotHeight !== undefined && opts.shotHeight !== null) { + postBody['shotHeight'] = opts.shotHeight + } + if (opts.shotFillType !== undefined && opts.shotFillType !== null) { + postBody['shotFillType'] = opts.shotFillType + } + if (opts.inspectItems !== undefined && opts.inspectItems !== null) { + postBody['inspectItems'] = opts.inspectItems + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iv/0.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 updateViTemplate 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( + '/viTemplates/{templateId}', + '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) + } + ) + } + + /** + * 删除视频审查模板 + * @param {Object} opts - parameters + * @param {string} opts.templateId - 模板ID,路径参数 + * @param {string} callback - callback + @return {Object} result + */ + + deleteViTemplate (opts, callback) { + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling deleteViTemplate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 iv/0.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 deleteViTemplate 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( + '/viTemplates/{templateId}', + '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) + } + ) + } +} +module.exports = IV diff --git a/packages/libs/lib-jdcloud/src/repo/jcq/v1/jcq.js b/packages/libs/lib-jdcloud/src/repo/jcq/v1/jcq.js new file mode 100644 index 000000000..4163d69b2 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/jcq/v1/jcq.js @@ -0,0 +1,3106 @@ +/* + * 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. + * + * Topic + * Topic相关接口 + * + * 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 = 'jcq' +Service._services[serviceId] = true + +/** + * jcq service. + * @version 1.0.2 + */ + +JDCloud.JCQ = class JCQ extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'jcq.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查看接入点接口 + * @param {Object} opts - parameters + * @param {string} opts.topicName - topic 名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param accessPoint accessPoint + */ + + describeAccessPoint (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 describeAccessPoint" + ) + } + + opts = opts || {} + + if (opts.topicName === undefined || opts.topicName === null) { + throw new Error( + "Missing the required parameter 'opts.topicName' when calling describeAccessPoint" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + topicName: opts.topicName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jcq/1.0.2' + } + + 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 describeAccessPoint 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 = this.makeRequest( + '/regions/{regionId}/topics/{topicName}/accessPoints', + '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) + } + ) + } + + /** + * consumerGroupId列表 + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string consumerGroupIds consumerGroupId列表 + */ + + describeConsumerGroupIds (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 describeConsumerGroupIds" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jcq/1.0.2' + } + + 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 describeConsumerGroupIds 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 = this.makeRequest( + '/regions/{regionId}/consumerGroupIds', + '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) + } + ) + } + + /** + * 死信消息数(按照用户或者consumerGroupId) + * @param {Object} opts - parameters + * @param {string} [opts.consumerGroupId] - consumerGroupId为空则显示该用户所有订阅关系里的死信数量 optional + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[10, 100] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param deadLetterNumber deadLetterNumbers + * @param integer totalCount 总数 + */ + + describeDeadLetterNumbers (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 describeDeadLetterNumbers" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.consumerGroupId !== undefined && opts.consumerGroupId !== null) { + queryParams['consumerGroupId'] = opts.consumerGroupId + } + 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 + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jcq/1.0.2' + } + + 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 describeDeadLetterNumbers 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 = this.makeRequest( + '/regions/{regionId}/deadLetterNumbers', + '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.topicName - topic 名称 + * @param {string} [opts.consumerGroupId] - consumerGroupId为空则显示该Topic下所有订阅关系里的死信数量 optional + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[10, 100] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param deadLetterNumber deadLetterNumbers + * @param integer totalCount 总数 + */ + + describeDeadLetterNumbersWithTopic ( + 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 describeDeadLetterNumbersWithTopic" + ) + } + + opts = opts || {} + + if (opts.topicName === undefined || opts.topicName === null) { + throw new Error( + "Missing the required parameter 'opts.topicName' when calling describeDeadLetterNumbersWithTopic" + ) + } + + let postBody = null + let queryParams = {} + if (opts.consumerGroupId !== undefined && opts.consumerGroupId !== null) { + queryParams['consumerGroupId'] = opts.consumerGroupId + } + 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, + topicName: opts.topicName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jcq/1.0.2' + } + + 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 describeDeadLetterNumbersWithTopic 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 = this.makeRequest( + '/regions/{regionId}/topics/{topicName}/deadLetterNumbers', + '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.topicName - topic 名称 + * @param {string} opts.consumerGroupId - consumerGroupId + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[10, 100] optional + * @param {string} opts.startTime - 开始时间 + * @param {string} opts.endTime - 结束时间 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param deadLetter deadLetters + * @param integer totalCount 总数 + */ + + listDeadLetters (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 listDeadLetters" + ) + } + + opts = opts || {} + + if (opts.topicName === undefined || opts.topicName === null) { + throw new Error( + "Missing the required parameter 'opts.topicName' when calling listDeadLetters" + ) + } + if (opts.consumerGroupId === undefined || opts.consumerGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.consumerGroupId' when calling listDeadLetters" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling listDeadLetters" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling listDeadLetters" + ) + } + + 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.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: regionId, + topicName: opts.topicName, + consumerGroupId: opts.consumerGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jcq/1.0.2' + } + + 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 listDeadLetters 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 = this.makeRequest( + '/regions/{regionId}/topics/{topicName}/subscriptions/{consumerGroupId}:listDeadLetters', + '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.topicName - topic 名称 + * @param {string} opts.consumerGroupId - consumerGroupId + * @param {string} [opts.messageIds] - messageIds,多个逗号隔开,不传该值就是删除所有的死信 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string messageIds 被删除的消息的id列表 + */ + + deleteDeadLetters (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 deleteDeadLetters" + ) + } + + opts = opts || {} + + if (opts.topicName === undefined || opts.topicName === null) { + throw new Error( + "Missing the required parameter 'opts.topicName' when calling deleteDeadLetters" + ) + } + if (opts.consumerGroupId === undefined || opts.consumerGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.consumerGroupId' when calling deleteDeadLetters" + ) + } + + let postBody = null + let queryParams = {} + if (opts.messageIds !== undefined && opts.messageIds !== null) { + queryParams['messageIds'] = opts.messageIds + } + + let pathParams = { + regionId: regionId, + topicName: opts.topicName, + consumerGroupId: opts.consumerGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jcq/1.0.2' + } + + 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 deleteDeadLetters 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 = this.makeRequest( + '/regions/{regionId}/topics/{topicName}/subscriptions/{consumerGroupId}:deleteDeadLetters', + '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.topicName - topic 名称 + * @param {string} opts.consumerGroupId - consumerGroupId + * @param {string} [opts.messageIds] - messageIds,多个逗号隔开,不传该值就是重发所有死信 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string messageIds 重发成功的消息id列表 + */ + + resendDeadLetters (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 resendDeadLetters" + ) + } + + opts = opts || {} + + if (opts.topicName === undefined || opts.topicName === null) { + throw new Error( + "Missing the required parameter 'opts.topicName' when calling resendDeadLetters" + ) + } + if (opts.consumerGroupId === undefined || opts.consumerGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.consumerGroupId' when calling resendDeadLetters" + ) + } + + let postBody = {} + if (opts.messageIds !== undefined && opts.messageIds !== null) { + postBody['messageIds'] = opts.messageIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + topicName: opts.topicName, + consumerGroupId: opts.consumerGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jcq/1.0.2' + } + + 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 resendDeadLetters 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 = this.makeRequest( + '/regions/{regionId}/topics/{topicName}/subscriptions/{consumerGroupId}:resendDeadLetters', + '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.topicName - topic 名称 + * @param {string} opts.startTime - 开始时间 + * @param {string} opts.endTime - 结束时间 + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[10, 100] optional + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param message messages + */ + + describeMessages (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 describeMessages" + ) + } + + opts = opts || {} + + if (opts.topicName === undefined || opts.topicName === null) { + throw new Error( + "Missing the required parameter 'opts.topicName' when calling describeMessages" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeMessages" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeMessages" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + queryParams['pageNumber'] = opts.pageNumber + } + + let pathParams = { + regionId: regionId, + topicName: opts.topicName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jcq/1.0.2' + } + + 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 describeMessages 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 = this.makeRequest( + '/regions/{regionId}/topics/{topicName}/messages', + '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) + } + ) + } + + /** + * 查询message详情 + * @param {Object} opts - parameters + * @param {string} opts.topicName - topic 名称 + * @param {string} opts.messageId - message Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param message message 消息详情 + */ + + describeMessage (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 describeMessage" + ) + } + + opts = opts || {} + + if (opts.topicName === undefined || opts.topicName === null) { + throw new Error( + "Missing the required parameter 'opts.topicName' when calling describeMessage" + ) + } + if (opts.messageId === undefined || opts.messageId === null) { + throw new Error( + "Missing the required parameter 'opts.messageId' when calling describeMessage" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + topicName: opts.topicName, + messageId: opts.messageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jcq/1.0.2' + } + + 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 describeMessage 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 = this.makeRequest( + '/regions/{regionId}/topics/{topicName}/messages/{messageId}', + '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.topicName - topic 名称 + * @param {string} opts.messageId - message Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param messageTraceInfo messageTraceInfo 消息轨迹信息 + */ + + describeMessageTrace (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 describeMessageTrace" + ) + } + + opts = opts || {} + + if (opts.topicName === undefined || opts.topicName === null) { + throw new Error( + "Missing the required parameter 'opts.topicName' when calling describeMessageTrace" + ) + } + if (opts.messageId === undefined || opts.messageId === null) { + throw new Error( + "Missing the required parameter 'opts.messageId' when calling describeMessageTrace" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + topicName: opts.topicName, + messageId: opts.messageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jcq/1.0.2' + } + + 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 describeMessageTrace 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 = this.makeRequest( + '/regions/{regionId}/topics/{topicName}/messageTrace/{messageId}', + '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) + } + ) + } + + /** + * 根据businessId查询消息 + * @param {Object} opts - parameters + * @param {string} opts.topicName - topic 名称 + * @param {string} opts.businessId - business id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param message messages + */ + + describeMessagesByBusinessId ( + 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 describeMessagesByBusinessId" + ) + } + + opts = opts || {} + + if (opts.topicName === undefined || opts.topicName === null) { + throw new Error( + "Missing the required parameter 'opts.topicName' when calling describeMessagesByBusinessId" + ) + } + if (opts.businessId === undefined || opts.businessId === null) { + throw new Error( + "Missing the required parameter 'opts.businessId' when calling describeMessagesByBusinessId" + ) + } + + let postBody = {} + if (opts.businessId !== undefined && opts.businessId !== null) { + postBody['businessId'] = opts.businessId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + topicName: opts.topicName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jcq/1.0.2' + } + + 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 describeMessagesByBusinessId 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 = this.makeRequest( + '/regions/{regionId}/topics/{topicName}/messagesWithBusinessId', + '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) + } + ) + } + + /** + * 查看当前topic授予了哪些用户哪些权限 + * @param {Object} opts - parameters + * @param {string} opts.topicName - topic 名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param permission permissions + */ + + describePermission (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 describePermission" + ) + } + + opts = opts || {} + + if (opts.topicName === undefined || opts.topicName === null) { + throw new Error( + "Missing the required parameter 'opts.topicName' when calling describePermission" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + topicName: opts.topicName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jcq/1.0.2' + } + + 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 describePermission 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 = this.makeRequest( + '/regions/{regionId}/topics/{topicName}/iam', + '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) + } + ) + } + + /** + * 对当前topic授予目标用户特定权限 + * @param {Object} opts - parameters + * @param {string} opts.topicName - topic 名称 + * @param {string} opts.permission - 权限类型,[PUB,SUB,PUBSUB] + * @param {string} opts.targetUserId - 目标用户UserId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + addPermission (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 addPermission" + ) + } + + opts = opts || {} + + if (opts.topicName === undefined || opts.topicName === null) { + throw new Error( + "Missing the required parameter 'opts.topicName' when calling addPermission" + ) + } + if (opts.permission === undefined || opts.permission === null) { + throw new Error( + "Missing the required parameter 'opts.permission' when calling addPermission" + ) + } + if (opts.targetUserId === undefined || opts.targetUserId === null) { + throw new Error( + "Missing the required parameter 'opts.targetUserId' when calling addPermission" + ) + } + + let postBody = {} + if (opts.permission !== undefined && opts.permission !== null) { + postBody['permission'] = opts.permission + } + if (opts.targetUserId !== undefined && opts.targetUserId !== null) { + postBody['targetUserId'] = opts.targetUserId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + topicName: opts.topicName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jcq/1.0.2' + } + + 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 addPermission 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 = this.makeRequest( + '/regions/{regionId}/topics/{topicName}/iam', + '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) + } + ) + } + + /** + * 删除当前topic对目标用户授权的权限 + * @param {Object} opts - parameters + * @param {string} opts.topicName - topic 名称 + * @param {string} opts.permission - 权限类型, [PUB, SUB, PUBSUB] + * @param {string} opts.targetUserId - 目标用户UserId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + removePermission (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 removePermission" + ) + } + + opts = opts || {} + + if (opts.topicName === undefined || opts.topicName === null) { + throw new Error( + "Missing the required parameter 'opts.topicName' when calling removePermission" + ) + } + if (opts.permission === undefined || opts.permission === null) { + throw new Error( + "Missing the required parameter 'opts.permission' when calling removePermission" + ) + } + if (opts.targetUserId === undefined || opts.targetUserId === null) { + throw new Error( + "Missing the required parameter 'opts.targetUserId' when calling removePermission" + ) + } + + let postBody = null + let queryParams = {} + if (opts.permission !== undefined && opts.permission !== null) { + queryParams['permission'] = opts.permission + } + if (opts.targetUserId !== undefined && opts.targetUserId !== null) { + queryParams['targetUserId'] = opts.targetUserId + } + + let pathParams = { + regionId: regionId, + topicName: opts.topicName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jcq/1.0.2' + } + + 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 removePermission 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 = this.makeRequest( + '/regions/{regionId}/topics/{topicName}/iam', + '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.topicName - topic 名称 + * @param {string} [opts.consumerGroupFilter] - consumerGroupFilter,consumerGroupId的过滤条件 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[10, 100] optional + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param subscription subscriptions + * @param integer totalCount 订阅关系的总数 + */ + + describeSubscriptions (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 describeSubscriptions" + ) + } + + opts = opts || {} + + if (opts.topicName === undefined || opts.topicName === null) { + throw new Error( + "Missing the required parameter 'opts.topicName' when calling describeSubscriptions" + ) + } + + let postBody = null + let queryParams = {} + if ( + opts.consumerGroupFilter !== undefined && + opts.consumerGroupFilter !== null + ) { + queryParams['consumerGroupFilter'] = opts.consumerGroupFilter + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + queryParams['pageNumber'] = opts.pageNumber + } + + let pathParams = { + regionId: regionId, + topicName: opts.topicName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jcq/1.0.2' + } + + 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 describeSubscriptions 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 = this.makeRequest( + '/regions/{regionId}/topics/{topicName}/subscriptions', + '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.topicName - topic 名称 + * @param {string} opts.consumerGroupId - consumerGroupId + * @param {integer} [opts.messageInvisibleTimeInSeconds] - 消息隐藏时间单位秒 optional + * @param {boolean} [opts.dlqEnable] - 是否开启死信队列[true, false] optional + * @param {integer} [opts.maxRetryTimes] - 最大重试次数dlqEnable为true必填,范围[0,16] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + createSubscription (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 createSubscription" + ) + } + + opts = opts || {} + + if (opts.topicName === undefined || opts.topicName === null) { + throw new Error( + "Missing the required parameter 'opts.topicName' when calling createSubscription" + ) + } + if (opts.consumerGroupId === undefined || opts.consumerGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.consumerGroupId' when calling createSubscription" + ) + } + + let postBody = {} + if (opts.consumerGroupId !== undefined && opts.consumerGroupId !== null) { + postBody['consumerGroupId'] = opts.consumerGroupId + } + if ( + opts.messageInvisibleTimeInSeconds !== undefined && + opts.messageInvisibleTimeInSeconds !== null + ) { + postBody['messageInvisibleTimeInSeconds'] = + opts.messageInvisibleTimeInSeconds + } + if (opts.dlqEnable !== undefined && opts.dlqEnable !== null) { + postBody['dlqEnable'] = opts.dlqEnable + } + if (opts.maxRetryTimes !== undefined && opts.maxRetryTimes !== null) { + postBody['maxRetryTimes'] = opts.maxRetryTimes + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + topicName: opts.topicName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jcq/1.0.2' + } + + 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 createSubscription 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 = this.makeRequest( + '/regions/{regionId}/topics/{topicName}/subscriptions', + '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.topicName - topic 名称 + * @param {string} opts.consumerGroupId - consumerGroupId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param subscription subscription 订阅详情 + */ + + describeSubscription (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 describeSubscription" + ) + } + + opts = opts || {} + + if (opts.topicName === undefined || opts.topicName === null) { + throw new Error( + "Missing the required parameter 'opts.topicName' when calling describeSubscription" + ) + } + if (opts.consumerGroupId === undefined || opts.consumerGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.consumerGroupId' when calling describeSubscription" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + topicName: opts.topicName, + consumerGroupId: opts.consumerGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jcq/1.0.2' + } + + 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 describeSubscription 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 = this.makeRequest( + '/regions/{regionId}/topics/{topicName}/subscriptions/{consumerGroupId}', + '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.topicName - topic 名称 + * @param {string} opts.consumerGroupId - consumerGroupId + * @param {integer} [opts.maxRetryTimes] - 最大重试次数 optional + * @param {integer} [opts.messageInvisibleTimeInSeconds] - 消息ack超时时间 optional + * @param {boolean} [opts.dlqEnable] - 是否开启死信队列[true, false] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifySubscriptionAttribute (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 modifySubscriptionAttribute" + ) + } + + opts = opts || {} + + if (opts.topicName === undefined || opts.topicName === null) { + throw new Error( + "Missing the required parameter 'opts.topicName' when calling modifySubscriptionAttribute" + ) + } + if (opts.consumerGroupId === undefined || opts.consumerGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.consumerGroupId' when calling modifySubscriptionAttribute" + ) + } + + let postBody = {} + if (opts.maxRetryTimes !== undefined && opts.maxRetryTimes !== null) { + postBody['maxRetryTimes'] = opts.maxRetryTimes + } + if ( + opts.messageInvisibleTimeInSeconds !== undefined && + opts.messageInvisibleTimeInSeconds !== null + ) { + postBody['messageInvisibleTimeInSeconds'] = + opts.messageInvisibleTimeInSeconds + } + if (opts.dlqEnable !== undefined && opts.dlqEnable !== null) { + postBody['dlqEnable'] = opts.dlqEnable + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + topicName: opts.topicName, + consumerGroupId: opts.consumerGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jcq/1.0.2' + } + + 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 modifySubscriptionAttribute 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 = this.makeRequest( + '/regions/{regionId}/topics/{topicName}/subscriptions/{consumerGroupId}', + 'PATCH', + 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.topicName - topic 名称 + * @param {string} opts.consumerGroupId - consumerGroupId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteSubscription (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 deleteSubscription" + ) + } + + opts = opts || {} + + if (opts.topicName === undefined || opts.topicName === null) { + throw new Error( + "Missing the required parameter 'opts.topicName' when calling deleteSubscription" + ) + } + if (opts.consumerGroupId === undefined || opts.consumerGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.consumerGroupId' when calling deleteSubscription" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + topicName: opts.topicName, + consumerGroupId: opts.consumerGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jcq/1.0.2' + } + + 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 deleteSubscription 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 = this.makeRequest( + '/regions/{regionId}/topics/{topicName}/subscriptions/{consumerGroupId}', + '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.topicName - topic 名称 + * @param {string} opts.consumerGroupId - consumerGroupId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + cleanMessages (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 cleanMessages" + ) + } + + opts = opts || {} + + if (opts.topicName === undefined || opts.topicName === null) { + throw new Error( + "Missing the required parameter 'opts.topicName' when calling cleanMessages" + ) + } + if (opts.consumerGroupId === undefined || opts.consumerGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.consumerGroupId' when calling cleanMessages" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + topicName: opts.topicName, + consumerGroupId: opts.consumerGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jcq/1.0.2' + } + + 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 cleanMessages 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 = this.makeRequest( + '/regions/{regionId}/topics/{topicName}/subscriptions/{consumerGroupId}:cleanMessages', + '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.topicName - topic 名称 + * @param {string} opts.consumerGroupId - consumerGroupId + * @param {string} opts.time - 时间 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + resetConsumeOffset (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 resetConsumeOffset" + ) + } + + opts = opts || {} + + if (opts.topicName === undefined || opts.topicName === null) { + throw new Error( + "Missing the required parameter 'opts.topicName' when calling resetConsumeOffset" + ) + } + if (opts.consumerGroupId === undefined || opts.consumerGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.consumerGroupId' when calling resetConsumeOffset" + ) + } + if (opts.time === undefined || opts.time === null) { + throw new Error( + "Missing the required parameter 'opts.time' when calling resetConsumeOffset" + ) + } + + let postBody = {} + if (opts.time !== undefined && opts.time !== null) { + postBody['time'] = opts.time + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + topicName: opts.topicName, + consumerGroupId: opts.consumerGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jcq/1.0.2' + } + + 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 resetConsumeOffset 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 = this.makeRequest( + '/regions/{regionId}/topics/{topicName}/subscriptions/{consumerGroupId}:resetConsumeOffset', + '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) + } + ) + } + + /** + * 查询topic列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[10, 100] optional + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {string} [opts.topicFilter] - topic名称的过滤条件,大小写不敏感 optional + * @param {tagFilter} [opts.tagFilters] - 标签过滤条件 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param topic topics + * @param integer totalCount 总数 + */ + + describeTopics (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 describeTopics" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + queryParams['pageNumber'] = opts.pageNumber + } + if (opts.topicFilter !== undefined && opts.topicFilter !== null) { + queryParams['topicFilter'] = opts.topicFilter + } + Object.assign( + queryParams, + this.buildTagFilterParam(opts.tagFilters, 'tagFilters') + ) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jcq/1.0.2' + } + + 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 describeTopics 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 = this.makeRequest( + '/regions/{regionId}/topics', + '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) + } + ) + } + + /** + * 创建一个指定名称的topic + * @param {Object} opts - parameters + * @param {string} opts.topicName - topic名称 + * @param {string} opts.type - 类型,[normal,global_order] + * @param {string} [opts.description] - 描述,长度不大于255 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + createTopic (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 createTopic" + ) + } + + opts = opts || {} + + if (opts.topicName === undefined || opts.topicName === null) { + throw new Error( + "Missing the required parameter 'opts.topicName' when calling createTopic" + ) + } + if (opts.type === undefined || opts.type === null) { + throw new Error( + "Missing the required parameter 'opts.type' when calling createTopic" + ) + } + + let postBody = {} + if (opts.topicName !== undefined && opts.topicName !== null) { + postBody['topicName'] = opts.topicName + } + if (opts.type !== undefined && opts.type !== null) { + postBody['type'] = opts.type + } + 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 jcq/1.0.2' + } + + 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 createTopic 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 = this.makeRequest( + '/regions/{regionId}/topics', + '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) + } + ) + } + + /** + * 查询topic详情 + * @param {Object} opts - parameters + * @param {string} opts.topicName - topic 名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param topic topic + */ + + describeTopic (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 describeTopic" + ) + } + + opts = opts || {} + + if (opts.topicName === undefined || opts.topicName === null) { + throw new Error( + "Missing the required parameter 'opts.topicName' when calling describeTopic" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + topicName: opts.topicName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jcq/1.0.2' + } + + 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 describeTopic 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 = this.makeRequest( + '/regions/{regionId}/topics/{topicName}', + '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) + } + ) + } + + /** + * 删除单个topic + * @param {Object} opts - parameters + * @param {string} opts.topicName - topic 名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteTopic (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 deleteTopic" + ) + } + + opts = opts || {} + + if (opts.topicName === undefined || opts.topicName === null) { + throw new Error( + "Missing the required parameter 'opts.topicName' when calling deleteTopic" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + topicName: opts.topicName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jcq/1.0.2' + } + + 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 deleteTopic 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 = this.makeRequest( + '/regions/{regionId}/topics/{topicName}', + '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) + } + ) + } +} +module.exports = JDCloud.JCQ diff --git a/packages/libs/lib-jdcloud/src/repo/jdccs/v1/jdccs.js b/packages/libs/lib-jdcloud/src/repo/jdccs/v1/jdccs.js new file mode 100644 index 000000000..5130e868a --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/jdccs/v1/jdccs.js @@ -0,0 +1,3707 @@ +/* + * 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. + * + * Ticket API + * 云托管服务的工单API + * + * 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 = 'jdccs' +Service._services[serviceId] = true + +/** + * jdccs service. + * @version 1.1.5 + */ + +class JDCCS extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'jdccs.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询报警规则列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码, 默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20 optional + * @param {string} [opts.resourceType] - 资源类型 bandwidth:带宽 optional + * @param {string} [opts.resourceId] - 资源ID,指定resourceId时须指定resourceType optional + * @param {string} [opts.idc] - 机房英文标识 optional + * @param {string} [opts.status] - 规则状态 disabled:禁用 enabled:启用 optional + * @param {filter} [opts.filters] - alarmId - 规则实施ID,精确匹配,支持多个 + optional + * @param {string} callback - callback + @return {Object} result + * @param describeAlarm alarms + * @param integer pageNumber 页码 + * @param integer pageSize 分页大小 + * @param integer totalCount 总数量 + */ + + describeAlarms (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 + } + if (opts.resourceType !== undefined && opts.resourceType !== null) { + queryParams['resourceType'] = opts.resourceType + } + if (opts.resourceId !== undefined && opts.resourceId !== null) { + queryParams['resourceId'] = opts.resourceId + } + if (opts.idc !== undefined && opts.idc !== null) { + queryParams['idc'] = opts.idc + } + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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 describeAlarms 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( + '/alarms', + '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.idc] - idc机房实例ID optional + * @param {string} [opts.resourceType] - 资源类型,bandwidth:带宽 optional + * @param {string} [opts.resourceId] - 带宽实例ID optional + * @param {string} [opts.name] - 规则名称 optional + * @param {string} [opts.metric] - 监控项,bandwidthTrafficIn:上行实时流量 bandwidthTrafficOut:下行实时流量 optional + * @param {integer} [opts.period] - 统计周期(单位:分钟) optional + * @param {string} [opts.statisticMethod] - 统计方法:平均值=avg、最大值=max、最小值=min optional + * @param {string} [opts.operator] - 计算方式 >=、>、<、<=、=、!= optional + * @param {number} [opts.threshold] - 阈值 optional + * @param {integer} [opts.times] - 连续多少次后报警 optional + * @param {integer} [opts.noticePeriod] - 通知周期 单位:小时 optional + * @param {string} [opts.status] - 规则状态 disabled:禁用 enabled:启用 optional + * @param {string} [opts.noticeMethod] - 通知方式 all:全部 sms:短信 email:邮件 optional + * @param {string} [opts.noticeObj] - 通知对象 all:全部 persons:个人 groups:角色组 optional + * @param {string} [opts.userId] - 通知对象用户ID,若多个用逗号分隔 optional + * @param {string} [opts.groupId] - 通知对象组ID optional + * @param {string} callback - callback + @return {Object} result + * @param boolean success + */ + + createAlarm (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.idc !== undefined && opts.idc !== null) { + postBody['idc'] = opts.idc + } + if (opts.resourceType !== undefined && opts.resourceType !== null) { + postBody['resourceType'] = opts.resourceType + } + if (opts.resourceId !== undefined && opts.resourceId !== null) { + postBody['resourceId'] = opts.resourceId + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.metric !== undefined && opts.metric !== null) { + postBody['metric'] = opts.metric + } + if (opts.period !== undefined && opts.period !== null) { + postBody['period'] = opts.period + } + if (opts.statisticMethod !== undefined && opts.statisticMethod !== null) { + postBody['statisticMethod'] = opts.statisticMethod + } + if (opts.operator !== undefined && opts.operator !== null) { + postBody['operator'] = opts.operator + } + if (opts.threshold !== undefined && opts.threshold !== null) { + postBody['threshold'] = opts.threshold + } + if (opts.times !== undefined && opts.times !== null) { + postBody['times'] = opts.times + } + if (opts.noticePeriod !== undefined && opts.noticePeriod !== null) { + postBody['noticePeriod'] = opts.noticePeriod + } + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + if (opts.noticeMethod !== undefined && opts.noticeMethod !== null) { + postBody['noticeMethod'] = opts.noticeMethod + } + if (opts.noticeObj !== undefined && opts.noticeObj !== null) { + postBody['noticeObj'] = opts.noticeObj + } + if (opts.userId !== undefined && opts.userId !== null) { + postBody['userId'] = opts.userId + } + if (opts.groupId !== undefined && opts.groupId !== null) { + postBody['groupId'] = opts.groupId + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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 createAlarm 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( + '/alarms', + '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.alarmId - 报警规则ID + * @param {string} callback - callback + @return {Object} result + * @param alarm alarm + */ + + describeAlarm (opts, callback) { + opts = opts || {} + + if (opts.alarmId === undefined || opts.alarmId === null) { + throw new Error( + "Missing the required parameter 'opts.alarmId' when calling describeAlarm" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + alarmId: opts.alarmId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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 describeAlarm 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( + '/alarms/{alarmId}', + '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.alarmId - 报警规则ID + * @param {string} [opts.name] - 规则名称 optional + * @param {string} [opts.metric] - 监控项,bandwidthTrafficIn:上行实时流量 bandwidthTrafficOut:下行实时流量 optional + * @param {integer} [opts.period] - 统计周期(单位:分钟) optional + * @param {string} [opts.statisticMethod] - 统计方法:平均值=avg、最大值=max、最小值=min optional + * @param {string} [opts.operator] - 计算方式 >=、>、<、<=、=、!= optional + * @param {number} [opts.threshold] - 阈值 optional + * @param {integer} [opts.times] - 连续多少次后报警 optional + * @param {integer} [opts.noticePeriod] - 通知周期 单位:小时 optional + * @param {string} [opts.status] - 规则状态 disabled:禁用 enabled:启用 optional + * @param {string} [opts.noticeMethod] - 通知方式 all:全部 sms:短信 email:邮件 optional + * @param {string} [opts.userId] - 通知对象用户ID,若多个用逗号分隔 optional + * @param {string} [opts.groupId] - 通知对象组ID optional + * @param {string} callback - callback + @return {Object} result + * @param boolean success + */ + + updateAlarm (opts, callback) { + opts = opts || {} + + if (opts.alarmId === undefined || opts.alarmId === null) { + throw new Error( + "Missing the required parameter 'opts.alarmId' when calling updateAlarm" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.metric !== undefined && opts.metric !== null) { + postBody['metric'] = opts.metric + } + if (opts.period !== undefined && opts.period !== null) { + postBody['period'] = opts.period + } + if (opts.statisticMethod !== undefined && opts.statisticMethod !== null) { + postBody['statisticMethod'] = opts.statisticMethod + } + if (opts.operator !== undefined && opts.operator !== null) { + postBody['operator'] = opts.operator + } + if (opts.threshold !== undefined && opts.threshold !== null) { + postBody['threshold'] = opts.threshold + } + if (opts.times !== undefined && opts.times !== null) { + postBody['times'] = opts.times + } + if (opts.noticePeriod !== undefined && opts.noticePeriod !== null) { + postBody['noticePeriod'] = opts.noticePeriod + } + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + if (opts.noticeMethod !== undefined && opts.noticeMethod !== null) { + postBody['noticeMethod'] = opts.noticeMethod + } + if (opts.userId !== undefined && opts.userId !== null) { + postBody['userId'] = opts.userId + } + if (opts.groupId !== undefined && opts.groupId !== null) { + postBody['groupId'] = opts.groupId + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + alarmId: opts.alarmId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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 updateAlarm 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( + '/alarms/{alarmId}', + '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) + } + ) + } + + /** + * 删除报警 + * @param {Object} opts - parameters + * @param {string} opts.alarmId - 报警规则ID + * @param {string} callback - callback + @return {Object} result + * @param boolean success + */ + + deleteAlarm (opts, callback) { + opts = opts || {} + + if (opts.alarmId === undefined || opts.alarmId === null) { + throw new Error( + "Missing the required parameter 'opts.alarmId' when calling deleteAlarm" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + alarmId: opts.alarmId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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 deleteAlarm 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( + '/alarms/{alarmId}', + '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 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20 optional + * @param {string} [opts.alarmId] - 报警规则ID optional + * @param {string} [opts.idc] - 机房英文标识 optional + * @param {integer} [opts.startTime] - 查询时间范围的开始时间, UNIX时间戳 optional + * @param {integer} [opts.endTime] - 查询时间范围的结束时间, UNIX时间戳 optional + * @param {string} callback - callback + @return {Object} result + * @param alarmHistory alarmHistory + * @param integer pageNumber 页码 + * @param integer pageSize 分页大小 + * @param integer totalCount 总数量 + */ + + describeAlarmHistory (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 + } + if (opts.alarmId !== undefined && opts.alarmId !== null) { + queryParams['alarmId'] = opts.alarmId + } + if (opts.idc !== undefined && opts.idc !== null) { + queryParams['idc'] = opts.idc + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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 describeAlarmHistory 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( + '/alarmHistory', + '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.alarmId - 报警规则ID + * @param {string} [opts.status] - 规则状态 disabled:禁用 enabled:启用 optional + * @param {string} callback - callback + @return {Object} result + * @param boolean success + */ + + switchAlarm (opts, callback) { + opts = opts || {} + + if (opts.alarmId === undefined || opts.alarmId === null) { + throw new Error( + "Missing the required parameter 'opts.alarmId' when calling switchAlarm" + ) + } + + let postBody = {} + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + alarmId: opts.alarmId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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 switchAlarm 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( + '/alarms/{alarmId}:switch', + '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) + } + ) + } + + /** + * 查询可用监控项列表 + * @param {Object} opts - parameters + * @param {string} callback - callback + @return {Object} result + * @param metric metrics + */ + + describeMetrics (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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 describeMetrics 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( + '/metrics', + '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.idc - IDC机房ID + * @param {string} opts.metric - 监控项英文标识(id) + * @param {string} opts.resourceId - 资源ID + * @param {integer} opts.startTime - 查询时间范围的开始时间, UNIX时间戳,(机柜电流最多支持最近90天数据查询、带宽流量最多支持最近30天数据查询) + * @param {integer} opts.endTime - 查询时间范围的结束时间, UNIX时间戳,(机柜电流最多支持最近90天数据查询、带宽流量最多支持最近30天数据查询) + * @param {string} [opts.timeInterval] - 时间间隔:分钟m、小时h、天d,如: 10分钟=10m、1小时=1h,3天=3d;默认5m,最小支持5m,最大90d 目前带宽上、下行流量查询,时间间隔:1m、5m,默认5m。1m时间间隔支持的最大时间范围为2小时 optional + * @param {string} [opts.ip] - 交换机IP,指定ip时须同时指定port optional + * @param {string} [opts.port] - 端口,指定port时须同时指定ip optional + * @param {string} callback - callback + @return {Object} result + * @param metricData metricData + */ + + describeMetricData (opts, callback) { + opts = opts || {} + + if (opts.idc === undefined || opts.idc === null) { + throw new Error( + "Missing the required parameter 'opts.idc' when calling describeMetricData" + ) + } + 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" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeMetricData" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeMetricData" + ) + } + + let postBody = null + let queryParams = {} + 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.ip !== undefined && opts.ip !== null) { + queryParams['ip'] = opts.ip + } + if (opts.port !== undefined && opts.port !== null) { + queryParams['port'] = opts.port + } + + let pathParams = { + regionId: 'jdcloud', + idc: opts.idc, + metric: opts.metric + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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( + '/idcs/{idc}/metrics/{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) + } + ) + } + + /** + * 查看某资源的最后一个监控数据点(目前只支持机柜电流) + * @param {Object} opts - parameters + * @param {string} opts.idc - IDC机房ID + * @param {string} opts.metric - 监控项英文标识(id) + * @param {string} opts.resourceId - 资源ID,支持多个resourceId批量查询,每个id用英文竖线分隔 + * @param {string} callback - callback + @return {Object} result + * @param lastDownsampleRespItem items + */ + + lastDownsample (opts, callback) { + opts = opts || {} + + if (opts.idc === undefined || opts.idc === null) { + throw new Error( + "Missing the required parameter 'opts.idc' when calling lastDownsample" + ) + } + if (opts.metric === undefined || opts.metric === null) { + throw new Error( + "Missing the required parameter 'opts.metric' 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.resourceId !== undefined && opts.resourceId !== null) { + queryParams['resourceId'] = opts.resourceId + } + + let pathParams = { + regionId: 'jdcloud', + idc: opts.idc, + metric: opts.metric + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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( + '/idcs/{idc}/metrics/{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) + } + ) + } + + /** + * 查询带宽(出口)流量列表 + * @param {Object} opts - parameters + * @param {string} opts.idc - IDC机房ID + * @param {integer} [opts.pageNumber] - 页码, 默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20 optional + * @param {string} [opts.bandwidthName] - 带宽(出口)名称 optional + * @param {string} callback - callback + @return {Object} result + * @param describeBandwidthTraffic bandwidthTraffics + * @param integer pageNumber 页码 + * @param integer pageSize 分页大小 + * @param integer totalCount 总数量 + */ + + describeBandwidthTraffics (opts, callback) { + opts = opts || {} + + if (opts.idc === undefined || opts.idc === null) { + throw new Error( + "Missing the required parameter 'opts.idc' when calling describeBandwidthTraffics" + ) + } + + 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.bandwidthName !== undefined && opts.bandwidthName !== null) { + queryParams['bandwidthName'] = opts.bandwidthName + } + + let pathParams = { + regionId: 'jdcloud', + idc: opts.idc + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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 describeBandwidthTraffics 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( + '/idcs/{idc}/bandwidthTraffics', + '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.idc - IDC机房ID + * @param {string} opts.bandwidthId - 带宽(出口)实例ID + * @param {string} callback - callback + @return {Object} result + * @param bandwidthTraffic bandwidthTraffic 带宽(出口)流量(资源)详情 + */ + + describeBandwidthTraffic (opts, callback) { + opts = opts || {} + + if (opts.idc === undefined || opts.idc === null) { + throw new Error( + "Missing the required parameter 'opts.idc' when calling describeBandwidthTraffic" + ) + } + if (opts.bandwidthId === undefined || opts.bandwidthId === null) { + throw new Error( + "Missing the required parameter 'opts.bandwidthId' when calling describeBandwidthTraffic" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + idc: opts.idc, + bandwidthId: opts.bandwidthId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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 describeBandwidthTraffic 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( + '/idcs/{idc}/bandwidthTraffics/{bandwidthId}', + '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网段查询流量采样数据 + * @param {Object} opts - parameters + * @param {string} opts.resourceId - 资源ID,支持多个resourceId批量查询,每个id用英文竖线分隔 + * @param {integer} opts.startTime - 查询时间范围的开始时间, UNIX时间戳,(支持查询最近30分钟数据且时间范围不超过5分钟) + * @param {integer} opts.endTime - 查询时间范围的结束时间, UNIX时间戳,(支持查询最近30分钟数据且时间范围不超过5分钟) + * @param {string} callback - callback + @return {Object} result + * @param trafficSamplingData data + */ + + describeTrafficSampling (opts, callback) { + opts = opts || {} + + if (opts.resourceId === undefined || opts.resourceId === null) { + throw new Error( + "Missing the required parameter 'opts.resourceId' when calling describeTrafficSampling" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeTrafficSampling" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeTrafficSampling" + ) + } + + let postBody = null + let queryParams = {} + 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 + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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 describeTrafficSampling 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( + '/trafficSampling', + '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} callback - callback + @return {Object} result + * @param openDevices openDevices + */ + + describeOpenDevices (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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 describeOpenDevices 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( + '/openDevices', + '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.deviceCodes] - 设备编码,支持多个deviceCode批量查询,每个id用英文竖线分隔 optional + * @param {string} opts.deviceType - 设备类型 + * @param {string} callback - callback + @return {Object} result + * @param openDevicesData data + */ + + describeOpenDevicesData (opts, callback) { + opts = opts || {} + + if (opts.deviceType === undefined || opts.deviceType === null) { + throw new Error( + "Missing the required parameter 'opts.deviceType' when calling describeOpenDevicesData" + ) + } + + let postBody = null + let queryParams = {} + if (opts.deviceCodes !== undefined && opts.deviceCodes !== null) { + queryParams['deviceCodes'] = opts.deviceCodes + } + if (opts.deviceType !== undefined && opts.deviceType !== null) { + queryParams['deviceType'] = opts.deviceType + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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 describeOpenDevicesData 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( + '/openDevicesData', + '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) + } + ) + } + + /** + * 按照时间段查询单个机柜AB路电流 + * @param {Object} opts - parameters + * @param {string} opts.idc - IDC机房ID + * @param {string} opts.resourceId - 机柜资源ID + * @param {integer} opts.startTime - 查询时间范围的开始时间, UNIX时间戳,(最多支持最近90天数据查询) + * @param {integer} opts.endTime - 查询时间范围的结束时间, UNIX时间戳,(最多支持最近90天数据查询) + * @param {string} [opts.timeInterval] - 时间间隔:分钟m、小时h、天d,如: 10分钟=10m、1小时=1h,3天=3d;默认5m,最小支持5m,最大90d 目前带宽上、下行流量查询,时间间隔:1m、5m,默认5m。时间间隔支持的最大时间范围为2小时 optional + * @param {string} callback - callback + @return {Object} result + * @param cabinetCurrentRespItem data + */ + + describeRangetimeCabinetCurrent (opts, callback) { + opts = opts || {} + + if (opts.idc === undefined || opts.idc === null) { + throw new Error( + "Missing the required parameter 'opts.idc' when calling describeRangetimeCabinetCurrent" + ) + } + if (opts.resourceId === undefined || opts.resourceId === null) { + throw new Error( + "Missing the required parameter 'opts.resourceId' when calling describeRangetimeCabinetCurrent" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeRangetimeCabinetCurrent" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeRangetimeCabinetCurrent" + ) + } + + let postBody = null + let queryParams = {} + 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 + } + + let pathParams = { + regionId: 'jdcloud', + idc: opts.idc + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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 describeRangetimeCabinetCurrent 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( + '/idcs/{idc}/rangetimeCabinetCurrent', + '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) + } + ) + } + + /** + * 查询多个机柜AB路实时电流 + * @param {Object} opts - parameters + * @param {string} opts.idc - IDC机房ID + * @param {string} opts.resourceId - 资源ID,支持多个resourceId批量查询,每个id用英文竖线分隔 + * @param {string} callback - callback + @return {Object} result + * @param cabinetCurrentRespItem data + */ + + describeRealtimeCabinetCurrent (opts, callback) { + opts = opts || {} + + if (opts.idc === undefined || opts.idc === null) { + throw new Error( + "Missing the required parameter 'opts.idc' when calling describeRealtimeCabinetCurrent" + ) + } + if (opts.resourceId === undefined || opts.resourceId === null) { + throw new Error( + "Missing the required parameter 'opts.resourceId' when calling describeRealtimeCabinetCurrent" + ) + } + + let postBody = null + let queryParams = {} + if (opts.resourceId !== undefined && opts.resourceId !== null) { + queryParams['resourceId'] = opts.resourceId + } + + let pathParams = { + regionId: 'jdcloud', + idc: opts.idc + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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 describeRealtimeCabinetCurrent 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( + '/idcs/{idc}/realtimeCabinetCurrent', + '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) + } + ) + } + + /** + * 按照时间段查询单个机柜AB路电流-原始数据 + * @param {Object} opts - parameters + * @param {string} opts.idc - IDC机房ID + * @param {string} opts.resourceId - 机柜资源ID + * @param {integer} opts.startTime - 查询时间范围的开始时间, UNIX时间戳,(最多支持最近90天数据查询) + * @param {integer} opts.endTime - 查询时间范围的结束时间, UNIX时间戳,(最多支持最近90天数据查询) + * @param {string} callback - callback + @return {Object} result + * @param object data + */ + + describeRangetimeCabinetOriCurrent (opts, callback) { + opts = opts || {} + + if (opts.idc === undefined || opts.idc === null) { + throw new Error( + "Missing the required parameter 'opts.idc' when calling describeRangetimeCabinetOriCurrent" + ) + } + if (opts.resourceId === undefined || opts.resourceId === null) { + throw new Error( + "Missing the required parameter 'opts.resourceId' when calling describeRangetimeCabinetOriCurrent" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeRangetimeCabinetOriCurrent" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeRangetimeCabinetOriCurrent" + ) + } + + let postBody = null + let queryParams = {} + 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 + } + + let pathParams = { + regionId: 'jdcloud', + idc: opts.idc + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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 describeRangetimeCabinetOriCurrent 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( + '/idcs/{idc}/rangetimeCabinetOriCurrent', + '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) + } + ) + } + + /** + * 查询IDC机房列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码, 默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20 optional + * @param {integer} [opts.all] - 是否查询全部,默认分页 optional + * @param {string} [opts.includeExternalIdc] - 是否强制包含外部机房 yes/no optional + * @param {string} callback - callback + @return {Object} result + * @param idc idcs + * @param integer pageNumber 页码 + * @param integer pageSize 分页大小 + * @param integer totalCount 总数量 + */ + + describeIdcs (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 + } + if (opts.all !== undefined && opts.all !== null) { + queryParams['all'] = opts.all + } + if ( + opts.includeExternalIdc !== undefined && + opts.includeExternalIdc !== null + ) { + queryParams['includeExternalIdc'] = opts.includeExternalIdc + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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 describeIdcs 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( + '/idcs', + '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.idc - IDC机房ID + * @param {integer} [opts.pageNumber] - 页码, 默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20 optional + * @param {integer} [opts.all] - 是否查询全部,默认分页 optional + * @param {filter} [opts.filters] - roomNo - 房间号,精确匹配,支持多个 + optional + * @param {string} callback - callback + @return {Object} result + * @param room rooms + * @param integer pageNumber 页码 + * @param integer pageSize 分页大小 + * @param integer totalCount 总数量 + */ + + describeRooms (opts, callback) { + opts = opts || {} + + if (opts.idc === undefined || opts.idc === null) { + throw new Error( + "Missing the required parameter 'opts.idc' when calling describeRooms" + ) + } + + 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.all !== undefined && opts.all !== null) { + queryParams['all'] = opts.all + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: 'jdcloud', + idc: opts.idc + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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 describeRooms 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( + '/idcs/{idc}/rooms', + '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.idc - IDC机房ID + * @param {integer} [opts.pageNumber] - 页码, 默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20 optional + * @param {string} [opts.cabinetType] - 机柜类型 formal:正式机柜 reserved:预留机柜 optional + * @param {string} [opts.cabinetOpenStatus] - 机柜开通状态 disabled:未开通 enabling:开通中 enabled:已开通 disabling:关电中 optional + * @param {string} [opts.cabinetNo] - 机柜编码 optional + * @param {filter} [opts.filters] - roomNo - 房间号,精确匹配,支持多个 +cabinetId - 机柜ID,精确匹配,支持多个 +cabinetNo - 机柜编码,精确匹配,支持多个 +cabinetOpenStatus - 机柜开通状态,精确匹配,支持多个 + optional + * @param {sort} [opts.sorts] - cabinetNo - 机柜编码 roomNo - 房间号 optional + * @param {string} callback - callback + @return {Object} result + * @param describeCabinet cabinets + * @param integer pageNumber 页码 + * @param integer pageSize 分页大小 + * @param integer totalCount 总数量 + */ + + describeCabinets (opts, callback) { + opts = opts || {} + + if (opts.idc === undefined || opts.idc === null) { + throw new Error( + "Missing the required parameter 'opts.idc' when calling describeCabinets" + ) + } + + 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.cabinetType !== undefined && opts.cabinetType !== null) { + queryParams['cabinetType'] = opts.cabinetType + } + if ( + opts.cabinetOpenStatus !== undefined && + opts.cabinetOpenStatus !== null + ) { + queryParams['cabinetOpenStatus'] = opts.cabinetOpenStatus + } + if (opts.cabinetNo !== undefined && opts.cabinetNo !== null) { + queryParams['cabinetNo'] = opts.cabinetNo + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + Object.assign(queryParams, super.buildSortParam(opts.sorts, 'sorts')) + + let pathParams = { + regionId: 'jdcloud', + idc: opts.idc + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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 describeCabinets 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( + '/idcs/{idc}/cabinets', + '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.idc - IDC机房ID + * @param {string} opts.cabinetId - 机柜实例ID + * @param {string} callback - callback + @return {Object} result + * @param cabinet cabinet + */ + + describeCabinet (opts, callback) { + opts = opts || {} + + if (opts.idc === undefined || opts.idc === null) { + throw new Error( + "Missing the required parameter 'opts.idc' when calling describeCabinet" + ) + } + if (opts.cabinetId === undefined || opts.cabinetId === null) { + throw new Error( + "Missing the required parameter 'opts.cabinetId' when calling describeCabinet" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + idc: opts.idc, + cabinetId: opts.cabinetId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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 describeCabinet 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( + '/idcs/{idc}/cabinets/{cabinetId}', + '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.idc - IDC机房ID + * @param {integer} [opts.pageNumber] - 页码, 默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20 optional + * @param {string} [opts.cabinetId] - 机柜ID optional + * @param {string} [opts.deviceType] - 设备类型 server:服务器 network:网络设备 storage:存储设备 other:其他设备 optional + * @param {string} [opts.assetStatus] - 资产状态 launched:已上架 opened:已开通 canceling:退订中 operating:操作中 modifing:变更中 optional + * @param {string} [opts.assetBelong] - 资产归属 own:自备 lease:租赁 optional + * @param {string} [opts.deviceNo] - 设备编码 optional + * @param {string} [opts.snNo] - 设备SN号 optional + * @param {filter} [opts.filters] - deviceId - 设备实例ID,精确匹配,支持多个 +snNo - 设备SN号,精确匹配,支持多个 +deviceNo - 设备编码,精确匹配,支持多个 +cabinetNo - 机柜编码,精确匹配,支持多个 + optional + * @param {sort} [opts.sorts] - deviceNo - 设备编码 cabinetNo - 机柜编码 optional + * @param {string} callback - callback + @return {Object} result + * @param describeDevice devices + * @param integer pageNumber 页码 + * @param integer pageSize 分页大小 + * @param integer totalCount 总数量 + */ + + describeDevices (opts, callback) { + opts = opts || {} + + if (opts.idc === undefined || opts.idc === null) { + throw new Error( + "Missing the required parameter 'opts.idc' when calling describeDevices" + ) + } + + 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.cabinetId !== undefined && opts.cabinetId !== null) { + queryParams['cabinetId'] = opts.cabinetId + } + if (opts.deviceType !== undefined && opts.deviceType !== null) { + queryParams['deviceType'] = opts.deviceType + } + if (opts.assetStatus !== undefined && opts.assetStatus !== null) { + queryParams['assetStatus'] = opts.assetStatus + } + if (opts.assetBelong !== undefined && opts.assetBelong !== null) { + queryParams['assetBelong'] = opts.assetBelong + } + if (opts.deviceNo !== undefined && opts.deviceNo !== null) { + queryParams['deviceNo'] = opts.deviceNo + } + if (opts.snNo !== undefined && opts.snNo !== null) { + queryParams['snNo'] = opts.snNo + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + Object.assign(queryParams, super.buildSortParam(opts.sorts, 'sorts')) + + let pathParams = { + regionId: 'jdcloud', + idc: opts.idc + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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 describeDevices 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( + '/idcs/{idc}/devices', + '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.idc - IDC机房ID + * @param {string} opts.deviceId - 设备实例ID + * @param {string} callback - callback + @return {Object} result + * @param device device + */ + + describeDevice (opts, callback) { + opts = opts || {} + + if (opts.idc === undefined || opts.idc === null) { + throw new Error( + "Missing the required parameter 'opts.idc' when calling describeDevice" + ) + } + if (opts.deviceId === undefined || opts.deviceId === null) { + throw new Error( + "Missing the required parameter 'opts.deviceId' when calling describeDevice" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + idc: opts.idc, + deviceId: opts.deviceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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 describeDevice 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( + '/idcs/{idc}/devices/{deviceId}', + '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列表 + * @param {Object} opts - parameters + * @param {string} opts.idc - IDC机房ID + * @param {integer} [opts.pageNumber] - 页码, 默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20 optional + * @param {string} [opts.lineType] - 线路类型 dynamicBGP:动态BGP thirdLineBGP:三线BGP telecom:电信单线 unicom:联通单线 mobile:移动单线 optional + * @param {string} [opts.status] - 状态 normal:正常 abnormal:异常 optional + * @param {string} [opts.cidrAddr] - IP地址段 optional + * @param {filter} [opts.filters] - ipId - 公网IP实例ID,精确匹配,支持多个 + optional + * @param {sort} [opts.sorts] - null optional + * @param {string} callback - callback + @return {Object} result + * @param ip ips + * @param integer pageNumber 页码 + * @param integer pageSize 分页大小 + * @param integer totalCount 总数量 + */ + + describeIps (opts, callback) { + opts = opts || {} + + if (opts.idc === undefined || opts.idc === null) { + throw new Error( + "Missing the required parameter 'opts.idc' when calling describeIps" + ) + } + + 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.lineType !== undefined && opts.lineType !== null) { + queryParams['lineType'] = opts.lineType + } + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + if (opts.cidrAddr !== undefined && opts.cidrAddr !== null) { + queryParams['cidrAddr'] = opts.cidrAddr + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + Object.assign(queryParams, super.buildSortParam(opts.sorts, 'sorts')) + + let pathParams = { + regionId: 'jdcloud', + idc: opts.idc + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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 describeIps 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( + '/idcs/{idc}/ips', + '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.idc - IDC机房ID + * @param {integer} [opts.pageNumber] - 页码, 默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20 optional + * @param {string} [opts.lineType] - 线路类型 dynamicBGP:动态BGP thirdLineBGP:三线BGP telecom:电信单线 unicom:联通单线 mobile:移动单线 optional + * @param {string} [opts.chargeType] - 计费方式 fixedBandwidth:固定带宽 95thPercentile:95峰值 merge95thPercentile:合并95峰值 optional + * @param {string} [opts.bandwidthName] - 带宽(出口)名称 optional + * @param {string} [opts.relatedIp] - 关联的公网IP optional + * @param {filter} [opts.filters] - bandwidthId - 带宽实例ID,精确匹配,支持多个 + optional + * @param {sort} [opts.sorts] - null optional + * @param {string} callback - callback + @return {Object} result + * @param describeBandwidth bandwidths + * @param integer pageNumber 页码 + * @param integer pageSize 分页大小 + * @param integer totalCount 总数量 + */ + + describeBandwidths (opts, callback) { + opts = opts || {} + + if (opts.idc === undefined || opts.idc === null) { + throw new Error( + "Missing the required parameter 'opts.idc' when calling describeBandwidths" + ) + } + + 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.lineType !== undefined && opts.lineType !== null) { + queryParams['lineType'] = opts.lineType + } + if (opts.chargeType !== undefined && opts.chargeType !== null) { + queryParams['chargeType'] = opts.chargeType + } + if (opts.bandwidthName !== undefined && opts.bandwidthName !== null) { + queryParams['bandwidthName'] = opts.bandwidthName + } + if (opts.relatedIp !== undefined && opts.relatedIp !== null) { + queryParams['relatedIp'] = opts.relatedIp + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + Object.assign(queryParams, super.buildSortParam(opts.sorts, 'sorts')) + + let pathParams = { + regionId: 'jdcloud', + idc: opts.idc + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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 describeBandwidths 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( + '/idcs/{idc}/bandwidths', + '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.idc - IDC机房ID + * @param {string} opts.bandwidthId - 带宽(出口)实例ID + * @param {string} callback - callback + @return {Object} result + * @param bandwidth bandwidth + */ + + describeBandwidth (opts, callback) { + opts = opts || {} + + if (opts.idc === undefined || opts.idc === null) { + throw new Error( + "Missing the required parameter 'opts.idc' when calling describeBandwidth" + ) + } + if (opts.bandwidthId === undefined || opts.bandwidthId === null) { + throw new Error( + "Missing the required parameter 'opts.bandwidthId' when calling describeBandwidth" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + idc: opts.idc, + bandwidthId: opts.bandwidthId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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 describeBandwidth 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( + '/idcs/{idc}/bandwidths/{bandwidthId}', + '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.idc - IDC机房ID + * @param {string} callback - callback + @return {Object} result + * @param cabinetOverview cabinet + * @param deviceOverview device + * @param ipOverview ip + * @param bandwidthOverview bandwidth + */ + + describeIdcOverview (opts, callback) { + opts = opts || {} + + if (opts.idc === undefined || opts.idc === null) { + throw new Error( + "Missing the required parameter 'opts.idc' when calling describeIdcOverview" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + idc: opts.idc + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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 describeIdcOverview 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( + '/idcs/{idc}/overview', + '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 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20 optional + * @param {string} [opts.type] - 工单TAB类型 pendingProcess:待我处理 pendingReview:待审核 processing:处理中 all:全部(默认) optional + * @param {string} [opts.ticketTypeName] - 工单类型 optional + * @param {string} [opts.status] - 工单状态 pendingReview:待审核 revoked:已撤销 processing:处理中 pendingVerification:待核验 pendingClose:待关单 rejected:已拒绝 completed:已完成 cancelled:已取消 draft:草稿中 optional + * @param {string} [opts.ticketNo] - 工单编号 optional + * @param {string} [opts.ticketTemplateName] - 工单名称 optional + * @param {string} [opts.description] - 描述 optional + * @param {string} [opts.startTime] - 创建开始时间,遵循ISO8601标准,使用UTC时间,格式为:yyyy-MM-ddTHH:mm:ssZ optional + * @param {string} [opts.endTime] - 创建结束时间,遵循ISO8601标准,使用UTC时间,格式为:yyyy-MM-ddTHH:mm:ssZ optional + * @param {filter} [opts.filters] - ticketNo - 工单编号,精确匹配,支持多个 + optional + * @param {sort} [opts.sorts] - createdTime - 创建时间 closedTime - 关闭时间 optional + * @param {string} callback - callback + @return {Object} result + * @param ticket tickets + * @param integer pageNumber 页码 + * @param integer pageSize 分页大小 + * @param integer totalCount 总数量 + */ + + describeTickets (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 + } + if (opts.type !== undefined && opts.type !== null) { + queryParams['type'] = opts.type + } + if (opts.ticketTypeName !== undefined && opts.ticketTypeName !== null) { + queryParams['ticketTypeName'] = opts.ticketTypeName + } + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + if (opts.ticketNo !== undefined && opts.ticketNo !== null) { + queryParams['ticketNo'] = opts.ticketNo + } + if ( + opts.ticketTemplateName !== undefined && + opts.ticketTemplateName !== null + ) { + queryParams['ticketTemplateName'] = opts.ticketTemplateName + } + if (opts.description !== undefined && opts.description !== null) { + queryParams['description'] = opts.description + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + Object.assign(queryParams, super.buildSortParam(opts.sorts, 'sorts')) + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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 describeTickets 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( + '/tickets', + '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.ticketNo - 工单编号 + * @param {string} callback - callback + @return {Object} result + * @param ticket ticket 工单详情 + */ + + describeTicket (opts, callback) { + opts = opts || {} + + if (opts.ticketNo === undefined || opts.ticketNo === null) { + throw new Error( + "Missing the required parameter 'opts.ticketNo' when calling describeTicket" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + ticketNo: opts.ticketNo + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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 describeTicket 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( + '/tickets/{ticketNo}', + '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.phone] - 提单人手机号 optional + * @param {string} [opts.email] - 提单人邮箱 optional + * @param {string} [opts.idc] - idc机房实例id optional + * @param {boolean} [opts.isExternalIdc] - 是否是商业化外部机房 optional + * @param {integer} [opts.count] - 数量 optional + * @param {string} [opts.externalIdcAddress] - 外部机房地址 optional + * @param {string} [opts.externalIdcContactPerson] - 外部机房联系人 optional + * @param {string} [opts.externalIdcContactPhone] - 外部机房联系电话 optional + * @param {string} [opts.remarks] - 描述 optional + * @param {array} [opts.attach] - 附件 optional + * @param {string} callback - callback + @return {Object} result + * @param string ticketNo + */ + + createGeneralServicesTicket (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.phone !== undefined && opts.phone !== null) { + postBody['phone'] = opts.phone + } + if (opts.email !== undefined && opts.email !== null) { + postBody['email'] = opts.email + } + if (opts.idc !== undefined && opts.idc !== null) { + postBody['idc'] = opts.idc + } + if (opts.isExternalIdc !== undefined && opts.isExternalIdc !== null) { + postBody['isExternalIdc'] = opts.isExternalIdc + } + if (opts.count !== undefined && opts.count !== null) { + postBody['count'] = opts.count + } + if ( + opts.externalIdcAddress !== undefined && + opts.externalIdcAddress !== null + ) { + postBody['externalIdcAddress'] = opts.externalIdcAddress + } + if ( + opts.externalIdcContactPerson !== undefined && + opts.externalIdcContactPerson !== null + ) { + postBody['externalIdcContactPerson'] = opts.externalIdcContactPerson + } + if ( + opts.externalIdcContactPhone !== undefined && + opts.externalIdcContactPhone !== null + ) { + postBody['externalIdcContactPhone'] = opts.externalIdcContactPhone + } + if (opts.remarks !== undefined && opts.remarks !== null) { + postBody['remarks'] = opts.remarks + } + if (opts.attach !== undefined && opts.attach !== null) { + postBody['attach'] = opts.attach + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdccs/1.1.5' + } + + 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 createGeneralServicesTicket 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( + '/generalServicesTicket', + '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 = JDCCS diff --git a/packages/libs/lib-jdcloud/src/repo/jdfusion/v1/jdfusion.js b/packages/libs/lib-jdcloud/src/repo/jdfusion/v1/jdfusion.js new file mode 100644 index 000000000..23de64e60 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/jdfusion/v1/jdfusion.js @@ -0,0 +1,13705 @@ +/* + * 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. + * + * Vpc-VserverGroup + * 与服务器组相关的接口 + * + * 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 = 'jdfusion' +Service._services[serviceId] = true + +/** + * jdfusion service. + * @version 0.3.0 + */ + +JDCloud.JDFUSION = class JDFUSION extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'jdfusion.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 获取当前用户的云注册信息 + * @param {Object} opts - parameters + * @param {string} [opts.driver] - 只获取对应driver的云信息 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param cloudInfo clouds + */ + + getCloudInfos (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 getCloudInfos" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.driver !== undefined && opts.driver !== null) { + queryParams['driver'] = opts.driver + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getCloudInfos 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 = this.makeRequest( + '/regions/{regionId}/cloud_info', + '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 {cloudInfo} opts.cloud + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param cloudInfo cloud + */ + + registCloudInfo (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 registCloudInfo" + ) + } + + opts = opts || {} + + if (opts.cloud === undefined || opts.cloud === null) { + throw new Error( + "Missing the required parameter 'opts.cloud' when calling registCloudInfo" + ) + } + + let postBody = {} + if (opts.cloud !== undefined && opts.cloud !== null) { + postBody['cloud'] = opts.cloud + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 registCloudInfo 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 = this.makeRequest( + '/regions/{regionId}/cloud_info', + '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.cloudId - 云信息ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param cloudInfo cloud + */ + + getCloudInfoById (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 getCloudInfoById" + ) + } + + opts = opts || {} + + if (opts.cloudId === undefined || opts.cloudId === null) { + throw new Error( + "Missing the required parameter 'opts.cloudId' when calling getCloudInfoById" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + cloudId: opts.cloudId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getCloudInfoById 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 = this.makeRequest( + '/regions/{regionId}/cloud_info/{cloudId}', + '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.cloudId - 云信息ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + unregistCloudInfo (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 unregistCloudInfo" + ) + } + + opts = opts || {} + + if (opts.cloudId === undefined || opts.cloudId === null) { + throw new Error( + "Missing the required parameter 'opts.cloudId' when calling unregistCloudInfo" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + cloudId: opts.cloudId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 unregistCloudInfo 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 = this.makeRequest( + '/regions/{regionId}/cloud_info/{cloudId}', + '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) + } + ) + } + + /** + * 验证指定云信息的AK、SK + * @param {Object} opts - parameters + * @param {string} opts.cloudId - 云信息ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + validCloudInfo (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 validCloudInfo" + ) + } + + opts = opts || {} + + if (opts.cloudId === undefined || opts.cloudId === null) { + throw new Error( + "Missing the required parameter 'opts.cloudId' when calling validCloudInfo" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + cloudId: opts.cloudId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 validCloudInfo 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 = this.makeRequest( + '/regions/{regionId}/cloud_info/{cloudId}/valid', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param deploymentInfo deployments + */ + + getDeployments (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 getDeployments" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getDeployments 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 = this.makeRequest( + '/regions/{regionId}/deployments', + '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 {deploymentInfo} opts.deployment - 创建deployment + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param deploymentInfo deployment + */ + + createDeployment (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 createDeployment" + ) + } + + opts = opts || {} + + if (opts.deployment === undefined || opts.deployment === null) { + throw new Error( + "Missing the required parameter 'opts.deployment' when calling createDeployment" + ) + } + + let postBody = {} + if (opts.deployment !== undefined && opts.deployment !== null) { + postBody['deployment'] = opts.deployment + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 createDeployment 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 = this.makeRequest( + '/regions/{regionId}/deployments', + '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) + } + ) + } + + /** + * 根据已有资源反向生成deployment + * @param {Object} opts - parameters + * @param {reverseDeploymentInfo} opts.reverse - 根据已有资源反向生成deployment + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param deploymentInfo deployment + */ + + reverseDeployment (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 reverseDeployment" + ) + } + + opts = opts || {} + + if (opts.reverse === undefined || opts.reverse === null) { + throw new Error( + "Missing the required parameter 'opts.reverse' when calling reverseDeployment" + ) + } + + let postBody = {} + if (opts.reverse !== undefined && opts.reverse !== null) { + postBody['reverse'] = opts.reverse + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 reverseDeployment 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 = this.makeRequest( + '/regions/{regionId}/deployments:reverse', + '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.id - Deployment ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param deploymentInfo deployment + */ + + getDeploymentsById (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 getDeploymentsById" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling getDeploymentsById" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getDeploymentsById 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 = this.makeRequest( + '/regions/{regionId}/deployments/{id}', + '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.id - Deployment ID + * @param {deploymentInfo} opts.deployment - 修改deployment + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param deploymentInfo deployment + */ + + editDeployment (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 editDeployment" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling editDeployment" + ) + } + if (opts.deployment === undefined || opts.deployment === null) { + throw new Error( + "Missing the required parameter 'opts.deployment' when calling editDeployment" + ) + } + + let postBody = {} + if (opts.deployment !== undefined && opts.deployment !== null) { + postBody['deployment'] = opts.deployment + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 editDeployment 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 = this.makeRequest( + '/regions/{regionId}/deployments/{id}', + '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) + } + ) + } + + /** + * 删除部署信息 + * @param {Object} opts - parameters + * @param {string} opts.id - Deployment ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteDeployment (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 deleteDeployment" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling deleteDeployment" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 deleteDeployment 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 = this.makeRequest( + '/regions/{regionId}/deployments/{id}', + '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.id - Deployment ID + * @param {deployment} opts.deployment - 创建deployment + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param deploymentInfo deployment + */ + + cloneDeployment (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 cloneDeployment" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling cloneDeployment" + ) + } + if (opts.deployment === undefined || opts.deployment === null) { + throw new Error( + "Missing the required parameter 'opts.deployment' when calling cloneDeployment" + ) + } + + let postBody = {} + if (opts.deployment !== undefined && opts.deployment !== null) { + postBody['deployment'] = opts.deployment + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 cloneDeployment 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 = this.makeRequest( + '/regions/{regionId}/deployments/{id}:clone', + '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) + } + ) + } + + /** + * 预部署 + * @param {Object} opts - parameters + * @param {string} opts.id - Deployment ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + dryrunDeployment (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 dryrunDeployment" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling dryrunDeployment" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 dryrunDeployment 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 = this.makeRequest( + '/regions/{regionId}/deployments/{id}:dryrun', + '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.id - Deployment ID + * @param {apply} opts.apply - 应用部署 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param deploymentInfo deployment + */ + + applyDeployment (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 applyDeployment" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling applyDeployment" + ) + } + if (opts.apply === undefined || opts.apply === null) { + throw new Error( + "Missing the required parameter 'opts.apply' when calling applyDeployment" + ) + } + + let postBody = {} + if (opts.apply !== undefined && opts.apply !== null) { + postBody['apply'] = opts.apply + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 applyDeployment 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 = this.makeRequest( + '/regions/{regionId}/deployments/{id}:apply', + '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.id - deployment ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param taskInfo task + */ + + getDeploymentResult (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 getDeploymentResult" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling getDeploymentResult" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getDeploymentResult 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 = this.makeRequest( + '/regions/{regionId}/deployments/{id}/result', + '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.id - Deployment ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param deploymentApplyInfo versions + */ + + getDeploymentVersions (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 getDeploymentVersions" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling getDeploymentVersions" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getDeploymentVersions 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 = this.makeRequest( + '/regions/{regionId}/deployments/{id}/versions', + '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.id - deployment ID + * @param {string} opts.version_id - application ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param deploymentInfo deployment + */ + + getDeploymentsVersion (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 getDeploymentsVersion" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling getDeploymentsVersion" + ) + } + if (opts.version_id === undefined || opts.version_id === null) { + throw new Error( + "Missing the required parameter 'opts.version_id' when calling getDeploymentsVersion" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id, + version_id: opts.version_id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getDeploymentsVersion 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 = this.makeRequest( + '/regions/{regionId}/deployments/{id}/versions/{version_id}', + '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.id - deployment ID + * @param {string} opts.version_id - application ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param deploymentInfo deployment + */ + + rollbackDeploymentsVersion (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 rollbackDeploymentsVersion" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling rollbackDeploymentsVersion" + ) + } + if (opts.version_id === undefined || opts.version_id === null) { + throw new Error( + "Missing the required parameter 'opts.version_id' when calling rollbackDeploymentsVersion" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id, + version_id: opts.version_id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 rollbackDeploymentsVersion 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 = this.makeRequest( + '/regions/{regionId}/deployments/{id}/versions/{version_id}:rollback', + '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) + } + ) + } + + /** + * 查询某一次的历史执行结果(内部使用) + * @param {Object} opts - parameters + * @param {string} opts.id - deployment ID + * @param {string} opts.record - deployment ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param taskInfo task + */ + + getDeploymentsResultsByIdRecord ( + 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 getDeploymentsResultsByIdRecord" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling getDeploymentsResultsByIdRecord" + ) + } + if (opts.record === undefined || opts.record === null) { + throw new Error( + "Missing the required parameter 'opts.record' when calling getDeploymentsResultsByIdRecord" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id, + record: opts.record + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getDeploymentsResultsByIdRecord 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 = this.makeRequest( + '/regions/{regionId}/deployments/{id}/results/{record}', + '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.vmId] - 云主机id optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param cloudDataDisk disks + */ + + getDisks (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 getDisks" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.vmId !== undefined && opts.vmId !== null) { + queryParams['vmId'] = opts.vmId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getDisks 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 = this.makeRequest( + '/regions/{regionId}/disk_disks', + '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 {createDataDisk} opts.disk - 创建云硬盘 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param resourceTFInfo task + */ + + createDisk (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 createDisk" + ) + } + + opts = opts || {} + + if (opts.disk === undefined || opts.disk === null) { + throw new Error( + "Missing the required parameter 'opts.disk' when calling createDisk" + ) + } + + let postBody = {} + if (opts.disk !== undefined && opts.disk !== null) { + postBody['disk'] = opts.disk + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 createDisk 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 = this.makeRequest( + '/regions/{regionId}/disk_disks', + '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.id - 云硬盘 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param cloudDataDisk disk + */ + + getDiskById (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 getDiskById" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling getDiskById" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getDiskById 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 = this.makeRequest( + '/regions/{regionId}/disk_disks/{id}', + '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.id - 云硬盘 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + removeDiskById (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 removeDiskById" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling removeDiskById" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 removeDiskById 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 = this.makeRequest( + '/regions/{regionId}/disk_disks/{id}', + '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.id - 云硬盘 ID + * @param {attachDataDisk} opts.attach - 云硬盘挂载至虚拟机 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param resourceTFInfo task + */ + + attachDiskToVmInstanceByDiskId ( + 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 attachDiskToVmInstanceByDiskId" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling attachDiskToVmInstanceByDiskId" + ) + } + if (opts.attach === undefined || opts.attach === null) { + throw new Error( + "Missing the required parameter 'opts.attach' when calling attachDiskToVmInstanceByDiskId" + ) + } + + let postBody = {} + if (opts.attach !== undefined && opts.attach !== null) { + postBody['attach'] = opts.attach + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 attachDiskToVmInstanceByDiskId 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 = this.makeRequest( + '/regions/{regionId}/disk_disks/{id}:attach', + '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) + } + ) + } + + /** + * 从虚拟机卸载云硬盘 + * @param {Object} opts - parameters + * @param {string} opts.id - 云硬盘 ID + * @param {detachDataDisk} opts.detach - 从虚拟机卸载云硬盘 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + detachDiskToVmInstanceByDiskId ( + 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 detachDiskToVmInstanceByDiskId" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling detachDiskToVmInstanceByDiskId" + ) + } + if (opts.detach === undefined || opts.detach === null) { + throw new Error( + "Missing the required parameter 'opts.detach' when calling detachDiskToVmInstanceByDiskId" + ) + } + + let postBody = {} + if (opts.detach !== undefined && opts.detach !== null) { + postBody['detach'] = opts.detach + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 detachDiskToVmInstanceByDiskId 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 = this.makeRequest( + '/regions/{regionId}/disk_disks/{id}:detach', + '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) + } + ) + } + + /** + * 根据云提供商查询对应的OSS存储桶列表 + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param ossBucketInfo buckets + */ + + getBuckets (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 getBuckets" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getBuckets 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 = this.makeRequest( + '/regions/{regionId}/oss_buckets', + '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) + } + ) + } + + /** + * 根据给定的信息,创建OSS存储桶 + * @param {Object} opts - parameters + * @param {createOSSBucket} opts.bucket - 创建OSS存储桶 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param resourceTFInfo task + */ + + createBucket (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 createBucket" + ) + } + + opts = opts || {} + + if (opts.bucket === undefined || opts.bucket === null) { + throw new Error( + "Missing the required parameter 'opts.bucket' when calling createBucket" + ) + } + + let postBody = {} + if (opts.bucket !== undefined && opts.bucket !== null) { + postBody['bucket'] = opts.bucket + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 createBucket 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 = this.makeRequest( + '/regions/{regionId}/oss_buckets', + '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) + } + ) + } + + /** + * 根据云提供商查询对应的OSS存储桶信息 + * @param {Object} opts - parameters + * @param {string} opts.name - OSS存储桶名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param ossBucketDetailInfo bucket + */ + + getBucketByName (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 getBucketByName" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling getBucketByName" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + name: opts.name + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getBucketByName 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 = this.makeRequest( + '/regions/{regionId}/oss_buckets/{name}', + '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) + } + ) + } + + /** + * 删除指定ID的OSS存储桶信息 + * @param {Object} opts - parameters + * @param {string} opts.name - OSS存储桶名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteBucket (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 deleteBucket" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling deleteBucket" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + name: opts.name + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 deleteBucket 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 = this.makeRequest( + '/regions/{regionId}/oss_buckets/{name}', + '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) + } + ) + } + + /** + * 根据过滤条件,取得指定OSS存储桶上的文件列表 + * @param {Object} opts - parameters + * @param {string} opts.name - OSS存储桶名称 + * @param {string} [opts.marker] - 本次查询的起点(文件key值) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean isTruncated 是否已被截断(表示没有更多数据了) + * @param string marker 本次查询的起点(文件key值) + * @param ossFileInfo files + */ + + getBucketFiles (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 getBucketFiles" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling getBucketFiles" + ) + } + + let postBody = null + let queryParams = {} + if (opts.marker !== undefined && opts.marker !== null) { + queryParams['marker'] = opts.marker + } + + let pathParams = { + regionId: regionId, + name: opts.name + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getBucketFiles 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 = this.makeRequest( + '/regions/{regionId}/oss_buckets/{name}/files', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param transferTaskInfoWithID tasks + */ + + getTransferTasks (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 getTransferTasks" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getTransferTasks 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 = this.makeRequest( + '/regions/{regionId}/oss_transferTasks', + '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 {transferSimpleTaskInfo} [opts.task] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param transferTaskInfoWithID task + */ + + createTransferTask (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 createTransferTask" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.task !== undefined && opts.task !== null) { + postBody['task'] = opts.task + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 createTransferTask 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 = this.makeRequest( + '/regions/{regionId}/oss_transferTasks_simple', + '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) + } + ) + } + + /** + * 根据指定ID获取任务信息 + * @param {Object} opts - parameters + * @param {string} opts.id - 用户ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param transferTaskInfoWithID task + */ + + getTransferTaskById (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 getTransferTaskById" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling getTransferTaskById" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getTransferTaskById 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 = this.makeRequest( + '/regions/{regionId}/oss_transferTasks/{id}', + '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) + } + ) + } + + /** + * 根据指定ID修改任务 + * @param {Object} opts - parameters + * @param {string} opts.id - 任务ID + * @param {transferTaskInfo} [opts.task] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + editTransferTask (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 editTransferTask" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling editTransferTask" + ) + } + + let postBody = {} + if (opts.task !== undefined && opts.task !== null) { + postBody['task'] = opts.task + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 editTransferTask 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 = this.makeRequest( + '/regions/{regionId}/oss_transferTasks/{id}', + '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) + } + ) + } + + /** + * 根据指定ID删除任务 + * @param {Object} opts - parameters + * @param {string} opts.id - 任务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteTransferTask (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 deleteTransferTask" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling deleteTransferTask" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 deleteTransferTask 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 = this.makeRequest( + '/regions/{regionId}/oss_transferTasks/{id}', + '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) + } + ) + } + + /** + * 根据指定ID启动任务 + * @param {Object} opts - parameters + * @param {string} opts.id - 用户ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + startTransferTask (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 startTransferTask" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling startTransferTask" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 startTransferTask 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 = this.makeRequest( + '/regions/{regionId}/oss_transferTasks/{id}:start', + '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) + } + ) + } + + /** + * 根据指定ID停止任务 + * @param {Object} opts - parameters + * @param {string} opts.id - 用户ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + stopTransferTask (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 stopTransferTask" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling stopTransferTask" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 stopTransferTask 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 = this.makeRequest( + '/regions/{regionId}/oss_transferTasks/{id}:stop', + '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) + } + ) + } + + /** + * 根据指定任务id查询迁移进度 + * @param {Object} opts - parameters + * @param {string} opts.id - 任务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param transferTaskProgressInfo task + */ + + getTransferTaskProgress (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 getTransferTaskProgress" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling getTransferTaskProgress" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getTransferTaskProgress 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 = this.makeRequest( + '/regions/{regionId}/oss_transferTasks/{id}/progress', + '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) + } + ) + } + + /** + * 根据指定任务id查询迁移失败文件列表 + * @param {Object} opts - parameters + * @param {string} opts.id - 任务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param transferTaskFailedDetailInfo task + */ + + getTransferTaskFailedFiles (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 getTransferTaskFailedFiles" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling getTransferTaskFailedFiles" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getTransferTaskFailedFiles 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 = this.makeRequest( + '/regions/{regionId}/oss_transferTasks/{id}/failed-files', + '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.instId - RDS实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param rdsAccountInfo accounts + */ + + getRdsAccountsByInstId (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 getRdsAccountsByInstId" + ) + } + + opts = opts || {} + + if (opts.instId === undefined || opts.instId === null) { + throw new Error( + "Missing the required parameter 'opts.instId' when calling getRdsAccountsByInstId" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instId: opts.instId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getRdsAccountsByInstId 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 = this.makeRequest( + '/regions/{regionId}/rds_instances/{instId}/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实例的账户 + * @param {Object} opts - parameters + * @param {string} opts.instId - RDS实例ID + * @param {createRDSAccount} opts.account - 创建RDS实例的账号信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param resourceTFInfo task + */ + + createRdsAccounts (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 createRdsAccounts" + ) + } + + opts = opts || {} + + if (opts.instId === undefined || opts.instId === null) { + throw new Error( + "Missing the required parameter 'opts.instId' when calling createRdsAccounts" + ) + } + if (opts.account === undefined || opts.account === null) { + throw new Error( + "Missing the required parameter 'opts.account' when calling createRdsAccounts" + ) + } + + let postBody = {} + if (opts.account !== undefined && opts.account !== null) { + postBody['account'] = opts.account + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instId: opts.instId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 createRdsAccounts 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 = this.makeRequest( + '/regions/{regionId}/rds_instances/{instId}/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.instId - RDS实例ID + * @param {string} opts.accountName - 账号名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param rdsAccountInfo account + */ + + getRdsAccountsByInstIdAndAccountName ( + 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 getRdsAccountsByInstIdAndAccountName" + ) + } + + opts = opts || {} + + if (opts.instId === undefined || opts.instId === null) { + throw new Error( + "Missing the required parameter 'opts.instId' when calling getRdsAccountsByInstIdAndAccountName" + ) + } + if (opts.accountName === undefined || opts.accountName === null) { + throw new Error( + "Missing the required parameter 'opts.accountName' when calling getRdsAccountsByInstIdAndAccountName" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instId: opts.instId, + accountName: opts.accountName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getRdsAccountsByInstIdAndAccountName 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 = this.makeRequest( + '/regions/{regionId}/rds_instances/{instId}/accounts/{accountName}', + '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.instId - RDS实例ID + * @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.instId === undefined || opts.instId === null) { + throw new Error( + "Missing the required parameter 'opts.instId' 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, + instId: opts.instId, + accountName: opts.accountName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 = this.makeRequest( + '/regions/{regionId}/rds_instances/{instId}/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) + } + ) + } + + /** + * 给RDS账号分配数据库权限 + * @param {Object} opts - parameters + * @param {string} opts.instId - RDS实例ID + * @param {string} opts.accountName - 账号名称 + * @param {dbPrivilegeInfo} opts.dbPrivilegeInfo - RDS账号对数据库的权限信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + grantRdsAccount (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 grantRdsAccount" + ) + } + + opts = opts || {} + + if (opts.instId === undefined || opts.instId === null) { + throw new Error( + "Missing the required parameter 'opts.instId' when calling grantRdsAccount" + ) + } + if (opts.accountName === undefined || opts.accountName === null) { + throw new Error( + "Missing the required parameter 'opts.accountName' when calling grantRdsAccount" + ) + } + if (opts.dbPrivilegeInfo === undefined || opts.dbPrivilegeInfo === null) { + throw new Error( + "Missing the required parameter 'opts.dbPrivilegeInfo' when calling grantRdsAccount" + ) + } + + let postBody = {} + if (opts.dbPrivilegeInfo !== undefined && opts.dbPrivilegeInfo !== null) { + postBody['dbPrivilegeInfo'] = opts.dbPrivilegeInfo + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instId: opts.instId, + accountName: opts.accountName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 grantRdsAccount 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 = this.makeRequest( + '/regions/{regionId}/rds_instances/{instId}/accounts/{accountName}:grant', + '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.instId - RDS实例ID + * @param {string} opts.accountName - 账号名称 + * @param {string} opts.dbName - 数据库名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + revokeRdsAccount (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 revokeRdsAccount" + ) + } + + opts = opts || {} + + if (opts.instId === undefined || opts.instId === null) { + throw new Error( + "Missing the required parameter 'opts.instId' when calling revokeRdsAccount" + ) + } + if (opts.accountName === undefined || opts.accountName === null) { + throw new Error( + "Missing the required parameter 'opts.accountName' when calling revokeRdsAccount" + ) + } + if (opts.dbName === undefined || opts.dbName === null) { + throw new Error( + "Missing the required parameter 'opts.dbName' when calling revokeRdsAccount" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instId: opts.instId, + accountName: opts.accountName, + dbName: opts.dbName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 revokeRdsAccount 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 = this.makeRequest( + '/regions/{regionId}/rds_instances/{instId}/accounts/{accountName}/databases/{dbName}:revoke', + '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) + } + ) + } + + /** + * 通过异步任务,给RDS账号分配数据库权限 + * @param {Object} opts - parameters + * @param {string} opts.instId - RDS实例ID + * @param {string} opts.accountName - 账号名称 + * @param {dbPrivilegeInfo} opts.info - RDS账号对数据库的权限信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param resourceTFInfo cloud + */ + + grantRdsAccountsByTask (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 grantRdsAccountsByTask" + ) + } + + opts = opts || {} + + if (opts.instId === undefined || opts.instId === null) { + throw new Error( + "Missing the required parameter 'opts.instId' when calling grantRdsAccountsByTask" + ) + } + if (opts.accountName === undefined || opts.accountName === null) { + throw new Error( + "Missing the required parameter 'opts.accountName' when calling grantRdsAccountsByTask" + ) + } + if (opts.info === undefined || opts.info === null) { + throw new Error( + "Missing the required parameter 'opts.info' when calling grantRdsAccountsByTask" + ) + } + + let postBody = {} + if (opts.info !== undefined && opts.info !== null) { + postBody['info'] = opts.info + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instId: opts.instId, + accountName: opts.accountName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 grantRdsAccountsByTask 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 = this.makeRequest( + '/regions/{regionId}/rds_instances/{instId}/accounts/{accountName}:grantByTask', + '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.instId - RDS实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param rdsDBInfo dbs + */ + + getRdsDatabasesByInstId (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 getRdsDatabasesByInstId" + ) + } + + opts = opts || {} + + if (opts.instId === undefined || opts.instId === null) { + throw new Error( + "Missing the required parameter 'opts.instId' when calling getRdsDatabasesByInstId" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instId: opts.instId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getRdsDatabasesByInstId 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 = this.makeRequest( + '/regions/{regionId}/rds_instances/{instId}/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.instId - RDS实例ID + * @param {createRDSDB} opts.database - 创建RDS实例的数据库信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param resourceTFInfo task + */ + + 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.instId === undefined || opts.instId === null) { + throw new Error( + "Missing the required parameter 'opts.instId' when calling createRdsDatabase" + ) + } + if (opts.database === undefined || opts.database === null) { + throw new Error( + "Missing the required parameter 'opts.database' when calling createRdsDatabase" + ) + } + + let postBody = {} + if (opts.database !== undefined && opts.database !== null) { + postBody['database'] = opts.database + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instId: opts.instId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 = this.makeRequest( + '/regions/{regionId}/rds_instances/{instId}/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实例上的数据库信息 + * @param {Object} opts - parameters + * @param {string} opts.instId - RDS实例ID + * @param {string} opts.dbName - 数据库名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param rdsDBInfo db + */ + + getRdsDatabaseByInstIdAndDbName ( + 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 getRdsDatabaseByInstIdAndDbName" + ) + } + + opts = opts || {} + + if (opts.instId === undefined || opts.instId === null) { + throw new Error( + "Missing the required parameter 'opts.instId' when calling getRdsDatabaseByInstIdAndDbName" + ) + } + if (opts.dbName === undefined || opts.dbName === null) { + throw new Error( + "Missing the required parameter 'opts.dbName' when calling getRdsDatabaseByInstIdAndDbName" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instId: opts.instId, + dbName: opts.dbName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getRdsDatabaseByInstIdAndDbName 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 = this.makeRequest( + '/regions/{regionId}/rds_instances/{instId}/databases/{dbName}', + '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.instId - RDS实例ID + * @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.instId === undefined || opts.instId === null) { + throw new Error( + "Missing the required parameter 'opts.instId' 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, + instId: opts.instId, + dbName: opts.dbName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 = this.makeRequest( + '/regions/{regionId}/rds_instances/{instId}/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) + } + ) + } + + /** + * 根据云提供商查询对应的RDS实例信息 + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param rdsInstanceDetailInfo instances + */ + + getRdsInstances (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 getRdsInstances" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getRdsInstances 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 = this.makeRequest( + '/regions/{regionId}/rds_instances', + '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 {createRDSInstance} opts.instance - 创建RDS实例 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param resourceTFInfo task + */ + + createRdsInstance (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 createRdsInstance" + ) + } + + opts = opts || {} + + if (opts.instance === undefined || opts.instance === null) { + throw new Error( + "Missing the required parameter 'opts.instance' when calling createRdsInstance" + ) + } + + let postBody = {} + if (opts.instance !== undefined && opts.instance !== null) { + postBody['instance'] = opts.instance + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 createRdsInstance 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 = this.makeRequest( + '/regions/{regionId}/rds_instances', + '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) + } + ) + } + + /** + * 查询指定ID的RDS实例信息 + * @param {Object} opts - parameters + * @param {string} opts.instId - RDS实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param rdsInstanceDetailInfo instance + */ + + getRdsByInstId (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 getRdsByInstId" + ) + } + + opts = opts || {} + + if (opts.instId === undefined || opts.instId === null) { + throw new Error( + "Missing the required parameter 'opts.instId' when calling getRdsByInstId" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instId: opts.instId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getRdsByInstId 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 = this.makeRequest( + '/regions/{regionId}/rds_instances/{instId}', + '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) + } + ) + } + + /** + * 删除指定ID的RDS实例信息 + * @param {Object} opts - parameters + * @param {string} opts.instId - RDS实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteRdsByInstId (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 deleteRdsByInstId" + ) + } + + opts = opts || {} + + if (opts.instId === undefined || opts.instId === null) { + throw new Error( + "Missing the required parameter 'opts.instId' when calling deleteRdsByInstId" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instId: opts.instId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 deleteRdsByInstId 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 = this.makeRequest( + '/regions/{regionId}/rds_instances/{instId}', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param channelInfo channels + */ + + getChannels (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 getChannels" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getChannels 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 = this.makeRequest( + '/regions/{regionId}/migration_mysqlChannels', + '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 {channelInfo} opts.channel - 创建channel + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param channelInfo channel + */ + + createChannel (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 createChannel" + ) + } + + opts = opts || {} + + if (opts.channel === undefined || opts.channel === null) { + throw new Error( + "Missing the required parameter 'opts.channel' when calling createChannel" + ) + } + + let postBody = {} + if (opts.channel !== undefined && opts.channel !== null) { + postBody['channel'] = opts.channel + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 createChannel 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 = this.makeRequest( + '/regions/{regionId}/migration_mysqlChannels', + '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) + } + ) + } + + /** + * 删除channel + * @param {Object} opts - parameters + * @param {string} opts.id - channel ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteChannel (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 deleteChannel" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling deleteChannel" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 deleteChannel 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 = this.makeRequest( + '/regions/{regionId}/migration_mysqlChannels/{id}', + '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.id - channel ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + startChannel (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 startChannel" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling startChannel" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 startChannel 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 = this.makeRequest( + '/regions/{regionId}/migration_mysqlChannels/{id}:start', + '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) + } + ) + } + + /** + * 停止数据同步 + * @param {Object} opts - parameters + * @param {string} opts.id - channel ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + stopChannel (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 stopChannel" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling stopChannel" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 stopChannel 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 = this.makeRequest( + '/regions/{regionId}/migration_mysqlChannels/{id}:stop', + '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) + } + ) + } + + /** + * 查询数据源 + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param datasourceInfo datasources + */ + + getDatasources (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 getDatasources" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getDatasources 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 = this.makeRequest( + '/regions/{regionId}/migration_mysqlDatasources', + '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 {datasourceInfo} opts.datasource - 创建数据源 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param datasourceInfo datasource + */ + + createDatasource (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 createDatasource" + ) + } + + opts = opts || {} + + if (opts.datasource === undefined || opts.datasource === null) { + throw new Error( + "Missing the required parameter 'opts.datasource' when calling createDatasource" + ) + } + + let postBody = {} + if (opts.datasource !== undefined && opts.datasource !== null) { + postBody['datasource'] = opts.datasource + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 createDatasource 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 = this.makeRequest( + '/regions/{regionId}/migration_mysqlDatasources', + '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.id - channel ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteDatasource (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 deleteDatasource" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling deleteDatasource" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 deleteDatasource 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 = this.makeRequest( + '/regions/{regionId}/migration_mysqlDatasources/{id}', + '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) + } + ) + } + + /** + * 根据数据库类型,取得RDS实例的规格 + * @param {Object} opts - parameters + * @param {string} opts.engine - RDS数据库引擎,目前只支持mysql + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param rdsSpecification specifications + */ + + getRdsSpecification (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 getRdsSpecification" + ) + } + + opts = opts || {} + + if (opts.engine === undefined || opts.engine === null) { + throw new Error( + "Missing the required parameter 'opts.engine' when calling getRdsSpecification" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + engine: opts.engine + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getRdsSpecification 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 = this.makeRequest( + '/regions/{regionId}/rds_specification/{engine}', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param regionInfo regions + */ + + getRegions (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 getRegions" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getRegions 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 = this.makeRequest( + '/regions/{regionId}/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) + } + ) + } + + /** + * 查询可用域列表信息 + * @param {Object} opts - parameters + * @param {string} opts.region - 区域id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param azInfo azs + */ + + getRegionsAvailableZones (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 getRegionsAvailableZones" + ) + } + + opts = opts || {} + + if (opts.region === undefined || opts.region === null) { + throw new Error( + "Missing the required parameter 'opts.region' when calling getRegionsAvailableZones" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + region: opts.region + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getRegionsAvailableZones 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 = this.makeRequest( + '/regions/{regionId}/regions_availableZones/{region}', + '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) + } + ) + } + + /** + * 读取指定ID的运行结果和运行状态 + * @param {Object} opts - parameters + * @param {string} opts.task - 执行请求 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param taskInfo tasks + */ + + getTaskInfoHistoryById (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 getTaskInfoHistoryById" + ) + } + + opts = opts || {} + + if (opts.task === undefined || opts.task === null) { + throw new Error( + "Missing the required parameter 'opts.task' when calling getTaskInfoHistoryById" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + task: opts.task + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getTaskInfoHistoryById 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 = this.makeRequest( + '/regions/{regionId}/task_infos/{task}/history', + '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) + } + ) + } + + /** + * 读取指定ID的运行结果和运行状态 + * @param {Object} opts - parameters + * @param {string} opts.task - 执行请求 ID + * @param {string} [opts.fileName] - 执行文件名称 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param taskInfo task + */ + + getTaskInfoById (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 getTaskInfoById" + ) + } + + opts = opts || {} + + if (opts.task === undefined || opts.task === null) { + throw new Error( + "Missing the required parameter 'opts.task' when calling getTaskInfoById" + ) + } + + let postBody = null + let queryParams = {} + if (opts.fileName !== undefined && opts.fileName !== null) { + queryParams['fileName'] = opts.fileName + } + + let pathParams = { + regionId: regionId, + task: opts.task + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getTaskInfoById 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 = this.makeRequest( + '/regions/{regionId}/task_infos/{task}', + '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.imageSource] - 镜像来源: system:系统官方公共镜像。 self:用户自定义镜像。 others:用户共享的镜像。 marketplace:镜像市场云市场 提供的镜像。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param imageInfo images + */ + + getVmImages (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 getVmImages" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.imageSource !== undefined && opts.imageSource !== null) { + queryParams['imageSource'] = opts.imageSource + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getVmImages 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 = this.makeRequest( + '/regions/{regionId}/vm_images', + '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) + } + ) + } + + /** + * 根据云提供商查询对应的VM资源信息 + * @param {Object} opts - parameters + * @param {string} opts.id - 资源实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param vmInfoDetail vm + */ + + getVmInstancesById (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 getVmInstancesById" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling getVmInstancesById" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getVmInstancesById 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 = this.makeRequest( + '/regions/{regionId}/vm_instances/{id}', + '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) + } + ) + } + + /** + * 通过虚拟机id删除虚拟机 + * @param {Object} opts - parameters + * @param {string} opts.id - 资源实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteVmInstanceById (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 deleteVmInstanceById" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling deleteVmInstanceById" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 deleteVmInstanceById 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 = this.makeRequest( + '/regions/{regionId}/vm_instances/{id}', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param vmInfo vms + */ + + getVmInstances (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 getVmInstances" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getVmInstances 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 = this.makeRequest( + '/regions/{regionId}/vm_instances', + '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 {createVm} opts.vm - 创建VM + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param resourceTFInfo task + */ + + createVmInstance (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 createVmInstance" + ) + } + + opts = opts || {} + + if (opts.vm === undefined || opts.vm === null) { + throw new Error( + "Missing the required parameter 'opts.vm' when calling createVmInstance" + ) + } + + let postBody = {} + if (opts.vm !== undefined && opts.vm !== null) { + postBody['vm'] = opts.vm + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 createVmInstance 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 = this.makeRequest( + '/regions/{regionId}/vm_instances', + '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) + } + ) + } + + /** + * 停止运行一台实例。只有状态为 运行中(Running)的实例才可以进行此操作。 + * @param {Object} opts - parameters + * @param {string} opts.id - 资源实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + stopVmInstanceById (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 stopVmInstanceById" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling stopVmInstanceById" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 stopVmInstanceById 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 = this.makeRequest( + '/regions/{regionId}/vm_instances/{id}:stop', + '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) + } + ) + } + + /** + * 启动一台实例。实例状态必须为 已停止(Stopped),才可以调用该接口。 + * @param {Object} opts - parameters + * @param {string} opts.id - 资源实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + startVmInstanceById (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 startVmInstanceById" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling startVmInstanceById" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 startVmInstanceById 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 = this.makeRequest( + '/regions/{regionId}/vm_instances/{id}:start', + '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) + } + ) + } + + /** + * 只能重启状态为 运行中(Running)的实例。 + * @param {Object} opts - parameters + * @param {string} opts.id - 资源实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + rebootVmInstanceById (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 rebootVmInstanceById" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling rebootVmInstanceById" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 rebootVmInstanceById 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 = this.makeRequest( + '/regions/{regionId}/vm_instances/{id}:reboot', + '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) + } + ) + } + + /** + * 虚拟机规格列表 + * @param {Object} opts - parameters + * @param {string} [opts.az] - 可用区 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instanceTypeInfo instanceTypes + */ + + getVmInstanceTypes (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 getVmInstanceTypes" + ) + } + + 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 jdfusion/0.3.0' + } + + 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 getVmInstanceTypes 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 = this.makeRequest( + '/regions/{regionId}/vm_instanceTypes', + '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.name - keypair name + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param keypairInfo keypair + */ + + getVmKeypairsByName (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 getVmKeypairsByName" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling getVmKeypairsByName" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + name: opts.name + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getVmKeypairsByName 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 = this.makeRequest( + '/regions/{regionId}/vm_keypairs/{name}', + '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.name - keypair name + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteVmKeypairByName (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 deleteVmKeypairByName" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling deleteVmKeypairByName" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + name: opts.name + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 deleteVmKeypairByName 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 = this.makeRequest( + '/regions/{regionId}/vm_keypairs/{name}', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param keypairInfo keypairs + */ + + getVmKeypairs (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 getVmKeypairs" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getVmKeypairs 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 = this.makeRequest( + '/regions/{regionId}/vm_keypairs', + '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 {createKeypair} opts.keypair - 创建keypair + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param resourceTFInfo tasks + */ + + createVmKeypair (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 createVmKeypair" + ) + } + + opts = opts || {} + + if (opts.keypair === undefined || opts.keypair === null) { + throw new Error( + "Missing the required parameter 'opts.keypair' when calling createVmKeypair" + ) + } + + let postBody = {} + if (opts.keypair !== undefined && opts.keypair !== null) { + postBody['keypair'] = opts.keypair + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 createVmKeypair 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 = this.makeRequest( + '/regions/{regionId}/vm_keypairs', + '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) + } + ) + } + + /** + * 根据云提供商查询对应的公网IP资源信息 + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param eipAddress eipAddresses + */ + + getVpcEips (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 getVpcEips" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getVpcEips 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 = this.makeRequest( + '/regions/{regionId}/vpc_eips', + '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 + * @param {Object} opts - parameters + * @param {allocateEipAddress} opts.allocate - 分配弹性公网ip + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param resourceTFInfo task + */ + + createVpcEip (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 createVpcEip" + ) + } + + opts = opts || {} + + if (opts.allocate === undefined || opts.allocate === null) { + throw new Error( + "Missing the required parameter 'opts.allocate' when calling createVpcEip" + ) + } + + let postBody = {} + if (opts.allocate !== undefined && opts.allocate !== null) { + postBody['allocate'] = opts.allocate + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 createVpcEip 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 = this.makeRequest( + '/regions/{regionId}/vpc_eips', + '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) + } + ) + } + + /** + * 根据云提供商查询对应的公网IP资源信息 + * @param {Object} opts - parameters + * @param {string} opts.id - 公网IP ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param eipAddress eipAddress + */ + + getVpcEipById (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 getVpcEipById" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling getVpcEipById" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getVpcEipById 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 = this.makeRequest( + '/regions/{regionId}/vpc_eips/{id}', + '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 + * @param {Object} opts - parameters + * @param {string} opts.id - 公网IP ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteVpcEipById (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 deleteVpcEipById" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling deleteVpcEipById" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 deleteVpcEipById 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 = this.makeRequest( + '/regions/{regionId}/vpc_eips/{id}', + '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) + } + ) + } + + /** + * 弹性公网IP绑定到虚拟机 + * @param {Object} opts - parameters + * @param {string} opts.id - 公网IP ID + * @param {associateEipAddress} opts.associate - 弹性公网IP绑定到虚拟机 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param resourceTFInfo task + */ + + associateVpcEipById (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 associateVpcEipById" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling associateVpcEipById" + ) + } + if (opts.associate === undefined || opts.associate === null) { + throw new Error( + "Missing the required parameter 'opts.associate' when calling associateVpcEipById" + ) + } + + let postBody = {} + if (opts.associate !== undefined && opts.associate !== null) { + postBody['associate'] = opts.associate + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 associateVpcEipById 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 = this.makeRequest( + '/regions/{regionId}/vpc_eips/{id}:associate', + '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) + } + ) + } + + /** + * 解绑公网IP + * @param {Object} opts - parameters + * @param {string} opts.id - 公网IP ID + * @param {unassociateEipAddress} opts.unassociate - 解绑公网IP + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + disassociateVpcEipById (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 disassociateVpcEipById" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling disassociateVpcEipById" + ) + } + if (opts.unassociate === undefined || opts.unassociate === null) { + throw new Error( + "Missing the required parameter 'opts.unassociate' when calling disassociateVpcEipById" + ) + } + + let postBody = {} + if (opts.unassociate !== undefined && opts.unassociate !== null) { + postBody['unassociate'] = opts.unassociate + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 disassociateVpcEipById 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 = this.makeRequest( + '/regions/{regionId}/vpc_eips/{id}:disassociate', + '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) + } + ) + } + + /** + * 根据过滤条件,查监听器列表 + * @param {Object} opts - parameters + * @param {string} [opts.slbid] - 负载均衡id optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param lbHttpListener httpListeners + */ + + getLbHttpListener (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 getLbHttpListener" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.slbid !== undefined && opts.slbid !== null) { + queryParams['slbid'] = opts.slbid + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getLbHttpListener 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 = this.makeRequest( + '/regions/{regionId}/vpc_lbHttpListener', + '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) + } + ) + } + + /** + * 创建HTTP监听器 + * @param {Object} opts - parameters + * @param {createLoadBalancerHTTPListener} opts.httpListener - 创建HTTP监听器 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param resourceTFInfo task + */ + + createVpcLBHttpListener (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 createVpcLBHttpListener" + ) + } + + opts = opts || {} + + if (opts.httpListener === undefined || opts.httpListener === null) { + throw new Error( + "Missing the required parameter 'opts.httpListener' when calling createVpcLBHttpListener" + ) + } + + let postBody = {} + if (opts.httpListener !== undefined && opts.httpListener !== null) { + postBody['httpListener'] = opts.httpListener + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 createVpcLBHttpListener 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 = this.makeRequest( + '/regions/{regionId}/vpc_lbHttpListener', + '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.id - 网卡 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param netInterfaceInfo netInterface + */ + + getVpcNetworkInterfaceById (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 getVpcNetworkInterfaceById" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling getVpcNetworkInterfaceById" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getVpcNetworkInterfaceById 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 = this.makeRequest( + '/regions/{regionId}/vpc_networkInterfaces/{id}', + '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.id - 网卡 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteVpcNetworkInterfaceById ( + 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 deleteVpcNetworkInterfaceById" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling deleteVpcNetworkInterfaceById" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 deleteVpcNetworkInterfaceById 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 = this.makeRequest( + '/regions/{regionId}/vpc_networkInterfaces/{id}', + '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.vmId] - 云主机id optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param netInterfaceInfo netInterfaces + */ + + getVpcNetworkInterfaces (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 getVpcNetworkInterfaces" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.vmId !== undefined && opts.vmId !== null) { + queryParams['vmId'] = opts.vmId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getVpcNetworkInterfaces 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 = this.makeRequest( + '/regions/{regionId}/vpc_networkInterfaces', + '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 {createNetInterface} opts.netInterface - 创建网卡 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param resourceTFInfo task + */ + + createVpcNetworkInterface (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 createVpcNetworkInterface" + ) + } + + opts = opts || {} + + if (opts.netInterface === undefined || opts.netInterface === null) { + throw new Error( + "Missing the required parameter 'opts.netInterface' when calling createVpcNetworkInterface" + ) + } + + let postBody = {} + if (opts.netInterface !== undefined && opts.netInterface !== null) { + postBody['netInterface'] = opts.netInterface + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 createVpcNetworkInterface 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 = this.makeRequest( + '/regions/{regionId}/vpc_networkInterfaces', + '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.id - 网卡 ID + * @param {attachNetInterface} opts.attach - 网卡挂载虚拟机 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param resourceTFInfo task + */ + + attachVpcNetworkInterfaceById ( + 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 attachVpcNetworkInterfaceById" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling attachVpcNetworkInterfaceById" + ) + } + if (opts.attach === undefined || opts.attach === null) { + throw new Error( + "Missing the required parameter 'opts.attach' when calling attachVpcNetworkInterfaceById" + ) + } + + let postBody = {} + if (opts.attach !== undefined && opts.attach !== null) { + postBody['attach'] = opts.attach + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 attachVpcNetworkInterfaceById 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 = this.makeRequest( + '/regions/{regionId}/vpc_networkInterfaces/{id}:attach', + '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) + } + ) + } + + /** + * 卸载网卡 + * @param {Object} opts - parameters + * @param {string} opts.id - 网卡 ID + * @param {detachNetInterface} opts.detach - 卸载网卡 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + detachVpcNetworkInterfaceById ( + 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 detachVpcNetworkInterfaceById" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling detachVpcNetworkInterfaceById" + ) + } + if (opts.detach === undefined || opts.detach === null) { + throw new Error( + "Missing the required parameter 'opts.detach' when calling detachVpcNetworkInterfaceById" + ) + } + + let postBody = {} + if (opts.detach !== undefined && opts.detach !== null) { + postBody['detach'] = opts.detach + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 detachVpcNetworkInterfaceById 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 = this.makeRequest( + '/regions/{regionId}/vpc_networkInterfaces/{id}:detach', + '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) + } + ) + } + + /** + * 查询指定的安全组资源信息 + * @param {Object} opts - parameters + * @param {string} opts.id - SecurityGroup ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param securityGroupDetail securityGroup + */ + + getVpcSecurityGroupById (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 getVpcSecurityGroupById" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling getVpcSecurityGroupById" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getVpcSecurityGroupById 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 = this.makeRequest( + '/regions/{regionId}/vpc_securityGroups/{id}', + '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.id - SecurityGroup ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteVpcSecurityGroupById (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 deleteVpcSecurityGroupById" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling deleteVpcSecurityGroupById" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 deleteVpcSecurityGroupById 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 = this.makeRequest( + '/regions/{regionId}/vpc_securityGroups/{id}', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param securityGroupInfo securityGroups + */ + + getVpcSecurityGroups (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 getVpcSecurityGroups" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getVpcSecurityGroups 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 = this.makeRequest( + '/regions/{regionId}/vpc_securityGroups', + '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 {createSecurityGroup} opts.securityGroup - 创建securityGroup + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param resourceTFInfo task + */ + + createVpcSecurityGroup (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 createVpcSecurityGroup" + ) + } + + opts = opts || {} + + if (opts.securityGroup === undefined || opts.securityGroup === null) { + throw new Error( + "Missing the required parameter 'opts.securityGroup' when calling createVpcSecurityGroup" + ) + } + + let postBody = {} + if (opts.securityGroup !== undefined && opts.securityGroup !== null) { + postBody['securityGroup'] = opts.securityGroup + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 createVpcSecurityGroup 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 = this.makeRequest( + '/regions/{regionId}/vpc_securityGroups', + '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.id - 安全组ID + * @param {createSgRule} opts.sgRule - 新增安全组规则 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param resourceTFInfo task + */ + + createSecurityGroupsRule (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 createSecurityGroupsRule" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling createSecurityGroupsRule" + ) + } + if (opts.sgRule === undefined || opts.sgRule === null) { + throw new Error( + "Missing the required parameter 'opts.sgRule' when calling createSecurityGroupsRule" + ) + } + + let postBody = {} + if (opts.sgRule !== undefined && opts.sgRule !== null) { + postBody['sgRule'] = opts.sgRule + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 createSecurityGroupsRule 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 = this.makeRequest( + '/regions/{regionId}/vpc_securityGroups/{id}/rule', + '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.id - 安全组ID + * @param {string} opts.ruleType - 规则类型,ingress、egress + * @param {string} opts.protocol - 协议,tcp、udp、icmp 或者 all + * @param {string} opts.fromPort - 起始端口 + * @param {string} opts.toPort - 终止端口 + * @param {string} [opts.nicType] - 网络类型,internet、intranet optional + * @param {string} [opts.policy] - 认证策略,accept、drop optional + * @param {string} [opts.priority] - 认证策略的权重,1-100 optional + * @param {string} [opts.cidrIp] - 目标IP地址范围 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteSecurityGroupsRule (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 deleteSecurityGroupsRule" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling deleteSecurityGroupsRule" + ) + } + if (opts.ruleType === undefined || opts.ruleType === null) { + throw new Error( + "Missing the required parameter 'opts.ruleType' when calling deleteSecurityGroupsRule" + ) + } + if (opts.protocol === undefined || opts.protocol === null) { + throw new Error( + "Missing the required parameter 'opts.protocol' when calling deleteSecurityGroupsRule" + ) + } + if (opts.fromPort === undefined || opts.fromPort === null) { + throw new Error( + "Missing the required parameter 'opts.fromPort' when calling deleteSecurityGroupsRule" + ) + } + if (opts.toPort === undefined || opts.toPort === null) { + throw new Error( + "Missing the required parameter 'opts.toPort' when calling deleteSecurityGroupsRule" + ) + } + + let postBody = null + let queryParams = {} + if (opts.ruleType !== undefined && opts.ruleType !== null) { + queryParams['ruleType'] = opts.ruleType + } + if (opts.protocol !== undefined && opts.protocol !== null) { + queryParams['protocol'] = opts.protocol + } + if (opts.fromPort !== undefined && opts.fromPort !== null) { + queryParams['fromPort'] = opts.fromPort + } + if (opts.toPort !== undefined && opts.toPort !== null) { + queryParams['toPort'] = opts.toPort + } + if (opts.nicType !== undefined && opts.nicType !== null) { + queryParams['nicType'] = opts.nicType + } + if (opts.policy !== undefined && opts.policy !== null) { + queryParams['policy'] = opts.policy + } + if (opts.priority !== undefined && opts.priority !== null) { + queryParams['priority'] = opts.priority + } + if (opts.cidrIp !== undefined && opts.cidrIp !== null) { + queryParams['cidrIp'] = opts.cidrIp + } + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 deleteSecurityGroupsRule 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 = this.makeRequest( + '/regions/{regionId}/vpc_securityGroups/{id}/rule', + '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) + } + ) + } + + /** + * 根据云提供商查询对应的SLB资源信息 + * @param {Object} opts - parameters + * @param {string} opts.id - LB ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param slbInfoDetail slb + */ + + getVpcSlbById (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 getVpcSlbById" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling getVpcSlbById" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getVpcSlbById 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 = this.makeRequest( + '/regions/{regionId}/vpc_slbs/{id}', + '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) + } + ) + } + + /** + * 删除SLB + * @param {Object} opts - parameters + * @param {string} opts.id - LB ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteVpcSlbById (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 deleteVpcSlbById" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling deleteVpcSlbById" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 deleteVpcSlbById 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 = this.makeRequest( + '/regions/{regionId}/vpc_slbs/{id}', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param slbInfo slbs + */ + + getVpcSlbs (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 getVpcSlbs" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getVpcSlbs 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 = this.makeRequest( + '/regions/{regionId}/vpc_slbs', + '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 {slbInfo} opts.slb - 创建SLB + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param resourceTFInfo task + */ + + createVpcSlb (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 createVpcSlb" + ) + } + + opts = opts || {} + + if (opts.slb === undefined || opts.slb === null) { + throw new Error( + "Missing the required parameter 'opts.slb' when calling createVpcSlb" + ) + } + + let postBody = {} + if (opts.slb !== undefined && opts.slb !== null) { + postBody['slb'] = opts.slb + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 createVpcSlb 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 = this.makeRequest( + '/regions/{regionId}/vpc_slbs', + '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.id - LB ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + startSlb (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 startSlb" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling startSlb" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 startSlb 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 = this.makeRequest( + '/regions/{regionId}/vpc_slbs/{id}:start', + '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) + } + ) + } + + /** + * 停止负载均衡 + * @param {Object} opts - parameters + * @param {string} opts.id - LB ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + stopSlb (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 stopSlb" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling stopSlb" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 stopSlb 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 = this.makeRequest( + '/regions/{regionId}/vpc_slbs/{id}:stop', + '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) + } + ) + } + + /** + * 删除监听器 + * @param {Object} opts - parameters + * @param {string} opts.id - 负载均衡id + * @param {integer} opts.listenerPort - 监听器端口 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteSlbsListener (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 deleteSlbsListener" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling deleteSlbsListener" + ) + } + if (opts.listenerPort === undefined || opts.listenerPort === null) { + throw new Error( + "Missing the required parameter 'opts.listenerPort' when calling deleteSlbsListener" + ) + } + + let postBody = null + let queryParams = {} + if (opts.listenerPort !== undefined && opts.listenerPort !== null) { + queryParams['listenerPort'] = opts.listenerPort + } + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 deleteSlbsListener 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 = this.makeRequest( + '/regions/{regionId}/vpc_slbs_listener/{id}', + '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.id - 负载均衡id + * @param {integer} opts.listenerPort - 监听器端口 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + startSlbListener (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 startSlbListener" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling startSlbListener" + ) + } + if (opts.listenerPort === undefined || opts.listenerPort === null) { + throw new Error( + "Missing the required parameter 'opts.listenerPort' when calling startSlbListener" + ) + } + + let postBody = {} + if (opts.listenerPort !== undefined && opts.listenerPort !== null) { + postBody['listenerPort'] = opts.listenerPort + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 startSlbListener 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 = this.makeRequest( + '/regions/{regionId}/vpc_slbs_listener/{id}:start', + '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) + } + ) + } + + /** + * 停止监听器 + * @param {Object} opts - parameters + * @param {string} opts.id - 负载均衡id + * @param {integer} opts.listenerPort - 监听器端口 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + stopSlbListener (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 stopSlbListener" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling stopSlbListener" + ) + } + if (opts.listenerPort === undefined || opts.listenerPort === null) { + throw new Error( + "Missing the required parameter 'opts.listenerPort' when calling stopSlbListener" + ) + } + + let postBody = {} + if (opts.listenerPort !== undefined && opts.listenerPort !== null) { + postBody['listenerPort'] = opts.listenerPort + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 stopSlbListener 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 = this.makeRequest( + '/regions/{regionId}/vpc_slbs_listener/{id}:stop', + '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) + } + ) + } + + /** + * 根据云提供商查询对应的subnet资源信息 + * @param {Object} opts - parameters + * @param {string} opts.id - VPC ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param subnetDesInfo subnet + */ + + getVpcSubnetById (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 getVpcSubnetById" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling getVpcSubnetById" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getVpcSubnetById 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 = this.makeRequest( + '/regions/{regionId}/vpc_subnets/{id}', + '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.id - VPC ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteVpcSubnetById (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 deleteVpcSubnetById" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling deleteVpcSubnetById" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 deleteVpcSubnetById 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 = this.makeRequest( + '/regions/{regionId}/vpc_subnets/{id}', + '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) + } + ) + } + + /** + * 根据云提供商查询对应的subnet资源信息 + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param subnetDesInfo subnets + */ + + getVpcSubnets (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 getVpcSubnets" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getVpcSubnets 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 = this.makeRequest( + '/regions/{regionId}/vpc_subnets', + '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 {createSubnet} opts.subnet - 创建subnet + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param resourceTFInfo task + */ + + createVpcSubnet (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 createVpcSubnet" + ) + } + + opts = opts || {} + + if (opts.subnet === undefined || opts.subnet === null) { + throw new Error( + "Missing the required parameter 'opts.subnet' when calling createVpcSubnet" + ) + } + + let postBody = {} + if (opts.subnet !== undefined && opts.subnet !== null) { + postBody['subnet'] = opts.subnet + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 createVpcSubnet 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 = this.makeRequest( + '/regions/{regionId}/vpc_subnets', + '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) + } + ) + } + + /** + * 根据云提供商查询对应的VPC资源信息 + * @param {Object} opts - parameters + * @param {string} opts.id - VPC ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param vpcInfoDetail vpc + */ + + getVpcById (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 getVpcById" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling getVpcById" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getVpcById 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 = this.makeRequest( + '/regions/{regionId}/vpc_vpcs/{id}', + '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) + } + ) + } + + /** + * 删除VPC + * @param {Object} opts - parameters + * @param {string} opts.id - VPC ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteVpcById (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 deleteVpcById" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling deleteVpcById" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 deleteVpcById 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 = this.makeRequest( + '/regions/{regionId}/vpc_vpcs/{id}', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param vpcListInfo vpcs + */ + + getVpcs (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 getVpcs" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getVpcs 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 = this.makeRequest( + '/regions/{regionId}/vpc_vpcs', + '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 {vpcInfo} opts.vpc - 创建VPC + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param resourceTFInfo task + */ + + createVpc (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 createVpc" + ) + } + + opts = opts || {} + + if (opts.vpc === undefined || opts.vpc === null) { + throw new Error( + "Missing the required parameter 'opts.vpc' when calling createVpc" + ) + } + + let postBody = {} + if (opts.vpc !== undefined && opts.vpc !== null) { + postBody['vpc'] = opts.vpc + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 createVpc 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 = this.makeRequest( + '/regions/{regionId}/vpc_vpcs', + '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.slbid] - 负载均衡id optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param vserverGroupInfo vserverGroups + */ + + getVpcVServerGroups (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 getVpcVServerGroups" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.slbid !== undefined && opts.slbid !== null) { + queryParams['slbid'] = opts.slbid + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getVpcVServerGroups 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 = this.makeRequest( + '/regions/{regionId}/vpc_vserverGroups', + '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 {createVserverGroup} opts.vserverGroup - 创建虚拟服务器组 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param resourceTFInfo task + */ + + createVpcVServerGroup (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 createVpcVServerGroup" + ) + } + + opts = opts || {} + + if (opts.vserverGroup === undefined || opts.vserverGroup === null) { + throw new Error( + "Missing the required parameter 'opts.vserverGroup' when calling createVpcVServerGroup" + ) + } + + let postBody = {} + if (opts.vserverGroup !== undefined && opts.vserverGroup !== null) { + postBody['vserverGroup'] = opts.vserverGroup + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 createVpcVServerGroup 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 = this.makeRequest( + '/regions/{regionId}/vpc_vserverGroups', + '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.id - 服务器组ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param vserverGroupDetail vserverGroup + */ + + getVserverGroupsById (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 getVserverGroupsById" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling getVserverGroupsById" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 getVserverGroupsById 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 = this.makeRequest( + '/regions/{regionId}/vpc_vserverGroups/{id}', + '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.id - 服务器组ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteVserverGroup (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 deleteVserverGroup" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling deleteVserverGroup" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdfusion/0.3.0' + } + + 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 deleteVserverGroup 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 = this.makeRequest( + '/regions/{regionId}/vpc_vserverGroups/{id}', + '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) + } + ) + } +} +module.exports = JDCloud.JDFUSION diff --git a/packages/libs/lib-jdcloud/src/repo/jdro/v1/jdro.js b/packages/libs/lib-jdcloud/src/repo/jdro/v1/jdro.js new file mode 100644 index 000000000..03430ec2f --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/jdro/v1/jdro.js @@ -0,0 +1,1514 @@ +/* + * 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. + * + * Template + * Interface of Template + * + * 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 = 'jdro' +Service._services[serviceId] = true + +/** + * jdro service. + * @version 0.0.4 + */ + +JDCloud.JDRO = class JDRO extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'jdro.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询支持的资源列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 当前所在页,默认为1 optional + * @param {integer} [opts.pageSize] - 页面大小,默认为20;取值范围[1, 100] optional + * @param {string} [opts.product] - 产品线类型,比如 VM optional + * @param {string} [opts.search] - 搜索的内容 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param describeResourceTypeListItem resourceTypeList + * @param integer totalCount + */ + + describeResourceTypeList (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 describeResourceTypeList" + ) + } + + 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.product !== undefined && opts.product !== null) { + queryParams['product'] = opts.product + } + if (opts.search !== undefined && opts.search !== null) { + queryParams['search'] = opts.search + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdro/0.0.4' + } + + 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 describeResourceTypeList 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 = this.makeRequest( + '/regions/{regionId}/resourcetypes', + '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.resourceType - 资源类型 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param object propertyTypes + * @param resourceTypes resourceTypes + */ + + describeResourceTypeSpecification ( + 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 describeResourceTypeSpecification" + ) + } + + opts = opts || {} + + if (opts.resourceType === undefined || opts.resourceType === null) { + throw new Error( + "Missing the required parameter 'opts.resourceType' when calling describeResourceTypeSpecification" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + resourceType: opts.resourceType + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdro/0.0.4' + } + + 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 describeResourceTypeSpecification 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 = this.makeRequest( + '/regions/{regionId}/resourcetypes/{resourceType}', + '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 optional + * @param {integer} [opts.pageSize] - 页面大小,默认为20;取值范围[1, 100] optional + * @param {string} [opts.stackName] - 资源栈名称 optional + * @param {string} [opts.action] - 资源栈正在执行的动作 optional + * @param {string} [opts.status] - 资源栈正在执行的动作的状态 optional + * @param {string} [opts.createStartTime] - 创建开始时间 optional + * @param {string} [opts.createEndTime] - 创建结束时间 optional + * @param {string} [opts.updateStartTime] - 更新开始时间 optional + * @param {string} [opts.updateEndTime] - 更新结束时间 optional + * @param {string} [opts.sortField] - 排序字段, createtime, updatetime optional + * @param {string} [opts.sortBy] - 排序方式,asc,desc optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param stackOut list + * @param integer totalCount + */ + + describeStacks (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 describeStacks" + ) + } + + 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.stackName !== undefined && opts.stackName !== null) { + queryParams['stackName'] = opts.stackName + } + if (opts.action !== undefined && opts.action !== null) { + queryParams['action'] = opts.action + } + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + if (opts.createStartTime !== undefined && opts.createStartTime !== null) { + queryParams['createStartTime'] = opts.createStartTime + } + if (opts.createEndTime !== undefined && opts.createEndTime !== null) { + queryParams['createEndTime'] = opts.createEndTime + } + if (opts.updateStartTime !== undefined && opts.updateStartTime !== null) { + queryParams['updateStartTime'] = opts.updateStartTime + } + if (opts.updateEndTime !== undefined && opts.updateEndTime !== null) { + queryParams['updateEndTime'] = opts.updateEndTime + } + if (opts.sortField !== undefined && opts.sortField !== null) { + queryParams['sortField'] = opts.sortField + } + if (opts.sortBy !== undefined && opts.sortBy !== null) { + queryParams['sortBy'] = opts.sortBy + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdro/0.0.4' + } + + 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 describeStacks 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 = this.makeRequest( + '/regions/{regionId}/stacks', + '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 {environment} opts.environment + * @param {object} opts.template - 模板, JSON对象 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string stackID + */ + + createStack (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 createStack" + ) + } + + opts = opts || {} + + if (opts.environment === undefined || opts.environment === null) { + throw new Error( + "Missing the required parameter 'opts.environment' when calling createStack" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling createStack" + ) + } + + let postBody = {} + if (opts.environment !== undefined && opts.environment !== null) { + postBody['environment'] = opts.environment + } + if (opts.template !== undefined && opts.template !== null) { + postBody['template'] = opts.template + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdro/0.0.4' + } + + 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 createStack 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 = this.makeRequest( + '/regions/{regionId}/stacks', + '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.stackId - 资源栈 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param stackOut stack + */ + + describeStack (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 describeStack" + ) + } + + opts = opts || {} + + if (opts.stackId === undefined || opts.stackId === null) { + throw new Error( + "Missing the required parameter 'opts.stackId' when calling describeStack" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + stackId: opts.stackId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdro/0.0.4' + } + + 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 describeStack 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 = this.makeRequest( + '/regions/{regionId}/stacks/{stackId}', + '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.stackId - 资源栈 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string details + */ + + deleteStack (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 deleteStack" + ) + } + + opts = opts || {} + + if (opts.stackId === undefined || opts.stackId === null) { + throw new Error( + "Missing the required parameter 'opts.stackId' when calling deleteStack" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + stackId: opts.stackId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdro/0.0.4' + } + + 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 deleteStack 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 = this.makeRequest( + '/regions/{regionId}/stacks/{stackId}', + '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.stackId - 资源栈 ID + * @param {environment} opts.environment + * @param {object} opts.template - 模板, JSON对象 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string id + */ + + createChangeSet (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 createChangeSet" + ) + } + + opts = opts || {} + + if (opts.stackId === undefined || opts.stackId === null) { + throw new Error( + "Missing the required parameter 'opts.stackId' when calling createChangeSet" + ) + } + if (opts.environment === undefined || opts.environment === null) { + throw new Error( + "Missing the required parameter 'opts.environment' when calling createChangeSet" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling createChangeSet" + ) + } + + let postBody = {} + if (opts.environment !== undefined && opts.environment !== null) { + postBody['environment'] = opts.environment + } + if (opts.template !== undefined && opts.template !== null) { + postBody['template'] = opts.template + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + stackId: opts.stackId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdro/0.0.4' + } + + 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 createChangeSet 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 = this.makeRequest( + '/regions/{regionId}/stacks/{stackId}/changesets', + '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.stackId - 资源栈 ID + * @param {string} opts.changesetId - 更改集 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + executeChangeSet (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 executeChangeSet" + ) + } + + opts = opts || {} + + if (opts.stackId === undefined || opts.stackId === null) { + throw new Error( + "Missing the required parameter 'opts.stackId' when calling executeChangeSet" + ) + } + if (opts.changesetId === undefined || opts.changesetId === null) { + throw new Error( + "Missing the required parameter 'opts.changesetId' when calling executeChangeSet" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + stackId: opts.stackId, + changesetId: opts.changesetId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdro/0.0.4' + } + + 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 executeChangeSet 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 = this.makeRequest( + '/regions/{regionId}/stacks/{stackId}/changesets/{changesetId}', + '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.stackId - 资源栈 ID + * @param {integer} [opts.pageNumber] - 当前所在页,默认为1 optional + * @param {integer} [opts.pageSize] - 页面大小,默认为20;取值范围[1, 100] optional + * @param {string} [opts.startTime] - 事件开始时间 optional + * @param {string} [opts.endTime] - 事件结束时间 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param eventOut list + * @param integer totalCount + */ + + describeStackEvents (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 describeStackEvents" + ) + } + + opts = opts || {} + + if (opts.stackId === undefined || opts.stackId === null) { + throw new Error( + "Missing the required parameter 'opts.stackId' when calling describeStackEvents" + ) + } + + 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.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: regionId, + stackId: opts.stackId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdro/0.0.4' + } + + 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 describeStackEvents 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 = this.makeRequest( + '/regions/{regionId}/stacks/{stackId}/events', + '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.stackId - 资源栈 ID + * @param {integer} [opts.pageNumber] - 当前所在页,默认为1 optional + * @param {integer} [opts.pageSize] - 页面大小,默认为20;取值范围[1, 100] optional + * @param {string} [opts.search] - 按照京东云产品线名称或者资源逻辑ID进行模糊搜索 optional + * @param {string} [opts.product] - 只按照京东云产品线名称进行模糊搜索,比如VM,Disk等 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param resourceOut list + * @param integer totalCount + */ + + describeStackResources (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 describeStackResources" + ) + } + + opts = opts || {} + + if (opts.stackId === undefined || opts.stackId === null) { + throw new Error( + "Missing the required parameter 'opts.stackId' when calling describeStackResources" + ) + } + + 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.search !== undefined && opts.search !== null) { + queryParams['search'] = opts.search + } + if (opts.product !== undefined && opts.product !== null) { + queryParams['product'] = opts.product + } + + let pathParams = { + regionId: regionId, + stackId: opts.stackId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdro/0.0.4' + } + + 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 describeStackResources 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 = this.makeRequest( + '/regions/{regionId}/stacks/{stackId}/resources', + '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.stackId - 资源栈 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string template 模板信息 + */ + + describeStackTemplate (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 describeStackTemplate" + ) + } + + opts = opts || {} + + if (opts.stackId === undefined || opts.stackId === null) { + throw new Error( + "Missing the required parameter 'opts.stackId' when calling describeStackTemplate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + stackId: opts.stackId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdro/0.0.4' + } + + 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 describeStackTemplate 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 = this.makeRequest( + '/regions/{regionId}/stacks/{stackId}/template', + '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 {environment} [opts.environment] optional + * @param {object} opts.template - 模板 + * @param {string} [opts.validateMode] - 可取值:(validateTemplate (检测模板), validateStack (检测模板和environment)) 默认validateTemplate optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string describe + * @param object result 验证模板结果信息,JSON格式 + */ + + validateTemplate (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 validateTemplate" + ) + } + + opts = opts || {} + + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling validateTemplate" + ) + } + + let postBody = {} + if (opts.environment !== undefined && opts.environment !== null) { + postBody['environment'] = opts.environment + } + if (opts.template !== undefined && opts.template !== null) { + postBody['template'] = opts.template + } + if (opts.validateMode !== undefined && opts.validateMode !== null) { + postBody['validateMode'] = opts.validateMode + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jdro/0.0.4' + } + + 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 validateTemplate 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 = this.makeRequest( + '/regions/{regionId}/templateValidate', + '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 = JDCloud.JDRO diff --git a/packages/libs/lib-jdcloud/src/repo/jdw/v1/jdw.js b/packages/libs/lib-jdcloud/src/repo/jdw/v1/jdw.js new file mode 100644 index 000000000..cae23a923 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/jdw/v1/jdw.js @@ -0,0 +1,47 @@ +/* + * 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. + * + * 实例管理 + * 实例管理相关接口 + * + * 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 = 'jdw' +Service._services[serviceId] = true + +/** + * jdw service. + * @version 1.0.0 + */ + +JDCloud.JDW = class JDW extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'jdw.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } +} +module.exports = JDCloud.JDW diff --git a/packages/libs/lib-jdcloud/src/repo/jdworkspace/v1/jdworkspace.js b/packages/libs/lib-jdcloud/src/repo/jdworkspace/v1/jdworkspace.js new file mode 100644 index 000000000..5ef5521db --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/jdworkspace/v1/jdworkspace.js @@ -0,0 +1,47 @@ +/* + * 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. + * + * JDCLOUD 态势感知续费管理 API + * 态势感知续费管理相关信息接口 + * + * 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 = 'jdworkspace' +Service._services[serviceId] = true + +/** + * jdworkspace service. + * @version 0.1.0 + */ + +class JDWORKSPACE extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'billing.release.workspace.jdcloud.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } +} +module.exports = JDWORKSPACE diff --git a/packages/libs/lib-jdcloud/src/repo/jke/v1/jke.js b/packages/libs/lib-jdcloud/src/repo/jke/v1/jke.js new file mode 100644 index 000000000..6b254b652 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/jke/v1/jke.js @@ -0,0 +1,153 @@ +/* + * 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. + * + * 配额 + * k8s 集群配额相关接口 + * + * 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 = 'jke' +Service._services[serviceId] = true + +/** + * jke service. + * @version 0.1.0 + */ + +JDCloud.JKE = class JKE extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'jke.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询(k8s 集群)配额 + * @param {Object} opts - parameters + * @param {filter} [opts.filters] - resourceTypes - 资源类型,暂时只支持[kubernetes] + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param quota quotas + */ + + describeQuotas (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 describeQuotas" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + Object.assign(queryParams, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jke/0.1.0' + } + + 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 describeQuotas 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 = this.makeRequest( + '/regions/{regionId}/quotas', + '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 = JDCloud.JKE diff --git a/packages/libs/lib-jdcloud/src/repo/jmr/v1/jmr.js b/packages/libs/lib-jdcloud/src/repo/jmr/v1/jmr.js new file mode 100644 index 000000000..95ff8699f --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/jmr/v1/jmr.js @@ -0,0 +1,1205 @@ +/* + * 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. + * + * 集群管理 + * JMR集群管理相关接口 + * + * 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 = 'jmr' +Service._services[serviceId] = true + +/** + * jmr service. + * @version 1.1.6 + */ + +class JMR extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'jmr.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询用户的集群列表及相关服务的一些信息 + * @param {Object} opts - parameters + * @param {string} [opts.dataCenter] - 地域信息 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param object data 包括集群信息列表 + * @param boolean status + */ + + idataCluster (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 idataCluster" + ) + } + + opts = opts || {} + + if (opts.dataCenter === undefined || opts.dataCenter === null) { + throw new Error( + "Missing the required parameter 'opts.dataCenter' when calling idataCluster" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + dataCenter: opts.dataCenter + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jmr/1.1.6' + } + + 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 idataCluster 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}/idata', + '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.version - JMR软件版本号 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string data 对应的软件清单信息 + * @param boolean status + */ + + getSoftwareInfo (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 getSoftwareInfo" + ) + } + + opts = opts || {} + + if (opts.version === undefined || opts.version === null) { + throw new Error( + "Missing the required parameter 'opts.version' when calling getSoftwareInfo" + ) + } + + let postBody = null + let queryParams = {} + if (opts.version !== undefined && opts.version !== null) { + queryParams['version'] = opts.version + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jmr/1.1.6' + } + + 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 getSoftwareInfo 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}/softwareInfo', + '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) + } + ) + } + + /** + * 查询JMR的版本信息 + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string data + * @param boolean status + */ + + getJmrVersionList (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 getJmrVersionList" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jmr/1.1.6' + } + + 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 getJmrVersionList 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}/jmrVersions', + '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) + } + ) + } + + /** + * 查询JMR的监控模板信息 + * @param {Object} opts - parameters + * @param {string} opts.clusterId - 集群ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param monitorLabelDetail data + * @param boolean status + */ + + monitorLabelList (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 monitorLabelList" + ) + } + + opts = opts || {} + + if (opts.clusterId === undefined || opts.clusterId === null) { + throw new Error( + "Missing the required parameter 'opts.clusterId' when calling monitorLabelList" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + clusterId: opts.clusterId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jmr/1.1.6' + } + + 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 monitorLabelList 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}/monitorLabelList/{clusterId}', + '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.clusterId - 集群ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param cluster cluster + * @param boolean status + */ + + describeCluster (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 describeCluster" + ) + } + + opts = opts || {} + + if (opts.clusterId === undefined || opts.clusterId === null) { + throw new Error( + "Missing the required parameter 'opts.clusterId' when calling describeCluster" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + clusterId: opts.clusterId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jmr/1.1.6' + } + + 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 describeCluster 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}/clusters/{clusterId}', + '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.dataCenter] - 地域 optional + * @param {string} [opts.status] - 集群状态,CREATING,RUNNING,RELEASED,FAILED等 optional + * @param {string} [opts.clusterName] - 集群名称 optional + * @param {string} [opts.orderBy] - 排序,比如 id desc optional + * @param {integer} [opts.pageNum] - 页数,默认为1 optional + * @param {integer} [opts.pageSize] - 每页数目,默认为10 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalNum 集群总的数目 + * @param clusterListNode clusters + * @param boolean status + */ + + describeClusters (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 describeClusters" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.dataCenter !== undefined && opts.dataCenter !== null) { + queryParams['dataCenter'] = opts.dataCenter + } + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + if (opts.clusterName !== undefined && opts.clusterName !== null) { + queryParams['clusterName'] = opts.clusterName + } + if (opts.orderBy !== undefined && opts.orderBy !== null) { + queryParams['orderBy'] = opts.orderBy + } + if (opts.pageNum !== undefined && opts.pageNum !== null) { + queryParams['pageNum'] = opts.pageNum + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jmr/1.1.6' + } + + 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 describeClusters 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}/clusters', + '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.clusterId - 集群ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status 是否开始释放集群 + */ + + releaseCluster (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 releaseCluster" + ) + } + + opts = opts || {} + + if (opts.clusterId === undefined || opts.clusterId === null) { + throw new Error( + "Missing the required parameter 'opts.clusterId' when calling releaseCluster" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + clusterId: opts.clusterId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jmr/1.1.6' + } + + 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 releaseCluster 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}/clusters/{clusterId}:release', + '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 {clusterExpansion} opts.clusterExpansion - 描述集群扩容信息 + * @param {string} [opts.clientToken] - 用于保证请求的幂等性。由客户端生成,长度不能超过64个字符。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status 是否开始扩容集群 + */ + + clusterExpansion (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 clusterExpansion" + ) + } + + opts = opts || {} + + if (opts.clusterExpansion === undefined || opts.clusterExpansion === null) { + throw new Error( + "Missing the required parameter 'opts.clusterExpansion' when calling clusterExpansion" + ) + } + + let postBody = {} + if (opts.clusterExpansion !== undefined && opts.clusterExpansion !== null) { + postBody['clusterExpansion'] = opts.clusterExpansion + } + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jmr/1.1.6' + } + + 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 clusterExpansion 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}/cluster:expansion', + '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 {clusterReduction} opts.clusterReduction - 描述集群缩容信息 + * @param {string} [opts.clientToken] - 用于保证请求的幂等性。由客户端生成,长度不能超过64个字符。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status 是否开始缩容集群 + */ + + clusterReduction (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 clusterReduction" + ) + } + + opts = opts || {} + + if (opts.clusterReduction === undefined || opts.clusterReduction === null) { + throw new Error( + "Missing the required parameter 'opts.clusterReduction' when calling clusterReduction" + ) + } + + let postBody = {} + if (opts.clusterReduction !== undefined && opts.clusterReduction !== null) { + postBody['clusterReduction'] = opts.clusterReduction + } + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jmr/1.1.6' + } + + 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 clusterReduction 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}/cluster:reduction', + '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 {clusterSpec} opts.clusterSpec - 描述集群配置 + * @param {string} [opts.clientToken] - 用于保证请求的幂等性。由客户端生成,长度不能超过64个字符。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status 是否开始创建集群 + * @param string clusterId 集群ID + * @param string message 创建集群的信息 + */ + + createCluster (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 createCluster" + ) + } + + opts = opts || {} + + if (opts.clusterSpec === undefined || opts.clusterSpec === null) { + throw new Error( + "Missing the required parameter 'opts.clusterSpec' when calling createCluster" + ) + } + + let postBody = {} + if (opts.clusterSpec !== undefined && opts.clusterSpec !== null) { + postBody['clusterSpec'] = opts.clusterSpec + } + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 jmr/1.1.6' + } + + 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 createCluster 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}/cluster:create', + '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 = JMR diff --git a/packages/libs/lib-jdcloud/src/repo/kafka/v1/kafka.js b/packages/libs/lib-jdcloud/src/repo/kafka/v1/kafka.js new file mode 100644 index 000000000..639c60bc8 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/kafka/v1/kafka.js @@ -0,0 +1,643 @@ +/* + * 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. + * + * kafka topic 相关接口 + * kafka topic 相关接口 + * + * 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 = 'kafka' +Service._services[serviceId] = true + +/** + * kafka service. + * @version 1.0.0 + */ + +JDCloud.KAFKA = class KAFKA extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'kafka.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询kafka实例列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码,默认1 optional + * @param {integer} [opts.pageSize] - 分页大小,默认10 optional + * @param {filter} [opts.filters] - 过滤条件: +instanceId -实例Id,精确匹配,支持多个 +instanceVersion -实例版本,精确匹配,支持单个 +instanceName - 实例名称,模糊匹配,支持单个 +instanceStatus - 实例状态,精确匹配,支持多个(running:运行,error:错误,creating:创建中,changing:变配中,stop:已停止,processing:处理中) +chargeMode - 计费类型,按配置postpaid_by_duration或者包年包月prepaid_by_duration + optional + * @param {tagFilter} [opts.tagFilters] - 标签过滤条件 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instance instances + * @param integer totalCount kafka实例总数 + */ + + 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 + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + Object.assign( + queryParams, + super.buildTagFilterParam(opts.tagFilters, 'tagFilters') + ) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kafka/1.0.0' + } + + 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}/instances', + '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) + } + ) + } + + /** + * 创建一个指定配置的kafka实例 + * @param {Object} opts - parameters + * @param {instanceSpec} opts.instance - kafka实例的相关配置 + * @param {chargeSpec} [opts.charge] - 计费信息的相关配置,只有prepaid_by_duration和postpaid_by_duration 2种计费模式 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string instanceId kafka实例编号 + * @param string buyId buyId + */ + + createInstance (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 createInstance" + ) + } + + opts = opts || {} + + if (opts.instance === undefined || opts.instance === null) { + throw new Error( + "Missing the required parameter 'opts.instance' when calling createInstance" + ) + } + + let postBody = {} + if (opts.instance !== undefined && opts.instance !== null) { + postBody['instance'] = opts.instance + } + if (opts.charge !== undefined && opts.charge !== null) { + postBody['charge'] = opts.charge + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kafka/1.0.0' + } + + 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 createInstance 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}/instances', + '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) + } + ) + } + + /** + * 查询kafka实例的详细信息 + * @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 kafka实例详细信息 + */ + + 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 || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeInstance" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kafka/1.0.0' + } + + 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}/instances/{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) + } + ) + } + + /** + * 删除按配置计费或包年包月已到期的kafka实例,包年包月未到期不可删除。 +状态为创建中和变配中的不可删除。 + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + 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 || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteInstance" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kafka/1.0.0' + } + + 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}/instances/{instanceId}', + '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) + } + ) + } + + /** + * 变更kafka实例的配置,实例为running状态才可变更配置 + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {array} opts.instanceClassSpec - 变更的规格 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string instanceId kafka实例编号 + * @param string buyId buyId + */ + + 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.instanceClassSpec === undefined || + opts.instanceClassSpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.instanceClassSpec' when calling modifyInstanceSpec" + ) + } + + let postBody = {} + if ( + opts.instanceClassSpec !== undefined && + opts.instanceClassSpec !== null + ) { + postBody['instanceClassSpec'] = opts.instanceClassSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kafka/1.0.0' + } + + 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}/instances/{instanceId}: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) + } + ) + } +} +module.exports = JDCloud.KAFKA diff --git a/packages/libs/lib-jdcloud/src/repo/kms/v1/kms.js b/packages/libs/lib-jdcloud/src/repo/kms/v1/kms.js new file mode 100644 index 000000000..6a5403e41 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/kms/v1/kms.js @@ -0,0 +1,3468 @@ +/* + * 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. + * + * Statistics Service + * 基于硬件保护密钥的安全数据托管服务 + * + * 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 = 'kms' +Service._services[serviceId] = true + +/** + * kms service. + * @version 0.3.3 + */ + +class KMS extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'kms.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 获取密钥列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[10, 100] optional + * @param {string} callback - callback + @return {Object} result + * @param keyInfo keyList + * @param integer totalCount Key的数量 + */ + + describeKeyList (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 + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 describeKeyList 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( + '/key', + '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) + } + ) + } + + /** + * 创建一个CMK(用户主密钥),默认为启用状态 + * @param {Object} opts - parameters + * @param {keyCfg} opts.keyCfg + * @param {string} callback - callback + @return {Object} result + * @param string keyId 创建的密钥ID + */ + + createKey (opts, callback) { + opts = opts || {} + + if (opts.keyCfg === undefined || opts.keyCfg === null) { + throw new Error( + "Missing the required parameter 'opts.keyCfg' when calling createKey" + ) + } + + let postBody = {} + if (opts.keyCfg !== undefined && opts.keyCfg !== null) { + postBody['keyCfg'] = opts.keyCfg + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 createKey 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( + '/key:create', + '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.keyId - 密钥ID + * @param {string} callback - callback + @return {Object} result + * @param keyInfo keyInfo + */ + + describeKey (opts, callback) { + opts = opts || {} + + if (opts.keyId === undefined || opts.keyId === null) { + throw new Error( + "Missing the required parameter 'opts.keyId' when calling describeKey" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + keyId: opts.keyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 describeKey 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( + '/key/{keyId}', + '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) + } + ) + } + + /** + * - 修改对称密钥配置,包括key的名称、用途、是否自动轮换和轮换周期等; +- 修改非对称密钥配置,包括key的名称、用途等。 + + * @param {Object} opts - parameters + * @param {string} opts.keyId - 密钥ID + * @param {keyCfg} opts.keyCfg + * @param {string} callback - callback + @return {Object} result + */ + + updateKeyDescription (opts, callback) { + opts = opts || {} + + if (opts.keyId === undefined || opts.keyId === null) { + throw new Error( + "Missing the required parameter 'opts.keyId' when calling updateKeyDescription" + ) + } + if (opts.keyCfg === undefined || opts.keyCfg === null) { + throw new Error( + "Missing the required parameter 'opts.keyCfg' when calling updateKeyDescription" + ) + } + + let postBody = {} + if (opts.keyCfg !== undefined && opts.keyCfg !== null) { + postBody['keyCfg'] = opts.keyCfg + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + keyId: opts.keyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 updateKeyDescription 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( + '/key/{keyId}', + 'PATCH', + 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.keyId - 密钥ID + * @param {string} callback - callback + @return {Object} result + */ + + enableKey (opts, callback) { + opts = opts || {} + + if (opts.keyId === undefined || opts.keyId === null) { + throw new Error( + "Missing the required parameter 'opts.keyId' when calling enableKey" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + keyId: opts.keyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 enableKey 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( + '/key/{keyId}:enable', + 'PATCH', + 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.keyId - 密钥ID + * @param {string} callback - callback + @return {Object} result + */ + + disableKey (opts, callback) { + opts = opts || {} + + if (opts.keyId === undefined || opts.keyId === null) { + throw new Error( + "Missing the required parameter 'opts.keyId' when calling disableKey" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + keyId: opts.keyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 disableKey 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( + '/key/{keyId}:disable', + 'PATCH', + 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) + } + ) + } + + /** + * 计划在以后的是个时间点删除密钥,默认为7天 + * @param {Object} opts - parameters + * @param {string} opts.keyId - 密钥ID + * @param {integer} [opts.delayDays] - 延迟删除时间,单位(天),默认为7天;支持时间范围:7~30天 optional + * @param {string} callback - callback + @return {Object} result + */ + + scheduleKeyDeletion (opts, callback) { + opts = opts || {} + + if (opts.keyId === undefined || opts.keyId === null) { + throw new Error( + "Missing the required parameter 'opts.keyId' when calling scheduleKeyDeletion" + ) + } + + let postBody = null + let queryParams = {} + if (opts.delayDays !== undefined && opts.delayDays !== null) { + queryParams['delayDays'] = opts.delayDays + } + + let pathParams = { + regionId: 'jdcloud', + keyId: opts.keyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 scheduleKeyDeletion 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( + '/key/{keyId}:delete', + '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.keyId - 密钥ID + * @param {string} callback - callback + @return {Object} result + */ + + cancelKeyDeletion (opts, callback) { + opts = opts || {} + + if (opts.keyId === undefined || opts.keyId === null) { + throw new Error( + "Missing the required parameter 'opts.keyId' when calling cancelKeyDeletion" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + keyId: opts.keyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 cancelKeyDeletion 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( + '/key/{keyId}:cancelDelete', + 'PATCH', + 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.keyId - 密钥ID + * @param {string} callback - callback + @return {Object} result + */ + + keyRotation (opts, callback) { + opts = opts || {} + + if (opts.keyId === undefined || opts.keyId === null) { + throw new Error( + "Missing the required parameter 'opts.keyId' when calling keyRotation" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + keyId: opts.keyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 keyRotation 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( + '/key/{keyId}:rotate', + 'PATCH', + 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) + } + ) + } + + /** + * 使用密钥对数据进行加密,针对非对称密钥:使用公钥进行加密,仅支持RSA_PKCS1_PADDING填充方式,最大加密数据长度为245字节 + * @param {Object} opts - parameters + * @param {string} opts.keyId - 密钥ID + * @param {} [opts.plaintext] - 明文数据 Base64-encoded binary data object optional + * @param {string} callback - callback + @return {Object} result + * @param string ciphertextBlob 密文数据 Base64-encoded binary data object + */ + + encrypt (opts, callback) { + opts = opts || {} + + if (opts.keyId === undefined || opts.keyId === null) { + throw new Error( + "Missing the required parameter 'opts.keyId' when calling encrypt" + ) + } + + let postBody = {} + if (opts.plaintext !== undefined && opts.plaintext !== null) { + postBody['plaintext'] = opts.plaintext + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + keyId: opts.keyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 encrypt 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( + '/key/{keyId}:Encrypt', + '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.keyId - 密钥ID + * @param {} [opts.ciphertextBlob] - 密文数据 Base64-encoded binary data object optional + * @param {string} callback - callback + @return {Object} result + * @param string plaintext 明文数据 Base64-encoded binary data object + */ + + decrypt (opts, callback) { + opts = opts || {} + + if (opts.keyId === undefined || opts.keyId === null) { + throw new Error( + "Missing the required parameter 'opts.keyId' when calling decrypt" + ) + } + + let postBody = {} + if (opts.ciphertextBlob !== undefined && opts.ciphertextBlob !== null) { + postBody['ciphertextBlob'] = opts.ciphertextBlob + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + keyId: opts.keyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 decrypt 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( + '/key/{keyId}:Decrypt', + '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.keyId - 密钥ID + * @param {string} callback - callback + @return {Object} result + * @param string publicKeyBlob 公钥,PEM格式 + */ + + getPublicKey (opts, callback) { + opts = opts || {} + + if (opts.keyId === undefined || opts.keyId === null) { + throw new Error( + "Missing the required parameter 'opts.keyId' when calling getPublicKey" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + keyId: opts.keyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 getPublicKey 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( + '/key/{keyId}:GetPublicKey', + '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) + } + ) + } + + /** + * 使用非对称密钥的私钥签名,签名算法仅支持RSA_PKCS1_PADDING填充方式,最大签名数据长度为4K字节 + * @param {Object} opts - parameters + * @param {string} opts.keyId - 密钥ID + * @param {} [opts.plaintext] - 需要签名的数据 Base64-encoded binary data object optional + * @param {string} callback - callback + @return {Object} result + * @param string signature 签名 + */ + + sign (opts, callback) { + opts = opts || {} + + if (opts.keyId === undefined || opts.keyId === null) { + throw new Error( + "Missing the required parameter 'opts.keyId' when calling sign" + ) + } + + let postBody = {} + if (opts.plaintext !== undefined && opts.plaintext !== null) { + postBody['plaintext'] = opts.plaintext + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + keyId: opts.keyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 sign 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( + '/key/{keyId}:Sign', + '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.keyId - 密钥ID + * @param {} [opts.plaintext] - 需要签名的数据 Base64-encoded binary data object optional + * @param {} [opts.signature] - 签名 optional + * @param {string} callback - callback + @return {Object} result + * @param boolean validated 校验签名结果,true为成功,false为失败 + */ + + validate (opts, callback) { + opts = opts || {} + + if (opts.keyId === undefined || opts.keyId === null) { + throw new Error( + "Missing the required parameter 'opts.keyId' when calling validate" + ) + } + + let postBody = {} + if (opts.plaintext !== undefined && opts.plaintext !== null) { + postBody['plaintext'] = opts.plaintext + } + if (opts.signature !== undefined && opts.signature !== null) { + postBody['signature'] = opts.signature + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + keyId: opts.keyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 validate 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( + '/key/{keyId}:Validate', + '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) + } + ) + } + + /** + * 从KMS中获取一对数据密钥的明文/密文 + * @param {Object} opts - parameters + * @param {string} opts.keyId - 密钥ID + * @param {string} callback - callback + @return {Object} result + * @param string plaintext 明文DEK Base64-encoded binary data object + * @param string ciphertextBlob 密文DEK Base64-encoded binary data object + */ + + generateDataKey (opts, callback) { + opts = opts || {} + + if (opts.keyId === undefined || opts.keyId === null) { + throw new Error( + "Missing the required parameter 'opts.keyId' when calling generateDataKey" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + keyId: opts.keyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 generateDataKey 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( + '/key/{keyId}:GenerateDataKey', + '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.keyId - 密钥ID + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[10, 100] optional + * @param {string} callback - callback + @return {Object} result + * @param keyDetail keyDetail + */ + + describeKeyDetail (opts, callback) { + opts = opts || {} + + if (opts.keyId === undefined || opts.keyId === null) { + throw new Error( + "Missing the required parameter 'opts.keyId' when calling describeKeyDetail" + ) + } + + 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: 'jdcloud', + keyId: opts.keyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 describeKeyDetail 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( + '/key/{keyId}:describeKeyDetail', + '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.keyId - 密钥ID + * @param {string} opts.version - 密钥版本 + * @param {string} callback - callback + @return {Object} result + */ + + enableKeyVersion (opts, callback) { + opts = opts || {} + + if (opts.keyId === undefined || opts.keyId === null) { + throw new Error( + "Missing the required parameter 'opts.keyId' when calling enableKeyVersion" + ) + } + if (opts.version === undefined || opts.version === null) { + throw new Error( + "Missing the required parameter 'opts.version' when calling enableKeyVersion" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + keyId: opts.keyId, + version: opts.version + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 enableKeyVersion 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( + '/key/{keyId}/version/{version}:enable', + 'PATCH', + 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.keyId - 密钥ID + * @param {string} opts.version - 密钥版本 + * @param {string} callback - callback + @return {Object} result + */ + + disableKeyVersion (opts, callback) { + opts = opts || {} + + if (opts.keyId === undefined || opts.keyId === null) { + throw new Error( + "Missing the required parameter 'opts.keyId' when calling disableKeyVersion" + ) + } + if (opts.version === undefined || opts.version === null) { + throw new Error( + "Missing the required parameter 'opts.version' when calling disableKeyVersion" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + keyId: opts.keyId, + version: opts.version + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 disableKeyVersion 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( + '/key/{keyId}/version/{version}:disable', + 'PATCH', + 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) + } + ) + } + + /** + * 计划在以后的是个时间点删除指定版本密钥,默认为7天 + * @param {Object} opts - parameters + * @param {string} opts.keyId - 密钥ID + * @param {string} opts.version - 密钥版本 + * @param {integer} [opts.delayDays] - 延迟删除时间,单位(天),默认为7天;支持时间范围:7~30天 optional + * @param {string} callback - callback + @return {Object} result + */ + + scheduleKeyVersionDeletion (opts, callback) { + opts = opts || {} + + if (opts.keyId === undefined || opts.keyId === null) { + throw new Error( + "Missing the required parameter 'opts.keyId' when calling scheduleKeyVersionDeletion" + ) + } + if (opts.version === undefined || opts.version === null) { + throw new Error( + "Missing the required parameter 'opts.version' when calling scheduleKeyVersionDeletion" + ) + } + + let postBody = null + let queryParams = {} + if (opts.delayDays !== undefined && opts.delayDays !== null) { + queryParams['delayDays'] = opts.delayDays + } + + let pathParams = { + regionId: 'jdcloud', + keyId: opts.keyId, + version: opts.version + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 scheduleKeyVersionDeletion 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( + '/key/{keyId}/version/{version}:delete', + '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.keyId - 密钥ID + * @param {string} opts.version - 密钥版本 + * @param {string} callback - callback + @return {Object} result + */ + + cancelKeyVersionDeletion (opts, callback) { + opts = opts || {} + + if (opts.keyId === undefined || opts.keyId === null) { + throw new Error( + "Missing the required parameter 'opts.keyId' when calling cancelKeyVersionDeletion" + ) + } + if (opts.version === undefined || opts.version === null) { + throw new Error( + "Missing the required parameter 'opts.version' when calling cancelKeyVersionDeletion" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + keyId: opts.keyId, + version: opts.version + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 cancelKeyVersionDeletion 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( + '/key/{keyId}/version/{version}:cancelDelete', + 'PATCH', + 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 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[10, 100] optional + * @param {string} callback - callback + @return {Object} result + * @param secretInfo secretList + * @param integer totalCount Secret的数量 + */ + + describeSecretList (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 + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 describeSecretList 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( + '/secret', + '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 {secretCfg} opts.secretCfg + * @param {string} callback - callback + @return {Object} result + * @param string secretId secretId + */ + + createSecret (opts, callback) { + opts = opts || {} + + if (opts.secretCfg === undefined || opts.secretCfg === null) { + throw new Error( + "Missing the required parameter 'opts.secretCfg' when calling createSecret" + ) + } + + let postBody = {} + if (opts.secretCfg !== undefined && opts.secretCfg !== null) { + postBody['secretCfg'] = opts.secretCfg + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 createSecret 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( + '/secret:create', + '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.secretId - 机密ID + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[10, 100] optional + * @param {string} callback - callback + @return {Object} result + * @param secretDetail secretDetail + */ + + describeSecretVersionList (opts, callback) { + opts = opts || {} + + if (opts.secretId === undefined || opts.secretId === null) { + throw new Error( + "Missing the required parameter 'opts.secretId' when calling describeSecretVersionList" + ) + } + + 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: 'jdcloud', + secretId: opts.secretId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 describeSecretVersionList 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( + '/secret/{secretId}', + '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.secretId - 机密ID + * @param {secretDescCfg} opts.secretDescCfg + * @param {string} callback - callback + @return {Object} result + */ + + updateSecret (opts, callback) { + opts = opts || {} + + if (opts.secretId === undefined || opts.secretId === null) { + throw new Error( + "Missing the required parameter 'opts.secretId' when calling updateSecret" + ) + } + if (opts.secretDescCfg === undefined || opts.secretDescCfg === null) { + throw new Error( + "Missing the required parameter 'opts.secretDescCfg' when calling updateSecret" + ) + } + + let postBody = {} + if (opts.secretDescCfg !== undefined && opts.secretDescCfg !== null) { + postBody['secretDescCfg'] = opts.secretDescCfg + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + secretId: opts.secretId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 updateSecret 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( + '/secret/{secretId}', + 'PATCH', + 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.secretId - 机密ID + * @param {string} callback - callback + @return {Object} result + */ + + enableSecret (opts, callback) { + opts = opts || {} + + if (opts.secretId === undefined || opts.secretId === null) { + throw new Error( + "Missing the required parameter 'opts.secretId' when calling enableSecret" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + secretId: opts.secretId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 enableSecret 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( + '/secret/{secretId}:enable', + 'PATCH', + 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.secretId - 机密ID + * @param {string} callback - callback + @return {Object} result + */ + + disableSecret (opts, callback) { + opts = opts || {} + + if (opts.secretId === undefined || opts.secretId === null) { + throw new Error( + "Missing the required parameter 'opts.secretId' when calling disableSecret" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + secretId: opts.secretId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 disableSecret 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( + '/secret/{secretId}:disable', + 'PATCH', + 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.secretId - 机密ID + * @param {string} callback - callback + @return {Object} result + */ + + deleteSecret (opts, callback) { + opts = opts || {} + + if (opts.secretId === undefined || opts.secretId === null) { + throw new Error( + "Missing the required parameter 'opts.secretId' when calling deleteSecret" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + secretId: opts.secretId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 deleteSecret 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( + '/secret/{secretId}:delete', + '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.secretId - 机密ID + * @param {secretVersionCfg} opts.secretVersionCfg + * @param {string} callback - callback + @return {Object} result + */ + + createSecretVersion (opts, callback) { + opts = opts || {} + + if (opts.secretId === undefined || opts.secretId === null) { + throw new Error( + "Missing the required parameter 'opts.secretId' when calling createSecretVersion" + ) + } + if (opts.secretVersionCfg === undefined || opts.secretVersionCfg === null) { + throw new Error( + "Missing the required parameter 'opts.secretVersionCfg' when calling createSecretVersion" + ) + } + + let postBody = {} + if (opts.secretVersionCfg !== undefined && opts.secretVersionCfg !== null) { + postBody['secretVersionCfg'] = opts.secretVersionCfg + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + secretId: opts.secretId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 createSecretVersion 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( + '/secret/{secretId}:createSecretVersion', + '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.secretId - 机密ID + * @param {string} opts.version - 机密版本 + * @param {string} callback - callback + @return {Object} result + * @param secretVersionItem secretVersionItem + */ + + describeSecretVersionInfo (opts, callback) { + opts = opts || {} + + if (opts.secretId === undefined || opts.secretId === null) { + throw new Error( + "Missing the required parameter 'opts.secretId' when calling describeSecretVersionInfo" + ) + } + if (opts.version === undefined || opts.version === null) { + throw new Error( + "Missing the required parameter 'opts.version' when calling describeSecretVersionInfo" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + secretId: opts.secretId, + version: opts.version + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 describeSecretVersionInfo 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( + '/secret/{secretId}/version/{version}', + '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.secretId - 机密ID + * @param {string} opts.version - 机密版本 + * @param {secretTimeCfg} opts.secretTimeCfg + * @param {string} callback - callback + @return {Object} result + */ + + updateSecretVersion (opts, callback) { + opts = opts || {} + + if (opts.secretId === undefined || opts.secretId === null) { + throw new Error( + "Missing the required parameter 'opts.secretId' when calling updateSecretVersion" + ) + } + if (opts.version === undefined || opts.version === null) { + throw new Error( + "Missing the required parameter 'opts.version' when calling updateSecretVersion" + ) + } + if (opts.secretTimeCfg === undefined || opts.secretTimeCfg === null) { + throw new Error( + "Missing the required parameter 'opts.secretTimeCfg' when calling updateSecretVersion" + ) + } + + let postBody = {} + if (opts.secretTimeCfg !== undefined && opts.secretTimeCfg !== null) { + postBody['secretTimeCfg'] = opts.secretTimeCfg + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + secretId: opts.secretId, + version: opts.version + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 updateSecretVersion 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( + '/secret/{secretId}/version/{version}', + 'PATCH', + 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.secretId - 机密ID + * @param {string} opts.version - 机密版本 + * @param {string} callback - callback + @return {Object} result + */ + + enableSecretVersion (opts, callback) { + opts = opts || {} + + if (opts.secretId === undefined || opts.secretId === null) { + throw new Error( + "Missing the required parameter 'opts.secretId' when calling enableSecretVersion" + ) + } + if (opts.version === undefined || opts.version === null) { + throw new Error( + "Missing the required parameter 'opts.version' when calling enableSecretVersion" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + secretId: opts.secretId, + version: opts.version + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 enableSecretVersion 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( + '/secret/{secretId}/version/{version}:enable', + 'PATCH', + 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.secretId - 机密ID + * @param {string} opts.version - 机密版本 + * @param {string} callback - callback + @return {Object} result + */ + + disableSecretVersion (opts, callback) { + opts = opts || {} + + if (opts.secretId === undefined || opts.secretId === null) { + throw new Error( + "Missing the required parameter 'opts.secretId' when calling disableSecretVersion" + ) + } + if (opts.version === undefined || opts.version === null) { + throw new Error( + "Missing the required parameter 'opts.version' when calling disableSecretVersion" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + secretId: opts.secretId, + version: opts.version + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 disableSecretVersion 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( + '/secret/{secretId}/version/{version}:disable', + 'PATCH', + 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.secretId - 机密ID + * @param {string} opts.version - 机密版本 + * @param {string} callback - callback + @return {Object} result + */ + + deleteSecretVersion (opts, callback) { + opts = opts || {} + + if (opts.secretId === undefined || opts.secretId === null) { + throw new Error( + "Missing the required parameter 'opts.secretId' when calling deleteSecretVersion" + ) + } + if (opts.version === undefined || opts.version === null) { + throw new Error( + "Missing the required parameter 'opts.version' when calling deleteSecretVersion" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + secretId: opts.secretId, + version: opts.version + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kms/0.3.3' + } + + 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 deleteSecretVersion 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( + '/secret/{secretId}/version/{version}:delete', + '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) + } + ) + } +} +module.exports = KMS diff --git a/packages/libs/lib-jdcloud/src/repo/kubernetes/v1/kubernetes.js b/packages/libs/lib-jdcloud/src/repo/kubernetes/v1/kubernetes.js new file mode 100644 index 000000000..27777c2ad --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/kubernetes/v1/kubernetes.js @@ -0,0 +1,2647 @@ +/* + * 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. + * + * ServerlessCluster + * Serverless集群相关接口 + * + * 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 = 'kubernetes' +Service._services[serviceId] = true + +/** + * kubernetes service. + * @version 1.2.2 + */ + +class KUBERNETES extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'kubernetes.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询集群列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 100] optional + * @param {filter} [opts.filters] - name - 集群名称,模糊匹配,仅支持单个 +id - id,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param cluster clusters + * @param number totalCount + */ + + describeClusters (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 describeClusters" + ) + } + + 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 kubernetes/1.2.2' + } + + 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 describeClusters 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}/clusters', + '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) + } + ) + } + + /** + * - 创建集群 +- 证书 + - 关于kubernetes的证书,默认生成,不需要用户传入。 +- nodegroup + - cluster必须与nodeGroup进行绑定 + - cluster支持多nodegroup + - 状态 + - pending,reconciling,deleting状态不可以操作更新接口 + - running,running_with_error状态可以操作nodegroup所有接口 + - error状态只可以查询,删除 + - delete状态的cluster在十五分钟内可以查询,十五分钟后无法查询到 +- 状态限制 + - pending,reconciling,deleting状态不可以操作更新接口 + - running状态可以操作cluster所有接口 + - error状态只可以查询,删除 + - delete状态的cluster在十五分钟内可以查询,十五分钟后无法查询到 + + * @param {Object} opts - parameters + * @param {string} opts.name - 名称(同一用户的 cluster 允许重名) + * @param {string} [opts.description] - 描述 optional + * @param {string} [opts.version] - kubernetes的版本 optional + * @param {boolean} [opts.isEdge] - 是否是边缘计算集群 optional + * @param {array} [opts.azs] - 集群所在的az optional + * @param {nodeGroupSpec} opts.nodeGroup - 集群节点组 + * @param {string} opts.accessKey - 用户的AccessKey,插件调用open-api时的认证凭证 + * @param {string} opts.secretKey - 用户的SecretKey,插件调用open-api时的认证凭证 + * @param {array} [opts.addonsConfig] - 集群组件配置 optional + * @param {string} [opts.clusterNetworkType] - 集群网络配置类型,取值:auto,customized,创建集群接口合并,原CreateCusomizedCluster接口废弃 optional + * @param {autoClusterNetworkSpec} [opts.autoClusterNetworkSpec] - clusterNetworkType为【auto】时,此配置必须要配置 optional + * @param {customizedClusterNetworkSpec} [opts.customizedClusterNetworkSpec] - clusterNetworkType为【customized】时,此配置必须要配置 optional + * @param {array} [opts.clusterEnvironments] - 用户自定义的集群的环境信息,会影响到创建集群时的组件模版的渲染 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string clusterId + */ + + createCluster (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 createCluster" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createCluster" + ) + } + if (opts.nodeGroup === undefined || opts.nodeGroup === null) { + throw new Error( + "Missing the required parameter 'opts.nodeGroup' when calling createCluster" + ) + } + if (opts.accessKey === undefined || opts.accessKey === null) { + throw new Error( + "Missing the required parameter 'opts.accessKey' when calling createCluster" + ) + } + if (opts.secretKey === undefined || opts.secretKey === null) { + throw new Error( + "Missing the required parameter 'opts.secretKey' when calling createCluster" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.version !== undefined && opts.version !== null) { + postBody['version'] = opts.version + } + if (opts.isEdge !== undefined && opts.isEdge !== null) { + postBody['isEdge'] = opts.isEdge + } + if (opts.azs !== undefined && opts.azs !== null) { + postBody['azs'] = opts.azs + } + if (opts.nodeGroup !== undefined && opts.nodeGroup !== null) { + postBody['nodeGroup'] = opts.nodeGroup + } + if (opts.accessKey !== undefined && opts.accessKey !== null) { + postBody['accessKey'] = opts.accessKey + } + if (opts.secretKey !== undefined && opts.secretKey !== null) { + postBody['secretKey'] = opts.secretKey + } + if (opts.addonsConfig !== undefined && opts.addonsConfig !== null) { + postBody['addonsConfig'] = opts.addonsConfig + } + if ( + opts.clusterNetworkType !== undefined && + opts.clusterNetworkType !== null + ) { + postBody['clusterNetworkType'] = opts.clusterNetworkType + } + if ( + opts.autoClusterNetworkSpec !== undefined && + opts.autoClusterNetworkSpec !== null + ) { + postBody['autoClusterNetworkSpec'] = opts.autoClusterNetworkSpec + } + if ( + opts.customizedClusterNetworkSpec !== undefined && + opts.customizedClusterNetworkSpec !== null + ) { + postBody['customizedClusterNetworkSpec'] = + opts.customizedClusterNetworkSpec + } + if ( + opts.clusterEnvironments !== undefined && + opts.clusterEnvironments !== null + ) { + postBody['clusterEnvironments'] = opts.clusterEnvironments + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kubernetes/1.2.2' + } + + 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 createCluster 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}/clusters', + '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.clusterId - 集群 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param cluster cluster + */ + + describeCluster (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 describeCluster" + ) + } + + opts = opts || {} + + if (opts.clusterId === undefined || opts.clusterId === null) { + throw new Error( + "Missing the required parameter 'opts.clusterId' when calling describeCluster" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + clusterId: opts.clusterId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kubernetes/1.2.2' + } + + 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 describeCluster 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}/clusters/{clusterId}', + '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>集群 name 和 description 必须要指定一个 + * @param {Object} opts - parameters + * @param {string} opts.clusterId - 集群 ID + * @param {string} [opts.name] - 集群名称 optional + * @param {string} [opts.description] - 集群描述 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyCluster (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 modifyCluster" + ) + } + + opts = opts || {} + + if (opts.clusterId === undefined || opts.clusterId === null) { + throw new Error( + "Missing the required parameter 'opts.clusterId' when calling modifyCluster" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + clusterId: opts.clusterId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kubernetes/1.2.2' + } + + 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 modifyCluster 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}/clusters/{clusterId}', + 'PATCH', + 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) + } + ) + } + + /** + * 删除集群,以及集群的所有node节点,网络,云盘等所有资源。 + * @param {Object} opts - parameters + * @param {string} opts.clusterId - 集群 ID + * @param {string} [opts.routeTableId] - 替换路由表id optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteCluster (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 deleteCluster" + ) + } + + opts = opts || {} + + if (opts.clusterId === undefined || opts.clusterId === null) { + throw new Error( + "Missing the required parameter 'opts.clusterId' when calling deleteCluster" + ) + } + + let postBody = null + let queryParams = {} + if (opts.routeTableId !== undefined && opts.routeTableId !== null) { + queryParams['routeTableId'] = opts.routeTableId + } + + let pathParams = { + regionId: regionId, + clusterId: opts.clusterId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kubernetes/1.2.2' + } + + 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 deleteCluster 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}/clusters/{clusterId}', + '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 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 100] optional + * @param {filter} [opts.filters] - name - 节点组名称,模糊匹配,支持单个 +id - 节点组 id,支持多个 +clusterId - 根据 clusterId 查询 +clusterName - 根据 cluster 名称查询 + optional + * @param {tagFilter} [opts.tags] - Tag筛选条件 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param nodeGroup nodeGroups + * @param number totalCount + */ + + describeNodeGroups (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 describeNodeGroups" + ) + } + + 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')) + Object.assign(queryParams, super.buildTagFilterParam(opts.tags, 'tags')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kubernetes/1.2.2' + } + + 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 describeNodeGroups 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}/nodeGroups', + '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> +- 要求集群状态为running + + * @param {Object} opts - parameters + * @param {string} opts.name - 名称(同一用户的 cluster 内部唯一) + * @param {string} [opts.description] - 描述 optional + * @param {string} opts.clusterId - 工作节点所属的集群 + * @param {nodeConfigSpec} opts.nodeConfig - 工作节点配置信息 + * @param {array} [opts.azs] - 工作节点组的 az,必须为集群az的子集,默认为集群az optional + * @param {integer} opts.initialNodeCount - 工作节点组初始化大小 + * @param {cAConfigSpec} [opts.caConfig] - 自动伸缩配置 optional + * @param {nodeGroupNetworkSpec} [opts.nodeGroupNetwork] - 节点组的网络配置,如果集群的类型customized类型,则必须指定该参数,如果是auto,则不是必须 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string nodeGroupId + */ + + createNodeGroup (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 createNodeGroup" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createNodeGroup" + ) + } + if (opts.clusterId === undefined || opts.clusterId === null) { + throw new Error( + "Missing the required parameter 'opts.clusterId' when calling createNodeGroup" + ) + } + if (opts.nodeConfig === undefined || opts.nodeConfig === null) { + throw new Error( + "Missing the required parameter 'opts.nodeConfig' when calling createNodeGroup" + ) + } + if (opts.initialNodeCount === undefined || opts.initialNodeCount === null) { + throw new Error( + "Missing the required parameter 'opts.initialNodeCount' when calling createNodeGroup" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.clusterId !== undefined && opts.clusterId !== null) { + postBody['clusterId'] = opts.clusterId + } + if (opts.nodeConfig !== undefined && opts.nodeConfig !== null) { + postBody['nodeConfig'] = opts.nodeConfig + } + if (opts.azs !== undefined && opts.azs !== null) { + postBody['azs'] = opts.azs + } + if (opts.initialNodeCount !== undefined && opts.initialNodeCount !== null) { + postBody['initialNodeCount'] = opts.initialNodeCount + } + if (opts.caConfig !== undefined && opts.caConfig !== null) { + postBody['caConfig'] = opts.caConfig + } + if (opts.nodeGroupNetwork !== undefined && opts.nodeGroupNetwork !== null) { + postBody['nodeGroupNetwork'] = opts.nodeGroupNetwork + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kubernetes/1.2.2' + } + + 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 createNodeGroup 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}/nodeGroups', + '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.nodeGroupId - 工作节点组 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param nodeGroup nodeGroup + */ + + describeNodeGroup (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 describeNodeGroup" + ) + } + + opts = opts || {} + + if (opts.nodeGroupId === undefined || opts.nodeGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.nodeGroupId' when calling describeNodeGroup" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + nodeGroupId: opts.nodeGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kubernetes/1.2.2' + } + + 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 describeNodeGroup 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}/nodeGroups/{nodeGroupId}', + '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>name 和 description 必须要指定一个 + * @param {Object} opts - parameters + * @param {string} opts.nodeGroupId - 工作节点组 ID + * @param {string} [opts.name] - 工作节点组名称 optional + * @param {string} [opts.description] - 工作节点组描述 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyNodeGroup (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 modifyNodeGroup" + ) + } + + opts = opts || {} + + if (opts.nodeGroupId === undefined || opts.nodeGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.nodeGroupId' when calling modifyNodeGroup" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + nodeGroupId: opts.nodeGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kubernetes/1.2.2' + } + + 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 modifyNodeGroup 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}/nodeGroups/{nodeGroupId}', + 'PATCH', + 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.nodeGroupId - 工作节点组 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteNodeGroup (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 deleteNodeGroup" + ) + } + + opts = opts || {} + + if (opts.nodeGroupId === undefined || opts.nodeGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.nodeGroupId' when calling deleteNodeGroup" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + nodeGroupId: opts.nodeGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kubernetes/1.2.2' + } + + 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 deleteNodeGroup 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}/nodeGroups/{nodeGroupId}', + '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.nodeGroupId - 工作节点组 ID + * @param {integer} opts.expectCount - 预期目标节点数量 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + setNodeGroupSize (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 setNodeGroupSize" + ) + } + + opts = opts || {} + + if (opts.nodeGroupId === undefined || opts.nodeGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.nodeGroupId' when calling setNodeGroupSize" + ) + } + if (opts.expectCount === undefined || opts.expectCount === null) { + throw new Error( + "Missing the required parameter 'opts.expectCount' when calling setNodeGroupSize" + ) + } + + let postBody = {} + if (opts.expectCount !== undefined && opts.expectCount !== null) { + postBody['expectCount'] = opts.expectCount + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + nodeGroupId: opts.nodeGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kubernetes/1.2.2' + } + + 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 setNodeGroupSize 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}/nodeGroups/{nodeGroupId}:setNodeGroupSize', + '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.nodeGroupId - 工作节点组 ID + * @param {cAConfigSpec} opts.caConfig - 自动伸缩配置,其中 enable 必须指定 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + setNodeGroupCA (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 setNodeGroupCA" + ) + } + + opts = opts || {} + + if (opts.nodeGroupId === undefined || opts.nodeGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.nodeGroupId' when calling setNodeGroupCA" + ) + } + if (opts.caConfig === undefined || opts.caConfig === null) { + throw new Error( + "Missing the required parameter 'opts.caConfig' when calling setNodeGroupCA" + ) + } + + let postBody = {} + if (opts.caConfig !== undefined && opts.caConfig !== null) { + postBody['caConfig'] = opts.caConfig + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + nodeGroupId: opts.nodeGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kubernetes/1.2.2' + } + + 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 setNodeGroupCA 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}/nodeGroups/{nodeGroupId}:setNodeGroupCA', + '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.nodeGroupId - 工作节点组 ID + * @param {array} [opts.instanceIds] - 需要从工作节点组中删除的实例 +- 不可将一个集群中的实例全部删除 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteNodeInstances (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 deleteNodeInstances" + ) + } + + opts = opts || {} + + if (opts.nodeGroupId === undefined || opts.nodeGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.nodeGroupId' when calling deleteNodeInstances" + ) + } + + let postBody = {} + if (opts.instanceIds !== undefined && opts.instanceIds !== null) { + postBody['instanceIds'] = opts.instanceIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + nodeGroupId: opts.nodeGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kubernetes/1.2.2' + } + + 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 deleteNodeInstances 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}/nodeGroups/{nodeGroupId}:deleteNodeInstances', + '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) + } + ) + } + + /** + * 查询 kubernetes 集群配额 + * @param {Object} opts - parameters + * @param {filter} [opts.filters] - resourceTypes - 资源类型,暂时只支持[kubernetes、serverless-kubernetes] + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param quota quotas + */ + + describeQuotas (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 describeQuotas" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kubernetes/1.2.2' + } + + 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 describeQuotas 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}/quotas', + '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.masterVersion] - 集群的大版本,如 1.16.4-jcs.3 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param masterVersion masterVersions + */ + + describeVersions (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 describeVersions" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.masterVersion !== undefined && opts.masterVersion !== null) { + queryParams['masterVersion'] = opts.masterVersion + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kubernetes/1.2.2' + } + + 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 describeVersions 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}/versions', + '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) + } + ) + } + + /** + * 查询Serverless集群列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 100] optional + * @param {filter} [opts.filters] - name - 集群名称,模糊匹配,仅支持单个 +id - id,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param serverlessCluster clusters + * @param number totalCount + */ + + describeServerlessClusters (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 describeServerlessClusters" + ) + } + + 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 kubernetes/1.2.2' + } + + 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 describeServerlessClusters 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}/serverless-clusters', + '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) + } + ) + } + + /** + * - 创建Serverless集群 +- 证书 + - 关于kubernetes的证书,默认生成,不需要用户传入。 +- 状态限制 + - pending,reconciling,deleting状态不可以操作更新接口 + - running状态可以操作cluster所有接口 + - error状态只可以查询,删除 + - delete状态的cluster在十五分钟内可以查询,十五分钟后无法查询到 + + * @param {Object} opts - parameters + * @param {string} opts.name - 名称(同一用户的 cluster 允许重名) + * @param {string} [opts.description] - 描述 optional + * @param {string} [opts.version] - kubernetes的版本 optional + * @param {array} [opts.azs] - 集群所在的az optional + * @param {string} opts.accessKey - 用户的AccessKey,插件调用open-api时的认证凭证 + * @param {string} opts.secretKey - 用户的SecretKey,插件调用open-api时的认证凭证 + * @param {array} [opts.addonsConfig] - 集群组件配置 optional + * @param {serverlessClusterNetworkSpec} opts.clusterNetworkSpec - 集群网络配置 + * @param {array} [opts.clusterEnvironments] - 用户自定义的集群的环境信息,会影响到创建集群时的组件模版的渲染 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string clusterId + */ + + createServerlessCluster (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 createServerlessCluster" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createServerlessCluster" + ) + } + if (opts.accessKey === undefined || opts.accessKey === null) { + throw new Error( + "Missing the required parameter 'opts.accessKey' when calling createServerlessCluster" + ) + } + if (opts.secretKey === undefined || opts.secretKey === null) { + throw new Error( + "Missing the required parameter 'opts.secretKey' when calling createServerlessCluster" + ) + } + if ( + opts.clusterNetworkSpec === undefined || + opts.clusterNetworkSpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.clusterNetworkSpec' when calling createServerlessCluster" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.version !== undefined && opts.version !== null) { + postBody['version'] = opts.version + } + if (opts.azs !== undefined && opts.azs !== null) { + postBody['azs'] = opts.azs + } + if (opts.accessKey !== undefined && opts.accessKey !== null) { + postBody['accessKey'] = opts.accessKey + } + if (opts.secretKey !== undefined && opts.secretKey !== null) { + postBody['secretKey'] = opts.secretKey + } + if (opts.addonsConfig !== undefined && opts.addonsConfig !== null) { + postBody['addonsConfig'] = opts.addonsConfig + } + if ( + opts.clusterNetworkSpec !== undefined && + opts.clusterNetworkSpec !== null + ) { + postBody['clusterNetworkSpec'] = opts.clusterNetworkSpec + } + if ( + opts.clusterEnvironments !== undefined && + opts.clusterEnvironments !== null + ) { + postBody['clusterEnvironments'] = opts.clusterEnvironments + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kubernetes/1.2.2' + } + + 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 createServerlessCluster 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}/serverless-clusters', + '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.clusterId - 集群 ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param serverlessCluster cluster + */ + + describeServerlessCluster (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 describeServerlessCluster" + ) + } + + opts = opts || {} + + if (opts.clusterId === undefined || opts.clusterId === null) { + throw new Error( + "Missing the required parameter 'opts.clusterId' when calling describeServerlessCluster" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + clusterId: opts.clusterId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kubernetes/1.2.2' + } + + 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 describeServerlessCluster 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}/serverless-clusters/{clusterId}', + '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) + } + ) + } + + /** + * 修改Serverless集群的 名称 和 描述。<br>集群 name 和 description 必须要指定一个 + * @param {Object} opts - parameters + * @param {string} opts.clusterId - 集群 ID + * @param {string} [opts.name] - 集群名称 optional + * @param {string} [opts.description] - 集群描述 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyServerlessCluster (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 modifyServerlessCluster" + ) + } + + opts = opts || {} + + if (opts.clusterId === undefined || opts.clusterId === null) { + throw new Error( + "Missing the required parameter 'opts.clusterId' when calling modifyServerlessCluster" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + clusterId: opts.clusterId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kubernetes/1.2.2' + } + + 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 modifyServerlessCluster 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}/serverless-clusters/{clusterId}', + 'PATCH', + 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) + } + ) + } + + /** + * 删除Serverless集群,以及集群的所有网络,云盘等所有资源。 + * @param {Object} opts - parameters + * @param {string} opts.clusterId - 集群 ID + * @param {string} [opts.routeTableId] - 替换路由表id optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteServerlessCluster (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 deleteServerlessCluster" + ) + } + + opts = opts || {} + + if (opts.clusterId === undefined || opts.clusterId === null) { + throw new Error( + "Missing the required parameter 'opts.clusterId' when calling deleteServerlessCluster" + ) + } + + let postBody = null + let queryParams = {} + if (opts.routeTableId !== undefined && opts.routeTableId !== null) { + queryParams['routeTableId'] = opts.routeTableId + } + + let pathParams = { + regionId: regionId, + clusterId: opts.clusterId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kubernetes/1.2.2' + } + + 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 deleteServerlessCluster 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}/serverless-clusters/{clusterId}', + '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) + } + ) + } + + /** + * 查询Serverless集群版本列表 + * @param {Object} opts - parameters + * @param {string} [opts.masterVersion] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param serverlessMasterVersion masterVersions + */ + + describeServerlessVersions (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 describeServerlessVersions" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.masterVersion !== undefined && opts.masterVersion !== null) { + queryParams['masterVersion'] = opts.masterVersion + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 kubernetes/1.2.2' + } + + 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 describeServerlessVersions 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}/serverless-versions', + '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 = KUBERNETES diff --git a/packages/libs/lib-jdcloud/src/repo/lavm/v1/lavm.js b/packages/libs/lib-jdcloud/src/repo/lavm/v1/lavm.js new file mode 100644 index 000000000..1c41a1748 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/lavm/v1/lavm.js @@ -0,0 +1,4188 @@ +/* + * 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. + * + * quota + * 轻量应用云主机配额模型的相关接口 + * + * 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 = 'lavm' +Service._services[serviceId] = true + +/** + * lavm service. + * @version 1.3.1 + */ + +class LAVM extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'lavm.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询磁盘信息。 + + * @param {Object} opts - parameters + * @param {string} [opts.instanceId] - 指定的轻量应用云主机的实例ID + optional + * @param {string} [opts.diskIds] - 磁盘ID, `[\"volume-xxx\", \"volume-yyy\"]`, json array 字串 + optional + * @param {integer} [opts.pageSize] - 页码;默认为1。 optional + * @param {integer} [opts.pageNumber] - 分页大小;<br>默认为20;取值范围[10, 100]。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param disk disks + * @param integer total 本次查询可匹配到的总记录数,使用者需要结合 `pageNumber` 和 `pageSize` 计算是否可以继续分页。 + */ + + describeDisks (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 describeDisks" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.instanceId !== undefined && opts.instanceId !== null) { + queryParams['instanceId'] = opts.instanceId + } + if (opts.diskIds !== undefined && opts.diskIds !== null) { + queryParams['diskIds'] = opts.diskIds + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + queryParams['pageNumber'] = opts.pageNumber + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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 describeDisks 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}/disks', + '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 {integer} [opts.pageSize] - 分页查询时设置的每页行数。最大值:100,默认值:10。 + optional + * @param {integer} [opts.pageNumber] - 防火墙规则列表的页码。起始值:1,默认值:1。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param firewallRule firewallRules + * @param integer totalCount + */ + + describeFirewallRules (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 describeFirewallRules" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeFirewallRules" + ) + } + + let postBody = null + let queryParams = {} + if (opts.instanceId !== undefined && opts.instanceId !== null) { + queryParams['instanceId'] = opts.instanceId + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + queryParams['pageNumber'] = opts.pageNumber + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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 describeFirewallRules 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}/firewallRule', + '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} opts.sourceAddress - 源Ip的CRDI格式的地址 + + * @param {string} opts.ruleProtocol - 规则限定协议。取值范围: +TCP:TCP协议。 +UDP:UDP协议。 +ICMP:ICMP协议。 + + * @param {string} opts.port - 端口范围。若规则限定协议为传输层协议(TCP、UDP),取值范围为1`~`65535,若规则限定协议为非传输层协议(ICMP协议),恒为0。使用正斜线(/)隔开起始端口和终止端口,例如:1024/1055表示端口范围为1024`~`1055。 + + * @param {string} [opts.remark] - 防火墙规则的备注, 不超过100个字符 + optional + * @param {string} [opts.clientToken] - 用于保证请求的幂等性。由客户端生成,并确保不同请求中该参数唯一,长度不能超过64个字符。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string firewallId + */ + + createFirewallRule (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 createFirewallRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createFirewallRule" + ) + } + if (opts.sourceAddress === undefined || opts.sourceAddress === null) { + throw new Error( + "Missing the required parameter 'opts.sourceAddress' when calling createFirewallRule" + ) + } + if (opts.ruleProtocol === undefined || opts.ruleProtocol === null) { + throw new Error( + "Missing the required parameter 'opts.ruleProtocol' when calling createFirewallRule" + ) + } + if (opts.port === undefined || opts.port === null) { + throw new Error( + "Missing the required parameter 'opts.port' when calling createFirewallRule" + ) + } + + let postBody = {} + if (opts.instanceId !== undefined && opts.instanceId !== null) { + postBody['instanceId'] = opts.instanceId + } + if (opts.sourceAddress !== undefined && opts.sourceAddress !== null) { + postBody['sourceAddress'] = opts.sourceAddress + } + if (opts.ruleProtocol !== undefined && opts.ruleProtocol !== null) { + postBody['ruleProtocol'] = opts.ruleProtocol + } + if (opts.port !== undefined && opts.port !== null) { + postBody['port'] = opts.port + } + if (opts.remark !== undefined && opts.remark !== null) { + postBody['remark'] = opts.remark + } + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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 createFirewallRule 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}/firewallRule', + '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 - 指定的轻量应用云主机的实例ID + + * @param {string} opts.ruleId - 防火墙规则ID + + * @param {string} opts.sourceAddress - 源Ip的CRDI格式的地址 + + * @param {string} opts.ruleProtocol - 规则限定协议。取值范围: +TCP:TCP协议。 +UDP:UDP协议。 +ICMP:ICMP协议。 + + * @param {string} opts.port - 端口范围。若规则限定协议为传输层协议(TCP、UDP),取值范围为1`~`65535,若规则限定协议为非传输层协议(ICMP协议),恒为0。使用正斜线(/)隔开起始端口和终止端口,例如:1024/1055表示端口范围为1024`~`1055。 + + * @param {string} [opts.remark] - 防火墙规则的备注, 不超过100个字符 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string firewallId + */ + + modifyFirewallRule (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 modifyFirewallRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyFirewallRule" + ) + } + if (opts.ruleId === undefined || opts.ruleId === null) { + throw new Error( + "Missing the required parameter 'opts.ruleId' when calling modifyFirewallRule" + ) + } + if (opts.sourceAddress === undefined || opts.sourceAddress === null) { + throw new Error( + "Missing the required parameter 'opts.sourceAddress' when calling modifyFirewallRule" + ) + } + if (opts.ruleProtocol === undefined || opts.ruleProtocol === null) { + throw new Error( + "Missing the required parameter 'opts.ruleProtocol' when calling modifyFirewallRule" + ) + } + if (opts.port === undefined || opts.port === null) { + throw new Error( + "Missing the required parameter 'opts.port' when calling modifyFirewallRule" + ) + } + + let postBody = {} + if (opts.instanceId !== undefined && opts.instanceId !== null) { + postBody['instanceId'] = opts.instanceId + } + if (opts.ruleId !== undefined && opts.ruleId !== null) { + postBody['ruleId'] = opts.ruleId + } + if (opts.sourceAddress !== undefined && opts.sourceAddress !== null) { + postBody['sourceAddress'] = opts.sourceAddress + } + if (opts.ruleProtocol !== undefined && opts.ruleProtocol !== null) { + postBody['ruleProtocol'] = opts.ruleProtocol + } + if (opts.port !== undefined && opts.port !== null) { + postBody['port'] = opts.port + } + if (opts.remark !== undefined && opts.remark !== null) { + postBody['remark'] = opts.remark + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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 modifyFirewallRule 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}/firewallRule', + 'PATCH', + 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} opts.ruleId - 防火墙规则ID + + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteFirewallRule (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 deleteFirewallRule" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteFirewallRule" + ) + } + if (opts.ruleId === undefined || opts.ruleId === null) { + throw new Error( + "Missing the required parameter 'opts.ruleId' when calling deleteFirewallRule" + ) + } + + let postBody = null + let queryParams = {} + if (opts.instanceId !== undefined && opts.instanceId !== null) { + queryParams['instanceId'] = opts.instanceId + } + if (opts.ruleId !== undefined && opts.ruleId !== null) { + queryParams['ruleId'] = opts.ruleId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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 deleteFirewallRule 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}/firewallRule', + '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) + } + ) + } + + /** + * DescribeImages 查询指定地域下一个或多个镜像信息Image 模型。 + + * @param {Object} opts - parameters + * @param {string} [opts.imageIds] - 镜像ID, `[\"img-m5s0****29\", \"img-m5s0****30\"]`, json array 字串。 + optional + * @param {string} [opts.imageType] - 镜像类型。 可能取值:system, app, custom, 如果imageIds不传时,此项为必传。 + optional + * @param {string} [opts.platform] - 根据镜像的操作系统发行版查询。 +取值范围:`Ubuntu、CentOS、Windows Server`。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param image images + */ + + describeImages (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 describeImages" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.imageIds !== undefined && opts.imageIds !== null) { + queryParams['imageIds'] = opts.imageIds + } + if (opts.imageType !== undefined && opts.imageType !== null) { + queryParams['imageType'] = opts.imageType + } + if (opts.platform !== undefined && opts.platform !== null) { + queryParams['platform'] = opts.platform + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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 describeImages 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}/images', + '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} opts.imageName - 自定义镜像名称 + + * @param {string} [opts.description] - 镜像描述信息 + optional + * @param {string} [opts.clientToken] - 用于保证请求的幂等性。由客户端生成,并确保不同请求中该参数唯一,长度不能超过64个字符。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string imageId + */ + + createCustomImage (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 createCustomImage" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createCustomImage" + ) + } + if (opts.imageName === undefined || opts.imageName === null) { + throw new Error( + "Missing the required parameter 'opts.imageName' when calling createCustomImage" + ) + } + + let postBody = {} + if (opts.instanceId !== undefined && opts.instanceId !== null) { + postBody['instanceId'] = opts.instanceId + } + if (opts.imageName !== undefined && opts.imageName !== null) { + postBody['imageName'] = opts.imageName + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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 createCustomImage 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}/images', + '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.imageId - 自定义镜像ID + + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteCustomImage (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 deleteCustomImage" + ) + } + + opts = opts || {} + + if (opts.imageId === undefined || opts.imageId === null) { + throw new Error( + "Missing the required parameter 'opts.imageId' when calling deleteCustomImage" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + imageId: opts.imageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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 deleteCustomImage 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}/images/{imageId}', + '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) + } + ) + } + + /** + * 修改镜像属性。 +详细操作说明请参考帮助文档:[镜像概述](https://docs.jdcloud.com/cn/virtual-machines/image-overview) +## 接口说明 +- 只支持修改镜像名称或描述。 + + * @param {Object} opts - parameters + * @param {string} opts.imageId - 自定义镜像ID + * @param {string} [opts.name] - 镜像名称。参考 [公共参数规范](https://docs.jdcloud.com/virtual-machines/api/general_parameters)。 optional + * @param {string} [opts.description] - 镜像描述。参考 [公共参数规范](https://docs.jdcloud.com/virtual-machines/api/general_parameters)。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyImageAttribute (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 modifyImageAttribute" + ) + } + + opts = opts || {} + + if (opts.imageId === undefined || opts.imageId === null) { + throw new Error( + "Missing the required parameter 'opts.imageId' when calling modifyImageAttribute" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + imageId: opts.imageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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 modifyImageAttribute 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}/images/{imageId}:modifyImageAttribute', + '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.instanceIds] - 轻量应用云主机的实例ID, `[\"lavm-xxx\", \"lavm-yyy\"]`, json array 字串 + optional + * @param {string} [opts.chargeType] - 实例的计费方式, 目前只支持且默认值prepaid_by_duration, 包年包月, + optional + * @param {string} [opts.publicIpAddresses] - 轻量应用云主机的公网IP, 例如: `[\"114.1.x.y\", \"114.2.x.z\"]`, json array 字串 + optional + * @param {string} [opts.names] - 轻量应用云主机的实例名称, 支持模糊搜索, 例如: `[\"instanceName-1\", \"instanceName-2\"]`, json array 字串 + optional + * @param {integer} [opts.pageNumber] - 页码;默认为1。 optional + * @param {integer} [opts.pageSize] - 分页大小;<br>默认为20;取值范围[10, 100]。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instance instances + * @param integer totalCount 本次查询可匹配到的总记录数,使用者需要结合 `pageNumber` 和 `pageSize` 计算是否可以继续分页。 + */ + + 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.instanceIds !== undefined && opts.instanceIds !== null) { + queryParams['instanceIds'] = opts.instanceIds + } + if (opts.chargeType !== undefined && opts.chargeType !== null) { + queryParams['chargeType'] = opts.chargeType + } + if ( + opts.publicIpAddresses !== undefined && + opts.publicIpAddresses !== null + ) { + queryParams['publicIpAddresses'] = opts.publicIpAddresses + } + if (opts.names !== undefined && opts.names !== null) { + queryParams['names'] = opts.names + } + 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 + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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}/instances', + '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.imageId - 镜像ID + + * @param {string} opts.planId - 套餐ID + + * @param {string} [opts.chargeUnit] - 购买资源的时长单位,取值为"day"或"month",默认按月"month" + optional + * @param {integer} opts.period - 购买资源的时长, 默认按月计ChargeUnit="month"。ChargeUnit="month"时,取值1到9,12,24,36个月,即{1-9,12,24,36};ChargeUnit="day"时,取值1到30天,即{1-30} + + * @param {boolean} [opts.autoRenew] - 是否开启到期自动续费 + optional + * @param {integer} [opts.amount] - 创建轻量应用云主机的数量 + optional + * @param {string} [opts.name] - 实例名称。长度最长128个字符,只允许中文、数字、大小写字母、英文下划线(\_)、连字符(-)及点(.),不能以(.)作为首尾。 + optional + * @param {string} [opts.chargeType] - 计费方式。取值:prepaid_by_duration, 目前仅支持包年包月计费方式。 + optional + * @param {string} [opts.clientToken] - 用于保证请求的幂等性。由客户端生成,并确保不同请求中该参数唯一,长度不能超过64个字符。 + optional + * @param {string} [opts.password] - 实例密码。可用于SSH登录和VNC登录。长度为8\~30个字符,必须同时包含大、小写英文字母、数字和特殊符号中的三类字符。特殊符号包括:\(\)\`~!@#$%^&\*\_-+=\|{}\[ ]:";'<>,.?/, +如指定密钥,则密码不会生成注入,否则即使不指定密码系统也将默认自动生成随机密码,并以短信和邮件通知。 + optional + * @param {array} [opts.keyNames] - 密钥对名称。仅Linux系统下该参数生效,当前仅支持输入单个密钥。 + optional + * @param {string} [opts.passwordAuth] - 密码授权,若存在密匙,则根据此参数决定是否使用密码,若没有密匙,此参数无效,会强制使用密码。 +若不使用密码,且密匙对解绑后,用户需重置密码,方可使用密码登录。 +此参数在windows系统中必须为yes。 + optional + * @param {string} [opts.buyScenario] - 产品线统一活动凭证JSON字符串,需要BASE64编码,目前要求编码前格式为 {"activity":{"activityType":必填字段, "activityIdentifier":必填字段}} optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string 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.imageId === undefined || opts.imageId === null) { + throw new Error( + "Missing the required parameter 'opts.imageId' when calling createInstances" + ) + } + if (opts.planId === undefined || opts.planId === null) { + throw new Error( + "Missing the required parameter 'opts.planId' when calling createInstances" + ) + } + if (opts.period === undefined || opts.period === null) { + throw new Error( + "Missing the required parameter 'opts.period' when calling createInstances" + ) + } + + let postBody = {} + if (opts.imageId !== undefined && opts.imageId !== null) { + postBody['imageId'] = opts.imageId + } + if (opts.planId !== undefined && opts.planId !== null) { + postBody['planId'] = opts.planId + } + if (opts.chargeUnit !== undefined && opts.chargeUnit !== null) { + postBody['chargeUnit'] = opts.chargeUnit + } + if (opts.period !== undefined && opts.period !== null) { + postBody['period'] = opts.period + } + if (opts.autoRenew !== undefined && opts.autoRenew !== null) { + postBody['autoRenew'] = opts.autoRenew + } + if (opts.amount !== undefined && opts.amount !== null) { + postBody['amount'] = opts.amount + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.chargeType !== undefined && opts.chargeType !== null) { + postBody['chargeType'] = opts.chargeType + } + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.password !== undefined && opts.password !== null) { + postBody['password'] = opts.password + } + if (opts.keyNames !== undefined && opts.keyNames !== null) { + postBody['keyNames'] = opts.keyNames + } + if (opts.passwordAuth !== undefined && opts.passwordAuth !== null) { + postBody['passwordAuth'] = opts.passwordAuth + } + if (opts.buyScenario !== undefined && opts.buyScenario !== null) { + postBody['buyScenario'] = opts.buyScenario + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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}/instances', + '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 - 轻量应用云主机的实例ID + + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + 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 = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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}/instances/{instanceId}: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.instanceId - 轻量应用云主机的实例ID + + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + 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 = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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}/instances/{instanceId}: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.instanceId - 轻量应用云主机的实例ID + + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + rebootInstance (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 rebootInstance" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling rebootInstance" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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 rebootInstance 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}/instances/{instanceId}:rebootInstance', + '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) + } + ) + } + + /** + * 获取lavm 实例,vnc url + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 轻量应用云主机的实例ID + + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string vncUrl lavm实例的vnc url + */ + + describeInstanceVncUrl (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 describeInstanceVncUrl" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeInstanceVncUrl" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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 describeInstanceVncUrl 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}/instances/{instanceId}/vnc', + '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} [opts.imageId] - 目标镜像ID + optional + * @param {array} [opts.keyNames] - 密钥对名称。仅Linux系统下该参数生效,当前仅支持输入单个密钥。 + optional + * @param {string} [opts.password] - 密码 + optional + * @param {string} [opts.passwordAuth] - 密码授权,若存在密匙,则根据此参数决定是否使用密码,若没有密匙,此参数无效,会强制使用密码。 +若不使用密码,且密匙对解绑后,用户需重置密码,方可使用密码登录。 +此参数在windows系统中必须为yes。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + resetSystem (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 resetSystem" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling resetSystem" + ) + } + + let postBody = {} + if (opts.imageId !== undefined && opts.imageId !== null) { + postBody['imageId'] = opts.imageId + } + if (opts.keyNames !== undefined && opts.keyNames !== null) { + postBody['keyNames'] = opts.keyNames + } + if (opts.password !== undefined && opts.password !== null) { + postBody['password'] = opts.password + } + if (opts.passwordAuth !== undefined && opts.passwordAuth !== null) { + postBody['passwordAuth'] = opts.passwordAuth + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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 resetSystem 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}/instances/{instanceId}:resetSystem', + '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 - 轻量应用云主机的实例ID + + * @param {string} [opts.password] - 新的服务器密码 + optional + * @param {string} [opts.instanceName] - 服务器名称 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateInstanceAttribute (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 updateInstanceAttribute" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling updateInstanceAttribute" + ) + } + + let postBody = {} + if (opts.password !== undefined && opts.password !== null) { + postBody['password'] = opts.password + } + if (opts.instanceName !== undefined && opts.instanceName !== null) { + postBody['instanceName'] = opts.instanceName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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 updateInstanceAttribute 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}/instances/{instanceId}:updateInstanceAttribute', + '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 - 轻量应用云主机的实例ID + + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param plan plans + */ + + describePlansCanUpgrade (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 describePlansCanUpgrade" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describePlansCanUpgrade" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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 describePlansCanUpgrade 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}/instances/{instanceId}:describePlansCanUpgrade', + '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} opts.planId - 轻量应用云主机方案ID + + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + upgradeInstance (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 upgradeInstance" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling upgradeInstance" + ) + } + if (opts.planId === undefined || opts.planId === null) { + throw new Error( + "Missing the required parameter 'opts.planId' when calling upgradeInstance" + ) + } + + let postBody = {} + if (opts.planId !== undefined && opts.planId !== null) { + postBody['planId'] = opts.planId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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 upgradeInstance 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}/instances/{instanceId}:upgradeInstance', + '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 - 轻量应用云主机的实例ID + + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instance instance lavm实例详情 + */ + + 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 || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeInstance" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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}/instances/{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.instanceIds] - 轻量应用云主机的实例ID, `["lavm-xxx", "lavm-yyy"]`, json array 字串 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instanceTrafficPackageUsage instanceTrafficPackageUsages + */ + + describeInstancesTrafficPackages ( + 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 describeInstancesTrafficPackages" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + Object.assign( + queryParams, + super.buildArrayParam(opts.instanceIds, 'instanceIds') + ) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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 describeInstancesTrafficPackages 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}/instancesTrafficPackages', + '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 {array} [opts.domainNames] - 域名名称,最多20个,例如: `[\"name-1\", \"name-2\"]`, json array 字串。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + associateDomains (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 associateDomains" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling associateDomains" + ) + } + + let postBody = {} + if (opts.domainNames !== undefined && opts.domainNames !== null) { + postBody['domainNames'] = opts.domainNames + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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 associateDomains 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}/instances/{instanceId}:associateDomains', + '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 - 轻量云主机的实例ID。 + + * @param {array} [opts.domainNames] - 域名名称,最多20个,例如: `[\"name-1\", \"name-2\"]`, json array 字串。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + disassociateDomains (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 disassociateDomains" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling disassociateDomains" + ) + } + + let postBody = {} + if (opts.domainNames !== undefined && opts.domainNames !== null) { + postBody['domainNames'] = opts.domainNames + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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 disassociateDomains 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}/instances/{instanceId}:disassociateDomains', + '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.domainNames] - 域名名称。支持模糊搜索,最多20个,例如: `[\"name-1\", \"name-2\"]`, json array 字串。 + optional + * @param {integer} [opts.pageNumber] - 页码;默认为1。 optional + * @param {integer} [opts.pageSize] - 分页大小;<br>默认为20;取值范围[10, 100]。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instanceDomain domains + * @param integer totalCount 本次查询可匹配到的总记录数,使用者需要结合 `pageNumber` 和 `pageSize` 计算是否可以继续分页。 + */ + + describeDomains (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 describeDomains" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.domainNames !== undefined && opts.domainNames !== null) { + queryParams['domainNames'] = opts.domainNames + } + 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 + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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 describeDomains 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}/instanceDomains', + '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) + } + ) + } + + /** + * +批量查询密钥对。 + +详细操作说明请参考帮助文档:[密钥概述](https://docs.jdcloud.com/cn/virtual-machines/keypair-overview) + +## 接口说明 +- 使用 `filters` 过滤器进行条件筛选,每个 `filter` 之间的关系为逻辑与(AND)的关系。 +- 单次查询最大可查询100条密钥数据。 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1。 optional + * @param {integer} [opts.pageSize] - 分页大小;<br>默认为20;取值范围[10, 100]。 optional + * @param {filter} [opts.filters] - <b>filters 中支持使用以下关键字进行过滤</b> +`keyNames`: 密钥对名称,精确匹配,支持多个。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param keypair keypairs + * @param number totalCount 本次查询可匹配到的总记录数,使用者需要结合 `pageNumber` 和 `pageSize` 计算是否可以继续分页。 + */ + + describeKeypairs (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 describeKeypairs" + ) + } + + 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 lavm/1.3.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 describeKeypairs 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}/keypairs', + '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) + } + ) + } + + /** + * +创建密钥。 + +公钥和私钥都由京东云生成,公钥保存在京东云,私钥返回给用户,由用户保存。 + +详细操作说明请参考帮助文档:[创建密钥](https://docs.jdcloud.com/cn/virtual-machines/create-keypair) + +## 接口说明 +- 调用该接口创建密钥后,公钥部分存储在京东云,并返回未加密的 `PEM` 编码的 `PKCS#8` 格式私钥,您只有一次机会保存您的私钥。请妥善保管。 + + * @param {Object} opts - parameters + * @param {string} opts.keyName - 密钥对名称,需要全局唯一。 +只允许数字、大小写字母、下划线“_”及中划线“-”,不超过32个字符。 + + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string keyName 密钥对名称。 + * @param string serviceCode 产品线。 + * @param string privateKey 密钥对的私钥部分,`PEM PKCS#8` 格式。 + * @param string keyFingerprint 密钥对的指纹,根据 `RFC4716` 定义的公钥指纹格式,采用 `MD5` 信息摘要算法。 + */ + + createKeypair (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 createKeypair" + ) + } + + opts = opts || {} + + if (opts.keyName === undefined || opts.keyName === null) { + throw new Error( + "Missing the required parameter 'opts.keyName' when calling createKeypair" + ) + } + + let postBody = {} + if (opts.keyName !== undefined && opts.keyName !== null) { + postBody['keyName'] = opts.keyName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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 createKeypair 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}/keypairs', + '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) + } + ) + } + + /** + * +导入密钥。 + +与创建密钥不同的是,导入的密钥是由用户生成的。生成之后将公钥部分导入到京东云。 + +详细操作说明请参考帮助文档:[创建密钥](https://docs.jdcloud.com/cn/virtual-machines/create-keypair) + +## 接口说明 +- 调用该接口导入由其他工具生成的密钥对的公钥部分。 + + * @param {Object} opts - parameters + * @param {string} opts.keyName - 密钥对名称,需要全局唯一。 +只允许数字、大小写字母、下划线“_”及中划线“-”,不超过32个字符。 + + * @param {string} opts.publicKey - 密钥对的公钥部分。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string keyName 密钥对名称。 + * @param string keyFingerprint 密钥对的指纹,根据 `RFC4716` 定义的公钥指纹格式,采用 `MD5` 信息摘要算法。 + */ + + importKeypair (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 importKeypair" + ) + } + + opts = opts || {} + + if (opts.keyName === undefined || opts.keyName === null) { + throw new Error( + "Missing the required parameter 'opts.keyName' when calling importKeypair" + ) + } + if (opts.publicKey === undefined || opts.publicKey === null) { + throw new Error( + "Missing the required parameter 'opts.publicKey' when calling importKeypair" + ) + } + + let postBody = {} + if (opts.keyName !== undefined && opts.keyName !== null) { + postBody['keyName'] = opts.keyName + } + if (opts.publicKey !== undefined && opts.publicKey !== null) { + postBody['publicKey'] = opts.publicKey + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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 importKeypair 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}/keypairs:import', + '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) + } + ) + } + + /** + * +删除密钥。 + +详细操作说明请参考帮助文档:[删除密钥](https://docs.jdcloud.com/cn/virtual-machines/delete-keypair) + +## 接口说明 +- 密钥删除后,使用该密钥的实例仍可正常使用与之匹配的本地私钥登录,且密钥仍会显示在实例详情中。 +- 密钥删除后,与之关联的实例模板将变为不可用,并且与该实例模板关联的高可用组也会变为不可用。 + + * @param {Object} opts - parameters + * @param {string} opts.keyName - 密钥名称。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteKeypair (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 deleteKeypair" + ) + } + + opts = opts || {} + + if (opts.keyName === undefined || opts.keyName === null) { + throw new Error( + "Missing the required parameter 'opts.keyName' when calling deleteKeypair" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + keyName: opts.keyName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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 deleteKeypair 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}/keypairs/{keyName}', + '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) + } + ) + } + + /** + * +为云主机实例绑定密钥。 + +详细操作说明请参考帮助文档:[绑定密钥](https://docs.jdcloud.com/cn/virtual-machines/bind-keypair) + +## 接口说明 +- 只支持为 linux 云主机实例绑定密钥。 +- 每台云主机实例只支持绑定一个密钥。如果云主机绑定的密钥被删除了,那么该云主机还可以再次绑定密钥。 + + * @param {Object} opts - parameters + * @param {string} opts.keyName - 密钥名称。 + * @param {array} [opts.instanceIds] - 要绑定的云主机Id列表。 optional + * @param {string} opts.passwordAuth - 绑定密钥后,根据此参数决定是否允许使用密码登录。可选范围: +`yes`:允许SSH密码登录。 +`no`:禁止SSH密码登录。 + + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string successInstanceId + * @param string failInstanceId + */ + + attachKeypair (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 attachKeypair" + ) + } + + opts = opts || {} + + if (opts.keyName === undefined || opts.keyName === null) { + throw new Error( + "Missing the required parameter 'opts.keyName' when calling attachKeypair" + ) + } + if (opts.passwordAuth === undefined || opts.passwordAuth === null) { + throw new Error( + "Missing the required parameter 'opts.passwordAuth' when calling attachKeypair" + ) + } + + let postBody = {} + if (opts.instanceIds !== undefined && opts.instanceIds !== null) { + postBody['instanceIds'] = opts.instanceIds + } + if (opts.passwordAuth !== undefined && opts.passwordAuth !== null) { + postBody['passwordAuth'] = opts.passwordAuth + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + keyName: opts.keyName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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 attachKeypair 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}/keypairs/{keyName}:attach', + '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) + } + ) + } + + /** + * +为云主机实例解绑密钥。 + +详细操作说明请参考帮助文档:[绑定密钥](https://docs.jdcloud.com/cn/virtual-machines/bind-keypair) + +## 接口说明 +- 调用该接口解绑云主机实例中的密钥。 + + * @param {Object} opts - parameters + * @param {string} opts.keyName - 密钥名称。 + * @param {array} [opts.instanceIds] - 要解绑的云主机实例ID列表。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string successInstanceId + * @param string failInstanceId + */ + + detachKeypair (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 detachKeypair" + ) + } + + opts = opts || {} + + if (opts.keyName === undefined || opts.keyName === null) { + throw new Error( + "Missing the required parameter 'opts.keyName' when calling detachKeypair" + ) + } + + let postBody = {} + if (opts.instanceIds !== undefined && opts.instanceIds !== null) { + postBody['instanceIds'] = opts.instanceIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + keyName: opts.keyName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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 detachKeypair 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}/keypairs/{keyName}:detach', + '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.classification] - 套餐分类:通用型套餐(字段:universal)、存储型套餐(字段:storage)、企业型套餐(字段:enterprise) + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param plan plans + */ + + describePlans (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 describePlans" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.classification !== undefined && opts.classification !== null) { + queryParams['classification'] = opts.classification + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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 describePlans 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}/plans', + '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.planIds - 方案Ids, jsonArray的string 例如 `[\"plan-id1\", \"plan-id2\"]` + + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param object statusMap 方案是否售罄map + key: planId, value: true 售罄 , false 可售 + + */ + + describePlansSoldOutStatus (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 describePlansSoldOutStatus" + ) + } + + opts = opts || {} + + if (opts.planIds === undefined || opts.planIds === null) { + throw new Error( + "Missing the required parameter 'opts.planIds' when calling describePlansSoldOutStatus" + ) + } + + let postBody = null + let queryParams = {} + if (opts.planIds !== undefined && opts.planIds !== null) { + queryParams['planIds'] = opts.planIds + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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 describePlansSoldOutStatus 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}/describePlansSoldOutStatus', + '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 {array} [opts.resourceTypes] - 资源名列表,可取值: +general_instance 通用型套餐实例 +custom_image 自定义镜像 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param quota quotas + */ + + queryQuota (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 queryQuota" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.resourceTypes !== undefined && opts.resourceTypes !== null) { + postBody['resourceTypes'] = opts.resourceTypes + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lavm/1.3.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 queryQuota 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}/quotas', + '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 = LAVM diff --git a/packages/libs/lib-jdcloud/src/repo/lb/v1/lb.js b/packages/libs/lib-jdcloud/src/repo/lb/v1/lb.js new file mode 100644 index 000000000..89533ad39 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/lb/v1/lb.js @@ -0,0 +1,7219 @@ +/* + * 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. + * + * Forwarding-Rules-Group + * 转发规则组相关接口 + * + * 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 = 'lb' +Service._services[serviceId] = true + +/** + * lb service. + * @version 0.6.6 + */ + +class LB extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'lb.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询后端服务列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞), 页码超过总页数时, 显示最后一页 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {filter} [opts.filters] - backendIds - 后端服务Id列表,支持多个 +backendNames - 后端服务名字列表,支持多个 +loadBalancerId - 负载均衡器Id,支持单个 +agId - 可用性组Id,支持单个 +loadBalancerType - 负载均衡类型,取值为:alb、nlb、dnlb,默认alb,支持单个 +protocol - 后端服务的协议【alb】支持Http、Tcp和Udp,【nlb】支持Tcp、Udp,【dnlb】支持Tcp、Udp,默认查询所有,支持单个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param backend backends + * @param integer totalCount 总数量 + */ + + describeBackends (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 describeBackends" + ) + } + + 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 lb/0.6.6' + } + + 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 describeBackends 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}/backends/', + '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.backendName - 后端服务名字,只允许输入中文、数字、大小写字母、英文下划线“_”及中划线“-”,不允许为空且不超过32字符 + * @param {string} opts.loadBalancerId - 后端服务所属负载均衡的Id + * @param {string} opts.protocol - 后端服务的协议 <br>【alb】取值范围:Http、Tcp、Udp <br>【nlb】取值范围:Tcp、Udp <br>【dnlb】取值范围:Tcp、Udp + * @param {integer} opts.port - 后端服务的端口,取值范围为[1, 65535],如指定了TargetSpec中的port,实际按照target指定的port进行转发 + * @param {healthCheckSpec} opts.healthCheckSpec - 健康检查信息 + * @param {string} [opts.algorithm] - 调度算法 <br>【alb,nlb】取值范围为[IpHash, RoundRobin, LeastConn](取值范围的含义:加权源Ip哈希,加权轮询和加权最小连接),alb和nlb默认为加权轮询 <br>【dnlb】取值范围为[IpHash, QuintupleHash](取值范围的含义分别为:加权源Ip哈希和加权五元组哈希),dnlb默认为加权源Ip哈希 optional + * @param {array} [opts.targetGroupIds] - 虚拟服务器组的Id列表,目前只支持一个,且与agIds不能同时存在 optional + * @param {array} [opts.agIds] - 高可用组的Id列表,目前只支持一个,且与targetGroupIds不能同时存在 optional + * @param {array} [opts.agInfoSpec] - 高可用组属性设置:1.defatult_weight:默认权重, 优先级 agInfoSpec > agIds optional + * @param {boolean} [opts.proxyProtocol] - 【alb Tcp、Udp协议】获取真实ip, 取值为False(不获取)或者True(获取,支持Proxy Protocol v1版本),默认为False optional + * @param {string} [opts.description] - 描述,允许输入UTF-8编码下的全部字符,不超过256字符 optional + * @param {boolean} [opts.sessionStickiness] - 会话保持, 取值为false(不开启)或者true(开启),默认为false <br>【alb Http协议,RoundRobin算法】支持基于cookie的会话保持 <br>【nlb】支持基于报文源目的IP的会话保持 optional + * @param {integer} [opts.sessionStickyTimeout] - 【nlb】会话保持超时时间,sessionStickiness开启时生效,默认300s, 取值范围[1-3600] optional + * @param {integer} [opts.connectionDrainingSeconds] - 【nlb】连接耗尽超时。移除target前,连接的最大保持时间,默认300s,取值范围[0-3600] optional + * @param {integer} [opts.httpCookieExpireSeconds] - 【alb Http协议】cookie的过期时间,sessionStickiness开启时生效,取值范围为[0-86400], 默认为0(表示cookie与浏览器同生命周期) optional + * @param {boolean} [opts.httpForwardedProtocol] - 【alb Http协议】获取负载均衡的协议, 取值为False(不获取)或True(获取), 默认为False optional + * @param {boolean} [opts.httpForwardedPort] - 【alb Http协议】获取负载均衡的端口, 取值为False(不获取)或True(获取), 默认为False optional + * @param {boolean} [opts.httpForwardedHost] - 【alb Http协议】获取负载均衡的host信息, 取值为False(不获取)或True(获取), 默认为False optional + * @param {boolean} [opts.httpForwardedVip] - 【alb Http协议】获取负载均衡的vip, 取值为False(不获取)或True(获取), 默认为False optional + * @param {boolean} [opts.httpForwardedClientPort] - 【alb Http协议】获取请求端使用的端口, 取值为False(不获取)或True(获取), 默认为False optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string backendId 后端服务id + */ + + createBackend (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 createBackend" + ) + } + + opts = opts || {} + + if (opts.backendName === undefined || opts.backendName === null) { + throw new Error( + "Missing the required parameter 'opts.backendName' when calling createBackend" + ) + } + if (opts.loadBalancerId === undefined || opts.loadBalancerId === null) { + throw new Error( + "Missing the required parameter 'opts.loadBalancerId' when calling createBackend" + ) + } + if (opts.protocol === undefined || opts.protocol === null) { + throw new Error( + "Missing the required parameter 'opts.protocol' when calling createBackend" + ) + } + if (opts.port === undefined || opts.port === null) { + throw new Error( + "Missing the required parameter 'opts.port' when calling createBackend" + ) + } + if (opts.healthCheckSpec === undefined || opts.healthCheckSpec === null) { + throw new Error( + "Missing the required parameter 'opts.healthCheckSpec' when calling createBackend" + ) + } + + let postBody = {} + if (opts.backendName !== undefined && opts.backendName !== null) { + postBody['backendName'] = opts.backendName + } + if (opts.loadBalancerId !== undefined && opts.loadBalancerId !== null) { + postBody['loadBalancerId'] = opts.loadBalancerId + } + if (opts.protocol !== undefined && opts.protocol !== null) { + postBody['protocol'] = opts.protocol + } + if (opts.port !== undefined && opts.port !== null) { + postBody['port'] = opts.port + } + if (opts.healthCheckSpec !== undefined && opts.healthCheckSpec !== null) { + postBody['healthCheckSpec'] = opts.healthCheckSpec + } + if (opts.algorithm !== undefined && opts.algorithm !== null) { + postBody['algorithm'] = opts.algorithm + } + if (opts.targetGroupIds !== undefined && opts.targetGroupIds !== null) { + postBody['targetGroupIds'] = opts.targetGroupIds + } + if (opts.agIds !== undefined && opts.agIds !== null) { + postBody['agIds'] = opts.agIds + } + if (opts.agInfoSpec !== undefined && opts.agInfoSpec !== null) { + postBody['agInfoSpec'] = opts.agInfoSpec + } + if (opts.proxyProtocol !== undefined && opts.proxyProtocol !== null) { + postBody['proxyProtocol'] = opts.proxyProtocol + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if ( + opts.sessionStickiness !== undefined && + opts.sessionStickiness !== null + ) { + postBody['sessionStickiness'] = opts.sessionStickiness + } + if ( + opts.sessionStickyTimeout !== undefined && + opts.sessionStickyTimeout !== null + ) { + postBody['sessionStickyTimeout'] = opts.sessionStickyTimeout + } + if ( + opts.connectionDrainingSeconds !== undefined && + opts.connectionDrainingSeconds !== null + ) { + postBody['connectionDrainingSeconds'] = opts.connectionDrainingSeconds + } + if ( + opts.httpCookieExpireSeconds !== undefined && + opts.httpCookieExpireSeconds !== null + ) { + postBody['httpCookieExpireSeconds'] = opts.httpCookieExpireSeconds + } + if ( + opts.httpForwardedProtocol !== undefined && + opts.httpForwardedProtocol !== null + ) { + postBody['httpForwardedProtocol'] = opts.httpForwardedProtocol + } + if ( + opts.httpForwardedPort !== undefined && + opts.httpForwardedPort !== null + ) { + postBody['httpForwardedPort'] = opts.httpForwardedPort + } + if ( + opts.httpForwardedHost !== undefined && + opts.httpForwardedHost !== null + ) { + postBody['httpForwardedHost'] = opts.httpForwardedHost + } + if (opts.httpForwardedVip !== undefined && opts.httpForwardedVip !== null) { + postBody['httpForwardedVip'] = opts.httpForwardedVip + } + if ( + opts.httpForwardedClientPort !== undefined && + opts.httpForwardedClientPort !== null + ) { + postBody['httpForwardedClientPort'] = opts.httpForwardedClientPort + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 createBackend 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}/backends/', + '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.backendId - Backend Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param backend backend 后端服务的信息 + */ + + describeBackend (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 describeBackend" + ) + } + + opts = opts || {} + + if (opts.backendId === undefined || opts.backendId === null) { + throw new Error( + "Missing the required parameter 'opts.backendId' when calling describeBackend" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + backendId: opts.backendId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 describeBackend 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}/backends/{backendId}', + '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.backendId - Backend Id + * @param {string} [opts.backendName] - 后端服务名称,只允许输入中文、数字、大小写字母、英文下划线“_”及中划线“-”,不允许为空且不超过32字符 optional + * @param {healthCheckSpec} [opts.healthCheckSpec] - 健康检查信息 optional + * @param {string} [opts.algorithm] - 调度算法 <br>【alb,nlb】取值范围为[IpHash, RoundRobin, LeastConn](含义分别为:加权源Ip哈希,加权轮询和加权最小连接) <br>【dnlb】取值范围为[IpHash, QuintupleHash](含义分别为:加权源Ip哈希和加权五元组哈希) optional + * @param {array} [opts.targetGroupIds] - 虚拟服务器组的Id列表,目前只支持一个,且与agIds不能同时存在 optional + * @param {array} [opts.agIds] - 高可用组的Id列表,目前只支持一个,且与targetGroupIds不能同时存在 optional + * @param {array} [opts.agInfoSpec] - 高可用组属性设置:1.defatult_weight:默认权重, 优先级 agInfoSpec > agIds optional + * @param {boolean} [opts.proxyProtocol] - 【alb Tcp、Udp协议】是否启用Proxy ProtocolV1协议获取真实源ip, 取值为false(不开启)或者true(开启), 默认为false optional + * @param {string} [opts.description] - 描述,允许输入UTF-8编码下的全部字符,不超过256字符 optional + * @param {boolean} [opts.sessionStickiness] - 会话保持, 取值为false(不开启)或者true(开启),默认为false <br>【alb Http协议,RoundRobin算法】支持基于cookie的会话保持 <br>【nlb】支持基于报文源目的IP的会话保持 optional + * @param {integer} [opts.sessionStickyTimeout] - 【nlb】会话保持超时时间,sessionStickiness开启时生效, 取值范围[1-3600] optional + * @param {integer} [opts.connectionDrainingSeconds] - 【nlb】连接耗尽超时,移除target前,连接的最大保持时间,默认300s,取值范围[0-3600] optional + * @param {integer} [opts.httpCookieExpireSeconds] - 【alb Http协议】cookie的过期时间,sessionStickiness开启时生效,取值范围为[0-86400], 0表示cookie与浏览器同生命周期 optional + * @param {boolean} [opts.httpForwardedProtocol] - 【alb Http协议】获取负载均衡的协议, 取值为False(不获取)或True(获取) optional + * @param {boolean} [opts.httpForwardedPort] - 【alb Http协议】获取负载均衡的端口, 取值为False(不获取)或True(获取) optional + * @param {boolean} [opts.httpForwardedHost] - 【alb Http协议】获取负载均衡的host信息, 取值为False(不获取)或True(获取) optional + * @param {boolean} [opts.httpForwardedVip] - 【alb Http协议】获取负载均衡的vip, 取值为False(不获取)或True(获取) optional + * @param {boolean} [opts.httpForwardedClientPort] - 【alb Http协议】获取请求端使用的端口, 取值为False(不获取)或True(获取) optional + * @param {boolean} [opts.closeHealthCheck] - 【alb,dnlb】关闭健康检查,取值为false(不关闭)或true(关闭) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateBackend (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 updateBackend" + ) + } + + opts = opts || {} + + if (opts.backendId === undefined || opts.backendId === null) { + throw new Error( + "Missing the required parameter 'opts.backendId' when calling updateBackend" + ) + } + + let postBody = {} + if (opts.backendName !== undefined && opts.backendName !== null) { + postBody['backendName'] = opts.backendName + } + if (opts.healthCheckSpec !== undefined && opts.healthCheckSpec !== null) { + postBody['healthCheckSpec'] = opts.healthCheckSpec + } + if (opts.algorithm !== undefined && opts.algorithm !== null) { + postBody['algorithm'] = opts.algorithm + } + if (opts.targetGroupIds !== undefined && opts.targetGroupIds !== null) { + postBody['targetGroupIds'] = opts.targetGroupIds + } + if (opts.agIds !== undefined && opts.agIds !== null) { + postBody['agIds'] = opts.agIds + } + if (opts.agInfoSpec !== undefined && opts.agInfoSpec !== null) { + postBody['agInfoSpec'] = opts.agInfoSpec + } + if (opts.proxyProtocol !== undefined && opts.proxyProtocol !== null) { + postBody['proxyProtocol'] = opts.proxyProtocol + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if ( + opts.sessionStickiness !== undefined && + opts.sessionStickiness !== null + ) { + postBody['sessionStickiness'] = opts.sessionStickiness + } + if ( + opts.sessionStickyTimeout !== undefined && + opts.sessionStickyTimeout !== null + ) { + postBody['sessionStickyTimeout'] = opts.sessionStickyTimeout + } + if ( + opts.connectionDrainingSeconds !== undefined && + opts.connectionDrainingSeconds !== null + ) { + postBody['connectionDrainingSeconds'] = opts.connectionDrainingSeconds + } + if ( + opts.httpCookieExpireSeconds !== undefined && + opts.httpCookieExpireSeconds !== null + ) { + postBody['httpCookieExpireSeconds'] = opts.httpCookieExpireSeconds + } + if ( + opts.httpForwardedProtocol !== undefined && + opts.httpForwardedProtocol !== null + ) { + postBody['httpForwardedProtocol'] = opts.httpForwardedProtocol + } + if ( + opts.httpForwardedPort !== undefined && + opts.httpForwardedPort !== null + ) { + postBody['httpForwardedPort'] = opts.httpForwardedPort + } + if ( + opts.httpForwardedHost !== undefined && + opts.httpForwardedHost !== null + ) { + postBody['httpForwardedHost'] = opts.httpForwardedHost + } + if (opts.httpForwardedVip !== undefined && opts.httpForwardedVip !== null) { + postBody['httpForwardedVip'] = opts.httpForwardedVip + } + if ( + opts.httpForwardedClientPort !== undefined && + opts.httpForwardedClientPort !== null + ) { + postBody['httpForwardedClientPort'] = opts.httpForwardedClientPort + } + if (opts.closeHealthCheck !== undefined && opts.closeHealthCheck !== null) { + postBody['closeHealthCheck'] = opts.closeHealthCheck + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + backendId: opts.backendId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 updateBackend 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}/backends/{backendId}', + 'PATCH', + 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.backendId - Backend Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteBackend (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 deleteBackend" + ) + } + + opts = opts || {} + + if (opts.backendId === undefined || opts.backendId === null) { + throw new Error( + "Missing the required parameter 'opts.backendId' when calling deleteBackend" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + backendId: opts.backendId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 deleteBackend 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}/backends/{backendId}', + '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) + } + ) + } + + /** + * 查询后端服务下的target的健康状态 + * @param {Object} opts - parameters + * @param {string} opts.backendId - Backend Id + * @param {integer} [opts.pageNumber] - 页码, 默认为1,取值范围:[1,∞), 页码超过总页数时, 显示最后一页 optional + * @param {integer} [opts.pageSize] - 分页大小,默认返回全部,取值范围:[10,100] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param targetHealth targetHealths + * @param integer totalCount 总数量 + */ + + describeTargetHealth (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 describeTargetHealth" + ) + } + + opts = opts || {} + + if (opts.backendId === undefined || opts.backendId === null) { + throw new Error( + "Missing the required parameter 'opts.backendId' when calling describeTargetHealth" + ) + } + + 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, + backendId: opts.backendId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 describeTargetHealth 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}/backends/{backendId}/health', + '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) + } + ) + } + + /** + * 修改后端服务-高可用组(ag)下target信息 + * @param {Object} opts - parameters + * @param {string} opts.backendId - Backend Id + * @param {array} opts.targetUpdateSpecs - 修改ag target信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateAgTargets (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 updateAgTargets" + ) + } + + opts = opts || {} + + if (opts.backendId === undefined || opts.backendId === null) { + throw new Error( + "Missing the required parameter 'opts.backendId' when calling updateAgTargets" + ) + } + if ( + opts.targetUpdateSpecs === undefined || + opts.targetUpdateSpecs === null + ) { + throw new Error( + "Missing the required parameter 'opts.targetUpdateSpecs' when calling updateAgTargets" + ) + } + + let postBody = {} + if ( + opts.targetUpdateSpecs !== undefined && + opts.targetUpdateSpecs !== null + ) { + postBody['targetUpdateSpecs'] = opts.targetUpdateSpecs + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + backendId: opts.backendId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 updateAgTargets 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}/backends/{backendId}:updateAgTargets', + 'PATCH', + 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) + } + ) + } + + /** + * 查询 后端服务-高可用组 Target列表详情 + * @param {Object} opts - parameters + * @param {string} opts.backendId - Backend Id + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞), 页码超过总页数时, 显示最后一页 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {filter} [opts.filters] - weight - 权重, 支持多个 +targetIds - Target ID列表,支持多个 +instanceId - Instance ID,仅支持单个 +ipAddress - ip地址,仅支持单个 + optional + * @param {sort} [opts.sorts] - createdTime - 默认值,默认按 createdTime 倒序 +weight - 权重值 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param agTarget targets + * @param integer totalCount 总数量 + */ + + describeAgTargets (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 describeAgTargets" + ) + } + + opts = opts || {} + + if (opts.backendId === undefined || opts.backendId === null) { + throw new Error( + "Missing the required parameter 'opts.backendId' when calling describeAgTargets" + ) + } + + 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')) + Object.assign(queryParams, super.buildSortParam(opts.sorts, 'sorts')) + + let pathParams = { + regionId: regionId, + backendId: opts.backendId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 describeAgTargets 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}/backends/{backendId}/agTargets', + '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 {filter} [opts.filters] - customizedConfigurationIds - 个性化配置ID,支持多个 +customizedConfigurationNames - 个性化配置名称,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param customizedConfiguration customizedConfigurations + * @param integer totalCount 总数量 + */ + + describeCustomizedConfigurations ( + 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 describeCustomizedConfigurations" + ) + } + + 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 lb/0.6.6' + } + + 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 describeCustomizedConfigurations 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}/customizedConfigurations/', + '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.customizedConfigurationName - 个性化配置名称,只允许输入中文、数字、大小写字母、英文下划线“_”及中划线“-”,不允许为空且不超过32字符 + * @param {string} [opts.description] - 描述,允许输入UTF-8编码下的全部字符,不超过256字符 optional + * @param {customizedConfigurationContentSpec} [opts.customizedConfigurationContent] - 个性化配置内容 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string customizedConfigurationId 个性化配置Id + */ + + createCustomizedConfiguration ( + 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 createCustomizedConfiguration" + ) + } + + opts = opts || {} + + if ( + opts.customizedConfigurationName === undefined || + opts.customizedConfigurationName === null + ) { + throw new Error( + "Missing the required parameter 'opts.customizedConfigurationName' when calling createCustomizedConfiguration" + ) + } + + let postBody = {} + if ( + opts.customizedConfigurationName !== undefined && + opts.customizedConfigurationName !== null + ) { + postBody['customizedConfigurationName'] = opts.customizedConfigurationName + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if ( + opts.customizedConfigurationContent !== undefined && + opts.customizedConfigurationContent !== null + ) { + postBody['customizedConfigurationContent'] = + opts.customizedConfigurationContent + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 createCustomizedConfiguration 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}/customizedConfigurations/', + '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.customizedConfigurationId - Customized Configuration Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param customizedConfiguration customizedConfiguration 个性化配置资源信息 + */ + + describeCustomizedConfiguration ( + 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 describeCustomizedConfiguration" + ) + } + + opts = opts || {} + + if ( + opts.customizedConfigurationId === undefined || + opts.customizedConfigurationId === null + ) { + throw new Error( + "Missing the required parameter 'opts.customizedConfigurationId' when calling describeCustomizedConfiguration" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + customizedConfigurationId: opts.customizedConfigurationId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 describeCustomizedConfiguration 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}/customizedConfigurations/{customizedConfigurationId}', + '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.customizedConfigurationId - Customized Configuration Id + * @param {string} [opts.customizedConfigurationName] - 个性化配置名称,只允许输入中文、数字、大小写字母、英文下划线“_”及中划线“-”,不允许为空且不超过32字符 optional + * @param {string} [opts.description] - 描述,允许输入UTF-8编码下的全部字符,不超过256字符 optional + * @param {customizedConfigurationContentSpec} [opts.customizedConfigurationContent] - 个性化配置内容 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateCustomizedConfiguration ( + 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 updateCustomizedConfiguration" + ) + } + + opts = opts || {} + + if ( + opts.customizedConfigurationId === undefined || + opts.customizedConfigurationId === null + ) { + throw new Error( + "Missing the required parameter 'opts.customizedConfigurationId' when calling updateCustomizedConfiguration" + ) + } + + let postBody = {} + if ( + opts.customizedConfigurationName !== undefined && + opts.customizedConfigurationName !== null + ) { + postBody['customizedConfigurationName'] = opts.customizedConfigurationName + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if ( + opts.customizedConfigurationContent !== undefined && + opts.customizedConfigurationContent !== null + ) { + postBody['customizedConfigurationContent'] = + opts.customizedConfigurationContent + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + customizedConfigurationId: opts.customizedConfigurationId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 updateCustomizedConfiguration 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}/customizedConfigurations/{customizedConfigurationId}', + 'PATCH', + 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.customizedConfigurationId - Customized Configuration Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteCustomizedConfiguration ( + 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 deleteCustomizedConfiguration" + ) + } + + opts = opts || {} + + if ( + opts.customizedConfigurationId === undefined || + opts.customizedConfigurationId === null + ) { + throw new Error( + "Missing the required parameter 'opts.customizedConfigurationId' when calling deleteCustomizedConfiguration" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + customizedConfigurationId: opts.customizedConfigurationId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 deleteCustomizedConfiguration 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}/customizedConfigurations/{customizedConfigurationId}', + '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.customizedConfigurationId - Customized Configuration Id + * @param {array} opts.resourceIds - 个性化配置要绑定的资源ID列表, 对于已绑定配置的资源需要先解绑 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + associateCustomizedConfiguration ( + 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 associateCustomizedConfiguration" + ) + } + + opts = opts || {} + + if ( + opts.customizedConfigurationId === undefined || + opts.customizedConfigurationId === null + ) { + throw new Error( + "Missing the required parameter 'opts.customizedConfigurationId' when calling associateCustomizedConfiguration" + ) + } + if (opts.resourceIds === undefined || opts.resourceIds === null) { + throw new Error( + "Missing the required parameter 'opts.resourceIds' when calling associateCustomizedConfiguration" + ) + } + + let postBody = {} + if (opts.resourceIds !== undefined && opts.resourceIds !== null) { + postBody['resourceIds'] = opts.resourceIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + customizedConfigurationId: opts.customizedConfigurationId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 associateCustomizedConfiguration 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}/customizedConfigurations/{customizedConfigurationId}:associateCustomizedConfiguration', + '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.customizedConfigurationId - Customized Configuration Id + * @param {array} opts.resourceIds - 个性化配置要解绑的资源ID列表 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + disassociateCustomizedConfiguration ( + 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 disassociateCustomizedConfiguration" + ) + } + + opts = opts || {} + + if ( + opts.customizedConfigurationId === undefined || + opts.customizedConfigurationId === null + ) { + throw new Error( + "Missing the required parameter 'opts.customizedConfigurationId' when calling disassociateCustomizedConfiguration" + ) + } + if (opts.resourceIds === undefined || opts.resourceIds === null) { + throw new Error( + "Missing the required parameter 'opts.resourceIds' when calling disassociateCustomizedConfiguration" + ) + } + + let postBody = {} + if (opts.resourceIds !== undefined && opts.resourceIds !== null) { + postBody['resourceIds'] = opts.resourceIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + customizedConfigurationId: opts.customizedConfigurationId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 disassociateCustomizedConfiguration 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}/customizedConfigurations/{customizedConfigurationId}:disassociateCustomizedConfiguration', + '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.pageNumber] - 页码, 默认为1, 取值范围:[1,∞), 页码超过总页数时, 显示最后一页 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {filter} [opts.filters] - listenerNames - 监听器名称列表,支持多个 +listenerIds - 监听器Id列表,支持多个 +loadBalancerId - 负载均衡器Id,支持单个 +loadBalancerType - 负载均衡类型,取值为:alb、nlb、dnlb,默认alb,支持单个 +urlMapIds - 【仅alb支持】转发规则组Id列表,支持多个 +securityPolicyIds - 监听器绑定的安全策略ID,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param listener listeners + * @param integer totalCount 总数量 + */ + + describeListeners (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 describeListeners" + ) + } + + 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 lb/0.6.6' + } + + 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 describeListeners 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}/listeners/', + '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.listenerName - Listener的名字,只允许输入中文、数字、大小写字母、英文下划线“_”及中划线“-”,不允许为空且不超过32字符 + * @param {string} opts.protocol - 监听协议, 取值为Tcp, Tls, Http, Https, Udp <br>【alb】支持Http, Https,Tcp、Tls和Udp <br>【nlb】支持Tcp, Udp <br>【dnlb】支持Tcp, Udp + * @param {boolean} [opts.hstsEnable] - 【alb使用https时支持】是否开启HSTS,True(开启), False(关闭),缺省为False optional + * @param {integer} [opts.hstsMaxAge] - 【alb使用https时支持】HSTS过期时间(秒),取值范围为[1, 94608000(3年)],缺省为31536000(1年) optional + * @param {integer} opts.port - 监听端口,取值范围为[1, 65535] + * @param {string} opts.backendId - 默认的后端服务Id + * @param {string} opts.loadBalancerId - Listener所属loadBalancer的Id + * @param {string} [opts.urlMapId] - 【alb Https和Http协议】转发规则组Id optional + * @param {string} [opts.action] - 默认后端服务的转发策略,取值为Forward或Redirect, 现只支持Forward, 默认为Forward optional + * @param {array} [opts.certificateSpecs] - 【alb Https和Tls协议】Listener绑定的默认证书,最多支持两个,两个证书的加密算法需要不同 optional + * @param {limitationSpec} [opts.limitation] - 【仅ALB支持】限速配置 optional + * @param {integer} [opts.connectionIdleTimeSeconds] - 【alb、nlb】空闲连接超时时间, 范围为[1,86400]。 <br>(Tcp和Tls协议)默认为:1800s <br>(Udp协议)默认为:300s <br>(Http和Https协议)默认为:60s <br>【dnlb】不支持 optional + * @param {string} [opts.description] - 描述,允许输入UTF-8编码下的全部字符,不超过256字符 optional + * @param {string} [opts.securityPolicyId] - 绑定的安全策略id,仅支持应用负载均衡的HTTPS、TLS监听配置,不传默认使用默认安全策略 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string listenerId 监听器id + */ + + createListener (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 createListener" + ) + } + + opts = opts || {} + + if (opts.listenerName === undefined || opts.listenerName === null) { + throw new Error( + "Missing the required parameter 'opts.listenerName' when calling createListener" + ) + } + if (opts.protocol === undefined || opts.protocol === null) { + throw new Error( + "Missing the required parameter 'opts.protocol' when calling createListener" + ) + } + if (opts.port === undefined || opts.port === null) { + throw new Error( + "Missing the required parameter 'opts.port' when calling createListener" + ) + } + if (opts.backendId === undefined || opts.backendId === null) { + throw new Error( + "Missing the required parameter 'opts.backendId' when calling createListener" + ) + } + if (opts.loadBalancerId === undefined || opts.loadBalancerId === null) { + throw new Error( + "Missing the required parameter 'opts.loadBalancerId' when calling createListener" + ) + } + + let postBody = {} + if (opts.listenerName !== undefined && opts.listenerName !== null) { + postBody['listenerName'] = opts.listenerName + } + if (opts.protocol !== undefined && opts.protocol !== null) { + postBody['protocol'] = opts.protocol + } + if (opts.hstsEnable !== undefined && opts.hstsEnable !== null) { + postBody['hstsEnable'] = opts.hstsEnable + } + if (opts.hstsMaxAge !== undefined && opts.hstsMaxAge !== null) { + postBody['hstsMaxAge'] = opts.hstsMaxAge + } + if (opts.port !== undefined && opts.port !== null) { + postBody['port'] = opts.port + } + if (opts.backendId !== undefined && opts.backendId !== null) { + postBody['backendId'] = opts.backendId + } + if (opts.loadBalancerId !== undefined && opts.loadBalancerId !== null) { + postBody['loadBalancerId'] = opts.loadBalancerId + } + if (opts.urlMapId !== undefined && opts.urlMapId !== null) { + postBody['urlMapId'] = opts.urlMapId + } + if (opts.action !== undefined && opts.action !== null) { + postBody['action'] = opts.action + } + if (opts.certificateSpecs !== undefined && opts.certificateSpecs !== null) { + postBody['certificateSpecs'] = opts.certificateSpecs + } + if (opts.limitation !== undefined && opts.limitation !== null) { + postBody['limitation'] = opts.limitation + } + if ( + opts.connectionIdleTimeSeconds !== undefined && + opts.connectionIdleTimeSeconds !== null + ) { + postBody['connectionIdleTimeSeconds'] = opts.connectionIdleTimeSeconds + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.securityPolicyId !== undefined && opts.securityPolicyId !== null) { + postBody['securityPolicyId'] = opts.securityPolicyId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 createListener 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}/listeners/', + '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.listenerId - 监听器ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param listener listener 监听器的信息 + */ + + describeListener (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 describeListener" + ) + } + + opts = opts || {} + + if (opts.listenerId === undefined || opts.listenerId === null) { + throw new Error( + "Missing the required parameter 'opts.listenerId' when calling describeListener" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + listenerId: opts.listenerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 describeListener 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}/listeners/{listenerId}', + '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.listenerId - 监听器ID + * @param {string} [opts.listenerName] - 监听器名称,只允许输入中文、数字、大小写字母、英文下划线“_”及中划线“-”,不允许为空且不超过32字符 optional + * @param {string} [opts.status] - Listener状态, 取值为On或者为Off optional + * @param {boolean} [opts.hstsEnable] - 【alb使用https时支持】是否开启HSTS,True(开启), False(关闭),缺省为不改变原值 optional + * @param {integer} [opts.hstsMaxAge] - 【alb使用https时支持】HSTS过期时间(秒),取值范围为[1, 94608000(3年)],缺省为不改变原值 optional + * @param {array} [opts.certificateSpecs] - 【alb Https和Tls协议】Listener绑定的默认证书,最多支持两个,两个证书的加密算法需要不同 optional + * @param {limitationSpec} [opts.limitation] - 【仅ALB支持】限速配置 optional + * @param {integer} [opts.connectionIdleTimeSeconds] - 【alb、nlb】空闲连接超时时间, 范围为[1,86400]。 <br>(Tcp和Tls协议)默认为:1800s <br>(Http和Https协议)默认为:60s <br>【dnlb】不支持该功能 optional + * @param {string} [opts.backendId] - 默认后端服务Id optional + * @param {string} [opts.urlMapId] - 【alb Https和Http协议】转发规则组Id optional + * @param {string} [opts.description] - 监听器描述,允许输入UTF-8编码下的全部字符,不超过256字符 optional + * @param {string} [opts.securityPolicyId] - 绑定的安全策略id,仅支持应用负载均衡的HTTPS、TLS监听配置 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateListener (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 updateListener" + ) + } + + opts = opts || {} + + if (opts.listenerId === undefined || opts.listenerId === null) { + throw new Error( + "Missing the required parameter 'opts.listenerId' when calling updateListener" + ) + } + + let postBody = {} + if (opts.listenerName !== undefined && opts.listenerName !== null) { + postBody['listenerName'] = opts.listenerName + } + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + if (opts.hstsEnable !== undefined && opts.hstsEnable !== null) { + postBody['hstsEnable'] = opts.hstsEnable + } + if (opts.hstsMaxAge !== undefined && opts.hstsMaxAge !== null) { + postBody['hstsMaxAge'] = opts.hstsMaxAge + } + if (opts.certificateSpecs !== undefined && opts.certificateSpecs !== null) { + postBody['certificateSpecs'] = opts.certificateSpecs + } + if (opts.limitation !== undefined && opts.limitation !== null) { + postBody['limitation'] = opts.limitation + } + if ( + opts.connectionIdleTimeSeconds !== undefined && + opts.connectionIdleTimeSeconds !== null + ) { + postBody['connectionIdleTimeSeconds'] = opts.connectionIdleTimeSeconds + } + if (opts.backendId !== undefined && opts.backendId !== null) { + postBody['backendId'] = opts.backendId + } + if (opts.urlMapId !== undefined && opts.urlMapId !== null) { + postBody['urlMapId'] = opts.urlMapId + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.securityPolicyId !== undefined && opts.securityPolicyId !== null) { + postBody['securityPolicyId'] = opts.securityPolicyId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + listenerId: opts.listenerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 updateListener 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}/listeners/{listenerId}', + 'PATCH', + 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.listenerId - 监听器ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteListener (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 deleteListener" + ) + } + + opts = opts || {} + + if (opts.listenerId === undefined || opts.listenerId === null) { + throw new Error( + "Missing the required parameter 'opts.listenerId' when calling deleteListener" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + listenerId: opts.listenerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 deleteListener 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}/listeners/{listenerId}', + '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) + } + ) + } + + /** + * listener批量添加扩展证书 + * @param {Object} opts - parameters + * @param {string} opts.listenerId - 监听器ID + * @param {array} [opts.certificates] - 【alb Https和Tls协议】ssl server证书列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + addListenerCertificates (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 addListenerCertificates" + ) + } + + opts = opts || {} + + if (opts.listenerId === undefined || opts.listenerId === null) { + throw new Error( + "Missing the required parameter 'opts.listenerId' when calling addListenerCertificates" + ) + } + + let postBody = {} + if (opts.certificates !== undefined && opts.certificates !== null) { + postBody['certificates'] = opts.certificates + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + listenerId: opts.listenerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 addListenerCertificates 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}/listeners/{listenerId}:addListenerCertificates', + '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) + } + ) + } + + /** + * listener批量修改扩展证书 + * @param {Object} opts - parameters + * @param {string} opts.listenerId - 监听器ID + * @param {array} [opts.certificates] - 【alb Https和Tls协议】Listener绑定的扩展证书列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateListenerCertificates (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 updateListenerCertificates" + ) + } + + opts = opts || {} + + if (opts.listenerId === undefined || opts.listenerId === null) { + throw new Error( + "Missing the required parameter 'opts.listenerId' when calling updateListenerCertificates" + ) + } + + let postBody = {} + if (opts.certificates !== undefined && opts.certificates !== null) { + postBody['certificates'] = opts.certificates + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + listenerId: opts.listenerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 updateListenerCertificates 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}/listeners/{listenerId}:updateListenerCertificates', + '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) + } + ) + } + + /** + * listener批量删除扩展证书 + * @param {Object} opts - parameters + * @param {string} opts.listenerId - 监听器ID + * @param {array} [opts.certificateBindIds] - 【alb Https和Tls协议】扩展证书绑定Id optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteListenerCertificates (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 deleteListenerCertificates" + ) + } + + opts = opts || {} + + if (opts.listenerId === undefined || opts.listenerId === null) { + throw new Error( + "Missing the required parameter 'opts.listenerId' when calling deleteListenerCertificates" + ) + } + + let postBody = {} + if ( + opts.certificateBindIds !== undefined && + opts.certificateBindIds !== null + ) { + postBody['certificateBindIds'] = opts.certificateBindIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + listenerId: opts.listenerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 deleteListenerCertificates 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}/listeners/{listenerId}:deleteListenerCertificates', + '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.pageNumber] - 页码, 默认为1, 取值范围:[1,∞), 页码超过总页数时, 显示最后一页 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {filter} [opts.filters] - loadBalancerType - 负载均衡类型,取值为:alb、nlb、dnlb,默认alb,支持单个 +loadBalancerIds - 负载均衡ID列表,支持多个 +loadBalancerNames - 负载均衡名称列表,支持多个; 支持operator为like的模糊搜索,此时name只能传单个 +vpcId - 负载均衡所在Vpc的Id,支持单个 +azType - 负载均衡az类型,取值:all(全部类型),standard(标准负载均衡),edge(边缘负载均衡),默认all,支持单个 +azs - 可用区,仅支持边缘可用区,支持多个 +privateIpAddresses - 负载均衡的vip地址,支持多个 +ipv6Addresses - 负载均衡的ipv6地址,支持多个 +serviceCodes - 产品唯一掩码,支持多个 +serviceIds - 产品唯一ID,支持多个 +elasticIpAddress - 负载均衡的弹性公网ip地址,支持单个 +targetPrivateIpAddress - 后端target的内网IP地址,支持单个 +customizedConfigurationIds - 负载均衡绑定的个性化配置ID,支持多个 + optional + * @param {tagFilter} [opts.tags] - Tag筛选条件 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param loadBalancer loadBalancers + * @param integer totalCount 总数量 + */ + + describeLoadBalancers (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 describeLoadBalancers" + ) + } + + 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')) + Object.assign(queryParams, super.buildTagFilterParam(opts.tags, 'tags')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 describeLoadBalancers 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}/loadBalancers/', + '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.loadBalancerName - LoadBalancer的名称,只允许输入中文、数字、大小写字母、英文下划线“_”及中划线“-”,不允许为空且不超过32字符 + * @param {string} opts.subnetId - LoadBalancer所属子网的Id + * @param {string} [opts.type] - LoadBalancer的类型,取值:alb、nlb、dnlb,默认为alb optional + * @param {array} [opts.azs] - 【alb,nlb】LoadBalancer所属availability Zone列表,对于alb,nlb是必选参数,可用区个数不能超过2个 <br>【dnlb】中心可用区,dnlb不需要传该参数,全可用区可用;边缘可用区,仅支持传入单可用区 optional + * @param {chargeSpec} [opts.chargeSpec] - 【alb】支持按用量计费,默认为按用量。【nlb】支持按用量计费。【dnlb】支持按配置计费 optional + * @param {elasticIpSpec} [opts.elasticIp] - 负载均衡关联的弹性IP规格 optional + * @param {string} [opts.privateIpAddress] - 指定LoadBalancer的VIP(内网IPv4地址),需要属于指定的子网并且未被占用 optional + * @param {array} [opts.securityGroupIds] - 【alb】 安全组 ID列表 optional + * @param {string} [opts.description] - LoadBalancer的描述信息,允许输入UTF-8编码下的全部字符,不超过256字符 optional + * @param {boolean} [opts.deleteProtection] - 删除保护,取值为True(开启)或False(关闭),默认为False optional + * @param {array} [opts.userTags] - 用户tag 信息 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string loadBalancerId 负载均衡id + */ + + createLoadBalancer (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 createLoadBalancer" + ) + } + + opts = opts || {} + + if (opts.loadBalancerName === undefined || opts.loadBalancerName === null) { + throw new Error( + "Missing the required parameter 'opts.loadBalancerName' when calling createLoadBalancer" + ) + } + if (opts.subnetId === undefined || opts.subnetId === null) { + throw new Error( + "Missing the required parameter 'opts.subnetId' when calling createLoadBalancer" + ) + } + + let postBody = {} + if (opts.loadBalancerName !== undefined && opts.loadBalancerName !== null) { + postBody['loadBalancerName'] = opts.loadBalancerName + } + if (opts.subnetId !== undefined && opts.subnetId !== null) { + postBody['subnetId'] = opts.subnetId + } + if (opts.type !== undefined && opts.type !== null) { + postBody['type'] = opts.type + } + if (opts.azs !== undefined && opts.azs !== null) { + postBody['azs'] = opts.azs + } + if (opts.chargeSpec !== undefined && opts.chargeSpec !== null) { + postBody['chargeSpec'] = opts.chargeSpec + } + if (opts.elasticIp !== undefined && opts.elasticIp !== null) { + postBody['elasticIp'] = opts.elasticIp + } + if (opts.privateIpAddress !== undefined && opts.privateIpAddress !== null) { + postBody['privateIpAddress'] = opts.privateIpAddress + } + if (opts.securityGroupIds !== undefined && opts.securityGroupIds !== null) { + postBody['securityGroupIds'] = opts.securityGroupIds + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.deleteProtection !== undefined && opts.deleteProtection !== null) { + postBody['deleteProtection'] = opts.deleteProtection + } + if (opts.userTags !== undefined && opts.userTags !== null) { + postBody['userTags'] = opts.userTags + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 createLoadBalancer 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}/loadBalancers/', + '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.loadBalancerId - LB ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param loadBalancer loadBalancer 负载均衡的信息 + */ + + describeLoadBalancer (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 describeLoadBalancer" + ) + } + + opts = opts || {} + + if (opts.loadBalancerId === undefined || opts.loadBalancerId === null) { + throw new Error( + "Missing the required parameter 'opts.loadBalancerId' when calling describeLoadBalancer" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + loadBalancerId: opts.loadBalancerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 describeLoadBalancer 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}/loadBalancers/{loadBalancerId}', + '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.loadBalancerId - LB ID + * @param {string} [opts.loadBalancerName] - LoadBalancer的名称,只允许输入中文、数字、大小写字母、英文下划线“_”及中划线“-”,不允许为空且不超过32字符 optional + * @param {string} [opts.action] - 启用或停止LoadBalancer,取值为Start(启用)或Stop(停止) optional + * @param {string} [opts.description] - LoadBalancer的描述信息,允许输入UTF-8编码下的全部字符,不超过256字符 optional + * @param {boolean} [opts.domainEnable] - 是否绑定域名,包括外网和内网,缺省为不改变原值 optional + * @param {boolean} [opts.deleteProtection] - 删除保护,取值为True(开启)或False(关闭),默认为False optional + * @param {string} [opts.privateIpAddress] - 变更loadBalancer的vip地址,新地址只允许是loadBalancer本子网中的空闲ip地址,缺省为不改变原值 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateLoadBalancer (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 updateLoadBalancer" + ) + } + + opts = opts || {} + + if (opts.loadBalancerId === undefined || opts.loadBalancerId === null) { + throw new Error( + "Missing the required parameter 'opts.loadBalancerId' when calling updateLoadBalancer" + ) + } + + let postBody = {} + if (opts.loadBalancerName !== undefined && opts.loadBalancerName !== null) { + postBody['loadBalancerName'] = opts.loadBalancerName + } + if (opts.action !== undefined && opts.action !== null) { + postBody['action'] = opts.action + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.domainEnable !== undefined && opts.domainEnable !== null) { + postBody['domainEnable'] = opts.domainEnable + } + if (opts.deleteProtection !== undefined && opts.deleteProtection !== null) { + postBody['deleteProtection'] = opts.deleteProtection + } + if (opts.privateIpAddress !== undefined && opts.privateIpAddress !== null) { + postBody['privateIpAddress'] = opts.privateIpAddress + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + loadBalancerId: opts.loadBalancerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 updateLoadBalancer 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}/loadBalancers/{loadBalancerId}', + 'PATCH', + 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) + } + ) + } + + /** + * 删除负载均衡,负载均衡下的监听器,转发规则组(仅alb支持),后端服务,服务器组会一起删除 + * @param {Object} opts - parameters + * @param {string} opts.loadBalancerId - LB ID + * @param {boolean} [opts.deleteElasticIp] - 是否打包删除弹性公网IP,取值范围:true、false,默认false。true表示删除负载均衡时打包删除其绑定的弹性公网IP;false表示删除负载均衡时不删除其绑定的弹性公网IP。包年包月和无计费信息的弹性公网IP不支持打包删除 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteLoadBalancer (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 deleteLoadBalancer" + ) + } + + opts = opts || {} + + if (opts.loadBalancerId === undefined || opts.loadBalancerId === null) { + throw new Error( + "Missing the required parameter 'opts.loadBalancerId' when calling deleteLoadBalancer" + ) + } + + let postBody = null + let queryParams = {} + if (opts.deleteElasticIp !== undefined && opts.deleteElasticIp !== null) { + queryParams['deleteElasticIp'] = opts.deleteElasticIp + } + + let pathParams = { + regionId: regionId, + loadBalancerId: opts.loadBalancerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 deleteLoadBalancer 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}/loadBalancers/{loadBalancerId}', + '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.securityGroupId - securityGroup ID + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞), 页码超过总页数时, 显示最后一页 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount 总数量 + * @param loadBalancer loadBalancers + */ + + describeLoadBalancersBySecurityGroup ( + 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 describeLoadBalancersBySecurityGroup" + ) + } + + opts = opts || {} + + if (opts.securityGroupId === undefined || opts.securityGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.securityGroupId' when calling describeLoadBalancersBySecurityGroup" + ) + } + + let postBody = {} + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + securityGroupId: opts.securityGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 describeLoadBalancersBySecurityGroup 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}/loadBalancers/{securityGroupId}:describeLoadBalancersBySecurityGroup', + '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) + } + ) + } + + /** + * 负载均衡绑定弹性公网IP + * @param {Object} opts - parameters + * @param {string} opts.loadBalancerId - LB ID + * @param {string} opts.elasticIpId - 弹性公网IP ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + associateElasticIp (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 associateElasticIp" + ) + } + + opts = opts || {} + + if (opts.loadBalancerId === undefined || opts.loadBalancerId === null) { + throw new Error( + "Missing the required parameter 'opts.loadBalancerId' when calling associateElasticIp" + ) + } + if (opts.elasticIpId === undefined || opts.elasticIpId === null) { + throw new Error( + "Missing the required parameter 'opts.elasticIpId' when calling associateElasticIp" + ) + } + + let postBody = {} + if (opts.elasticIpId !== undefined && opts.elasticIpId !== null) { + postBody['elasticIpId'] = opts.elasticIpId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + loadBalancerId: opts.loadBalancerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 associateElasticIp 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}/loadBalancers/{loadBalancerId}:associateElasticIp', + '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) + } + ) + } + + /** + * 负载均衡解绑弹性公网IP + * @param {Object} opts - parameters + * @param {string} opts.loadBalancerId - LB ID + * @param {string} opts.elasticIpId - 弹性公网IP ID + * @param {boolean} [opts.deleteElasticIp] - 解绑时是否同时删除弹性公网IP,取值范围:true、false,默认false。true表示解绑弹性公网IP时删除该弹性公网IP;false表示解绑弹性公网IP时不删除该弹性公网IP。包年包月和无计费信息的弹性公网IP不支持解绑时删除 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + disassociateElasticIp (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 disassociateElasticIp" + ) + } + + opts = opts || {} + + if (opts.loadBalancerId === undefined || opts.loadBalancerId === null) { + throw new Error( + "Missing the required parameter 'opts.loadBalancerId' when calling disassociateElasticIp" + ) + } + if (opts.elasticIpId === undefined || opts.elasticIpId === null) { + throw new Error( + "Missing the required parameter 'opts.elasticIpId' when calling disassociateElasticIp" + ) + } + + let postBody = {} + if (opts.elasticIpId !== undefined && opts.elasticIpId !== null) { + postBody['elasticIpId'] = opts.elasticIpId + } + if (opts.deleteElasticIp !== undefined && opts.deleteElasticIp !== null) { + postBody['deleteElasticIp'] = opts.deleteElasticIp + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + loadBalancerId: opts.loadBalancerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 disassociateElasticIp 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}/loadBalancers/{loadBalancerId}:disassociateElasticIp', + '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.loadBalancerId - LB ID + * @param {array} [opts.securityGroupIds] - 安全组 ID列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + associateSecurityGroup (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 associateSecurityGroup" + ) + } + + opts = opts || {} + + if (opts.loadBalancerId === undefined || opts.loadBalancerId === null) { + throw new Error( + "Missing the required parameter 'opts.loadBalancerId' when calling associateSecurityGroup" + ) + } + + let postBody = {} + if (opts.securityGroupIds !== undefined && opts.securityGroupIds !== null) { + postBody['securityGroupIds'] = opts.securityGroupIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + loadBalancerId: opts.loadBalancerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 associateSecurityGroup 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}/loadBalancers/{loadBalancerId}:associateSecurityGroup', + '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.loadBalancerId - LB ID + * @param {array} [opts.securityGroupIds] - 安全组 ID列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + disassociateSecurityGroup (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 disassociateSecurityGroup" + ) + } + + opts = opts || {} + + if (opts.loadBalancerId === undefined || opts.loadBalancerId === null) { + throw new Error( + "Missing the required parameter 'opts.loadBalancerId' when calling disassociateSecurityGroup" + ) + } + + let postBody = {} + if (opts.securityGroupIds !== undefined && opts.securityGroupIds !== null) { + postBody['securityGroupIds'] = opts.securityGroupIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + loadBalancerId: opts.loadBalancerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 disassociateSecurityGroup 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}/loadBalancers/{loadBalancerId}:disassociateSecurityGroup', + '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.pageNumber] - 页码, 默认为1, 取值范围:[1,∞), 页码超过总页数时, 显示最后一页 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {filter} [opts.filters] - securityPolicyIds - 安全策略ID,支持多个 +securityPolicyNames - 安全策略名称,支持多个; 支持operator为like的模糊搜索,此时name只能传单个 +securityPolicyType - 安全策略类型(SYSTEM/CUSTOM/ALL),支持单个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param securityPolicy securityPolicies + * @param integer totalCount 总数量 + */ + + describeSecurityPolicies (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 describeSecurityPolicies" + ) + } + + 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 lb/0.6.6' + } + + 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 describeSecurityPolicies 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}/securityPolicies/', + '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.securityPolicyName - 安全策略名称,只允许输入中文、数字、大小写字母、英文下划线“_”及中划线“-”,不允许为空且不超过32字符 + * @param {string} [opts.description] - 安全策略描述,允许输入UTF-8编码下的全部字符,不超过256字符 optional + * @param {array} [opts.protocols] - TLS协议版本列表,目前支持TLSv1、TLSv1.1、TLSv1.2和TLSv1.3,传入的每个protocol至少需要传入一个支持的cipher optional + * @param {array} [opts.ciphers] - TLS加密套件列表,传入的每个cipher至少需要传入一个能够支持的protocol +TLSv1和TLSv1.1支持的加密套件: +AES128-SHA +AES256-SHA +CAMELLIA128-SHA +CAMELLIA256-SHA +DES-CBC3-SHA +ECDHE-RSA-AES128-SHA +ECDHE-RSA-AES256-SHA +ECDHE-RSA-DES-CBC3-SHA +IDEA-CBC-SHA +SEED-SHA +ECDHE-ECDSA-AES256-SHA +ECDHE-ECDSA-AES128-SHA +ECDHE-ECDSA-DES-CBC3-SHA +TLSv1.2支持的加密套件: +AES128-CCM +AES128-CCM8 +AES128-GCM-SHA256 +AES128-SHA +AES128-SHA256 +AES256-CCM +AES256-CCM8 +AES256-GCM-SHA384 +AES256-SHA +AES256-SHA256 +ARIA128-GCM-SHA256 +ARIA256-GCM-SHA384 +CAMELLIA128-SHA +CAMELLIA128-SHA256 +CAMELLIA256-SHA +CAMELLIA256-SHA256 +DES-CBC3-SHA +ECDHE-ARIA128-GCM-SHA256 +ECDHE-ARIA256-GCM-SHA384 +ECDHE-RSA-AES128-GCM-SHA256 +ECDHE-RSA-AES128-SHA +ECDHE-RSA-AES128-SHA256 +ECDHE-RSA-AES256-GCM-SHA384 +ECDHE-RSA-AES256-SHA +ECDHE-RSA-AES256-SHA384 +ECDHE-RSA-CAMELLIA128-SHA256 +ECDHE-RSA-CAMELLIA256-SHA384 +ECDHE-RSA-CHACHA20-POLY1305 +ECDHE-RSA-DES-CBC3-SHA +SEED-SHA +ECDHE-ECDSA-AES256-GCM-SHA384 +ECDHE-ECDSA-CHACHA20-POLY1305 +ECDHE-ECDSA-AES256-CCM8 +ECDHE-ECDSA-AES256-CCM +ECDHE-ECDSA-ARIA256-GCM-SHA384 +ECDHE-ECDSA-AES128-GCM-SHA256 +ECDHE-ECDSA-AES128-CCM8 +ECDHE-ECDSA-AES128-CCM +ECDHE-ECDSA-ARIA128-GCM-SHA256 +ECDHE-ECDSA-AES256-SHA384 +ECDHE-ECDSA-CAMELLIA256-SHA384 +ECDHE-ECDSA-AES128-SHA256 +ECDHE-ECDSA-CAMELLIA128-SHA256 +ECDHE-ECDSA-AES256-SHA +ECDHE-ECDSA-AES128-SHA +ECDHE-ECDSA-DES-CBC3-SHA +TLSv1.3支持的加密套件: +TLS_AES_256_GCM_SHA384 +TLS_CHACHA20_POLY1305_SHA256 +TLS_AES_128_GCM_SHA256 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string securityPolicyId 安全策略Id + */ + + createSecurityPolicy (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 createSecurityPolicy" + ) + } + + opts = opts || {} + + if ( + opts.securityPolicyName === undefined || + opts.securityPolicyName === null + ) { + throw new Error( + "Missing the required parameter 'opts.securityPolicyName' when calling createSecurityPolicy" + ) + } + + let postBody = {} + if ( + opts.securityPolicyName !== undefined && + opts.securityPolicyName !== null + ) { + postBody['securityPolicyName'] = opts.securityPolicyName + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.protocols !== undefined && opts.protocols !== null) { + postBody['protocols'] = opts.protocols + } + if (opts.ciphers !== undefined && opts.ciphers !== null) { + postBody['ciphers'] = opts.ciphers + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 createSecurityPolicy 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}/securityPolicies/', + '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.securityPolicyId - Security Policy Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param securityPolicy securityPolicy 安全策略资源信息 + */ + + describeSecurityPolicy (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 describeSecurityPolicy" + ) + } + + opts = opts || {} + + if (opts.securityPolicyId === undefined || opts.securityPolicyId === null) { + throw new Error( + "Missing the required parameter 'opts.securityPolicyId' when calling describeSecurityPolicy" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + securityPolicyId: opts.securityPolicyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 describeSecurityPolicy 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}/securityPolicies/{securityPolicyId}', + '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.securityPolicyId - Security Policy Id + * @param {string} [opts.securityPolicyName] - 安全策略名称,只允许输入中文、数字、大小写字母、英文下划线“_”及中划线“-”,不允许为空且不超过32字符 optional + * @param {string} [opts.description] - 安全策略描述,允许输入UTF-8编码下的全部字符,不超过256字符 optional + * @param {array} [opts.protocols] - TLS协议版本列表,目前支持TLSv1、TLSv1.1、TLSv1.2和TLSv1.3,传入的每个protocol至少需要传入一个支持的cipher optional + * @param {array} [opts.ciphers] - TLS加密套件列表,传入的每个cipher至少需要传入一个能够支持的protocol +TLSv1和TLSv1.1支持的加密套件: +AES128-SHA +AES256-SHA +CAMELLIA128-SHA +CAMELLIA256-SHA +DES-CBC3-SHA +ECDHE-RSA-AES128-SHA +ECDHE-RSA-AES256-SHA +ECDHE-RSA-DES-CBC3-SHA +IDEA-CBC-SHA +SEED-SHA +ECDHE-ECDSA-AES256-SHA +ECDHE-ECDSA-AES128-SHA +ECDHE-ECDSA-DES-CBC3-SHA +TLSv1.2支持的加密套件: +AES128-CCM +AES128-CCM8 +AES128-GCM-SHA256 +AES128-SHA +AES128-SHA256 +AES256-CCM +AES256-CCM8 +AES256-GCM-SHA384 +AES256-SHA +AES256-SHA256 +ARIA128-GCM-SHA256 +ARIA256-GCM-SHA384 +CAMELLIA128-SHA +CAMELLIA128-SHA256 +CAMELLIA256-SHA +CAMELLIA256-SHA256 +DES-CBC3-SHA +ECDHE-ARIA128-GCM-SHA256 +ECDHE-ARIA256-GCM-SHA384 +ECDHE-RSA-AES128-GCM-SHA256 +ECDHE-RSA-AES128-SHA +ECDHE-RSA-AES128-SHA256 +ECDHE-RSA-AES256-GCM-SHA384 +ECDHE-RSA-AES256-SHA +ECDHE-RSA-AES256-SHA384 +ECDHE-RSA-CAMELLIA128-SHA256 +ECDHE-RSA-CAMELLIA256-SHA384 +ECDHE-RSA-CHACHA20-POLY1305 +ECDHE-RSA-DES-CBC3-SHA +SEED-SHA +ECDHE-ECDSA-AES256-GCM-SHA384 +ECDHE-ECDSA-CHACHA20-POLY1305 +ECDHE-ECDSA-AES256-CCM8 +ECDHE-ECDSA-AES256-CCM +ECDHE-ECDSA-ARIA256-GCM-SHA384 +ECDHE-ECDSA-AES128-GCM-SHA256 +ECDHE-ECDSA-AES128-CCM8 +ECDHE-ECDSA-AES128-CCM +ECDHE-ECDSA-ARIA128-GCM-SHA256 +ECDHE-ECDSA-AES256-SHA384 +ECDHE-ECDSA-CAMELLIA256-SHA384 +ECDHE-ECDSA-AES128-SHA256 +ECDHE-ECDSA-CAMELLIA128-SHA256 +ECDHE-ECDSA-AES256-SHA +ECDHE-ECDSA-AES128-SHA +ECDHE-ECDSA-DES-CBC3-SHA +TLSv1.3支持的加密套件: +TLS_AES_256_GCM_SHA384 +TLS_CHACHA20_POLY1305_SHA256 +TLS_AES_128_GCM_SHA256 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateSecurityPolicy (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 updateSecurityPolicy" + ) + } + + opts = opts || {} + + if (opts.securityPolicyId === undefined || opts.securityPolicyId === null) { + throw new Error( + "Missing the required parameter 'opts.securityPolicyId' when calling updateSecurityPolicy" + ) + } + + let postBody = {} + if ( + opts.securityPolicyName !== undefined && + opts.securityPolicyName !== null + ) { + postBody['securityPolicyName'] = opts.securityPolicyName + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.protocols !== undefined && opts.protocols !== null) { + postBody['protocols'] = opts.protocols + } + if (opts.ciphers !== undefined && opts.ciphers !== null) { + postBody['ciphers'] = opts.ciphers + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + securityPolicyId: opts.securityPolicyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 updateSecurityPolicy 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}/securityPolicies/{securityPolicyId}', + 'PATCH', + 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.securityPolicyId - Security Policy Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteSecurityPolicy (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 deleteSecurityPolicy" + ) + } + + opts = opts || {} + + if (opts.securityPolicyId === undefined || opts.securityPolicyId === null) { + throw new Error( + "Missing the required parameter 'opts.securityPolicyId' when calling deleteSecurityPolicy" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + securityPolicyId: opts.securityPolicyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 deleteSecurityPolicy 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}/securityPolicies/{securityPolicyId}', + '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) + } + ) + } + + /** + * 查询安全策略支持Cipher列表详情 + * @param {Object} opts - parameters + * @param {filter} [opts.filters] - protocols - 安全策略支持的协议,支持多个 +ciphers - 安全策略支持的加密套件,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param supportedCipher supportedCiphers + * @param integer totalCount 总数量 + */ + + describeSupportedCiphers (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 describeSupportedCiphers" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 describeSupportedCiphers 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}/supportedCiphers/', + '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) + } + ) + } + + /** + * 查询虚拟服务器组列表详情,返回target详情功能3个月后将会下线,建议用户直接使用describeTargets接口查询target详情 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞), 页码超过总页数时, 显示最后一页 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {filter} [opts.filters] - targetGroupIds - TargetGroup ID列表,支持多个 +targetGroupNames - TargetGroup名称列表,支持多个 +loadBalancerId - TargetGroup所属负载均衡的Id,支持单个 +loadBalancerType - 负载均衡类型,取值为:alb、nlb、dnlb,默认alb,支持单个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param targetGroup targetGroups + * @param integer totalCount 总数量 + */ + + describeTargetGroups (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 describeTargetGroups" + ) + } + + 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 lb/0.6.6' + } + + 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 describeTargetGroups 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}/targetGroups/', + '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.targetGroupName - 虚拟服务器组名称,只允许输入中文、数字、大小写字母、英文下划线“_”及中划线“-”,不允许为空且不超过32字符 + * @param {string} opts.loadBalancerId - 负载均衡的Id + * @param {string} [opts.description] - 描述,允许输入UTF-8编码下的全部字符,不超过256字符 optional + * @param {string} [opts.type] - 类型,取值为instance或ip optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string targetGroupId 虚拟服务器组Id + */ + + createTargetGroup (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 createTargetGroup" + ) + } + + opts = opts || {} + + if (opts.targetGroupName === undefined || opts.targetGroupName === null) { + throw new Error( + "Missing the required parameter 'opts.targetGroupName' when calling createTargetGroup" + ) + } + if (opts.loadBalancerId === undefined || opts.loadBalancerId === null) { + throw new Error( + "Missing the required parameter 'opts.loadBalancerId' when calling createTargetGroup" + ) + } + + let postBody = {} + if (opts.targetGroupName !== undefined && opts.targetGroupName !== null) { + postBody['targetGroupName'] = opts.targetGroupName + } + if (opts.loadBalancerId !== undefined && opts.loadBalancerId !== null) { + postBody['loadBalancerId'] = opts.loadBalancerId + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.type !== undefined && opts.type !== null) { + postBody['type'] = opts.type + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 createTargetGroup 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}/targetGroups/', + '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) + } + ) + } + + /** + * 查询TargetGroup详情,返回target详情功能3个月后将会下线,建议用户直接使用describeTargets接口查询target详情 + * @param {Object} opts - parameters + * @param {string} opts.targetGroupId - TargetGroup Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param targetGroup targetGroup TargetGroup资源信息 + */ + + describeTargetGroup (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 describeTargetGroup" + ) + } + + opts = opts || {} + + if (opts.targetGroupId === undefined || opts.targetGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.targetGroupId' when calling describeTargetGroup" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + targetGroupId: opts.targetGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 describeTargetGroup 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}/targetGroups/{targetGroupId}', + '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.targetGroupId - TargetGroup Id + * @param {string} [opts.description] - 虚拟服务器组描述,允许输入UTF-8编码下的全部字符,不超过256字符 optional + * @param {string} [opts.targetGroupName] - 虚拟服务器组名称,只允许输入中文、数字、大小写字母、英文下划线“_”及中划线“-”,不允许为空且不超过32字符 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateTargetGroup (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 updateTargetGroup" + ) + } + + opts = opts || {} + + if (opts.targetGroupId === undefined || opts.targetGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.targetGroupId' when calling updateTargetGroup" + ) + } + + let postBody = {} + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.targetGroupName !== undefined && opts.targetGroupName !== null) { + postBody['targetGroupName'] = opts.targetGroupName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + targetGroupId: opts.targetGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 updateTargetGroup 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}/targetGroups/{targetGroupId}', + 'PATCH', + 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.targetGroupId - TargetGroup Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteTargetGroup (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 deleteTargetGroup" + ) + } + + opts = opts || {} + + if (opts.targetGroupId === undefined || opts.targetGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.targetGroupId' when calling deleteTargetGroup" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + targetGroupId: opts.targetGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 deleteTargetGroup 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}/targetGroups/{targetGroupId}', + '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) + } + ) + } + + /** + * 往TargetGroup中加入Target + * @param {Object} opts - parameters + * @param {string} opts.targetGroupId - TargetGroup Id + * @param {array} opts.targetSpecs - 注册Target列表 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + registerTargets (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 registerTargets" + ) + } + + opts = opts || {} + + if (opts.targetGroupId === undefined || opts.targetGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.targetGroupId' when calling registerTargets" + ) + } + if (opts.targetSpecs === undefined || opts.targetSpecs === null) { + throw new Error( + "Missing the required parameter 'opts.targetSpecs' when calling registerTargets" + ) + } + + let postBody = {} + if (opts.targetSpecs !== undefined && opts.targetSpecs !== null) { + postBody['targetSpecs'] = opts.targetSpecs + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + targetGroupId: opts.targetGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 registerTargets 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}/targetGroups/{targetGroupId}:registerTargets', + '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) + } + ) + } + + /** + * 从TargetGroup中移除一个或多个Target,失败则全部回滚。 成功移除的target将不会再接收来自loadbalancer新建连接的流量 + * @param {Object} opts - parameters + * @param {string} opts.targetGroupId - TargetGroup Id + * @param {array} opts.targetIds - Target Id列表 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deRegisterTargets (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 deRegisterTargets" + ) + } + + opts = opts || {} + + if (opts.targetGroupId === undefined || opts.targetGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.targetGroupId' when calling deRegisterTargets" + ) + } + if (opts.targetIds === undefined || opts.targetIds === null) { + throw new Error( + "Missing the required parameter 'opts.targetIds' when calling deRegisterTargets" + ) + } + + let postBody = {} + if (opts.targetIds !== undefined && opts.targetIds !== null) { + postBody['targetIds'] = opts.targetIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + targetGroupId: opts.targetGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 deRegisterTargets 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}/targetGroups/{targetGroupId}:deregisterTargets', + '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) + } + ) + } + + /** + * 修改target信息 + * @param {Object} opts - parameters + * @param {string} opts.targetGroupId - TargetGroup Id + * @param {array} opts.targetUpdateSpecs - 修改target信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateTargets (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 updateTargets" + ) + } + + opts = opts || {} + + if (opts.targetGroupId === undefined || opts.targetGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.targetGroupId' when calling updateTargets" + ) + } + if ( + opts.targetUpdateSpecs === undefined || + opts.targetUpdateSpecs === null + ) { + throw new Error( + "Missing the required parameter 'opts.targetUpdateSpecs' when calling updateTargets" + ) + } + + let postBody = {} + if ( + opts.targetUpdateSpecs !== undefined && + opts.targetUpdateSpecs !== null + ) { + postBody['targetUpdateSpecs'] = opts.targetUpdateSpecs + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + targetGroupId: opts.targetGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 updateTargets 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}/targetGroups/{targetGroupId}:updateTargets', + '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) + } + ) + } + + /** + * 查询Target列表详情 + * @param {Object} opts - parameters + * @param {string} opts.targetGroupId - TargetGroup Id + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞), 页码超过总页数时, 显示最后一页 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {filter} [opts.filters] - targetIds - Target ID列表,支持多个 +instanceId - Instance ID,仅支持单个 +type - vm, container, ip,仅支持单个 +port - 端口,仅支持单个 +ipAddress - ip地址,仅支持单个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param target targets + * @param integer totalCount 总数量 + */ + + describeTargets (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 describeTargets" + ) + } + + opts = opts || {} + + if (opts.targetGroupId === undefined || opts.targetGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.targetGroupId' when calling describeTargets" + ) + } + + 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, + targetGroupId: opts.targetGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 describeTargets 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}/targetGroups/{targetGroupId}:describeTargets', + '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 {filter} [opts.filters] - urlMapIds - 转发规则组Id列表,支持多个 +urlMapNames -转发规则组名称列表,支持多个 +loadBalancerId - 负载均衡器Id,支持单个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param urlMap urlMaps + * @param integer totalCount 总数量 + */ + + describeUrlMaps (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 describeUrlMaps" + ) + } + + 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 lb/0.6.6' + } + + 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 describeUrlMaps 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}/urlMaps/', + '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) + } + ) + } + + /** + * 创建转发规则组,仅alb支持 + * @param {Object} opts - parameters + * @param {string} opts.urlMapName - 转发规则组名称,同一个负载均衡下,名称不能重复,只允许输入中文、数字、大小写字母、英文下划线“_”及中划线“-”,不允许为空且不超过32字符 + * @param {string} opts.loadBalancerId - 转发规则组所属负载均衡的Id + * @param {string} [opts.description] - 描述,允许输入UTF-8编码下的全部字符,不超过256字符 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string urlMapId 转发规则组id + */ + + createUrlMap (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 createUrlMap" + ) + } + + opts = opts || {} + + if (opts.urlMapName === undefined || opts.urlMapName === null) { + throw new Error( + "Missing the required parameter 'opts.urlMapName' when calling createUrlMap" + ) + } + if (opts.loadBalancerId === undefined || opts.loadBalancerId === null) { + throw new Error( + "Missing the required parameter 'opts.loadBalancerId' when calling createUrlMap" + ) + } + + let postBody = {} + if (opts.urlMapName !== undefined && opts.urlMapName !== null) { + postBody['urlMapName'] = opts.urlMapName + } + if (opts.loadBalancerId !== undefined && opts.loadBalancerId !== null) { + postBody['loadBalancerId'] = opts.loadBalancerId + } + 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 lb/0.6.6' + } + + 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 createUrlMap 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}/urlMaps/', + '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.urlMapId - 转发规则组Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param urlMap urlMap 转发规则组的信息 + */ + + describeUrlMap (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 describeUrlMap" + ) + } + + opts = opts || {} + + if (opts.urlMapId === undefined || opts.urlMapId === null) { + throw new Error( + "Missing the required parameter 'opts.urlMapId' when calling describeUrlMap" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + urlMapId: opts.urlMapId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 describeUrlMap 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}/urlMaps/{urlMapId}', + '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.urlMapId - 转发规则组Id + * @param {string} [opts.description] - 转发规则组描述,允许输入UTF-8编码下的全部字符,不超过256字符 optional + * @param {string} [opts.urlMapName] - 转发规则组名称,同一个负载均衡下,名称不能重复,只允许输入中文、数字、大小写字母、英文下划线“_”及中划线“-”,不允许为空且不超过32字符 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateUrlMap (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 updateUrlMap" + ) + } + + opts = opts || {} + + if (opts.urlMapId === undefined || opts.urlMapId === null) { + throw new Error( + "Missing the required parameter 'opts.urlMapId' when calling updateUrlMap" + ) + } + + let postBody = {} + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.urlMapName !== undefined && opts.urlMapName !== null) { + postBody['urlMapName'] = opts.urlMapName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + urlMapId: opts.urlMapId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 updateUrlMap 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}/urlMaps/{urlMapId}', + 'PATCH', + 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.urlMapId - 转发规则组Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteUrlMap (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 deleteUrlMap" + ) + } + + opts = opts || {} + + if (opts.urlMapId === undefined || opts.urlMapId === null) { + throw new Error( + "Missing the required parameter 'opts.urlMapId' when calling deleteUrlMap" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + urlMapId: opts.urlMapId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 deleteUrlMap 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}/urlMaps/{urlMapId}', + '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.urlMapId - 转发规则组Id + * @param {array} [opts.ruleSpecs] - 转发规则的信息 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + addRules (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 addRules" + ) + } + + opts = opts || {} + + if (opts.urlMapId === undefined || opts.urlMapId === null) { + throw new Error( + "Missing the required parameter 'opts.urlMapId' when calling addRules" + ) + } + + let postBody = {} + if (opts.ruleSpecs !== undefined && opts.ruleSpecs !== null) { + postBody['ruleSpecs'] = opts.ruleSpecs + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + urlMapId: opts.urlMapId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 addRules 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}/urlMaps/{urlMapId}:addRules', + '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.urlMapId - 转发规则组Id + * @param {array} [opts.ruleUpdateSpecs] - 更新转发规则rules信息 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateRules (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 updateRules" + ) + } + + opts = opts || {} + + if (opts.urlMapId === undefined || opts.urlMapId === null) { + throw new Error( + "Missing the required parameter 'opts.urlMapId' when calling updateRules" + ) + } + + let postBody = {} + if (opts.ruleUpdateSpecs !== undefined && opts.ruleUpdateSpecs !== null) { + postBody['ruleUpdateSpecs'] = opts.ruleUpdateSpecs + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + urlMapId: opts.urlMapId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 updateRules 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}/urlMaps/{urlMapId}:updateRules', + 'PATCH', + 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.urlMapId - 转发规则组Id + * @param {array} [opts.ruleIds] - rule Id列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteRules (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 deleteRules" + ) + } + + opts = opts || {} + + if (opts.urlMapId === undefined || opts.urlMapId === null) { + throw new Error( + "Missing the required parameter 'opts.urlMapId' when calling deleteRules" + ) + } + + let postBody = {} + if (opts.ruleIds !== undefined && opts.ruleIds !== null) { + postBody['ruleIds'] = opts.ruleIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + urlMapId: opts.urlMapId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 lb/0.6.6' + } + + 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 deleteRules 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}/urlMaps/{urlMapId}:deleteRules', + '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 = LB diff --git a/packages/libs/lib-jdcloud/src/repo/live/v1/live.js b/packages/libs/lib-jdcloud/src/repo/live/v1/live.js new file mode 100644 index 000000000..d6d718798 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/live/v1/live.js @@ -0,0 +1,16459 @@ +/* + * 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. + * + * Live-Video + * 直播管理API + * + * 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 = 'live' +Service._services[serviceId] = true + +/** + * live service. + * @version 1.0.22 + */ + +class LIVE extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'live.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询域名下的APP列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNum] - 页码 +- 取值范围: [1, 100000] + optional + * @param {integer} [opts.pageSize] - 分页大小 +- 取值范围: [10, 100] + optional + * @param {filter} [opts.filters] - 域名下的app列表过滤条件: + - name: publishDomain 直播的推流域名 + - values: 如果参数为空,则查询全部 + - 过滤条件为空,则表示查询用户下的所有应用名 + optional + * @param {string} callback - callback + @return {Object} result + * @param integer pageNumber 当前页码 + * @param integer pageSize 每页数量 + * @param integer totalCount 查询总数 + * @param app apps + */ + + describeLiveApp (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.pageNum !== undefined && opts.pageNum !== null) { + queryParams['pageNum'] = opts.pageNum + } + 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 live/1.0.22' + } + + 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 describeLiveApp 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( + '/apps', + '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) + } + ) + } + + /** + * 添加直播应用名 +- 需要提前在应用(app)级别绑定功能模板时才需要提前新建应用名 +- 新的应用名可以推流时自动创建 + + * @param {Object} opts - parameters + * @param {string} opts.publishDomain - 直播的推流域名 + * @param {string} opts.appName - 应用名称 +- 取值: 数字字母中划线("-")下划线("_") 50个字符以内 + + * @param {string} callback - callback + @return {Object} result + */ + + addLiveApp (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling addLiveApp" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling addLiveApp" + ) + } + + let postBody = {} + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + postBody['publishDomain'] = opts.publishDomain + } + if (opts.appName !== undefined && opts.appName !== null) { + postBody['appName'] = opts.appName + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 addLiveApp 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( + '/apps', + '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.publishDomain - 直播的推流域名 + * @param {string} opts.appName - 应用名称 + * @param {string} callback - callback + @return {Object} result + */ + + stopLiveApp (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling stopLiveApp" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling stopLiveApp" + ) + } + + let postBody = {} + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + postBody['publishDomain'] = opts.publishDomain + } + if (opts.appName !== undefined && opts.appName !== null) { + postBody['appName'] = opts.appName + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 stopLiveApp 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( + '/apps:stop', + '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) + } + ) + } + + /** + * 查询(直播or时移)播放鉴权KEY + * @param {Object} opts - parameters + * @param {string} opts.playDomain - (直播or时移)播放域名 +- 仅支持精确匹配 + + * @param {string} callback - callback + @return {Object} result + * @param string playDomain 播放域名 + * @param string authStatus (直播or时移)播放鉴权状态 + on: 开启 + off: 关闭 + + * @param string authKey (直播or时移)播放鉴权key + */ + + describeLivePlayAuthKey (opts, callback) { + opts = opts || {} + + if (opts.playDomain === undefined || opts.playDomain === null) { + throw new Error( + "Missing the required parameter 'opts.playDomain' when calling describeLivePlayAuthKey" + ) + } + + let postBody = null + let queryParams = {} + if (opts.playDomain !== undefined && opts.playDomain !== null) { + queryParams['playDomain'] = opts.playDomain + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLivePlayAuthKey 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( + '/livePlayAuthKey', + '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) + } + ) + } + + /** + * 设置(直播or时移)播放鉴权KEY + * @param {Object} opts - parameters + * @param {string} opts.playDomain - (直播or时移)播放域名 + * @param {string} [opts.authStatus] - (直播or时移)播放鉴权状态 + on: 开启 + off: 关闭 +- 当播放鉴权状态on(开启)时,authKey不能为空 + optional + * @param {string} [opts.authKey] - (直播or时移)播放鉴权key +- 取值: 支持大小写字母和数字 长度6-32位 + optional + * @param {string} callback - callback + @return {Object} result + */ + + setLivePlayAuthKey (opts, callback) { + opts = opts || {} + + if (opts.playDomain === undefined || opts.playDomain === null) { + throw new Error( + "Missing the required parameter 'opts.playDomain' when calling setLivePlayAuthKey" + ) + } + + let postBody = {} + if (opts.playDomain !== undefined && opts.playDomain !== null) { + postBody['playDomain'] = opts.playDomain + } + if (opts.authStatus !== undefined && opts.authStatus !== null) { + postBody['authStatus'] = opts.authStatus + } + if (opts.authKey !== undefined && opts.authKey !== null) { + postBody['authKey'] = opts.authKey + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 setLivePlayAuthKey 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( + '/livePlayAuthKey', + '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) + } + ) + } + + /** + * 查询直播回看播放鉴权KEY + * @param {Object} opts - parameters + * @param {string} opts.restartDomain - 直播回看播放域名 +- 仅支持精确匹配 + + * @param {string} callback - callback + @return {Object} result + * @param string playDomain 回看播放域名 + * @param string authStatus 回看播放鉴权状态 + on: 开启 + off: 关闭 + + * @param string authKey 回看播放鉴权key + */ + + describeLiveRestartAuthKey (opts, callback) { + opts = opts || {} + + if (opts.restartDomain === undefined || opts.restartDomain === null) { + throw new Error( + "Missing the required parameter 'opts.restartDomain' when calling describeLiveRestartAuthKey" + ) + } + + let postBody = null + let queryParams = {} + if (opts.restartDomain !== undefined && opts.restartDomain !== null) { + queryParams['restartDomain'] = opts.restartDomain + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveRestartAuthKey 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( + '/liveRestartAuthKey', + '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) + } + ) + } + + /** + * 设置直播回看播放鉴权KEY + * @param {Object} opts - parameters + * @param {string} opts.restartDomain - 直播回看播放域名 + * @param {string} [opts.authStatus] - 直播回看播放鉴权状态 + on: 开启 + off: 关闭 +- 当回看播放鉴权状态on(开启)时,authKey不能为空 + optional + * @param {string} [opts.authKey] - 直播回看播放鉴权key +- 取值: 支持大小写字母和数字 长度6-32位 + optional + * @param {string} callback - callback + @return {Object} result + */ + + setLiveRestartAuthKey (opts, callback) { + opts = opts || {} + + if (opts.restartDomain === undefined || opts.restartDomain === null) { + throw new Error( + "Missing the required parameter 'opts.restartDomain' when calling setLiveRestartAuthKey" + ) + } + + let postBody = {} + if (opts.restartDomain !== undefined && opts.restartDomain !== null) { + postBody['restartDomain'] = opts.restartDomain + } + if (opts.authStatus !== undefined && opts.authStatus !== null) { + postBody['authStatus'] = opts.authStatus + } + if (opts.authKey !== undefined && opts.authKey !== null) { + postBody['authKey'] = opts.authKey + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 setLiveRestartAuthKey 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( + '/liveRestartAuthKey', + '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) + } + ) + } + + /** + * 查询直播计费账单用量数据 +允许通过条件过滤查询,支持的过滤字段如下: + - startTime[eq] 账单开始时间 + - endTime[eq] 账单结束时间 + - billType[eq] 账单计费类型 + - userPin[like] 用户PIN + + * @param {Object} opts - parameters + * @param {filter} [opts.filters] - 传参字段描述: + startTime(必填) : 2019-08-21T16:15:10Z + endTime(必填) : 2019-08-21T18:10:10Z + billType(非必填) : + enum: + - 1 (online) + - 2 (offline) + userPin(非必填) : mt_test + optional + * @param {string} callback - callback + @return {Object} result + * @param billDataResultObject resultObject + */ + + describeLiveBillData (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveBillData 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( + '/liveBillDatas', + '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.playDomain - (直播or时移)播放域名 +- 仅支持精确匹配 + + * @param {string} callback - callback + @return {Object} result + * @param string playDomain 播放域名 + * @param string certStatus (直播or时移)播放证书状态 + on: 开启 + off: 关闭 + + * @param string cert (直播or时移)播放证书 + * @param string title (直播or时移)播放证书别名 + */ + + describeLiveDomainCertificate (opts, callback) { + opts = opts || {} + + if (opts.playDomain === undefined || opts.playDomain === null) { + throw new Error( + "Missing the required parameter 'opts.playDomain' when calling describeLiveDomainCertificate" + ) + } + + let postBody = null + let queryParams = {} + if (opts.playDomain !== undefined && opts.playDomain !== null) { + queryParams['playDomain'] = opts.playDomain + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveDomainCertificate 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( + '/liveDomainCertificate', + '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) + } + ) + } + + /** + * 设置(直播or时移)播放证书 +-- 设置成功之后30分钟以内生效 + + * @param {Object} opts - parameters + * @param {string} opts.playDomain - (直播or时移)播放域名 + * @param {string} opts.certStatus - (直播or时移)播放证书状态 + on: 开启 + off: 关闭 +- 当播放证书状态on(开启)时,cert和key不能为空 + + * @param {string} [opts.cert] - (直播or时移)播放证书 +- 取值: 最大支持4098 +- 当播放证书状态on(开启)时,cert不能为空 + optional + * @param {string} [opts.key] - (直播or时移)播放证书key +- 取值: 最大支持2048 +- 当播放证书状态on(开启)时,key不能为空 + optional + * @param {string} [opts.title] - (直播or时移)播放证书别名 +- 取值: 支持大小写字母和数字 长度最大256 + optional + * @param {string} callback - callback + @return {Object} result + */ + + setLiveDomainCertificate (opts, callback) { + opts = opts || {} + + if (opts.playDomain === undefined || opts.playDomain === null) { + throw new Error( + "Missing the required parameter 'opts.playDomain' when calling setLiveDomainCertificate" + ) + } + if (opts.certStatus === undefined || opts.certStatus === null) { + throw new Error( + "Missing the required parameter 'opts.certStatus' when calling setLiveDomainCertificate" + ) + } + + let postBody = {} + if (opts.playDomain !== undefined && opts.playDomain !== null) { + postBody['playDomain'] = opts.playDomain + } + if (opts.certStatus !== undefined && opts.certStatus !== null) { + postBody['certStatus'] = opts.certStatus + } + if (opts.cert !== undefined && opts.cert !== null) { + postBody['cert'] = opts.cert + } + if (opts.key !== undefined && opts.key !== null) { + postBody['key'] = opts.key + } + if (opts.title !== undefined && opts.title !== null) { + postBody['title'] = opts.title + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 setLiveDomainCertificate 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( + '/liveDomainCertificate', + '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.restartDomain - 直播回看域名 +- 仅支持精确匹配 + + * @param {string} callback - callback + @return {Object} result + * @param string restartDomain 直播回看域名 + * @param string certStatus 直播回看播放证书状态 + on: 开启 + off: 关闭 + + * @param string cert 直播回看证书 + * @param string title 直播回看证书别名 + */ + + describeLiveRestartDomainCertificate (opts, callback) { + opts = opts || {} + + if (opts.restartDomain === undefined || opts.restartDomain === null) { + throw new Error( + "Missing the required parameter 'opts.restartDomain' when calling describeLiveRestartDomainCertificate" + ) + } + + let postBody = null + let queryParams = {} + if (opts.restartDomain !== undefined && opts.restartDomain !== null) { + queryParams['restartDomain'] = opts.restartDomain + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveRestartDomainCertificate 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( + '/liveRestartDomainCertificate', + '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) + } + ) + } + + /** + * 设置直播回看证书 +-- 设置成功之后30分钟以内生效 + + * @param {Object} opts - parameters + * @param {string} opts.restartDomain - 直播回看域名 + * @param {string} opts.certStatus - 直播回看证书状态 + on: 开启 + off: 关闭 +- 当播放证书状态on(开启)时,cert和key不能为空 + + * @param {string} [opts.cert] - 直播回看证书 +- 取值: 最大支持4098 +- 当播放证书状态on(开启)时,cert不能为空 + optional + * @param {string} [opts.key] - 直播回看证书key +- 取值: 最大支持2048 +- 当播放证书状态on(开启)时,key不能为空 + optional + * @param {string} [opts.title] - 直播回看证书别名 +- 取值: 支持大小写字母和数字 长度最大256 + optional + * @param {string} callback - callback + @return {Object} result + */ + + setLiveRestartDomainCertificate (opts, callback) { + opts = opts || {} + + if (opts.restartDomain === undefined || opts.restartDomain === null) { + throw new Error( + "Missing the required parameter 'opts.restartDomain' when calling setLiveRestartDomainCertificate" + ) + } + if (opts.certStatus === undefined || opts.certStatus === null) { + throw new Error( + "Missing the required parameter 'opts.certStatus' when calling setLiveRestartDomainCertificate" + ) + } + + let postBody = {} + if (opts.restartDomain !== undefined && opts.restartDomain !== null) { + postBody['restartDomain'] = opts.restartDomain + } + if (opts.certStatus !== undefined && opts.certStatus !== null) { + postBody['certStatus'] = opts.certStatus + } + if (opts.cert !== undefined && opts.cert !== null) { + postBody['cert'] = opts.cert + } + if (opts.key !== undefined && opts.key !== null) { + postBody['key'] = opts.key + } + if (opts.title !== undefined && opts.title !== null) { + postBody['title'] = opts.title + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 setLiveRestartDomainCertificate 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( + '/liveRestartDomainCertificate', + '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.pageNum] - 页码 +- 取值范围[1, 100000] + optional + * @param {integer} [opts.pageSize] - 分页大小 +- 取值范围[10, 100] + optional + * @param {string} [opts.publishDomain] - 推流域名 +- 目前仅支持精确查询 +- 为空时,查询用户所有直播域名 + optional + * @param {string} callback - callback + @return {Object} result + * @param integer pageNumber 当前页码 + * @param integer pageSize 每页数量 + * @param integer totalCount 查询总数 + * @param domainDetails domainDetails + */ + + describeLiveDomains (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.pageNum !== undefined && opts.pageNum !== null) { + queryParams['pageNum'] = opts.pageNum + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + queryParams['publishDomain'] = opts.publishDomain + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveDomains 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( + '/domains', + '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.publishDomain - 直播的推流域名 +- 不支持泛域名 + + * @param {string} opts.playDomain - 直播的播放域名 +- 不支持泛域名 + + * @param {string} callback - callback + @return {Object} result + */ + + addLiveDomain (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling addLiveDomain" + ) + } + if (opts.playDomain === undefined || opts.playDomain === null) { + throw new Error( + "Missing the required parameter 'opts.playDomain' when calling addLiveDomain" + ) + } + + let postBody = {} + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + postBody['publishDomain'] = opts.publishDomain + } + if (opts.playDomain !== undefined && opts.playDomain !== null) { + postBody['playDomain'] = opts.playDomain + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 addLiveDomain 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( + '/domains', + '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) + } + ) + } + + /** + * 启动域名 +- 启用状态为 停用 的直播域名对(推流域名,播放域名)将DomainStatus变更为online + + * @param {Object} opts - parameters + * @param {string} opts.publishDomain - 推流域名 +- 需要启动的域名对(推流域名,播放域名)中的推流域名 + + * @param {string} callback - callback + @return {Object} result + */ + + startLiveDomain (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling startLiveDomain" + ) + } + + let postBody = {} + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + postBody['publishDomain'] = opts.publishDomain + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 startLiveDomain 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( + '/domains:start', + '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) + } + ) + } + + /** + * 停用域名 +- 停用直播域名对(推流域名,播放域名),将DomainStatus变更为offline +- 停用该直播域名对后,直播域名信息仍保留,但用户将不能再用该推流域名推流或播放域名播放 + + * @param {Object} opts - parameters + * @param {string} opts.publishDomain - 推流域名 +- 需要停用的域名对(推流域名,播放域名)中的推流域名 + + * @param {string} callback - callback + @return {Object} result + */ + + stopLiveDomain (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling stopLiveDomain" + ) + } + + let postBody = {} + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + postBody['publishDomain'] = opts.publishDomain + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 stopLiveDomain 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( + '/domains:stop', + '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) + } + ) + } + + /** + * 查询指定域名相关信息 + * @param {Object} opts - parameters + * @param {string} opts.publishDomain - 推流域名 +- 需要停用的域名对(推流域名,播放域名)中的推流域名 + + * @param {string} callback - callback + @return {Object} result + * @param integer sourceId SourceID + * @param publishDomain publishDomains + * @param playDomain playDomains + */ + + describeLiveDomainDetail (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling describeLiveDomainDetail" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + publishDomain: opts.publishDomain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveDomainDetail 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( + '/domains/{publishDomain}', + '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) + } + ) + } + + /** + * 删除直播域名 +- 请慎重操作(建议在进行域名删除前到域名解析服务商处恢复域名A记录),以免导致删除操作后此域名不可访问。 + deleteLiveDomain调用成功后将删除本条直播域名的全部相关记录,对于仅需要暂停使用该直播域名,推荐stopLiveDomain接口 + + * @param {Object} opts - parameters + * @param {string} opts.publishDomain - 推流域名 + + * @param {string} callback - callback + @return {Object} result + */ + + deleteLiveDomain (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling deleteLiveDomain" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + publishDomain: opts.publishDomain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 deleteLiveDomain 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( + '/domains/{publishDomain}', + '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.playDomain - 直播的播放域名 +- 回看域名所对应的原播放域名,新建的回看域名将绑定到此播放域名下 + + * @param {string} opts.restartDomain - 直播回看域名 +- 直播域名必须已经备案完成 + + * @param {string} callback - callback + @return {Object} result + */ + + addLiveRestartDomain (opts, callback) { + opts = opts || {} + + if (opts.playDomain === undefined || opts.playDomain === null) { + throw new Error( + "Missing the required parameter 'opts.playDomain' when calling addLiveRestartDomain" + ) + } + if (opts.restartDomain === undefined || opts.restartDomain === null) { + throw new Error( + "Missing the required parameter 'opts.restartDomain' when calling addLiveRestartDomain" + ) + } + + let postBody = {} + if (opts.playDomain !== undefined && opts.playDomain !== null) { + postBody['playDomain'] = opts.playDomain + } + if (opts.restartDomain !== undefined && opts.restartDomain !== null) { + postBody['restartDomain'] = opts.restartDomain + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 addLiveRestartDomain 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( + '/domains:restart', + '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) + } + ) + } + + /** + * 创建直播拉流转推任务 + + * @param {Object} opts - parameters + * @param {string} opts.sourceUrl - 拉流地址 +- 支持rtmp + + * @param {string} opts.pushUrl - 转推地址 +- 支持rtmp + + * @param {string} opts.startMode - 执行方式 +- StartNow: 立即执行 +- StartAsScheduled: 定时执行,根据参数设定的时间 + + * @param {string} [opts.startTime] - 开始时间 +- UTC时间, ISO8601示例:2021-07-26T08:08:08Z +- 不填表示立即开始 + optional + * @param {string} [opts.endTime] - 结束时间 +- UTC时间, ISO8601示例:2021-07-26T08:08:08Z +- 最大支持365天,与开始时间间隔不超过7天。 + - 假设当前时间2021年03月30日11:50:01,则:结束时间不可超过2022年03月30日11:50:01。 +- 不填拉不到流10分钟自动结束 + optional + * @param {array} [opts.callbackEvents] - 回调类型 +- 不填发送全部回调 +- TaskStart 任务开始 +- TaskExit 任务结束 +- callbackUrl非空的情况下,callbackEvents有效 + optional + * @param {string} [opts.callbackUrl] - 事件回调地址 + optional + * @param {string} [opts.name] - 任务名称 +- 最大255字符 + optional + * @param {string} callback - callback + @return {Object} result + * @param string taskId 任务ID + */ + + createLiveForwardTask (opts, callback) { + opts = opts || {} + + if (opts.sourceUrl === undefined || opts.sourceUrl === null) { + throw new Error( + "Missing the required parameter 'opts.sourceUrl' when calling createLiveForwardTask" + ) + } + if (opts.pushUrl === undefined || opts.pushUrl === null) { + throw new Error( + "Missing the required parameter 'opts.pushUrl' when calling createLiveForwardTask" + ) + } + if (opts.startMode === undefined || opts.startMode === null) { + throw new Error( + "Missing the required parameter 'opts.startMode' when calling createLiveForwardTask" + ) + } + + let postBody = {} + if (opts.sourceUrl !== undefined && opts.sourceUrl !== null) { + postBody['sourceUrl'] = opts.sourceUrl + } + if (opts.pushUrl !== undefined && opts.pushUrl !== null) { + postBody['pushUrl'] = opts.pushUrl + } + if (opts.startMode !== undefined && opts.startMode !== null) { + postBody['startMode'] = opts.startMode + } + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.callbackEvents !== undefined && opts.callbackEvents !== null) { + postBody['callbackEvents'] = opts.callbackEvents + } + if (opts.callbackUrl !== undefined && opts.callbackUrl !== null) { + postBody['callbackUrl'] = opts.callbackUrl + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 createLiveForwardTask 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( + '/LiveForwardTask:create', + '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.taskId - 任务ID + + * @param {string} [opts.sourceUrl] - 拉流地址 +- 支持rtmp + optional + * @param {string} [opts.pushUrl] - 转推地址 +- 支持rtmp + optional + * @param {string} [opts.startTime] - 开始时间 +- UTC时间, ISO8601示例:2021-07-26T08:08:08Z +- 不填表示立即开始 + optional + * @param {string} [opts.endTime] - 结束时间 +- UTC时间, ISO8601示例:2021-07-26T08:08:08Z +- 最大支持365天,与开始时间间隔不超过7天。 +- 不填拉不到流10分钟自动结束 + optional + * @param {array} [opts.callbackEvents] - 回调类型 +- 不填发送全部回调 +- TaskStart 任务开始 +- TaskExit 任务结束 +- callbackUrl非空的情况下,callbackEvents有效 + optional + * @param {string} [opts.callbackUrl] - 事件回调地址 + optional + * @param {string} [opts.name] - 任务名称 +- 最大255字符 + optional + * @param {string} callback - callback + @return {Object} result + */ + + updateLiveForwardTask (opts, callback) { + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling updateLiveForwardTask" + ) + } + + let postBody = {} + if (opts.taskId !== undefined && opts.taskId !== null) { + postBody['taskId'] = opts.taskId + } + if (opts.sourceUrl !== undefined && opts.sourceUrl !== null) { + postBody['sourceUrl'] = opts.sourceUrl + } + if (opts.pushUrl !== undefined && opts.pushUrl !== null) { + postBody['pushUrl'] = opts.pushUrl + } + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.callbackEvents !== undefined && opts.callbackEvents !== null) { + postBody['callbackEvents'] = opts.callbackEvents + } + if (opts.callbackUrl !== undefined && opts.callbackUrl !== null) { + postBody['callbackUrl'] = opts.callbackUrl + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 updateLiveForwardTask 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( + '/LiveForwardTask:update', + '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.pageNum] - 页码 +- 取值范围 [1, 100000] + optional + * @param {integer} [opts.pageSize] - 分页大小 +- 取值范围 [10, 100] + optional + * @param {filter} [opts.filters] - 拉流转推任务查询过滤条件: +- name: taskId 任务ID +- value: 如果参数为空,则查询全部 +- name: taskName 任务名称 +- value: 如果参数为空,则查询全部 + optional + * @param {string} callback - callback + @return {Object} result + * @param integer pageNumber 当前页码 + * @param integer pageSize 每页数量 + * @param integer totalCount 查询总数 + * @param liveTaskInfo dataList + */ + + queryLiveForwardTask (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.pageNum !== undefined && opts.pageNum !== null) { + queryParams['pageNum'] = opts.pageNum + } + 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 live/1.0.22' + } + + 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 queryLiveForwardTask 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( + '/LiveForwardTask:query', + '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.taskIds - 任务ID,批量用,分隔 + + * @param {string} callback - callback + @return {Object} result + */ + + startLiveForwardTask (opts, callback) { + opts = opts || {} + + if (opts.taskIds === undefined || opts.taskIds === null) { + throw new Error( + "Missing the required parameter 'opts.taskIds' when calling startLiveForwardTask" + ) + } + + let postBody = null + let queryParams = {} + if (opts.taskIds !== undefined && opts.taskIds !== null) { + queryParams['taskIds'] = opts.taskIds + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 startLiveForwardTask 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( + '/LiveForwardTask:start', + '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.taskIds - 任务ID,批量用,分隔 + + * @param {string} callback - callback + @return {Object} result + */ + + stopLiveForwardTask (opts, callback) { + opts = opts || {} + + if (opts.taskIds === undefined || opts.taskIds === null) { + throw new Error( + "Missing the required parameter 'opts.taskIds' when calling stopLiveForwardTask" + ) + } + + let postBody = null + let queryParams = {} + if (opts.taskIds !== undefined && opts.taskIds !== null) { + queryParams['taskIds'] = opts.taskIds + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 stopLiveForwardTask 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( + '/LiveForwardTask:stop', + '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.taskIds - 任务ID,批量用,分隔 + + * @param {string} callback - callback + @return {Object} result + */ + + deleteLiveForwardTask (opts, callback) { + opts = opts || {} + + if (opts.taskIds === undefined || opts.taskIds === null) { + throw new Error( + "Missing the required parameter 'opts.taskIds' when calling deleteLiveForwardTask" + ) + } + + let postBody = null + let queryParams = {} + if (opts.taskIds !== undefined && opts.taskIds !== null) { + queryParams['taskIds'] = opts.taskIds + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 deleteLiveForwardTask 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( + '/LiveForwardTask:delete', + '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.template - 模板名称。长度不超过128个字符。UTF-8编码 + + * @param {array} [opts.modules] - 检测项列表。取值范围: + BlackScreen - 黑屏 + PureColor - 纯色 + ColorCast - 偏色 + FrozenFrame - 静帧 + Brightness - 亮度 + Contrast - 对比度 + optional + * @param {string} callback - callback + @return {Object} result + */ + + addCustomLiveStreamQualityDetectionTemplate (opts, callback) { + opts = opts || {} + + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling addCustomLiveStreamQualityDetectionTemplate" + ) + } + + let postBody = {} + if (opts.template !== undefined && opts.template !== null) { + postBody['template'] = opts.template + } + if (opts.modules !== undefined && opts.modules !== null) { + postBody['modules'] = opts.modules + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 addCustomLiveStreamQualityDetectionTemplate 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( + '/qualityDetectionCustoms:template', + '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.pageNum] - 页码 +- 取值范围 [1, 100000] + optional + * @param {integer} [opts.pageSize] - 分页大小 +- 取值范围 [10, 100] + optional + * @param {filter} [opts.filters] - 质量检测模板查询过滤条件 +- name: template 质量检测自定义名称 +- value: 如果参数为空,则查询全部 + optional + * @param {string} callback - callback + @return {Object} result + * @param integer pageNumber 当前页码 + * @param integer pageSize 每页数量 + * @param integer totalCount 查询总数 + * @param qualityDetectionTemplate qualityDetectionTemplates + */ + + describeCustomLiveStreamQualityDetectionTemplates (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.pageNum !== undefined && opts.pageNum !== null) { + queryParams['pageNum'] = opts.pageNum + } + 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 live/1.0.22' + } + + 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 describeCustomLiveStreamQualityDetectionTemplates 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( + '/qualityDetectionCustoms', + '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.publishDomain - 推流域名 + * @param {string} opts.appName - 应用名称 + * @param {string} opts.template - 质量检测模板 + + * @param {string} callback - callback + @return {Object} result + */ + + addLiveStreamAppQualityDetection (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling addLiveStreamAppQualityDetection" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling addLiveStreamAppQualityDetection" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling addLiveStreamAppQualityDetection" + ) + } + + let postBody = {} + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + postBody['publishDomain'] = opts.publishDomain + } + if (opts.appName !== undefined && opts.appName !== null) { + postBody['appName'] = opts.appName + } + if (opts.template !== undefined && opts.template !== null) { + postBody['template'] = opts.template + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 addLiveStreamAppQualityDetection 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( + '/qualityDetectionApps:template', + '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.publishDomain - 推流域名 + * @param {string} opts.template - 质量检测模板 + + * @param {string} callback - callback + @return {Object} result + */ + + addLiveStreamDomainQualityDetection (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling addLiveStreamDomainQualityDetection" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling addLiveStreamDomainQualityDetection" + ) + } + + let postBody = {} + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + postBody['publishDomain'] = opts.publishDomain + } + if (opts.template !== undefined && opts.template !== null) { + postBody['template'] = opts.template + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 addLiveStreamDomainQualityDetection 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( + '/qualityDetectionDomains:template', + '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.publishDomain - 推流域名 + * @param {string} opts.notifyUrl - 质量检测回调通知的URL地址: +- 以 http:// 开头,外网可访问的地址 + + * @param {string} callback - callback + @return {Object} result + */ + + setLiveStreamQualityDetectionNotifyConfig (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling setLiveStreamQualityDetectionNotifyConfig" + ) + } + if (opts.notifyUrl === undefined || opts.notifyUrl === null) { + throw new Error( + "Missing the required parameter 'opts.notifyUrl' when calling setLiveStreamQualityDetectionNotifyConfig" + ) + } + + let postBody = {} + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + postBody['publishDomain'] = opts.publishDomain + } + if (opts.notifyUrl !== undefined && opts.notifyUrl !== null) { + postBody['notifyUrl'] = opts.notifyUrl + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 setLiveStreamQualityDetectionNotifyConfig 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( + '/qualityDetectionNotifys:config', + '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.template - 质量检测模板 + * @param {string} callback - callback + @return {Object} result + */ + + deleteCustomLiveStreamQualityDetectionTemplate (opts, callback) { + opts = opts || {} + + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling deleteCustomLiveStreamQualityDetectionTemplate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + template: opts.template + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 deleteCustomLiveStreamQualityDetectionTemplate 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( + '/qualityDetectionCustoms/{template}', + '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.publishDomain - 推流域名 + * @param {string} opts.appName - 应用名称 + * @param {string} opts.template - 质量检测模板 + * @param {string} callback - callback + @return {Object} result + */ + + deleteLiveStreamAppQualityDetection (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling deleteLiveStreamAppQualityDetection" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling deleteLiveStreamAppQualityDetection" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling deleteLiveStreamAppQualityDetection" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + publishDomain: opts.publishDomain, + appName: opts.appName, + template: opts.template + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 deleteLiveStreamAppQualityDetection 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( + '/qualityDetectionApps/{publishDomain}/appNames/{appName}/templates/{template}', + '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.publishDomain - 推流域名 + * @param {string} opts.template - 质量检测模板 + * @param {string} callback - callback + @return {Object} result + */ + + deleteLiveStreamDomainQualityDetection (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling deleteLiveStreamDomainQualityDetection" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling deleteLiveStreamDomainQualityDetection" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + publishDomain: opts.publishDomain, + template: opts.template + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 deleteLiveStreamDomainQualityDetection 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( + '/qualityDetectionDomains/{publishDomain}/templates/{template}', + '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.publishDomain - 推流域名 + * @param {string} callback - callback + @return {Object} result + * @param string publishDomain 推流域名 + * @param string notifyUrl 回调地址 + */ + + describeLiveStreamQualityDetectionNotifyConfig (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling describeLiveStreamQualityDetectionNotifyConfig" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + publishDomain: opts.publishDomain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveStreamQualityDetectionNotifyConfig 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( + '/qualityDetectionNotifys/{publishDomain}:config', + '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.publishDomain - 推流域名 + * @param {string} callback - callback + @return {Object} result + */ + + deleteLiveStreamQualityDetectionNotifyConfig (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling deleteLiveStreamQualityDetectionNotifyConfig" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + publishDomain: opts.publishDomain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 deleteLiveStreamQualityDetectionNotifyConfig 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( + '/qualityDetectionNotifys/{publishDomain}:config', + '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.template - 质量检测模板 + * @param {string} callback - callback + @return {Object} result + * @param templateBinding bindingList + */ + + describeQualityDetectionBinding (opts, callback) { + opts = opts || {} + + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling describeQualityDetectionBinding" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + template: opts.template + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeQualityDetectionBinding 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( + '/qualityDetectionTemplates/{template}:binding', + '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.fileUrl - 需要删除的录制文件在oss的url + + * @param {boolean} [opts.completely] - 是否深度删除所有的ts文件,仅对.m3u8录制文件生效。默认: true + optional + * @param {string} callback - callback + @return {Object} result + */ + + deleteLiveRecordings (opts, callback) { + opts = opts || {} + + if (opts.fileUrl === undefined || opts.fileUrl === null) { + throw new Error( + "Missing the required parameter 'opts.fileUrl' when calling deleteLiveRecordings" + ) + } + + let postBody = null + let queryParams = {} + if (opts.fileUrl !== undefined && opts.fileUrl !== null) { + queryParams['fileUrl'] = opts.fileUrl + } + if (opts.completely !== undefined && opts.completely !== null) { + queryParams['completely'] = opts.completely + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 deleteLiveRecordings 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( + '/recordings:delete', + '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) + } + ) + } + + /** + * 开启P2P + + * @param {Object} opts - parameters + * @param {string} [opts.playDomain] - 播放域名 optional + * @param {string} callback - callback + @return {Object} result + */ + + openLiveP2p (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.playDomain !== undefined && opts.playDomain !== null) { + postBody['playDomain'] = opts.playDomain + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 openLiveP2p 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( + '/liveP2p:open', + '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) + } + ) + } + + /** + * 关闭P2P + * @param {Object} opts - parameters + * @param {string} [opts.playDomain] - 播放域名 optional + * @param {string} callback - callback + @return {Object} result + */ + + closeLiveP2p (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.playDomain !== undefined && opts.playDomain !== null) { + postBody['playDomain'] = opts.playDomain + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 closeLiveP2p 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( + '/liveP2p:close', + '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) + } + ) + } + + /** + * 查询P2P配置 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码 +- 取值范围[1, 100000] + optional + * @param {integer} [opts.pageSize] - 分页大小 +- 取值范围[10, 100] + optional + * @param {string} opts.playDomain - 直播的播放域名 +- 目前仅支持精确匹配 + + * @param {string} callback - callback + @return {Object} result + * @param p2pResultObject resultObject + */ + + describeLiveP2pConfigs (opts, callback) { + opts = opts || {} + + if (opts.playDomain === undefined || opts.playDomain === null) { + throw new Error( + "Missing the required parameter 'opts.playDomain' when calling describeLiveP2pConfigs" + ) + } + + 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.playDomain !== undefined && opts.playDomain !== null) { + queryParams['playDomain'] = opts.playDomain + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveP2pConfigs 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( + '/liveP2p:configs', + '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.pageNum] - 页码 +- 取值范围[1, 100000] + optional + * @param {integer} [opts.pageSize] - 分页大小 +- 取值范围[10, 100] + optional + * @param {filter} [opts.filters] - 录制模板列表查询过滤条件: + - name: template 录制模板自定义名称 + - value: 如果参数为空,则查询全部 + optional + * @param {string} callback - callback + @return {Object} result + * @param integer pageNumber 当前页码 + * @param integer pageSize 每页数量 + * @param integer totalCount 查询总数 + * @param recordTemplate recordTemplates + */ + + describeCustomLiveStreamRecordTemplates (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.pageNum !== undefined && opts.pageNum !== null) { + queryParams['pageNum'] = opts.pageNum + } + 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 live/1.0.22' + } + + 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 describeCustomLiveStreamRecordTemplates 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( + '/recordCustoms:template', + '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.recordPeriod - 自动录制周期 +- 取值: [15,360] +- 单位: 分钟 + + * @param {string} opts.saveBucket - 存储桶 + + * @param {string} [opts.saveEndpoint] - endpoint + optional + * @param {string} opts.recordFileType - 录制文件格式: +- 取值: ts,flv,mp4 (多种类型之间用;隔开) +- 不区分大小写 + + * @param {string} opts.template - 录制模板自定义名称: + - 取值要求:数字、大小写字母或短横线("-")、下划线("_"), + 最大长度50个字符 + - <b>注意: 不能与已定义命名重复</b> + + * @param {string} callback - callback + @return {Object} result + */ + + addCustomLiveStreamRecordTemplate (opts, callback) { + opts = opts || {} + + if (opts.recordPeriod === undefined || opts.recordPeriod === null) { + throw new Error( + "Missing the required parameter 'opts.recordPeriod' when calling addCustomLiveStreamRecordTemplate" + ) + } + if (opts.saveBucket === undefined || opts.saveBucket === null) { + throw new Error( + "Missing the required parameter 'opts.saveBucket' when calling addCustomLiveStreamRecordTemplate" + ) + } + if (opts.recordFileType === undefined || opts.recordFileType === null) { + throw new Error( + "Missing the required parameter 'opts.recordFileType' when calling addCustomLiveStreamRecordTemplate" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling addCustomLiveStreamRecordTemplate" + ) + } + + let postBody = {} + if (opts.recordPeriod !== undefined && opts.recordPeriod !== null) { + postBody['recordPeriod'] = opts.recordPeriod + } + if (opts.saveBucket !== undefined && opts.saveBucket !== null) { + postBody['saveBucket'] = opts.saveBucket + } + if (opts.saveEndpoint !== undefined && opts.saveEndpoint !== null) { + postBody['saveEndpoint'] = opts.saveEndpoint + } + if (opts.recordFileType !== undefined && opts.recordFileType !== null) { + postBody['recordFileType'] = opts.recordFileType + } + if (opts.template !== undefined && opts.template !== null) { + postBody['template'] = opts.template + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 addCustomLiveStreamRecordTemplate 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( + '/recordCustoms:template', + '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.publishDomain - 推流域名 + * @param {string} opts.appName - 应用名称 + * @param {string} opts.template - 录制模版 + * @param {string} callback - callback + @return {Object} result + */ + + addLiveStreamAppRecord (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling addLiveStreamAppRecord" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling addLiveStreamAppRecord" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling addLiveStreamAppRecord" + ) + } + + let postBody = {} + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + postBody['publishDomain'] = opts.publishDomain + } + if (opts.appName !== undefined && opts.appName !== null) { + postBody['appName'] = opts.appName + } + if (opts.template !== undefined && opts.template !== null) { + postBody['template'] = opts.template + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 addLiveStreamAppRecord 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( + '/recordApps:config', + '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.publishDomain - 推流域名 + * @param {string} opts.template - 录制模版 + * @param {string} callback - callback + @return {Object} result + */ + + addLiveStreamDomainRecord (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling addLiveStreamDomainRecord" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling addLiveStreamDomainRecord" + ) + } + + let postBody = {} + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + postBody['publishDomain'] = opts.publishDomain + } + if (opts.template !== undefined && opts.template !== null) { + postBody['template'] = opts.template + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 addLiveStreamDomainRecord 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( + '/recordDomains:config', + '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) + } + ) + } + + /** + * 查询直播直播录制配置 +- 录制模板配置按照 域名,应用,流 3级配置添加,以最小的粒度配置生效 +- 域名、应用、流 依次粒度递减 即: 域名>应用>流 +- 该查询旨在查询域名、应用、流最终生效的录制模板配置,并非各级的模板绑定情况 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNum] - 页码 +- 取值范围 [1, 100000] + optional + * @param {integer} [opts.pageSize] - 分页大小 +- 取值范围 [10, 100] + optional + * @param {filter} [opts.filters] - 录制配置查询过滤条件: + - name: publishDomain,必填(推流域名) + - value: 参数 + - name: appName,必填(应用名称) + - value: 参数 + - name: streamName,非必填(流名称) + - value: 参数 + optional + * @param {string} callback - callback + @return {Object} result + * @param integer pageNumber 当前页码 + * @param integer pageSize 每页数量 + * @param integer totalCount 查询总数 + * @param liveRecordConfig recordConfigs + */ + + describeCustomLiveStreamRecordConfig (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.pageNum !== undefined && opts.pageNum !== null) { + queryParams['pageNum'] = opts.pageNum + } + 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 live/1.0.22' + } + + 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 describeCustomLiveStreamRecordConfig 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( + '/records:config', + '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.publishDomain - 推流域名 + * @param {string} opts.notifyUrl - 录制回调通知的URL地址 +- 以 http:// 开头,外网可访问的地址 + + * @param {string} callback - callback + @return {Object} result + */ + + setLiveStreamRecordNotifyConfig (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling setLiveStreamRecordNotifyConfig" + ) + } + if (opts.notifyUrl === undefined || opts.notifyUrl === null) { + throw new Error( + "Missing the required parameter 'opts.notifyUrl' when calling setLiveStreamRecordNotifyConfig" + ) + } + + let postBody = {} + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + postBody['publishDomain'] = opts.publishDomain + } + if (opts.notifyUrl !== undefined && opts.notifyUrl !== null) { + postBody['notifyUrl'] = opts.notifyUrl + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 setLiveStreamRecordNotifyConfig 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( + '/recordNotifys:config', + '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.template - 录制模板 + * @param {string} callback - callback + @return {Object} result + */ + + deleteCustomLiveStreamRecordTemplate (opts, callback) { + opts = opts || {} + + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling deleteCustomLiveStreamRecordTemplate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + template: opts.template + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 deleteCustomLiveStreamRecordTemplate 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( + '/recordCustoms/{template}', + '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.publishDomain - 推流域名 + * @param {string} opts.appName - 应用名称 + * @param {string} opts.template - 录制模板 + + * @param {string} callback - callback + @return {Object} result + */ + + deleteLiveStreamAppRecord (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling deleteLiveStreamAppRecord" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling deleteLiveStreamAppRecord" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling deleteLiveStreamAppRecord" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + publishDomain: opts.publishDomain, + appName: opts.appName, + template: opts.template + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 deleteLiveStreamAppRecord 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( + '/recordApps/{publishDomain}/appNames/{appName}/templates/{template}', + '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.publishDomain - 推流域名 + * @param {string} opts.template - 录制模板 + + * @param {string} callback - callback + @return {Object} result + */ + + deleteLiveStreamDomainRecord (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling deleteLiveStreamDomainRecord" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling deleteLiveStreamDomainRecord" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + publishDomain: opts.publishDomain, + template: opts.template + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 deleteLiveStreamDomainRecord 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( + '/recordDomains/{publishDomain}/templates/{template}', + '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.publishDomain - 推流域名 + * @param {string} callback - callback + @return {Object} result + * @param string publishDomain 推流域名 + * @param string notifyUrl 回调地址 + */ + + describeLiveStreamRecordNotifyConfig (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling describeLiveStreamRecordNotifyConfig" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + publishDomain: opts.publishDomain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveStreamRecordNotifyConfig 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( + '/recordNotifys/{publishDomain}', + '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.publishDomain - 推流域名 + * @param {string} callback - callback + @return {Object} result + */ + + deleteLiveStreamRecordNotifyConfig (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling deleteLiveStreamRecordNotifyConfig" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + publishDomain: opts.publishDomain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 deleteLiveStreamRecordNotifyConfig 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( + '/recordNotifys/{publishDomain}', + '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.publishDomain - 推流域名 + * @param {string} opts.appName - 应用名称 + * @param {string} opts.streamName - 流名称 + * @param {array} [opts.recordTimes] - 录制时间集合 +- 最大支持10段,多段合并成一个文件 +- 多段时间跨度最小不能小于10s +- 多段时间跨度最大不能超过8小时 + optional + * @param {string} opts.saveBucket - 存储桶 + * @param {string} opts.saveEndpoint - 存储地址 + * @param {string} opts.recordFileType - 录制文件类型: +- 取值: ts,flv,mp4 (多种类型之间用;隔开) +- 不区分大小写 + + * @param {string} [opts.saveObject] - 录制文件存储Object: +- 默认: /record/{Date}/{ServerId}/{AppName}/{StreamName}/{StartTime}_{EndTime} + optional + * @param {string} [opts.taskExternalId] - 打点录制任务外部id(可传入您的id,在回调时会在该字段返回) + optional + * @param {string} callback - callback + @return {Object} result + */ + + addLiveRecordTask (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling addLiveRecordTask" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling addLiveRecordTask" + ) + } + if (opts.streamName === undefined || opts.streamName === null) { + throw new Error( + "Missing the required parameter 'opts.streamName' when calling addLiveRecordTask" + ) + } + if (opts.saveBucket === undefined || opts.saveBucket === null) { + throw new Error( + "Missing the required parameter 'opts.saveBucket' when calling addLiveRecordTask" + ) + } + if (opts.saveEndpoint === undefined || opts.saveEndpoint === null) { + throw new Error( + "Missing the required parameter 'opts.saveEndpoint' when calling addLiveRecordTask" + ) + } + if (opts.recordFileType === undefined || opts.recordFileType === null) { + throw new Error( + "Missing the required parameter 'opts.recordFileType' when calling addLiveRecordTask" + ) + } + + let postBody = {} + if (opts.recordTimes !== undefined && opts.recordTimes !== null) { + postBody['recordTimes'] = opts.recordTimes + } + if (opts.saveBucket !== undefined && opts.saveBucket !== null) { + postBody['saveBucket'] = opts.saveBucket + } + if (opts.saveEndpoint !== undefined && opts.saveEndpoint !== null) { + postBody['saveEndpoint'] = opts.saveEndpoint + } + if (opts.recordFileType !== undefined && opts.recordFileType !== null) { + postBody['recordFileType'] = opts.recordFileType + } + if (opts.saveObject !== undefined && opts.saveObject !== null) { + postBody['saveObject'] = opts.saveObject + } + if (opts.taskExternalId !== undefined && opts.taskExternalId !== null) { + postBody['taskExternalId'] = opts.taskExternalId + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + publishDomain: opts.publishDomain, + appName: opts.appName, + streamName: opts.streamName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 addLiveRecordTask 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( + '/records/{publishDomain}/appNames/{appName}/streamNames/{streamName}/task', + '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.template - 录制模板 + * @param {string} callback - callback + @return {Object} result + * @param templateBinding bindingList + */ + + describeRecordBinding (opts, callback) { + opts = opts || {} + + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling describeRecordBinding" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + template: opts.template + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeRecordBinding 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( + '/recordTemplates/{template}:binding', + '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.domainName] - 播放域名 optional + * @param {string} [opts.appName] - 应用名称 optional + * @param {string} [opts.streamName] - 流名称 optional + * @param {string} [opts.ispName] - 运营商 + optional + * @param {string} [opts.locationName] - 查询的区域,如beijing,shanghai。多个用逗号分隔 + optional + * @param {string} [opts.period] - 查询周期,当前取值范围:“oneMin,fiveMin,halfHour,hour,twoHour,sixHour,day,followTime”,分别表示1min,5min,半小时,1小时,2小时,6小时,1天,跟随时间。默认为空,表示fiveMin。当传入followTime时,表示按Endtime-StartTime的周期,只返回一个点 + optional + * @param {string} opts.startTime - 起始时间 +- UTC时间 + 格式:yyyy-MM-dd'T'HH:mm:ss'Z' + 示例:2018-10-21T10:00:00Z + + * @param {string} [opts.endTime] - 结束时间: +- UTC时间 + 格式:yyyy-MM-dd'T'HH:mm:ss'Z' + 示例:2018-10-21T10:00:00Z +- 为空,默认为当前时间,查询时间跨度不超过1天 + optional + * @param {string} callback - callback + @return {Object} result + * @param liveStatisticGroupByStreamResult dataList + */ + + describeLiveStatisticGroupByStream (opts, callback) { + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeLiveStatisticGroupByStream" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + if (opts.appName !== undefined && opts.appName !== null) { + queryParams['appName'] = opts.appName + } + if (opts.streamName !== undefined && opts.streamName !== null) { + queryParams['streamName'] = opts.streamName + } + if (opts.ispName !== undefined && opts.ispName !== null) { + queryParams['ispName'] = opts.ispName + } + if (opts.locationName !== undefined && opts.locationName !== null) { + queryParams['locationName'] = opts.locationName + } + if (opts.period !== undefined && opts.period !== null) { + queryParams['period'] = opts.period + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveStatisticGroupByStream 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( + '/describeLiveStatisticGroupByStream', + '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.domainName - 播放域名 + * @param {string} opts.appName - 应用名称 + * @param {string} opts.streamName - 流名称 + * @param {string} [opts.ispName] - 运营商 + optional + * @param {string} [opts.locationName] - 查询的区域,如beijing,shanghai。多个用逗号分隔 + optional + * @param {string} [opts.period] - 查询周期,当前取值范围:“oneMin,fiveMin,halfHour,hour,twoHour,sixHour,day,followTime”,分别表示1min,5min,半小时,1小时,2小时,6小时,1天,跟随时间。默认为空,表示fiveMin。当传入followTime时,表示按Endtime-StartTime的周期,只返回一个点 + optional + * @param {string} opts.startTime - 起始时间 +- UTC时间 + 格式:yyyy-MM-dd'T'HH:mm:ss'Z' + 示例:2018-10-21T10:00:00Z + + * @param {string} [opts.endTime] - 结束时间: +- UTC时间 + 格式:yyyy-MM-dd'T'HH:mm:ss'Z' + 示例:2018-10-21T10:00:00Z +- 为空,默认为当前时间,查询时间跨度不超过1天 + optional + * @param {string} callback - callback + @return {Object} result + * @param liveStatisticGroupByAreaResult dataList + */ + + describeLiveStatisticGroupByArea (opts, callback) { + opts = opts || {} + + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling describeLiveStatisticGroupByArea" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling describeLiveStatisticGroupByArea" + ) + } + if (opts.streamName === undefined || opts.streamName === null) { + throw new Error( + "Missing the required parameter 'opts.streamName' when calling describeLiveStatisticGroupByArea" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeLiveStatisticGroupByArea" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + if (opts.appName !== undefined && opts.appName !== null) { + queryParams['appName'] = opts.appName + } + if (opts.streamName !== undefined && opts.streamName !== null) { + queryParams['streamName'] = opts.streamName + } + if (opts.ispName !== undefined && opts.ispName !== null) { + queryParams['ispName'] = opts.ispName + } + if (opts.locationName !== undefined && opts.locationName !== null) { + queryParams['locationName'] = opts.locationName + } + if (opts.period !== undefined && opts.period !== null) { + queryParams['period'] = opts.period + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveStatisticGroupByArea 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( + '/describeLiveStatisticGroupByArea', + '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.domainName - 播放域名 + * @param {string} [opts.appName] - 应用名称 optional + * @param {string} [opts.streamName] - 流名称 optional + * @param {string} [opts.ispName] - 运营商 + optional + * @param {string} [opts.locationName] - 查询的区域,如beijing,shanghai。多个用逗号分隔 + optional + * @param {string} [opts.protocolType] - 查询的流协议类型,取值范围:"rtmp,hdl,hls",多个时以逗号分隔 + optional + * @param {string} [opts.period] - 查询周期,当前取值范围:“oneMin,fiveMin,halfHour,hour,twoHour,sixHour,day,followTime”,分别表示1min,5min,半小时,1小时,2小时,6小时,1天,跟随时间。默认为空,表示fiveMin。当传入followTime时,表示按Endtime-StartTime的周期,只返回一个点 + optional + * @param {string} opts.startTime - 起始时间 +- UTC时间 + 格式:yyyy-MM-dd'T'HH:mm:ss'Z' + 示例:2018-10-21T10:00:00Z + + * @param {string} [opts.endTime] - 结束时间: +- UTC时间 + 格式:yyyy-MM-dd'T'HH:mm:ss'Z' + 示例:2018-10-21T10:00:00Z +- 为空,默认为当前时间,查询时间跨度不超过1天 + optional + * @param {string} callback - callback + @return {Object} result + * @param liveStatisticGroupByAreaIspResult dataList + */ + + describeLiveStatisticGroupByAreaIsp (opts, callback) { + opts = opts || {} + + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling describeLiveStatisticGroupByAreaIsp" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeLiveStatisticGroupByAreaIsp" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + if (opts.appName !== undefined && opts.appName !== null) { + queryParams['appName'] = opts.appName + } + if (opts.streamName !== undefined && opts.streamName !== null) { + queryParams['streamName'] = opts.streamName + } + if (opts.ispName !== undefined && opts.ispName !== null) { + queryParams['ispName'] = opts.ispName + } + if (opts.locationName !== undefined && opts.locationName !== null) { + queryParams['locationName'] = opts.locationName + } + if (opts.protocolType !== undefined && opts.protocolType !== null) { + queryParams['protocolType'] = opts.protocolType + } + if (opts.period !== undefined && opts.period !== null) { + queryParams['period'] = opts.period + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveStatisticGroupByAreaIsp 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( + '/describeLiveStatisticGroupByAreaIsp', + '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.domainName] - 播放域名 optional + * @param {string} [opts.appName] - 应用名称 optional + * @param {string} [opts.streamName] - 流名称 optional + * @param {string} [opts.ispName] - 运营商 + optional + * @param {string} [opts.locationName] - 查询的区域,如beijing,shanghai。多个用逗号分隔 + optional + * @param {string} [opts.period] - 查询周期,当前取值范围:“oneMin,fiveMin,halfHour,hour,twoHour,sixHour,day,followTime”,分别表示1min,5min,半小时,1小时,2小时,6小时,1天,跟随时间。默认为空,表示fiveMin。当传入followTime时,表示按Endtime-StartTime的周期,只返回一个点 + optional + * @param {string} opts.startTime - 起始时间 +- UTC时间 + 格式:yyyy-MM-dd'T'HH:mm:ss'Z' + 示例:2018-10-21T10:00:00Z + + * @param {string} [opts.endTime] - 结束时间: +- UTC时间 + 格式:yyyy-MM-dd'T'HH:mm:ss'Z' + 示例:2018-10-21T10:00:00Z +- 为空,默认为当前时间,查询时间跨度不超过1天 + optional + * @param {string} callback - callback + @return {Object} result + * @param liveStatisticGroupByStreamResult dataList + */ + + describeLivePublishStatisticGroupByStream (opts, callback) { + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeLivePublishStatisticGroupByStream" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + if (opts.appName !== undefined && opts.appName !== null) { + queryParams['appName'] = opts.appName + } + if (opts.streamName !== undefined && opts.streamName !== null) { + queryParams['streamName'] = opts.streamName + } + if (opts.ispName !== undefined && opts.ispName !== null) { + queryParams['ispName'] = opts.ispName + } + if (opts.locationName !== undefined && opts.locationName !== null) { + queryParams['locationName'] = opts.locationName + } + if (opts.period !== undefined && opts.period !== null) { + queryParams['period'] = opts.period + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLivePublishStatisticGroupByStream 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( + '/describeLivePublishStatisticGroupByStream', + '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.domainName - 推流域名 + * @param {string} opts.appName - 应用名称 + * @param {string} opts.streamName - 流名称 + * @param {string} opts.startTime - 起始时间 +- UTC时间 + 格式:yyyy-MM-dd'T'HH:mm:ss'Z' + 示例:2018-10-21T10:00:00Z + + * @param {string} [opts.endTime] - 结束时间: +- UTC时间 + 格式:yyyy-MM-dd'T'HH:mm:ss'Z' + 示例:2018-10-21T10:00:00Z +- 为空,默认为当前时间,查询时间跨度不超过1天 + optional + * @param {string} callback - callback + @return {Object} result + * @param publishStreamInfoResult dataList + */ + + describePublishStreamInfoData (opts, callback) { + opts = opts || {} + + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling describePublishStreamInfoData" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling describePublishStreamInfoData" + ) + } + if (opts.streamName === undefined || opts.streamName === null) { + throw new Error( + "Missing the required parameter 'opts.streamName' when calling describePublishStreamInfoData" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describePublishStreamInfoData" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + if (opts.appName !== undefined && opts.appName !== null) { + queryParams['appName'] = opts.appName + } + if (opts.streamName !== undefined && opts.streamName !== null) { + queryParams['streamName'] = opts.streamName + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describePublishStreamInfoData 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( + '/describePublishStreamInfoData', + '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.domainName] - 播放域名 optional + * @param {string} [opts.appName] - 应用名称 optional + * @param {string} [opts.streamName] - 流名称 optional + * @param {string} [opts.ispName] - 运营商 + optional + * @param {string} [opts.locationName] - 查询的区域,如beijing,shanghai。多个用逗号分隔 + optional + * @param {string} [opts.protocolType] - 查询的流协议类型,取值范围:"rtmp,hdl,hls",多个时以逗号分隔 + optional + * @param {string} [opts.period] - 查询周期,当前取值范围:“oneMin,fiveMin,halfHour,hour,twoHour,sixHour,day,followTime”,分别表示1min,5min,半小时,1小时,2小时,6小时,1天,跟随时间。默认为空,表示fiveMin。当传入followTime时,表示按Endtime-StartTime的周期,只返回一个点 + optional + * @param {string} opts.startTime - 起始时间 +- UTC时间 + 格式:yyyy-MM-dd'T'HH:mm:ss'Z' + 示例:2018-10-21T10:00:00Z + + * @param {string} [opts.endTime] - 结束时间: +- UTC时间 + 格式:yyyy-MM-dd'T'HH:mm:ss'Z' + 示例:2018-10-21T10:00:00Z +- 为空,默认为当前时间 + optional + * @param {string} callback - callback + @return {Object} result + * @param liveStreamUserNumResult dataList + */ + + describeLiveStreamHistoryUserNum (opts, callback) { + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeLiveStreamHistoryUserNum" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + if (opts.appName !== undefined && opts.appName !== null) { + queryParams['appName'] = opts.appName + } + if (opts.streamName !== undefined && opts.streamName !== null) { + queryParams['streamName'] = opts.streamName + } + if (opts.ispName !== undefined && opts.ispName !== null) { + queryParams['ispName'] = opts.ispName + } + if (opts.locationName !== undefined && opts.locationName !== null) { + queryParams['locationName'] = opts.locationName + } + if (opts.protocolType !== undefined && opts.protocolType !== null) { + queryParams['protocolType'] = opts.protocolType + } + if (opts.period !== undefined && opts.period !== null) { + queryParams['period'] = opts.period + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveStreamHistoryUserNum 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( + '/describeLiveStreamHistoryUserNum', + '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.domainName] - 播放域名 optional + * @param {string} [opts.appName] - 应用名称 optional + * @param {string} [opts.protocolType] - 查询的流协议类型,取值范围:"rtmp,hdl,hls",多个时以逗号分隔 + optional + * @param {string} [opts.ispName] - 运营商 + optional + * @param {string} [opts.locationName] - 查询的区域,如beijing,shanghai。多个用逗号分隔 + optional + * @param {string} [opts.period] - 查询周期,当前取值范围:“oneMin,fiveMin,halfHour,hour,twoHour,sixHour,day,followTime”,分别表示1min,5min,半小时,1小时,2小时,6小时,1天,跟随时间。默认为空,表示fiveMin。当传入followTime时,表示按Endtime-StartTime的周期,只返回一个点 + optional + * @param {string} opts.startTime - 起始时间 +- UTC时间 + 格式:yyyy-MM-dd'T'HH:mm:ss'Z' + 示例:2018-10-21T10:00:00Z + + * @param {string} [opts.endTime] - 结束时间: +- UTC时间 + 格式:yyyy-MM-dd'T'HH:mm:ss'Z' + 示例:2018-10-21T10:00:00Z +- 为空,默认为当前时间 + optional + * @param {string} callback - callback + @return {Object} result + * @param liveStreamUserNumResult dataList + */ + + describeLivePublishStreamNum (opts, callback) { + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeLivePublishStreamNum" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + if (opts.appName !== undefined && opts.appName !== null) { + queryParams['appName'] = opts.appName + } + if (opts.protocolType !== undefined && opts.protocolType !== null) { + queryParams['protocolType'] = opts.protocolType + } + if (opts.ispName !== undefined && opts.ispName !== null) { + queryParams['ispName'] = opts.ispName + } + if (opts.locationName !== undefined && opts.locationName !== null) { + queryParams['locationName'] = opts.locationName + } + if (opts.period !== undefined && opts.period !== null) { + queryParams['period'] = opts.period + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLivePublishStreamNum 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( + '/describeLivePublishStreamNum', + '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.domainName - 推流域名 + * @param {string} opts.appName - 应用名称 + * @param {string} opts.protocolType - 协议,取值范围:"hdl,hls" + + * @param {string} opts.startTime - 起始时间 +- UTC时间 + 格式:yyyy-MM-dd'T'HH:mm:ss'Z' + 示例:2018-10-21T10:00:00Z + + * @param {string} [opts.endTime] - 结束时间: +- UTC时间 + 格式:yyyy-MM-dd'T'HH:mm:ss'Z' + 示例:2018-10-21T10:00:00Z +- 为空,默认为当前时间,时间跨度不不超过⼀一天 + optional + * @param {string} callback - callback + @return {Object} result + * @param liveStreamPlayerRankingResult dataList + */ + + describeLiveStreamPlayerRankingData (opts, callback) { + opts = opts || {} + + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling describeLiveStreamPlayerRankingData" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling describeLiveStreamPlayerRankingData" + ) + } + if (opts.protocolType === undefined || opts.protocolType === null) { + throw new Error( + "Missing the required parameter 'opts.protocolType' when calling describeLiveStreamPlayerRankingData" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeLiveStreamPlayerRankingData" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + if (opts.appName !== undefined && opts.appName !== null) { + queryParams['appName'] = opts.appName + } + if (opts.protocolType !== undefined && opts.protocolType !== null) { + queryParams['protocolType'] = opts.protocolType + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveStreamPlayerRankingData 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( + '/describeLiveStreamPlayerRankingData', + '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.domainName - 推流域名 + + * @param {string} opts.appName - 应用名称 + + * @param {string} opts.streamName - 流名称 + + * @param {string} callback - callback + @return {Object} result + * @param liveTranscodeStreamResult dataList + */ + + describeLiveTranscodeStreamList (opts, callback) { + opts = opts || {} + + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling describeLiveTranscodeStreamList" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling describeLiveTranscodeStreamList" + ) + } + if (opts.streamName === undefined || opts.streamName === null) { + throw new Error( + "Missing the required parameter 'opts.streamName' when calling describeLiveTranscodeStreamList" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + if (opts.appName !== undefined && opts.appName !== null) { + queryParams['appName'] = opts.appName + } + if (opts.streamName !== undefined && opts.streamName !== null) { + queryParams['streamName'] = opts.streamName + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveTranscodeStreamList 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( + '/describeLiveTranscodeStreamList', + '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.domainName] - 推流域名 optional + * @param {string} callback - callback + @return {Object} result + * @param string datetime 时间 + * @param integer streamCount 流数量 + */ + + describeLiveTranscodeStreamNum (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveTranscodeStreamNum 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( + '/describeLiveTranscodeStreamNum', + '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.domainName - 推流域名 + * @param {string} opts.appName - 应用名称 + * @param {string} [opts.ispName] - 运营商 + optional + * @param {string} [opts.locationName] - 查询的区域,如beijing,shanghai。多个用逗号分隔 + optional + * @param {string} [opts.protocolType] - 查询的流协议类型,取值范围:"rtmp,hdl,hls",多个时以逗号分隔 + optional + * @param {string} [opts.period] - 查询周期,当前取值范围:“oneMin,fiveMin,halfHour,hour,twoHour,sixHour,day,followTime”,分别表示1min,5min,半小时,1小时,2小时,6小时,1天,跟随时间。默认为空,表示fiveMin。当传入followTime时,表示按Endtime-StartTime的周期,只返回一个点 + optional + * @param {string} opts.startTime - 查询起始时间,UTC时间,格式:yyyy-MM-dd'T'HH:mm:ss'Z' + + * @param {string} [opts.endTime] - 查询截至时间,UTC时间,格式:yyyy-MM-dd'T'HH:mm:ss'Z',为空时默认为当前时间 + optional + * @param {string} callback - callback + @return {Object} result + * @param liveStreamUserNumResult dataList + */ + + describeLiveTranscodeStreamPlayerUserNum (opts, callback) { + opts = opts || {} + + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling describeLiveTranscodeStreamPlayerUserNum" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling describeLiveTranscodeStreamPlayerUserNum" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeLiveTranscodeStreamPlayerUserNum" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + if (opts.appName !== undefined && opts.appName !== null) { + queryParams['appName'] = opts.appName + } + if (opts.ispName !== undefined && opts.ispName !== null) { + queryParams['ispName'] = opts.ispName + } + if (opts.locationName !== undefined && opts.locationName !== null) { + queryParams['locationName'] = opts.locationName + } + if (opts.protocolType !== undefined && opts.protocolType !== null) { + queryParams['protocolType'] = opts.protocolType + } + if (opts.period !== undefined && opts.period !== null) { + queryParams['period'] = opts.period + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveTranscodeStreamPlayerUserNum 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( + '/describeLiveTranscodeStreamPlayerUserNum', + '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) + } + ) + } + + /** + * 查询转码流播放带宽 +- 查询1分钟粒度的数据时,时间跨度不超过7天,其他粒度时时间跨度不超过30天 + + * @param {Object} opts - parameters + * @param {string} opts.domainName - 推流域名 + * @param {string} opts.appName - 应用名称 + * @param {string} [opts.ispName] - 运营商 + optional + * @param {string} [opts.locationName] - 查询的区域,如beijing,shanghai。多个用逗号分隔 + optional + * @param {string} [opts.protocolType] - 查询的流协议类型,取值范围:"rtmp,hdl,hls",多个时以逗号分隔 + optional + * @param {string} [opts.period] - 查询周期,当前取值范围:“oneMin,fiveMin,halfHour,hour,twoHour,sixHour,day,followTime”,分别表示1min,5min,半小时,1小时,2小时,6小时,1天,跟随时间。默认为空,表示fiveMin。当传入followTime时,表示按Endtime-StartTime的周期,只返回一个点 + optional + * @param {string} opts.startTime - 查询起始时间,UTC时间,格式:yyyy-MM-dd'T'HH:mm:ss'Z' + + * @param {string} [opts.endTime] - 查询截至时间,UTC时间,格式:yyyy-MM-dd'T'HH:mm:ss'Z',为空时默认为当前时间 + optional + * @param {string} callback - callback + @return {Object} result + * @param bandwidthStatisticResult dataList + */ + + describeLiveTranscodeStreamBandwidth (opts, callback) { + opts = opts || {} + + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling describeLiveTranscodeStreamBandwidth" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling describeLiveTranscodeStreamBandwidth" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeLiveTranscodeStreamBandwidth" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + if (opts.appName !== undefined && opts.appName !== null) { + queryParams['appName'] = opts.appName + } + if (opts.ispName !== undefined && opts.ispName !== null) { + queryParams['ispName'] = opts.ispName + } + if (opts.locationName !== undefined && opts.locationName !== null) { + queryParams['locationName'] = opts.locationName + } + if (opts.protocolType !== undefined && opts.protocolType !== null) { + queryParams['protocolType'] = opts.protocolType + } + if (opts.period !== undefined && opts.period !== null) { + queryParams['period'] = opts.period + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveTranscodeStreamBandwidth 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( + '/describeLiveTranscodeStreamBandwidth', + '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.domainName - 推流域名 + * @param {string} [opts.appName] - 应用名称 optional + * @param {string} [opts.streamName] - 流名称 optional + * @param {integer} [opts.pageNum] - 页码,起始页码1 + optional + * @param {integer} [opts.pageSize] - 每页最大记录数,取值:[10,100],默认:10 + optional + * @param {string} opts.startTime - 起始时间 +- UTC时间 + 格式:yyyy-MM-dd'T'HH:mm:ss'Z' + 示例:2018-10-21T10:00:00Z + + * @param {string} [opts.endTime] - 结束时间: +- UTC时间 + 格式:yyyy-MM-dd'T'HH:mm:ss'Z' + 示例:2018-10-21T10:00:00Z +- 为空,默认为当前时间,查询时间跨度不超过30天 + optional + * @param {string} callback - callback + @return {Object} result + * @param publishOnlineStreamResultData streamList + * @param integer total 流数量 + */ + + describeDomainOnlineStream (opts, callback) { + opts = opts || {} + + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling describeDomainOnlineStream" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeDomainOnlineStream" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + if (opts.appName !== undefined && opts.appName !== null) { + queryParams['appName'] = opts.appName + } + if (opts.streamName !== undefined && opts.streamName !== null) { + queryParams['streamName'] = opts.streamName + } + if (opts.pageNum !== undefined && opts.pageNum !== null) { + queryParams['pageNum'] = opts.pageNum + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeDomainOnlineStream 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( + '/describeDomainOnlineStream', + '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.domains - 播放域名,多个时以逗号(,)分隔 + * @param {string} [opts.interval] - 时间间隔,取值(hour,day),不传默认小时 +- 按小时(hour)下载时是.log文件 +- 按天(day)下载时是.zip文件 + optional + * @param {string} opts.startTime - 起始时间 +- UTC时间 + 格式:yyyy-MM-dd'T'HH:mm:ss'Z' + 示例:2018-10-21T10:00:00Z + + * @param {string} [opts.endTime] - 结束时间: +- UTC时间 + 格式:yyyy-MM-dd'T'HH:mm:ss'Z' + 示例:2018-10-21T10:00:00Z +- 为空,默认为当前时间 + optional + * @param {string} callback - callback + @return {Object} result + * @param domainsLogResult dataList + */ + + describeDomainsLog (opts, callback) { + opts = opts || {} + + if (opts.domains === undefined || opts.domains === null) { + throw new Error( + "Missing the required parameter 'opts.domains' when calling describeDomainsLog" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeDomainsLog" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domains !== undefined && opts.domains !== null) { + queryParams['domains'] = opts.domains + } + if (opts.interval !== undefined && opts.interval !== null) { + queryParams['interval'] = opts.interval + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeDomainsLog 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( + '/describeDomainsLog', + '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) + } + ) + } + + /** + * 查询URL播放排行 + * @param {Object} opts - parameters + * @param {string} opts.domainName - 播放域名 + * @param {integer} [opts.size] - 查询Top数量,默认20,即返回Top20的数据 optional + * @param {string} [opts.rankfield] - 排行依据字段,取值:["pv", "flow", "bandwidth"],默认pv +- pv 播放次数 +- flow 流量 +- bandwidth 带宽 + optional + * @param {string} opts.startTime - 起始时间 +- UTC时间 + 格式:yyyy-MM-dd'T'HH:mm:ss'Z' + 示例:2018-10-21T10:00:00Z + + * @param {string} [opts.endTime] - 结束时间: +- UTC时间 + 格式:yyyy-MM-dd'T'HH:mm:ss'Z' + 示例:2018-10-21T10:00:00Z +- 为空,默认为当前时间 + optional + * @param {string} callback - callback + @return {Object} result + * @param rankingUrlResult dataList + */ + + describeUrlRanking (opts, callback) { + opts = opts || {} + + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling describeUrlRanking" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeUrlRanking" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + if (opts.size !== undefined && opts.size !== null) { + queryParams['size'] = opts.size + } + if (opts.rankfield !== undefined && opts.rankfield !== null) { + queryParams['rankfield'] = opts.rankfield + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeUrlRanking 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( + '/describeUrlRanking', + '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.domainName - 推流域名 + * @param {string} [opts.appName] - 应用名称 optional + * @param {string} [opts.streamName] - 流名称 optional + * @param {string} opts.startTime - 起始时间 +- UTC时间 + 格式:yyyy-MM-dd'T'HH:mm:ss'Z' + 示例:2018-10-21T10:00:00Z + + * @param {string} [opts.endTime] - 结束时间: +- UTC时间 + 格式:yyyy-MM-dd'T'HH:mm:ss'Z' + 示例:2018-10-21T10:00:00Z +- 为空,默认为当前时间 + optional + * @param {integer} [opts.pageNumber] - 页码,起始页码1 + optional + * @param {integer} [opts.pageSize] - 每页最大记录数,取值:[10,1000],默认:100 + optional + * @param {string} callback - callback + @return {Object} result + * @param integer pageNumber 当前页码 + * @param integer pageSize 每页数量 + * @param integer totalCount 查询总数 + * @param liveStreamPublishInfo publishInfoList + */ + + describeLiveStreamPublishInfoByPage (opts, callback) { + opts = opts || {} + + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling describeLiveStreamPublishInfoByPage" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeLiveStreamPublishInfoByPage" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + if (opts.appName !== undefined && opts.appName !== null) { + queryParams['appName'] = opts.appName + } + if (opts.streamName !== undefined && opts.streamName !== null) { + queryParams['streamName'] = opts.streamName + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + 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: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveStreamPublishInfoByPage 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( + '/describeLiveStreamPublishInfoByPage', + '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.domainName - 推流域名 + * @param {string} [opts.appName] - 应用名称 optional + * @param {string} [opts.streamName] - 流名称 optional + * @param {string} opts.startTime - 起始时间 +- UTC时间 + 格式:yyyy-MM-dd'T'HH:mm:ss'Z' + 示例:2018-10-21T10:00:00Z + + * @param {string} [opts.endTime] - 结束时间: +- UTC时间 + 格式:yyyy-MM-dd'T'HH:mm:ss'Z' + 示例:2018-10-21T10:00:00Z +- 为空,默认为当前时间 + optional + * @param {integer} [opts.pageNumber] - 页码,起始页码1 + optional + * @param {integer} [opts.pageSize] - 每页最大记录数,取值:[10,1000],默认:100 + optional + * @param {string} callback - callback + @return {Object} result + * @param integer pageNumber 当前页码 + * @param integer pageSize 每页数量 + * @param integer totalCount 查询总数 + * @param liveStreamPlayInfo playInfoList + */ + + describeLiveStreamPlayInfoByPage (opts, callback) { + opts = opts || {} + + if (opts.domainName === undefined || opts.domainName === null) { + throw new Error( + "Missing the required parameter 'opts.domainName' when calling describeLiveStreamPlayInfoByPage" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeLiveStreamPlayInfoByPage" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + if (opts.appName !== undefined && opts.appName !== null) { + queryParams['appName'] = opts.appName + } + if (opts.streamName !== undefined && opts.streamName !== null) { + queryParams['streamName'] = opts.streamName + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + 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: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveStreamPlayInfoByPage 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( + '/describeLiveStreamPlayInfoByPage', + '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.domainName] - 播放域名 optional + * @param {string} [opts.grade] - 码率档次,可以查询指定档次的转码时长,取值: +- video_h264_4k_1 +- video_h264_2k_1 +- video_h264_shd_1 +- video_h264_hd_1 +- video_h264_sd_1 +- video_h265_4k_1 +- video_h265_2k_1 +- video_h265_shd_1 +- video_h265_hd_1 +- video_h265_sd_1 + optional + * @param {string} [opts.period] - 查询周期,取值范围:“day,month,year,followTime”,分别表示1天,1月,1年,跟随时间。默认为空,表示day。当传入followTime时,表示按Endtime-StartTime的周期,只返回一个点 + optional + * @param {string} opts.startTime - 查询起始时间,UTC时间,格式:yyyy-MM-dd'T'HH:mm:ss'Z' + + * @param {string} [opts.endTime] - 查询截至时间,UTC时间,格式:yyyy-MM-dd'T'HH:mm:ss'Z',为空时默认为当前时间 + optional + * @param {string} callback - callback + @return {Object} result + * @param transcodeDurationStatisticResult dataList + */ + + describeLiveTranscodingDurationData (opts, callback) { + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeLiveTranscodingDurationData" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + if (opts.grade !== undefined && opts.grade !== null) { + queryParams['grade'] = opts.grade + } + if (opts.period !== undefined && opts.period !== null) { + queryParams['period'] = opts.period + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveTranscodingDurationData 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( + '/describeLiveTranscodingDurationData', + '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.period] - 查询周期,取值范围:“day,month,year,followTime”,分别表示1天,1月,1年,跟随时间。默认为空,表示day。当传入followTime时,表示按Endtime-StartTime的周期,只返回一个点 + optional + * @param {string} opts.startTime - 查询起始时间,UTC时间,格式:yyyy-MM-dd'T'HH:mm:ss'Z' + + * @param {string} [opts.endTime] - 查询截至时间,UTC时间,格式:yyyy-MM-dd'T'HH:mm:ss'Z',为空时默认为当前时间 + optional + * @param {string} callback - callback + @return {Object} result + * @param fileStorageStatisticResult dataList + */ + + describeLiveFileStorageData (opts, callback) { + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeLiveFileStorageData" + ) + } + + let postBody = null + let queryParams = {} + if (opts.period !== undefined && opts.period !== null) { + queryParams['period'] = opts.period + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveFileStorageData 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( + '/describeLiveFileStorageData', + '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) + } + ) + } + + /** + * 查询带宽数据 +- 查询某个时间段内的带宽数据(平均带宽) +- 查询1分钟粒度的数据时,时间跨度不超过7天,其他粒度时时间跨度不超过30天 + + * @param {Object} opts - parameters + * @param {string} [opts.domainName] - 播放域名,可以通过指定域名查询该域名下产生的带宽数据。 + optional + * @param {string} [opts.appName] - 推流AppName,将AppName作为查询条件时须指定域名。 + optional + * @param {string} [opts.streamName] - 流名称,将流名称作为查询条件时须指定域名和AppName。 + optional + * @param {string} [opts.ispName] - 运营商 + optional + * @param {string} [opts.locationName] - 查询的区域,如beijing,shanghai。多个用逗号分隔 + optional + * @param {string} [opts.protocolType] - 查询的流协议类型,取值范围:"rtmp,hdl,hls",多个时以逗号分隔 + optional + * @param {string} [opts.period] - 查询周期,当前取值范围:“oneMin,fiveMin,halfHour,hour,twoHour,sixHour,day,followTime”,分别表示1min,5min,半小时,1小时,2小时,6小时,1天,跟随时间。默认为空,表示fiveMin。当传入followTime时,表示按Endtime-StartTime的周期,只返回一个点 + optional + * @param {string} opts.startTime - 查询起始时间,UTC时间,格式:yyyy-MM-dd'T'HH:mm:ss'Z' + + * @param {string} [opts.endTime] - 查询截至时间,UTC时间,格式:yyyy-MM-dd'T'HH:mm:ss'Z',为空时默认为当前时间 + optional + * @param {string} callback - callback + @return {Object} result + * @param bandwidthStatisticResult dataList + */ + + describeLiveStreamBandwidthData (opts, callback) { + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeLiveStreamBandwidthData" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + if (opts.appName !== undefined && opts.appName !== null) { + queryParams['appName'] = opts.appName + } + if (opts.streamName !== undefined && opts.streamName !== null) { + queryParams['streamName'] = opts.streamName + } + if (opts.ispName !== undefined && opts.ispName !== null) { + queryParams['ispName'] = opts.ispName + } + if (opts.locationName !== undefined && opts.locationName !== null) { + queryParams['locationName'] = opts.locationName + } + if (opts.protocolType !== undefined && opts.protocolType !== null) { + queryParams['protocolType'] = opts.protocolType + } + if (opts.period !== undefined && opts.period !== null) { + queryParams['period'] = opts.period + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveStreamBandwidthData 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( + '/describeLiveStreamBandwidthData', + '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) + } + ) + } + + /** + * 查询推流带宽 +- 查询某个时间段内的推流上行带宽数据 +- 查询1分钟粒度的数据时,时间跨度不超过7天,其他粒度时时间跨度不超过30天 + + * @param {Object} opts - parameters + * @param {string} [opts.domainName] - 推流域名,可以通过指定域名查询该域名下产生的带宽数据。 + optional + * @param {string} [opts.appName] - 推流AppName,将AppName作为查询条件时须指定域名。 + optional + * @param {string} [opts.streamName] - 流名称,将流名称作为查询条件时须指定域名和AppName。 + optional + * @param {string} [opts.ispName] - 运营商 + optional + * @param {string} [opts.locationName] - 查询的区域,如beijing,shanghai。多个用逗号分隔 + optional + * @param {string} [opts.protocolType] - 查询的流协议类型,取值范围:"rtmp,hdl,hls",多个时以逗号分隔 + optional + * @param {string} [opts.period] - 查询周期,当前取值范围:“oneMin,fiveMin,halfHour,hour,twoHour,sixHour,day,followTime”,分别表示1min,5min,半小时,1小时,2小时,6小时,1天,跟随时间。默认为空,表示fiveMin。当传入followTime时,表示按Endtime-StartTime的周期,只返回一个点 + optional + * @param {string} opts.startTime - 查询起始时间,UTC时间,格式:yyyy-MM-dd'T'HH:mm:ss'Z' + + * @param {string} [opts.endTime] - 查询截至时间,UTC时间,格式:yyyy-MM-dd'T'HH:mm:ss'Z',为空时默认为当前时间 + optional + * @param {string} callback - callback + @return {Object} result + * @param bandwidthStatisticResult dataList + */ + + describeLiveStreamPublishBandwidthData (opts, callback) { + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeLiveStreamPublishBandwidthData" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + if (opts.appName !== undefined && opts.appName !== null) { + queryParams['appName'] = opts.appName + } + if (opts.streamName !== undefined && opts.streamName !== null) { + queryParams['streamName'] = opts.streamName + } + if (opts.ispName !== undefined && opts.ispName !== null) { + queryParams['ispName'] = opts.ispName + } + if (opts.locationName !== undefined && opts.locationName !== null) { + queryParams['locationName'] = opts.locationName + } + if (opts.protocolType !== undefined && opts.protocolType !== null) { + queryParams['protocolType'] = opts.protocolType + } + if (opts.period !== undefined && opts.period !== null) { + queryParams['period'] = opts.period + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveStreamPublishBandwidthData 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( + '/describeLiveStreamPublishBandwidthData', + '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) + } + ) + } + + /** + * 查询流量数据 +- 查询某个时间段内的流量数据。 +- 查询1分钟粒度的数据时,时间跨度不超过7天,其他粒度时时间跨度不超过30天 + + * @param {Object} opts - parameters + * @param {string} [opts.domainName] - 播放域名,可以通过指定域名查询该域名下产生的带宽数据。 + optional + * @param {string} [opts.appName] - 推流AppName,将AppName作为查询条件时须指定域名。 + optional + * @param {string} [opts.streamName] - 流名称 + optional + * @param {string} [opts.ispName] - 运营商 + optional + * @param {string} [opts.locationName] - 查询的区域,如beijing,shanghai。多个用逗号分隔 + optional + * @param {string} [opts.protocolType] - 查询的流协议类型,取值范围:"rtmp,hdl,hls",多个时以逗号分隔 + optional + * @param {string} [opts.period] - 查询周期,当前取值范围:“oneMin,fiveMin,halfHour,hour,twoHour,sixHour,day,followTime”,分别表示1min,5min,半小时,1小时,2小时,6小时,1天,跟随时间。默认为空,表示fiveMin。当传入followTime时,表示按Endtime-StartTime的周期,只返回一个点 + optional + * @param {string} opts.startTime - 查询起始时间,UTC时间,格式:yyyy-MM-dd'T'HH:mm:ss'Z' + + * @param {string} [opts.endTime] - 查询截至时间,UTC时间,格式:yyyy-MM-dd'T'HH:mm:ss'Z',为空时默认为当前时间 + optional + * @param {string} callback - callback + @return {Object} result + * @param trafficStatisticResult dataList + */ + + describeLiveStreamTrafficData (opts, callback) { + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeLiveStreamTrafficData" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + if (opts.appName !== undefined && opts.appName !== null) { + queryParams['appName'] = opts.appName + } + if (opts.streamName !== undefined && opts.streamName !== null) { + queryParams['streamName'] = opts.streamName + } + if (opts.ispName !== undefined && opts.ispName !== null) { + queryParams['ispName'] = opts.ispName + } + if (opts.locationName !== undefined && opts.locationName !== null) { + queryParams['locationName'] = opts.locationName + } + if (opts.protocolType !== undefined && opts.protocolType !== null) { + queryParams['protocolType'] = opts.protocolType + } + if (opts.period !== undefined && opts.period !== null) { + queryParams['period'] = opts.period + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveStreamTrafficData 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( + '/describeLiveStreamTrafficData', + '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) + } + ) + } + + /** + * 查询推流上行流量数据 +- 查询某个时间段内的流量数据。 +- 查询1分钟粒度的数据时,时间跨度不超过7天,其他粒度时时间跨度不超过30天 + + * @param {Object} opts - parameters + * @param {string} [opts.domainName] - 推流域名,可以通过指定域名查询该域名下产生的带宽数据。 + optional + * @param {string} [opts.appName] - 推流AppName,将AppName作为查询条件时须指定域名。 + optional + * @param {string} [opts.streamName] - 流名称 + optional + * @param {string} [opts.ispName] - 运营商 + optional + * @param {string} [opts.locationName] - 查询的区域,如beijing,shanghai。多个用逗号分隔 + optional + * @param {string} [opts.protocolType] - 查询的流协议类型,取值范围:"rtmp,hdl,hls",多个时以逗号分隔 + optional + * @param {string} [opts.period] - 查询周期,当前取值范围:“oneMin,fiveMin,halfHour,hour,twoHour,sixHour,day,followTime”,分别表示1min,5min,半小时,1小时,2小时,6小时,1天,跟随时间。默认为空,表示fiveMin。当传入followTime时,表示按Endtime-StartTime的周期,只返回一个点 + optional + * @param {string} opts.startTime - 查询起始时间,UTC时间,格式:yyyy-MM-dd'T'HH:mm:ss'Z' + + * @param {string} [opts.endTime] - 查询截至时间,UTC时间,格式:yyyy-MM-dd'T'HH:mm:ss'Z',为空时默认为当前时间 + optional + * @param {string} callback - callback + @return {Object} result + * @param trafficStatisticResult dataList + */ + + describeLiveStreamPublishTrafficData (opts, callback) { + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeLiveStreamPublishTrafficData" + ) + } + + let postBody = null + let queryParams = {} + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + if (opts.appName !== undefined && opts.appName !== null) { + queryParams['appName'] = opts.appName + } + if (opts.streamName !== undefined && opts.streamName !== null) { + queryParams['streamName'] = opts.streamName + } + if (opts.ispName !== undefined && opts.ispName !== null) { + queryParams['ispName'] = opts.ispName + } + if (opts.locationName !== undefined && opts.locationName !== null) { + queryParams['locationName'] = opts.locationName + } + if (opts.protocolType !== undefined && opts.protocolType !== null) { + queryParams['protocolType'] = opts.protocolType + } + if (opts.period !== undefined && opts.period !== null) { + queryParams['period'] = opts.period + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveStreamPublishTrafficData 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( + '/describeLiveStreamPublishTrafficData', + '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.publishDomain] - 推流域名 optional + * @param {string} [opts.appName] - 应用名称 optional + * @param {string} [opts.streamName] - 流名称 optional + * @param {integer} [opts.shotMode] - 截图模式:1表示采样截图;2表示关键帧截图(默认为2) optional + * @param {string} opts.startTime - 起始时间: +- UTC时间 + 格式: yyyy-MM-dd'T'HH:mm:ss'Z' + 示例: 2018-10-21T10:00:00Z +- 支持最大查询90天以内的数据 + + * @param {string} [opts.endTime] - 结束时间: +- UTC时间 + 格式: yyyy-MM-dd'T'HH:mm:ss'Z' + 示例: 2018-10-21T10:00:00Z +- 为空,默认当前时间 + optional + * @param {string} callback - callback + @return {Object} result + * @param snapshotCountStatisticResult snapshotData + */ + + describeLiveSnapshotData (opts, callback) { + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeLiveSnapshotData" + ) + } + + let postBody = null + let queryParams = {} + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + queryParams['publishDomain'] = opts.publishDomain + } + if (opts.appName !== undefined && opts.appName !== null) { + queryParams['appName'] = opts.appName + } + if (opts.streamName !== undefined && opts.streamName !== null) { + queryParams['streamName'] = opts.streamName + } + if (opts.shotMode !== undefined && opts.shotMode !== null) { + queryParams['shotMode'] = opts.shotMode + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveSnapshotData 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( + '/liveSnapshotData', + '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.publishDomain] - 推流域名 optional + * @param {string} [opts.appName] - 应用名称 optional + * @param {string} [opts.streamName] - 流名称 optional + * @param {string} opts.startTime - 起始时间 +- UTC时间 + 格式:yyyy-MM-dd'T'HH:mm:ss'Z' + 示例:2018-10-21T10:00:00Z +- 支持最大查询90天以内的数据 + + * @param {string} [opts.endTime] - 结束时间: +- UTC时间 + 格式:yyyy-MM-dd'T'HH:mm:ss'Z' + 示例:2018-10-21T10:00:00Z +- 为空,默认为当前时间 + optional + * @param {string} callback - callback + @return {Object} result + * @param pornCountStatisticResult pornData + */ + + describeLivePornData (opts, callback) { + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeLivePornData" + ) + } + + let postBody = null + let queryParams = {} + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + queryParams['publishDomain'] = opts.publishDomain + } + if (opts.appName !== undefined && opts.appName !== null) { + queryParams['appName'] = opts.appName + } + if (opts.streamName !== undefined && opts.streamName !== null) { + queryParams['streamName'] = opts.streamName + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLivePornData 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( + '/livePornData', + '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.format - 截图格式 +- 取值: jpg, png +- 不区分大小写 + + * @param {integer} [opts.width] - 截图宽度 +- 取值: [8,8192] +- 如果(width,height)只设置其中之一,则按所设置参数项等比缩放另一项输出截图 +- 如果(width,height)都不设置,则按源流大小输出截图 + optional + * @param {integer} [opts.height] - 截图高度 +- 取值: [8,8192] +- 如果(width,height)只设置其中之一,则按所设置参数项等比缩放另一项输出截图 +- 如果(width,height)都不设置,则按源流大小输出截图 + optional + * @param {integer} opts.fillType - 截图与设定的宽高不匹配时的处理规则 + 1: 拉伸 + 2: 留黑 + 3: 留白 + 4: 高斯模糊 +- 1是按照设定宽高拉伸 +- 2,3,4是等比例的缩放多余或不足处按调置处理 + + * @param {integer} opts.snapshotInterval - 截图周期 +- 取值范围 [5,3600] +- 单位: 秒 + + * @param {integer} opts.saveMode - 存储模式 + 1: 覆盖存储 + 2: 顺序存储 + + * @param {string} opts.saveBucket - 存储桶 + * @param {string} [opts.saveEndpoint] - 存储地址 optional + * @param {string} opts.template - 截图模板自定义名称: +- 取值要求: 数字、大小写字母或短横线("-")、下划线("_"), + 首尾不能有特殊字符("-") + 最大长度50个字符 +- <b>注意: 不能与已定义命名重复</b> + + * @param {string} callback - callback + @return {Object} result + */ + + addCustomLiveStreamSnapshotTemplate (opts, callback) { + opts = opts || {} + + if (opts.format === undefined || opts.format === null) { + throw new Error( + "Missing the required parameter 'opts.format' when calling addCustomLiveStreamSnapshotTemplate" + ) + } + if (opts.fillType === undefined || opts.fillType === null) { + throw new Error( + "Missing the required parameter 'opts.fillType' when calling addCustomLiveStreamSnapshotTemplate" + ) + } + if (opts.snapshotInterval === undefined || opts.snapshotInterval === null) { + throw new Error( + "Missing the required parameter 'opts.snapshotInterval' when calling addCustomLiveStreamSnapshotTemplate" + ) + } + if (opts.saveMode === undefined || opts.saveMode === null) { + throw new Error( + "Missing the required parameter 'opts.saveMode' when calling addCustomLiveStreamSnapshotTemplate" + ) + } + if (opts.saveBucket === undefined || opts.saveBucket === null) { + throw new Error( + "Missing the required parameter 'opts.saveBucket' when calling addCustomLiveStreamSnapshotTemplate" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling addCustomLiveStreamSnapshotTemplate" + ) + } + + let postBody = {} + if (opts.format !== undefined && opts.format !== null) { + postBody['format'] = opts.format + } + if (opts.width !== undefined && opts.width !== null) { + postBody['width'] = opts.width + } + if (opts.height !== undefined && opts.height !== null) { + postBody['height'] = opts.height + } + if (opts.fillType !== undefined && opts.fillType !== null) { + postBody['fillType'] = opts.fillType + } + if (opts.snapshotInterval !== undefined && opts.snapshotInterval !== null) { + postBody['snapshotInterval'] = opts.snapshotInterval + } + if (opts.saveMode !== undefined && opts.saveMode !== null) { + postBody['saveMode'] = opts.saveMode + } + if (opts.saveBucket !== undefined && opts.saveBucket !== null) { + postBody['saveBucket'] = opts.saveBucket + } + if (opts.saveEndpoint !== undefined && opts.saveEndpoint !== null) { + postBody['saveEndpoint'] = opts.saveEndpoint + } + if (opts.template !== undefined && opts.template !== null) { + postBody['template'] = opts.template + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 addCustomLiveStreamSnapshotTemplate 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( + '/snapshotCustoms:template', + '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) + } + ) + } + + /** + * 查询直播截图配置 +- 截图模板配置按照 域名,应用,流 3级配置添加,以最小的粒度配置生效 +- 域名、应用、流 依次粒度递减 即: 域名>应用>流 +- 该查询旨在查询域名、应用、流最终生效的截图模板配置,并非各级的模板绑定情况 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNum] - 页码 +- 取值范围 [1, 100000] + optional + * @param {integer} [opts.pageSize] - 分页大小 +- 取值范围 [10, 100] + optional + * @param {filter} [opts.filters] - 直播截图查询过滤条件: +- name: publishDomain 必填(推流域名) +- value: 参数 +- name: appName 必填(应用名称) +- value: 参数 +- name: streamName 非必填(流名称) +- value: 参数 + optional + * @param {string} callback - callback + @return {Object} result + * @param integer pageNumber 当前页码 + * @param integer pageSize 每页数量 + * @param integer totalCount 查询总数 + * @param snapshotConfig snapshotConfigs + */ + + describeCustomLiveStreamSnapshotConfig (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.pageNum !== undefined && opts.pageNum !== null) { + queryParams['pageNum'] = opts.pageNum + } + 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 live/1.0.22' + } + + 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 describeCustomLiveStreamSnapshotConfig 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( + '/snapshotCustoms:config', + '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.pageNum] - 页码 +- 取值范围 [1, 100000] + optional + * @param {integer} [opts.pageSize] - 分页大小 +- 取值范围 [10, 100] + optional + * @param {filter} [opts.filters] - 截图模板查询过滤条件 +- name: template 录制模板自定义名称 +- value: 如果参数为空,则查询全部 + optional + * @param {string} callback - callback + @return {Object} result + * @param integer pageNumber 当前页码 + * @param integer pageSize 每页数量 + * @param integer totalCount 查询总数 + * @param snapshotTemplate snapshotTemplates + */ + + describeCustomLiveStreamSnapshotTemplates (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.pageNum !== undefined && opts.pageNum !== null) { + queryParams['pageNum'] = opts.pageNum + } + 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 live/1.0.22' + } + + 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 describeCustomLiveStreamSnapshotTemplates 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( + '/snapshotCustoms', + '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.publishDomain - 推流域名 + * @param {string} opts.appName - 应用名称 + * @param {string} opts.template - 截图模板 + + * @param {string} callback - callback + @return {Object} result + */ + + addLiveStreamAppSnapshot (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling addLiveStreamAppSnapshot" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling addLiveStreamAppSnapshot" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling addLiveStreamAppSnapshot" + ) + } + + let postBody = {} + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + postBody['publishDomain'] = opts.publishDomain + } + if (opts.appName !== undefined && opts.appName !== null) { + postBody['appName'] = opts.appName + } + if (opts.template !== undefined && opts.template !== null) { + postBody['template'] = opts.template + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 addLiveStreamAppSnapshot 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( + '/snapshotApps:template', + '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.publishDomain - 推流域名 + * @param {string} opts.template - 截图模板 + + * @param {string} callback - callback + @return {Object} result + */ + + addLiveStreamDomainSnapshot (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling addLiveStreamDomainSnapshot" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling addLiveStreamDomainSnapshot" + ) + } + + let postBody = {} + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + postBody['publishDomain'] = opts.publishDomain + } + if (opts.template !== undefined && opts.template !== null) { + postBody['template'] = opts.template + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 addLiveStreamDomainSnapshot 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( + '/snapshotDomains:template', + '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.publishDomain - 推流域名 + * @param {string} opts.notifyUrl - 截图回调通知的URL地址: +- 以 http:// 开头,外网可访问的地址 + + * @param {string} callback - callback + @return {Object} result + */ + + setLiveStreamSnapshotNotifyConfig (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling setLiveStreamSnapshotNotifyConfig" + ) + } + if (opts.notifyUrl === undefined || opts.notifyUrl === null) { + throw new Error( + "Missing the required parameter 'opts.notifyUrl' when calling setLiveStreamSnapshotNotifyConfig" + ) + } + + let postBody = {} + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + postBody['publishDomain'] = opts.publishDomain + } + if (opts.notifyUrl !== undefined && opts.notifyUrl !== null) { + postBody['notifyUrl'] = opts.notifyUrl + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 setLiveStreamSnapshotNotifyConfig 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( + '/snapshotNotifys:config', + '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.template - 截图模板 + * @param {string} callback - callback + @return {Object} result + */ + + deleteCustomLiveStreamSnapshotTemplate (opts, callback) { + opts = opts || {} + + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling deleteCustomLiveStreamSnapshotTemplate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + template: opts.template + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 deleteCustomLiveStreamSnapshotTemplate 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( + '/snapshotCustoms/{template}', + '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) + } + ) + } + + /** + * 删除APP截图配置 + * @param {Object} opts - parameters + * @param {string} opts.publishDomain - 推流域名 + * @param {string} opts.appName - 应用名称 + * @param {string} opts.template - 截图模板 + + * @param {string} callback - callback + @return {Object} result + */ + + deleteLiveStreamAppSnapshot (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling deleteLiveStreamAppSnapshot" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling deleteLiveStreamAppSnapshot" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling deleteLiveStreamAppSnapshot" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + publishDomain: opts.publishDomain, + appName: opts.appName, + template: opts.template + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 deleteLiveStreamAppSnapshot 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( + '/snapshotApps/{publishDomain}/appNames/{appName}/templates/{template}', + '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.publishDomain - 推流域名 + * @param {string} opts.template - 截图模板 + * @param {string} callback - callback + @return {Object} result + */ + + deleteLiveStreamDomainSnapshot (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling deleteLiveStreamDomainSnapshot" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling deleteLiveStreamDomainSnapshot" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + publishDomain: opts.publishDomain, + template: opts.template + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 deleteLiveStreamDomainSnapshot 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( + '/snapshotDomains/{publishDomain}/templates/{template}', + '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.publishDomain - 推流域名 + * @param {string} callback - callback + @return {Object} result + * @param string publishDomain 推流域名 + * @param string notifyUrl 回调地址 + */ + + describeLiveStreamSnapshotNotifyConfig (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling describeLiveStreamSnapshotNotifyConfig" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + publishDomain: opts.publishDomain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveStreamSnapshotNotifyConfig 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( + '/snapshotNotifys/{publishDomain}:config', + '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.publishDomain - 推流域名 + * @param {string} callback - callback + @return {Object} result + */ + + deleteLiveStreamSnapshotNotifyConfig (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling deleteLiveStreamSnapshotNotifyConfig" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + publishDomain: opts.publishDomain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 deleteLiveStreamSnapshotNotifyConfig 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( + '/snapshotNotifys/{publishDomain}:config', + '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.template - 截图模板 + * @param {string} callback - callback + @return {Object} result + * @param templateBinding bindingList + */ + + describeSnapshotBinding (opts, callback) { + opts = opts || {} + + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling describeSnapshotBinding" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + template: opts.template + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeSnapshotBinding 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( + '/snapshotTemplates/{template}:binding', + '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.publishDomain - 推流域名 + * @param {string} opts.appName - 应用名称 + * @param {string} opts.streamName - 流名称 + * @param {integer} [opts.forbidTime] - 禁流时长,单位:s 0表示永久禁流;大于0为限时禁流,超过时长自动解禁 optional + * @param {string} callback - callback + @return {Object} result + */ + + forbidLiveStream (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling forbidLiveStream" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling forbidLiveStream" + ) + } + if (opts.streamName === undefined || opts.streamName === null) { + throw new Error( + "Missing the required parameter 'opts.streamName' when calling forbidLiveStream" + ) + } + + let postBody = {} + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + postBody['publishDomain'] = opts.publishDomain + } + if (opts.appName !== undefined && opts.appName !== null) { + postBody['appName'] = opts.appName + } + if (opts.streamName !== undefined && opts.streamName !== null) { + postBody['streamName'] = opts.streamName + } + if (opts.forbidTime !== undefined && opts.forbidTime !== null) { + postBody['forbidTime'] = opts.forbidTime + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 forbidLiveStream 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( + '/streams:forbid', + '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) + } + ) + } + + /** + * 恢复直播流推送 + * @param {Object} opts - parameters + * @param {string} opts.publishDomain - 推流域名 + * @param {string} opts.appName - 应用名称 + * @param {string} opts.streamName - 流名称 + * @param {string} callback - callback + @return {Object} result + */ + + resumeLiveStream (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling resumeLiveStream" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling resumeLiveStream" + ) + } + if (opts.streamName === undefined || opts.streamName === null) { + throw new Error( + "Missing the required parameter 'opts.streamName' when calling resumeLiveStream" + ) + } + + let postBody = {} + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + postBody['publishDomain'] = opts.publishDomain + } + if (opts.appName !== undefined && opts.appName !== null) { + postBody['appName'] = opts.appName + } + if (opts.streamName !== undefined && opts.streamName !== null) { + postBody['streamName'] = opts.streamName + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 resumeLiveStream 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( + '/streams:resume', + '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) + } + ) + } + + /** + * 中断直播流推送 +- 中断操作1秒后可以继续推流 + + * @param {Object} opts - parameters + * @param {string} opts.publishDomain - 推流域名 + * @param {string} opts.appName - 应用名称 + * @param {string} opts.streamName - 流名称 + * @param {string} callback - callback + @return {Object} result + */ + + interruptLiveStream (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling interruptLiveStream" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling interruptLiveStream" + ) + } + if (opts.streamName === undefined || opts.streamName === null) { + throw new Error( + "Missing the required parameter 'opts.streamName' when calling interruptLiveStream" + ) + } + + let postBody = {} + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + postBody['publishDomain'] = opts.publishDomain + } + if (opts.appName !== undefined && opts.appName !== null) { + postBody['appName'] = opts.appName + } + if (opts.streamName !== undefined && opts.streamName !== null) { + postBody['streamName'] = opts.streamName + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 interruptLiveStream 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( + '/streams:interrupt', + '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) + } + ) + } + + /** + * 查询直播实时流信息 + + * @param {Object} opts - parameters + * @param {string} opts.publishDomain - 推流域名 + * @param {string} opts.appName - 应用名称 + * @param {string} opts.streamName - 流名称 + * @param {string} callback - callback + @return {Object} result + * @param string publishDomain 推流域名 + * @param string appName 应用名称 + * @param string streamName 流名称 + * @param string status 流状态 + on: 在线流 + off: 非在线流 + + */ + + describeLiveStreamInfo (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling describeLiveStreamInfo" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling describeLiveStreamInfo" + ) + } + if (opts.streamName === undefined || opts.streamName === null) { + throw new Error( + "Missing the required parameter 'opts.streamName' when calling describeLiveStreamInfo" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + publishDomain: opts.publishDomain, + appName: opts.appName, + streamName: opts.streamName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveStreamInfo 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( + '/streams/{publishDomain}/appNames/{appName}/streamNames/{streamName}/streamInfo', + '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.publishDomain - 推流域名 + * @param {string} opts.notifyUrl - 直播流状态回调地址 +- 必须以 http:// 开头 + + * @param {string} callback - callback + @return {Object} result + */ + + setLiveStreamNotifyConfig (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling setLiveStreamNotifyConfig" + ) + } + if (opts.notifyUrl === undefined || opts.notifyUrl === null) { + throw new Error( + "Missing the required parameter 'opts.notifyUrl' when calling setLiveStreamNotifyConfig" + ) + } + + let postBody = {} + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + postBody['publishDomain'] = opts.publishDomain + } + if (opts.notifyUrl !== undefined && opts.notifyUrl !== null) { + postBody['notifyUrl'] = opts.notifyUrl + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 setLiveStreamNotifyConfig 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( + '/streamNotifys', + '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.publishDomain - 推流域名 + * @param {string} callback - callback + @return {Object} result + * @param string publishDomain 推流域名 + * @param string notifyUrl 流状态回调地址 + */ + + describeLiveStreamNotifyConfig (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling describeLiveStreamNotifyConfig" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + publishDomain: opts.publishDomain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveStreamNotifyConfig 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( + '/streamNotifys/{publishDomain}', + '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.publishDomain - 推流域名 + * @param {string} callback - callback + @return {Object} result + */ + + deleteLiveStreamNotifyConfig (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling deleteLiveStreamNotifyConfig" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + publishDomain: opts.publishDomain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 deleteLiveStreamNotifyConfig 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( + '/streamNotifys/{publishDomain}', + '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.publishDomain - 推流域名 + * @param {integer} [opts.pageNum] - 页码 +- 取值范围[1, 100000] + optional + * @param {integer} [opts.pageSize] - 分页大小 +- 取值范围[10, 100] + optional + * @param {string} [opts.appName] - 应用名称 optional + * @param {string} callback - callback + @return {Object} result + * @param integer pageNumber 当前页码 + * @param integer pageSize 每页数量 + * @param integer totalCount 查询总数 + * @param onlineStreamInfo onlineStreamInfos + */ + + describeLiveStreamOnlineList (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling describeLiveStreamOnlineList" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pageNum !== undefined && opts.pageNum !== null) { + queryParams['pageNum'] = opts.pageNum + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.appName !== undefined && opts.appName !== null) { + queryParams['appName'] = opts.appName + } + + let pathParams = { + regionId: 'jdcloud', + publishDomain: opts.publishDomain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveStreamOnlineList 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( + '/streams/{publishDomain}/onlineList', + '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.publishDomain - 推流域名 + * @param {integer} [opts.pageNum] - 页码<br> +- 取值范围[1, 100000] + optional + * @param {integer} [opts.pageSize] - 分页大小<br> +- 取值范围[10, 100] + optional + * @param {string} [opts.appName] - 应用名称 optional + * @param {string} [opts.streamName] - 流名称 optional + * @param {string} opts.startTime - 推流起始时间<br> +- UTC时间 + 格式:yyyy-MM-dd'T'HH:mm:ss'Z' + 示例:2018-10-21T10:00:00Z +- 最大支持最近30天内的流历史查询 + + * @param {string} [opts.endTime] - 推流结束时间<br> +- UTC时间 + 格式:yyyy-MM-dd'T'HH:mm:ss'Z' + 示例:2018-10-21T10:00:00Z +- 最大支持最近30天内的流历史查询 +- 结束时间为空默认为当前时间 + optional + * @param {string} callback - callback + @return {Object} result + * @param integer pageNumber 当前页码 + * @param integer pageSize 每页数量 + * @param integer totalCount 查询总数 + * @param liveStreamPublishInfo liveStreamPublishInfos + */ + + describeLiveStreamPublishList (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling describeLiveStreamPublishList" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeLiveStreamPublishList" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pageNum !== undefined && opts.pageNum !== null) { + queryParams['pageNum'] = opts.pageNum + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.appName !== undefined && opts.appName !== null) { + queryParams['appName'] = opts.appName + } + if (opts.streamName !== undefined && opts.streamName !== null) { + queryParams['streamName'] = opts.streamName + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: 'jdcloud', + publishDomain: opts.publishDomain + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveStreamPublishList 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( + '/streams/{publishDomain}/publishList', + '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) + } + ) + } + + /** + * 开启回看 +1、直播回看文件格式仅支持m3u8。 +2、回看时长用户可以配置,最大支持7天,即用户请求回看内容,最多可以请求最近7天的直播回看内容。 +3、域名格式:http://{restartDomain}/{appName}/{streamName}/index.m3u8?starttime=1527756680&endtime=1527760280 (unix时间戳) +4、starttime-endtime最长可支持24小时,可跨天 + + * @param {Object} opts - parameters + * @param {string} opts.restartDomain - 回看的播放域名 + * @param {string} callback - callback + @return {Object} result + */ + + openLiveRestart (opts, callback) { + opts = opts || {} + + if (opts.restartDomain === undefined || opts.restartDomain === null) { + throw new Error( + "Missing the required parameter 'opts.restartDomain' when calling openLiveRestart" + ) + } + + let postBody = {} + if (opts.restartDomain !== undefined && opts.restartDomain !== null) { + postBody['restartDomain'] = opts.restartDomain + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 openLiveRestart 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( + '/liveRestart:open', + '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) + } + ) + } + + /** + * 关闭回看 + * @param {Object} opts - parameters + * @param {string} opts.restartDomain - 回看的播放域名 + * @param {string} callback - callback + @return {Object} result + */ + + closeLiveRestart (opts, callback) { + opts = opts || {} + + if (opts.restartDomain === undefined || opts.restartDomain === null) { + throw new Error( + "Missing the required parameter 'opts.restartDomain' when calling closeLiveRestart" + ) + } + + let postBody = {} + if (opts.restartDomain !== undefined && opts.restartDomain !== null) { + postBody['restartDomain'] = opts.restartDomain + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 closeLiveRestart 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( + '/liveRestart:close', + '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) + } + ) + } + + /** + * 查询回看配置 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNum] - 页码;默认为1;取值范围[1, 100000] optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[10, 100] optional + * @param {string} opts.restartDomain - 回看的推流域名 + * @param {string} callback - callback + @return {Object} result + * @param integer pageNumber 当前页码 + * @param integer pageSize 每页数量 + * @param integer totalCount 查询总数 + * @param restartConfig restartConfigs + */ + + describeLiveRestartConfigs (opts, callback) { + opts = opts || {} + + if (opts.restartDomain === undefined || opts.restartDomain === null) { + throw new Error( + "Missing the required parameter 'opts.restartDomain' when calling describeLiveRestartConfigs" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pageNum !== undefined && opts.pageNum !== null) { + queryParams['pageNum'] = opts.pageNum + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.restartDomain !== undefined && opts.restartDomain !== null) { + queryParams['restartDomain'] = opts.restartDomain + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveRestartConfigs 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( + '/liveRestart:configs', + '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) + } + ) + } + + /** + * 开启时移 +直播支持最大4小时的HLS时移,使用方式为在播放域名后增加时移参数来实现,参数类型支持指定开始时间和时间偏移量2种方式进行时移。 开启直播时移后,重新推流生效,使用播放域名带相应参数访问即可播放 +- 域名格式: +1、http://{playDomain}/{appName}/{streamName}/index.m3u8?timeshift=400(秒,指从当前时间往前时移的偏移量) +2、http://{playDomain}/{appName}/{streamName}/index.m3u8?starttime=1529223702 (unix时间戳) + + * @param {Object} opts - parameters + * @param {string} opts.playDomain - 直播的播放域名 + * @param {string} callback - callback + @return {Object} result + */ + + openLiveTimeshift (opts, callback) { + opts = opts || {} + + if (opts.playDomain === undefined || opts.playDomain === null) { + throw new Error( + "Missing the required parameter 'opts.playDomain' when calling openLiveTimeshift" + ) + } + + let postBody = {} + if (opts.playDomain !== undefined && opts.playDomain !== null) { + postBody['playDomain'] = opts.playDomain + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 openLiveTimeshift 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( + '/liveTimeshift:open', + '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) + } + ) + } + + /** + * 关闭时移 + * @param {Object} opts - parameters + * @param {string} opts.playDomain - 直播的播放域名 + * @param {string} callback - callback + @return {Object} result + */ + + closeLiveTimeshift (opts, callback) { + opts = opts || {} + + if (opts.playDomain === undefined || opts.playDomain === null) { + throw new Error( + "Missing the required parameter 'opts.playDomain' when calling closeLiveTimeshift" + ) + } + + let postBody = {} + if (opts.playDomain !== undefined && opts.playDomain !== null) { + postBody['playDomain'] = opts.playDomain + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 closeLiveTimeshift 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( + '/liveTimeshift:close', + '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) + } + ) + } + + /** + * 查询时移配置 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码 +- 取值范围[1, 100000] + optional + * @param {integer} [opts.pageSize] - 分页大小 +- 取值范围[10, 100] + optional + * @param {string} opts.playDomain - 直播的播放域名 +- 目前仅支持精确匹配 + + * @param {string} callback - callback + @return {Object} result + * @param integer pageNumber 当前页码 + * @param integer pageSize 每页数量 + * @param integer totalCount 查询总数 + * @param timeshiftConfig timeshiftConfigs + */ + + describeLiveTimeshiftConfigs (opts, callback) { + opts = opts || {} + + if (opts.playDomain === undefined || opts.playDomain === null) { + throw new Error( + "Missing the required parameter 'opts.playDomain' when calling describeLiveTimeshiftConfigs" + ) + } + + 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.playDomain !== undefined && opts.playDomain !== null) { + queryParams['playDomain'] = opts.playDomain + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveTimeshiftConfigs 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( + '/liveTimeshift:configs', + '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.publishDomain - 直播的推流域名 + * @param {string} opts.template - 转码模版 +- 取值范围: 系统标准转码模板, 用户自定义转码模板 +- 系统标准转码模板 + ld (h.264/640*360/15f) + sd (h.264/960*540/25f) + hd (h.264/1280*720/25f) + shd (h.264/1920*1080/30f) + ld-265 (h.265/640*360/15f) + sd-265 (h.265/960*540/25f) + hd-265 (h.265/1280*720/25f) + shd-265 (h.265/1920*1080/30f) + + * @param {string} callback - callback + @return {Object} result + */ + + addLiveStreamDomainTranscode (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling addLiveStreamDomainTranscode" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling addLiveStreamDomainTranscode" + ) + } + + let postBody = {} + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + postBody['publishDomain'] = opts.publishDomain + } + if (opts.template !== undefined && opts.template !== null) { + postBody['template'] = opts.template + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 addLiveStreamDomainTranscode 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( + '/transcodeDomains:config', + '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.publishDomain - 推流域名 + * @param {string} opts.appName - 应用名称 + * @param {string} opts.template - 转码模版 +- 取值范围: 系统标准转码模板, 用户自定义转码模板 +- 系统标准转码模板 + ld (h.264/640*360/15f) + sd (h.264/960*540/25f) + hd (h.264/1280*720/25f) + shd (h.264/1920*1080/30f) + ld-265 (h.265/640*360/15f) + sd-265 (h.265/960*540/25f) + hd-265 (h.265/1280*720/25f) + shd-265 (h.265/1920*1080/30f) + + * @param {string} callback - callback + @return {Object} result + */ + + addLiveStreamAppTranscode (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling addLiveStreamAppTranscode" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling addLiveStreamAppTranscode" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling addLiveStreamAppTranscode" + ) + } + + let postBody = {} + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + postBody['publishDomain'] = opts.publishDomain + } + if (opts.appName !== undefined && opts.appName !== null) { + postBody['appName'] = opts.appName + } + if (opts.template !== undefined && opts.template !== null) { + postBody['template'] = opts.template + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 addLiveStreamAppTranscode 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( + '/transcodeApps:config', + '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) + } + ) + } + + /** + * 添加自定义转码模板 +- 系统为您预设了标准转码模板,如果不能满足您的转码需求,可以通过此接口添加自定义转码模板 +- 系统标准转码模板 + ld (h.264/640*360/15f) + sd (h.264/960*540/25f) + hd (h.264/1280*720/25f) + shd (h.264/1920*1080/30f) + ld-265 (h.265/640*360/15f) + sd-265 (h.265/960*540/25f) + hd-265 (h.265/1280*720/25f) + shd-265 (h.265/1920*1080/30f) + + * @param {Object} opts - parameters + * @param {string} [opts.templateName] - 转码模板名称 +- 长度范围:[1,50] + optional + * @param {string} [opts.videoCodec] - 视频编码格式,取值:h264,h265,默认h264 +- h264时,分辨率小于等于1080p +- h265时,分辨率小于等于4k + optional + * @param {integer} opts.videoCodeRate - 转码输出的码率值 +- 取值范围: [128,15000] +- 单位: kpbs + + * @param {string} opts.videoFrameRate - 转码输出的帧率值 +- 取值:[1,30] + + * @param {integer} [opts.width] - 转码输出视频宽度 +- 取值: [128,4096] +- 如果(width,height)只设置其中之一,则按所设置参数项等比缩放另一项输出转码 +- 如果(width,height)都不设置,则按源流大小输出转码 + optional + * @param {integer} [opts.height] - 转码输出视频高度 +- 取值: [128,4096] +- 如果(width,height)只设置其中之一,则按所设置参数项等比缩放另一项输出转码 +- 如果(width,height)都不设置,则按源流大小输出转码 + optional + * @param {string} opts.template - 转码模板(转码流输出后缀) +- 取值要求:数字、大小写字母或短横线("-"),必须以数字或字母作为开头和结尾,长度不超过50字符 +- <b>注意: 不能与系统的标准的转码模板和当前用户已自定义命名重复</b> +- 系统标准转码模板 + ld (h.264/640*360/15f) + sd (h.264/960*540/25f) + hd (h.264/1280*720/25f) + shd (h.264/1920*1080/30f) + ld-265 (h.265/640*360/15f) + sd-265 (h.265/960*540/25f) + hd-265 (h.265/1280*720/25f) + shd-265 (h.265/1920*1080/30f) + + * @param {string} opts.audioCodec - 转码输出音频编码格式 +- 取值: aac、mp3 +- 不区分大小写 + + * @param {string} [opts.audioFormat] - 转码输出音频格式 +- 取值: aac_lc,aac_low,aac_he,aac_he_v2; 默认:aac_he +- 不区分大小写 + optional + * @param {integer} opts.audioSampleRate - 转码输出音频采样率 +- 取值: [44100,48000] + + * @param {integer} opts.audioChannel - 转码输出音频通道数 + 1: 单声道 + 2: 双声道 + + * @param {integer} opts.audioCodeRate - 转码输出音频码率 +- 取值: [16,128] +- 单位: kbps + + * @param {string} [opts.jdchd] - 京享超清开关 +- 取值: jdchd-1.0,off +- 京享超清暂时只支持h.264 + optional + * @param {string} [opts.audioComfort] - 舒适音频 +- 取值: on,off + optional + * @param {string} callback - callback + @return {Object} result + */ + + addCustomLiveStreamTranscodeTemplate (opts, callback) { + opts = opts || {} + + if (opts.videoCodeRate === undefined || opts.videoCodeRate === null) { + throw new Error( + "Missing the required parameter 'opts.videoCodeRate' when calling addCustomLiveStreamTranscodeTemplate" + ) + } + if (opts.videoFrameRate === undefined || opts.videoFrameRate === null) { + throw new Error( + "Missing the required parameter 'opts.videoFrameRate' when calling addCustomLiveStreamTranscodeTemplate" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling addCustomLiveStreamTranscodeTemplate" + ) + } + if (opts.audioCodec === undefined || opts.audioCodec === null) { + throw new Error( + "Missing the required parameter 'opts.audioCodec' when calling addCustomLiveStreamTranscodeTemplate" + ) + } + if (opts.audioSampleRate === undefined || opts.audioSampleRate === null) { + throw new Error( + "Missing the required parameter 'opts.audioSampleRate' when calling addCustomLiveStreamTranscodeTemplate" + ) + } + if (opts.audioChannel === undefined || opts.audioChannel === null) { + throw new Error( + "Missing the required parameter 'opts.audioChannel' when calling addCustomLiveStreamTranscodeTemplate" + ) + } + if (opts.audioCodeRate === undefined || opts.audioCodeRate === null) { + throw new Error( + "Missing the required parameter 'opts.audioCodeRate' when calling addCustomLiveStreamTranscodeTemplate" + ) + } + + let postBody = {} + if (opts.templateName !== undefined && opts.templateName !== null) { + postBody['templateName'] = opts.templateName + } + if (opts.videoCodec !== undefined && opts.videoCodec !== null) { + postBody['videoCodec'] = opts.videoCodec + } + if (opts.videoCodeRate !== undefined && opts.videoCodeRate !== null) { + postBody['videoCodeRate'] = opts.videoCodeRate + } + if (opts.videoFrameRate !== undefined && opts.videoFrameRate !== null) { + postBody['videoFrameRate'] = opts.videoFrameRate + } + if (opts.width !== undefined && opts.width !== null) { + postBody['width'] = opts.width + } + if (opts.height !== undefined && opts.height !== null) { + postBody['height'] = opts.height + } + if (opts.template !== undefined && opts.template !== null) { + postBody['template'] = opts.template + } + if (opts.audioCodec !== undefined && opts.audioCodec !== null) { + postBody['audioCodec'] = opts.audioCodec + } + if (opts.audioFormat !== undefined && opts.audioFormat !== null) { + postBody['audioFormat'] = opts.audioFormat + } + if (opts.audioSampleRate !== undefined && opts.audioSampleRate !== null) { + postBody['audioSampleRate'] = opts.audioSampleRate + } + if (opts.audioChannel !== undefined && opts.audioChannel !== null) { + postBody['audioChannel'] = opts.audioChannel + } + if (opts.audioCodeRate !== undefined && opts.audioCodeRate !== null) { + postBody['audioCodeRate'] = opts.audioCodeRate + } + if (opts.jdchd !== undefined && opts.jdchd !== null) { + postBody['jdchd'] = opts.jdchd + } + if (opts.audioComfort !== undefined && opts.audioComfort !== null) { + postBody['audioComfort'] = opts.audioComfort + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 addCustomLiveStreamTranscodeTemplate 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( + '/transcodeCustoms:template', + '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.pageNum] - 页码 +- 取值范围 [1, 100000] + optional + * @param {integer} [opts.pageSize] - 分页大小 +- 取值范围 [10, 100] + optional + * @param {filter} [opts.filters] - 转码模板查询过滤条件: + - name: template 转码模板自定义名称 + - value: 如果参数为空,则查询全部 + - 如果为空,则表示查询该用下所有自定义的转码模板 + optional + * @param {string} callback - callback + @return {Object} result + * @param integer pageNumber 当前页码 + * @param integer pageSize 每页数量 + * @param integer totalCount 查询总数 + * @param transcodeInfo transcodeTemplates + */ + + describeCustomLiveStreamTranscodeTemplates (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.pageNum !== undefined && opts.pageNum !== null) { + queryParams['pageNum'] = opts.pageNum + } + 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 live/1.0.22' + } + + 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 describeCustomLiveStreamTranscodeTemplates 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( + '/transcodeCustoms', + '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.pageNum] - 页码 +- 取值范围 [1, 100000] + optional + * @param {integer} [opts.pageSize] - 分页大小 +- 取值范围 [10, 100] + optional + * @param {filter} [opts.filters] - 转码模板查询过滤条件: + - name: template 转码模板自定义名称 + - value: 如果参数为空,则查询全部 + - 如果为空,则表示查询该用下所有自定义的转码模板 + optional + * @param {string} callback - callback + @return {Object} result + * @param integer pageNumber 当前页码 + * @param integer pageSize 每页数量 + * @param integer totalCount 查询总数 + * @param transcodeInfo transcodeTemplates + */ + + describeSystemLiveStreamTranscodeTemplates (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.pageNum !== undefined && opts.pageNum !== null) { + queryParams['pageNum'] = opts.pageNum + } + 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 live/1.0.22' + } + + 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 describeSystemLiveStreamTranscodeTemplates 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( + '/transcodeSystem', + '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) + } + ) + } + + /** + * 查询转码模板配置 +- 转码模板配置按照 域名,应用,流 3级配置添加,以最小的粒度配置生效原则 +- 域名、应用、流 依次粒度递减 即: 域名>应用>流 +- 该查询旨在查询域名、应用、流最终生效的转码模板配置,并非各级的模板绑定情况 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNum] - 页码 +- 取值范围 [1, 100000] + optional + * @param {integer} [opts.pageSize] - 分页大小 +- 取值范围[10, 100] + optional + * @param {filter} [opts.filters] - 模板配置查询过滤条件: + - name: publishDomain 必填(推流域名) + - value: 参数 + - name: appName 必填(应用名称) + - value: 参数 + - name: streamName 非必填(流名称) + - value: 参数 + optional + * @param {string} callback - callback + @return {Object} result + * @param integer pageNumber 当前页码 + * @param integer pageSize 每页数量 + * @param integer totalCount 查询总数 + * @param templateConfig transcodeConfigs + */ + + describeLiveStreamTranscodeConfig (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.pageNum !== undefined && opts.pageNum !== null) { + queryParams['pageNum'] = opts.pageNum + } + 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 live/1.0.22' + } + + 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 describeLiveStreamTranscodeConfig 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( + '/transcodes:config', + '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.publishDomain - 推流域名 + * @param {string} opts.template - 转码模板 + * @param {string} callback - callback + @return {Object} result + */ + + deleteLiveStreamDomainTranscode (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling deleteLiveStreamDomainTranscode" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling deleteLiveStreamDomainTranscode" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + publishDomain: opts.publishDomain, + template: opts.template + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 deleteLiveStreamDomainTranscode 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( + '/transcodeDomains/{publishDomain}/templates/{template}:config', + '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.publishDomain - 推流域名 + * @param {string} opts.appName - 应用名称 + * @param {string} opts.template - 转码模板 + + * @param {string} callback - callback + @return {Object} result + */ + + deleteLiveStreamAppTranscode (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling deleteLiveStreamAppTranscode" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling deleteLiveStreamAppTranscode" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling deleteLiveStreamAppTranscode" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + publishDomain: opts.publishDomain, + appName: opts.appName, + template: opts.template + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 deleteLiveStreamAppTranscode 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( + '/transcodeApps/{publishDomain}/appNames/{appName}/templates/{template}', + '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) + } + ) + } + + /** + * 查询用户自定义转码模板详情 +- 查询用户自定义转码模板详情 +- 系统标准转码模板 + ld (h.264/640*360/15f) + sd (h.264/960*540/24f) + hd (h.264/1280*720/25f) + shd (h.264/1920*1080/30f) + ld-265 (h.265/640*360/15f) + sd-265 (h.265/960*540/24f) + hd-265 (h.265/1280*720/25f) + shd-265 (h.265/1920*1080/30f) + + * @param {Object} opts - parameters + * @param {string} opts.template - 转码模板 + * @param {string} callback - callback + @return {Object} result + * @param string videoCodec 视频编码格式,取值:h264,h265,默认h264 + + * @param integer videoCodeRate 转码输出的码率值 +- 单位: kpbs + + * @param string videoFrameRate 转码输出的帧率值 + + * @param integer width 转码输出视频宽度 + + * @param integer height 转码输出视频高度 + + * @param string template 转码模板 + + * @param string audioCodec 转码输出音频编码格式 + + * @param string audioFormat 转码输出音频格式 + + * @param integer audioSampleRate 转码输出音频采样率 + + * @param integer audioChannel 转码输出音频通道数 + 1: 单声道 + 2: 双声道 + + * @param integer audioCodeRate 转码输出音频码率 +- 单位: kbps + + * @param string jdchd 京享超清 +- 取值: jdchd-1.0,off + + * @param string audioComfort 舒适音频 +- 取值: on,off + + */ + + describeCustomLiveStreamTranscodeTemplate (opts, callback) { + opts = opts || {} + + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling describeCustomLiveStreamTranscodeTemplate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + template: opts.template + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeCustomLiveStreamTranscodeTemplate 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( + '/transcodeCustoms/{template}', + '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.template - 转码模板 + + * @param {string} callback - callback + @return {Object} result + */ + + deleteCustomLiveStreamTranscodeTemplate (opts, callback) { + opts = opts || {} + + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling deleteCustomLiveStreamTranscodeTemplate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + template: opts.template + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 deleteCustomLiveStreamTranscodeTemplate 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( + '/transcodeCustoms/{template}', + '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.template - 转码模板 + * @param {string} callback - callback + @return {Object} result + * @param templateBinding bindingList + */ + + describeTranscodeBinding (opts, callback) { + opts = opts || {} + + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling describeTranscodeBinding" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + template: opts.template + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeTranscodeBinding 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( + '/transcodeTemplates/{template}:binding', + '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.publishDomain - 直播的推流域名 + * @param {string} opts.template - 翻译模版 +- 取值范围: 系统标准翻译模板, 用户自定义翻译模板 +- 系统标准翻译模板 + system-zh-en (中译英) + system-en-zh (英译中) + + * @param {string} callback - callback + @return {Object} result + */ + + addLiveStreamDomainTranslate (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling addLiveStreamDomainTranslate" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling addLiveStreamDomainTranslate" + ) + } + + let postBody = {} + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + postBody['publishDomain'] = opts.publishDomain + } + if (opts.template !== undefined && opts.template !== null) { + postBody['template'] = opts.template + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 addLiveStreamDomainTranslate 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( + '/translateDomains:config', + '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.publishDomain - 推流域名 + * @param {string} opts.appName - 应用名称 + * @param {string} opts.template - 翻译模版 +- 取值范围: 系统标准翻译模板, 用户自定义翻译模板 +- 系统标准翻译模板 + system-zh-en (中译英) + system-en-zh (英译中) + + * @param {string} callback - callback + @return {Object} result + */ + + addLiveStreamAppTranslate (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling addLiveStreamAppTranslate" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling addLiveStreamAppTranslate" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling addLiveStreamAppTranslate" + ) + } + + let postBody = {} + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + postBody['publishDomain'] = opts.publishDomain + } + if (opts.appName !== undefined && opts.appName !== null) { + postBody['appName'] = opts.appName + } + if (opts.template !== undefined && opts.template !== null) { + postBody['template'] = opts.template + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 addLiveStreamAppTranslate 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( + '/translateApps:config', + '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.publishDomain - 推流域名 + * @param {string} opts.appName - 应用名称 + * @param {string} opts.streamName - 流名称 + * @param {string} opts.template - 翻译模版 +- 取值范围: 系统标准翻译模板, 用户自定义翻译模板 +- 系统标准翻译模板 + system-zh-en (中译英) + system-en-zh (英译中) + + * @param {string} callback - callback + @return {Object} result + */ + + addLiveStreamTranslate (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling addLiveStreamTranslate" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling addLiveStreamTranslate" + ) + } + if (opts.streamName === undefined || opts.streamName === null) { + throw new Error( + "Missing the required parameter 'opts.streamName' when calling addLiveStreamTranslate" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling addLiveStreamTranslate" + ) + } + + let postBody = {} + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + postBody['publishDomain'] = opts.publishDomain + } + if (opts.appName !== undefined && opts.appName !== null) { + postBody['appName'] = opts.appName + } + if (opts.streamName !== undefined && opts.streamName !== null) { + postBody['streamName'] = opts.streamName + } + if (opts.template !== undefined && opts.template !== null) { + postBody['template'] = opts.template + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 addLiveStreamTranslate 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( + '/translateStream:config', + '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.pageNum] - 页码 +- 取值范围 [1, 100000] + optional + * @param {integer} [opts.pageSize] - 分页大小 +- 取值范围 [10, 100] + optional + * @param {filter} [opts.filters] - 翻译模板查询过滤条件: + - name: template 翻译模板名称 + - value: 如果参数为空,则查询全部 + optional + * @param {string} callback - callback + @return {Object} result + * @param integer pageNumber 当前页码 + * @param integer pageSize 每页数量 + * @param integer totalCount 查询总数 + * @param translateInfo translateTemplates + */ + + describeSystemLiveStreamTranslateTemplates (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.pageNum !== undefined && opts.pageNum !== null) { + queryParams['pageNum'] = opts.pageNum + } + 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 live/1.0.22' + } + + 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 describeSystemLiveStreamTranslateTemplates 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( + '/translateSystem', + '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) + } + ) + } + + /** + * 查询翻译模板配置 +- 翻译模板配置按照 域名,应用,流 3级配置添加,以最小的粒度配置生效原则 +- 域名、应用、流 依次粒度递减 即: 域名>应用>流 +- 该查询旨在查询域名、应用、流最终生效的翻译模板配置,并非各级的模板绑定情况 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNum] - 页码 +- 取值范围 [1, 100000] + optional + * @param {integer} [opts.pageSize] - 分页大小 +- 取值范围[10, 100] + optional + * @param {filter} [opts.filters] - 模板配置查询过滤条件: + - name: publishDomain 必填(推流域名) + - value: 参数 + - name: appName 必填(应用名称) + - value: 参数 + - name: streamName 非必填(流名称) + - value: 参数 + optional + * @param {string} callback - callback + @return {Object} result + * @param integer pageNumber 当前页码 + * @param integer pageSize 每页数量 + * @param integer totalCount 查询总数 + * @param translateTemplateConfig translateConfigs + */ + + describeLiveStreamTranslateConfig (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.pageNum !== undefined && opts.pageNum !== null) { + queryParams['pageNum'] = opts.pageNum + } + 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 live/1.0.22' + } + + 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 describeLiveStreamTranslateConfig 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( + '/translates:config', + '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 {filter} [opts.filters] - 模板配置查询过滤条件: + - name: publishDomain 必填(推流域名) + - value: 参数 + - name: level 非必填(Level) + - value: 参数,取值:domain,app,stream + optional + * @param {string} callback - callback + @return {Object} result + * @param domainTranslateTemplateConfig templateList + */ + + describeLiveDomainTranslateConfig (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeLiveDomainTranslateConfig 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( + '/translateTemplates:domain', + '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.publishDomain - 推流域名 + * @param {string} opts.template - 翻译模板 + * @param {string} callback - callback + @return {Object} result + */ + + deleteLiveStreamDomainTranslate (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling deleteLiveStreamDomainTranslate" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling deleteLiveStreamDomainTranslate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + publishDomain: opts.publishDomain, + template: opts.template + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 deleteLiveStreamDomainTranslate 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( + '/translateDomains/{publishDomain}/templates/{template}:config', + '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.publishDomain - 推流域名 + * @param {string} opts.appName - 应用名称 + * @param {string} opts.template - 翻译模板 + * @param {string} callback - callback + @return {Object} result + */ + + deleteLiveStreamAppTranslate (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling deleteLiveStreamAppTranslate" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling deleteLiveStreamAppTranslate" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling deleteLiveStreamAppTranslate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + publishDomain: opts.publishDomain, + appName: opts.appName, + template: opts.template + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 deleteLiveStreamAppTranslate 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( + '/translateApps/{publishDomain}/appNames/{appName}/templates/{template}', + '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.publishDomain - 推流域名 + * @param {string} opts.appName - 应用名称 + * @param {string} opts.streamName - 流名称 + * @param {string} opts.template - 翻译模板 + * @param {string} callback - callback + @return {Object} result + */ + + deleteLiveStreamTranslate (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling deleteLiveStreamTranslate" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling deleteLiveStreamTranslate" + ) + } + if (opts.streamName === undefined || opts.streamName === null) { + throw new Error( + "Missing the required parameter 'opts.streamName' when calling deleteLiveStreamTranslate" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling deleteLiveStreamTranslate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + publishDomain: opts.publishDomain, + appName: opts.appName, + streamName: opts.streamName, + template: opts.template + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 deleteLiveStreamTranslate 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( + '/translateStream/{publishDomain}/appNames/{appName}/streams/{streamName}/templates/{template}', + '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.template - 翻译模板 + * @param {string} callback - callback + @return {Object} result + * @param templateBinding bindingList + */ + + describeTranslateBinding (opts, callback) { + opts = opts || {} + + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling describeTranslateBinding" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + template: opts.template + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeTranslateBinding 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( + '/translateTemplates/{template}:binding', + '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 {} opts.publishDomain - 推流域名 + * @param {} opts.appName - APP名 + * @param {} opts.streamName - 流名 + * @param {string} callback - callback + @return {Object} result + */ + + pauseLiveStreamTranslate (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling pauseLiveStreamTranslate" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling pauseLiveStreamTranslate" + ) + } + if (opts.streamName === undefined || opts.streamName === null) { + throw new Error( + "Missing the required parameter 'opts.streamName' when calling pauseLiveStreamTranslate" + ) + } + + let postBody = {} + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + postBody['publishDomain'] = opts.publishDomain + } + if (opts.appName !== undefined && opts.appName !== null) { + postBody['appName'] = opts.appName + } + if (opts.streamName !== undefined && opts.streamName !== null) { + postBody['streamName'] = opts.streamName + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 pauseLiveStreamTranslate 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( + '/translate:pause', + '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 {} opts.publishDomain - 推流域名 + * @param {} opts.appName - APP名 + * @param {} opts.streamName - 流名 + * @param {string} callback - callback + @return {Object} result + */ + + resumeLiveStreamTranslate (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling resumeLiveStreamTranslate" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling resumeLiveStreamTranslate" + ) + } + if (opts.streamName === undefined || opts.streamName === null) { + throw new Error( + "Missing the required parameter 'opts.streamName' when calling resumeLiveStreamTranslate" + ) + } + + let postBody = {} + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + postBody['publishDomain'] = opts.publishDomain + } + if (opts.appName !== undefined && opts.appName !== null) { + postBody['appName'] = opts.appName + } + if (opts.streamName !== undefined && opts.streamName !== null) { + postBody['streamName'] = opts.streamName + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 resumeLiveStreamTranslate 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( + '/translate:resume', + '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.position] - 水印位置 +- 取值范围:左上:1,右上:3, 左下:7,右下:9,默认:1 + optional + * @param {string} [opts.offsetUnit] - 偏移量单位 +- 取值: percent,pixel +- percent:按百分比; pixel:像素 默认:pixel + optional + * @param {integer} opts.offsetX - x轴偏移量 +- 取值范围 + percent: (0,100] + pixel: (0,1920] + + * @param {integer} opts.offsetY - y轴偏移量: +- 取值范围 + percent: (0,100] + pixel: (0,1920] + + * @param {string} [opts.sizeUnit] - 水印大小单位 +- 取值: percent,pixel +- percent:按百分比; pixel:像素 默认:pixel + optional + * @param {integer} opts.width - 水印宽度: +- 取值范围 + percent: (0,100] + pixel: (0,1920] + + * @param {integer} opts.height - 水印高度: +- 取值范围 + percent: (0,100] + pixel: (0,1920] + + * @param {string} opts.template - 自定义水印模板名称 +-&ensp;取值要求: 数字、大小写字母、短横线("-")、下划线("_"), +&ensp;&ensp;首尾不能有特殊字符("-"), +&ensp;&ensp;不超过50字符,utf-8格式 +-&ensp;<b>注意: 不能与已定义命名重复</b> + + * @param {string} [opts.uploadId] - 创建上传任务时返回的uploadId参数,当通过接口上传水印图片时,uploadId必填 + optional + * @param {string} opts.url - 水印地址<br>-&ensp;以&ensp;http:// 开头,可公开访问地址<br> + * @param {string} callback - callback + @return {Object} result + */ + + addCustomLiveStreamWatermarkTemplate (opts, callback) { + opts = opts || {} + + if (opts.offsetX === undefined || opts.offsetX === null) { + throw new Error( + "Missing the required parameter 'opts.offsetX' when calling addCustomLiveStreamWatermarkTemplate" + ) + } + if (opts.offsetY === undefined || opts.offsetY === null) { + throw new Error( + "Missing the required parameter 'opts.offsetY' when calling addCustomLiveStreamWatermarkTemplate" + ) + } + if (opts.width === undefined || opts.width === null) { + throw new Error( + "Missing the required parameter 'opts.width' when calling addCustomLiveStreamWatermarkTemplate" + ) + } + if (opts.height === undefined || opts.height === null) { + throw new Error( + "Missing the required parameter 'opts.height' when calling addCustomLiveStreamWatermarkTemplate" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling addCustomLiveStreamWatermarkTemplate" + ) + } + if (opts.url === undefined || opts.url === null) { + throw new Error( + "Missing the required parameter 'opts.url' when calling addCustomLiveStreamWatermarkTemplate" + ) + } + + let postBody = {} + if (opts.position !== undefined && opts.position !== null) { + postBody['position'] = opts.position + } + if (opts.offsetUnit !== undefined && opts.offsetUnit !== null) { + postBody['offsetUnit'] = opts.offsetUnit + } + if (opts.offsetX !== undefined && opts.offsetX !== null) { + postBody['offsetX'] = opts.offsetX + } + if (opts.offsetY !== undefined && opts.offsetY !== null) { + postBody['offsetY'] = opts.offsetY + } + if (opts.sizeUnit !== undefined && opts.sizeUnit !== null) { + postBody['sizeUnit'] = opts.sizeUnit + } + if (opts.width !== undefined && opts.width !== null) { + postBody['width'] = opts.width + } + if (opts.height !== undefined && opts.height !== null) { + postBody['height'] = opts.height + } + if (opts.template !== undefined && opts.template !== null) { + postBody['template'] = opts.template + } + if (opts.uploadId !== undefined && opts.uploadId !== null) { + postBody['uploadId'] = opts.uploadId + } + if (opts.url !== undefined && opts.url !== null) { + postBody['url'] = opts.url + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 addCustomLiveStreamWatermarkTemplate 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( + '/watermarkCustoms:template', + '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.pageNum] - 页码 +- 取值范围 [1, 100000] + optional + * @param {integer} [opts.pageSize] - 分页大小 +- 取值范围 [10, 100] + optional + * @param {filter} [opts.filters] - 水印模板列表查询过滤条件: + - name: template 录制模板自定义名称 + - value: 如果参数为空,则查询全部 + optional + * @param {string} callback - callback + @return {Object} result + * @param integer pageNumber 当前页码 + * @param integer pageSize 每页数量 + * @param integer totalCount 查询总数 + * @param watermarkTemplate watermarkTemplates + */ + + describeCustomLiveStreamWatermarkTemplates (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.pageNum !== undefined && opts.pageNum !== null) { + queryParams['pageNum'] = opts.pageNum + } + 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 live/1.0.22' + } + + 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 describeCustomLiveStreamWatermarkTemplates 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( + '/watermarkCustoms', + '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.publishDomain - 推流域名 + * @param {string} opts.appName - 应用名称 + * @param {string} opts.template - 水印模板名称 + + * @param {string} callback - callback + @return {Object} result + */ + + addLiveStreamAppWatermark (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling addLiveStreamAppWatermark" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling addLiveStreamAppWatermark" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling addLiveStreamAppWatermark" + ) + } + + let postBody = {} + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + postBody['publishDomain'] = opts.publishDomain + } + if (opts.appName !== undefined && opts.appName !== null) { + postBody['appName'] = opts.appName + } + if (opts.template !== undefined && opts.template !== null) { + postBody['template'] = opts.template + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 addLiveStreamAppWatermark 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( + '/watermarkApps:config', + '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.publishDomain - 推流域名 + * @param {string} opts.template - 水印模板 + + * @param {string} callback - callback + @return {Object} result + */ + + addLiveStreamDomainWatermark (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling addLiveStreamDomainWatermark" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling addLiveStreamDomainWatermark" + ) + } + + let postBody = {} + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + postBody['publishDomain'] = opts.publishDomain + } + if (opts.template !== undefined && opts.template !== null) { + postBody['template'] = opts.template + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 addLiveStreamDomainWatermark 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( + '/watermarkDomains:config', + '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) + } + ) + } + + /** + * 查询直播水印配置 +- 水印模板配置按照 域名,应用,流 3级配置添加,以最小的粒度配置生效 +- 域名、应用、流 依次粒度递减 即: 域名>应用>流 +- 该查询旨在查询域名、应用、流最终生效的水印模板配置,并非各级的模板绑定情况 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNum] - 页码 +- 取值范围 [1, 100000] + optional + * @param {integer} [opts.pageSize] - 分页大小 +- 取值范围 [10, 100] + optional + * @param {filter} [opts.filters] - 水印配置查询过滤条件: + - name: publishDomain,必填(推流域名) + - value: 参数 + - name: appName,必填(应用名称) + - value: 参数 + - name: streamName,非必填(流名称) + - value: 参数 + optional + * @param {string} callback - callback + @return {Object} result + * @param integer pageNumber 当前页码 + * @param integer pageSize 每页数量 + * @param integer totalCount 查询总数 + * @param liveStreamRecordConfig watermarkConfigs + */ + + describeCustomLiveStreamWatermarkConfig (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.pageNum !== undefined && opts.pageNum !== null) { + queryParams['pageNum'] = opts.pageNum + } + 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 live/1.0.22' + } + + 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 describeCustomLiveStreamWatermarkConfig 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( + '/watermarks:config', + '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.template - 水印模板 + + * @param {string} callback - callback + @return {Object} result + */ + + deleteCustomLiveStreamWatermarkTemplate (opts, callback) { + opts = opts || {} + + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling deleteCustomLiveStreamWatermarkTemplate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + template: opts.template + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 deleteCustomLiveStreamWatermarkTemplate 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( + '/watermarkCustoms/{template}', + '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.publishDomain - 推流域名 + * @param {string} opts.appName - 应用名称 + * @param {string} opts.template - 水印模板 + + * @param {string} callback - callback + @return {Object} result + */ + + deleteLiveStreamAppWatermark (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling deleteLiveStreamAppWatermark" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling deleteLiveStreamAppWatermark" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling deleteLiveStreamAppWatermark" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + publishDomain: opts.publishDomain, + appName: opts.appName, + template: opts.template + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 deleteLiveStreamAppWatermark 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( + '/watermarkApps/{publishDomain}/appNames/{appName}/templates/{template}', + '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.publishDomain - 推流域名 + * @param {string} opts.template - 水印模板 + + * @param {string} callback - callback + @return {Object} result + */ + + deleteLiveStreamDomainWatermark (opts, callback) { + opts = opts || {} + + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling deleteLiveStreamDomainWatermark" + ) + } + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling deleteLiveStreamDomainWatermark" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + publishDomain: opts.publishDomain, + template: opts.template + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 deleteLiveStreamDomainWatermark 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( + '/watermarkDomains/{publishDomain}/templates/{template}', + '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.template - 水印模板 + * @param {string} callback - callback + @return {Object} result + * @param templateBinding bindingList + */ + + describeWatermarkBinding (opts, callback) { + opts = opts || {} + + if (opts.template === undefined || opts.template === null) { + throw new Error( + "Missing the required parameter 'opts.template' when calling describeWatermarkBinding" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + template: opts.template + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 live/1.0.22' + } + + 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 describeWatermarkBinding 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( + '/watermarkTemplates/{template}:binding', + '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 = LIVE diff --git a/packages/libs/lib-jdcloud/src/repo/logs/v1/logs.js b/packages/libs/lib-jdcloud/src/repo/logs/v1/logs.js new file mode 100644 index 000000000..8fea7f2d2 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/logs/v1/logs.js @@ -0,0 +1,8150 @@ +/* + * 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. + * + * WebConf APIs + * 日志服务webconf相关的管理控制接口 + * + * 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 = 'logs' +Service._services[serviceId] = true + +/** + * logs service. + * @version 2.0.1 + */ + +class LOGS extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'logs.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * k8s agent heartbeat + * @param {Object} opts - parameters + * @param {string} callback - callback + @return {Object} result + */ + + k8sAgentHeartbeat (opts, callback) { + opts = opts || {} + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 k8sAgentHeartbeat 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( + '/heartbeat', + '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.collectInfoUID - 采集配置 UID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string uID UID + * @param agResourceEnd agResource + * @param string appCode 日志来源 + * @param object binlogSpec binlog规格 + * @param collectTempalteEnd detail + * @param integer enabled + * @param boolean hasResource 是否存在资源 + * @param object k8sSpec k8s规格 + * @param string logsetUID 日志集 UID + * @param string logtopicUID 日志主题 UID + * @param string name 采集配置名称 + * @param integer resourceMode 采集资源时选择的模式,1.正常的选择实例模式(默认模式);2.选择标签tag模式 3.选择高可用组ag模式 + * @param string resourceType 采集实例类型, 只能是 all/part + * @param string serviceCode 产品线 + * @param tagResourceEnd tagResource + * @param string templateName 日志类型名称 + * @param string templateUID 日志类型 + */ + + describeCollectInfo (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 describeCollectInfo" + ) + } + + opts = opts || {} + + if (opts.collectInfoUID === undefined || opts.collectInfoUID === null) { + throw new Error( + "Missing the required parameter 'opts.collectInfoUID' when calling describeCollectInfo" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + collectInfoUID: opts.collectInfoUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 describeCollectInfo 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}/collectinfos/{collectInfoUID}', + '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.collectInfoUID - 采集配置 UID + * @param {array} [opts.agResource] - 高可用组资源 optional + * @param {binlogSpec} [opts.binlogSpec] optional + * @param {boolean} opts.enabled - 采集状态,0-禁用,1-启用 + * @param {boolean} [opts.filterEnabled] - 过滤器是否启用。当appcode为custom时必填 optional + * @param {k8sSpec} [opts.k8sSpec] optional + * @param {string} [opts.logFile] - 日志文件名。当appcode为custom时为必填。日志文件名支持正则表达式。 optional + * @param {array} [opts.logFilters] - 过滤器。设置过滤器后可根据用户设定的关键词采集部分日志,如仅采集 Error 的日志。目前最大允许5个。 optional + * @param {string} [opts.logPath] - 日志路径。当appcode为custom时为必填。目前仅支持对 Linux 云主机上的日志进行采集,路径支持通配符“*”和“?”,文件路径应符合 Linux 的文件路径规则 optional + * @param {boolean} [opts.logtopicEnabled] - 目的地是否是日志服务logtopic,只支持业务应用日志 optional + * @param {string} [opts.name] - 采集配置名称 optional + * @param {string} [opts.regexpStr] - 首行正则 optional + * @param {integer} [opts.resourceMode] - 采集资源时选择的模式,1.正常的选择实例模式(默认模式);2.选择标签tag模式 3.选择高可用组ag模式 optional + * @param {string} opts.resourceType - 采集实例类型, 只能是 all/part 当选择all时,传入的实例列表无效;custom类型的采集配置目前仅支持part方式,即用户指定实例列表; + * @param {array} [opts.resources] - 采集实例列表:jdcloud类型最多添加20个资源;custom类型支持的资源数量不限; optional + * @param {tagResource} [opts.tagResource] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateCollectInfo (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 updateCollectInfo" + ) + } + + opts = opts || {} + + if (opts.collectInfoUID === undefined || opts.collectInfoUID === null) { + throw new Error( + "Missing the required parameter 'opts.collectInfoUID' when calling updateCollectInfo" + ) + } + if (opts.enabled === undefined || opts.enabled === null) { + throw new Error( + "Missing the required parameter 'opts.enabled' when calling updateCollectInfo" + ) + } + if (opts.resourceType === undefined || opts.resourceType === null) { + throw new Error( + "Missing the required parameter 'opts.resourceType' when calling updateCollectInfo" + ) + } + + let postBody = {} + if (opts.agResource !== undefined && opts.agResource !== null) { + postBody['agResource'] = opts.agResource + } + if (opts.binlogSpec !== undefined && opts.binlogSpec !== null) { + postBody['binlogSpec'] = opts.binlogSpec + } + if (opts.enabled !== undefined && opts.enabled !== null) { + postBody['enabled'] = opts.enabled + } + if (opts.filterEnabled !== undefined && opts.filterEnabled !== null) { + postBody['filterEnabled'] = opts.filterEnabled + } + if (opts.k8sSpec !== undefined && opts.k8sSpec !== null) { + postBody['k8sSpec'] = opts.k8sSpec + } + if (opts.logFile !== undefined && opts.logFile !== null) { + postBody['logFile'] = opts.logFile + } + if (opts.logFilters !== undefined && opts.logFilters !== null) { + postBody['logFilters'] = opts.logFilters + } + if (opts.logPath !== undefined && opts.logPath !== null) { + postBody['logPath'] = opts.logPath + } + if (opts.logtopicEnabled !== undefined && opts.logtopicEnabled !== null) { + postBody['logtopicEnabled'] = opts.logtopicEnabled + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.regexpStr !== undefined && opts.regexpStr !== null) { + postBody['regexpStr'] = opts.regexpStr + } + if (opts.resourceMode !== undefined && opts.resourceMode !== null) { + postBody['resourceMode'] = opts.resourceMode + } + if (opts.resourceType !== undefined && opts.resourceType !== null) { + postBody['resourceType'] = opts.resourceType + } + if (opts.resources !== undefined && opts.resources !== null) { + postBody['resources'] = opts.resources + } + if (opts.tagResource !== undefined && opts.tagResource !== null) { + postBody['tagResource'] = opts.tagResource + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + collectInfoUID: opts.collectInfoUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 updateCollectInfo 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}/collectinfos/{collectInfoUID}', + '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) + } + ) + } + + /** + * 删除采集配置 + * @param {Object} opts - parameters + * @param {string} opts.collectInfoUID - 采集配置 UID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteCollectInfo (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 deleteCollectInfo" + ) + } + + opts = opts || {} + + if (opts.collectInfoUID === undefined || opts.collectInfoUID === null) { + throw new Error( + "Missing the required parameter 'opts.collectInfoUID' when calling deleteCollectInfo" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + collectInfoUID: opts.collectInfoUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 deleteCollectInfo 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}/collectinfos/{collectInfoUID}', + '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.collectInfoUID - 采集配置 UID + * @param {integer} [opts.pageNumber] - 当前所在页,默认为1 optional + * @param {integer} [opts.pageSize] - 页面大小,默认为20;取值范围[1, 100] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param resourceEnd data + * @param integer numberPages 总页数 + * @param integer numberRecords 总记录数 + * @param integer pageNumber 当前页码 + * @param integer pageSize 分页大小 + */ + + describeCollectResources (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 describeCollectResources" + ) + } + + opts = opts || {} + + if (opts.collectInfoUID === undefined || opts.collectInfoUID === null) { + throw new Error( + "Missing the required parameter 'opts.collectInfoUID' when calling describeCollectResources" + ) + } + + 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, + collectInfoUID: opts.collectInfoUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 describeCollectResources 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}/collectinfos/{collectInfoUID}/resources', + '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.collectInfoUID - 采集配置 UID + * @param {boolean} opts.enabled - 采集状态,0-禁用,1-启用 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateCollectInfoStatus (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 updateCollectInfoStatus" + ) + } + + opts = opts || {} + + if (opts.collectInfoUID === undefined || opts.collectInfoUID === null) { + throw new Error( + "Missing the required parameter 'opts.collectInfoUID' when calling updateCollectInfoStatus" + ) + } + if (opts.enabled === undefined || opts.enabled === null) { + throw new Error( + "Missing the required parameter 'opts.enabled' when calling updateCollectInfoStatus" + ) + } + + let postBody = {} + if (opts.enabled !== undefined && opts.enabled !== null) { + postBody['enabled'] = opts.enabled + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + collectInfoUID: opts.collectInfoUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 updateCollectInfoStatus 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}/collectinfos/{collectInfoUID}:switch', + '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) + } + ) + } + + /** + * 增量更新采集实例列表。更新的动作支持 add 、 remove + * @param {Object} opts - parameters + * @param {string} opts.collectInfoUID - 采集配置 UID + * @param {string} opts.action - action + * @param {array} [opts.resources] - 采集实例列表(系统日志存在上限限制) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateCollectResources (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 updateCollectResources" + ) + } + + opts = opts || {} + + if (opts.collectInfoUID === undefined || opts.collectInfoUID === null) { + throw new Error( + "Missing the required parameter 'opts.collectInfoUID' when calling updateCollectResources" + ) + } + if (opts.action === undefined || opts.action === null) { + throw new Error( + "Missing the required parameter 'opts.action' when calling updateCollectResources" + ) + } + + let postBody = {} + if (opts.action !== undefined && opts.action !== null) { + postBody['action'] = opts.action + } + if (opts.resources !== undefined && opts.resources !== null) { + postBody['resources'] = opts.resources + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + collectInfoUID: opts.collectInfoUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 updateCollectResources 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}/collectinfos/{collectInfoUID}:updateResources', + '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.collectInfoUIDs - 采集配置 UID 列表,以逗号分隔 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param collectInfoBasicEnd data + * @param integer numberPages 总页数 + * @param integer numberRecords 总记录数 + * @param integer pageNumber 当前页码 + * @param integer pageSize 分页大小 + */ + + describeCollectInfoBatch (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 describeCollectInfoBatch" + ) + } + + opts = opts || {} + + if (opts.collectInfoUIDs === undefined || opts.collectInfoUIDs === null) { + throw new Error( + "Missing the required parameter 'opts.collectInfoUIDs' when calling describeCollectInfoBatch" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + collectInfoUIDs: opts.collectInfoUIDs + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 describeCollectInfoBatch 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}/collectinfos/{collectInfoUIDs}:batch', + '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.logtopicUID - 日志主题 UID + * @param {integer} [opts.pageNumber] - 当前所在页,默认为1 optional + * @param {integer} [opts.pageSize] - 页面大小,默认为20;取值范围[1, 200] optional + * @param {string} [opts.name] - 采集配置名称 optional + * @param {string} [opts.collectInfoUID] - 采集配置UID optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param collectInfoBasicEnd data + * @param integer numberPages 总页数 + * @param integer numberRecords 总记录数 + * @param integer pageNumber 当前页码 + * @param integer pageSize 分页大小 + */ + + describeCollectInfos (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 describeCollectInfos" + ) + } + + opts = opts || {} + + if (opts.logtopicUID === undefined || opts.logtopicUID === null) { + throw new Error( + "Missing the required parameter 'opts.logtopicUID' when calling describeCollectInfos" + ) + } + + 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.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + if (opts.collectInfoUID !== undefined && opts.collectInfoUID !== null) { + queryParams['collectInfoUID'] = opts.collectInfoUID + } + + let pathParams = { + regionId: regionId, + logtopicUID: opts.logtopicUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 describeCollectInfos 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}/logtopics/{logtopicUID}/collectinfos', + '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.logtopicUID - 日志主题 UID + * @param {array} [opts.agResource] - 高可用组资源 optional + * @param {string} opts.appCode - 日志来源,只能是 custom/jdcloud + * @param {binlogSpec} [opts.binlogSpec] optional + * @param {boolean} opts.enabled - 采集状态,0-禁用,1-启用 + * @param {boolean} [opts.filterEnabled] - 过滤器是否启用。当appcode为custom时必填 optional + * @param {k8sSpec} [opts.k8sSpec] optional + * @param {string} [opts.logFile] - 日志文件名。当appcode为custom时为必填。日志文件名支持正则表达式。 optional + * @param {array} [opts.logFilters] - 过滤器。设置过滤器后可根据用户设定的关键词采集部分日志,如仅采集 Error 的日志。目前最大允许5个。 optional + * @param {string} [opts.logPath] - 日志路径。当appcode为custom时为必填。目前仅支持对 Linux 云主机上的日志进行采集,路径支持通配符“*”和“?”,文件路径应符合 Linux 的文件路径规则 optional + * @param {boolean} [opts.logtopicEnabled] - 目的地是否是日志服务logtopic,只支持业务应用日志 optional + * @param {string} [opts.name] - 采集配置名称 optional + * @param {string} [opts.regexpStr] - 首行正则 optional + * @param {integer} [opts.resourceMode] - 采集资源时选择的模式,1.正常的选择实例模式(默认模式);2.选择标签tag模式 3.选择高可用组ag模式 optional + * @param {string} opts.resourceType - 采集实例类型, 只能是 all/part 当选择all时,传入的实例列表无效;custom类型的采集配置目前仅支持part方式,即用户指定实例列表; + * @param {array} [opts.resources] - 采集实例列表:jdcloud类型最多添加20个资源;custom类型支持的资源数量不限; optional + * @param {string} opts.serviceCode - 产品线,当日志来源为jdcloud时,填写云产品serviceCode。否则填写自定义日志类型:vm,k8s,binlog,etc + * @param {tagResource} [opts.tagResource] optional + * @param {string} [opts.templateUID] - 日志类型。当appcode为jdcloud时为必填 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string uID UID + */ + + createCollectInfo (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 createCollectInfo" + ) + } + + opts = opts || {} + + if (opts.logtopicUID === undefined || opts.logtopicUID === null) { + throw new Error( + "Missing the required parameter 'opts.logtopicUID' when calling createCollectInfo" + ) + } + if (opts.appCode === undefined || opts.appCode === null) { + throw new Error( + "Missing the required parameter 'opts.appCode' when calling createCollectInfo" + ) + } + if (opts.enabled === undefined || opts.enabled === null) { + throw new Error( + "Missing the required parameter 'opts.enabled' when calling createCollectInfo" + ) + } + if (opts.resourceType === undefined || opts.resourceType === null) { + throw new Error( + "Missing the required parameter 'opts.resourceType' when calling createCollectInfo" + ) + } + if (opts.serviceCode === undefined || opts.serviceCode === null) { + throw new Error( + "Missing the required parameter 'opts.serviceCode' when calling createCollectInfo" + ) + } + + let postBody = {} + if (opts.agResource !== undefined && opts.agResource !== null) { + postBody['agResource'] = opts.agResource + } + if (opts.appCode !== undefined && opts.appCode !== null) { + postBody['appCode'] = opts.appCode + } + if (opts.binlogSpec !== undefined && opts.binlogSpec !== null) { + postBody['binlogSpec'] = opts.binlogSpec + } + if (opts.enabled !== undefined && opts.enabled !== null) { + postBody['enabled'] = opts.enabled + } + if (opts.filterEnabled !== undefined && opts.filterEnabled !== null) { + postBody['filterEnabled'] = opts.filterEnabled + } + if (opts.k8sSpec !== undefined && opts.k8sSpec !== null) { + postBody['k8sSpec'] = opts.k8sSpec + } + if (opts.logFile !== undefined && opts.logFile !== null) { + postBody['logFile'] = opts.logFile + } + if (opts.logFilters !== undefined && opts.logFilters !== null) { + postBody['logFilters'] = opts.logFilters + } + if (opts.logPath !== undefined && opts.logPath !== null) { + postBody['logPath'] = opts.logPath + } + if (opts.logtopicEnabled !== undefined && opts.logtopicEnabled !== null) { + postBody['logtopicEnabled'] = opts.logtopicEnabled + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.regexpStr !== undefined && opts.regexpStr !== null) { + postBody['regexpStr'] = opts.regexpStr + } + if (opts.resourceMode !== undefined && opts.resourceMode !== null) { + postBody['resourceMode'] = opts.resourceMode + } + if (opts.resourceType !== undefined && opts.resourceType !== null) { + postBody['resourceType'] = opts.resourceType + } + if (opts.resources !== undefined && opts.resources !== null) { + postBody['resources'] = opts.resources + } + if (opts.serviceCode !== undefined && opts.serviceCode !== null) { + postBody['serviceCode'] = opts.serviceCode + } + if (opts.tagResource !== undefined && opts.tagResource !== null) { + postBody['tagResource'] = opts.tagResource + } + if (opts.templateUID !== undefined && opts.templateUID !== null) { + postBody['templateUID'] = opts.templateUID + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + logtopicUID: opts.logtopicUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 createCollectInfo 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}/logtopics/{logtopicUID}/collectinfos', + '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.logtopicUID - 日志主题 UID + * @param {array} [opts.indexToken] - 行级索引分词符。 Rune 数组 optional + * @param {array} [opts.parserFields] optional + * @param {string} opts.parserMode - 解析类型。oneline - 单行,split - 分割, json - json, regexp - regexp + * @param {string} [opts.parserPattern] - 解析语法 optional + * @param {string} [opts.parserSample] - 日志样例 optional + * @param {array} [opts.pipelines] - 预处理任务列表。按照数组的顺序执行。 optional + * @param {boolean} [opts.reserveOriginContent] - 是否保留原始内容字段 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + createParser (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 createParser" + ) + } + + opts = opts || {} + + if (opts.logtopicUID === undefined || opts.logtopicUID === null) { + throw new Error( + "Missing the required parameter 'opts.logtopicUID' when calling createParser" + ) + } + if (opts.parserMode === undefined || opts.parserMode === null) { + throw new Error( + "Missing the required parameter 'opts.parserMode' when calling createParser" + ) + } + + let postBody = {} + if (opts.indexToken !== undefined && opts.indexToken !== null) { + postBody['indexToken'] = opts.indexToken + } + if (opts.parserFields !== undefined && opts.parserFields !== null) { + postBody['parserFields'] = opts.parserFields + } + if (opts.parserMode !== undefined && opts.parserMode !== null) { + postBody['parserMode'] = opts.parserMode + } + if (opts.parserPattern !== undefined && opts.parserPattern !== null) { + postBody['parserPattern'] = opts.parserPattern + } + if (opts.parserSample !== undefined && opts.parserSample !== null) { + postBody['parserSample'] = opts.parserSample + } + if (opts.pipelines !== undefined && opts.pipelines !== null) { + postBody['pipelines'] = opts.pipelines + } + if ( + opts.reserveOriginContent !== undefined && + opts.reserveOriginContent !== null + ) { + postBody['reserveOriginContent'] = opts.reserveOriginContent + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + logtopicUID: opts.logtopicUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 createParser 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}/logtopics/{logtopicUID}/createParser', + '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.logtopicUID - 日志主题 UID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + describeParser (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 describeParser" + ) + } + + opts = opts || {} + + if (opts.logtopicUID === undefined || opts.logtopicUID === null) { + throw new Error( + "Missing the required parameter 'opts.logtopicUID' when calling describeParser" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + logtopicUID: opts.logtopicUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 describeParser 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}/logtopics/{logtopicUID}/describeParser', + '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.logtopicUID - 日志主题 UID + * @param {array} [opts.indexToken] - 行级索引分词符。 Rune 数组 optional + * @param {array} [opts.parserFields] optional + * @param {string} opts.parserMode - 解析类型。oneline - 单行,split - 分割, json - json, regexp - regexp + * @param {string} [opts.parserPattern] - 解析语法 optional + * @param {string} [opts.parserSample] - 日志样例 optional + * @param {array} [opts.pipelines] - 预处理任务列表。按照数组的顺序执行。 optional + * @param {boolean} [opts.reserveOriginContent] - 是否保留原始内容字段 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateParser (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 updateParser" + ) + } + + opts = opts || {} + + if (opts.logtopicUID === undefined || opts.logtopicUID === null) { + throw new Error( + "Missing the required parameter 'opts.logtopicUID' when calling updateParser" + ) + } + if (opts.parserMode === undefined || opts.parserMode === null) { + throw new Error( + "Missing the required parameter 'opts.parserMode' when calling updateParser" + ) + } + + let postBody = {} + if (opts.indexToken !== undefined && opts.indexToken !== null) { + postBody['indexToken'] = opts.indexToken + } + if (opts.parserFields !== undefined && opts.parserFields !== null) { + postBody['parserFields'] = opts.parserFields + } + if (opts.parserMode !== undefined && opts.parserMode !== null) { + postBody['parserMode'] = opts.parserMode + } + if (opts.parserPattern !== undefined && opts.parserPattern !== null) { + postBody['parserPattern'] = opts.parserPattern + } + if (opts.parserSample !== undefined && opts.parserSample !== null) { + postBody['parserSample'] = opts.parserSample + } + if (opts.pipelines !== undefined && opts.pipelines !== null) { + postBody['pipelines'] = opts.pipelines + } + if ( + opts.reserveOriginContent !== undefined && + opts.reserveOriginContent !== null + ) { + postBody['reserveOriginContent'] = opts.reserveOriginContent + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + logtopicUID: opts.logtopicUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 updateParser 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}/logtopics/{logtopicUID}/updateParser', + '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.parserMode - 解析类型。oneline - 单行,split - 分割, json - json, regexp - regexp + * @param {string} [opts.parserPattern] - 解析语法 optional + * @param {string} [opts.parserSample] - 日志样例 optional + * @param {array} [opts.pipelines] - 预处理任务列表。按照数组的顺序执行。 optional + * @param {boolean} [opts.reserveOriginContent] - 是否保留原始内容字段 optional + * @param {string} callback - callback + @return {Object} result + */ + + validateParser (opts, callback) { + opts = opts || {} + + if (opts.parserMode === undefined || opts.parserMode === null) { + throw new Error( + "Missing the required parameter 'opts.parserMode' when calling validateParser" + ) + } + + let postBody = {} + if (opts.parserMode !== undefined && opts.parserMode !== null) { + postBody['parserMode'] = opts.parserMode + } + if (opts.parserPattern !== undefined && opts.parserPattern !== null) { + postBody['parserPattern'] = opts.parserPattern + } + if (opts.parserSample !== undefined && opts.parserSample !== null) { + postBody['parserSample'] = opts.parserSample + } + if (opts.pipelines !== undefined && opts.pipelines !== null) { + postBody['pipelines'] = opts.pipelines + } + if ( + opts.reserveOriginContent !== undefined && + opts.reserveOriginContent !== null + ) { + postBody['reserveOriginContent'] = opts.reserveOriginContent + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 validateParser 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( + '/validateParser', + '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) + } + ) + } + + /** + * search + * @param {Object} opts - parameters + * @param {string} opts.logsetUID - 日志集ID + * @param {string} opts.logtopicUID - 日志主题ID + * @param {string} opts.action - "preview"表示预览, "fulltext"表示全文检索, "advance"表示按照搜索语句检索 + * @param {string} [opts.expr] - Base64编码的搜索表达式, optional + * @param {boolean} [opts.caseSensitive] - 搜索关键字大小写敏感, 默认false optional + * @param {string} [opts.startTime] - 开始时间。格式 “YYYY-MM-DDThh:mm:ssTZD”, 比如 “2018-11-09T15:34:46+0800”.当action != preview时,必填 optional + * @param {string} [opts.endTime] - 结束时间。格式 “YYYY-MM-DDThh:mm:ssTZD”, 比如 “2018-11-09T15:34:46+0800”.当action != preview时,必填 optional + * @param {integer} [opts.pageNumber] - 页数。 最小为1,最大为99 optional + * @param {integer} [opts.pageSize] - 每页个数。默认为10,最大100 optional + * @param {string} [opts.sort] - 返回排序,不填或者为空,默认为desc,"asc":按照时间正序返回结果,"desc":按照时间倒序返回结果 optional + * @param {filter} [opts.filters] - 指定返回字段,只对系统日志生效,不填默认按照产品线配置返回字段,Name支持:key,Values填入返回字段 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param object data + * @param searchFields searchFields + * @param integer total 总数 + */ + + search (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 search" + ) + } + + opts = opts || {} + + if (opts.logsetUID === undefined || opts.logsetUID === null) { + throw new Error( + "Missing the required parameter 'opts.logsetUID' when calling search" + ) + } + if (opts.logtopicUID === undefined || opts.logtopicUID === null) { + throw new Error( + "Missing the required parameter 'opts.logtopicUID' when calling search" + ) + } + if (opts.action === undefined || opts.action === null) { + throw new Error( + "Missing the required parameter 'opts.action' when calling search" + ) + } + + let postBody = null + let queryParams = {} + if (opts.action !== undefined && opts.action !== null) { + queryParams['action'] = opts.action + } + if (opts.expr !== undefined && opts.expr !== null) { + queryParams['expr'] = opts.expr + } + if (opts.caseSensitive !== undefined && opts.caseSensitive !== null) { + queryParams['caseSensitive'] = opts.caseSensitive + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + queryParams['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.sort !== undefined && opts.sort !== null) { + queryParams['sort'] = opts.sort + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId, + logsetUID: opts.logsetUID, + logtopicUID: opts.logtopicUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 search 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}/logsets/{logsetUID}/logtopics/{logtopicUID}/search', + '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.logtopicUID - 日志主题 UID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean caseSensitive 是否大小写敏感 + * @param boolean chn 是否开启中文分词 + * @param fieldIndexOption fieldIndexOptions + * @param boolean fulltextIndex 是否开启全文检索,0-禁用,1-启用 + * @param boolean logReduce 是否开启日志聚类,0-禁用,1-启用 + * @param integer maxTextLen 统计分析字段最大长度 + * @param string token + * @param string uid + */ + + describeIndexOption (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 describeIndexOption" + ) + } + + opts = opts || {} + + if (opts.logtopicUID === undefined || opts.logtopicUID === null) { + throw new Error( + "Missing the required parameter 'opts.logtopicUID' when calling describeIndexOption" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + logtopicUID: opts.logtopicUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 describeIndexOption 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}/logtopics/{logtopicUID}/indexoptions', + '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.logtopicUID - 日志主题 UID + * @param {boolean} opts.logReduce - 是否开启日志聚类,0-禁用,1-启用 + * @param {boolean} opts.fulltextIndex - 是否开启全文检索,0-禁用,1-启用 + * @param {boolean} opts.caseSensitive - 是否大小写敏感 + * @param {boolean} opts.chn - 是否开启中文分词 + * @param {array} [opts.token] - 分词符 optional + * @param {array} [opts.fieldIndexOptions] - 字段索引配置 optional + * @param {integer} opts.maxTextLen - 统计分析字段最大长度 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string uID UID + */ + + createIndexOption (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 createIndexOption" + ) + } + + opts = opts || {} + + if (opts.logtopicUID === undefined || opts.logtopicUID === null) { + throw new Error( + "Missing the required parameter 'opts.logtopicUID' when calling createIndexOption" + ) + } + if (opts.logReduce === undefined || opts.logReduce === null) { + throw new Error( + "Missing the required parameter 'opts.logReduce' when calling createIndexOption" + ) + } + if (opts.fulltextIndex === undefined || opts.fulltextIndex === null) { + throw new Error( + "Missing the required parameter 'opts.fulltextIndex' when calling createIndexOption" + ) + } + if (opts.caseSensitive === undefined || opts.caseSensitive === null) { + throw new Error( + "Missing the required parameter 'opts.caseSensitive' when calling createIndexOption" + ) + } + if (opts.chn === undefined || opts.chn === null) { + throw new Error( + "Missing the required parameter 'opts.chn' when calling createIndexOption" + ) + } + if (opts.maxTextLen === undefined || opts.maxTextLen === null) { + throw new Error( + "Missing the required parameter 'opts.maxTextLen' when calling createIndexOption" + ) + } + + let postBody = {} + if (opts.logReduce !== undefined && opts.logReduce !== null) { + postBody['logReduce'] = opts.logReduce + } + if (opts.fulltextIndex !== undefined && opts.fulltextIndex !== null) { + postBody['fulltextIndex'] = opts.fulltextIndex + } + if (opts.caseSensitive !== undefined && opts.caseSensitive !== null) { + postBody['caseSensitive'] = opts.caseSensitive + } + if (opts.chn !== undefined && opts.chn !== null) { + postBody['chn'] = opts.chn + } + if (opts.token !== undefined && opts.token !== null) { + postBody['token'] = opts.token + } + if ( + opts.fieldIndexOptions !== undefined && + opts.fieldIndexOptions !== null + ) { + postBody['fieldIndexOptions'] = opts.fieldIndexOptions + } + if (opts.maxTextLen !== undefined && opts.maxTextLen !== null) { + postBody['maxTextLen'] = opts.maxTextLen + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + logtopicUID: opts.logtopicUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 createIndexOption 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}/logtopics/{logtopicUID}/indexoptions', + '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.logtopicUID - 日志主题 UID + * @param {boolean} opts.logReduce - 是否开启日志聚类,0-禁用,1-启用 + * @param {boolean} opts.fulltextIndex - 是否开启全文检索,0-禁用,1-启用 + * @param {boolean} opts.caseSensitive - 是否大小写敏感 + * @param {boolean} opts.chn - 是否开启中文分词 + * @param {array} [opts.token] - 分词符 optional + * @param {array} [opts.fieldIndexOptions] - 字段索引配置 optional + * @param {integer} opts.maxTextLen - 统计分析字段最大长度 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateIndexOption (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 updateIndexOption" + ) + } + + opts = opts || {} + + if (opts.logtopicUID === undefined || opts.logtopicUID === null) { + throw new Error( + "Missing the required parameter 'opts.logtopicUID' when calling updateIndexOption" + ) + } + if (opts.logReduce === undefined || opts.logReduce === null) { + throw new Error( + "Missing the required parameter 'opts.logReduce' when calling updateIndexOption" + ) + } + if (opts.fulltextIndex === undefined || opts.fulltextIndex === null) { + throw new Error( + "Missing the required parameter 'opts.fulltextIndex' when calling updateIndexOption" + ) + } + if (opts.caseSensitive === undefined || opts.caseSensitive === null) { + throw new Error( + "Missing the required parameter 'opts.caseSensitive' when calling updateIndexOption" + ) + } + if (opts.chn === undefined || opts.chn === null) { + throw new Error( + "Missing the required parameter 'opts.chn' when calling updateIndexOption" + ) + } + if (opts.maxTextLen === undefined || opts.maxTextLen === null) { + throw new Error( + "Missing the required parameter 'opts.maxTextLen' when calling updateIndexOption" + ) + } + + let postBody = {} + if (opts.logReduce !== undefined && opts.logReduce !== null) { + postBody['logReduce'] = opts.logReduce + } + if (opts.fulltextIndex !== undefined && opts.fulltextIndex !== null) { + postBody['fulltextIndex'] = opts.fulltextIndex + } + if (opts.caseSensitive !== undefined && opts.caseSensitive !== null) { + postBody['caseSensitive'] = opts.caseSensitive + } + if (opts.chn !== undefined && opts.chn !== null) { + postBody['chn'] = opts.chn + } + if (opts.token !== undefined && opts.token !== null) { + postBody['token'] = opts.token + } + if ( + opts.fieldIndexOptions !== undefined && + opts.fieldIndexOptions !== null + ) { + postBody['fieldIndexOptions'] = opts.fieldIndexOptions + } + if (opts.maxTextLen !== undefined && opts.maxTextLen !== null) { + postBody['maxTextLen'] = opts.maxTextLen + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + logtopicUID: opts.logtopicUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 updateIndexOption 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}/logtopics/{logtopicUID}/indexoptions', + '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) + } + ) + } + + /** + * 删除索引配置:业务日志指定索引相关的配置,包含全局及字段级别的配置 + * @param {Object} opts - parameters + * @param {string} opts.logtopicUID - 日志主题 UID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteIndexOption (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 deleteIndexOption" + ) + } + + opts = opts || {} + + if (opts.logtopicUID === undefined || opts.logtopicUID === null) { + throw new Error( + "Missing the required parameter 'opts.logtopicUID' when calling deleteIndexOption" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + logtopicUID: opts.logtopicUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 deleteIndexOption 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}/logtopics/{logtopicUID}/indexoptions', + '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.pin - 租户,必填 + * @param {string} opts.product - 产品名,必填 + * @param {string} opts.instance - 实例,必填 + * @param {string} callback - callback + @return {Object} result + * @param instanceCollectConfigInfo data + */ + + instanceCollectConfigList (opts, callback) { + opts = opts || {} + + if (opts.pin === undefined || opts.pin === null) { + throw new Error( + "Missing the required parameter 'opts.pin' when calling instanceCollectConfigList" + ) + } + if (opts.product === undefined || opts.product === null) { + throw new Error( + "Missing the required parameter 'opts.product' when calling instanceCollectConfigList" + ) + } + if (opts.instance === undefined || opts.instance === null) { + throw new Error( + "Missing the required parameter 'opts.instance' when calling instanceCollectConfigList" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pin !== undefined && opts.pin !== null) { + queryParams['pin'] = opts.pin + } + if (opts.product !== undefined && opts.product !== null) { + queryParams['product'] = opts.product + } + if (opts.instance !== undefined && opts.instance !== null) { + queryParams['instance'] = opts.instance + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 instanceCollectConfigList 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( + '/instanceCollectConfigList', + '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.pin - 租户,必填 + * @param {string} opts.product - 产品名,必填 + * @param {string} opts.instance - 实例,必填 + * @param {array} [opts.configs] - 修改的采集配置信息 optional + * @param {string} callback - callback + @return {Object} result + * @param string result 修改结果 + */ + + instanceCollectConfigModify (opts, callback) { + opts = opts || {} + + if (opts.pin === undefined || opts.pin === null) { + throw new Error( + "Missing the required parameter 'opts.pin' when calling instanceCollectConfigModify" + ) + } + if (opts.product === undefined || opts.product === null) { + throw new Error( + "Missing the required parameter 'opts.product' when calling instanceCollectConfigModify" + ) + } + if (opts.instance === undefined || opts.instance === null) { + throw new Error( + "Missing the required parameter 'opts.instance' when calling instanceCollectConfigModify" + ) + } + + let postBody = {} + if (opts.pin !== undefined && opts.pin !== null) { + postBody['pin'] = opts.pin + } + if (opts.product !== undefined && opts.product !== null) { + postBody['product'] = opts.product + } + if (opts.instance !== undefined && opts.instance !== null) { + postBody['instance'] = opts.instance + } + if (opts.configs !== undefined && opts.configs !== null) { + postBody['configs'] = opts.configs + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 instanceCollectConfigModify 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( + '/instanceCollectConfigModify', + '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) + } + ) + } + + /** + * k8s watch heartbeat + * @param {Object} opts - parameters + * @param {string} [opts.cluster] - 集群 optional + * @param {string} [opts.devId] - 设备id optional + * @param {boolean} [opts.cloud] - 公有云集群标识 optional + * @param {integer} [opts.nodeCount] - node数量 optional + * @param {integer} [opts.containerCount] - 容器数量 optional + * @param {integer} [opts.latestPodChangeTime] - 最新容器变化时间 optional + * @param {string} callback - callback + @return {Object} result + * @param boolean result 配置下发结果true:成功;false:失败; + */ + + k8sWatchHeartbeat (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.cluster !== undefined && opts.cluster !== null) { + postBody['cluster'] = opts.cluster + } + if (opts.devId !== undefined && opts.devId !== null) { + postBody['devId'] = opts.devId + } + if (opts.cloud !== undefined && opts.cloud !== null) { + postBody['cloud'] = opts.cloud + } + if (opts.nodeCount !== undefined && opts.nodeCount !== null) { + postBody['nodeCount'] = opts.nodeCount + } + if (opts.containerCount !== undefined && opts.containerCount !== null) { + postBody['containerCount'] = opts.containerCount + } + if ( + opts.latestPodChangeTime !== undefined && + opts.latestPodChangeTime !== null + ) { + postBody['latestPodChangeTime'] = opts.latestPodChangeTime + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 k8sWatchHeartbeat 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( + '/k8sWatchHeartbeat', + '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) + } + ) + } + + /** + * 获取满足条件的查询id + * @param {Object} opts - parameters + * @param {string} [opts.pin] - 租户信息 optional + * @param {array} [opts.apps] - 搜索应用 optional + * @param {string} [opts.keyword] - 搜索关键字 optional + * @param {string} [opts.exclude] - 排除关键字 optional + * @param {array} [opts.hosts] - 查询机器 optional + * @param {array} [opts.filePaths] - 日志路径 optional + * @param {string} [opts.logLevel] - 日志等级,枚举类型取值为:DEBUG,INFO,WARN,ERROR,FATAL,ALL,UNKNOWN optional + * @param {string} [opts.thread] - 线程 optional + * @param {string} [opts.clazz] - 类名 optional + * @param {integer} [opts.limit] - 限制条数 optional + * @param {string} [opts.startTime] - 开始时间 optional + * @param {string} [opts.endTime] - 结束时间 optional + * @param {string} [opts.timeUnit] - 查询时间单位,枚举类型取值为:NANOSECONDS,MICROSECONDS,SECONDS,MINUTES,DAYS optional + * @param {string} [opts.searchType] - 搜索类型:regular、exact optional + * @param {string} [opts.instanceName] - 应用名 optional + * @param {string} [opts.productName] - 产品名 optional + * @param {string} [opts.logTypeName] - 日志类型名称 optional + * @param {array} [opts.chunks] - chunks optional + * @param {string} [opts.direction] - 匹配方向 optional + * @param {string} [opts.searchId] - 查询id optional + * @param {integer} [opts.searchIndex] - 检索index optional + * @param {integer} [opts.searchEndTime] - searchEndTime optional + * @param {integer} [opts.lifecycle] - lifecycle optional + * @param {string} [opts.querySql] - 查询sql optional + * @param {object} [opts.indexParams] - 索引参数列表,map类型,key必须是string类型,value可自定义 optional + * @param {string} callback - callback + @return {Object} result + * @param integer status response状态码 + * @param string desc response描述 + * @param string searchId 日志查询id + */ + + logSearchId (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.pin !== undefined && opts.pin !== null) { + postBody['pin'] = opts.pin + } + if (opts.apps !== undefined && opts.apps !== null) { + postBody['apps'] = opts.apps + } + if (opts.keyword !== undefined && opts.keyword !== null) { + postBody['keyword'] = opts.keyword + } + if (opts.exclude !== undefined && opts.exclude !== null) { + postBody['exclude'] = opts.exclude + } + if (opts.hosts !== undefined && opts.hosts !== null) { + postBody['hosts'] = opts.hosts + } + if (opts.filePaths !== undefined && opts.filePaths !== null) { + postBody['filePaths'] = opts.filePaths + } + if (opts.logLevel !== undefined && opts.logLevel !== null) { + postBody['logLevel'] = opts.logLevel + } + if (opts.thread !== undefined && opts.thread !== null) { + postBody['thread'] = opts.thread + } + if (opts.clazz !== undefined && opts.clazz !== null) { + postBody['clazz'] = opts.clazz + } + if (opts.limit !== undefined && opts.limit !== null) { + postBody['limit'] = opts.limit + } + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.timeUnit !== undefined && opts.timeUnit !== null) { + postBody['timeUnit'] = opts.timeUnit + } + if (opts.searchType !== undefined && opts.searchType !== null) { + postBody['searchType'] = opts.searchType + } + if (opts.instanceName !== undefined && opts.instanceName !== null) { + postBody['instanceName'] = opts.instanceName + } + if (opts.productName !== undefined && opts.productName !== null) { + postBody['productName'] = opts.productName + } + if (opts.logTypeName !== undefined && opts.logTypeName !== null) { + postBody['logTypeName'] = opts.logTypeName + } + if (opts.chunks !== undefined && opts.chunks !== null) { + postBody['chunks'] = opts.chunks + } + if (opts.direction !== undefined && opts.direction !== null) { + postBody['direction'] = opts.direction + } + if (opts.searchId !== undefined && opts.searchId !== null) { + postBody['searchId'] = opts.searchId + } + if (opts.searchIndex !== undefined && opts.searchIndex !== null) { + postBody['searchIndex'] = opts.searchIndex + } + if (opts.searchEndTime !== undefined && opts.searchEndTime !== null) { + postBody['searchEndTime'] = opts.searchEndTime + } + if (opts.lifecycle !== undefined && opts.lifecycle !== null) { + postBody['lifecycle'] = opts.lifecycle + } + if (opts.querySql !== undefined && opts.querySql !== null) { + postBody['querySql'] = opts.querySql + } + if (opts.indexParams !== undefined && opts.indexParams !== null) { + postBody['indexParams'] = opts.indexParams + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 logSearchId 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( + '/logSearchId', + '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 {} [opts.searchId] - 检索id optional + * @param {} [opts.limit] - response状态码 optional + * @param {string} callback - callback + @return {Object} result + * @param boolean completed 本次检索是否完成 + * @param logInfo logs + */ + + logSearch (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.searchId !== undefined && opts.searchId !== null) { + postBody['searchId'] = opts.searchId + } + if (opts.limit !== undefined && opts.limit !== null) { + postBody['limit'] = opts.limit + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 logSearch 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( + '/logSearch', + '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.logtopicUID - 日志主题 UID + * @param {string} [opts.name] - Name 任务名 optional + * @param {string} [opts.keyword] - Keyword 查询关键字 optional + * @param {integer} [opts.compress] - Compress 压缩方式:0:不压缩,1:gzip,2:snappy optional + * @param {integer} [opts.format] - Format 文件格式:0: CSV, 1:JSON optional + * @param {integer} [opts.logCount] - 日志条数 optional + * @param {integer} [opts.quote] - Quote quote:0:双引号;1:单引号 optional + * @param {integer} [opts.fileSort] - FileSort 文件排序,0:正序,1:倒序 optional + * @param {integer} [opts.startTimestamp] - StartTimestamp 下载内容开始时间 optional + * @param {integer} [opts.endTimestamp] - EndTimestamp 下载内容截止时间 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string downloadTaskUID DownloadTaskUID + */ + + createLogDownloadTask (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 createLogDownloadTask" + ) + } + + opts = opts || {} + + if (opts.logtopicUID === undefined || opts.logtopicUID === null) { + throw new Error( + "Missing the required parameter 'opts.logtopicUID' when calling createLogDownloadTask" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.keyword !== undefined && opts.keyword !== null) { + postBody['keyword'] = opts.keyword + } + if (opts.compress !== undefined && opts.compress !== null) { + postBody['compress'] = opts.compress + } + if (opts.format !== undefined && opts.format !== null) { + postBody['format'] = opts.format + } + if (opts.logCount !== undefined && opts.logCount !== null) { + postBody['logCount'] = opts.logCount + } + if (opts.quote !== undefined && opts.quote !== null) { + postBody['quote'] = opts.quote + } + if (opts.fileSort !== undefined && opts.fileSort !== null) { + postBody['fileSort'] = opts.fileSort + } + if (opts.startTimestamp !== undefined && opts.startTimestamp !== null) { + postBody['startTimestamp'] = opts.startTimestamp + } + if (opts.endTimestamp !== undefined && opts.endTimestamp !== null) { + postBody['endTimestamp'] = opts.endTimestamp + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + logtopicUID: opts.logtopicUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 createLogDownloadTask 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}/logtopics/{logtopicUID}/downloadtask', + '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.logtopicUID - 日志主题 UID + * @param {string} opts.downloadTaskUID - 日志下载任务 UID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string downloadTaskUID DownloadTaskUID + */ + + cancelLogDownloadTask (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 cancelLogDownloadTask" + ) + } + + opts = opts || {} + + if (opts.logtopicUID === undefined || opts.logtopicUID === null) { + throw new Error( + "Missing the required parameter 'opts.logtopicUID' when calling cancelLogDownloadTask" + ) + } + if (opts.downloadTaskUID === undefined || opts.downloadTaskUID === null) { + throw new Error( + "Missing the required parameter 'opts.downloadTaskUID' when calling cancelLogDownloadTask" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + logtopicUID: opts.logtopicUID, + downloadTaskUID: opts.downloadTaskUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 cancelLogDownloadTask 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}/logtopics/{logtopicUID}/downloadtask/{downloadTaskUID}/cancel', + '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) + } + ) + } + + /** + * 获取日志下载任务列表 + * @param {Object} opts - parameters + * @param {string} opts.logtopicUID - 日志主题 UID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param logDownloadTask data + */ + + getLogDownloadTasks (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 getLogDownloadTasks" + ) + } + + opts = opts || {} + + if (opts.logtopicUID === undefined || opts.logtopicUID === null) { + throw new Error( + "Missing the required parameter 'opts.logtopicUID' when calling getLogDownloadTasks" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + logtopicUID: opts.logtopicUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 getLogDownloadTasks 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}/logtopics/{logtopicUID}/downloadtasks', + '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 optional + * @param {integer} [opts.pageSize] - 页面大小,默认为20;取值范围[1, 200] optional + * @param {string} [opts.name] - 日志集名称. 已废弃,需要通过filter传递 optional + * @param {filter} [opts.filters] - 过滤条件,key,Values。 支持的key: name optional + * @param {tagFilter} [opts.tags] - 标签过滤条件,key,Values optional + * @param {string} [opts.resourceGroupIds] - 资源组过滤条件 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param logsetEnd data + * @param integer numberPages 总页数 + * @param integer numberRecords 总记录数 + * @param integer pageNumber 当前页码 + * @param integer pageSize 分页大小 + */ + + describeLogsets (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 describeLogsets" + ) + } + + 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.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + Object.assign(queryParams, super.buildTagFilterParam(opts.tags, 'tags')) + Object.assign( + queryParams, + super.buildArrayParam(opts.resourceGroupIds, 'resourceGroupIds') + ) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 describeLogsets 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}/logsets', + '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.name - 日志集名称 + * @param {string} [opts.description] - 日志集描述 optional + * @param {integer} [opts.lifeCycle] - 保存周期,只能是 7, 15, 30 optional + * @param {array} [opts.tags] - 标签列表 optional + * @param {string} [opts.resourceGroupUID] - 资源组信息 optional + * @param {boolean} [opts.inner] - 是否是内部资源。 设置为 true,则外部租户不可见。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string uID UID + */ + + createLogset (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 createLogset" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createLogset" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.lifeCycle !== undefined && opts.lifeCycle !== null) { + postBody['lifeCycle'] = opts.lifeCycle + } + if (opts.tags !== undefined && opts.tags !== null) { + postBody['tags'] = opts.tags + } + if (opts.resourceGroupUID !== undefined && opts.resourceGroupUID !== null) { + postBody['resourceGroupUID'] = opts.resourceGroupUID + } + if (opts.inner !== undefined && opts.inner !== null) { + postBody['inner'] = opts.inner + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 createLogset 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}/logsets', + '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.logsetUID - 日志集 UID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string uID UID + * @param string createTime 创建时间 + * @param string description 描述信息 + * @param boolean hasTopic 是否存在日志主题 + * @param integer lifeCycle 保存周期 + * @param string name 日志集名称 + * @param string region 地域信息 + * @param string resourceGroupUID 资源组 + * @param tag tags + */ + + describeLogset (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 describeLogset" + ) + } + + opts = opts || {} + + if (opts.logsetUID === undefined || opts.logsetUID === null) { + throw new Error( + "Missing the required parameter 'opts.logsetUID' when calling describeLogset" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + logsetUID: opts.logsetUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 describeLogset 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}/logsets/{logsetUID}', + '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.logsetUID - 日志集 UID + * @param {string} opts.name - 日志集名称 + * @param {string} [opts.description] - 日志集描述 optional + * @param {integer} [opts.lifeCycle] - 保存周期,只能是 7, 15, 30 optional + * @param {array} [opts.tags] - 标签列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateLogset (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 updateLogset" + ) + } + + opts = opts || {} + + if (opts.logsetUID === undefined || opts.logsetUID === null) { + throw new Error( + "Missing the required parameter 'opts.logsetUID' when calling updateLogset" + ) + } + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling updateLogset" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.lifeCycle !== undefined && opts.lifeCycle !== null) { + postBody['lifeCycle'] = opts.lifeCycle + } + if (opts.tags !== undefined && opts.tags !== null) { + postBody['tags'] = opts.tags + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + logsetUID: opts.logsetUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 updateLogset 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}/logsets/{logsetUID}', + '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) + } + ) + } + + /** + * 删除日志集,删除多个日志集时,任意的日志集包含了日志主题的,将导致全部删除失败。 + * @param {Object} opts - parameters + * @param {string} opts.logsetUIDs - 日志集ID,多个日志集ID以逗号分割 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteLogset (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 deleteLogset" + ) + } + + opts = opts || {} + + if (opts.logsetUIDs === undefined || opts.logsetUIDs === null) { + throw new Error( + "Missing the required parameter 'opts.logsetUIDs' when calling deleteLogset" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + logsetUIDs: opts.logsetUIDs + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 deleteLogset 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}/logsets/{logsetUIDs}', + '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.logsetUID - 日志集 UID + * @param {integer} [opts.pageNumber] - 当前所在页,默认为1 optional + * @param {integer} [opts.pageSize] - 页面大小,默认为20;取值范围[1, 200] optional + * @param {string} [opts.name] - 日志主题名称 optional + * @param {string} [opts.appName] - 日志主题采集的日志类型 optional + * @param {filter} [opts.filters] - 过滤条件,key,Values optional + * @param {tagFilter} [opts.tags] - 过滤条件,key,Values optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param logtopicDetailEnd data + * @param integer numberPages 总页数 + * @param integer numberRecords 总记录数 + * @param integer pageNumber 当前页码 + * @param integer pageSize 分页大小 + */ + + describeLogtopics (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 describeLogtopics" + ) + } + + opts = opts || {} + + if (opts.logsetUID === undefined || opts.logsetUID === null) { + throw new Error( + "Missing the required parameter 'opts.logsetUID' when calling describeLogtopics" + ) + } + + 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.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + if (opts.appName !== undefined && opts.appName !== null) { + queryParams['appName'] = opts.appName + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + Object.assign(queryParams, super.buildTagFilterParam(opts.tags, 'tags')) + + let pathParams = { + regionId: regionId, + logsetUID: opts.logsetUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 describeLogtopics 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}/logsets/{logsetUID}/logtopics', + '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.logsetUID - 日志集 UID + * @param {string} opts.name - 日志主题名称 + * @param {string} [opts.description] - 日志集描述 optional + * @param {boolean} [opts.inOrder] - 保序 optional + * @param {integer} [opts.lifeCycle] - 保存周期,只能是 7, 15, 30 optional + * @param {array} [opts.tags] - 标签列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string uID UID + */ + + createLogtopic (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 createLogtopic" + ) + } + + opts = opts || {} + + if (opts.logsetUID === undefined || opts.logsetUID === null) { + throw new Error( + "Missing the required parameter 'opts.logsetUID' when calling createLogtopic" + ) + } + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createLogtopic" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.inOrder !== undefined && opts.inOrder !== null) { + postBody['inOrder'] = opts.inOrder + } + if (opts.lifeCycle !== undefined && opts.lifeCycle !== null) { + postBody['lifeCycle'] = opts.lifeCycle + } + if (opts.tags !== undefined && opts.tags !== null) { + postBody['tags'] = opts.tags + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + logsetUID: opts.logsetUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 createLogtopic 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}/logsets/{logsetUID}/logtopics', + '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.logsetUID - 日志集 UID + * @param {string} opts.logtopicUIDs - 日志主题ID,多个日志主题ID以逗号分割 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteLogtopic (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 deleteLogtopic" + ) + } + + opts = opts || {} + + if (opts.logsetUID === undefined || opts.logsetUID === null) { + throw new Error( + "Missing the required parameter 'opts.logsetUID' when calling deleteLogtopic" + ) + } + if (opts.logtopicUIDs === undefined || opts.logtopicUIDs === null) { + throw new Error( + "Missing the required parameter 'opts.logtopicUIDs' when calling deleteLogtopic" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + logsetUID: opts.logsetUID, + logtopicUIDs: opts.logtopicUIDs + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 deleteLogtopic 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}/logsets/{logsetUID}/logtopics/{logtopicUIDs}', + '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.appName] - 日志主题采集的日志类型 optional + * @param {filter} [opts.filters] - 过滤条件,key,Values, 合法的key:logtopicName, logtopicUID, logsetName, logsetUID optional + * @param {tagFilter} [opts.tags] - 过滤条件,key,Values optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param logtopicBaseEnd data + */ + + describeLogtopicsGlobal (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 describeLogtopicsGlobal" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.appName !== undefined && opts.appName !== null) { + queryParams['appName'] = opts.appName + } + 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 logs/2.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 describeLogtopicsGlobal 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}/logtopics', + '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) + } + ) + } + + /** + * 查询日志主题基本信息。如配置了采集配置,将返回采集配置的UID + * @param {Object} opts - parameters + * @param {string} opts.logtopicUID - 日志主题 UID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string uID UID + * @param string appCode 日志来源,只在查询单个日志主题并且创建了采集配置时返回值 + * @param string appName 日志主题采集的日志类型 + * @param string collectInfoUID 采集配置UID + * @param string createTime 创建时间 + * @param string description 描述信息 + * @param boolean inOrder 保序标识 + * @param integer lifeCycle 生命周期 + * @param string logsetName 所属日志集名称 + * @param string logsetUID 所属日志集 + * @param string name 日志主题名称 + * @param string prePattern 预处理模式 + * @param string region 地域信息 + * @param string serviceCode 产品线serviceCode + */ + + describeLogtopic (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 describeLogtopic" + ) + } + + opts = opts || {} + + if (opts.logtopicUID === undefined || opts.logtopicUID === null) { + throw new Error( + "Missing the required parameter 'opts.logtopicUID' when calling describeLogtopic" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + logtopicUID: opts.logtopicUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 describeLogtopic 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}/logtopics/{logtopicUID}', + '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.logtopicUID - 日志主题 UID + * @param {string} [opts.name] - 日志主题名称 optional + * @param {string} opts.description - 日志主题描述 + * @param {integer} [opts.lifeCycle] - 保存周期,只能是 7, 15, 30 optional + * @param {boolean} [opts.inOrder] - 保序 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateLogtopic (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 updateLogtopic" + ) + } + + opts = opts || {} + + if (opts.logtopicUID === undefined || opts.logtopicUID === null) { + throw new Error( + "Missing the required parameter 'opts.logtopicUID' when calling updateLogtopic" + ) + } + if (opts.description === undefined || opts.description === null) { + throw new Error( + "Missing the required parameter 'opts.description' when calling updateLogtopic" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.lifeCycle !== undefined && opts.lifeCycle !== null) { + postBody['lifeCycle'] = opts.lifeCycle + } + if (opts.inOrder !== undefined && opts.inOrder !== null) { + postBody['inOrder'] = opts.inOrder + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + logtopicUID: opts.logtopicUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 updateLogtopic 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}/logtopics/{logtopicUID}', + '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) + } + ) + } + + /** + * 日志测试,根据用户输入的日志筛选条件以及监控指标设置进行模拟监控统计 + * @param {Object} opts - parameters + * @param {string} opts.logsetUID - 日志集 UID + * @param {string} opts.logtopicUID - 日志主题 UID + * @param {string} [opts.aggregate] - 聚合函数,支持 count sum max min avg; 配置方式(SettingType) 为 空或visual 时,必填; optional + * @param {array} [opts.content] - 测试内容 optional + * @param {string} [opts.dataField] - 查询字段,支持 英文字母 数字 下划线 中划线 点(中文日志原文和各产品线的key); 配置方式(SettingType) 为 空或visual 时,必填; optional + * @param {string} [opts.filterContent] - 过滤语法,可以为空 optional + * @param {string} [opts.filterOpen] - 是否打开过滤; 配置方式(SettingType) 为 空或visual 时,必填; optional + * @param {string} [opts.filterType] - 过滤类型,只能是fulltext和 advance; 配置方式(SettingType) 为 空或visual 时,必填; optional + * @param {string} [opts.metric] - 监控项 , 支持大小写英文字母 下划线 数字 点,且不超过255byte(不支持中划线); 配置方式(SettingType) 为 空或visual 时,必填; optional + * @param {string} [opts.settingType] - 配置方式: 可选参数;枚举值 visual,sql;分别代表可视化配置及sql配置方式,传空表示可视化配置; optional + * @param {metricTaskSqlSpec} [opts.sqlSpec] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string lines + * @param number value 监控值 + */ + + testMetricTask (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 testMetricTask" + ) + } + + opts = opts || {} + + if (opts.logsetUID === undefined || opts.logsetUID === null) { + throw new Error( + "Missing the required parameter 'opts.logsetUID' when calling testMetricTask" + ) + } + if (opts.logtopicUID === undefined || opts.logtopicUID === null) { + throw new Error( + "Missing the required parameter 'opts.logtopicUID' when calling testMetricTask" + ) + } + + let postBody = {} + if (opts.aggregate !== undefined && opts.aggregate !== null) { + postBody['aggregate'] = opts.aggregate + } + if (opts.content !== undefined && opts.content !== null) { + postBody['content'] = opts.content + } + if (opts.dataField !== undefined && opts.dataField !== null) { + postBody['dataField'] = opts.dataField + } + if (opts.filterContent !== undefined && opts.filterContent !== null) { + postBody['filterContent'] = opts.filterContent + } + if (opts.filterOpen !== undefined && opts.filterOpen !== null) { + postBody['filterOpen'] = opts.filterOpen + } + if (opts.filterType !== undefined && opts.filterType !== null) { + postBody['filterType'] = opts.filterType + } + if (opts.metric !== undefined && opts.metric !== null) { + postBody['metric'] = opts.metric + } + if (opts.settingType !== undefined && opts.settingType !== null) { + postBody['settingType'] = opts.settingType + } + if (opts.sqlSpec !== undefined && opts.sqlSpec !== null) { + postBody['sqlSpec'] = opts.sqlSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + logsetUID: opts.logsetUID, + logtopicUID: opts.logtopicUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 testMetricTask 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}/logsets/{logsetUID}/logtopics/{logtopicUID}/metrictaskTest', + '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.logsetUID - 日志集 UID + * @param {string} opts.logtopicUID - 日志主题 UID + * @param {integer} [opts.pageNumber] - 当前所在页,默认为1 +in: query optional + * @param {integer} [opts.pageSize] - 页面大小,默认为20;取值范围[1, 100] +in: query optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param metrictaskDetailEnd data + * @param integer numberPages 总页数 + * @param integer numberRecords 总记录数 + * @param integer pageNumber 当前页码 + * @param integer pageSize 分页大小 + */ + + describeMetricTasks (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 describeMetricTasks" + ) + } + + opts = opts || {} + + if (opts.logsetUID === undefined || opts.logsetUID === null) { + throw new Error( + "Missing the required parameter 'opts.logsetUID' when calling describeMetricTasks" + ) + } + if (opts.logtopicUID === undefined || opts.logtopicUID === null) { + throw new Error( + "Missing the required parameter 'opts.logtopicUID' when calling describeMetricTasks" + ) + } + + 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, + logsetUID: opts.logsetUID, + logtopicUID: opts.logtopicUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 describeMetricTasks 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}/logsets/{logsetUID}/logtopics/{logtopicUID}/metrictasks', + '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.logsetUID - 日志集 UID + * @param {string} opts.logtopicUID - 日志主题 UID + * @param {string} [opts.aggregate] - 聚合函数,支持 count sum max min avg; 配置方式(SettingType) 为 空或visual 时,必填; optional + * @param {string} opts.customUnit - 自定义单位 + * @param {string} [opts.dataField] - 查询字段,支持 英文字母 数字 下划线 中划线 点(中文日志原文和各产品线的key); 配置方式(SettingType) 为 空或visual 时,必填; optional + * @param {string} [opts.filterContent] - 过滤语法,可以为空 optional + * @param {string} [opts.filterOpen] - 是否打开过滤; 配置方式(SettingType) 为 空或visual 时,必填; optional + * @param {string} [opts.filterType] - 过滤类型,只能是fulltext和 advance; 配置方式(SettingType) 为 空或visual 时,必填; optional + * @param {integer} opts.interval - 时间周期,固定60s + * @param {string} [opts.metric] - 监控项 , 支持大小写英文字母 下划线 数字 点,且不超过255byte(不支持中划线); 配置方式(SettingType) 为 空或visual 时,必填; optional + * @param {string} opts.name - 监控任务名称,同一个日志主题下唯一,支持中文 大小写英文字母 下划线 中划线 数字,且不超过32字符 + * @param {string} [opts.settingType] - 配置方式: 可选参数;枚举值 visual,sql;分别代表可视化配置及sql配置方式,传空表示可视化配置; optional + * @param {metricTaskSqlSpec} [opts.sqlSpec] optional + * @param {string} opts.unit - 单位 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string id UID + * @param string suc + */ + + createMetricTask (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 createMetricTask" + ) + } + + opts = opts || {} + + if (opts.logsetUID === undefined || opts.logsetUID === null) { + throw new Error( + "Missing the required parameter 'opts.logsetUID' when calling createMetricTask" + ) + } + if (opts.logtopicUID === undefined || opts.logtopicUID === null) { + throw new Error( + "Missing the required parameter 'opts.logtopicUID' when calling createMetricTask" + ) + } + if (opts.customUnit === undefined || opts.customUnit === null) { + throw new Error( + "Missing the required parameter 'opts.customUnit' when calling createMetricTask" + ) + } + if (opts.interval === undefined || opts.interval === null) { + throw new Error( + "Missing the required parameter 'opts.interval' when calling createMetricTask" + ) + } + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createMetricTask" + ) + } + if (opts.unit === undefined || opts.unit === null) { + throw new Error( + "Missing the required parameter 'opts.unit' when calling createMetricTask" + ) + } + + let postBody = {} + if (opts.aggregate !== undefined && opts.aggregate !== null) { + postBody['aggregate'] = opts.aggregate + } + if (opts.customUnit !== undefined && opts.customUnit !== null) { + postBody['customUnit'] = opts.customUnit + } + if (opts.dataField !== undefined && opts.dataField !== null) { + postBody['dataField'] = opts.dataField + } + if (opts.filterContent !== undefined && opts.filterContent !== null) { + postBody['filterContent'] = opts.filterContent + } + if (opts.filterOpen !== undefined && opts.filterOpen !== null) { + postBody['filterOpen'] = opts.filterOpen + } + if (opts.filterType !== undefined && opts.filterType !== null) { + postBody['filterType'] = opts.filterType + } + if (opts.interval !== undefined && opts.interval !== null) { + postBody['interval'] = opts.interval + } + if (opts.metric !== undefined && opts.metric !== null) { + postBody['metric'] = opts.metric + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.settingType !== undefined && opts.settingType !== null) { + postBody['settingType'] = opts.settingType + } + if (opts.sqlSpec !== undefined && opts.sqlSpec !== null) { + postBody['sqlSpec'] = opts.sqlSpec + } + if (opts.unit !== undefined && opts.unit !== null) { + postBody['unit'] = opts.unit + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + logsetUID: opts.logsetUID, + logtopicUID: opts.logtopicUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 createMetricTask 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}/logsets/{logsetUID}/logtopics/{logtopicUID}/metrictasks', + '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.logsetUID - 日志集 UID + * @param {string} opts.logtopicUID - 日志主题 UID + * @param {string} opts.logmetrictaskUID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param metrictaskDetailEnd data + */ + + describeMetricTask (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 describeMetricTask" + ) + } + + opts = opts || {} + + if (opts.logsetUID === undefined || opts.logsetUID === null) { + throw new Error( + "Missing the required parameter 'opts.logsetUID' when calling describeMetricTask" + ) + } + if (opts.logtopicUID === undefined || opts.logtopicUID === null) { + throw new Error( + "Missing the required parameter 'opts.logtopicUID' when calling describeMetricTask" + ) + } + if (opts.logmetrictaskUID === undefined || opts.logmetrictaskUID === null) { + throw new Error( + "Missing the required parameter 'opts.logmetrictaskUID' when calling describeMetricTask" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + logsetUID: opts.logsetUID, + logtopicUID: opts.logtopicUID, + logmetrictaskUID: opts.logmetrictaskUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 describeMetricTask 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}/logsets/{logsetUID}/logtopics/{logtopicUID}/metrictasks/{logmetrictaskUID}', + '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.logsetUID - 日志集 UID + * @param {string} opts.logtopicUID - 日志主题 UID + * @param {string} opts.logmetrictaskUID + * @param {string} [opts.aggregate] - 聚合函数,支持 count sum max min avg; 配置方式(SettingType) 为 空或visual 时,必填; optional + * @param {string} opts.customUnit - 自定义单位 + * @param {string} [opts.dataField] - 查询字段,支持 英文字母 数字 下划线 中划线 点(中文日志原文和各产品线的key); 配置方式(SettingType) 为 空或visual 时,必填; optional + * @param {string} [opts.filterContent] - 过滤语法,可以为空 optional + * @param {string} [opts.filterOpen] - 是否打开过滤; 配置方式(SettingType) 为 空或visual 时,必填; optional + * @param {string} [opts.filterType] - 过滤类型,只能是fulltext和 advance; 配置方式(SettingType) 为 空或visual 时,必填; optional + * @param {string} [opts.metric] - 监控项 , 支持大小写英文字母 下划线 数字 点,且不超过255byte(不支持中划线); 配置方式(SettingType) 为 空或visual 时,必填; optional + * @param {string} opts.name - 监控任务名称,同一日志主题下唯一,支持中文 大小写英文字母 下划线 中划线 数字,且不超过32 + * @param {string} [opts.settingType] - 配置方式: 可选参数;枚举值 visual,sql;分别代表可视化配置及sql配置方式,传空表示可视化配置; optional + * @param {metricTaskSqlSpec} [opts.sqlSpec] optional + * @param {string} opts.unit - 单位 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string suc + */ + + updateMetricTask (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 updateMetricTask" + ) + } + + opts = opts || {} + + if (opts.logsetUID === undefined || opts.logsetUID === null) { + throw new Error( + "Missing the required parameter 'opts.logsetUID' when calling updateMetricTask" + ) + } + if (opts.logtopicUID === undefined || opts.logtopicUID === null) { + throw new Error( + "Missing the required parameter 'opts.logtopicUID' when calling updateMetricTask" + ) + } + if (opts.logmetrictaskUID === undefined || opts.logmetrictaskUID === null) { + throw new Error( + "Missing the required parameter 'opts.logmetrictaskUID' when calling updateMetricTask" + ) + } + if (opts.customUnit === undefined || opts.customUnit === null) { + throw new Error( + "Missing the required parameter 'opts.customUnit' when calling updateMetricTask" + ) + } + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling updateMetricTask" + ) + } + if (opts.unit === undefined || opts.unit === null) { + throw new Error( + "Missing the required parameter 'opts.unit' when calling updateMetricTask" + ) + } + + let postBody = {} + if (opts.aggregate !== undefined && opts.aggregate !== null) { + postBody['aggregate'] = opts.aggregate + } + if (opts.customUnit !== undefined && opts.customUnit !== null) { + postBody['customUnit'] = opts.customUnit + } + if (opts.dataField !== undefined && opts.dataField !== null) { + postBody['dataField'] = opts.dataField + } + if (opts.filterContent !== undefined && opts.filterContent !== null) { + postBody['filterContent'] = opts.filterContent + } + if (opts.filterOpen !== undefined && opts.filterOpen !== null) { + postBody['filterOpen'] = opts.filterOpen + } + if (opts.filterType !== undefined && opts.filterType !== null) { + postBody['filterType'] = opts.filterType + } + if (opts.metric !== undefined && opts.metric !== null) { + postBody['metric'] = opts.metric + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.settingType !== undefined && opts.settingType !== null) { + postBody['settingType'] = opts.settingType + } + if (opts.sqlSpec !== undefined && opts.sqlSpec !== null) { + postBody['sqlSpec'] = opts.sqlSpec + } + if (opts.unit !== undefined && opts.unit !== null) { + postBody['unit'] = opts.unit + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + logsetUID: opts.logsetUID, + logtopicUID: opts.logtopicUID, + logmetrictaskUID: opts.logmetrictaskUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 updateMetricTask 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}/logsets/{logsetUID}/logtopics/{logtopicUID}/metrictasks/{logmetrictaskUID}', + '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) + } + ) + } + + /** + * 删除指定监控任务。 + * @param {Object} opts - parameters + * @param {string} opts.logsetUID - 日志集 UID + * @param {string} opts.logtopicUID - 日志主题 UID + * @param {string} opts.logmetrictaskUID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string suc + */ + + deleteMetricTask (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 deleteMetricTask" + ) + } + + opts = opts || {} + + if (opts.logsetUID === undefined || opts.logsetUID === null) { + throw new Error( + "Missing the required parameter 'opts.logsetUID' when calling deleteMetricTask" + ) + } + if (opts.logtopicUID === undefined || opts.logtopicUID === null) { + throw new Error( + "Missing the required parameter 'opts.logtopicUID' when calling deleteMetricTask" + ) + } + if (opts.logmetrictaskUID === undefined || opts.logmetrictaskUID === null) { + throw new Error( + "Missing the required parameter 'opts.logmetrictaskUID' when calling deleteMetricTask" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + logsetUID: opts.logsetUID, + logtopicUID: opts.logtopicUID, + logmetrictaskUID: opts.logmetrictaskUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 deleteMetricTask 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}/logsets/{logsetUID}/logtopics/{logtopicUID}/metrictasks/{logmetrictaskUID}', + '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) + } + ) + } + + /** + * k8s日志采集配置下发 + * @param {Object} opts - parameters + * @param {string} [opts.tenantName] - 租户字段 optional + * @param {string} [opts.clusterName] - 集群字段 optional + * @param {string} [opts.zoneName] - 机房字段 optional + * @param {string} [opts.nodeIp] - node-ip字段 optional + * @param {string} [opts.conf] - 采集配置字段 optional + * @param {string} callback - callback + @return {Object} result + * @param boolean result 配置下发结果true:成功;false:失败; + */ + + k8sDispatchConf (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.tenantName !== undefined && opts.tenantName !== null) { + postBody['tenantName'] = opts.tenantName + } + if (opts.clusterName !== undefined && opts.clusterName !== null) { + postBody['clusterName'] = opts.clusterName + } + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.nodeIp !== undefined && opts.nodeIp !== null) { + postBody['nodeIp'] = opts.nodeIp + } + if (opts.conf !== undefined && opts.conf !== null) { + postBody['conf'] = opts.conf + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 k8sDispatchConf 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( + '/k8sconfig', + '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) + } + ) + } + + /** + * k8s日志采集配置下发 + * @param {Object} opts - parameters + * @param {string} [opts.tenantName] - 租户字段 optional + * @param {string} [opts.clusterName] - 集群字段 optional + * @param {string} [opts.zoneName] - 机房字段 optional + * @param {string} [opts.nodeIp] - node-ip字段 optional + * @param {string} [opts.conf] - 采集配置字段 optional + * @param {string} callback - callback + @return {Object} result + * @param boolean result 配置下发结果true:成功;false:失败; + */ + + k8sDispatchConfNew (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.tenantName !== undefined && opts.tenantName !== null) { + postBody['tenantName'] = opts.tenantName + } + if (opts.clusterName !== undefined && opts.clusterName !== null) { + postBody['clusterName'] = opts.clusterName + } + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.nodeIp !== undefined && opts.nodeIp !== null) { + postBody['nodeIp'] = opts.nodeIp + } + if (opts.conf !== undefined && opts.conf !== null) { + postBody['conf'] = opts.conf + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 k8sDispatchConfNew 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( + '/k8sconfigNew', + '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) + } + ) + } + + /** + * k8s日志采集配置下发 + * @param {Object} opts - parameters + * @param {string} [opts.tenantName] - 租户字段 optional + * @param {string} [opts.clusterName] - 集群字段 optional + * @param {string} [opts.zoneName] - 机房字段 optional + * @param {string} [opts.nodeIp] - node-ip字段 optional + * @param {string} [opts.conf] - 采集配置字段 optional + * @param {boolean} [opts.cloud] - 是否为公有云 optional + * @param {string} callback - callback + @return {Object} result + * @param boolean result 配置下发结果true:成功;false:失败; + */ + + k8sconfigNewV2 (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.tenantName !== undefined && opts.tenantName !== null) { + postBody['tenantName'] = opts.tenantName + } + if (opts.clusterName !== undefined && opts.clusterName !== null) { + postBody['clusterName'] = opts.clusterName + } + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.nodeIp !== undefined && opts.nodeIp !== null) { + postBody['nodeIp'] = opts.nodeIp + } + if (opts.conf !== undefined && opts.conf !== null) { + postBody['conf'] = opts.conf + } + if (opts.cloud !== undefined && opts.cloud !== null) { + postBody['cloud'] = opts.cloud + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 k8sconfigNewV2 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( + '/k8sconfigNewV2', + '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.product - 产品名称 + * @param {string} [opts.instance] - 实例名称 optional + * @param {string} [opts.searchId] - UUID,同一批次保持一致,必填 optional + * @param {string} [opts.logType] - 日志类型 optional + * @param {array} [opts.ip] - ip optional + * @param {array} [opts.podName] - pod name optional + * @param {string} [opts.namespace] - 命名空间 optional + * @param {string} [opts.cluster] - 集群 optional + * @param {string} [opts.containerName] - 容器名 optional + * @param {array} [opts.filePath] - 文件路径 optional + * @param {integer} [opts.startTime] - 开始时间纳秒数字,默认一小时前 optional + * @param {integer} [opts.endTime] - 结束时间纳秒数字,默认现在 optional + * @param {string} [opts.direction] - 正序:FORWARD、倒序:BACKWARD,默认BACKWARD optional + * @param {integer} [opts.limit] - 查询数量数字,默认100 optional + * @param {number} [opts.step] - 步长时间(单位:秒),10、0.5 optional + * @param {array} [opts.streamFilter] - label过滤 optional + * @param {lineFilter} [opts.lineFilter] - 行过滤 optional + * @param {formatFilter} [opts.fmtFilter] - 格式化过滤条件 optional + * @param {string} callback - callback + @return {Object} result + * @param string status status + * @param boolean completed status + * @param lokiResponseData data data + */ + + logDetailPublic (opts, callback) { + opts = opts || {} + + if (opts.product === undefined || opts.product === null) { + throw new Error( + "Missing the required parameter 'opts.product' when calling logDetailPublic" + ) + } + if (opts.instance === undefined || opts.instance === null) { + throw new Error( + "Missing the required parameter 'opts.instance' when calling logDetailPublic" + ) + } + + let postBody = {} + if (opts.searchId !== undefined && opts.searchId !== null) { + postBody['searchId'] = opts.searchId + } + if (opts.logType !== undefined && opts.logType !== null) { + postBody['logType'] = opts.logType + } + if (opts.ip !== undefined && opts.ip !== null) { + postBody['ip'] = opts.ip + } + if (opts.podName !== undefined && opts.podName !== null) { + postBody['podName'] = opts.podName + } + if (opts.namespace !== undefined && opts.namespace !== null) { + postBody['namespace'] = opts.namespace + } + if (opts.cluster !== undefined && opts.cluster !== null) { + postBody['cluster'] = opts.cluster + } + if (opts.containerName !== undefined && opts.containerName !== null) { + postBody['containerName'] = opts.containerName + } + if (opts.filePath !== undefined && opts.filePath !== null) { + postBody['filePath'] = opts.filePath + } + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.direction !== undefined && opts.direction !== null) { + postBody['direction'] = opts.direction + } + if (opts.limit !== undefined && opts.limit !== null) { + postBody['limit'] = opts.limit + } + if (opts.step !== undefined && opts.step !== null) { + postBody['step'] = opts.step + } + if (opts.streamFilter !== undefined && opts.streamFilter !== null) { + postBody['streamFilter'] = opts.streamFilter + } + if (opts.lineFilter !== undefined && opts.lineFilter !== null) { + postBody['lineFilter'] = opts.lineFilter + } + if (opts.fmtFilter !== undefined && opts.fmtFilter !== null) { + postBody['fmtFilter'] = opts.fmtFilter + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + product: opts.product, + instance: opts.instance + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 logDetailPublic 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( + '/logDetail/{product}/instance/{instance}', + '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.pin - 租户 + * @param {string} [opts.searchId] - UUID,同一批次保持一致,必填 optional + * @param {string} opts.product - 产品名,必填 + * @param {string} [opts.instance] - 实例 optional + * @param {string} [opts.logType] - 日志类型 optional + * @param {array} [opts.ip] - ip optional + * @param {array} [opts.podName] - pod name optional + * @param {string} [opts.namespace] - 命名空间 optional + * @param {string} [opts.cluster] - 集群 optional + * @param {string} [opts.containerName] - 容器名 optional + * @param {array} [opts.filePath] - 文件路径 optional + * @param {integer} [opts.startTime] - 开始时间纳秒数字,默认一小时前 optional + * @param {integer} [opts.endTime] - 结束时间纳秒数字,默认现在 optional + * @param {string} [opts.direction] - 正序:FORWARD、倒序:BACKWARD,默认BACKWARD optional + * @param {integer} [opts.limit] - 查询数量数字,默认100 optional + * @param {number} [opts.step] - 步长时间(单位:秒),10、0.5 optional + * @param {array} [opts.streamFilter] - label过滤 optional + * @param {lineFilter} [opts.lineFilter] - 行过滤 optional + * @param {formatFilter} [opts.fmtFilter] - 格式化过滤条件 optional + * @param {string} callback - callback + @return {Object} result + * @param string status status + * @param boolean completed status + * @param lokiResponseData data data + */ + + logDetail (opts, callback) { + opts = opts || {} + + if (opts.pin === undefined || opts.pin === null) { + throw new Error( + "Missing the required parameter 'opts.pin' when calling logDetail" + ) + } + if (opts.product === undefined || opts.product === null) { + throw new Error( + "Missing the required parameter 'opts.product' when calling logDetail" + ) + } + + let postBody = {} + if (opts.pin !== undefined && opts.pin !== null) { + postBody['pin'] = opts.pin + } + if (opts.searchId !== undefined && opts.searchId !== null) { + postBody['searchId'] = opts.searchId + } + if (opts.product !== undefined && opts.product !== null) { + postBody['product'] = opts.product + } + if (opts.instance !== undefined && opts.instance !== null) { + postBody['instance'] = opts.instance + } + if (opts.logType !== undefined && opts.logType !== null) { + postBody['logType'] = opts.logType + } + if (opts.ip !== undefined && opts.ip !== null) { + postBody['ip'] = opts.ip + } + if (opts.podName !== undefined && opts.podName !== null) { + postBody['podName'] = opts.podName + } + if (opts.namespace !== undefined && opts.namespace !== null) { + postBody['namespace'] = opts.namespace + } + if (opts.cluster !== undefined && opts.cluster !== null) { + postBody['cluster'] = opts.cluster + } + if (opts.containerName !== undefined && opts.containerName !== null) { + postBody['containerName'] = opts.containerName + } + if (opts.filePath !== undefined && opts.filePath !== null) { + postBody['filePath'] = opts.filePath + } + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.direction !== undefined && opts.direction !== null) { + postBody['direction'] = opts.direction + } + if (opts.limit !== undefined && opts.limit !== null) { + postBody['limit'] = opts.limit + } + if (opts.step !== undefined && opts.step !== null) { + postBody['step'] = opts.step + } + if (opts.streamFilter !== undefined && opts.streamFilter !== null) { + postBody['streamFilter'] = opts.streamFilter + } + if (opts.lineFilter !== undefined && opts.lineFilter !== null) { + postBody['lineFilter'] = opts.lineFilter + } + if (opts.fmtFilter !== undefined && opts.fmtFilter !== null) { + postBody['fmtFilter'] = opts.fmtFilter + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 logDetail 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( + '/logDetail', + '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.pin - 租户,必填 + * @param {string} opts.product - 产品,必填 + * @param {string} [opts.instance] - 实例 optional + * @param {string} [opts.logType] - 日志类型 optional + * @param {array} [opts.ip] - ip optional + * @param {array} [opts.podName] - pod name optional + * @param {string} [opts.namespace] - 命名空间 optional + * @param {string} [opts.cluster] - 集群 optional + * @param {string} [opts.containerName] - 容器名 optional + * @param {array} [opts.filePath] - 文件路径 optional + * @param {integer} [opts.startTime] - 开始时间纳秒数字,默认一小时前 optional + * @param {integer} [opts.endTime] - 结束时间纳秒数字,默认现在 optional + * @param {string} [opts.direction] - 正序:FORWARD、倒序:BACKWARD,默认BACKWARD optional + * @param {integer} [opts.limit] - 查询数量数字,默认100 optional + * @param {number} [opts.step] - 步长时间(单位:秒),10、0.5 optional + * @param {array} [opts.streamFilter] - label过滤 optional + * @param {lineFilter} [opts.lineFilter] - 行过滤 optional + * @param {formatFilter} [opts.fmtFilter] - 格式化过滤条件 optional + * @param {lokiMetricParam} [opts.metric] - 指标函数及参数 optional + * @param {string} [opts.queryType] - 检索类型枚举:range optional + * @param {string} [opts.duration] - 时间区间1s、1m、1h optional + * @param {string} [opts.groupBy] - 分组字段,逗号分隔 optional + * @param {string} callback - callback + @return {Object} result + * @param string status status + * @param boolean completed status + * @param lokiResponseData data data + */ + + logAggregate (opts, callback) { + opts = opts || {} + + if (opts.pin === undefined || opts.pin === null) { + throw new Error( + "Missing the required parameter 'opts.pin' when calling logAggregate" + ) + } + if (opts.product === undefined || opts.product === null) { + throw new Error( + "Missing the required parameter 'opts.product' when calling logAggregate" + ) + } + + let postBody = {} + if (opts.pin !== undefined && opts.pin !== null) { + postBody['pin'] = opts.pin + } + if (opts.product !== undefined && opts.product !== null) { + postBody['product'] = opts.product + } + if (opts.instance !== undefined && opts.instance !== null) { + postBody['instance'] = opts.instance + } + if (opts.logType !== undefined && opts.logType !== null) { + postBody['logType'] = opts.logType + } + if (opts.ip !== undefined && opts.ip !== null) { + postBody['ip'] = opts.ip + } + if (opts.podName !== undefined && opts.podName !== null) { + postBody['podName'] = opts.podName + } + if (opts.namespace !== undefined && opts.namespace !== null) { + postBody['namespace'] = opts.namespace + } + if (opts.cluster !== undefined && opts.cluster !== null) { + postBody['cluster'] = opts.cluster + } + if (opts.containerName !== undefined && opts.containerName !== null) { + postBody['containerName'] = opts.containerName + } + if (opts.filePath !== undefined && opts.filePath !== null) { + postBody['filePath'] = opts.filePath + } + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.direction !== undefined && opts.direction !== null) { + postBody['direction'] = opts.direction + } + if (opts.limit !== undefined && opts.limit !== null) { + postBody['limit'] = opts.limit + } + if (opts.step !== undefined && opts.step !== null) { + postBody['step'] = opts.step + } + if (opts.streamFilter !== undefined && opts.streamFilter !== null) { + postBody['streamFilter'] = opts.streamFilter + } + if (opts.lineFilter !== undefined && opts.lineFilter !== null) { + postBody['lineFilter'] = opts.lineFilter + } + if (opts.fmtFilter !== undefined && opts.fmtFilter !== null) { + postBody['fmtFilter'] = opts.fmtFilter + } + if (opts.metric !== undefined && opts.metric !== null) { + postBody['metric'] = opts.metric + } + if (opts.queryType !== undefined && opts.queryType !== null) { + postBody['queryType'] = opts.queryType + } + if (opts.duration !== undefined && opts.duration !== null) { + postBody['duration'] = opts.duration + } + if (opts.groupBy !== undefined && opts.groupBy !== null) { + postBody['groupBy'] = opts.groupBy + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 logAggregate 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( + '/logAggregate', + '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.pin - 租户,必填 + * @param {string} opts.product - 产品,必填 + * @param {string} [opts.instance] - 实例 optional + * @param {string} [opts.logType] - 日志类型 optional + * @param {array} [opts.ip] - ip optional + * @param {array} [opts.podName] - pod name optional + * @param {string} [opts.namespace] - 命名空间 optional + * @param {string} [opts.cluster] - 集群 optional + * @param {string} [opts.containerName] - 容器名 optional + * @param {array} [opts.filePath] - 文件路径 optional + * @param {integer} [opts.startTime] - 开始时间纳秒数字,默认一小时前 optional + * @param {integer} [opts.endTime] - 结束时间纳秒数字,默认现在 optional + * @param {string} [opts.direction] - 正序:FORWARD、倒序:BACKWARD,默认BACKWARD optional + * @param {integer} [opts.limit] - 查询数量数字,默认100 optional + * @param {number} [opts.step] - 步长时间(单位:秒),10、0.5 optional + * @param {array} [opts.streamFilter] - label过滤 optional + * @param {lineFilter} [opts.lineFilter] - 行过滤 optional + * @param {formatFilter} [opts.fmtFilter] - 格式化过滤条件 optional + * @param {lokiMetricParam} [opts.metric] - 指标函数及参数 optional + * @param {string} [opts.queryType] - 检索类型枚举:range optional + * @param {string} [opts.duration] - 时间区间1s、1m、1h optional + * @param {string} [opts.groupBy] - 分组字段,逗号分隔 optional + * @param {string} callback - callback + @return {Object} result + * @param string status status + * @param boolean completed status + * @param lokiResponseData data data + */ + + logCount (opts, callback) { + opts = opts || {} + + if (opts.pin === undefined || opts.pin === null) { + throw new Error( + "Missing the required parameter 'opts.pin' when calling logCount" + ) + } + if (opts.product === undefined || opts.product === null) { + throw new Error( + "Missing the required parameter 'opts.product' when calling logCount" + ) + } + + let postBody = {} + if (opts.pin !== undefined && opts.pin !== null) { + postBody['pin'] = opts.pin + } + if (opts.product !== undefined && opts.product !== null) { + postBody['product'] = opts.product + } + if (opts.instance !== undefined && opts.instance !== null) { + postBody['instance'] = opts.instance + } + if (opts.logType !== undefined && opts.logType !== null) { + postBody['logType'] = opts.logType + } + if (opts.ip !== undefined && opts.ip !== null) { + postBody['ip'] = opts.ip + } + if (opts.podName !== undefined && opts.podName !== null) { + postBody['podName'] = opts.podName + } + if (opts.namespace !== undefined && opts.namespace !== null) { + postBody['namespace'] = opts.namespace + } + if (opts.cluster !== undefined && opts.cluster !== null) { + postBody['cluster'] = opts.cluster + } + if (opts.containerName !== undefined && opts.containerName !== null) { + postBody['containerName'] = opts.containerName + } + if (opts.filePath !== undefined && opts.filePath !== null) { + postBody['filePath'] = opts.filePath + } + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.direction !== undefined && opts.direction !== null) { + postBody['direction'] = opts.direction + } + if (opts.limit !== undefined && opts.limit !== null) { + postBody['limit'] = opts.limit + } + if (opts.step !== undefined && opts.step !== null) { + postBody['step'] = opts.step + } + if (opts.streamFilter !== undefined && opts.streamFilter !== null) { + postBody['streamFilter'] = opts.streamFilter + } + if (opts.lineFilter !== undefined && opts.lineFilter !== null) { + postBody['lineFilter'] = opts.lineFilter + } + if (opts.fmtFilter !== undefined && opts.fmtFilter !== null) { + postBody['fmtFilter'] = opts.fmtFilter + } + if (opts.metric !== undefined && opts.metric !== null) { + postBody['metric'] = opts.metric + } + if (opts.queryType !== undefined && opts.queryType !== null) { + postBody['queryType'] = opts.queryType + } + if (opts.duration !== undefined && opts.duration !== null) { + postBody['duration'] = opts.duration + } + if (opts.groupBy !== undefined && opts.groupBy !== null) { + postBody['groupBy'] = opts.groupBy + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 logCount 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( + '/logCount', + '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) + } + ) + } + + /** + * 产品pod同步 + * @param {Object} opts - parameters + * @param {string} callback - callback + @return {Object} result + * @param boolean result 同步pod信息结,果true:成功;false:失败; + */ + + productPodChange (opts, callback) { + opts = opts || {} + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 productPodChange 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( + '/productPodChange', + '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) + } + ) + } + + /** + * 产品pod匹配同步 + * @param {Object} opts - parameters + * @param {string} [opts.operate] - 操作类型 optional + * @param {string} [opts.podInfo] - pod详情 optional + * @param {string} [opts.tenant] - 租户 optional + * @param {string} [opts.podListStr] - pod详情数组 optional + * @param {string} [opts.productName] - 产品名 optional + * @param {boolean} [opts.allTenantDistributability] - 是否所有租户可见 optional + * @param {string} callback - callback + @return {Object} result + * @param boolean result 配置下发结果true:成功;false:失败; + */ + + productPodLabelSelect (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.operate !== undefined && opts.operate !== null) { + postBody['operate'] = opts.operate + } + if (opts.podInfo !== undefined && opts.podInfo !== null) { + postBody['podInfo'] = opts.podInfo + } + if (opts.tenant !== undefined && opts.tenant !== null) { + postBody['tenant'] = opts.tenant + } + if (opts.podListStr !== undefined && opts.podListStr !== null) { + postBody['podListStr'] = opts.podListStr + } + if (opts.productName !== undefined && opts.productName !== null) { + postBody['productName'] = opts.productName + } + if ( + opts.allTenantDistributability !== undefined && + opts.allTenantDistributability !== null + ) { + postBody['allTenantDistributability'] = opts.allTenantDistributability + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 productPodLabelSelect 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( + '/productPodLabelSelect', + '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) + } + ) + } + + /** + * 自定义日志上报,该接口为PB格式,文档见 https://joyspace.jd.com/page/7CEjD5xK9Tvp6YvXvk5e + * @param {Object} opts - parameters + * @param {string} opts.logtopicUID - 日志主题uid + * @param {string} callback - callback + @return {Object} result + */ + + push (opts, callback) { + opts = opts || {} + + if (opts.logtopicUID === undefined || opts.logtopicUID === null) { + throw new Error( + "Missing the required parameter 'opts.logtopicUID' when calling push" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + logtopicUID: opts.logtopicUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 push 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( + '/logtopics/{logtopicUID}:push', + '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.logsetUID - 日志集ID + * @param {string} opts.logtopicUID - 日志主题ID + * @param {string} opts.action - "preview"表示预览, "fulltext"表示全文检索, "advance"表示按照搜索语句检索 + * @param {string} [opts.expr] - Base64编码的搜索表达式, optional + * @param {boolean} [opts.caseSensitive] - 搜索关键字大小写敏感, 默认false optional + * @param {string} [opts.startTime] - 开始时间。格式 “YYYY-MM-DDThh:mm:ssTZD”, 比如 “2018-11-09T15:34:46+0800”.当action != preview时,必填 optional + * @param {string} [opts.endTime] - 结束时间。格式 “YYYY-MM-DDThh:mm:ssTZD”, 比如 “2018-11-09T15:34:46+0800”.当action != preview时,必填 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer count 结果条数 + * @param object data + * @param string progress 任务进度 + * @param searchFields searchFields + * @param integer total 总数 + */ + + histograms (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 histograms" + ) + } + + opts = opts || {} + + if (opts.logsetUID === undefined || opts.logsetUID === null) { + throw new Error( + "Missing the required parameter 'opts.logsetUID' when calling histograms" + ) + } + if (opts.logtopicUID === undefined || opts.logtopicUID === null) { + throw new Error( + "Missing the required parameter 'opts.logtopicUID' when calling histograms" + ) + } + if (opts.action === undefined || opts.action === null) { + throw new Error( + "Missing the required parameter 'opts.action' when calling histograms" + ) + } + + let postBody = null + let queryParams = {} + if (opts.action !== undefined && opts.action !== null) { + queryParams['action'] = opts.action + } + if (opts.expr !== undefined && opts.expr !== null) { + queryParams['expr'] = opts.expr + } + if (opts.caseSensitive !== undefined && opts.caseSensitive !== null) { + queryParams['caseSensitive'] = opts.caseSensitive + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: regionId, + logsetUID: opts.logsetUID, + logtopicUID: opts.logtopicUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 histograms 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}/logsets/{logsetUID}/logtopics/{logtopicUID}/histograms', + '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.logsetUID - 日志集ID + * @param {string} opts.logtopicUID - 日志主题ID + * @param {string} [opts.taskID] - 扫描任务ID。 第一次调用传入空值即可。后续调用需传入该任务ID,以连续读取剩余日志。 optional + * @param {string} [opts.expr] - Base64编码的搜索表达式, optional + * @param {string} [opts.startTime] - 开始时间。格式 “YYYY-MM-DDThh:mm:ssTZD”, 比如 “2018-11-09T15:34:46+0800”.必填 optional + * @param {string} [opts.endTime] - 结束时间。格式 “YYYY-MM-DDThh:mm:ssTZD”, 比如 “2018-11-09T15:34:46+0800”.必填 optional + * @param {string} [opts.sort] - 返回排序,不填或者为空,默认为desc,"asc":按照时间正序返回结果,"desc":按照时间倒序返回结果 optional + * @param {filter} [opts.filters] - 指定返回字段,只对系统日志生效,不填默认按照产品线配置返回字段,Name支持:key,Values填入返回字段 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param object data + * @param searchFields searchFields + * @param string taskID 任务ID + * @param string taskStatus 任务状态, 为Complete 时,表示结束 + * @param integer total 总数 + */ + + getLogs (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 getLogs" + ) + } + + opts = opts || {} + + if (opts.logsetUID === undefined || opts.logsetUID === null) { + throw new Error( + "Missing the required parameter 'opts.logsetUID' when calling getLogs" + ) + } + if (opts.logtopicUID === undefined || opts.logtopicUID === null) { + throw new Error( + "Missing the required parameter 'opts.logtopicUID' when calling getLogs" + ) + } + + let postBody = null + let queryParams = {} + if (opts.taskID !== undefined && opts.taskID !== null) { + queryParams['taskID'] = opts.taskID + } + if (opts.expr !== undefined && opts.expr !== null) { + queryParams['expr'] = opts.expr + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.sort !== undefined && opts.sort !== null) { + queryParams['sort'] = opts.sort + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId, + logsetUID: opts.logsetUID, + logtopicUID: opts.logtopicUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 getLogs 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}/logsets/{logsetUID}/logtopics/{logtopicUID}/scan', + '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.logsetUID - 日志集ID + * @param {string} opts.logtopicUID - 日志主题ID + * @param {string} opts.action - "preview"表示预览, "fulltext"表示全文检索, "advance"表示按照搜索语句检索 + * @param {string} [opts.expr] - Base64编码的搜索表达式, optional + * @param {boolean} [opts.caseSensitive] - 搜索关键字大小写敏感, 默认false optional + * @param {string} [opts.startTime] - 开始时间。格式 “YYYY-MM-DDThh:mm:ssTZD”, 比如 “2018-11-09T15:34:46+0800”.当action != preview时,必填 optional + * @param {string} [opts.endTime] - 结束时间。格式 “YYYY-MM-DDThh:mm:ssTZD”, 比如 “2018-11-09T15:34:46+0800”.当action != preview时,必填 optional + * @param {integer} [opts.pageNumber] - 页数。 最小为1,最大为99 optional + * @param {integer} [opts.pageSize] - 每页个数。默认为10,最大100 optional + * @param {string} [opts.sort] - 返回排序,不填或者为空,默认为desc,"asc":按照时间正序返回结果,"desc":按照时间倒序返回结果 optional + * @param {filter} [opts.filters] - 指定返回字段,只对系统日志生效,不填默认按照产品线配置返回字段,Name支持:key,Values填入返回字段 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param object data + * @param searchFields searchFields + * @param integer total 总数 + */ + + search (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 search" + ) + } + + opts = opts || {} + + if (opts.logsetUID === undefined || opts.logsetUID === null) { + throw new Error( + "Missing the required parameter 'opts.logsetUID' when calling search" + ) + } + if (opts.logtopicUID === undefined || opts.logtopicUID === null) { + throw new Error( + "Missing the required parameter 'opts.logtopicUID' when calling search" + ) + } + if (opts.action === undefined || opts.action === null) { + throw new Error( + "Missing the required parameter 'opts.action' when calling search" + ) + } + + let postBody = null + let queryParams = {} + if (opts.action !== undefined && opts.action !== null) { + queryParams['action'] = opts.action + } + if (opts.expr !== undefined && opts.expr !== null) { + queryParams['expr'] = opts.expr + } + if (opts.caseSensitive !== undefined && opts.caseSensitive !== null) { + queryParams['caseSensitive'] = opts.caseSensitive + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + queryParams['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.sort !== undefined && opts.sort !== null) { + queryParams['sort'] = opts.sort + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId, + logsetUID: opts.logsetUID, + logtopicUID: opts.logtopicUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 search 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}/logsets/{logsetUID}/logtopics/{logtopicUID}/search', + '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.logsetUID - 日志集 UID + * @param {string} opts.logtopicUID - 日志主题 UID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string createdTime + * @param string kafkaBroker kafka接入点 + * @param string kafkaPassword kafka 用户密码 + * @param string kafkaTopic kafka Topic + * @param string kafkaUsername kafka 用户名 + * @param string logtopicId 日志主体 + * @param string pin 用户pin + * @param integer status 日志订阅状态,0表示未创建,1表示已创建,2表示开启,3表示关闭 + * @param string updatedTime + */ + + describeSubscribe (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 describeSubscribe" + ) + } + + opts = opts || {} + + if (opts.logsetUID === undefined || opts.logsetUID === null) { + throw new Error( + "Missing the required parameter 'opts.logsetUID' when calling describeSubscribe" + ) + } + if (opts.logtopicUID === undefined || opts.logtopicUID === null) { + throw new Error( + "Missing the required parameter 'opts.logtopicUID' when calling describeSubscribe" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + logsetUID: opts.logsetUID, + logtopicUID: opts.logtopicUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 describeSubscribe 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}/logsets/{logsetUID}/logtopics/{logtopicUID}/subscribe', + '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.logsetUID - 日志集 UID + * @param {string} opts.logtopicUID - 日志主题 UID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + createSubscribe (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 createSubscribe" + ) + } + + opts = opts || {} + + if (opts.logsetUID === undefined || opts.logsetUID === null) { + throw new Error( + "Missing the required parameter 'opts.logsetUID' when calling createSubscribe" + ) + } + if (opts.logtopicUID === undefined || opts.logtopicUID === null) { + throw new Error( + "Missing the required parameter 'opts.logtopicUID' when calling createSubscribe" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + logsetUID: opts.logsetUID, + logtopicUID: opts.logtopicUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 createSubscribe 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}/logsets/{logsetUID}/logtopics/{logtopicUID}/subscribe', + '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.logsetUID - 日志集 UID + * @param {string} opts.logtopicUID - 日志主题 UID + * @param {integer} [opts.status] - 日志订阅状态,0表示未创建,1表示刚创建,2表示开启,3表示关闭 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateSubscribe (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 updateSubscribe" + ) + } + + opts = opts || {} + + if (opts.logsetUID === undefined || opts.logsetUID === null) { + throw new Error( + "Missing the required parameter 'opts.logsetUID' when calling updateSubscribe" + ) + } + if (opts.logtopicUID === undefined || opts.logtopicUID === null) { + throw new Error( + "Missing the required parameter 'opts.logtopicUID' when calling updateSubscribe" + ) + } + + let postBody = {} + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + logsetUID: opts.logsetUID, + logtopicUID: opts.logtopicUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 logs/2.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 updateSubscribe 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}/logsets/{logsetUID}/logtopics/{logtopicUID}/subscribe', + 'PATCH', + 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 = LOGS diff --git a/packages/libs/lib-jdcloud/src/repo/mongodb/v1/mongodb.js b/packages/libs/lib-jdcloud/src/repo/mongodb/v1/mongodb.js new file mode 100644 index 000000000..5488584dc --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/mongodb/v1/mongodb.js @@ -0,0 +1,2898 @@ +/* + * 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. + * + * 安全管理 + * API related to MONGODB security + * + * 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 = 'mongodb' +Service._services[serviceId] = true + +/** + * mongodb service. + * @version 1.1.9 + */ + +JDCloud.MONGODB = class MONGODB extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'mongodb.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询实例信息 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1,取值范围:[1,∞) optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[1, 100] optional + * @param {filter} [opts.filters] - instanceId - 实例ID, 精确匹配 +instanceName - 实例名称, 模糊匹配 +instanceStatus - mongodb状态,精确匹配,支持多个.RUNNING:运行, ERROR:错误 ,BUILDING:创建中, DELETING:删除中, RESTORING:恢复中, RESIZING:变配中 +chargeMode - 计费类型,精确匹配 + optional + * @param {tagFilter} [opts.tagFilters] - Tag筛选条件 optional + * @param {sort} [opts.sorts] - createTime - 创建时间,asc(正序),desc(倒序) + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dBInstance dbInstances + * @param integer totalCount + * @param integer pageNumber + */ + + 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 + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + Object.assign( + queryParams, + super.buildTagFilterParam(opts.tagFilters, 'tagFilters') + ) + Object.assign(queryParams, super.buildSortParam(opts.sorts, 'sorts')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mongodb/1.1.9' + } + + 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}/instances', + '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 {dBInstanceSpec} opts.instanceSpec - 实例规格 + * @param {chargeSpec} [opts.chargeSpec] - 付费方式 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string instanceId + * @param string orderId + */ + + createInstance (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 createInstance" + ) + } + + opts = opts || {} + + if (opts.instanceSpec === undefined || opts.instanceSpec === null) { + throw new Error( + "Missing the required parameter 'opts.instanceSpec' when calling createInstance" + ) + } + + let postBody = {} + if (opts.instanceSpec !== undefined && opts.instanceSpec !== null) { + postBody['instanceSpec'] = opts.instanceSpec + } + if (opts.chargeSpec !== undefined && opts.chargeSpec !== null) { + postBody['chargeSpec'] = opts.chargeSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mongodb/1.1.9' + } + + 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 createInstance 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}/instances', + '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 - Instance ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + 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 || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteInstance" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mongodb/1.1.9' + } + + 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}/instances/{instanceId}', + '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.instanceId - Instance ID + * @param {} opts.accountPassword - 新密码,必须包含且只支持字母及数字,不少于8字符不超过16字符。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + resetPassword (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 resetPassword" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling resetPassword" + ) + } + if (opts.accountPassword === undefined || opts.accountPassword === null) { + throw new Error( + "Missing the required parameter 'opts.accountPassword' when calling resetPassword" + ) + } + + let postBody = {} + 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 mongodb/1.1.9' + } + + 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 resetPassword 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}/instances/{instanceId}:resetPassword', + '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 - Instance ID + * @param {} opts.instanceClass - 实例规格,包年包月不允许小于当前规格。 + * @param {} opts.instanceStorageGB - 存储空间,包年包月不允许小于当前规格。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string instanceId + * @param string orderId + */ + + 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.instanceClass === undefined || opts.instanceClass === null) { + throw new Error( + "Missing the required parameter 'opts.instanceClass' when calling modifyInstanceSpec" + ) + } + if ( + opts.instanceStorageGB === undefined || + opts.instanceStorageGB === null + ) { + throw new Error( + "Missing the required parameter 'opts.instanceStorageGB' when calling modifyInstanceSpec" + ) + } + + let postBody = {} + if (opts.instanceClass !== undefined && opts.instanceClass !== null) { + postBody['instanceClass'] = opts.instanceClass + } + if ( + opts.instanceStorageGB !== undefined && + opts.instanceStorageGB !== null + ) { + postBody['instanceStorageGB'] = opts.instanceStorageGB + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mongodb/1.1.9' + } + + 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}/instances/{instanceId}: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.instanceId - Instance ID + * @param {} opts.instanceName - 新的实例名称,只支持数字、字母、英文下划线、中文,且不少于2字符不超过32字符。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyInstanceName (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 modifyInstanceName" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyInstanceName" + ) + } + if (opts.instanceName === undefined || opts.instanceName === null) { + throw new Error( + "Missing the required parameter 'opts.instanceName' when calling modifyInstanceName" + ) + } + + let postBody = {} + if (opts.instanceName !== undefined && opts.instanceName !== null) { + postBody['instanceName'] = opts.instanceName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mongodb/1.1.9' + } + + 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 modifyInstanceName 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}/instances/{instanceId}:modifyInstanceName', + '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 - Instance ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string preferredBackupPeriod + * @param string preferredBackupWindow + * @param string backupRetentionPeriod + */ + + describeBackupPolicy (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 describeBackupPolicy" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeBackupPolicy" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mongodb/1.1.9' + } + + 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 describeBackupPolicy 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}/instances/{instanceId}/backupPolicy', + '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 - Instance ID + * @param {} opts.preferredBackupTime - 备份时间,格式:HH:mmZ- HH:mmZ,只允许间隔时间为1小时的整点. + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string preferredBackupPeriod + * @param string preferredBackupWindow + * @param string backupRetentionPeriod + */ + + modifyBackupPolicy (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 modifyBackupPolicy" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyBackupPolicy" + ) + } + if ( + opts.preferredBackupTime === undefined || + opts.preferredBackupTime === null + ) { + throw new Error( + "Missing the required parameter 'opts.preferredBackupTime' when calling modifyBackupPolicy" + ) + } + + let postBody = {} + if ( + opts.preferredBackupTime !== undefined && + opts.preferredBackupTime !== null + ) { + postBody['preferredBackupTime'] = opts.preferredBackupTime + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mongodb/1.1.9' + } + + 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 modifyBackupPolicy 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}/instances/{instanceId}/backupPolicy', + '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 - Instance ID + * @param {} opts.backupId - 备份ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + restoreInstance (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 restoreInstance" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling restoreInstance" + ) + } + if (opts.backupId === undefined || opts.backupId === null) { + throw new Error( + "Missing the required parameter 'opts.backupId' when calling restoreInstance" + ) + } + + let postBody = {} + if (opts.backupId !== undefined && opts.backupId !== null) { + postBody['backupId'] = opts.backupId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mongodb/1.1.9' + } + + 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 restoreInstance 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}/instances/{instanceId}/restoreInstance', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param flavor flavors + */ + + describeFlavors (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 describeFlavors" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mongodb/1.1.9' + } + + 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 describeFlavors 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}/flavors', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param availableZones availableZones + */ + + describeAvailableZones (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 describeAvailableZones" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mongodb/1.1.9' + } + + 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 describeAvailableZones 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}/availableZones', + '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 - Instance ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string instanceId + */ + + restartInstance (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 restartInstance" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling restartInstance" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mongodb/1.1.9' + } + + 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 restartInstance 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}/instances/{instanceId}:restartInstance', + '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 {shardingDBInstanceSpec} opts.shardingInstanceSpec - 实例规格 + * @param {chargeSpec} [opts.chargeSpec] - 付费方式 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string instanceId + * @param string orderId + */ + + createShardingInstance (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 createShardingInstance" + ) + } + + opts = opts || {} + + if ( + opts.shardingInstanceSpec === undefined || + opts.shardingInstanceSpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.shardingInstanceSpec' when calling createShardingInstance" + ) + } + + let postBody = {} + if ( + opts.shardingInstanceSpec !== undefined && + opts.shardingInstanceSpec !== null + ) { + postBody['shardingInstanceSpec'] = opts.shardingInstanceSpec + } + if (opts.chargeSpec !== undefined && opts.chargeSpec !== null) { + postBody['chargeSpec'] = opts.chargeSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mongodb/1.1.9' + } + + 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 createShardingInstance 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}/shardingInstances', + '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) + } + ) + } + + /** + * 变更分片集群的节点规格,支持Mognos、Shard节点。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - Instance ID + * @param {string} opts.nodeId - Node ID + * @param {} opts.nodeType - Shard节点或Mongos节点的规格,不允许小于当前规格。 + * @param {} [opts.nodeStorageGB] - Shard存储空间,当前节点为Shard时可用,不允许小于当前规格。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string nodeId + */ + + modifyNodeSpec (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 modifyNodeSpec" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyNodeSpec" + ) + } + if (opts.nodeId === undefined || opts.nodeId === null) { + throw new Error( + "Missing the required parameter 'opts.nodeId' when calling modifyNodeSpec" + ) + } + if (opts.nodeType === undefined || opts.nodeType === null) { + throw new Error( + "Missing the required parameter 'opts.nodeType' when calling modifyNodeSpec" + ) + } + + let postBody = {} + if (opts.nodeType !== undefined && opts.nodeType !== null) { + postBody['nodeType'] = opts.nodeType + } + if (opts.nodeStorageGB !== undefined && opts.nodeStorageGB !== null) { + postBody['nodeStorageGB'] = opts.nodeStorageGB + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + nodeId: opts.nodeId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mongodb/1.1.9' + } + + 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 modifyNodeSpec 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}/instances/{instanceId}/nodes/{nodeId}:modifyNodeSpec', + '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) + } + ) + } + + /** + * 重启MongoDB分片集群节点,支持重启Mongos、Shard。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - Instance ID + * @param {string} opts.nodeId - Node ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string nodeId + */ + + restartNode (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 restartNode" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling restartNode" + ) + } + if (opts.nodeId === undefined || opts.nodeId === null) { + throw new Error( + "Missing the required parameter 'opts.nodeId' when calling restartNode" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + nodeId: opts.nodeId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mongodb/1.1.9' + } + + 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 restartNode 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}/instances/{instanceId}/nodes/{nodeId}:restartNode', + '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.pageNumber] - 页码;默认为1,取值范围:[1,∞) optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[1, 100] optional + * @param {filter} [opts.filters] - instanceId - 实例ID, 精确匹配 +backupId - 备份ID, 精确匹配 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param backup backups + * @param integer totalCount + * @param integer pageNumber + */ + + describeBackups (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 describeBackups" + ) + } + + 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 mongodb/1.1.9' + } + + 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 describeBackups 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}/backups', + '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 {} opts.instanceId - 实例ID + * @param {} [opts.backupName] - 备份名称 optional + * @param {} [opts.backupMethod] - 备份方式,Logical - 逻辑备份、Physical - 物理备份 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string backupId + */ + + createBackup (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 createBackup" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createBackup" + ) + } + + let postBody = {} + if (opts.instanceId !== undefined && opts.instanceId !== null) { + postBody['instanceId'] = opts.instanceId + } + if (opts.backupName !== undefined && opts.backupName !== null) { + postBody['backupName'] = opts.backupName + } + if (opts.backupMethod !== undefined && opts.backupMethod !== null) { + postBody['backupMethod'] = opts.backupMethod + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mongodb/1.1.9' + } + + 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 createBackup 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}/backups', + '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.backupId - backup ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteBackup (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 deleteBackup" + ) + } + + opts = opts || {} + + if (opts.backupId === undefined || opts.backupId === null) { + throw new Error( + "Missing the required parameter 'opts.backupId' when calling deleteBackup" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + backupId: opts.backupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mongodb/1.1.9' + } + + 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 deleteBackup 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}/backups/{backupId}', + '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.backupId - backup ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param backupDownloadURL backupDownloadURL + */ + + backupDownloadURL (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 backupDownloadURL" + ) + } + + opts = opts || {} + + if (opts.backupId === undefined || opts.backupId === null) { + throw new Error( + "Missing the required parameter 'opts.backupId' when calling backupDownloadURL" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + backupId: opts.backupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mongodb/1.1.9' + } + + 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 backupDownloadURL 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}/backups/{backupId}/downloadURL', + '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] - 分页大小;默认为10;取值范围[1, 100] optional + * @param {filter} [opts.filters] - null optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param backupSynchronicity backupSynchronicities + * @param integer totalCount + * @param integer pageNumber + */ + + describeBackupSynchronicities ( + 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 describeBackupSynchronicities" + ) + } + + 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 mongodb/1.1.9' + } + + 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 describeBackupSynchronicities 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}/backupSynchronicities', + '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 {} opts.instanceId - 源实例ID + * @param {} opts.srcRegion - 源实例所在地域 + * @param {} opts.dstRegion - 备份同步的目标地域 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string serviceId + */ + + createBackupSynchronicity (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 createBackupSynchronicity" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createBackupSynchronicity" + ) + } + if (opts.srcRegion === undefined || opts.srcRegion === null) { + throw new Error( + "Missing the required parameter 'opts.srcRegion' when calling createBackupSynchronicity" + ) + } + if (opts.dstRegion === undefined || opts.dstRegion === null) { + throw new Error( + "Missing the required parameter 'opts.dstRegion' when calling createBackupSynchronicity" + ) + } + + let postBody = {} + if (opts.instanceId !== undefined && opts.instanceId !== null) { + postBody['instanceId'] = opts.instanceId + } + if (opts.srcRegion !== undefined && opts.srcRegion !== null) { + postBody['srcRegion'] = opts.srcRegion + } + if (opts.dstRegion !== undefined && opts.dstRegion !== null) { + postBody['dstRegion'] = opts.dstRegion + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mongodb/1.1.9' + } + + 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 createBackupSynchronicity 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}/backupSynchronicities', + '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.serviceId - service ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string serviceId + */ + + deleteBackupSynchronicities (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 deleteBackupSynchronicities" + ) + } + + opts = opts || {} + + if (opts.serviceId === undefined || opts.serviceId === null) { + throw new Error( + "Missing the required parameter 'opts.serviceId' when calling deleteBackupSynchronicities" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + serviceId: opts.serviceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mongodb/1.1.9' + } + + 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 deleteBackupSynchronicities 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}/backupSynchronicities/{serviceId}', + '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.instanceId - Instance ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string securityIps + */ + + describeSecurityIps (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 describeSecurityIps" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeSecurityIps" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mongodb/1.1.9' + } + + 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 describeSecurityIps 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}/instances/{instanceId}/securityIps', + '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 - Instance ID + * @param {} opts.modifyMode - 修改方式,Add 增加白名单,Delete 删除白名单. + * @param {} opts.securityIps - IP白名单分组下的IP列表,最多45个以逗号隔开,格式如下:0.0.0.0/0,10.23.12.24(IP),或者10.23.12.24/24(CIDR模式,无类域间路由,/24表示了地址中前缀的长度,范围[1,32])。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifySecurityIps (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 modifySecurityIps" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifySecurityIps" + ) + } + if (opts.modifyMode === undefined || opts.modifyMode === null) { + throw new Error( + "Missing the required parameter 'opts.modifyMode' when calling modifySecurityIps" + ) + } + if (opts.securityIps === undefined || opts.securityIps === null) { + throw new Error( + "Missing the required parameter 'opts.securityIps' when calling modifySecurityIps" + ) + } + + let postBody = {} + if (opts.modifyMode !== undefined && opts.modifyMode !== null) { + postBody['modifyMode'] = opts.modifyMode + } + if (opts.securityIps !== undefined && opts.securityIps !== null) { + postBody['securityIps'] = opts.securityIps + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mongodb/1.1.9' + } + + 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 modifySecurityIps 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}/instances/{instanceId}/securityIps', + '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 = JDCloud.MONGODB diff --git a/packages/libs/lib-jdcloud/src/repo/monitor/v1/monitor.js b/packages/libs/lib-jdcloud/src/repo/monitor/v1/monitor.js new file mode 100644 index 000000000..fe0e35d07 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/monitor/v1/monitor.js @@ -0,0 +1,2191 @@ +/* + * 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. + * + * Statistics APIs + * 资源统计相关接口 + * + * 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 = 'monitor' +Service._services[serviceId] = true + +/** + * monitor service. + * @version 1.3.9 + */ + +JDCloud.MONITOR = class MONITOR extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'monitor.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询报警历史 +检索条件组合优先级从高到低为 +1:alarmIds不为空 +2:alarmId不为空 +3:serviceCode不为空 +3.1:serviceCode + resourceId +3.2: serviceCode + resourceIds +3.3: serviceCode + ruleName +4:serviceCodes不为空 +4.1:serviceCode + resourceId +4.2: serviceCode + resourceIds +4.3: serviceCode + ruleName +5: 所有规则 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 当前所在页,默认为1 optional + * @param {integer} [opts.pageSize] - 页面大小,默认为20;取值范围[1, 100] optional + * @param {string} [opts.serviceCode] - 产品线标识,默认返回该serviceCode下所有group的数据。eg:serviceCode=jdw(jdw产品线下包含jdw-master与jdw-segment两个分组)会返回jdw-master和jdw-segment的数据。 optional + * @param {string} [opts.groupCode] - 分组标识、指定该参数时,查询只返回该group的数据。groupCode参数仅在与serviceCode匹配时生效;eg:serviceCode=jdw、groupCode=jdw-master,只返回jdw-master分组的数据,不返回jdw-segment的数据。 optional + * @param {string} [opts.resourceId] - 资源Id optional + * @param {string} [opts.alarmId] - 规则Id optional + * @param {integer} [opts.alarming] - 正在报警, 取值为1 optional + * @param {string} [opts.startTime] - 开始时间 optional + * @param {string} [opts.endTime] - 结束时间 optional + * @param {integer} [opts.ruleType] - 规则类型,默认查询1, 1表示资源监控,6表示站点监控,7表示可用性监控 optional + * @param {filter} [opts.filters] - serviceCodes - 产品线servicecode,精确匹配,支持多个 +resourceIds - 资源Id,精确匹配,支持多个(必须指定serviceCode才会在该serviceCode下根据resourceIds过滤,否则该参数不生效) +alarmIds - 规则Id,精确匹配,支持多个 +ruleName - 规则名称,模糊匹配,支持单个 optional + * @param {string} [opts.resourceIdList] - resourceId列表,必须指定serviceCode才会生效 optional + * @param {string} [opts.serviceCodeList] - 产品线列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param describedAlarmHistory alarmHistoryList + * @param integer total 总数 + */ + + describeAlarmHistory (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 describeAlarmHistory" + ) + } + + 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.serviceCode !== undefined && opts.serviceCode !== null) { + queryParams['serviceCode'] = opts.serviceCode + } + if (opts.groupCode !== undefined && opts.groupCode !== null) { + queryParams['groupCode'] = opts.groupCode + } + if (opts.resourceId !== undefined && opts.resourceId !== null) { + queryParams['resourceId'] = opts.resourceId + } + if (opts.alarmId !== undefined && opts.alarmId !== null) { + queryParams['alarmId'] = opts.alarmId + } + if (opts.alarming !== undefined && opts.alarming !== null) { + queryParams['alarming'] = opts.alarming + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.ruleType !== undefined && opts.ruleType !== null) { + queryParams['ruleType'] = opts.ruleType + } + Object.assign(queryParams, this.buildFilterParam(opts.filters, 'filters')) + Object.assign( + queryParams, + this.buildArrayParam(opts.resourceIdList, 'resourceIdList') + ) + Object.assign( + queryParams, + this.buildArrayParam(opts.serviceCodeList, 'serviceCodeList') + ) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/1.3.9' + } + + 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 describeAlarmHistory 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 = this.makeRequest( + '/regions/{regionId}/alarmHistory', + '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) + } + ) + } + + /** + * 查询规则, 查询参数组合及优先级从高到低为: +1:alarmIds不为空 +2:alarmId不为空 +3:serviceCode不为空 +3.1:serviceCode + resourceId +3.2: serviceCode + resourceIds +3.3: serviceCode + ruleName +4:serviceCodes不为空 +4.1:serviceCode + resourceId +4.2: serviceCode + resourceIds +4.3: serviceCode + ruleName +5: 所有规则 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 当前所在页,默认为1 optional + * @param {integer} [opts.pageSize] - 页面大小,默认为20;取值范围[1, 100] optional + * @param {string} [opts.serviceCode] - 产品线标识,默认返回该serviceCode下所有group的数据。eg:serviceCode=jdw(jdw产品线下包含jdw-master与jdw-segment两个分组)会返回jdw-master和jdw-segment的数据。 optional + * @param {string} [opts.groupCode] - 分组标识、指定该参数时,查询只返回该group的数据。groupCode参数仅在与serviceCode匹配时生效;eg:serviceCode=jdw、groupCode=jdw-master,只返回jdw-master分组的数据,不返回jdw-segment的数据。 optional + * @param {string} [opts.resourceId] - 资源ID,根据resourceId查询时必须指定serviceCode才会生效 optional + * @param {integer} [opts.ruleType] - 规则类型, 1表示资源监控,6表示站点监控,7表示可用性监控 optional + * @param {integer} [opts.status] - 规则报警状态, 1:正常, 2:报警,4:数据不足 optional + * @param {integer} [opts.enabled] - 规则状态:1为启用,0为禁用 optional + * @param {integer} [opts.isAlarming] - 是否为正在报警的规则,0为忽略,1为是,与 status 同时只能生效一个,isAlarming 优先生效 optional + * @param {string} [opts.alarmId] - 规则的id,若指定filter的alarmIds过滤时,忽略该参数 optional + * @param {filter} [opts.filters] - 服务码或资源Id列表 +serviceCodes - 产品线servicecode,精确匹配,支持多个 +resourceIds - 资源Id,精确匹配,支持多个(必须指定serviceCode才会在该serviceCode下根据resourceIds过滤,否则该参数不生效) +alarmIds - 规则id,精确匹配,支持多个 +ruleName - 规则名称,模糊匹配,支持单个 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param describedAlarm alarmList + * @param integer total 规则总数 + */ + + describeAlarms (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 describeAlarms" + ) + } + + 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.serviceCode !== undefined && opts.serviceCode !== null) { + queryParams['serviceCode'] = opts.serviceCode + } + if (opts.groupCode !== undefined && opts.groupCode !== null) { + queryParams['groupCode'] = opts.groupCode + } + if (opts.resourceId !== undefined && opts.resourceId !== null) { + queryParams['resourceId'] = opts.resourceId + } + if (opts.ruleType !== undefined && opts.ruleType !== null) { + queryParams['ruleType'] = opts.ruleType + } + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + if (opts.enabled !== undefined && opts.enabled !== null) { + queryParams['enabled'] = opts.enabled + } + if (opts.isAlarming !== undefined && opts.isAlarming !== null) { + queryParams['isAlarming'] = opts.isAlarming + } + if (opts.alarmId !== undefined && opts.alarmId !== null) { + queryParams['alarmId'] = opts.alarmId + } + Object.assign(queryParams, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/1.3.9' + } + + 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 describeAlarms 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 = this.makeRequest( + '/regions/{regionId}/alarms', + '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位,若两个请求clientToken相等,则返回第一次创建的规则id,只创建一次规则 + * @param {createAlarmParam} opts.createAlarmSpec + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string alarmIdList + */ + + createAlarm (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 createAlarm" + ) + } + + opts = opts || {} + + if (opts.clientToken === undefined || opts.clientToken === null) { + throw new Error( + "Missing the required parameter 'opts.clientToken' when calling createAlarm" + ) + } + if (opts.createAlarmSpec === undefined || opts.createAlarmSpec === null) { + throw new Error( + "Missing the required parameter 'opts.createAlarmSpec' when calling createAlarm" + ) + } + + let postBody = {} + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.createAlarmSpec !== undefined && opts.createAlarmSpec !== null) { + postBody['createAlarmSpec'] = opts.createAlarmSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/1.3.9' + } + + 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 createAlarm 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 = this.makeRequest( + '/regions/{regionId}/alarms', + '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.ids - 待删除的规则id,用逗号,分隔 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteAlarms (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 deleteAlarms" + ) + } + + opts = opts || {} + + if (opts.ids === undefined || opts.ids === null) { + throw new Error( + "Missing the required parameter 'opts.ids' when calling deleteAlarms" + ) + } + + let postBody = null + let queryParams = {} + if (opts.ids !== undefined && opts.ids !== null) { + queryParams['ids'] = opts.ids + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/1.3.9' + } + + 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 deleteAlarms 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 = this.makeRequest( + '/regions/{regionId}/alarms', + '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.alarmId - 规则id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param alarm alarm + */ + + describeAlarmsByID (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 describeAlarmsByID" + ) + } + + opts = opts || {} + + if (opts.alarmId === undefined || opts.alarmId === null) { + throw new Error( + "Missing the required parameter 'opts.alarmId' when calling describeAlarmsByID" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + alarmId: opts.alarmId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/1.3.9' + } + + 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 describeAlarmsByID 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 = this.makeRequest( + '/regions/{regionId}/alarms/{alarmId}', + '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.alarmId - 规则id + * @param {array} [opts.contacts] - 通知联系人 optional + * @param {baseRule} opts.rule + * @param {string} [opts.webHookContent] - 回调content 注:仅webHookUrl和webHookContent均不为空时,才会创建webHook optional + * @param {string} [opts.webHookProtocol] - webHook协议,目前支持http,https optional + * @param {string} [opts.webHookSecret] - 回调secret,用户请求签名,防伪造 optional + * @param {string} [opts.webHookUrl] - 回调url,例如http://www.jdcloud.com optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateAlarm (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 updateAlarm" + ) + } + + opts = opts || {} + + if (opts.alarmId === undefined || opts.alarmId === null) { + throw new Error( + "Missing the required parameter 'opts.alarmId' when calling updateAlarm" + ) + } + if (opts.rule === undefined || opts.rule === null) { + throw new Error( + "Missing the required parameter 'opts.rule' when calling updateAlarm" + ) + } + + let postBody = {} + if (opts.contacts !== undefined && opts.contacts !== null) { + postBody['contacts'] = opts.contacts + } + if (opts.rule !== undefined && opts.rule !== null) { + postBody['rule'] = opts.rule + } + if (opts.webHookContent !== undefined && opts.webHookContent !== null) { + postBody['webHookContent'] = opts.webHookContent + } + if (opts.webHookProtocol !== undefined && opts.webHookProtocol !== null) { + postBody['webHookProtocol'] = opts.webHookProtocol + } + if (opts.webHookSecret !== undefined && opts.webHookSecret !== null) { + postBody['webHookSecret'] = opts.webHookSecret + } + if (opts.webHookUrl !== undefined && opts.webHookUrl !== null) { + postBody['webHookUrl'] = opts.webHookUrl + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + alarmId: opts.alarmId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/1.3.9' + } + + 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 updateAlarm 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 = this.makeRequest( + '/regions/{regionId}/alarms/{alarmId}', + 'PATCH', + 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.alarmId - 规则id + * @param {integer} [opts.pageNumber] - 当前所在页,默认为1 optional + * @param {integer} [opts.pageSize] - 页面大小,默认为20;取值范围[1, 100] optional + * @param {integer} [opts.referenceType] - 联系人类型。0,联系人分组; 1,联系人 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param describedNoticeContacts contactsList + * @param integer total 报警联系人总数 + */ + + describeAlarmContacts (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 describeAlarmContacts" + ) + } + + opts = opts || {} + + if (opts.alarmId === undefined || opts.alarmId === null) { + throw new Error( + "Missing the required parameter 'opts.alarmId' when calling describeAlarmContacts" + ) + } + + 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.referenceType !== undefined && opts.referenceType !== null) { + queryParams['referenceType'] = opts.referenceType + } + + let pathParams = { + regionId: regionId, + alarmId: opts.alarmId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/1.3.9' + } + + 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 describeAlarmContacts 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 = this.makeRequest( + '/regions/{regionId}/alarms/{alarmId}/contacts', + '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.alarmId - 规则 id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + disableAlarm (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 disableAlarm" + ) + } + + opts = opts || {} + + if (opts.alarmId === undefined || opts.alarmId === null) { + throw new Error( + "Missing the required parameter 'opts.alarmId' when calling disableAlarm" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + alarmId: opts.alarmId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/1.3.9' + } + + 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 disableAlarm 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 = this.makeRequest( + '/regions/{regionId}/alarms/{alarmId}/disable', + '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.alarmId - 规则id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + enableAlarm (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 enableAlarm" + ) + } + + opts = opts || {} + + if (opts.alarmId === undefined || opts.alarmId === null) { + throw new Error( + "Missing the required parameter 'opts.alarmId' when calling enableAlarm" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + alarmId: opts.alarmId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/1.3.9' + } + + 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 enableAlarm 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 = this.makeRequest( + '/regions/{regionId}/alarms/{alarmId}/enable', + '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) + } + ) + } + + /** + * 查询报警历史 +检索条件组合优先级从高到低为 +1:alarmIds不为空 +2:alarmId不为空 +3:serviceCode不为空 +3.1:serviceCode + resourceId +3.2: serviceCode + resourceIds +3.3: serviceCode + ruleName +4:serviceCodes不为空 +4.1:serviceCode + resourceId +4.2: serviceCode + resourceIds +4.3: serviceCode + ruleName +5: 所有规则 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 当前所在页,默认为1 optional + * @param {integer} [opts.pageSize] - 页面大小,默认为20;取值范围[1, 100] optional + * @param {string} [opts.serviceCode] - 产品线标识,默认返回该serviceCode下所有group的数据。eg:serviceCode=jdw(jdw产品线下包含jdw-master与jdw-segment两个分组)会返回jdw-master和jdw-segment的数据。 optional + * @param {string} [opts.groupCode] - 分组标识、指定该参数时,查询只返回该group的数据。groupCode参数仅在与serviceCode匹配时生效;eg:serviceCode=jdw、groupCode=jdw-master,只返回jdw-master分组的数据,不返回jdw-segment的数据。 optional + * @param {string} [opts.resourceId] - 资源Id optional + * @param {string} [opts.alarmId] - 规则Id optional + * @param {integer} [opts.alarming] - 正在报警, 取值为1 optional + * @param {string} [opts.startTime] - 开始时间 optional + * @param {string} [opts.endTime] - 结束时间 optional + * @param {integer} [opts.ruleType] - 规则类型,默认查询1, 1表示资源监控,6表示站点监控,7表示可用性监控 optional + * @param {filter} [opts.filters] - serviceCodes - 产品线servicecode,精确匹配,支持多个 +resourceIds - 资源Id,精确匹配,支持多个(必须指定serviceCode才会在该serviceCode下根据resourceIds过滤,否则该参数不生效) +alarmIds - 规则Id,精确匹配,支持多个 +ruleName - 规则名称,模糊匹配,支持单个 optional + * @param {string} [opts.resourceIdList] - resourceId列表,必须指定serviceCode才会生效 optional + * @param {string} [opts.serviceCodeList] - 产品线列表 optional + * @param {string} callback - callback + @return {Object} result + * @param alarmHistoryWithDetail list + * @param integer total 总数 + */ + + describeAlarmHistoryAllRegion (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 + } + if (opts.serviceCode !== undefined && opts.serviceCode !== null) { + queryParams['serviceCode'] = opts.serviceCode + } + if (opts.groupCode !== undefined && opts.groupCode !== null) { + queryParams['groupCode'] = opts.groupCode + } + if (opts.resourceId !== undefined && opts.resourceId !== null) { + queryParams['resourceId'] = opts.resourceId + } + if (opts.alarmId !== undefined && opts.alarmId !== null) { + queryParams['alarmId'] = opts.alarmId + } + if (opts.alarming !== undefined && opts.alarming !== null) { + queryParams['alarming'] = opts.alarming + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.ruleType !== undefined && opts.ruleType !== null) { + queryParams['ruleType'] = opts.ruleType + } + Object.assign(queryParams, this.buildFilterParam(opts.filters, 'filters')) + Object.assign( + queryParams, + this.buildArrayParam(opts.resourceIdList, 'resourceIdList') + ) + Object.assign( + queryParams, + this.buildArrayParam(opts.serviceCodeList, 'serviceCodeList') + ) + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/1.3.9' + } + + 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 describeAlarmHistoryAllRegion 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 = this.makeRequest( + '/ruleNoticeHistory', + '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.ids - ids,多个id用|分隔 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteAlarmsCm (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 deleteAlarmsCm" + ) + } + + opts = opts || {} + + if (opts.ids === undefined || opts.ids === null) { + throw new Error( + "Missing the required parameter 'opts.ids' when calling deleteAlarmsCm" + ) + } + + let postBody = null + let queryParams = {} + if (opts.ids !== undefined && opts.ids !== null) { + queryParams['ids'] = opts.ids + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/1.3.9' + } + + 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 deleteAlarmsCm 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 = this.makeRequest( + '/regions/{regionId}/cmAlarms', + '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) + } + ) + } + + /** + * 根据产品线查询可用监控项列表,metric介绍:<a href="https://docs.jdcloud.com/cn/monitoring/metrics">Metrics</a> + * @param {Object} opts - parameters + * @param {string} opts.serviceCode - 资源的类型,取值vm, lb, ip, database 等 + * @param {integer} [opts.type] - metric的类型,取值0(控制台展示)、1(内部使用,控制台不展示)、2(所有).默认取0 optional + * @param {string} callback - callback + @return {Object} result + * @param metricDetail metrics + */ + + describeMetrics (opts, callback) { + opts = opts || {} + + if (opts.serviceCode === undefined || opts.serviceCode === null) { + throw new Error( + "Missing the required parameter 'opts.serviceCode' when calling describeMetrics" + ) + } + + let postBody = null + let queryParams = {} + if (opts.serviceCode !== undefined && opts.serviceCode !== null) { + queryParams['serviceCode'] = opts.serviceCode + } + if (opts.type !== undefined && opts.type !== null) { + queryParams['type'] = opts.type + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/1.3.9' + } + + 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 describeMetrics 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 = this.makeRequest( + '/metrics', + '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> + * @param {Object} opts - parameters + * @param {string} [opts.serviceCode] - 资源的类型,取值vm, lb, ip, database 等 optional + * @param {integer} [opts.type] - metric类型,取值0、1;默认值:0(常规指标,用于控制台创建报警规则)、1(其它) optional + * @param {string} callback - callback + @return {Object} result + * @param serviceCodeMetrics serviceCodeList + */ + + describeMetricsForCreateAlarm (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.serviceCode !== undefined && opts.serviceCode !== null) { + queryParams['serviceCode'] = opts.serviceCode + } + if (opts.type !== undefined && opts.type !== null) { + queryParams['type'] = opts.type + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/1.3.9' + } + + 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 describeMetricsForCreateAlarm 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 = this.makeRequest( + '/metricsForCreateAlarm', + '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> + * @param {Object} opts - parameters + * @param {string} opts.metric - 监控项英文标识(id) + * @param {string} opts.serviceCode - 资源的类型,取值vm, lb, ip, database 等 + * @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.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, this.buildTagFilterParam(opts.tags, 'tags')) + + let pathParams = { + regionId: regionId, + metric: opts.metric + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/1.3.9' + } + + 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 = this.makeRequest( + '/regions/{regionId}/metrics/{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介绍1:<a href="https://docs.jdcloud.com/cn/monitoring/metrics">Metrics</a> + * @param {Object} opts - parameters + * @param {string} opts.metric - 监控项英文标识(id) + * @param {string} [opts.aggrType] - 聚合方式,默认等于downSampleType或avg,可选值参考:sum、avg、last、min、max optional + * @param {string} [opts.downSampleType] - 采样方式,默认等于aggrType或avg,可选值参考: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 等 + * @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.serviceCode === undefined || opts.serviceCode === null) { + throw new Error( + "Missing the required parameter 'opts.serviceCode' 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.resourceId !== undefined && opts.resourceId !== null) { + queryParams['resourceId'] = opts.resourceId + } + Object.assign(queryParams, this.buildTagFilterParam(opts.tags, 'tags')) + + let pathParams = { + regionId: regionId, + metric: opts.metric + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/1.3.9' + } + + 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 = this.makeRequest( + '/regions/{regionId}/metrics/{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) + } + ) + } + + /** + * 该接口为自定义监控数据上报的接口,方便您将自己采集的时序数据上报到云监控。不同region域名上报不同region的数据,参考:<a href="https://docs.jdcloud.com/cn/monitoring/reporting-monitoring-data">调用说明</a>可上报原始数据和已聚合的统计数据。支持批量上报方式。单次请求最多包含 50 个数据点;数据大小不超过 256k。 + * @param {Object} opts - parameters + * @param {array} [opts.metricDataList] - 数据参数 optional + * @param {string} callback - callback + @return {Object} result + * @param boolean success 全部写入成功为true,否则为false + * @param metricDataList errMetricDataList + */ + + putMetricData (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.metricDataList !== undefined && opts.metricDataList !== null) { + postBody['metricDataList'] = opts.metricDataList + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/1.3.9' + } + + 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 putMetricData 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 = this.makeRequest( + '/customMetrics', + '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 serviceInfo 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, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/1.3.9' + } + + 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 = this.makeRequest( + '/services', + '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 = JDCloud.MONITOR diff --git a/packages/libs/lib-jdcloud/src/repo/monitor/v2/monitor.js b/packages/libs/lib-jdcloud/src/repo/monitor/v2/monitor.js new file mode 100644 index 000000000..7c430694a --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/monitor/v2/monitor.js @@ -0,0 +1,2615 @@ +/* + * 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. + * + * maintainAuxiliaryTags APIs + * 一组资源增加删除标签 + * + * 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 = 'monitor' +Service._services[serviceId] = true + +/** + * monitor service. + * @version 2.5.12 + */ + +class MONITOR extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'monitor.jdcloud-api.com' + options.basePath = '/v2' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询规则列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 当前所在页,默认为1 optional + * @param {integer} [opts.pageSize] - 页面大小,默认为20;取值范围[1, 100] optional + * @param {integer} [opts.dataOwner] - 数据所有者,1云监控控制台; 2云鼎。默认为1 optional + * @param {string} [opts.serviceCode] - 产品线标识,同一个产品线下可能存在多个product,如(redis下有redis2.8cluster、redis4.0) optional + * @param {string} [opts.product] - 产品标识,如redis下分多个产品(redis2.8cluster、redis4.0)。同时指定serviceCode与product时,product优先生效 optional + * @param {string} [opts.dimension] - 产品下的维度标识,指定dimension时必须指定product optional + * @param {string} [opts.ruleName] - 规则名称 optional + * @param {integer} [opts.ruleType] - 规则类型, 1表示资源监控,6表示站点监控,7表示可用性监控 optional + * @param {integer} [opts.enabled] - 规则状态:1为启用,0为禁用 optional + * @param {integer} [opts.ruleStatus] - 资源的规则状态 2:报警、4:数据不足 optional + * @param {filter} [opts.filters] - 服务码或资源Id列表 +products - 产品product,精确匹配,支持多个 +resourceIds - 资源Id,精确匹配,支持多个(必须指定serviceCode、product或dimension,否则该参数不生效) +alarmIds - 规则id,精确匹配,支持多个 optional + * @param {string} callback - callback + @return {Object} result + * @param describeGroupAlarm alarmList + * @param integer numberPages 总页数 + * @param integer numberRecords 总记录数 + * @param integer pageNumber 当前页码 + * @param integer pageSize 分页大小 + */ + + describeAlarms (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 + } + if (opts.dataOwner !== undefined && opts.dataOwner !== null) { + queryParams['dataOwner'] = opts.dataOwner + } + if (opts.serviceCode !== undefined && opts.serviceCode !== null) { + queryParams['serviceCode'] = opts.serviceCode + } + if (opts.product !== undefined && opts.product !== null) { + queryParams['product'] = opts.product + } + if (opts.dimension !== undefined && opts.dimension !== null) { + queryParams['dimension'] = opts.dimension + } + if (opts.ruleName !== undefined && opts.ruleName !== null) { + queryParams['ruleName'] = opts.ruleName + } + if (opts.ruleType !== undefined && opts.ruleType !== null) { + queryParams['ruleType'] = opts.ruleType + } + if (opts.enabled !== undefined && opts.enabled !== null) { + queryParams['enabled'] = opts.enabled + } + if (opts.ruleStatus !== undefined && opts.ruleStatus !== null) { + queryParams['ruleStatus'] = opts.ruleStatus + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/2.5.12' + } + + 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 describeAlarms 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( + '/groupAlarms', + '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.autoScalingPolicyId] - 弹性伸缩组Id。注:仅ag\asg产品线内部使用 optional + * @param {array} [opts.baseContact] - 告警通知联系人 optional + * @param {string} opts.clientToken - 幂等性校验参数,最长36位,若两个请求clientToken相等,则返回第一次创建的规则id,只创建一次规则 + * @param {integer} [opts.dataOwner] - 数据所有者,1云监控控制台; 2云鼎。默认为1 optional + * @param {string} [opts.dimension] - 资源维度,可用的维度请使用 describeProductsForAlarm接口查询 optional + * @param {integer} [opts.enabled] - 是否启用, 1表示启用规则,0表示禁用规则,默认为1 optional + * @param {array} [opts.multiWebHook] - url回调设置数组 optional + * @param {array} [opts.noticeOption] - 通知策略 optional + * @param {string} opts.product - 资源类型, 可用的资源类型列表请使用 describeProductsForAlarm接口查询。 + * @param {resourceOption} opts.resourceOption + * @param {string} opts.ruleName - 规则名称,规则名称,最大长度42个字符,只允许中英文、数字、''-''和"_" + * @param {ruleOption} opts.ruleOption + * @param {string} [opts.ruleType] - 规则类型, 默认为resourceMonitor optional + * @param {object} [opts.tags] - 资源维度,指定监控数据实例的维度标签,如resourceId=id。(请确认资源的监控数据带有该标签,否则规则会报数据不足) optional + * @param {webHookOption} [opts.webHookOption] optional + * @param {string} callback - callback + @return {Object} result + * @param string alarmId 创建成功的规则id + * @param integer ruleIds + */ + + createAlarm (opts, callback) { + opts = opts || {} + + if (opts.clientToken === undefined || opts.clientToken === null) { + throw new Error( + "Missing the required parameter 'opts.clientToken' when calling createAlarm" + ) + } + if (opts.product === undefined || opts.product === null) { + throw new Error( + "Missing the required parameter 'opts.product' when calling createAlarm" + ) + } + if (opts.resourceOption === undefined || opts.resourceOption === null) { + throw new Error( + "Missing the required parameter 'opts.resourceOption' when calling createAlarm" + ) + } + if (opts.ruleName === undefined || opts.ruleName === null) { + throw new Error( + "Missing the required parameter 'opts.ruleName' when calling createAlarm" + ) + } + if (opts.ruleOption === undefined || opts.ruleOption === null) { + throw new Error( + "Missing the required parameter 'opts.ruleOption' when calling createAlarm" + ) + } + + let postBody = {} + if ( + opts.autoScalingPolicyId !== undefined && + opts.autoScalingPolicyId !== null + ) { + postBody['autoScalingPolicyId'] = opts.autoScalingPolicyId + } + if (opts.baseContact !== undefined && opts.baseContact !== null) { + postBody['baseContact'] = opts.baseContact + } + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.dataOwner !== undefined && opts.dataOwner !== null) { + postBody['dataOwner'] = opts.dataOwner + } + if (opts.dimension !== undefined && opts.dimension !== null) { + postBody['dimension'] = opts.dimension + } + if (opts.enabled !== undefined && opts.enabled !== null) { + postBody['enabled'] = opts.enabled + } + if (opts.multiWebHook !== undefined && opts.multiWebHook !== null) { + postBody['multiWebHook'] = opts.multiWebHook + } + if (opts.noticeOption !== undefined && opts.noticeOption !== null) { + postBody['noticeOption'] = opts.noticeOption + } + if (opts.product !== undefined && opts.product !== null) { + postBody['product'] = opts.product + } + if (opts.resourceOption !== undefined && opts.resourceOption !== null) { + postBody['resourceOption'] = opts.resourceOption + } + if (opts.ruleName !== undefined && opts.ruleName !== null) { + postBody['ruleName'] = opts.ruleName + } + if (opts.ruleOption !== undefined && opts.ruleOption !== null) { + postBody['ruleOption'] = opts.ruleOption + } + if (opts.ruleType !== undefined && opts.ruleType !== null) { + postBody['ruleType'] = opts.ruleType + } + if (opts.tags !== undefined && opts.tags !== null) { + postBody['tags'] = opts.tags + } + if (opts.webHookOption !== undefined && opts.webHookOption !== null) { + postBody['webHookOption'] = opts.webHookOption + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/2.5.12' + } + + 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 createAlarm 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( + '/groupAlarms', + '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.alarmId - 规则id + * @param {string} callback - callback + @return {Object} result + * @param string alarmId 报警规则ID + * @param integer alarmStatus 规则状态,当一个规则下同时存在报警、数据不足、正常的资源时,规则状态按 报警>数据不足>正常的优先级展示 +监控项状态:-1 未启用 1正常,2告警,4数据不足 + * @param integer alarmStatusList + * @param baseContact baseContact + * @param string createTime 创建时间 + * @param string dimension 资源维度 + * @param string dimensionName 资源维度名称 + * @param integer enabled 是否启用, 1表示启用规则,0表示禁用规则,默认为1 + * @param webHookOption multiWebHook + * @param noticeOption noticeOption + * @param string product 资源类型 + * @param string productName 资源类型名称 + * @param resourceOption resourceOption + * @param string ruleName 规则名称,规则名称,最大长度42个字符,只允许中英文、数字、''-''和"_" + * @param ruleOptionDetail ruleOption + * @param string ruleType 规则类型, 默认为resourceMonitor + * @param string ruleVersion 规则版本 v1 v2 + * @param object tags 资源维度,指定监控数据实例的维度标签,如resourceId=id。(请确认资源的监控数据带有该标签,否则规则会报数据不足) + * @param webHookOption webHookOption + */ + + describeAlarm (opts, callback) { + opts = opts || {} + + if (opts.alarmId === undefined || opts.alarmId === null) { + throw new Error( + "Missing the required parameter 'opts.alarmId' when calling describeAlarm" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + alarmId: opts.alarmId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/2.5.12' + } + + 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 describeAlarm 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( + '/groupAlarms/{alarmId}', + '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.alarmId - 规则id + * @param {string} [opts.autoScalingPolicyId] - 弹性伸缩组Id。注:仅ag\asg产品线内部使用 optional + * @param {array} [opts.baseContact] - 告警通知联系人 optional + * @param {integer} [opts.dataOwner] - 数据所有者,1云监控控制台; 2云鼎。默认为1 optional + * @param {string} [opts.dimension] - 资源维度,可用的维度请使用 describeProductsForAlarm接口查询 optional + * @param {integer} [opts.enabled] - 是否启用, 1表示启用规则,0表示禁用规则,默认为1 optional + * @param {array} [opts.multiWebHook] - url回调设置数组 optional + * @param {array} [opts.noticeOption] - 通知策略 optional + * @param {string} opts.product - 资源类型, 可用的资源类型列表请使用 describeProductsForAlarm接口查询。 + * @param {resourceOption} opts.resourceOption + * @param {string} opts.ruleName - 规则名称,规则名称,最大长度42个字符,只允许中英文、数字、''-''和"_" + * @param {ruleOption} opts.ruleOption + * @param {string} [opts.ruleType] - 规则类型, 默认为resourceMonitor optional + * @param {object} [opts.tags] - 资源维度,指定监控数据实例的维度标签,如resourceId=id。(请确认资源的监控数据带有该标签,否则规则会报数据不足) optional + * @param {webHookOption} [opts.webHookOption] optional + * @param {string} callback - callback + @return {Object} result + * @param string alarmId 创建成功的规则id + * @param integer ruleIds + * @param boolean success 成功则返回true + */ + + updateAlarm (opts, callback) { + opts = opts || {} + + if (opts.alarmId === undefined || opts.alarmId === null) { + throw new Error( + "Missing the required parameter 'opts.alarmId' when calling updateAlarm" + ) + } + if (opts.product === undefined || opts.product === null) { + throw new Error( + "Missing the required parameter 'opts.product' when calling updateAlarm" + ) + } + if (opts.resourceOption === undefined || opts.resourceOption === null) { + throw new Error( + "Missing the required parameter 'opts.resourceOption' when calling updateAlarm" + ) + } + if (opts.ruleName === undefined || opts.ruleName === null) { + throw new Error( + "Missing the required parameter 'opts.ruleName' when calling updateAlarm" + ) + } + if (opts.ruleOption === undefined || opts.ruleOption === null) { + throw new Error( + "Missing the required parameter 'opts.ruleOption' when calling updateAlarm" + ) + } + + let postBody = {} + if ( + opts.autoScalingPolicyId !== undefined && + opts.autoScalingPolicyId !== null + ) { + postBody['autoScalingPolicyId'] = opts.autoScalingPolicyId + } + if (opts.baseContact !== undefined && opts.baseContact !== null) { + postBody['baseContact'] = opts.baseContact + } + if (opts.dataOwner !== undefined && opts.dataOwner !== null) { + postBody['dataOwner'] = opts.dataOwner + } + if (opts.dimension !== undefined && opts.dimension !== null) { + postBody['dimension'] = opts.dimension + } + if (opts.enabled !== undefined && opts.enabled !== null) { + postBody['enabled'] = opts.enabled + } + if (opts.multiWebHook !== undefined && opts.multiWebHook !== null) { + postBody['multiWebHook'] = opts.multiWebHook + } + if (opts.noticeOption !== undefined && opts.noticeOption !== null) { + postBody['noticeOption'] = opts.noticeOption + } + if (opts.product !== undefined && opts.product !== null) { + postBody['product'] = opts.product + } + if (opts.resourceOption !== undefined && opts.resourceOption !== null) { + postBody['resourceOption'] = opts.resourceOption + } + if (opts.ruleName !== undefined && opts.ruleName !== null) { + postBody['ruleName'] = opts.ruleName + } + if (opts.ruleOption !== undefined && opts.ruleOption !== null) { + postBody['ruleOption'] = opts.ruleOption + } + if (opts.ruleType !== undefined && opts.ruleType !== null) { + postBody['ruleType'] = opts.ruleType + } + if (opts.tags !== undefined && opts.tags !== null) { + postBody['tags'] = opts.tags + } + if (opts.webHookOption !== undefined && opts.webHookOption !== null) { + postBody['webHookOption'] = opts.webHookOption + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + alarmId: opts.alarmId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/2.5.12' + } + + 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 updateAlarm 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( + '/groupAlarms/{alarmId}', + '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) + } + ) + } + + /** + * 删除规则 + * @param {Object} opts - parameters + * @param {string} opts.alarmId - 规则id + * @param {string} callback - callback + @return {Object} result + * @param boolean success + */ + + deleteAlarms (opts, callback) { + opts = opts || {} + + if (opts.alarmId === undefined || opts.alarmId === null) { + throw new Error( + "Missing the required parameter 'opts.alarmId' when calling deleteAlarms" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + alarmId: opts.alarmId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/2.5.12' + } + + 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 deleteAlarms 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( + '/groupAlarms/{alarmId}', + '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.alarmId - 规则id + * @param {integer} [opts.pageNumber] - 当前所在页,默认为1 optional + * @param {integer} [opts.pageSize] - 页面大小,默认为20;取值范围[1, 100] optional + * @param {integer} [opts.referenceType] - 联系人类型。0,联系人分组; 1,联系人 optional + * @param {string} callback - callback + @return {Object} result + * @param describedNoticeContacts contactsList + * @param integer total 报警联系人总数 + */ + + describeAlarmContacts (opts, callback) { + opts = opts || {} + + if (opts.alarmId === undefined || opts.alarmId === null) { + throw new Error( + "Missing the required parameter 'opts.alarmId' when calling describeAlarmContacts" + ) + } + + 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.referenceType !== undefined && opts.referenceType !== null) { + queryParams['referenceType'] = opts.referenceType + } + + let pathParams = { + regionId: 'jdcloud', + alarmId: opts.alarmId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/2.5.12' + } + + 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 describeAlarmContacts 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( + '/groupAlarms/{alarmId}/contacts', + '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> + * @param {Object} opts - parameters + * @param {string} [opts.serviceCode] - 产品线 optional + * @param {string} [opts.product] - 产品类型,如redis2.8cluster(集群)\redis2.8MS(主从)。当serviceCode与product同时指定时,product优先级更高 optional + * @param {string} [opts.dimension] - 产品维度,必须指定serviceCode或product才生效。 optional + * @param {integer} [opts.metricType] - metric类型,取值0、1;默认值:0(常规指标,用于控制台创建报警规则)、1(其它) optional + * @param {string} callback - callback + @return {Object} result + * @param ruleMetricDetail metrics + */ + + describeMetricsForAlarm (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.serviceCode !== undefined && opts.serviceCode !== null) { + queryParams['serviceCode'] = opts.serviceCode + } + if (opts.product !== undefined && opts.product !== null) { + queryParams['product'] = opts.product + } + if (opts.dimension !== undefined && opts.dimension !== null) { + queryParams['dimension'] = opts.dimension + } + if (opts.metricType !== undefined && opts.metricType !== null) { + queryParams['metricType'] = opts.metricType + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/2.5.12' + } + + 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 describeMetricsForAlarm 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( + '/groupAlarms:metrics', + '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.serviceCode] - 产品线,从产品线维度筛选 optional + * @param {string} [opts.product] - 产品类型,从产品维度筛选、如redis2.8cluster\redis2.8instance。当serviceCode与product同时指定时,product优先级更高 optional + * @param {string} callback - callback + @return {Object} result + * @param product productList + */ + + describeProductsForAlarm (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.serviceCode !== undefined && opts.serviceCode !== null) { + queryParams['serviceCode'] = opts.serviceCode + } + if (opts.product !== undefined && opts.product !== null) { + queryParams['product'] = opts.product + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/2.5.12' + } + + 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 describeProductsForAlarm 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( + '/groupAlarms:products', + '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 {array} [opts.alarmIds] - 告警规则的ID列表 optional + * @param {integer} [opts.state] - 启用:1,禁用0, optional + * @param {string} callback - callback + @return {Object} result + * @param boolean success + */ + + enableAlarms (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.alarmIds !== undefined && opts.alarmIds !== null) { + postBody['alarmIds'] = opts.alarmIds + } + if (opts.state !== undefined && opts.state !== null) { + postBody['state'] = opts.state + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/2.5.12' + } + + 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 enableAlarms 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( + '/groupAlarms:switch', + '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.pageNumber] - 当前所在页,默认为1 optional + * @param {integer} [opts.pageSize] - 页面大小,默认为20;取值范围[1, 100] optional + * @param {integer} [opts.dataOwner] - 数据所有者,1云监控控制台; 2云鼎。默认为1 optional + * @param {string} [opts.serviceCode] - 产品线标识,同一个产品线下可能存在多个product,如(redis下有redis2.8cluster、redis4.0) optional + * @param {string} [opts.product] - 产品标识,默认返回该product下所有dimension的数据。eg:product=redis2.8cluster(redis2.8cluster产品下包含redis2.8-shard与redis2.8-proxy、redis2.8-instance多个维度)。 optional + * @param {string} [opts.dimension] - 维度标识、指定该参数时,查询只返回该维度的数据。如redis2.8cluster下存在实例、分片等多个维度 optional + * @param {string} [opts.region] - 根据region筛选对应region的资源的报警历史 optional + * @param {integer} [opts.isAlarming] - 正在报警, 取值为1 optional + * @param {integer} [opts.status] - 报警的状态,1为报警恢复、2为报警、4为报警恢复无数据 optional + * @param {string} [opts.startTime] - 开始时间 optional + * @param {string} [opts.endTime] - 结束时间 optional + * @param {integer} [opts.ruleType] - 规则类型,默认查询1, 1表示资源监控,6表示站点监控,7表示可用性监控 optional + * @param {string} [opts.ruleName] - 规则名称模糊搜索 optional + * @param {filter} [opts.filters] - serviceCodes - 产品线servicecode,精确匹配,支持多个 +resourceIds - 资源Id,精确匹配,支持多个(必须指定serviceCode才会在该serviceCode下根据resourceIds过滤,否则该参数不生效) +alarmIds - 规则Id,精确匹配,支持多个 optional + * @param {string} callback - callback + @return {Object} result + * @param describedAlarmHistory alarmHistoryList + * @param integer numberPages 总页数 + * @param integer numberRecords 总记录数 + * @param integer pageNumber 当前页码 + * @param integer pageSize 分页大小 + */ + + describeAlarmHistory (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 + } + if (opts.dataOwner !== undefined && opts.dataOwner !== null) { + queryParams['dataOwner'] = opts.dataOwner + } + if (opts.serviceCode !== undefined && opts.serviceCode !== null) { + queryParams['serviceCode'] = opts.serviceCode + } + if (opts.product !== undefined && opts.product !== null) { + queryParams['product'] = opts.product + } + if (opts.dimension !== undefined && opts.dimension !== null) { + queryParams['dimension'] = opts.dimension + } + if (opts.region !== undefined && opts.region !== null) { + queryParams['region'] = opts.region + } + if (opts.isAlarming !== undefined && opts.isAlarming !== null) { + queryParams['isAlarming'] = opts.isAlarming + } + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.ruleType !== undefined && opts.ruleType !== null) { + queryParams['ruleType'] = opts.ruleType + } + if (opts.ruleName !== undefined && opts.ruleName !== null) { + queryParams['ruleName'] = opts.ruleName + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/2.5.12' + } + + 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 describeAlarmHistory 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( + '/groupAlarmsHistory', + '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.namespaceUID - namespace + * @param {string} [opts.endTime] - 查询时间范围的结束时间, UTC时间,格式:2016-12-11T00:00:00+0800(为空时,将由startTime与timeInterval计算得出) optional + * @param {queryOption} opts.query + * @param {string} [opts.startTime] - 查询时间范围的开始时间, UTC时间,格式:2016-12-11T00:00:00+0800 optional + * @param {string} [opts.timeInterval] - 时间间隔:1h,6h,12h,1d,3d,7d,14d,固定时间间隔,timeInterval默认为1h,当前时间往 前1h optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param metricDataItemCm metricDatas + */ + + describeCustomMetricData (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 describeCustomMetricData" + ) + } + + opts = opts || {} + + if (opts.namespaceUID === undefined || opts.namespaceUID === null) { + throw new Error( + "Missing the required parameter 'opts.namespaceUID' when calling describeCustomMetricData" + ) + } + if (opts.query === undefined || opts.query === null) { + throw new Error( + "Missing the required parameter 'opts.query' when calling describeCustomMetricData" + ) + } + + let postBody = {} + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.query !== undefined && opts.query !== null) { + postBody['query'] = opts.query + } + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.timeInterval !== undefined && opts.timeInterval !== null) { + postBody['timeInterval'] = opts.timeInterval + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + namespaceUID: opts.namespaceUID + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/2.5.12' + } + + 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 describeCustomMetricData 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}/namespaces/{namespaceUID}/metricData', + '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) + } + ) + } + + /** + * 根据产品线查询可用监控项列表,metric介绍:<a href="https://docs.jdcloud.com/cn/monitoring/metrics">Metrics</a> + * @param {Object} opts - parameters + * @param {string} opts.serviceCode - 资源的类型,取值vm, lb, ip, database 等。<a href="https://docs.jdcloud.com/cn/monitoring/api/describeservices?content=API&SOP=JDCloud">describeServices</a>:查询己接入云监控的产品线列表 + * @param {string} [opts.dimension] optional + * @param {integer} [opts.type] - metric的类型,取值0(控制台展示)、1(内部使用,控制台不展示)、2(所有).默认取0 optional + * @param {string} callback - callback + @return {Object} result + * @param metricDetail metrics + */ + + describeMetrics (opts, callback) { + opts = opts || {} + + if (opts.serviceCode === undefined || opts.serviceCode === null) { + throw new Error( + "Missing the required parameter 'opts.serviceCode' when calling describeMetrics" + ) + } + + 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.type !== undefined && opts.type !== null) { + queryParams['type'] = opts.type + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/2.5.12' + } + + 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 describeMetrics 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( + '/metrics', + '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 {string} [opts.timeOffset] - 时间偏移,可传入30s、1m、1h、1d等数字+单位的形式(其中s秒,m分,h时,d天),当业务侧数据上报存在延迟时,可以传入该参数,该参数会使查询的时间段整体向前偏移.偏移后的开始时间若早于30天前,则开始时间自动设置为30天前;若偏移后结束时间早于30天前,则无效 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 + } + if (opts.timeOffset !== undefined && opts.timeOffset !== null) { + queryParams['timeOffset'] = opts.timeOffset + } + Object.assign(queryParams, super.buildTagFilterParam(opts.tags, 'tags')) + + let pathParams = { + regionId: regionId, + metric: opts.metric + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/2.5.12' + } + + 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}/metrics/{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列表。 +查询起止时间统一向下对齐10s, 举例:开始时间为 08:45:45 会对齐到08:45:40 + + * @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) +开始时间不得晚于当前时间,开始时间不得早于 30 天前 + optional + * @param {string} [opts.endTime] - 查询时间范围的结束时间, UTC时间,格式:2016-12-11T00:00:00+0800(为空时,将由startTime与timeInterval计算得出)(注意在url中+要转译为%2B故url中为2016-12-11T00:00:00%2B0800) +默认为当前时间,结束时间不得晚于当前时间. 如果晚于, 会被默认设成当前时间, 结束时间不得早于 30 天前. + optional + * @param {string} [opts.timeInterval] - 时间间隔:1h,6h,12h,1d,3d,7d,14d,固定时间间隔,timeInterval默认为1h,当前时间往 前1h +如果指定了 startTime 和 endTime,可以不用设置. 默认的,三个参数都不设置查询 1h 内数据. +timeInterval 默认值 1h +endTime 默认值, 当前时间 +startTime 默认值, endTime - timeInterval + optional + * @param {boolean} [opts.groupBy] - 是否对查询的tags分组 optional + * @param {boolean} [opts.rate] - 是否求速率。仅对累积类型指标有意义, 默认 false 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 monitor/2.5.12' + } + + 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}/metrics/{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) + } + ) + } + + /** + * 查询某资源下指定tag key的tag value + * @param {Object} opts - parameters + * @param {string} opts.tagKey - region + * @param {string} opts.serviceCode - serviceCode + * @param {string} opts.resourceId - 资源标识 + * @param {string} [opts.metric] - metric optional + * @param {string} [opts.startTime] - 查询时间范围的开始时间(如不传,则默认为1时前), UTC时间,格式:2016-12-11T00:00:00+0800(注意在url中+,:要转译,如2019-10-23T10%3A33%3A31%2B0800)。对于非连续的时序数据,开始时间无法保证准确性 optional + * @param {string} [opts.endTime] - 查询时间范围的结束时间(如不传,则默认为当前), UTC时间,格式:2016-12-11T00:00:00+0800(注意在url中+,:要转译,如2019-10-23T10%3A33%3A31%2B0800).对于非连续的时序数据,结束时间无法保证准确性 optional + * @param {string} [opts.timeInterval] - 时间间隔:1h,6h,12h,1d,3d,7d,14d,固定时间间隔,timeInterval默认为1h,当前时间往 前1h optional + * @param {tagFilter} [opts.tags] - 根据tags进行筛选(传入*和不传的效果一致) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string tagValues + */ + + describeTagValues (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 describeTagValues" + ) + } + + opts = opts || {} + + if (opts.tagKey === undefined || opts.tagKey === null) { + throw new Error( + "Missing the required parameter 'opts.tagKey' when calling describeTagValues" + ) + } + if (opts.serviceCode === undefined || opts.serviceCode === null) { + throw new Error( + "Missing the required parameter 'opts.serviceCode' when calling describeTagValues" + ) + } + if (opts.resourceId === undefined || opts.resourceId === null) { + throw new Error( + "Missing the required parameter 'opts.resourceId' when calling describeTagValues" + ) + } + + let postBody = null + let queryParams = {} + if (opts.serviceCode !== undefined && opts.serviceCode !== null) { + queryParams['serviceCode'] = opts.serviceCode + } + if (opts.resourceId !== undefined && opts.resourceId !== null) { + queryParams['resourceId'] = opts.resourceId + } + if (opts.metric !== undefined && opts.metric !== null) { + queryParams['metric'] = opts.metric + } + 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 + } + Object.assign(queryParams, super.buildTagFilterParam(opts.tags, 'tags')) + + let pathParams = { + regionId: regionId, + tagKey: opts.tagKey + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/2.5.12' + } + + 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 describeTagValues 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}/tagValues/{tagKey}', + '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.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 monitor/2.5.12' + } + + 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( + '/services', + '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) + } + ) + } + + /** + * 该接口为自定义监控数据上报的接口,方便您将自己采集的时序数据上报到云监控。不同region域名上报不同region的数据,参考:<a href="https://docs.jdcloud.com/cn/monitoring/reporting-monitoring-data">调用说明</a>可上报原始数据和已聚合的统计数据。支持批量上报方式。单次请求最多包含 50 个数据点;数据大小不超过 256k。 + * @param {Object} opts - parameters + * @param {array} [opts.metricDataList] - 数据参数 optional + * @param {string} callback - callback + @return {Object} result + * @param boolean success 全部写入成功为true,否则为false + * @param metricDataList errMetricDataList + */ + + putMetricData (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.metricDataList !== undefined && opts.metricDataList !== null) { + postBody['metricDataList'] = opts.metricDataList + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/2.5.12' + } + + 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 putMetricData 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( + '/customMetrics', + '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) + } + ) + } + + /** + * 该接口为自定义监控数据上报的接口,方便您将自己采集的时序数据上报到云监控。不同region域名上报不同region的数据,参考:<a href="https://docs.jdcloud.com/cn/monitoring/reporting-monitoring-data">调用说明</a>可上报原始数据和已聚合的统计数据。支持批量上报方式。单次请求最多包含 50 个数据点;数据大小不超过 256k。 + * @param {Object} opts - parameters + * @param {array} [opts.metricDataList] - 数据参数 optional + * @param {string} callback - callback + @return {Object} result + * @param boolean success 全部写入成功为true,否则为false + * @param metricDataList errMetricDataList + */ + + putCustomMetricData (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.metricDataList !== undefined && opts.metricDataList !== null) { + postBody['metricDataList'] = opts.metricDataList + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/2.5.12' + } + + 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 putCustomMetricData 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( + '/customMetrics', + '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} callback - callback + @return {Object} result + * @param integer failed 失败数量 + * @param integer success 成功数量 + */ + + put (opts, callback) { + 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: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/2.5.12' + } + + 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( + '/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} callback - callback + @return {Object} result + * @param integer failed 失败数量 + * @param integer success 成功数量 + */ + + putProductMetricData (opts, callback) { + 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: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitor/2.5.12' + } + + 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( + '/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) + } + ) + } +} +module.exports = MONITOR diff --git a/packages/libs/lib-jdcloud/src/repo/monitorcm/v1/monitorcm.js b/packages/libs/lib-jdcloud/src/repo/monitorcm/v1/monitorcm.js new file mode 100644 index 000000000..64fb09871 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/monitorcm/v1/monitorcm.js @@ -0,0 +1,131 @@ +/* + * 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. + * + * 监控项相关接口 + * 监控项相关接口,提供自定义监控数据上报功能 + * + * 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 = 'monitorcm' +Service._services[serviceId] = true + +/** + * monitorcm service. + * @version 1.0.0 + */ + +JDCloud.MONITORCM = class MONITORCM extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'monitor.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 上报用户自定义监控数据 + * @param {Object} opts - parameters + * @param {array} opts.metricDataList - 数据参数 + * @param {string} callback - callback + @return {Object} result + * @param boolean success + * @param metricDataList errMetricDataList + */ + + putMetricData (opts, callback) { + opts = opts || {} + + if (opts.metricDataList === undefined || opts.metricDataList === null) { + throw new Error( + "Missing the required parameter 'opts.metricDataList' when calling putMetricData" + ) + } + + let postBody = {} + if (opts.metricDataList !== undefined && opts.metricDataList !== null) { + postBody['metricDataList'] = opts.metricDataList + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 monitorcm/1.0.0' + } + + let formParams = {} + + let contentTypes = ['application/json'] + let accepts = ['application/json'] + + let returnType = null + + this.config.logger( + `call putMetricData 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 = this.makeRequest( + '/customMetrics', + 'POST', + pathParams, + queryParams, + headerParams, + formParams, + postBody, + contentTypes, + accepts, + returnType, + callback + ) + + return request.then( + function (result) { + if (callback) { + return callback(null, result) + } + return result + }, + function (error) { + if (callback) { + return callback(error) + } + return Promise.reject(error) + } + ) + } +} +module.exports = JDCloud.MONITORCM diff --git a/packages/libs/lib-jdcloud/src/repo/mps/v1/mps.js b/packages/libs/lib-jdcloud/src/repo/mps/v1/mps.js new file mode 100644 index 000000000..d303e4e52 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/mps/v1/mps.js @@ -0,0 +1,4244 @@ +/* + * 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. + * + * 媒体处理相关接口 + * 多媒体处理服务API,包括截图、转码、媒体处理消息通知等操作。本文档详细说明了媒体处理API及用法,适合开发人员阅读。 + * + * 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 = 'mps' +Service._services[serviceId] = true + +/** + * mps service. + * @version 0.4.10 + */ + +class MPS extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'mps.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 设置回调配置 + * @param {Object} opts - parameters + * @param {array} [opts.callbackEvents] - 回调事件列表。取值范围: +- snapshot_complete 截图完成,包括成功和失败 + optional + * @param {string} opts.callbackType - 回调方式,目前只支持 http + * @param {string} [opts.httpUrl] - 回调方式为 http 时,此为必须参数 optional + * @param {string} [opts.disabled] - 是否禁用回调,默认值为 false,即开启回调 optional + * @param {string} callback - callback + @return {Object} result + */ + + setCallbackSettings (opts, callback) { + opts = opts || {} + + if (opts.callbackType === undefined || opts.callbackType === null) { + throw new Error( + "Missing the required parameter 'opts.callbackType' when calling setCallbackSettings" + ) + } + + let postBody = {} + if (opts.callbackEvents !== undefined && opts.callbackEvents !== null) { + postBody['callbackEvents'] = opts.callbackEvents + } + if (opts.callbackType !== undefined && opts.callbackType !== null) { + postBody['callbackType'] = opts.callbackType + } + if (opts.httpUrl !== undefined && opts.httpUrl !== null) { + postBody['httpUrl'] = opts.httpUrl + } + if (opts.disabled !== undefined && opts.disabled !== null) { + postBody['disabled'] = opts.disabled + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 setCallbackSettings 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( + '/settings:setCallbackSettings', + '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} callback - callback + @return {Object} result + * @param callbackSettings resultObject + */ + + queryCallbackSettings (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 queryCallbackSettings 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( + '/settings:queryCallbackSettings', + '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.templateId - 截图模板ID + * @param {input} opts.input + * @param {output} opts.output + * @param {output} [opts.spriteOutput] optional + * @param {string} callback - callback + @return {Object} result + * @param submitSnapshotTaskResultObject resultObject + */ + + submitSnapshotTask (opts, callback) { + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling submitSnapshotTask" + ) + } + if (opts.input === undefined || opts.input === null) { + throw new Error( + "Missing the required parameter 'opts.input' when calling submitSnapshotTask" + ) + } + if (opts.output === undefined || opts.output === null) { + throw new Error( + "Missing the required parameter 'opts.output' when calling submitSnapshotTask" + ) + } + + let postBody = {} + if (opts.templateId !== undefined && opts.templateId !== null) { + postBody['templateId'] = opts.templateId + } + if (opts.input !== undefined && opts.input !== null) { + postBody['input'] = opts.input + } + if (opts.output !== undefined && opts.output !== null) { + postBody['output'] = opts.output + } + if (opts.spriteOutput !== undefined && opts.spriteOutput !== null) { + postBody['spriteOutput'] = opts.spriteOutput + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 submitSnapshotTask 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( + '/snapshotTasks:submit', + '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) + } + ) + } + + /** + * 查询视频截图任务列表 +支持过滤查询: + - createTime,ge 最早任务创建时间 + - createTime,le 最晚任务创建时间 + - status,in 任务状态IN查询 + - taskId,eq 任务ID精确查询 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认值为 1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认值为 10;取值范围 [10, 100] optional + * @param {filter} [opts.filters] optional + * @param {string} callback - callback + @return {Object} result + * @param listSnapshotTasksResultObject resultObject + */ + + listSnapshotTasks (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 mps/0.4.10' + } + + 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 listSnapshotTasks 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( + '/snapshotTasks', + '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.taskId - 任务ID,路径参数 + * @param {string} callback - callback + @return {Object} result + * @param snapshotTaskObject snapshotTaskObject + */ + + getSnapshotTask (opts, callback) { + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling getSnapshotTask" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 getSnapshotTask 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( + '/snapshotTasks/{taskId}', + '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.taskId - 任务ID,路径参数 + * @param {string} callback - callback + @return {Object} result + */ + + deleteSnapshotTask (opts, callback) { + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling deleteSnapshotTask" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 deleteSnapshotTask 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( + '/snapshotTasks/{taskId}', + '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.taskId - 任务ID,路径参数 + * @param {string} callback - callback + @return {Object} result + * @param snapshotTaskResultObject snapshotTaskResultObject + */ + + querySnapshotTaskResult (opts, callback) { + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling querySnapshotTaskResult" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 querySnapshotTaskResult 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( + '/snapshotTasks/{taskId}:queryResult', + '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) + } + ) + } + + /** + * 查询截图模板列表。 +允许通过条件过滤查询,支持的过滤字段如下: + - templateId[eq] 按模板ID精确查询 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认值为 1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认值为 10;取值范围 [10, 100] optional + * @param {filter} [opts.filters] optional + * @param {string} callback - callback + @return {Object} result + * @param listSnapshotTemplatesResultInfo resultObject + */ + + listSnapshotTemplates (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 mps/0.4.10' + } + + 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 listSnapshotTemplates 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( + '/snapshotTemplates', + '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.title - 模板标题。长度不超过 128 个字节。UTF-8 编码。 + * @param {integer} [opts.startTime] - 截图起始时间,取值范围单位为秒,缺省值为 0 + optional + * @param {string} [opts.frameType] - 截图帧类型。取值范围: + any - 任意帧 + intra - 关键帧 +缺省值为 any + optional + * @param {string} [opts.format] - 截图格式。取值范围: + jpg - 对应的截图或雪碧图输出文件扩展名为 jpg + png - 对应的截图或雪碧图输出文件扩展名为 png +缺省值为 jpg + optional + * @param {integer} [opts.number] - 截图数量。取值范围:[1, 3600] +缺省值为 10 +若雪碧图配置不为空,则生成雪碧图,提交的截图任务中,此字段会被雪碧图的行列积所覆盖。 + optional + * @param {integer} [opts.interval] - 截图时间间隔。取值范围:[1, 100],单位为秒 +若未设置,则对于普通截图,按照截图张数做平均截图;对于雪碧图,则按照行列数乘积做平均截图 + optional + * @param {integer} [opts.width] - 截图宽度,取值范围:[8, 4096] +若宽度和高度同时设置,则按照设置的宽高截图; +若宽度和高度均未设置,则截图保持与源视频相同的宽高值; +若宽度和高度其中一项未设置,则截图保持与源视频相同的宽高比; + optional + * @param {integer} [opts.height] - 截图高度,取值范围:[8, 4096] +若宽度和高度同时设置,则按照设置的宽高截图; +若宽度和高度均未设置,则截图保持与源视频相同的宽高值; +若宽度和高度其中一项未设置,则截图保持与源视频相同的宽高比; + optional + * @param {string} [opts.fillType] - 填充方式,当视频宽高与截图宽高指定值不能匹配时的填充处理方式。取值范围: + stretch - 伸缩 + black - 留黑 + white - 留白 + gauss - 高斯模糊 +缺省值为 black + optional + * @param {spriteConfig} [opts.spriteConfig] - 雪碧图配置。若此字段有值,则生成雪碧图。 + optional + * @param {string} callback - callback + @return {Object} result + * @param snapshotTemplateInfo resultObject + */ + + createSnapshotTemplate (opts, callback) { + opts = opts || {} + + if (opts.title === undefined || opts.title === null) { + throw new Error( + "Missing the required parameter 'opts.title' when calling createSnapshotTemplate" + ) + } + + let postBody = {} + if (opts.title !== undefined && opts.title !== null) { + postBody['title'] = opts.title + } + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.frameType !== undefined && opts.frameType !== null) { + postBody['frameType'] = opts.frameType + } + if (opts.format !== undefined && opts.format !== null) { + postBody['format'] = opts.format + } + if (opts.number !== undefined && opts.number !== null) { + postBody['number'] = opts.number + } + if (opts.interval !== undefined && opts.interval !== null) { + postBody['interval'] = opts.interval + } + if (opts.width !== undefined && opts.width !== null) { + postBody['width'] = opts.width + } + if (opts.height !== undefined && opts.height !== null) { + postBody['height'] = opts.height + } + if (opts.fillType !== undefined && opts.fillType !== null) { + postBody['fillType'] = opts.fillType + } + if (opts.spriteConfig !== undefined && opts.spriteConfig !== null) { + postBody['spriteConfig'] = opts.spriteConfig + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 createSnapshotTemplate 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( + '/snapshotTemplates', + '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.templateId - 模板ID + * @param {string} callback - callback + @return {Object} result + * @param snapshotTemplateInfo resultObject + */ + + getSnapshotTemplate (opts, callback) { + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling getSnapshotTemplate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 getSnapshotTemplate 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( + '/snapshotTemplates/{templateId}', + '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.templateId - 模板ID + * @param {string} [opts.title] - 模板标题。长度不超过 128 个字节。UTF-8 编码。 optional + * @param {integer} [opts.startTime] - 截图起始时间,单位为秒,缺省值为 0 optional + * @param {string} [opts.frameType] - 截图帧类型。取值范围:normal、intra optional + * @param {string} [opts.format] - 截图格式。取值范围:jpg、png optional + * @param {integer} [opts.number] - 截图数量,缺省值为 10 optional + * @param {integer} [opts.interval] - 截图间隔 optional + * @param {integer} [opts.width] - 截图宽度,取值范围:[8, 4096] + optional + * @param {integer} [opts.height] - 截图高度,取值范围:[8, 4096] + optional + * @param {string} [opts.fillType] - 填充方式,当视频宽高与截图宽高指定值不能匹配时的填充处理方式。取值范围: + stretch - 伸缩 + black - 留黑 + white - 留白 + gauss - 高斯模糊 +缺省值为 black + optional + * @param {spriteConfig} [opts.spriteConfig] - 雪碧图配置 optional + * @param {string} callback - callback + @return {Object} result + * @param snapshotTemplateInfo resultObject + */ + + modifySnapshotTemplate (opts, callback) { + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling modifySnapshotTemplate" + ) + } + + let postBody = {} + if (opts.title !== undefined && opts.title !== null) { + postBody['title'] = opts.title + } + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.frameType !== undefined && opts.frameType !== null) { + postBody['frameType'] = opts.frameType + } + if (opts.format !== undefined && opts.format !== null) { + postBody['format'] = opts.format + } + if (opts.number !== undefined && opts.number !== null) { + postBody['number'] = opts.number + } + if (opts.interval !== undefined && opts.interval !== null) { + postBody['interval'] = opts.interval + } + if (opts.width !== undefined && opts.width !== null) { + postBody['width'] = opts.width + } + if (opts.height !== undefined && opts.height !== null) { + postBody['height'] = opts.height + } + if (opts.fillType !== undefined && opts.fillType !== null) { + postBody['fillType'] = opts.fillType + } + if (opts.spriteConfig !== undefined && opts.spriteConfig !== null) { + postBody['spriteConfig'] = opts.spriteConfig + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 modifySnapshotTemplate 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( + '/snapshotTemplates/{templateId}', + 'PATCH', + 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.templateId - 模板ID + * @param {string} callback - callback + @return {Object} result + */ + + deleteSnapshotTemplate (opts, callback) { + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling deleteSnapshotTemplate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 deleteSnapshotTemplate 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( + '/snapshotTemplates/{templateId}', + '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.accessKey - 输入对象存储 accessKey,必须参数 + * @param {string} opts.secretKey - 输入对象存储 accessKey,必须参数 + * @param {string} opts.endpoint - 输入对象存储 endpoint。必须参数,内网域名,如 s3-internal.cn-north-1.jcloudcs.com + * @param {string} opts.bucket - 输入对象存储 bucket,必须参数 + * @param {string} opts.objectKey - 输入对象存储 objectKey,必须参数 + * @param {string} [opts.title] - 输入视频标题,可选参数,默认会从 objectKey 中截取 optional + * @param {array} [opts.templateIds] - 转码模板ID集合,必须参数,非空集合 optional + * @param {transcodeOutputConfig} opts.outputConfig - 输出配置,必须参数 + * @param {string} [opts.additionalProperties] - 附加参数,JSON格式的字符串。除非清楚了解其用途和用法,请勿使用此字段。 +若参数在本次作业提交所关联的模板中,存在相同用途的对应字段,则该属性值会覆盖模板中的对应字段; +若参数在本次作业提交所关联的模板中,不存在相同用途的对应字段,则该属性值会作为补充设置,用于生产任务; +有特殊说明的除外。 +当前支持的附加参数: + - hls.encrypt.key - HLS加密公钥,对应于转码模板中 encryption.hlsKey 字段 + - hls.encrypt.keyUrl - HLS加密公钥地址,对应于转码模板中 encryption.hlsKeyUrl 字段 + - hls.encrypt.encodeType - HLS加密公钥编码方式,对应于转码模板中 encryption.hlsKeyEncodeType 字段 +特殊说明: + - HLS加密相关参数,具有完整性要求,故 hls.encrypt 命名空间下的附加参数,依赖于 hls.encrypt.key 参数的设置情况。若设置 hls.encrypt.key 参数,则命名空间 hls.encrypt 下的其他参数也须同时设置;否则,其他参数会被忽略。 + optional + * @param {string} callback - callback + @return {Object} result + * @param submitTranscodeJobResultInfo resultObject + */ + + submitTranscodeJob (opts, callback) { + opts = opts || {} + + if (opts.accessKey === undefined || opts.accessKey === null) { + throw new Error( + "Missing the required parameter 'opts.accessKey' when calling submitTranscodeJob" + ) + } + if (opts.secretKey === undefined || opts.secretKey === null) { + throw new Error( + "Missing the required parameter 'opts.secretKey' when calling submitTranscodeJob" + ) + } + if (opts.endpoint === undefined || opts.endpoint === null) { + throw new Error( + "Missing the required parameter 'opts.endpoint' when calling submitTranscodeJob" + ) + } + if (opts.bucket === undefined || opts.bucket === null) { + throw new Error( + "Missing the required parameter 'opts.bucket' when calling submitTranscodeJob" + ) + } + if (opts.objectKey === undefined || opts.objectKey === null) { + throw new Error( + "Missing the required parameter 'opts.objectKey' when calling submitTranscodeJob" + ) + } + if (opts.outputConfig === undefined || opts.outputConfig === null) { + throw new Error( + "Missing the required parameter 'opts.outputConfig' when calling submitTranscodeJob" + ) + } + + let postBody = {} + if (opts.accessKey !== undefined && opts.accessKey !== null) { + postBody['accessKey'] = opts.accessKey + } + if (opts.secretKey !== undefined && opts.secretKey !== null) { + postBody['secretKey'] = opts.secretKey + } + if (opts.endpoint !== undefined && opts.endpoint !== null) { + postBody['endpoint'] = opts.endpoint + } + if (opts.bucket !== undefined && opts.bucket !== null) { + postBody['bucket'] = opts.bucket + } + if (opts.objectKey !== undefined && opts.objectKey !== null) { + postBody['objectKey'] = opts.objectKey + } + if (opts.title !== undefined && opts.title !== null) { + postBody['title'] = opts.title + } + if (opts.templateIds !== undefined && opts.templateIds !== null) { + postBody['templateIds'] = opts.templateIds + } + if (opts.outputConfig !== undefined && opts.outputConfig !== null) { + postBody['outputConfig'] = opts.outputConfig + } + if ( + opts.additionalProperties !== undefined && + opts.additionalProperties !== null + ) { + postBody['additionalProperties'] = opts.additionalProperties + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 submitTranscodeJob 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( + '/transcodeJobs:submit', + '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) + } + ) + } + + /** + * 查询转码作业列表。 +支持如下过滤器: +- title[eq] 按照输入视频标题进行精确匹配 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认值为 1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认值为 10;取值范围 [10, 100] optional + * @param {filter} [opts.filters] optional + * @param {string} callback - callback + @return {Object} result + * @param listTranscodeJobsResultInfo resultObject + */ + + listTranscodeJobs (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 mps/0.4.10' + } + + 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 listTranscodeJobs 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( + '/transcodeJobs', + '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.jobId - 转码作业ID + * @param {string} callback - callback + @return {Object} result + * @param transcodeJobInfo resultObject + */ + + getTranscodeJob (opts, callback) { + opts = opts || {} + + if (opts.jobId === undefined || opts.jobId === null) { + throw new Error( + "Missing the required parameter 'opts.jobId' when calling getTranscodeJob" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + jobId: opts.jobId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 getTranscodeJob 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( + '/transcodeJobs/{jobId}', + '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) + } + ) + } + + /** + * 查询转码模板列表。 +允许通过条件过滤查询,支持的过滤字段如下: + - transcodeType[eq] 按转码方式精确查询 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认值为 1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认值为 10;取值范围 [10, 100] optional + * @param {filter} [opts.filters] optional + * @param {string} callback - callback + @return {Object} result + * @param listTranscodeTemplatesResultInfo resultObject + */ + + listTranscodeTemplates (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 mps/0.4.10' + } + + 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 listTranscodeTemplates 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( + '/transcodeTemplates', + '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.title - 模板标题。长度不超过 128 个字符,最少 2 个字符。UTF-8 编码。 + + * @param {videoStreamSettings} opts.video - 视频参数配置 + * @param {audioStreamSettings} opts.audio - 音频参数配置 + * @param {containerSettings} opts.container - 容器封装配置 + * @param {encryptionSettings} [opts.encryption] - 加密配置 optional + * @param {string} opts.definition - 清晰度规格标记。取值范围: + SD - 标清 + HD - 高清 + FHD - 超清 + 2K + 4K + + * @param {string} [opts.transcodeType] - 转码方式。取值范围: + normal - 普通转码 + jdchd - 京享超清 + jdchs - 极速转码 +默认值为 normal + optional + * @param {string} callback - callback + @return {Object} result + * @param transcodeTemplateInfo resultObject + */ + + createTranscodeTemplate (opts, callback) { + opts = opts || {} + + if (opts.title === undefined || opts.title === null) { + throw new Error( + "Missing the required parameter 'opts.title' when calling createTranscodeTemplate" + ) + } + if (opts.video === undefined || opts.video === null) { + throw new Error( + "Missing the required parameter 'opts.video' when calling createTranscodeTemplate" + ) + } + if (opts.audio === undefined || opts.audio === null) { + throw new Error( + "Missing the required parameter 'opts.audio' when calling createTranscodeTemplate" + ) + } + if (opts.container === undefined || opts.container === null) { + throw new Error( + "Missing the required parameter 'opts.container' when calling createTranscodeTemplate" + ) + } + if (opts.definition === undefined || opts.definition === null) { + throw new Error( + "Missing the required parameter 'opts.definition' when calling createTranscodeTemplate" + ) + } + + let postBody = {} + if (opts.title !== undefined && opts.title !== null) { + postBody['title'] = opts.title + } + if (opts.video !== undefined && opts.video !== null) { + postBody['video'] = opts.video + } + if (opts.audio !== undefined && opts.audio !== null) { + postBody['audio'] = opts.audio + } + if (opts.container !== undefined && opts.container !== null) { + postBody['container'] = opts.container + } + if (opts.encryption !== undefined && opts.encryption !== null) { + postBody['encryption'] = opts.encryption + } + if (opts.definition !== undefined && opts.definition !== null) { + postBody['definition'] = opts.definition + } + if (opts.transcodeType !== undefined && opts.transcodeType !== null) { + postBody['transcodeType'] = opts.transcodeType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 createTranscodeTemplate 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( + '/transcodeTemplates', + '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.templateId - 模板ID + * @param {string} callback - callback + @return {Object} result + * @param transcodeTemplateInfo resultObject + */ + + getTranscodeTemplate (opts, callback) { + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling getTranscodeTemplate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 getTranscodeTemplate 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( + '/transcodeTemplates/{templateId}', + '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.templateId - 模板ID + * @param {string} [opts.title] - 模板标题。长度不超过 128 个字符,最少 2 个字符。UTF-8 编码。 + optional + * @param {videoStreamSettings} [opts.video] - 视频参数配置 optional + * @param {audioStreamSettings} [opts.audio] - 音频参数配置 optional + * @param {containerSettings} [opts.container] - 封装容器配置 optional + * @param {encryptionSettings} [opts.encryption] - 加密配置 optional + * @param {string} [opts.definition] - 清晰度规格标记。取值范围: + SD - 标清 + HD - 高清 + FHD - 超清 + 2K + 4K + optional + * @param {string} [opts.transcodeType] - 转码方式。取值范围: + normal - 普通转码 + jdchd - 京享超清 + jdchs - 极速转码 + optional + * @param {string} callback - callback + @return {Object} result + * @param transcodeTemplateInfo resultObject + */ + + updateTranscodeTemplate (opts, callback) { + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling updateTranscodeTemplate" + ) + } + + let postBody = {} + if (opts.title !== undefined && opts.title !== null) { + postBody['title'] = opts.title + } + if (opts.video !== undefined && opts.video !== null) { + postBody['video'] = opts.video + } + if (opts.audio !== undefined && opts.audio !== null) { + postBody['audio'] = opts.audio + } + if (opts.container !== undefined && opts.container !== null) { + postBody['container'] = opts.container + } + if (opts.encryption !== undefined && opts.encryption !== null) { + postBody['encryption'] = opts.encryption + } + if (opts.definition !== undefined && opts.definition !== null) { + postBody['definition'] = opts.definition + } + if (opts.transcodeType !== undefined && opts.transcodeType !== null) { + postBody['transcodeType'] = opts.transcodeType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 updateTranscodeTemplate 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( + '/transcodeTemplates/{templateId}', + '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) + } + ) + } + + /** + * 部分修改转码模板 + * @param {Object} opts - parameters + * @param {integer} opts.templateId - 模板ID + * @param {string} [opts.title] - 模板标题。长度不超过 128 个字符,最少 2 个字符。UTF-8 编码。 + optional + * @param {videoStreamSettings} [opts.video] - 视频参数配置 optional + * @param {audioStreamSettings} [opts.audio] - 音频参数配置 optional + * @param {containerSettings} [opts.container] - 封装容器配置 optional + * @param {encryptionSettings} [opts.encryption] - 加密配置 optional + * @param {string} [opts.definition] - 清晰度规格标记。取值范围: + SD - 标清 + HD - 高清 + FHD - 超清 + 2K + 4K + optional + * @param {string} [opts.transcodeType] - 转码方式。取值范围: + normal - 普通转码 + jdchd - 京享超清 + jdchs - 极速转码 + optional + * @param {string} callback - callback + @return {Object} result + * @param transcodeTemplateInfo resultObject + */ + + modifyTranscodeTemplate (opts, callback) { + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling modifyTranscodeTemplate" + ) + } + + let postBody = {} + if (opts.title !== undefined && opts.title !== null) { + postBody['title'] = opts.title + } + if (opts.video !== undefined && opts.video !== null) { + postBody['video'] = opts.video + } + if (opts.audio !== undefined && opts.audio !== null) { + postBody['audio'] = opts.audio + } + if (opts.container !== undefined && opts.container !== null) { + postBody['container'] = opts.container + } + if (opts.encryption !== undefined && opts.encryption !== null) { + postBody['encryption'] = opts.encryption + } + if (opts.definition !== undefined && opts.definition !== null) { + postBody['definition'] = opts.definition + } + if (opts.transcodeType !== undefined && opts.transcodeType !== null) { + postBody['transcodeType'] = opts.transcodeType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 modifyTranscodeTemplate 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( + '/transcodeTemplates/{templateId}', + 'PATCH', + 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.templateId - 模板ID + * @param {string} callback - callback + @return {Object} result + */ + + deleteTranscodeTemplate (opts, callback) { + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling deleteTranscodeTemplate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 deleteTranscodeTemplate 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( + '/transcodeTemplates/{templateId}', + '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) + } + ) + } + + /** + * 获取bucket的图片样式分隔符配置 + * @param {Object} opts - parameters + * @param {string} opts.bucketName - Bucket名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param styleDelimiterConf styleDelimiterConf + */ + + getStyleDelimiter (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 getStyleDelimiter" + ) + } + + opts = opts || {} + + if (opts.bucketName === undefined || opts.bucketName === null) { + throw new Error( + "Missing the required parameter 'opts.bucketName' when calling getStyleDelimiter" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + bucketName: opts.bucketName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 getStyleDelimiter 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}/buckets/{bucketName}/styleDelimiter/', + '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.bucketName - Bucket名称 + * @param {array} [opts.delimiters] - 图片样式分隔符配置(JSON数组);支持的分隔符包含:["-", "_", "/", "!"] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + setStyleDelimiter (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 setStyleDelimiter" + ) + } + + opts = opts || {} + + if (opts.bucketName === undefined || opts.bucketName === null) { + throw new Error( + "Missing the required parameter 'opts.bucketName' when calling setStyleDelimiter" + ) + } + + let postBody = {} + if (opts.delimiters !== undefined && opts.delimiters !== null) { + postBody['delimiters'] = opts.delimiters + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + bucketName: opts.bucketName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 setStyleDelimiter 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}/buckets/{bucketName}/styleDelimiter/', + '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) + } + ) + } + + /** + * 删除bucket的图片样式分隔符配置 + * @param {Object} opts - parameters + * @param {string} opts.bucketName - Bucket名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteStyleDelimiter (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 deleteStyleDelimiter" + ) + } + + opts = opts || {} + + if (opts.bucketName === undefined || opts.bucketName === null) { + throw new Error( + "Missing the required parameter 'opts.bucketName' when calling deleteStyleDelimiter" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + bucketName: opts.bucketName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 deleteStyleDelimiter 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}/buckets/{bucketName}/styleDelimiter/', + '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.bucketName - Bucket名称 + * @param {string} [opts.styleName] - 按样式名称查询 optional + * @param {integer} [opts.pageNumber] - 数据页码 optional + * @param {integer} [opts.pageSize] - 每页数据的条数 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param imageStyleQueryResult imageStyleQueryResult + */ + + listImageStyle (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 listImageStyle" + ) + } + + opts = opts || {} + + if (opts.bucketName === undefined || opts.bucketName === null) { + throw new Error( + "Missing the required parameter 'opts.bucketName' when calling listImageStyle" + ) + } + + let postBody = null + let queryParams = {} + if (opts.styleName !== undefined && opts.styleName !== null) { + queryParams['styleName'] = opts.styleName + } + 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, + bucketName: opts.bucketName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 listImageStyle 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}/buckets/{bucketName}/imageStyles', + '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.bucketName - Bucket名称 + * @param {integer} [opts.id] - 图片样式id(readOnly) optional + * @param {string} [opts.userId] - 用户id(readOnly) optional + * @param {string} [opts.styleName] - 图片样式名称 optional + * @param {string} [opts.params] - 图片样式参数 optional + * @param {string} [opts.paramAlias] - 图片样式参数别名 optional + * @param {string} [opts.regionId] - 所属区域(readOnly) optional + * @param {string} [opts.bucketName] - 所属Bucket(readOnly) optional + * @param {integer} [opts.status] - 图片样式状态(readOnly) optional + * @param {string} [opts.modifyTime] - 修改时间(readOnly) optional + * @param {string} [opts.createdTime] - 创建时间(readOnly) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param imageStyleID imageStyleID + */ + + createImageStyle (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 createImageStyle" + ) + } + + opts = opts || {} + + if (opts.bucketName === undefined || opts.bucketName === null) { + throw new Error( + "Missing the required parameter 'opts.bucketName' when calling createImageStyle" + ) + } + + let postBody = {} + if (opts.id !== undefined && opts.id !== null) { + postBody['id'] = opts.id + } + if (opts.userId !== undefined && opts.userId !== null) { + postBody['userId'] = opts.userId + } + if (opts.styleName !== undefined && opts.styleName !== null) { + postBody['styleName'] = opts.styleName + } + if (opts.params !== undefined && opts.params !== null) { + postBody['params'] = opts.params + } + if (opts.paramAlias !== undefined && opts.paramAlias !== null) { + postBody['paramAlias'] = opts.paramAlias + } + if (opts.regionId !== undefined && opts.regionId !== null) { + postBody['regionId'] = opts.regionId + } + if (opts.bucketName !== undefined && opts.bucketName !== null) { + postBody['bucketName'] = opts.bucketName + } + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + if (opts.modifyTime !== undefined && opts.modifyTime !== null) { + postBody['modifyTime'] = opts.modifyTime + } + if (opts.createdTime !== undefined && opts.createdTime !== null) { + postBody['createdTime'] = opts.createdTime + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + bucketName: opts.bucketName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 createImageStyle 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}/buckets/{bucketName}/imageStyles', + '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.bucketName - Bucket名称 + * @param {integer} opts.id - 图片样式id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param imageStyle imageStyle + */ + + getImageStyle (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 getImageStyle" + ) + } + + opts = opts || {} + + if (opts.bucketName === undefined || opts.bucketName === null) { + throw new Error( + "Missing the required parameter 'opts.bucketName' when calling getImageStyle" + ) + } + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling getImageStyle" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + bucketName: opts.bucketName, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 getImageStyle 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}/buckets/{bucketName}/imageStyles/{id}', + '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.bucketName - Bucket名称 + * @param {integer} opts.id - 图片样式id + * @param {integer} [opts.id] - 图片样式id(readOnly) optional + * @param {string} [opts.userId] - 用户id(readOnly) optional + * @param {string} [opts.styleName] - 图片样式名称 optional + * @param {string} [opts.params] - 图片样式参数 optional + * @param {string} [opts.paramAlias] - 图片样式参数别名 optional + * @param {string} [opts.regionId] - 所属区域(readOnly) optional + * @param {string} [opts.bucketName] - 所属Bucket(readOnly) optional + * @param {integer} [opts.status] - 图片样式状态(readOnly) optional + * @param {string} [opts.modifyTime] - 修改时间(readOnly) optional + * @param {string} [opts.createdTime] - 创建时间(readOnly) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateImageStyle (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 updateImageStyle" + ) + } + + opts = opts || {} + + if (opts.bucketName === undefined || opts.bucketName === null) { + throw new Error( + "Missing the required parameter 'opts.bucketName' when calling updateImageStyle" + ) + } + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling updateImageStyle" + ) + } + + let postBody = {} + if (opts.id !== undefined && opts.id !== null) { + postBody['id'] = opts.id + } + if (opts.userId !== undefined && opts.userId !== null) { + postBody['userId'] = opts.userId + } + if (opts.styleName !== undefined && opts.styleName !== null) { + postBody['styleName'] = opts.styleName + } + if (opts.params !== undefined && opts.params !== null) { + postBody['params'] = opts.params + } + if (opts.paramAlias !== undefined && opts.paramAlias !== null) { + postBody['paramAlias'] = opts.paramAlias + } + if (opts.regionId !== undefined && opts.regionId !== null) { + postBody['regionId'] = opts.regionId + } + if (opts.bucketName !== undefined && opts.bucketName !== null) { + postBody['bucketName'] = opts.bucketName + } + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + if (opts.modifyTime !== undefined && opts.modifyTime !== null) { + postBody['modifyTime'] = opts.modifyTime + } + if (opts.createdTime !== undefined && opts.createdTime !== null) { + postBody['createdTime'] = opts.createdTime + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + bucketName: opts.bucketName, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 updateImageStyle 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}/buckets/{bucketName}/imageStyles/{id}', + '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) + } + ) + } + + /** + * 删除图片样式 + * @param {Object} opts - parameters + * @param {string} opts.bucketName - Bucket名称 + * @param {integer} opts.id - 图片样式id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteImageStyle (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 deleteImageStyle" + ) + } + + opts = opts || {} + + if (opts.bucketName === undefined || opts.bucketName === null) { + throw new Error( + "Missing the required parameter 'opts.bucketName' when calling deleteImageStyle" + ) + } + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling deleteImageStyle" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + bucketName: opts.bucketName, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 deleteImageStyle 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}/buckets/{bucketName}/imageStyles/{id}', + '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.bucketName - Bucket名称 + * @param {string} [opts.styleName] - 按样式名称查询 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param imageStyleCount imageStyleCount + */ + + countImageStyle (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 countImageStyle" + ) + } + + opts = opts || {} + + if (opts.bucketName === undefined || opts.bucketName === null) { + throw new Error( + "Missing the required parameter 'opts.bucketName' when calling countImageStyle" + ) + } + + let postBody = null + let queryParams = {} + if (opts.styleName !== undefined && opts.styleName !== null) { + queryParams['styleName'] = opts.styleName + } + + let pathParams = { + regionId: regionId, + bucketName: opts.bucketName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 countImageStyle 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}/buckets/{bucketName}/imageStyles/count', + '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.status] - task 状态 (PENDING, RUNNING, SUCCESS, FAILED) optional + * @param {string} [opts.begin] - 开始时间 时间格式(GMT): yyyy-MM-dd'T'HH:mm:ss.SSS'Z' optional + * @param {string} [opts.end] - 结束时间 时间格式(GMT): yyyy-MM-dd'T'HH:mm:ss.SSS'Z' optional + * @param {string} [opts.marker] - 查询标记 optional + * @param {integer} [opts.limit] - 查询记录数 [1, 1000] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param thumbnailQuery thumbnailQuery + */ + + listThumbnailTask (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 listThumbnailTask" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + if (opts.begin !== undefined && opts.begin !== null) { + queryParams['begin'] = opts.begin + } + if (opts.end !== undefined && opts.end !== null) { + queryParams['end'] = opts.end + } + if (opts.marker !== undefined && opts.marker !== null) { + queryParams['marker'] = opts.marker + } + if (opts.limit !== undefined && opts.limit !== null) { + queryParams['limit'] = opts.limit + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 listThumbnailTask 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}/thumbnail', + '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) + } + ) + } + + /** + * 创建截图任务,创建成功时返回任务ID。本接口用于截取指定时间点的画面。 + * @param {Object} opts - parameters + * @param {string} [opts.taskID] - 任务ID (readonly) optional + * @param {string} [opts.status] - 状态 (SUCCESS, ERROR, PENDDING, RUNNING) (readonly) optional + * @param {integer} [opts.errorCode] - 错误码 (readonly) optional + * @param {string} [opts.createdTime] - 任务创建时间 时间格式(GMT): yyyy-MM-dd’T’HH:mm:ss.SSS’Z’ (readonly) optional + * @param {string} [opts.lastUpdatedTime] - 任务创建时间 时间格式(GMT): yyyy-MM-dd’T’HH:mm:ss.SSS’Z’ (readonly) optional + * @param {thumbnailTaskSource} opts.source + * @param {thumbnailTaskTarget} opts.target + * @param {thumbnailTaskRule} [opts.rule] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param thumbnailTaskID thumbnailTaskID + */ + + createThumbnailTask (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 createThumbnailTask" + ) + } + + opts = opts || {} + + if (opts.source === undefined || opts.source === null) { + throw new Error( + "Missing the required parameter 'opts.source' when calling createThumbnailTask" + ) + } + if (opts.target === undefined || opts.target === null) { + throw new Error( + "Missing the required parameter 'opts.target' when calling createThumbnailTask" + ) + } + + let postBody = {} + if (opts.taskID !== undefined && opts.taskID !== null) { + postBody['taskID'] = opts.taskID + } + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + if (opts.errorCode !== undefined && opts.errorCode !== null) { + postBody['errorCode'] = opts.errorCode + } + if (opts.createdTime !== undefined && opts.createdTime !== null) { + postBody['createdTime'] = opts.createdTime + } + if (opts.lastUpdatedTime !== undefined && opts.lastUpdatedTime !== null) { + postBody['lastUpdatedTime'] = opts.lastUpdatedTime + } + if (opts.source !== undefined && opts.source !== null) { + postBody['source'] = opts.source + } + if (opts.target !== undefined && opts.target !== null) { + postBody['target'] = opts.target + } + if (opts.rule !== undefined && opts.rule !== null) { + postBody['rule'] = opts.rule + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 createThumbnailTask 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}/thumbnail', + '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) + } + ) + } + + /** + * 根据任务ID获取截图任务。 + * @param {Object} opts - parameters + * @param {string} opts.taskId - task id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param thumbnailTask thumbnailTask + */ + + getThumbnailTask (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 getThumbnailTask" + ) + } + + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling getThumbnailTask" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 getThumbnailTask 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}/thumbnail/{taskId}', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param notification notification + */ + + getNotification (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 getNotification" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 getNotification 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}/notification', + '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) + } + ) + } + + /** + * 设置媒体处理通知, 在设置Notification时会对endpoint进行校验, 设置时会对endpoint发一条SubscriptionConfirmation(x-jdcloud-message-type头)的通知, 要求把Message内容进行base64编码返回给系统(body)进行校验 + * @param {Object} opts - parameters + * @param {boolean} opts.enabled - 是否启用通知 + * @param {string} [opts.endpoint] - 通知endpoint, 当前支持http://和https:// optional + * @param {array} [opts.events] - 触发通知的事件集合 (mpsTranscodeComplete, mpsThumbnailComplete) optional + * @param {string} [opts.notifyStrategy] - 重试策略, BACKOFF_RETRY: 退避重试策略, 重试 3 次, 每次重试的间隔时间是 10秒 到 20秒 之间的随机值; EXPONENTIAL_DECAY_RETRY: 指数衰减重试, 重试 176 次, 每次重试的间隔时间指数递增至 512秒, 总计重试时间为1天; 每次重试的具体间隔为: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 512 ... 512 秒(共167个512) optional + * @param {string} [opts.notifyContentFormat] - 描述了向 Endpoint 推送的消息格式, JSON: 包含消息正文和消息属性, SIMPLIFIED: 消息体即用户发布的消息, 不包含任何属性信息 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + setNotification (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 setNotification" + ) + } + + opts = opts || {} + + if (opts.enabled === undefined || opts.enabled === null) { + throw new Error( + "Missing the required parameter 'opts.enabled' when calling setNotification" + ) + } + + let postBody = {} + if (opts.enabled !== undefined && opts.enabled !== null) { + postBody['enabled'] = opts.enabled + } + if (opts.endpoint !== undefined && opts.endpoint !== null) { + postBody['endpoint'] = opts.endpoint + } + if (opts.events !== undefined && opts.events !== null) { + postBody['events'] = opts.events + } + if (opts.notifyStrategy !== undefined && opts.notifyStrategy !== null) { + postBody['notifyStrategy'] = opts.notifyStrategy + } + if ( + opts.notifyContentFormat !== undefined && + opts.notifyContentFormat !== null + ) { + postBody['notifyContentFormat'] = opts.notifyContentFormat + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 mps/0.4.10' + } + + 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 setNotification 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}/notification', + '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) + } + ) + } +} +module.exports = MPS diff --git a/packages/libs/lib-jdcloud/src/repo/nativecontainer/v1/nativecontainer.js b/packages/libs/lib-jdcloud/src/repo/nativecontainer/v1/nativecontainer.js new file mode 100644 index 000000000..9c305cd7c --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/nativecontainer/v1/nativecontainer.js @@ -0,0 +1,2662 @@ +/* + * 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. + * + * 用户设置 + * 查询用户设置接口 + * + * 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 = 'nativecontainer' +Service._services[serviceId] = true + +/** + * nativecontainer service. + * @version 2.3.0 + */ + +class NATIVECONTAINER extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'nativecontainer.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 批量查询原生容器的详细信息<br> +此接口支持分页查询,默认每页20条。 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 100] optional + * @param {filter} [opts.filters] - containerId - 实例ID,精确匹配,支持多个 +privateIpAddress - 主网卡IP地址,模糊匹配,支持单个 +az - 可用区,精确匹配,支持多个 +vpcId - 私有网络ID,精确匹配,支持多个 +status - 容器状态,精确匹配,支持多个 +name - 容器名称,模糊匹配,支持单个 +subnetId - 子网ID,精确匹配,支持多个 +agId - 镜像ID,精确匹配,支持多个 + optional + * @param {tagFilter} [opts.tags] - Tag筛选条件 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param container containers + * @param number totalCount + */ + + describeContainers (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 describeContainers" + ) + } + + 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')) + Object.assign(queryParams, super.buildTagFilterParam(opts.tags, 'tags')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nativecontainer/2.3.0' + } + + 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 describeContainers 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}/containers', + '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服务商 +- 镜像 + - 容器的镜像通过镜像名称来确定 + - nginx:tag, mysql/mysql-server:tag这样命名的镜像表示docker hub官方镜像 + - container-registry/image:tag这样命名的镜像表示私有仓储的镜像 + - 私有仓储必须兼容docker registry认证机制,并通过secret来保存机密信息 +- hostname规范 + - 支持两种方式:以标签方式书写或以完整主机名方式书写 + - 标签规范 + - 0-9,a-z(不分大小写)和-(减号),其他的都是无效的字符串 + - 不能以减号开始,也不能以减号结尾 + - 最小1个字符,最大63个字符 + - 完整的主机名由一系列标签与点连接组成 + - 标签与标签之间使用“.”(点)进行连接 + - 不能以“.”(点)开始,也不能以“.”(点)结尾 + - 整个主机名(包括标签以及分隔点“.”)最多有63个ASCII字符 +- 网络配置 + - 指定主网卡配置信息 + - 必须指定vpcId、subnetId、securityGroupIds + - 可以指定elasticIp规格来约束创建的弹性IP,带宽取值范围[1-200]Mbps,步进1Mbps + - 可以指定网卡的主IP(primaryIpAddress)和辅助IP(secondaryIpAddresses),此时maxCount只能为1 + - 可以指定希望的辅助IP个数(secondaryIpAddressCount)让系统自动创建内网IP + - 可以设置网卡的自动删除autoDelete属性,指明是否删除实例时自动删除网卡 + - 安全组securityGroup需与子网Subnet在同一个私有网络VPC内 + - 每个容器至多指定5个安全组 + - 主网卡deviceIndex设置为0 +- 存储 + - volume分为root volume和data volume,root volume的挂载目录是/,data volume的挂载目录可以随意指定 + - volume的底层存储介质当前只支持cloud类别,也就是云硬盘 + - 云盘类型为 ssd.io1 时,用户可以指定 iops,其他类型云盘无效,对已经存在的云盘无效,具体规则如下 + - 步长 10 + - 范围 [200,min(32000,size*50)] + - 默认值 size*30 + - root volume + - root volume支持cloud和local + - 云硬盘类型可以选择hdd.std1、ssd.gp1、ssd.io1 + - 磁盘大小 + - 所有类型:范围[10,100]GB,步长为10G + - 自动删除 + - 默认自动删除 + - 可以选择已存在的云硬盘 + - data volume + - data volume当前只能选择cloud类别 + - 云硬盘类型可以选择hdd.std1、ssd.gp1、ssd.io1 + - 磁盘大小 + - 所有类型:范围[20,2000]GB,步长为10G + - 自动删除 + - 默认自动删除 + - 可以选择已存在的云硬盘 + - 可以从快照创建磁盘 + - 单个容器可以挂载7个data volume +- 容器日志 + - default:默认在本地分配10MB的存储空间,自动rotate +- 其他 + - 创建完成后,容器状态为running + - maxCount为最大努力,不保证一定能达到maxCount + + * @param {Object} opts - parameters + * @param {containerSpec} opts.containerSpec - 创建容器规格 + * @param {integer} opts.maxCount - 购买实例数量;取值范围:[1,100] + * @param {string} [opts.clientToken] - 保证请求幂等性 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string containerIds + */ + + createContainers (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 createContainers" + ) + } + + opts = opts || {} + + if (opts.containerSpec === undefined || opts.containerSpec === null) { + throw new Error( + "Missing the required parameter 'opts.containerSpec' when calling createContainers" + ) + } + if (opts.maxCount === undefined || opts.maxCount === null) { + throw new Error( + "Missing the required parameter 'opts.maxCount' when calling createContainers" + ) + } + + let postBody = {} + if (opts.containerSpec !== undefined && opts.containerSpec !== null) { + postBody['containerSpec'] = opts.containerSpec + } + if (opts.maxCount !== undefined && opts.maxCount !== null) { + postBody['maxCount'] = opts.maxCount + } + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nativecontainer/2.3.0' + } + + 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 createContainers 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}/containers', + '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.containerId - Container ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param container container + */ + + describeContainer (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 describeContainer" + ) + } + + opts = opts || {} + + if (opts.containerId === undefined || opts.containerId === null) { + throw new Error( + "Missing the required parameter 'opts.containerId' when calling describeContainer" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + containerId: opts.containerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nativecontainer/2.3.0' + } + + 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 describeContainer 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}/containers/{containerId}', + '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) + } + ) + } + + /** + * 容器状态必须为 stopped、running 或 error状态。 <br> +按量付费的实例,如不主动删除将一直运行,不再使用的实例,可通过本接口主动停用。<br> +只能支持主动删除按配置计费类型的实例。包年包月过期的容器也可以删除,其它的情况还请发工单系统。计费状态异常的容器无法删除。 + + * @param {Object} opts - parameters + * @param {string} opts.containerId - Container ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteContainer (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 deleteContainer" + ) + } + + opts = opts || {} + + if (opts.containerId === undefined || opts.containerId === null) { + throw new Error( + "Missing the required parameter 'opts.containerId' when calling deleteContainer" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + containerId: opts.containerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nativecontainer/2.3.0' + } + + 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 deleteContainer 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}/containers/{containerId}', + '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> +容器实例或其绑定的云盘已欠费时,容器将无法正常启动。<br> + + * @param {Object} opts - parameters + * @param {string} opts.containerId - Container ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + startContainer (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 startContainer" + ) + } + + opts = opts || {} + + if (opts.containerId === undefined || opts.containerId === null) { + throw new Error( + "Missing the required parameter 'opts.containerId' when calling startContainer" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + containerId: opts.containerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nativecontainer/2.3.0' + } + + 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 startContainer 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}/containers/{containerId}:startContainer', + '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.containerId - Container ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + stopContainer (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 stopContainer" + ) + } + + opts = opts || {} + + if (opts.containerId === undefined || opts.containerId === null) { + throw new Error( + "Missing the required parameter 'opts.containerId' when calling stopContainer" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + containerId: opts.containerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nativecontainer/2.3.0' + } + + 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 stopContainer 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}/containers/{containerId}:stopContainer', + '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> +name 和 description 必须要指定一个 + + * @param {Object} opts - parameters + * @param {string} opts.containerId - Container ID + * @param {string} [opts.name] - 容器名称 optional + * @param {string} [opts.description] - 容器描述 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyContainerAttribute (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 modifyContainerAttribute" + ) + } + + opts = opts || {} + + if (opts.containerId === undefined || opts.containerId === null) { + throw new Error( + "Missing the required parameter 'opts.containerId' when calling modifyContainerAttribute" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + containerId: opts.containerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nativecontainer/2.3.0' + } + + 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 modifyContainerAttribute 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}/containers/{containerId}:modifyContainerAttribute', + 'PATCH', + 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. <br> +一台云主机只能绑定一个弹性公网 IP(主网卡),若主网卡已存在弹性公网IP,会返回错误。<br> +如果是黑名单中的用户,会返回错误。 + + * @param {Object} opts - parameters + * @param {string} opts.containerId - Container ID + * @param {string} opts.elasticIpId - 弹性IP ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + associateElasticIp (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 associateElasticIp" + ) + } + + opts = opts || {} + + if (opts.containerId === undefined || opts.containerId === null) { + throw new Error( + "Missing the required parameter 'opts.containerId' when calling associateElasticIp" + ) + } + if (opts.elasticIpId === undefined || opts.elasticIpId === null) { + throw new Error( + "Missing the required parameter 'opts.elasticIpId' when calling associateElasticIp" + ) + } + + let postBody = {} + if (opts.elasticIpId !== undefined && opts.elasticIpId !== null) { + postBody['elasticIpId'] = opts.elasticIpId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + containerId: opts.containerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nativecontainer/2.3.0' + } + + 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 associateElasticIp 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}/containers/{containerId}:associateElasticIp', + '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) + } + ) + } + + /** + * 容器解绑公网 IP,解绑的是主网卡、主内网 IP 对应的弹性 IP. + + * @param {Object} opts - parameters + * @param {string} opts.containerId - Container ID + * @param {string} opts.elasticIpId - 弹性IP ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + disassociateElasticIp (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 disassociateElasticIp" + ) + } + + opts = opts || {} + + if (opts.containerId === undefined || opts.containerId === null) { + throw new Error( + "Missing the required parameter 'opts.containerId' when calling disassociateElasticIp" + ) + } + if (opts.elasticIpId === undefined || opts.elasticIpId === null) { + throw new Error( + "Missing the required parameter 'opts.elasticIpId' when calling disassociateElasticIp" + ) + } + + let postBody = {} + if (opts.elasticIpId !== undefined && opts.elasticIpId !== null) { + postBody['elasticIpId'] = opts.elasticIpId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + containerId: opts.containerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nativecontainer/2.3.0' + } + + 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 disassociateElasticIp 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}/containers/{containerId}:disassociateElasticIp', + '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.containerId - Container ID + * @param {integer} [opts.tailLines] - 返回日志文件中倒数 tailLines 行,如不指定,默认从容器启动时或 sinceSeconds 指定的时间读取。 + optional + * @param {integer} [opts.sinceSeconds] - 返回相对于当前时间之前sinceSeconds之内的日志。 + optional + * @param {integer} [opts.limitBytes] - 限制返回的日志文件内容字节数,取值范围 [1-4]KB,最大 4KB. + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param object logs + */ + + getLogs (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 getLogs" + ) + } + + opts = opts || {} + + if (opts.containerId === undefined || opts.containerId === null) { + throw new Error( + "Missing the required parameter 'opts.containerId' when calling getLogs" + ) + } + + let postBody = null + let queryParams = {} + if (opts.tailLines !== undefined && opts.tailLines !== null) { + queryParams['tailLines'] = opts.tailLines + } + if (opts.sinceSeconds !== undefined && opts.sinceSeconds !== null) { + queryParams['sinceSeconds'] = opts.sinceSeconds + } + if (opts.limitBytes !== undefined && opts.limitBytes !== null) { + queryParams['limitBytes'] = opts.limitBytes + } + + let pathParams = { + regionId: regionId, + containerId: opts.containerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nativecontainer/2.3.0' + } + + 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 getLogs 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}/containers/{containerId}:getLogs', + '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) + } + ) + } + + /** + * 重置原生容器,对已有原生容器使用新的镜像重置。 +原容器 id 不变,不涉及计费变动,暂不支持修改实例类型,不会改变原生容器所在的物理节点,也不支持修改已经使用的系统盘和数据盘以及网络相关参数。 +- 镜像 + - 容器的镜像通过镜像名称来确定 + - nginx:tag 或 mysql/mysql-server:tag 这样命名的镜像表示 docker hub 官方镜像 + - container-registry/image:tag 这样命名的镜像表示私有仓储的镜像 + - 私有仓储必须兼容 docker registry 认证机制,并通过 secret 来保存机密信息 +- 其他 + - rebuild 之前容器必须处于关闭状态 + - rebuild 完成后,容器仍为关闭状态 + + * @param {Object} opts - parameters + * @param {string} opts.containerId - Container ID + * @param {string} opts.image - 镜像名称 </br> 1. Docker Hub官方镜像通过类似nginx, mysql/mysql-server的名字指定 </br> </br> repository长度最大256个字符,tag最大128个字符,registry最大255个字符 </br> 下载镜像超时时间:10分钟 + * @param {string} [opts.secret] - 镜像仓库认证信息;使用Docker Hub和京东云CR的镜像不需要secret optional + * @param {array} [opts.command] - 容器启动执行的命令, 如果不指定默认是镜像的ENTRYPOINT. 数组字符总长度范围:[0-256] optional + * @param {array} [opts.args] - 容器启动执行命令的参数, 如果不指定默认是镜像的CMD. 数组字符总长度范围:[0-2048] optional + * @param {boolean} [opts.tty] - 容器是否分配tty。默认不分配 optional + * @param {string} [opts.workingDir] - 容器的工作目录。如果不指定,默认是根目录(/),必须是绝对路径。字符长度范围:[0-1024] optional + * @param {array} [opts.envs] - 容器执行的环境变量;如果和镜像中的环境变量Key相同,会覆盖镜像中的值;</br> 最大100对 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + rebuildContainer (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 rebuildContainer" + ) + } + + opts = opts || {} + + if (opts.containerId === undefined || opts.containerId === null) { + throw new Error( + "Missing the required parameter 'opts.containerId' when calling rebuildContainer" + ) + } + if (opts.image === undefined || opts.image === null) { + throw new Error( + "Missing the required parameter 'opts.image' when calling rebuildContainer" + ) + } + + let postBody = {} + if (opts.image !== undefined && opts.image !== null) { + postBody['image'] = opts.image + } + if (opts.secret !== undefined && opts.secret !== null) { + postBody['secret'] = opts.secret + } + if (opts.command !== undefined && opts.command !== null) { + postBody['command'] = opts.command + } + if (opts.args !== undefined && opts.args !== null) { + postBody['args'] = opts.args + } + if (opts.tty !== undefined && opts.tty !== null) { + postBody['tty'] = opts.tty + } + if (opts.workingDir !== undefined && opts.workingDir !== null) { + postBody['workingDir'] = opts.workingDir + } + if (opts.envs !== undefined && opts.envs !== null) { + postBody['envs'] = opts.envs + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + containerId: opts.containerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nativecontainer/2.3.0' + } + + 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 rebuildContainer 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}/containers/{containerId}:rebuild', + '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.containerId - Container ID + * @param {string} opts.instanceType - 新实例类型,不可与原实例类型相同 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + resizeContainer (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 resizeContainer" + ) + } + + opts = opts || {} + + if (opts.containerId === undefined || opts.containerId === null) { + throw new Error( + "Missing the required parameter 'opts.containerId' when calling resizeContainer" + ) + } + if (opts.instanceType === undefined || opts.instanceType === null) { + throw new Error( + "Missing the required parameter 'opts.instanceType' when calling resizeContainer" + ) + } + + let postBody = {} + if (opts.instanceType !== undefined && opts.instanceType !== null) { + postBody['instanceType'] = opts.instanceType + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + containerId: opts.containerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nativecontainer/2.3.0' + } + + 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 resizeContainer 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}/containers/{containerId}:resize', + '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) + } + ) + } + + /** + * 创建exec + + * @param {Object} opts - parameters + * @param {string} opts.containerId - Container ID + * @param {array} [opts.command] - 执行命令 optional + * @param {boolean} [opts.tty] - 执行命令是否添加tty optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string execId + */ + + execCreate (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 execCreate" + ) + } + + opts = opts || {} + + if (opts.containerId === undefined || opts.containerId === null) { + throw new Error( + "Missing the required parameter 'opts.containerId' when calling execCreate" + ) + } + + let postBody = {} + if (opts.command !== undefined && opts.command !== null) { + postBody['command'] = opts.command + } + if (opts.tty !== undefined && opts.tty !== null) { + postBody['tty'] = opts.tty + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + containerId: opts.containerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nativecontainer/2.3.0' + } + + 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 execCreate 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}/containers/{containerId}:execCreate', + '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) + } + ) + } + + /** + * 获取exec退出码 + + * @param {Object} opts - parameters + * @param {string} opts.containerId - Container ID + * @param {string} opts.execId - exec ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer exitCode + */ + + execGetExitCode (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 execGetExitCode" + ) + } + + opts = opts || {} + + if (opts.containerId === undefined || opts.containerId === null) { + throw new Error( + "Missing the required parameter 'opts.containerId' when calling execGetExitCode" + ) + } + if (opts.execId === undefined || opts.execId === null) { + throw new Error( + "Missing the required parameter 'opts.execId' when calling execGetExitCode" + ) + } + + let postBody = null + let queryParams = {} + if (opts.execId !== undefined && opts.execId !== null) { + queryParams['execId'] = opts.execId + } + + let pathParams = { + regionId: regionId, + containerId: opts.containerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nativecontainer/2.3.0' + } + + 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 execGetExitCode 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}/containers/{containerId}:execGetExitCode', + '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) + } + ) + } + + /** + * 调整TTY大小 + + * @param {Object} opts - parameters + * @param {string} opts.containerId - Container ID + * @param {integer} opts.height - tty row + * @param {integer} opts.width - tty column + * @param {string} [opts.execId] - exec ID optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + resizeTTY (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 resizeTTY" + ) + } + + opts = opts || {} + + if (opts.containerId === undefined || opts.containerId === null) { + throw new Error( + "Missing the required parameter 'opts.containerId' when calling resizeTTY" + ) + } + if (opts.height === undefined || opts.height === null) { + throw new Error( + "Missing the required parameter 'opts.height' when calling resizeTTY" + ) + } + if (opts.width === undefined || opts.width === null) { + throw new Error( + "Missing the required parameter 'opts.width' when calling resizeTTY" + ) + } + + let postBody = {} + if (opts.height !== undefined && opts.height !== null) { + postBody['height'] = opts.height + } + if (opts.width !== undefined && opts.width !== null) { + postBody['width'] = opts.width + } + if (opts.execId !== undefined && opts.execId !== null) { + postBody['execId'] = opts.execId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + containerId: opts.containerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nativecontainer/2.3.0' + } + + 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 resizeTTY 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}/containers/{containerId}:resizeTTY', + '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 {filter} [opts.filters] - instanceTypes - 实例规格,精确匹配,支持多个 +az - 可用区,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instanceType instanceTypes + * @param instanceType specificInstanceTypes + * @param integer totalCount 总数量 + */ + + describeInstanceTypes (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 describeInstanceTypes" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nativecontainer/2.3.0' + } + + 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 describeInstanceTypes 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}/instanceTypes', + '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) + } + ) + } + + /** + * 查询资源的配额,支持:原生容器 pod 和 secret. + + * @param {Object} opts - parameters + * @param {string} opts.resourceType - resourceType - 资源类型,支持 [container, pod, secret] + + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param quota quota + */ + + describeQuota (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 describeQuota" + ) + } + + opts = opts || {} + + if (opts.resourceType === undefined || opts.resourceType === null) { + throw new Error( + "Missing the required parameter 'opts.resourceType' when calling describeQuota" + ) + } + + let postBody = null + let queryParams = {} + if (opts.resourceType !== undefined && opts.resourceType !== null) { + queryParams['resourceType'] = opts.resourceType + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nativecontainer/2.3.0' + } + + 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 describeQuota 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}/quotas', + '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) + } + ) + } + + /** + * 查询 secret 列表。<br> +此接口支持分页查询,默认每页20条。 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 100] optional + * @param {filter} [opts.filters] - name - secret名称,支持模糊搜索 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param secret secrets + * @param number totalCount + */ + + describeSecrets (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 describeSecrets" + ) + } + + 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 nativecontainer/2.3.0' + } + + 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 describeSecrets 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}/secrets', + '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) + } + ) + } + + /** + * 创建一个 secret,用于存放镜像仓库认证信息。 + + * @param {Object} opts - parameters + * @param {string} opts.name - 镜像仓库认证信息名称,不能重复 + + * @param {string} opts.secretType - 镜像仓库认证信息类型,目前仅支持:docker-registry 类型,用来和docker registry认证的类型。 + + * @param {dockerRegistryData} opts.data - 镜像仓库认证信息数据。<br> +必须包含server、username、password 字段,email 字段是可选的。<br> + + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string secretName + */ + + createSecret (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 createSecret" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createSecret" + ) + } + if (opts.secretType === undefined || opts.secretType === null) { + throw new Error( + "Missing the required parameter 'opts.secretType' when calling createSecret" + ) + } + if (opts.data === undefined || opts.data === null) { + throw new Error( + "Missing the required parameter 'opts.data' when calling createSecret" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.secretType !== undefined && opts.secretType !== null) { + postBody['secretType'] = opts.secretType + } + if (opts.data !== undefined && opts.data !== null) { + postBody['data'] = opts.data + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nativecontainer/2.3.0' + } + + 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 createSecret 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}/secrets', + '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) + } + ) + } + + /** + * 查询单个 secret 详情 + + * @param {Object} opts - parameters + * @param {string} opts.name - Secret Name + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param secret secret + */ + + describeSecret (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 describeSecret" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling describeSecret" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + name: opts.name + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nativecontainer/2.3.0' + } + + 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 describeSecret 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}/secrets/{name}', + '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) + } + ) + } + + /** + * 删除单个 secret + + * @param {Object} opts - parameters + * @param {string} opts.name - Secret Name + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteSecret (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 deleteSecret" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling deleteSecret" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + name: opts.name + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nativecontainer/2.3.0' + } + + 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 deleteSecret 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}/secrets/{name}', + '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) + } + ) + } +} +module.exports = NATIVECONTAINER diff --git a/packages/libs/lib-jdcloud/src/repo/nc/v1/nc.js b/packages/libs/lib-jdcloud/src/repo/nc/v1/nc.js new file mode 100644 index 000000000..371f1f74e --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/nc/v1/nc.js @@ -0,0 +1,1865 @@ +/* + * 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. + * + * 镜像仓库认证信息 + * 关于镜像仓库认证信息的相关接口 + * + * 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 = 'nc' +Service._services[serviceId] = true + +/** + * nc service. + * @version 0.2.5 + */ + +JDCloud.NC = class NC extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'nc.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 批量查询原生容器的详细信息<br> +此接口支持分页查询,默认每页20条。 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 100] optional + * @param {filter} [opts.filters] - containerId - 实例ID,精确匹配,支持多个 +privateIpAddress - 主网卡IP地址,模糊匹配,支持单个 +az - 可用区,精确匹配,支持多个 +vpcId - 私有网络ID,精确匹配,支持多个 +status - 容器状态,精确匹配,支持多个 +name - 实例名称,模糊匹配,支持单个 +subnetId - 镜像ID,模糊匹配,支持单个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param container containers + * @param number totalCount + */ + + describeContainers (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 describeContainers" + ) + } + + 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, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nc/0.2.5' + } + + 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 describeContainers 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 = this.makeRequest( + '/regions/{regionId}/containers', + '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) + } + ) + } + + /** + * 创建一台或多台指定配置容器。 +- 创建容器需要通过实名认证 +- 镜像 + - 容器的镜像通过镜像名称来确定 + - nginx:tag 或 mysql/mysql-server:tag 这样命名的镜像表示 docker hub 官方镜像 + - container-registry/image:tag 这样命名的镜像表示私有仓储的镜像 + - 私有仓储必须兼容 docker registry 认证机制,并通过 secret 来保存机密信息 +- hostname 规范 + - 支持两种方式:以标签方式书写或以完整主机名方式书写 + - 标签规范 + - 0-9,a-z(不分大小写)和 -(减号),其他的都是无效的字符串 + - 不能以减号开始,也不能以减号结尾 + - 最小1个字符,最大63个字符 + - 完整的主机名由一系列标签与点连接组成 + - 标签与标签之间使用“.”(点)进行连接 + - 不能以“.”(点)开始,也不能以“.”(点)结尾 + - 整个主机名(包括标签以及分隔点“.”)最多有63个ASCII字符 +- 网络配置 + - 指定主网卡配置信息 + - 必须指定一个子网 + - 一台云主机创建时必须指定一个安全组,至多指定 5 个安全组 + - 可以指定 elasticIp 规格来约束创建的弹性 IP,带宽取值范围 [1-200]Mbps,步进 1Mbps + - 可以指定网卡的主 IP(primaryIpAddress),该 IP 需要在子网 IP 范围内且未被占用,指定子网 IP 时 maxCount 只能为1 + - 安全组 securityGroup 需与子网 Subnet 在同一个私有网络 VPC 内 + - 主网卡 deviceIndex 设置为 1 +- 存储 + - volume 分为 root volume 和 data volume,root volume 的挂载目录是 /,data volume 的挂载目录可以随意指定 + - volume 的底层存储介质当前只支持 cloud 类别,也就是云硬盘 + - 系统盘 + - 云硬盘类型可以选择 ssd、premium-hdd + - 磁盘大小 + - ssd:范围 [10, 100]GB,步长为 10G + - premium-hdd:范围 [20, 1000]GB,步长为 10G + - 自动删除 + - 云盘默认跟随容器实例自动删除,如果是包年包月的数据盘或共享型数据盘,此参数不生效 + - 可以选择已存在的云硬盘 + - 数据盘 + - 云硬盘类型可以选择 ssd、premium-hdd + - 磁盘大小 + - ssd:范围[20,1000]GB,步长为10G + - premium-hdd:范围[20,3000]GB,步长为10G + - 自动删除 + - 默认自动删除 + - 可以选择已存在的云硬盘 + - 单个容器最多可以挂载 7 个 data volume +- 计费 + - 弹性IP的计费模式,如果选择按用量类型可以单独设置,其它计费模式都以主机为准 + - 云硬盘的计费模式以主机为准 +- 容器日志 + - 默认在本地分配10MB的存储空间,自动 rotate +- 其他 + - 创建完成后,容器状态为running + - maxCount 为最大努力,不保证一定能达到 maxCount + + * @param {Object} opts - parameters + * @param {containerSpec} [opts.containerSpec] - 创建容器规格 optional + * @param {integer} [opts.maxCount] - 购买实例数量;取值范围:[1,100] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string containerIds + */ + + createContainers (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 createContainers" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.containerSpec !== undefined && opts.containerSpec !== null) { + postBody['containerSpec'] = opts.containerSpec + } + if (opts.maxCount !== undefined && opts.maxCount !== null) { + postBody['maxCount'] = opts.maxCount + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nc/0.2.5' + } + + 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 createContainers 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 = this.makeRequest( + '/regions/{regionId}/containers', + '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.containerId - Container ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param container container + */ + + describeContainer (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 describeContainer" + ) + } + + opts = opts || {} + + if (opts.containerId === undefined || opts.containerId === null) { + throw new Error( + "Missing the required parameter 'opts.containerId' when calling describeContainer" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + containerId: opts.containerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nc/0.2.5' + } + + 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 describeContainer 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 = this.makeRequest( + '/regions/{regionId}/containers/{containerId}', + '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) + } + ) + } + + /** + * 容器状态必须为 stopped、running 或 error状态。 <br> +按量付费的实例,如不主动删除将一直运行,不再使用的实例,可通过本接口主动停用。<br> +只能支持主动删除按量计费类型的实例。包年包月过期的容器也可以删除,其它的情况还请发工单系统。计费状态异常的容器无法删除。 + + * @param {Object} opts - parameters + * @param {string} opts.containerId - Container ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteContainer (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 deleteContainer" + ) + } + + opts = opts || {} + + if (opts.containerId === undefined || opts.containerId === null) { + throw new Error( + "Missing the required parameter 'opts.containerId' when calling deleteContainer" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + containerId: opts.containerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nc/0.2.5' + } + + 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 deleteContainer 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 = this.makeRequest( + '/regions/{regionId}/containers/{containerId}', + '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> +容器实例或其绑定的云盘已欠费时,容器将无法正常启动。<br> + + * @param {Object} opts - parameters + * @param {string} opts.containerId - Container ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + startContainer (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 startContainer" + ) + } + + opts = opts || {} + + if (opts.containerId === undefined || opts.containerId === null) { + throw new Error( + "Missing the required parameter 'opts.containerId' when calling startContainer" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + containerId: opts.containerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nc/0.2.5' + } + + 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 startContainer 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 = this.makeRequest( + '/regions/{regionId}/containers/{containerId}:startContainer', + '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.containerId - Container ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + stopContainer (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 stopContainer" + ) + } + + opts = opts || {} + + if (opts.containerId === undefined || opts.containerId === null) { + throw new Error( + "Missing the required parameter 'opts.containerId' when calling stopContainer" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + containerId: opts.containerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nc/0.2.5' + } + + 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 stopContainer 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 = this.makeRequest( + '/regions/{regionId}/containers/{containerId}:stopContainer', + '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.containerId - Container ID + * @param {string} [opts.name] - 容器名称 optional + * @param {string} [opts.description] - 容器描述;和description必须要指定一个 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyContainerAttribute (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 modifyContainerAttribute" + ) + } + + opts = opts || {} + + if (opts.containerId === undefined || opts.containerId === null) { + throw new Error( + "Missing the required parameter 'opts.containerId' when calling modifyContainerAttribute" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + containerId: opts.containerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nc/0.2.5' + } + + 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 modifyContainerAttribute 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 = this.makeRequest( + '/regions/{regionId}/containers/{containerId}:modifyContainerAttribute', + 'PATCH', + 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. <br> +一台云主机只能绑定一个弹性公网 IP(主网卡),若主网卡已存在弹性公网IP,会返回错误。<br> +如果是黑名单中的用户,会返回错误。 + + * @param {Object} opts - parameters + * @param {string} opts.containerId - Container ID + * @param {string} opts.elasticIpId - 弹性IP ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + associateElasticIp (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 associateElasticIp" + ) + } + + opts = opts || {} + + if (opts.containerId === undefined || opts.containerId === null) { + throw new Error( + "Missing the required parameter 'opts.containerId' when calling associateElasticIp" + ) + } + if (opts.elasticIpId === undefined || opts.elasticIpId === null) { + throw new Error( + "Missing the required parameter 'opts.elasticIpId' when calling associateElasticIp" + ) + } + + let postBody = {} + if (opts.elasticIpId !== undefined && opts.elasticIpId !== null) { + postBody['elasticIpId'] = opts.elasticIpId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + containerId: opts.containerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nc/0.2.5' + } + + 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 associateElasticIp 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 = this.makeRequest( + '/regions/{regionId}/containers/{containerId}:associateElasticIp', + '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) + } + ) + } + + /** + * 容器解绑公网 IP,解绑的是主网卡、主内网 IP 对应的弹性 IP. + + * @param {Object} opts - parameters + * @param {string} opts.containerId - Container ID + * @param {string} opts.elasticIpId - 弹性IP ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + disassociateElasticIp (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 disassociateElasticIp" + ) + } + + opts = opts || {} + + if (opts.containerId === undefined || opts.containerId === null) { + throw new Error( + "Missing the required parameter 'opts.containerId' when calling disassociateElasticIp" + ) + } + if (opts.elasticIpId === undefined || opts.elasticIpId === null) { + throw new Error( + "Missing the required parameter 'opts.elasticIpId' when calling disassociateElasticIp" + ) + } + + let postBody = {} + if (opts.elasticIpId !== undefined && opts.elasticIpId !== null) { + postBody['elasticIpId'] = opts.elasticIpId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + containerId: opts.containerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nc/0.2.5' + } + + 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 disassociateElasticIp 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 = this.makeRequest( + '/regions/{regionId}/containers/{containerId}:disassociateElasticIp', + '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.containerId - Container ID + * @param {integer} [opts.tailLines] - 返回日志文件中倒数 tailLines 行,如不指定,默认从容器启动时或 sinceSeconds 指定的时间读取。 + optional + * @param {integer} [opts.sinceSeconds] - 返回相对于当前时间之前sinceSeconds之内的日志。 + optional + * @param {integer} [opts.limitBytes] - 限制返回的日志文件内容字节数,取值范围 [1-4]KB,最大 4KB. + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param object logs + */ + + getLogs (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 getLogs" + ) + } + + opts = opts || {} + + if (opts.containerId === undefined || opts.containerId === null) { + throw new Error( + "Missing the required parameter 'opts.containerId' when calling getLogs" + ) + } + + let postBody = null + let queryParams = {} + if (opts.tailLines !== undefined && opts.tailLines !== null) { + queryParams['tailLines'] = opts.tailLines + } + if (opts.sinceSeconds !== undefined && opts.sinceSeconds !== null) { + queryParams['sinceSeconds'] = opts.sinceSeconds + } + if (opts.limitBytes !== undefined && opts.limitBytes !== null) { + queryParams['limitBytes'] = opts.limitBytes + } + + let pathParams = { + regionId: regionId, + containerId: opts.containerId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nc/0.2.5' + } + + 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 getLogs 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 = this.makeRequest( + '/regions/{regionId}/containers/{containerId}:getLogs', + '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) + } + ) + } + + /** + * 查询资源的配额,支持:原生容器 pod 和 secret. + + * @param {Object} opts - parameters + * @param {string} opts.resourceType - resourceType - 资源类型,支持 [container, pod, secret] + + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param quota quota + */ + + describeQuota (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 describeQuota" + ) + } + + opts = opts || {} + + if (opts.resourceType === undefined || opts.resourceType === null) { + throw new Error( + "Missing the required parameter 'opts.resourceType' when calling describeQuota" + ) + } + + let postBody = null + let queryParams = {} + if (opts.resourceType !== undefined && opts.resourceType !== null) { + queryParams['resourceType'] = opts.resourceType + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nc/0.2.5' + } + + 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 describeQuota 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 = this.makeRequest( + '/regions/{regionId}/quotas', + '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) + } + ) + } + + /** + * 查询 secret 列表。<br> +此接口支持分页查询,默认每页20条。 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 100] optional + * @param {filter} [opts.filters] - name - secret名称,支持模糊搜索 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param secret secrets + * @param number totalCount + */ + + describeSecrets (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 describeSecrets" + ) + } + + 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, this.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nc/0.2.5' + } + + 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 describeSecrets 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 = this.makeRequest( + '/regions/{regionId}/secrets', + '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) + } + ) + } + + /** + * 创建一个 secret,用于存放镜像仓库机密相关信息。 + + * @param {Object} opts - parameters + * @param {string} opts.name - 机密数据名称,不能重复 + + * @param {string} opts.secretType - 机密数据的类型,目前仅支持:docker-registry 类型,用来和docker registry认证的类型。 + + * @param {dockerRegistryData} [opts.data] - 机密的数据。<br> +key 的有效字符包括字母、数字、-、_和.; <br> +value 是 Base64 编码的字符串,不能包含换行符(在 linux 下使用 base64 -w 0选项),每个value长度上限为4KB,整个data的长度不能超过256KB; <br> +必须包含server、username、password 字段,email 字段是可选的。<br> + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string secretName + */ + + createSecret (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 createSecret" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createSecret" + ) + } + if (opts.secretType === undefined || opts.secretType === null) { + throw new Error( + "Missing the required parameter 'opts.secretType' when calling createSecret" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.secretType !== undefined && opts.secretType !== null) { + postBody['secretType'] = opts.secretType + } + if (opts.data !== undefined && opts.data !== null) { + postBody['data'] = opts.data + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nc/0.2.5' + } + + 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 createSecret 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 = this.makeRequest( + '/regions/{regionId}/secrets', + '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) + } + ) + } + + /** + * 查询单个 secret 详情 + + * @param {Object} opts - parameters + * @param {string} opts.name - Secret Name + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param secret secret + */ + + describeSecret (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 describeSecret" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling describeSecret" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + name: opts.name + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nc/0.2.5' + } + + 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 describeSecret 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 = this.makeRequest( + '/regions/{regionId}/secrets/{name}', + '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) + } + ) + } + + /** + * 删除单个 secret + + * @param {Object} opts - parameters + * @param {string} opts.name - Secret Name + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteSecret (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 deleteSecret" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling deleteSecret" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + name: opts.name + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 nc/0.2.5' + } + + 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 deleteSecret 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 = this.makeRequest( + '/regions/{regionId}/secrets/{name}', + '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) + } + ) + } +} +module.exports = JDCloud.NC diff --git a/packages/libs/lib-jdcloud/src/repo/openjrtc/v1/openjrtc.js b/packages/libs/lib-jdcloud/src/repo/openjrtc/v1/openjrtc.js new file mode 100644 index 000000000..7bcd70b48 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/openjrtc/v1/openjrtc.js @@ -0,0 +1,5279 @@ +/* + * 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. + * + * UserRoom + * 用户房间号管理 + * + * 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 = 'openjrtc' +Service._services[serviceId] = true + +/** + * openjrtc service. + * @version 1.1.8 + */ + +class OPENJRTC extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'openjrtc.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 开启语音识别功能 + + * @param {Object} opts - parameters + * @param {string} [opts.appId] - 应用ID optional + * @param {string} [opts.userRoomId] - 业务接入方定义的且在JRTC系统内注册过的房间号 optional + * @param {integer} [opts.asrTaskType] - 语音识别场景 0-全部识别转文字 optional + * @param {string} callback - callback + @return {Object} result + */ + + startAsrTask (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.userRoomId !== undefined && opts.userRoomId !== null) { + postBody['userRoomId'] = opts.userRoomId + } + if (opts.asrTaskType !== undefined && opts.asrTaskType !== null) { + postBody['asrTaskType'] = opts.asrTaskType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 startAsrTask 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( + '/startAsrTask', + '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.appId] - 应用ID optional + * @param {string} [opts.userRoomId] - 业务接入方定义的且在JRTC系统内注册过的房间号 optional + * @param {integer} [opts.asrTaskType] - 语音识别场景 0-全部识别转文字 optional + * @param {string} callback - callback + @return {Object} result + */ + + stopAsrTask (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.userRoomId !== undefined && opts.userRoomId !== null) { + postBody['userRoomId'] = opts.userRoomId + } + if (opts.asrTaskType !== undefined && opts.asrTaskType !== null) { + postBody['asrTaskType'] = opts.asrTaskType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 stopAsrTask 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( + '/stopAsrTask', + '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.pageNumber] - 页码;默认值为 1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认值为 10;取值范围 [10, 100] optional + * @param {string} callback - callback + @return {Object} result + * @param appConentObject resultObject + */ + + describeApps (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 + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 describeApps 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( + '/applications', + '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.appId - 应用ID + * @param {string} callback - callback + @return {Object} result + * @param appInfoObject resultObject + */ + + describeApp (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling describeApp" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 describeApp 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( + '/applications/{appId}', + '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) + } + ) + } + + /** + * 查询应用appKey + + * @param {Object} opts - parameters + * @param {string} opts.appId - 应用ID + * @param {string} callback - callback + @return {Object} result + * @param appKeyInfoObject resultObject + */ + + describeAppKey (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling describeAppKey" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 describeAppKey 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( + '/applications/{appId}:describeAppKey', + '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.roomName] - 房间名称 optional + * @param {string} [opts.appId] - 应用ID optional + * @param {integer} [opts.roomType] - 房间类型 1-小房间(音频单流订阅) 2-大房间(音频固定订阅) optional + * @param {integer} [opts.meetingType] - 会议类型 0-即时会议 1-预约会议 optional + * @param {integer} [opts.peerId] - 用户ID(创建者ID) optional + * @param {string} callback - callback + @return {Object} result + * @param roomInfoObj resultObject + */ + + createRoom (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.roomName !== undefined && opts.roomName !== null) { + postBody['roomName'] = opts.roomName + } + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.roomType !== undefined && opts.roomType !== null) { + postBody['roomType'] = opts.roomType + } + if (opts.meetingType !== undefined && opts.meetingType !== null) { + postBody['meetingType'] = opts.meetingType + } + if (opts.peerId !== undefined && opts.peerId !== null) { + postBody['peerId'] = opts.peerId + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 createRoom 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( + '/createRoom', + '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.appId - 应用ID + * @param {integer} opts.roomId - 房间ID + * @param {string} callback - callback + @return {Object} result + * @param roomInfoObj resultObject + */ + + describeRoomInfo (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling describeRoomInfo" + ) + } + if (opts.roomId === undefined || opts.roomId === null) { + throw new Error( + "Missing the required parameter 'opts.roomId' when calling describeRoomInfo" + ) + } + + let postBody = null + let queryParams = {} + if (opts.roomId !== undefined && opts.roomId !== null) { + queryParams['roomId'] = opts.roomId + } + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 describeRoomInfo 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( + '/rooms/{appId}', + '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.appId - 应用ID + * @param {integer} [opts.roomId] - 房间ID optional + * @param {string} [opts.roomName] - 房间名称 optional + * @param {string} callback - callback + @return {Object} result + * @param roomInfoObj resultObject + */ + + updateRoom (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling updateRoom" + ) + } + + let postBody = {} + if (opts.roomId !== undefined && opts.roomId !== null) { + postBody['roomId'] = opts.roomId + } + if (opts.roomName !== undefined && opts.roomName !== null) { + postBody['roomName'] = opts.roomName + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 updateRoom 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( + '/rooms/{appId}', + '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) + } + ) + } + + /** + * 删除房间 + + * @param {Object} opts - parameters + * @param {string} opts.appId - 应用ID + * @param {integer} opts.roomId - 房间ID + * @param {string} callback - callback + @return {Object} result + */ + + deleteRoom (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling deleteRoom" + ) + } + if (opts.roomId === undefined || opts.roomId === null) { + throw new Error( + "Missing the required parameter 'opts.roomId' when calling deleteRoom" + ) + } + + let postBody = null + let queryParams = {} + if (opts.roomId !== undefined && opts.roomId !== null) { + queryParams['roomId'] = opts.roomId + } + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 deleteRoom 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( + '/rooms/{appId}', + '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) + } + ) + } + + /** + * 查询应用下的房间列表 +允许通过条件过滤查询,支持的过滤字段如下: + - appId[eq] 按应用ID查询 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认值为 1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认值为 10;取值范围 [10, 100] optional + * @param {filter} [opts.filters] - 传参字段描述: + appId: 应用ID + optional + * @param {string} callback - callback + @return {Object} result + * @param roomInfosObj resultObject + */ + + describeRooms (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 openjrtc/1.1.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 describeRooms 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( + '/rooms', + '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.roomId - 房间ID + * @param {string} callback - callback + @return {Object} result + * @param userOnlineNumInfo resultObject + */ + + describeRoomOnlineUserNum (opts, callback) { + opts = opts || {} + + if (opts.roomId === undefined || opts.roomId === null) { + throw new Error( + "Missing the required parameter 'opts.roomId' when calling describeRoomOnlineUserNum" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + roomId: opts.roomId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 describeRoomOnlineUserNum 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( + '/describeRoomOnlineUserNum/{roomId}', + '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.appId - 应用ID + * @param {integer} opts.roomId - 房间ID + * @param {array} [opts.peerIds] - peerId列表,最多支持20个peerId optional + * @param {string} callback - callback + @return {Object} result + */ + + removeRoomUser (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling removeRoomUser" + ) + } + if (opts.roomId === undefined || opts.roomId === null) { + throw new Error( + "Missing the required parameter 'opts.roomId' when calling removeRoomUser" + ) + } + + let postBody = {} + if (opts.peerIds !== undefined && opts.peerIds !== null) { + postBody['peerIds'] = opts.peerIds + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId, + roomId: opts.roomId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 removeRoomUser 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( + '/roomUser/{appId}/removeUser/{roomId}', + '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) + } + ) + } + + /** + * 移除房间内所有人员 + + * @param {Object} opts - parameters + * @param {string} opts.appId - 应用ID + * @param {integer} opts.roomId - 房间ID + * @param {string} callback - callback + @return {Object} result + */ + + removeAllRoomUsers (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling removeAllRoomUsers" + ) + } + if (opts.roomId === undefined || opts.roomId === null) { + throw new Error( + "Missing the required parameter 'opts.roomId' when calling removeAllRoomUsers" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId, + roomId: opts.roomId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 removeAllRoomUsers 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( + '/roomUser/{appId}/removeAll/{roomId}', + '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) + } + ) + } + + /** + * 查询房间人数,通讯时长,最大支持查询7天的数据 +允许通过条件过滤查询,支持的过滤字段如下: + - appId[eq] 按应用ID精确查询(必填) + - userRoomId[eq] 按房间ID精确查询(必填) + - startTime[eq] 开始时间 UTC格式(必填) + - endTime[eq] 截止时间 UTC格式 (必填) + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认值为 1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认值为 10;取值范围 [10, 100] optional + * @param {filter} [opts.filters] - 传参字段描述: + appId: 应用ID (必填) + userRoomId:业务接入方定义的且在JRTC系统内注册过的房间号(必填) + startTime: 房间使用起始时间 UTC (必填) + endTime:房间使用截止时间 UTC (必填) + optional + * @param {string} callback - callback + @return {Object} result + * @param roomUserNumInfos resultObject + */ + + describeOnlineUserNum (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 openjrtc/1.1.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 describeOnlineUserNum 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( + '/describeOnlineUserNum', + '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) + } + ) + } + + /** + * 查询房间用户记录,最大支持查询7天的数据 +允许通过条件过滤查询,支持的过滤字段如下: + - appId[eq] 按应用ID精确查询 (必填) + - startTime[eq] 开始时间 UTC格式 (必填) + - endTime[eq] 截止时间 UTC格式 (必填) + - userRoomId[eq] 按房间ID精确查询(必填) + - userId[eq] 按用户ID精确查询 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认值为 1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认值为 10;取值范围 [10, 100] optional + * @param {filter} [opts.filters] - 传参字段描述: + appId: 应用ID (必填) + startTime: 房间使用起始时间 UTC格式 (必填) + endTime:房间使用截止时间 UTC格式 (必填) + userRoomId:业务接入方定义的且在JRTC系统内注册过的房间号(必填) + userId:业务接入方定义的且在JRTC系统内注册过的用户id + optional + * @param {string} callback - callback + @return {Object} result + * @param roomUserRecordInfo resultObject + */ + + describeUserRecordByRoom (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 openjrtc/1.1.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 describeUserRecordByRoom 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( + '/describeUserRecordByRoom', + '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.appId - 应用ID + * @param {string} opts.userRoomId - 业务接入方定义的且在JRTC系统内注册过的用户房间号 + * @param {string} opts.userId - 业务接入方定义的且在JRTC系统内注册过的用户id + * @param {string} opts.kind - audio/video + * @param {string} opts.type - producer 发布流 consumer 订阅流 + * @param {string} opts.joinTime - 加入时间 UTC格式 + * @param {string} [opts.leaveTime] - 离开时间 UTC格式 optional + * @param {string} [opts.fromUserId] - 业务接入方定义的且在JRTC系统内注册过的用户id type=consumer时选择发送端用户id切换码率 optional + * @param {string} [opts.period] - 粒度 支持 1m 1h 1d optional + * @param {string} callback - callback + @return {Object} result + * @param streamBitRate content + */ + + describeP2pStreamBitRate (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling describeP2pStreamBitRate" + ) + } + if (opts.userRoomId === undefined || opts.userRoomId === null) { + throw new Error( + "Missing the required parameter 'opts.userRoomId' when calling describeP2pStreamBitRate" + ) + } + if (opts.userId === undefined || opts.userId === null) { + throw new Error( + "Missing the required parameter 'opts.userId' when calling describeP2pStreamBitRate" + ) + } + if (opts.kind === undefined || opts.kind === null) { + throw new Error( + "Missing the required parameter 'opts.kind' when calling describeP2pStreamBitRate" + ) + } + if (opts.type === undefined || opts.type === null) { + throw new Error( + "Missing the required parameter 'opts.type' when calling describeP2pStreamBitRate" + ) + } + if (opts.joinTime === undefined || opts.joinTime === null) { + throw new Error( + "Missing the required parameter 'opts.joinTime' when calling describeP2pStreamBitRate" + ) + } + + let postBody = null + let queryParams = {} + if (opts.appId !== undefined && opts.appId !== null) { + queryParams['appId'] = opts.appId + } + if (opts.userRoomId !== undefined && opts.userRoomId !== null) { + queryParams['userRoomId'] = opts.userRoomId + } + if (opts.userId !== undefined && opts.userId !== null) { + queryParams['userId'] = opts.userId + } + if (opts.kind !== undefined && opts.kind !== null) { + queryParams['kind'] = opts.kind + } + if (opts.type !== undefined && opts.type !== null) { + queryParams['type'] = opts.type + } + if (opts.joinTime !== undefined && opts.joinTime !== null) { + queryParams['joinTime'] = opts.joinTime + } + if (opts.leaveTime !== undefined && opts.leaveTime !== null) { + queryParams['leaveTime'] = opts.leaveTime + } + if (opts.fromUserId !== undefined && opts.fromUserId !== null) { + queryParams['fromUserId'] = opts.fromUserId + } + if (opts.period !== undefined && opts.period !== null) { + queryParams['period'] = opts.period + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 describeP2pStreamBitRate 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( + '/describeP2pStreamBitRate', + '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.appId] - 应用ID optional + * @param {string} opts.startTime - 开始时间 UTC格式 + * @param {string} [opts.endTime] - 结束时间 UTC格式 optional + * @param {string} callback - callback + @return {Object} result + * @param callDurationByCodeRate content + */ + + describeCallDurationByCodeRate (opts, callback) { + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeCallDurationByCodeRate" + ) + } + + let postBody = null + let queryParams = {} + if (opts.appId !== undefined && opts.appId !== null) { + queryParams['appId'] = opts.appId + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 describeCallDurationByCodeRate 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( + '/describeCallDurationByCodeRate', + '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) + } + ) + } + + /** + * 获取近7天通讯时长 + + * @param {Object} opts - parameters + * @param {string} callback - callback + @return {Object} result + * @param callDuration content + */ + + describeDailyCallDuration (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 describeDailyCallDuration 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( + '/describeDailyCallDuration', + '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.appId] - 应用ID optional + * @param {string} [opts.userName] - 用户名称 optional + * @param {string} [opts.userId] - 业务接入方的用户ID optional + * @param {boolean} [opts.temporary] - 是否临时用户 optional + * @param {string} callback - callback + @return {Object} result + * @param createUserResultObj resultObject + */ + + createUser (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.userName !== undefined && opts.userName !== null) { + postBody['userName'] = opts.userName + } + if (opts.userId !== undefined && opts.userId !== null) { + postBody['userId'] = opts.userId + } + if (opts.temporary !== undefined && opts.temporary !== null) { + postBody['temporary'] = opts.temporary + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 createUser 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( + '/createUser', + '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) + } + ) + } + + /** + * 查询peer对应的用户信息 + + * @param {Object} opts - parameters + * @param {integer} opts.peerId - peerId + * @param {string} callback - callback + @return {Object} result + * @param userInfoObj resultObject + */ + + describeUserByPeer (opts, callback) { + opts = opts || {} + + if (opts.peerId === undefined || opts.peerId === null) { + throw new Error( + "Missing the required parameter 'opts.peerId' when calling describeUserByPeer" + ) + } + + let postBody = null + let queryParams = {} + if (opts.peerId !== undefined && opts.peerId !== null) { + queryParams['peerId'] = opts.peerId + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 describeUserByPeer 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( + '/describeUserByPeer', + '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.appId] - 应用ID optional + * @param {string} [opts.userRoomId] - 业务接入方定义的且在JRTC系统内注册过的房间号 optional + * @param {integer} [opts.layoutTemplate] - 布局模板-支持参数1 optional + * @param {string} [opts.mainUserId] - 主人员userId optional + * @param {integer} [opts.outputType] - 输出类型 1:录制 2:旁路转推 optional + * @param {string} [opts.outputName] - 输出名称 optional + * @param {array} [opts.mcuUserInfos] - 参与混流人员参数 optional + * @param {outputEncode} [opts.outputEncode] - 输出格式 optional + * @param {string} callback - callback + @return {Object} result + */ + + startMcuTranscode (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.userRoomId !== undefined && opts.userRoomId !== null) { + postBody['userRoomId'] = opts.userRoomId + } + if (opts.layoutTemplate !== undefined && opts.layoutTemplate !== null) { + postBody['layoutTemplate'] = opts.layoutTemplate + } + if (opts.mainUserId !== undefined && opts.mainUserId !== null) { + postBody['mainUserId'] = opts.mainUserId + } + if (opts.outputType !== undefined && opts.outputType !== null) { + postBody['outputType'] = opts.outputType + } + if (opts.outputName !== undefined && opts.outputName !== null) { + postBody['outputName'] = opts.outputName + } + if (opts.mcuUserInfos !== undefined && opts.mcuUserInfos !== null) { + postBody['mcuUserInfos'] = opts.mcuUserInfos + } + if (opts.outputEncode !== undefined && opts.outputEncode !== null) { + postBody['outputEncode'] = opts.outputEncode + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 startMcuTranscode 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( + '/startMcuTranscode', + '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.appId] - 应用ID optional + * @param {string} [opts.userRoomId] - 业务接入方定义的且在JRTC系统内注册过的房间号 optional + * @param {string} callback - callback + @return {Object} result + */ + + stopMcuTranscode (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.userRoomId !== undefined && opts.userRoomId !== null) { + postBody['userRoomId'] = opts.userRoomId + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 stopMcuTranscode 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( + '/stopMcuTask', + '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.appId - 应用ID + * @param {integer} opts.roomId - 房间ID + * @param {string} [opts.eventName] - 事件名称 optional + * @param {string} [opts.message] - 自定义信令消息 optional + * @param {integer} [opts.peerId] - peerId optional + * @param {string} callback - callback + @return {Object} result + */ + + sendMessageToUser (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling sendMessageToUser" + ) + } + if (opts.roomId === undefined || opts.roomId === null) { + throw new Error( + "Missing the required parameter 'opts.roomId' when calling sendMessageToUser" + ) + } + + let postBody = {} + if (opts.eventName !== undefined && opts.eventName !== null) { + postBody['eventName'] = opts.eventName + } + if (opts.message !== undefined && opts.message !== null) { + postBody['message'] = opts.message + } + if (opts.peerId !== undefined && opts.peerId !== null) { + postBody['peerId'] = opts.peerId + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId, + roomId: opts.roomId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 sendMessageToUser 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( + '/message/{appId}/toUser/{roomId}', + '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.appId - 应用ID + * @param {integer} opts.roomId - 房间ID + * @param {string} [opts.eventName] - 事件名称 optional + * @param {string} [opts.message] - 自定义信令消息 optional + * @param {string} callback - callback + @return {Object} result + */ + + sendMessageToRoom (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling sendMessageToRoom" + ) + } + if (opts.roomId === undefined || opts.roomId === null) { + throw new Error( + "Missing the required parameter 'opts.roomId' when calling sendMessageToRoom" + ) + } + + let postBody = {} + if (opts.eventName !== undefined && opts.eventName !== null) { + postBody['eventName'] = opts.eventName + } + if (opts.message !== undefined && opts.message !== null) { + postBody['message'] = opts.message + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId, + roomId: opts.roomId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 sendMessageToRoom 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( + '/message/{appId}/toRoom/{roomId}', + '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.appId] - 应用ID optional + * @param {array} [opts.rules] - 推流规则 optional + * @param {string} callback - callback + @return {Object} result + */ + + addPushStreamRule (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.rules !== undefined && opts.rules !== null) { + postBody['rules'] = opts.rules + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 addPushStreamRule 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( + '/addPushStreamRule', + '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.appId] - 应用ID optional + * @param {array} [opts.rules] - 录制规则 optional + * @param {string} callback - callback + @return {Object} result + */ + + addRecordRule (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.rules !== undefined && opts.rules !== null) { + postBody['rules'] = opts.rules + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 addRecordRule 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( + '/addRecordRule', + '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) + } + ) + } + + /** + * 注册用户-将业务接入方用户体系的userId注册为jrtc系统内可识别和流转的用户id + + * @param {Object} opts - parameters + * @param {string} [opts.appId] - 应用ID optional + * @param {string} [opts.userName] - 用户名称 optional + * @param {string} [opts.userId] - 业务接入方用户体系定义的userId optional + * @param {boolean} [opts.temporary] - 是否临时用户 optional + * @param {string} callback - callback + @return {Object} result + * @param registerUserResultObj resultObject + */ + + registerUser (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.userName !== undefined && opts.userName !== null) { + postBody['userName'] = opts.userName + } + if (opts.userId !== undefined && opts.userId !== null) { + postBody['userId'] = opts.userId + } + if (opts.temporary !== undefined && opts.temporary !== null) { + postBody['temporary'] = opts.temporary + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 registerUser 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( + '/registerUser', + '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.appId - 应用ID + * @param {string} opts.userId - 业务接入方用户体系定义的且在JRTC系统内注册过的userId + * @param {string} callback - callback + @return {Object} result + * @param registerUserInfoObj resultObject + */ + + describeRegisterUser (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling describeRegisterUser" + ) + } + if (opts.userId === undefined || opts.userId === null) { + throw new Error( + "Missing the required parameter 'opts.userId' when calling describeRegisterUser" + ) + } + + let postBody = null + let queryParams = {} + if (opts.userId !== undefined && opts.userId !== null) { + queryParams['userId'] = opts.userId + } + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 describeRegisterUser 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( + '/describeRegisterUser/{appId}', + '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) + } + ) + } + + /** + * 查询注册用户列表 +允许通过条件过滤查询,支持的过滤字段如下: + - startTime[eq] 用户注册时间段开始时间-UTC时间 startTime,endTime同时有值时生效 + - endTime[eq] 用户注册时间段结束时间-UTC时间 startTime,endTime同时有值时生效 + + * @param {Object} opts - parameters + * @param {string} opts.appId - 应用ID + * @param {integer} [opts.pageNumber] - 页码;默认值为 1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认值为 10;取值范围 [10, 100] optional + * @param {filter} [opts.filters] - 传参字段描述: + startTime[eq]: 用户注册时间段开始时间-UTC时间 startTime,endTime同时有值时生效 + endTime[eq]: 用户注册时间段结束时间-UTC时间 startTime,endTime同时有值时生效 + optional + * @param {string} callback - callback + @return {Object} result + * @param registerUserInfosObj resultObject + */ + + describeRegisterUsers (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling describeRegisterUsers" + ) + } + + 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', + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 describeRegisterUsers 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( + '/describeRegisterUsers/{appId}', + '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) + } + ) + } + + /** + * 查询房间内推流信息列表 +允许通过条件过滤查询,支持的过滤字段如下: + - status[eq] 在线状态 1-在线 2-离线 + - kind[eq] 在线状态 1-音频流 2-视频流 100-数据流 + - startTime[eq] 用户推流开始时间-UTC时间 startTime,endTime同时指定时生效 + - endTime[eq] 用户推流结束时间-UTC时间 startTime,endTime同时指定时生效 + + * @param {Object} opts - parameters + * @param {string} opts.appId - 应用ID + * @param {integer} [opts.pageNumber] - 页码;默认值为 1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认值为 10;取值范围 [10, 100] optional + * @param {string} opts.userRoomId - 业务接入方定义的且在JRTC系统内注册过的房间号 + * @param {filter} [opts.filters] - 传参字段描述: +- status[eq] 在线状态 1-在线 2-离线 +- kind[eq] 在线状态 1-音频流 2-视频流 100-数据流 +- startTime[eq] 用户推流开始时间-UTC时间 startTime,endTime同时指定时生效 +- endTime[eq] 用户推流结束时间-UTC时间 startTime,endTime同时指定时生效 + optional + * @param {string} callback - callback + @return {Object} result + * @param roomStreamContent resultObject + */ + + describeStreamInfosByUserRoomId (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling describeStreamInfosByUserRoomId" + ) + } + if (opts.userRoomId === undefined || opts.userRoomId === null) { + throw new Error( + "Missing the required parameter 'opts.userRoomId' when calling describeStreamInfosByUserRoomId" + ) + } + + 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.userRoomId !== undefined && opts.userRoomId !== null) { + queryParams['userRoomId'] = opts.userRoomId + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 describeStreamInfosByUserRoomId 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( + '/describeStreamInfosByUserRoomId/{appId}', + '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.appId - 应用ID + * @param {string} opts.userRoomId - 业务接入方定义的且在JRTC系统内注册过的房间号 + * @param {string} opts.userId - 业务接入方用户体系定义的且在JRTC系统内注册过的userId + * @param {string} callback - callback + @return {Object} result + * @param streamInfo content + */ + + describeStreamInfosByUserId (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling describeStreamInfosByUserId" + ) + } + if (opts.userRoomId === undefined || opts.userRoomId === null) { + throw new Error( + "Missing the required parameter 'opts.userRoomId' when calling describeStreamInfosByUserId" + ) + } + if (opts.userId === undefined || opts.userId === null) { + throw new Error( + "Missing the required parameter 'opts.userId' when calling describeStreamInfosByUserId" + ) + } + + let postBody = null + let queryParams = {} + if (opts.userRoomId !== undefined && opts.userRoomId !== null) { + queryParams['userRoomId'] = opts.userRoomId + } + if (opts.userId !== undefined && opts.userId !== null) { + queryParams['userId'] = opts.userId + } + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 describeStreamInfosByUserId 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( + '/describeStreamInfosByUserId/{appId}', + '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) + } + ) + } + + /** + * 根据流ID查询推流信息 + + * @param {Object} opts - parameters + * @param {string} opts.appId - 应用ID + * @param {string} opts.streamId - 流ID + * @param {string} callback - callback + @return {Object} result + * @param streamInfo resultObject + */ + + describeStreamInfoByStreamId (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling describeStreamInfoByStreamId" + ) + } + if (opts.streamId === undefined || opts.streamId === null) { + throw new Error( + "Missing the required parameter 'opts.streamId' when calling describeStreamInfoByStreamId" + ) + } + + let postBody = null + let queryParams = {} + if (opts.streamId !== undefined && opts.streamId !== null) { + queryParams['streamId'] = opts.streamId + } + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 describeStreamInfoByStreamId 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( + '/describeStreamInfoByStreamId/{appId}', + '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) + } + ) + } + + /** + * 查询指定用户在房间内的推流历史记录 +允许通过条件过滤查询,支持的过滤字段如下: + - kind[eq] 在线状态 1-音频流 2-视频流 100-数据流 + - startTime[eq] 用户推流开始时间-UTC时间 startTime,endTime同时指定时生效 + - endTime[eq] 用户推流结束时间-UTC时间 startTime,endTime同时指定时生效 + + * @param {Object} opts - parameters + * @param {string} opts.appId - 应用ID + * @param {integer} [opts.pageNumber] - 页码;默认值为 1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认值为 10;取值范围 [10, 100] optional + * @param {string} opts.userRoomId - 业务接入方定义的且在JRTC系统内注册过的房间号 + * @param {string} opts.userId - 业务接入方用户体系定义的且在JRTC系统内注册过的userId + * @param {filter} [opts.filters] - 传参字段描述: +- kind[eq] 在线状态 1-音频流 2-视频流 100-数据流 +- startTime[eq] 用户推流开始时间-UTC时间 startTime,endTime同时指定时生效 +- endTime[eq] 用户推流结束时间-UTC时间 startTime,endTime同时指定时生效 + optional + * @param {string} callback - callback + @return {Object} result + * @param streamRecordContent resultObject + */ + + describeStreamRecordsByUserId (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling describeStreamRecordsByUserId" + ) + } + if (opts.userRoomId === undefined || opts.userRoomId === null) { + throw new Error( + "Missing the required parameter 'opts.userRoomId' when calling describeStreamRecordsByUserId" + ) + } + if (opts.userId === undefined || opts.userId === null) { + throw new Error( + "Missing the required parameter 'opts.userId' when calling describeStreamRecordsByUserId" + ) + } + + 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.userRoomId !== undefined && opts.userRoomId !== null) { + queryParams['userRoomId'] = opts.userRoomId + } + if (opts.userId !== undefined && opts.userId !== null) { + queryParams['userId'] = opts.userId + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 describeStreamRecordsByUserId 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( + '/describeStreamRecordsByUserId/{appId}', + '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) + } + ) + } + + /** + * 根据流ID查询推流历史记录 +允许通过条件过滤查询,支持的过滤字段如下: + - startTime[eq] 用户推流开始时间-UTC时间 startTime,endTime同时指定时生效 + - endTime[eq] 用户推流结束时间-UTC时间 startTime,endTime同时指定时生效 + + * @param {Object} opts - parameters + * @param {string} opts.appId - 应用ID + * @param {integer} [opts.pageNumber] - 页码;默认值为 1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认值为 10;取值范围 [10, 100] optional + * @param {string} opts.streamId - 流ID + * @param {filter} [opts.filters] - 传参字段描述: +- startTime[eq] 用户推流开始时间-UTC时间 startTime,endTime同时指定时生效 +- endTime[eq] 用户推流结束时间-UTC时间 startTime,endTime同时指定时生效 + optional + * @param {string} callback - callback + @return {Object} result + * @param streamRecordContent resultObject + */ + + describeStreamRecordsByStreamId (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling describeStreamRecordsByStreamId" + ) + } + if (opts.streamId === undefined || opts.streamId === null) { + throw new Error( + "Missing the required parameter 'opts.streamId' when calling describeStreamRecordsByStreamId" + ) + } + + 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.streamId !== undefined && opts.streamId !== null) { + queryParams['streamId'] = opts.streamId + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 describeStreamRecordsByStreamId 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( + '/describeStreamRecordsByStreamId/{appId}', + '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.appId - 应用ID + * @param {string} [opts.userRoomId] - 业务接入方定义的且在JRTC系统内注册过的房间号 optional + * @param {array} [opts.userIds] - 接入方定义的userId列表,最多支持20个userId optional + * @param {string} callback - callback + @return {Object} result + */ + + removeUserByUserRoomId (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling removeUserByUserRoomId" + ) + } + + let postBody = {} + if (opts.userRoomId !== undefined && opts.userRoomId !== null) { + postBody['userRoomId'] = opts.userRoomId + } + if (opts.userIds !== undefined && opts.userIds !== null) { + postBody['userIds'] = opts.userIds + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 removeUserByUserRoomId 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( + '/removeUserByUserRoomId/{appId}', + '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.appId - 应用ID + * @param {string} [opts.userRoomId] - 业务接入方定义的且在JRTC系统内注册过的房间号 optional + * @param {string} callback - callback + @return {Object} result + */ + + removeAllUsersByUserRoomId (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling removeAllUsersByUserRoomId" + ) + } + + let postBody = {} + if (opts.userRoomId !== undefined && opts.userRoomId !== null) { + postBody['userRoomId'] = opts.userRoomId + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 removeAllUsersByUserRoomId 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( + '/removeAllUsersByUserRoomId/{appId}', + '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) + } + ) + } + + /** + * 查询房间内人员列表 +允许通过条件过滤查询,支持的过滤字段如下: + - status[eq] 在线状态 1-在线 2-离线 + - startTime[eq] 用户加入时间段开始时间-UTC时间 startTime,endTime同时有值时生效 + - endTime[eq] 用户加入时间段结束时间-UTC时间 startTime,endTime同时有值时生效 + + * @param {Object} opts - parameters + * @param {string} opts.appId - 应用ID + * @param {integer} [opts.pageNumber] - 页码;默认值为 1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认值为 10;取值范围 [10, 100] optional + * @param {string} opts.userRoomId - 业务接入方定义的且在JRTC系统内注册过的房间号 + * @param {filter} [opts.filters] - 传参字段描述: +- status[eq] 在线状态 1-在线 2-离线 +- startTime[eq] 用户加入时间段开始时间-UTC时间 startTime,endTime同时有值时生效 +- endTime[eq] 用户加入时间段结束时间-UTC时间 startTime,endTime同时有值时生效 + optional + * @param {string} callback - callback + @return {Object} result + * @param roomUserInfosObj resultObject + */ + + describeRoomUsers (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling describeRoomUsers" + ) + } + if (opts.userRoomId === undefined || opts.userRoomId === null) { + throw new Error( + "Missing the required parameter 'opts.userRoomId' when calling describeRoomUsers" + ) + } + + 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.userRoomId !== undefined && opts.userRoomId !== null) { + queryParams['userRoomId'] = opts.userRoomId + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 describeRoomUsers 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( + '/describeRoomUsers/{appId}', + '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.appId - 应用ID + * @param {string} opts.userRoomId - 业务接入方定义的且在JRTC系统内注册过的房间号 + * @param {string} opts.userId - 业务接入方用户体系定义的且在JRTC系统内注册过的userId + * @param {string} callback - callback + @return {Object} result + * @param roomUserInfoObj resultObject + */ + + describeRoomUser (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling describeRoomUser" + ) + } + if (opts.userRoomId === undefined || opts.userRoomId === null) { + throw new Error( + "Missing the required parameter 'opts.userRoomId' when calling describeRoomUser" + ) + } + if (opts.userId === undefined || opts.userId === null) { + throw new Error( + "Missing the required parameter 'opts.userId' when calling describeRoomUser" + ) + } + + let postBody = null + let queryParams = {} + if (opts.userRoomId !== undefined && opts.userRoomId !== null) { + queryParams['userRoomId'] = opts.userRoomId + } + if (opts.userId !== undefined && opts.userId !== null) { + queryParams['userId'] = opts.userId + } + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 describeRoomUser 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( + '/describeRoomUser/{appId}', + '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.appId - 应用ID + * @param {string} opts.userRoomId - 业务接入方定义的且在JRTC系统内注册过的房间号 + * @param {string} callback - callback + @return {Object} result + * @param roomUsersNumInfoObj resultObject + */ + + describeRoomUsersNum (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling describeRoomUsersNum" + ) + } + if (opts.userRoomId === undefined || opts.userRoomId === null) { + throw new Error( + "Missing the required parameter 'opts.userRoomId' when calling describeRoomUsersNum" + ) + } + + let postBody = null + let queryParams = {} + if (opts.userRoomId !== undefined && opts.userRoomId !== null) { + queryParams['userRoomId'] = opts.userRoomId + } + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 describeRoomUsersNum 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( + '/describeRoomUsersNum/{appId}', + '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.appId - 应用ID + * @param {string} [opts.userRoomId] - 业务接入方定义的且在JRTC系统内注册过的房间号 optional + * @param {string} [opts.userId] - 业务接入方用户体系定义的且在JRTC系统内注册过的userId optional + * @param {string} [opts.streamId] - 要关闭的流ID optional + * @param {string} callback - callback + @return {Object} result + */ + + closeRoomUserStream (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling closeRoomUserStream" + ) + } + + let postBody = {} + if (opts.userRoomId !== undefined && opts.userRoomId !== null) { + postBody['userRoomId'] = opts.userRoomId + } + if (opts.userId !== undefined && opts.userId !== null) { + postBody['userId'] = opts.userId + } + if (opts.streamId !== undefined && opts.streamId !== null) { + postBody['streamId'] = opts.streamId + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 closeRoomUserStream 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( + '/closeRoomUserStream/{appId}', + '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) + } + ) + } + + /** + * 生成token-用户加入房间时携带token校验通过后方能加入 + + * @param {Object} opts - parameters + * @param {string} [opts.appId] - appId optional + * @param {string} [opts.appKey] - appKey optional + * @param {string} [opts.userId] - 用户id optional + * @param {string} [opts.userRoomId] - 业务接入方定义的且在JRTC系统内注册过的房间号 optional + * @param {integer} [opts.timestamp] - 时间戳-毫秒 optional + * @param {string} callback - callback + @return {Object} result + * @param tokenInfo resultObject + */ + + createToken (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.appKey !== undefined && opts.appKey !== null) { + postBody['appKey'] = opts.appKey + } + if (opts.userId !== undefined && opts.userId !== null) { + postBody['userId'] = opts.userId + } + if (opts.userRoomId !== undefined && opts.userRoomId !== null) { + postBody['userRoomId'] = opts.userRoomId + } + if (opts.timestamp !== undefined && opts.timestamp !== null) { + postBody['timestamp'] = opts.timestamp + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 createToken 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( + '/createToken', + '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.appId] - 应用ID optional + * @param {string} [opts.userRoomId] - 业务接入方定义的且在JRTC系统内注册过的房间号 optional + * @param {string} [opts.eventName] - 事件名称 optional + * @param {string} [opts.message] - 自定义信令消息 optional + * @param {string} callback - callback + @return {Object} result + */ + + postMessageToUserRoom (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.userRoomId !== undefined && opts.userRoomId !== null) { + postBody['userRoomId'] = opts.userRoomId + } + if (opts.eventName !== undefined && opts.eventName !== null) { + postBody['eventName'] = opts.eventName + } + if (opts.message !== undefined && opts.message !== null) { + postBody['message'] = opts.message + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 postMessageToUserRoom 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( + '/postMessageToUserRoom', + '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.appId] - 应用ID optional + * @param {string} [opts.userRoomId] - 业务接入方定义的且在JRTC系统内注册过的房间号 optional + * @param {string} [opts.userId] - 业务接入方用户体系定义的且在JRTC系统内注册过的userId optional + * @param {string} [opts.eventName] - 事件名称 optional + * @param {string} [opts.message] - 自定义信令消息 optional + * @param {string} callback - callback + @return {Object} result + */ + + postMessageToUser (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.userRoomId !== undefined && opts.userRoomId !== null) { + postBody['userRoomId'] = opts.userRoomId + } + if (opts.userId !== undefined && opts.userId !== null) { + postBody['userId'] = opts.userId + } + if (opts.eventName !== undefined && opts.eventName !== null) { + postBody['eventName'] = opts.eventName + } + if (opts.message !== undefined && opts.message !== null) { + postBody['message'] = opts.message + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 postMessageToUser 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( + '/postMessageToUser', + '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) + } + ) + } + + /** + * 注册用户房间号-将业务接入方定义的userRoomId注册为jrtc系统内可识别和流转的房间号 + + * @param {Object} opts - parameters + * @param {string} [opts.userRoomId] - 业务接入方定义的房间号 optional + * @param {string} [opts.roomName] - 房间名称 optional + * @param {string} [opts.appId] - 应用ID optional + * @param {integer} [opts.roomType] - 房间类型 1-小房间(音频单流订阅) 2-大房间(音频固定订阅),默认取控制台APP对应的房间类型 optional + * @param {string} callback - callback + @return {Object} result + * @param userRoomInfoObj resultObject + */ + + registerUserRoom (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.userRoomId !== undefined && opts.userRoomId !== null) { + postBody['userRoomId'] = opts.userRoomId + } + if (opts.roomName !== undefined && opts.roomName !== null) { + postBody['roomName'] = opts.roomName + } + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.roomType !== undefined && opts.roomType !== null) { + postBody['roomType'] = opts.roomType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 registerUserRoom 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( + '/registerUserRoom', + '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.appId - 应用ID + * @param {string} [opts.userRoomId] - 用户房间号 optional + * @param {string} [opts.roomName] - 房间名称 optional + * @param {integer} [opts.roomType] - 房间类型 1-小房间;2-大房间 optional + * @param {string} callback - callback + @return {Object} result + * @param userRoomInfoObj resultObject + */ + + updateUserRoom (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling updateUserRoom" + ) + } + + let postBody = {} + if (opts.userRoomId !== undefined && opts.userRoomId !== null) { + postBody['userRoomId'] = opts.userRoomId + } + if (opts.roomName !== undefined && opts.roomName !== null) { + postBody['roomName'] = opts.roomName + } + if (opts.roomType !== undefined && opts.roomType !== null) { + postBody['roomType'] = opts.roomType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 updateUserRoom 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( + '/updateUserRoom/{appId}', + '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) + } + ) + } + + /** + * 查询注册房间号 + + * @param {Object} opts - parameters + * @param {string} opts.appId - 应用ID + * @param {string} opts.userRoomId - 业务接入方定义的且在JRTC系统内注册过的房间号 + * @param {string} callback - callback + @return {Object} result + * @param userRoomInfoObj resultObject + */ + + describeUserRoom (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling describeUserRoom" + ) + } + if (opts.userRoomId === undefined || opts.userRoomId === null) { + throw new Error( + "Missing the required parameter 'opts.userRoomId' when calling describeUserRoom" + ) + } + + let postBody = null + let queryParams = {} + if (opts.userRoomId !== undefined && opts.userRoomId !== null) { + queryParams['userRoomId'] = opts.userRoomId + } + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 describeUserRoom 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( + '/describeUserRoom/{appId}', + '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) + } + ) + } + + /** + * 查询注册房间号列表 +允许通过条件过滤查询,支持的过滤字段如下: + - startTime[eq] 房间注册时间段开始时间-UTC时间 startTime,endTime同时有值时生效 + - endTime[eq] 房间注册时间段结束时间-UTC时间 startTime,endTime同时有值时生效 + + * @param {Object} opts - parameters + * @param {string} opts.appId - 应用ID + * @param {integer} [opts.pageNumber] - 页码;默认值为 1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认值为 10;取值范围 [10, 100] optional + * @param {filter} [opts.filters] - 传参字段描述: + - startTime[eq] 按房间注册时间段查询-UTC时间 startTime,endTime同时有值时生效 + - endTime[eq] 按房间注册时间段查询-UTC时间 startTime,endTime同时有值时生效 + optional + * @param {string} callback - callback + @return {Object} result + * @param userRoomInfosObj resultObject + */ + + describeUserRooms (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling describeUserRooms" + ) + } + + 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', + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 openjrtc/1.1.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 describeUserRooms 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( + '/describeUserRooms/{appId}', + '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 = OPENJRTC diff --git a/packages/libs/lib-jdcloud/src/repo/oss/v1/oss.js b/packages/libs/lib-jdcloud/src/repo/oss/v1/oss.js new file mode 100644 index 000000000..1dc38f584 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/oss/v1/oss.js @@ -0,0 +1,486 @@ +/* + * 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. + * + * OSS相关接口 + * OSS相关接口 + * + * 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 = 'oss' +Service._services[serviceId] = true + +/** + * oss service. + * @version 0.2.2 + */ + +JDCloud.OSS = class OSS extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'oss.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 列出当前用户的所有bucket + + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param user owner + * @param bucket buckets + */ + + listBuckets (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 listBuckets" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 oss/0.2.2' + } + + 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 listBuckets 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 = this.makeRequest( + '/regions/{regionId}/buckets', + '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) + } + ) + } + + /** + * 创建bucket + + * @param {Object} opts - parameters + * @param {string} opts.bucketname - bucket名字,例如:test-bucket + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + putBucket (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 putBucket" + ) + } + + opts = opts || {} + + if (opts.bucketname === undefined || opts.bucketname === null) { + throw new Error( + "Missing the required parameter 'opts.bucketname' when calling putBucket" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + bucketname: opts.bucketname + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 oss/0.2.2' + } + + 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 putBucket 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 = this.makeRequest( + '/regions/{regionId}/buckets/{bucketname}', + '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) + } + ) + } + + /** + * 删除一个bucket + + * @param {Object} opts - parameters + * @param {string} opts.bucketname - bucket名字,例如:test-bucket + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteBucket (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 deleteBucket" + ) + } + + opts = opts || {} + + if (opts.bucketname === undefined || opts.bucketname === null) { + throw new Error( + "Missing the required parameter 'opts.bucketname' when calling deleteBucket" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + bucketname: opts.bucketname + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 oss/0.2.2' + } + + 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 deleteBucket 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 = this.makeRequest( + '/regions/{regionId}/buckets/{bucketname}', + '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) + } + ) + } + + /** + * 查询bucket是否存在 + + * @param {Object} opts - parameters + * @param {string} opts.bucketname - bucket名字,例如:test-bucket + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + headBucket (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 headBucket" + ) + } + + opts = opts || {} + + if (opts.bucketname === undefined || opts.bucketname === null) { + throw new Error( + "Missing the required parameter 'opts.bucketname' when calling headBucket" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + bucketname: opts.bucketname + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 oss/0.2.2' + } + + 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 headBucket 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 = this.makeRequest( + '/regions/{regionId}/buckets/{bucketname}', + 'HEAD', + 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 = JDCloud.OSS diff --git a/packages/libs/lib-jdcloud/src/repo/ossopenapi/v1/ossopenapi.js b/packages/libs/lib-jdcloud/src/repo/ossopenapi/v1/ossopenapi.js new file mode 100644 index 000000000..344bd12dc --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/ossopenapi/v1/ossopenapi.js @@ -0,0 +1,1320 @@ +/* + * 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. + * + * vpc policy openapi v1 + * vpc policy openapi v1 + * + * 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 = 'ossopenapi' +Service._services[serviceId] = true + +/** + * ossopenapi service. + * @version 0.9.7 + */ + +class OSSOPENAPI extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'ossopenapi.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 根据type获取bucket用量数据 + * @param {Object} opts - parameters + * @param {array} [opts.capacityTypes] - <p>查询用量数据类型:</p><br><code>1000040</code>:标准存储<br><code>1000041</code>:低冗余存储<br><code>1000042</code>:归档存储<br><code>1000043</code>归档overHead存储:<br><code>1000044</code>低频存储:<br><code>1000045</code>低频overHead存储:<br><code>1</code>:内网GET流量<br><code>2</code>:内网HEAD流量<br><code>3</code>:内网PUT流量<br><code>4</code>:内网POST流量<br><code>5</code>:内网DELETE流量<br><code>6</code>:内网OPTIONS流量<br><code>7</code>:内网TRACE流量<br><code>11</code>:外网GET流量<br><code>12</code>:外网HEAD流量<br><code>13</code>:外网PUT流量<br><code>14</code>:外网POST流量<br><code>15</code>:外网DELETE流量<br><code>16</code>:外网OPTIONS流量<br><code>17</code>:外网TRACE流量<br><code>21</code>:CDN GET流量<br><code>22</code>:CDN HEAD流量<br><code>23</code>:CDN PUT流量<br><code>24</code>:CDN POST流量<br><code>25</code>:CDN DELETE流量<br><code>26</code>:CDN OPTIONS流量<br><code>27</code>:CDN TRACE流量<br><code>31</code>:内网GET数<br><code>32</code>:内网HEAD数<br><code>33</code>:内网PUT数<br><code>34</code>:内网POST数<br><code>35</code>:内网DELETE数<br><code>36</code>:内网OPTIONS数<br><code>37</code>:内网TRACE数<br><code>51</code>:外网GET数<br><code>52</code>:外网HEAD数<br><code>53</code>:外网PUT数<br><code>54</code>:外网POST数<br><code>55</code>:外网DELETE数<br><code>56</code>:外网OPTIONS数<br><code>57</code>:外网TRACE数<br><code>61</code>:CDN GET数<br><code>62</code>:CDN HEAD数<br><code>63</code>:CDN PUT数<br><code>64</code>:CDN POST数<br><code>65</code>:CDN DELETE数<br><code>66</code>:CDN OPTIONS数<br><code>67</code>:CDN TRACE数<br><code>71</code>:归档提前删除<br><code>72</code>:低频提前删除<br><code>81</code>:归档取回Bulk<br><code>82</code>:归档取回Std<br><code>83</code>:归档取回Exp<br><code>84</code>:低频数据取回 + optional + * @param {string} [opts.beginTime] - 开始时间,使用UTC时间,格式为:YYYY-MM-DDTHH:mm:ss'Z' optional + * @param {string} [opts.endTime] - 结束时间,使用UTC时间,格式为:YYYY-MM-DDTHH:mm:ss'Z' optional + * @param {integer} [opts.periodType] - 查询数据的聚合方式:<br><code>0</code>:all, 最大查询区间365天 <br><code>1</code>:hour,最大查询区间31天。默认1<br><code>2</code>:day, 最大查询区间365天。 optional + * @param {integer} opts.method - 返回数据的方式: <code>1</code>:recent(区间值), <code>2</code>:current(当前值。method = 2 时如果查询当前值时传入beginTime,则按照beginTime时间来进行查询;如果不传beginTime,则按照后端系统时间查询。) + * @param {array} [opts.bucketNames] - 查询的bucket Names。如果查询用户全部Bucket,则不传 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param bucketCapacityQueryResult bucketCapacityQueryResult + */ + + getBucketCapacity (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 getBucketCapacity" + ) + } + + opts = opts || {} + + if (opts.method === undefined || opts.method === null) { + throw new Error( + "Missing the required parameter 'opts.method' when calling getBucketCapacity" + ) + } + + let postBody = {} + if (opts.capacityTypes !== undefined && opts.capacityTypes !== null) { + postBody['capacityTypes'] = opts.capacityTypes + } + if (opts.beginTime !== undefined && opts.beginTime !== null) { + postBody['beginTime'] = opts.beginTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.periodType !== undefined && opts.periodType !== null) { + postBody['periodType'] = opts.periodType + } + if (opts.method !== undefined && opts.method !== null) { + postBody['method'] = opts.method + } + if (opts.bucketNames !== undefined && opts.bucketNames !== null) { + postBody['bucketNames'] = opts.bucketNames + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ossopenapi/0.9.7' + } + + 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 getBucketCapacity 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}/capacity/', + '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) + } + ) + } + + /** + * 根据type获取指定bucket用量数据 + * @param {Object} opts - parameters + * @param {string} opts.bucketName - 查询用量的指定bucket + * @param {array} [opts.capacityTypes] - <p>查询用量数据类型:</p><br><code>1000040</code>:标准存储<br><code>1000041</code>:低冗余存储<br><code>1000042</code>:归档存储<br><code>1000043</code>归档overHead存储:<br><code>1000044</code>低频存储:<br><code>1000045</code>低频overHead存储:<br><code>1</code>:内网GET流量<br><code>2</code>:内网HEAD流量<br><code>3</code>:内网PUT流量<br><code>4</code>:内网POST流量<br><code>5</code>:内网DELETE流量<br><code>6</code>:内网OPTIONS流量<br><code>7</code>:内网TRACE流量<br><code>11</code>:外网GET流量<br><code>12</code>:外网HEAD流量<br><code>13</code>:外网PUT流量<br><code>14</code>:外网POST流量<br><code>15</code>:外网DELETE流量<br><code>16</code>:外网OPTIONS流量<br><code>17</code>:外网TRACE流量<br><code>21</code>:CDN GET流量<br><code>22</code>:CDN HEAD流量<br><code>23</code>:CDN PUT流量<br><code>24</code>:CDN POST流量<br><code>25</code>:CDN DELETE流量<br><code>26</code>:CDN OPTIONS流量<br><code>27</code>:CDN TRACE流量<br><code>31</code>:内网GET数<br><code>32</code>:内网HEAD数<br><code>33</code>:内网PUT数<br><code>34</code>:内网POST数<br><code>35</code>:内网DELETE数<br><code>36</code>:内网OPTIONS数<br><code>37</code>:内网TRACE数<br><code>51</code>:外网GET数<br><code>52</code>:外网HEAD数<br><code>53</code>:外网PUT数<br><code>54</code>:外网POST数<br><code>55</code>:外网DELETE数<br><code>56</code>:外网OPTIONS数<br><code>57</code>:外网TRACE数<br><code>61</code>:CDN GET数<br><code>62</code>:CDN HEAD数<br><code>63</code>:CDN PUT数<br><code>64</code>:CDN POST数<br><code>65</code>:CDN DELETE数<br><code>66</code>:CDN OPTIONS数<br><code>67</code>:CDN TRACE数<br><code>71</code>:归档提前删除<br><code>72</code>:低频提前删除<br><code>81</code>:归档取回Bulk<br><code>82</code>:归档取回Std<br><code>83</code>:归档取回Exp<br><code>84</code>:低频数据取回 + optional + * @param {string} [opts.beginTime] - 开始时间,使用UTC时间,格式为:YYYY-MM-DDTHH:mm:ss'Z' optional + * @param {string} [opts.endTime] - 结束时间,使用UTC时间,格式为:YYYY-MM-DDTHH:mm:ss'Z' optional + * @param {integer} [opts.periodType] - 查询数据的聚合方式:<br><code>0</code>:all, 最大查询区间365天 <br><code>1</code>:hour,最大查询区间31天。默认1<br><code>2</code>:day, 最大查询区间365天。 optional + * @param {integer} opts.method - 返回数据的方式: <code>1</code>:recent(区间值), <code>2</code>:current(当前值。method = 2 时如果查询当前值时传入beginTime,则按照beginTime时间来进行查询;如果不传beginTime,则按照后端系统时间查询。) + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param bucketCapacityQueryResult bucketCapacityQueryResult + */ + + getSingleBucketCapacity (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 getSingleBucketCapacity" + ) + } + + opts = opts || {} + + if (opts.bucketName === undefined || opts.bucketName === null) { + throw new Error( + "Missing the required parameter 'opts.bucketName' when calling getSingleBucketCapacity" + ) + } + if (opts.method === undefined || opts.method === null) { + throw new Error( + "Missing the required parameter 'opts.method' when calling getSingleBucketCapacity" + ) + } + + let postBody = {} + if (opts.capacityTypes !== undefined && opts.capacityTypes !== null) { + postBody['capacityTypes'] = opts.capacityTypes + } + if (opts.beginTime !== undefined && opts.beginTime !== null) { + postBody['beginTime'] = opts.beginTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + if (opts.periodType !== undefined && opts.periodType !== null) { + postBody['periodType'] = opts.periodType + } + if (opts.method !== undefined && opts.method !== null) { + postBody['method'] = opts.method + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + bucketName: opts.bucketName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ossopenapi/0.9.7' + } + + 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 getSingleBucketCapacity 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}/capacity/{bucketName}', + '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.bucketName - Bucket名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param bucketBackSourceConfiguration bucketBackSourceConfiguration + */ + + getBackSourceConfiguration (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 getBackSourceConfiguration" + ) + } + + opts = opts || {} + + if (opts.bucketName === undefined || opts.bucketName === null) { + throw new Error( + "Missing the required parameter 'opts.bucketName' when calling getBackSourceConfiguration" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + bucketName: opts.bucketName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ossopenapi/0.9.7' + } + + 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 getBackSourceConfiguration 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}/buckets/{bucketName}/backSource', + '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.bucketName - Bucket名称 + * @param {array} [opts.backSourceRules] - 回源配置规则 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + putBackSourceConfiguration (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 putBackSourceConfiguration" + ) + } + + opts = opts || {} + + if (opts.bucketName === undefined || opts.bucketName === null) { + throw new Error( + "Missing the required parameter 'opts.bucketName' when calling putBackSourceConfiguration" + ) + } + + let postBody = {} + if (opts.backSourceRules !== undefined && opts.backSourceRules !== null) { + postBody['backSourceRules'] = opts.backSourceRules + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + bucketName: opts.bucketName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ossopenapi/0.9.7' + } + + 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 putBackSourceConfiguration 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}/buckets/{bucketName}/backSource', + '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) + } + ) + } + + /** + * 删除回源配置 + * @param {Object} opts - parameters + * @param {string} opts.bucketName - Bucket名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteBackSourceConfiguration ( + 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 deleteBackSourceConfiguration" + ) + } + + opts = opts || {} + + if (opts.bucketName === undefined || opts.bucketName === null) { + throw new Error( + "Missing the required parameter 'opts.bucketName' when calling deleteBackSourceConfiguration" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + bucketName: opts.bucketName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ossopenapi/0.9.7' + } + + 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 deleteBackSourceConfiguration 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}/buckets/{bucketName}/backSource', + '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) + } + ) + } + + /** + * 根据bucket名称获取该bucket下的同步任务 + * @param {Object} opts - parameters + * @param {string} opts.bucketName - Bucket名称 + * @param {string} opts.taskId - 任务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param historyReplicationTaskInfo historyReplicationTaskInfo + */ + + getHistoricalReplicatTask (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 getHistoricalReplicatTask" + ) + } + + opts = opts || {} + + if (opts.bucketName === undefined || opts.bucketName === null) { + throw new Error( + "Missing the required parameter 'opts.bucketName' when calling getHistoricalReplicatTask" + ) + } + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling getHistoricalReplicatTask" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + bucketName: opts.bucketName, + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ossopenapi/0.9.7' + } + + 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 getHistoricalReplicatTask 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}/buckets/{bucketName}/historical_replicat_task/{taskId}', + '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) + } + ) + } + + /** + * 停止bucket名称获取该bucket下的同步任务 + * @param {Object} opts - parameters + * @param {string} opts.bucketName - Bucket名称 + * @param {string} opts.taskId - 任务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + abortHistoricalReplicatTask (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 abortHistoricalReplicatTask" + ) + } + + opts = opts || {} + + if (opts.bucketName === undefined || opts.bucketName === null) { + throw new Error( + "Missing the required parameter 'opts.bucketName' when calling abortHistoricalReplicatTask" + ) + } + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling abortHistoricalReplicatTask" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + bucketName: opts.bucketName, + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ossopenapi/0.9.7' + } + + 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 abortHistoricalReplicatTask 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}/buckets/{bucketName}/historical_replicat_task/{taskId}/abort', + '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) + } + ) + } + + /** + * 根据bucket名称获取该bucket下的同步任务列表 + * @param {Object} opts - parameters + * @param {string} opts.bucketName - Bucket名称 + * @param {string} [opts.marker] - 同步任务列表开始的key optional + * @param {integer} [opts.limit] - 每次查询返回的结果数,默认为1000 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param listResult listResult + */ + + listHistoricalReplicatTasks (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 listHistoricalReplicatTasks" + ) + } + + opts = opts || {} + + if (opts.bucketName === undefined || opts.bucketName === null) { + throw new Error( + "Missing the required parameter 'opts.bucketName' when calling listHistoricalReplicatTasks" + ) + } + + let postBody = null + let queryParams = {} + if (opts.marker !== undefined && opts.marker !== null) { + queryParams['marker'] = opts.marker + } + if (opts.limit !== undefined && opts.limit !== null) { + queryParams['limit'] = opts.limit + } + + let pathParams = { + regionId: regionId, + bucketName: opts.bucketName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ossopenapi/0.9.7' + } + + 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 listHistoricalReplicatTasks 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}/buckets/{bucketName}/historical_replicat_task/', + '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.bucketName - Bucket名称 + * @param {string} opts.action - 是否覆盖 + * @param {string} opts.bucketName - bucket名称 + * @param {string} opts.bucketRegion - bucket所属区域 + * @param {string} opts.targetBucketName - 目标bucket名称 + * @param {string} opts.targetBucketRegion - 目标bucket所属区域 + * @param {string} opts.storageClass - 存储类型 + * @param {array} [opts.prefixSet] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param historyReplicationTask historyReplicationTask + */ + + createHistoricalReplicatTask ( + 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 createHistoricalReplicatTask" + ) + } + + opts = opts || {} + + if (opts.bucketName === undefined || opts.bucketName === null) { + throw new Error( + "Missing the required parameter 'opts.bucketName' when calling createHistoricalReplicatTask" + ) + } + if (opts.action === undefined || opts.action === null) { + throw new Error( + "Missing the required parameter 'opts.action' when calling createHistoricalReplicatTask" + ) + } + if (opts.bucketName === undefined || opts.bucketName === null) { + throw new Error( + "Missing the required parameter 'opts.bucketName' when calling createHistoricalReplicatTask" + ) + } + if (opts.bucketRegion === undefined || opts.bucketRegion === null) { + throw new Error( + "Missing the required parameter 'opts.bucketRegion' when calling createHistoricalReplicatTask" + ) + } + if (opts.targetBucketName === undefined || opts.targetBucketName === null) { + throw new Error( + "Missing the required parameter 'opts.targetBucketName' when calling createHistoricalReplicatTask" + ) + } + if ( + opts.targetBucketRegion === undefined || + opts.targetBucketRegion === null + ) { + throw new Error( + "Missing the required parameter 'opts.targetBucketRegion' when calling createHistoricalReplicatTask" + ) + } + if (opts.storageClass === undefined || opts.storageClass === null) { + throw new Error( + "Missing the required parameter 'opts.storageClass' when calling createHistoricalReplicatTask" + ) + } + + let postBody = {} + if (opts.action !== undefined && opts.action !== null) { + postBody['action'] = opts.action + } + if (opts.bucketName !== undefined && opts.bucketName !== null) { + postBody['bucketName'] = opts.bucketName + } + if (opts.bucketRegion !== undefined && opts.bucketRegion !== null) { + postBody['bucketRegion'] = opts.bucketRegion + } + if (opts.targetBucketName !== undefined && opts.targetBucketName !== null) { + postBody['targetBucketName'] = opts.targetBucketName + } + if ( + opts.targetBucketRegion !== undefined && + opts.targetBucketRegion !== null + ) { + postBody['targetBucketRegion'] = opts.targetBucketRegion + } + if (opts.storageClass !== undefined && opts.storageClass !== null) { + postBody['storageClass'] = opts.storageClass + } + if (opts.prefixSet !== undefined && opts.prefixSet !== null) { + postBody['prefixSet'] = opts.prefixSet + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + bucketName: opts.bucketName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ossopenapi/0.9.7' + } + + 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 createHistoricalReplicatTask 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}/buckets/{bucketName}/historical_replicat_task/', + '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.userId - 用户Id + * @param {string} opts.appCode - app code + * @param {string} opts.serviceCode - service code + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + openService (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 openService" + ) + } + + opts = opts || {} + + if (opts.userId === undefined || opts.userId === null) { + throw new Error( + "Missing the required parameter 'opts.userId' when calling openService" + ) + } + if (opts.appCode === undefined || opts.appCode === null) { + throw new Error( + "Missing the required parameter 'opts.appCode' when calling openService" + ) + } + if (opts.serviceCode === undefined || opts.serviceCode === null) { + throw new Error( + "Missing the required parameter 'opts.serviceCode' when calling openService" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + userId: opts.userId, + appCode: opts.appCode, + serviceCode: opts.serviceCode + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ossopenapi/0.9.7' + } + + 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 openService 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}/users/{userId}/appCodes/{appCode}/serviceCodes/{serviceCode}/openService', + '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 = OSSOPENAPI diff --git a/packages/libs/lib-jdcloud/src/repo/partner/v1/partner.js b/packages/libs/lib-jdcloud/src/repo/partner/v1/partner.js new file mode 100644 index 000000000..daf14dfbf --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/partner/v1/partner.js @@ -0,0 +1,2189 @@ +/* + * 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. + * + * 合作信息管理 + * 合作信息管理 + * + * 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 = 'partner' +Service._services[serviceId] = true + +/** + * partner service. + * @version 1.3.13 + */ + +class PARTNER extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'partner.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询合作产品列表 + * @param {Object} opts - parameters + * @param {string} [opts.cooperationId] - 合作id optional + * @param {string} [opts.companyName] - 公司名称 optional + * @param {string} [opts.name] - 合作名称 optional + * @param {string} [opts.productName] - 产品名称 optional + * @param {string} [opts.contractNo] - 合同编号 optional + * @param {integer} [opts.productType] - 产品类型 optional + * @param {integer} [opts.productMode] - 产品模式 optional + * @param {integer} [opts.productStatus] - 产品状态 optional + * @param {integer} [opts.settlementMode] - 结算方式 optional + * @param {integer} [opts.settlementCycle] - 结算周期 optional + * @param {integer} [opts.pageIndex] - 页码 optional + * @param {integer} [opts.pageSize] - 每页记录数 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param pagination pagination 分页信息 + * @param coProductVo result + * @param string requestId 请求id + */ + + describeCoProducts (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 describeCoProducts" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.cooperationId !== undefined && opts.cooperationId !== null) { + postBody['cooperationId'] = opts.cooperationId + } + if (opts.companyName !== undefined && opts.companyName !== null) { + postBody['companyName'] = opts.companyName + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.productName !== undefined && opts.productName !== null) { + postBody['productName'] = opts.productName + } + if (opts.contractNo !== undefined && opts.contractNo !== null) { + postBody['contractNo'] = opts.contractNo + } + if (opts.productType !== undefined && opts.productType !== null) { + postBody['productType'] = opts.productType + } + if (opts.productMode !== undefined && opts.productMode !== null) { + postBody['productMode'] = opts.productMode + } + if (opts.productStatus !== undefined && opts.productStatus !== null) { + postBody['productStatus'] = opts.productStatus + } + if (opts.settlementMode !== undefined && opts.settlementMode !== null) { + postBody['settlementMode'] = opts.settlementMode + } + if (opts.settlementCycle !== undefined && opts.settlementCycle !== null) { + postBody['settlementCycle'] = opts.settlementCycle + } + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + postBody['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 partner/1.3.13' + } + + 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 describeCoProducts 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}/CooperationInfo:describeCoProducts', + '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.cooperationId] - 合作id optional + * @param {string} [opts.companyName] - 公司名称 optional + * @param {string} [opts.name] - 合作名称 optional + * @param {string} [opts.productName] - 产品名称 optional + * @param {string} [opts.contractNo] - 合同编号 optional + * @param {integer} [opts.productType] - 产品类型 optional + * @param {integer} [opts.productMode] - 产品模式 optional + * @param {integer} [opts.productStatus] - 产品状态 optional + * @param {integer} [opts.settlementMode] - 结算方式 optional + * @param {integer} [opts.settlementCycle] - 结算周期 optional + * @param {integer} [opts.pageIndex] - 页码 optional + * @param {integer} [opts.pageSize] - 每页记录数 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string result 导出文件的下载url + * @param string requestId 请求id + */ + + exportCoProducts (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 exportCoProducts" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.cooperationId !== undefined && opts.cooperationId !== null) { + postBody['cooperationId'] = opts.cooperationId + } + if (opts.companyName !== undefined && opts.companyName !== null) { + postBody['companyName'] = opts.companyName + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.productName !== undefined && opts.productName !== null) { + postBody['productName'] = opts.productName + } + if (opts.contractNo !== undefined && opts.contractNo !== null) { + postBody['contractNo'] = opts.contractNo + } + if (opts.productType !== undefined && opts.productType !== null) { + postBody['productType'] = opts.productType + } + if (opts.productMode !== undefined && opts.productMode !== null) { + postBody['productMode'] = opts.productMode + } + if (opts.productStatus !== undefined && opts.productStatus !== null) { + postBody['productStatus'] = opts.productStatus + } + if (opts.settlementMode !== undefined && opts.settlementMode !== null) { + postBody['settlementMode'] = opts.settlementMode + } + if (opts.settlementCycle !== undefined && opts.settlementCycle !== null) { + postBody['settlementCycle'] = opts.settlementCycle + } + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + postBody['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 partner/1.3.13' + } + + 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 exportCoProducts 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}/CooperationInfo:exportCoProducts', + '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.uuid - 合作产品唯一标识 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param coProductDetailVo result 合作产品详情 + * @param string requestId 请求id + */ + + describeCoProduct (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 describeCoProduct" + ) + } + + opts = opts || {} + + if (opts.uuid === undefined || opts.uuid === null) { + throw new Error( + "Missing the required parameter 'opts.uuid' when calling describeCoProduct" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + uuid: opts.uuid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 partner/1.3.13' + } + + 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 describeCoProduct 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}/uuid/{uuid}:describeCoProduct', + '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.cooperationId] - 合作id optional + * @param {string} [opts.productName] - 合作产品名称 optional + * @param {string} [opts.name] - 合作名称 optional + * @param {integer} [opts.productType] - 产品类型 optional + * @param {integer} [opts.productMode] - 产品模式 optional + * @param {string} [opts.productDesc] - 产品简介 optional + * @param {string} [opts.targetCustomer] - 目标客户 optional + * @param {string} [opts.marketSize] - 市场规模 optional + * @param {string} [opts.comparableProduct] - 主要竞品 optional + * @param {integer} [opts.sellingForm] - 售卖形态 1套/n年、2套/n月、3套、4次 optional + * @param {string} [opts.sellingMode] - 售卖方式 1直销,2渠道,3代理 optional + * @param {string} [opts.pricing] - 定价 optional + * @param {integer} [opts.productStatus] - 产品状态 optional + * @param {string} [opts.incomeForecast] - 收入预测 optional + * @param {string} [opts.costStructure] - 成本结构 optional + * @param {string} [opts.grossMarginForecast] - 毛利率预测 optional + * @param {integer} [opts.pricingStrategy] - 定价策略 1市场对标, 2总成本加成,3变动成本加成 optional + * @param {integer} [opts.settlementMode] - 结算方式 1固定金额结算,2实际售价固定比例结算,3实际售价浮动比例结算 optional + * @param {integer} [opts.settlementCycle] - 结算周期 1周结后付款、2月结后付款、3季结后付款、4年结后付款,5 PO预付款 optional + * @param {string} [opts.riskSuggestion] - 风险及建议 optional + * @param {string} [opts.erp] - erp optional + * @param {string} [opts.uuid] - 产品唯一标识id optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean result true:修改成功 false:修改失败 + * @param string requestId 请求id + */ + + modifyCoProduct (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 modifyCoProduct" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.cooperationId !== undefined && opts.cooperationId !== null) { + postBody['cooperationId'] = opts.cooperationId + } + if (opts.productName !== undefined && opts.productName !== null) { + postBody['productName'] = opts.productName + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.productType !== undefined && opts.productType !== null) { + postBody['productType'] = opts.productType + } + if (opts.productMode !== undefined && opts.productMode !== null) { + postBody['productMode'] = opts.productMode + } + if (opts.productDesc !== undefined && opts.productDesc !== null) { + postBody['productDesc'] = opts.productDesc + } + if (opts.targetCustomer !== undefined && opts.targetCustomer !== null) { + postBody['targetCustomer'] = opts.targetCustomer + } + if (opts.marketSize !== undefined && opts.marketSize !== null) { + postBody['marketSize'] = opts.marketSize + } + if ( + opts.comparableProduct !== undefined && + opts.comparableProduct !== null + ) { + postBody['comparableProduct'] = opts.comparableProduct + } + if (opts.sellingForm !== undefined && opts.sellingForm !== null) { + postBody['sellingForm'] = opts.sellingForm + } + if (opts.sellingMode !== undefined && opts.sellingMode !== null) { + postBody['sellingMode'] = opts.sellingMode + } + if (opts.pricing !== undefined && opts.pricing !== null) { + postBody['pricing'] = opts.pricing + } + if (opts.productStatus !== undefined && opts.productStatus !== null) { + postBody['productStatus'] = opts.productStatus + } + if (opts.incomeForecast !== undefined && opts.incomeForecast !== null) { + postBody['incomeForecast'] = opts.incomeForecast + } + if (opts.costStructure !== undefined && opts.costStructure !== null) { + postBody['costStructure'] = opts.costStructure + } + if ( + opts.grossMarginForecast !== undefined && + opts.grossMarginForecast !== null + ) { + postBody['grossMarginForecast'] = opts.grossMarginForecast + } + if (opts.pricingStrategy !== undefined && opts.pricingStrategy !== null) { + postBody['pricingStrategy'] = opts.pricingStrategy + } + if (opts.settlementMode !== undefined && opts.settlementMode !== null) { + postBody['settlementMode'] = opts.settlementMode + } + if (opts.settlementCycle !== undefined && opts.settlementCycle !== null) { + postBody['settlementCycle'] = opts.settlementCycle + } + if (opts.riskSuggestion !== undefined && opts.riskSuggestion !== null) { + postBody['riskSuggestion'] = opts.riskSuggestion + } + if (opts.erp !== undefined && opts.erp !== null) { + postBody['erp'] = opts.erp + } + if (opts.uuid !== undefined && opts.uuid !== null) { + postBody['uuid'] = opts.uuid + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 partner/1.3.13' + } + + 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 modifyCoProduct 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}/CooperationInfo:modifyCoProduct', + '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.cooperationId] - 合作id optional + * @param {string} [opts.productName] - 合作产品名称 optional + * @param {string} [opts.name] - 合作名称 optional + * @param {integer} [opts.productType] - 产品类型 optional + * @param {integer} [opts.productMode] - 产品模式 optional + * @param {string} [opts.productDesc] - 产品简介 optional + * @param {string} [opts.targetCustomer] - 目标客户 optional + * @param {string} [opts.marketSize] - 市场规模 optional + * @param {string} [opts.comparableProduct] - 主要竞品 optional + * @param {integer} [opts.sellingForm] - 售卖形态 1套/n年、2套/n月、3套、4次 optional + * @param {string} [opts.sellingMode] - 售卖方式 1直销,2渠道,3代理 optional + * @param {string} [opts.pricing] - 定价 optional + * @param {integer} [opts.productStatus] - 产品状态 optional + * @param {string} [opts.incomeForecast] - 收入预测 optional + * @param {string} [opts.costStructure] - 成本结构 optional + * @param {string} [opts.grossMarginForecast] - 毛利率预测 optional + * @param {integer} [opts.pricingStrategy] - 定价策略 1市场对标, 2总成本加成,3变动成本加成 optional + * @param {integer} [opts.settlementMode] - 结算方式 1固定金额结算,2实际售价固定比例结算,3实际售价浮动比例结算 optional + * @param {integer} [opts.settlementCycle] - 结算周期 1周结后付款、2月结后付款、3季结后付款、4年结后付款,5 PO预付款 optional + * @param {string} [opts.riskSuggestion] - 风险及建议 optional + * @param {string} [opts.erp] - erp optional + * @param {string} [opts.uuid] - 产品唯一标识id optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean result true:添加成功 false:添加失败 + * @param string requestId 请求id + */ + + addCoProduct (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 addCoProduct" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.cooperationId !== undefined && opts.cooperationId !== null) { + postBody['cooperationId'] = opts.cooperationId + } + if (opts.productName !== undefined && opts.productName !== null) { + postBody['productName'] = opts.productName + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.productType !== undefined && opts.productType !== null) { + postBody['productType'] = opts.productType + } + if (opts.productMode !== undefined && opts.productMode !== null) { + postBody['productMode'] = opts.productMode + } + if (opts.productDesc !== undefined && opts.productDesc !== null) { + postBody['productDesc'] = opts.productDesc + } + if (opts.targetCustomer !== undefined && opts.targetCustomer !== null) { + postBody['targetCustomer'] = opts.targetCustomer + } + if (opts.marketSize !== undefined && opts.marketSize !== null) { + postBody['marketSize'] = opts.marketSize + } + if ( + opts.comparableProduct !== undefined && + opts.comparableProduct !== null + ) { + postBody['comparableProduct'] = opts.comparableProduct + } + if (opts.sellingForm !== undefined && opts.sellingForm !== null) { + postBody['sellingForm'] = opts.sellingForm + } + if (opts.sellingMode !== undefined && opts.sellingMode !== null) { + postBody['sellingMode'] = opts.sellingMode + } + if (opts.pricing !== undefined && opts.pricing !== null) { + postBody['pricing'] = opts.pricing + } + if (opts.productStatus !== undefined && opts.productStatus !== null) { + postBody['productStatus'] = opts.productStatus + } + if (opts.incomeForecast !== undefined && opts.incomeForecast !== null) { + postBody['incomeForecast'] = opts.incomeForecast + } + if (opts.costStructure !== undefined && opts.costStructure !== null) { + postBody['costStructure'] = opts.costStructure + } + if ( + opts.grossMarginForecast !== undefined && + opts.grossMarginForecast !== null + ) { + postBody['grossMarginForecast'] = opts.grossMarginForecast + } + if (opts.pricingStrategy !== undefined && opts.pricingStrategy !== null) { + postBody['pricingStrategy'] = opts.pricingStrategy + } + if (opts.settlementMode !== undefined && opts.settlementMode !== null) { + postBody['settlementMode'] = opts.settlementMode + } + if (opts.settlementCycle !== undefined && opts.settlementCycle !== null) { + postBody['settlementCycle'] = opts.settlementCycle + } + if (opts.riskSuggestion !== undefined && opts.riskSuggestion !== null) { + postBody['riskSuggestion'] = opts.riskSuggestion + } + if (opts.erp !== undefined && opts.erp !== null) { + postBody['erp'] = opts.erp + } + if (opts.uuid !== undefined && opts.uuid !== null) { + postBody['uuid'] = opts.uuid + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 partner/1.3.13' + } + + 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 addCoProduct 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}/CooperationInfo:addCoProduct', + '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.fileUuid - 合同附件唯一标识 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean result true-删除成功,false-删除失败 + */ + + deleteFile (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 deleteFile" + ) + } + + opts = opts || {} + + if (opts.fileUuid === undefined || opts.fileUuid === null) { + throw new Error( + "Missing the required parameter 'opts.fileUuid' when calling deleteFile" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + fileUuid: opts.fileUuid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 partner/1.3.13' + } + + 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 deleteFile 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}/fileUuid/{fileUuid}/Contract:deleteFile', + '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.contractUuid] - 合同唯一标识(添加不需要传,编辑必传) optional + * @param {string} [opts.contractNo] - 合同编号 optional + * @param {string} [opts.startDate] - 开始时间 optional + * @param {string} [opts.endDate] - 结束时间 optional + * @param {string} [opts.remark] - 备注 optional + * @param {string} [opts.fileUuid] - 合同附件文件标识 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string result 合同唯一标识(添加失败为空) + * @param string requestId 请求id + */ + + addContract (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 addContract" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.contractUuid !== undefined && opts.contractUuid !== null) { + postBody['contractUuid'] = opts.contractUuid + } + if (opts.contractNo !== undefined && opts.contractNo !== null) { + postBody['contractNo'] = opts.contractNo + } + if (opts.startDate !== undefined && opts.startDate !== null) { + postBody['startDate'] = opts.startDate + } + if (opts.endDate !== undefined && opts.endDate !== null) { + postBody['endDate'] = opts.endDate + } + if (opts.remark !== undefined && opts.remark !== null) { + postBody['remark'] = opts.remark + } + if (opts.fileUuid !== undefined && opts.fileUuid !== null) { + postBody['fileUuid'] = opts.fileUuid + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 partner/1.3.13' + } + + 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 addContract 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}/Contract:addContract', + '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.contractUuid] - 合同唯一标识(添加不需要传,编辑必传) optional + * @param {string} [opts.contractNo] - 合同编号 optional + * @param {string} [opts.startDate] - 开始时间 optional + * @param {string} [opts.endDate] - 结束时间 optional + * @param {string} [opts.remark] - 备注 optional + * @param {string} [opts.fileUuid] - 合同附件文件标识 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean result true:修改成功 false:修改失败 + * @param string requestId 请求id + */ + + modifyContract (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 modifyContract" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.contractUuid !== undefined && opts.contractUuid !== null) { + postBody['contractUuid'] = opts.contractUuid + } + if (opts.contractNo !== undefined && opts.contractNo !== null) { + postBody['contractNo'] = opts.contractNo + } + if (opts.startDate !== undefined && opts.startDate !== null) { + postBody['startDate'] = opts.startDate + } + if (opts.endDate !== undefined && opts.endDate !== null) { + postBody['endDate'] = opts.endDate + } + if (opts.remark !== undefined && opts.remark !== null) { + postBody['remark'] = opts.remark + } + if (opts.fileUuid !== undefined && opts.fileUuid !== null) { + postBody['fileUuid'] = opts.fileUuid + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 partner/1.3.13' + } + + 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 modifyContract 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}/Contract:modifyContract', + '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.customerPin] - 客户pin optional + * @param {string} [opts.aliasName] optional + * @param {string} [opts.nameLike] - 客户名称 optional + * @param {integer} [opts.accountType] - 账户类型(1个人2企业) optional + * @param {string} [opts.loginName] - 帐户名 optional + * @param {string} [opts.startRelTime] - 关联开始时间(格式:yyyy-MM-dd HH:mm:ss) optional + * @param {string} [opts.endRelTime] - 关联结束时间(格式:yyyy-MM-dd HH:mm:ss) optional + * @param {integer} [opts.pageIndex] - 当前页序号 optional + * @param {integer} [opts.pageSize] - 当前条数 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param pagination pagination + * @param customer result + */ + + queryMyCustomerList (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 queryMyCustomerList" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.customerPin !== undefined && opts.customerPin !== null) { + postBody['customerPin'] = opts.customerPin + } + if (opts.aliasName !== undefined && opts.aliasName !== null) { + postBody['aliasName'] = opts.aliasName + } + if (opts.nameLike !== undefined && opts.nameLike !== null) { + postBody['nameLike'] = opts.nameLike + } + if (opts.accountType !== undefined && opts.accountType !== null) { + postBody['accountType'] = opts.accountType + } + if (opts.loginName !== undefined && opts.loginName !== null) { + postBody['loginName'] = opts.loginName + } + if (opts.startRelTime !== undefined && opts.startRelTime !== null) { + postBody['startRelTime'] = opts.startRelTime + } + if (opts.endRelTime !== undefined && opts.endRelTime !== null) { + postBody['endRelTime'] = opts.endRelTime + } + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + postBody['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 partner/1.3.13' + } + + 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 queryMyCustomerList 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}/customerManage:queryMyCustomerList', + '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.pin] optional + * @param {string} [opts.loginName] - 帐户名 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param partnerUserDTO partnerUserDTOList + */ + + getPartnerUserList (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 getPartnerUserList" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.pin !== undefined && opts.pin !== null) { + queryParams['pin'] = opts.pin + } + if (opts.loginName !== undefined && opts.loginName !== null) { + queryParams['loginName'] = opts.loginName + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 partner/1.3.13' + } + + 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 getPartnerUserList 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}/getPartnerUserList', + '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 {number} [opts.id] - ID optional + * @param {string} [opts.codeType] - 字典类型 optional + * @param {string} [opts.code] - 字典编码 optional + * @param {string} [opts.name] - 字典编码名称 optional + * @param {string} [opts.value] - 字典编码值 optional + * @param {boolean} [opts.useFlag] - null optional + * @param {string} [opts.systemType] - 系统类型 optional + * @param {string} [opts.refValue] - 引用值 optional + * @param {integer} [opts.seq] - 顺序 optional + * @param {string} [opts.remark] - 字典说明 optional + * @param {string} [opts.createTime] - 创建时间 optional + * @param {string} [opts.createUser] - 创建人 optional + * @param {string} [opts.updateTime] - 修改时间 optional + * @param {string} [opts.updateUser] - 修改人 optional + * @param {integer} [opts.yn] - 是否删除0未删除,1已删除 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string code 返还编码0成功,其他失败 + * @param string message 返回消息 + */ + + modifyDicDetail (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 modifyDicDetail" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.id !== undefined && opts.id !== null) { + postBody['id'] = opts.id + } + if (opts.codeType !== undefined && opts.codeType !== null) { + postBody['codeType'] = opts.codeType + } + if (opts.code !== undefined && opts.code !== null) { + postBody['code'] = opts.code + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + if (opts.useFlag !== undefined && opts.useFlag !== null) { + postBody['useFlag'] = opts.useFlag + } + if (opts.systemType !== undefined && opts.systemType !== null) { + postBody['systemType'] = opts.systemType + } + if (opts.refValue !== undefined && opts.refValue !== null) { + postBody['refValue'] = opts.refValue + } + if (opts.seq !== undefined && opts.seq !== null) { + postBody['seq'] = opts.seq + } + if (opts.remark !== undefined && opts.remark !== null) { + postBody['remark'] = opts.remark + } + if (opts.createTime !== undefined && opts.createTime !== null) { + postBody['createTime'] = opts.createTime + } + if (opts.createUser !== undefined && opts.createUser !== null) { + postBody['createUser'] = opts.createUser + } + if (opts.updateTime !== undefined && opts.updateTime !== null) { + postBody['updateTime'] = opts.updateTime + } + if (opts.updateUser !== undefined && opts.updateUser !== null) { + postBody['updateUser'] = opts.updateUser + } + if (opts.yn !== undefined && opts.yn !== null) { + postBody['yn'] = opts.yn + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 partner/1.3.13' + } + + 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 modifyDicDetail 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}/dictionary:modifyDicDetail', + '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) + } + ) + } + + /** + * 获取伙伴账单 + * @param {Object} opts - parameters + * @param {string} [opts.pin] - 渠道商pin optional + * @param {string} [opts.loginName] - 账号名 optional + * @param {string} opts.billDate - 账期,yyyy-MM + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param pinBill pinBills + * @param productBill productBills + */ + + describePartnerBills (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 describePartnerBills" + ) + } + + opts = opts || {} + + if (opts.billDate === undefined || opts.billDate === null) { + throw new Error( + "Missing the required parameter 'opts.billDate' when calling describePartnerBills" + ) + } + + let postBody = {} + if (opts.pin !== undefined && opts.pin !== null) { + postBody['pin'] = opts.pin + } + if (opts.loginName !== undefined && opts.loginName !== null) { + postBody['loginName'] = opts.loginName + } + if (opts.billDate !== undefined && opts.billDate !== null) { + postBody['billDate'] = opts.billDate + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 partner/1.3.13' + } + + 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 describePartnerBills 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}/describePartnerBills', + '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.startTime - 按月查询开始时间(yyyy/MM/dd) + * @param {string} opts.endTime - 按月查询结束时间(yyyy/MM/dd) + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param summaryBill result + */ + + getTotalConsumption (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 getTotalConsumption" + ) + } + + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling getTotalConsumption" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling getTotalConsumption" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 partner/1.3.13' + } + + 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 getTotalConsumption 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}/accountingBill:getTotalConsumption', + '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.startTime - 按月查询开始时间(yyyy/MM/dd) + * @param {string} opts.endTime - 按月查询结束时间(yyyy/MM/dd) + * @param {string} [opts.pin] - pin optional + * @param {integer} opts.pageSize - 每页条数 + * @param {integer} opts.pageIndex - 第几页 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param pagination pagination + * @param summaryBill result + */ + + getEachConsumption (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 getEachConsumption" + ) + } + + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling getEachConsumption" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling getEachConsumption" + ) + } + if (opts.pageSize === undefined || opts.pageSize === null) { + throw new Error( + "Missing the required parameter 'opts.pageSize' when calling getEachConsumption" + ) + } + if (opts.pageIndex === undefined || opts.pageIndex === null) { + throw new Error( + "Missing the required parameter 'opts.pageIndex' when calling getEachConsumption" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.pin !== undefined && opts.pin !== null) { + queryParams['pin'] = opts.pin + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 partner/1.3.13' + } + + 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 getEachConsumption 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}/accountingBill:getEachConsumption', + '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) + } + ) + } + + /** + * 查询服务商相关pin下每个产品的消费数据 + * @param {Object} opts - parameters + * @param {string} [opts.pin] - pin optional + * @param {string} opts.startTime - 按月查询开始时间(yyyy-MM-dd),不可跨月 + * @param {string} opts.endTime - 按月查询结束时间(yyyy-MM-dd),不可跨月 + * @param {integer} opts.pageSize - 每页条数,不超过100 + * @param {integer} opts.pageIndex - 第几页 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param pagination pagination + * @param serviceCodeBill result + */ + + describeCustomerBillByProduct ( + 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 describeCustomerBillByProduct" + ) + } + + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeCustomerBillByProduct" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeCustomerBillByProduct" + ) + } + if (opts.pageSize === undefined || opts.pageSize === null) { + throw new Error( + "Missing the required parameter 'opts.pageSize' when calling describeCustomerBillByProduct" + ) + } + if (opts.pageIndex === undefined || opts.pageIndex === null) { + throw new Error( + "Missing the required parameter 'opts.pageIndex' when calling describeCustomerBillByProduct" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pin !== undefined && opts.pin !== null) { + queryParams['pin'] = opts.pin + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 partner/1.3.13' + } + + 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 describeCustomerBillByProduct 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}/accountingBill:describeCustomerBillByProduct', + '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 = PARTNER diff --git a/packages/libs/lib-jdcloud/src/repo/pipeline/v1/pipeline.js b/packages/libs/lib-jdcloud/src/repo/pipeline/v1/pipeline.js new file mode 100644 index 000000000..0319bd6d4 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/pipeline/v1/pipeline.js @@ -0,0 +1,1886 @@ +/* + * 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. + * + * tools + * API OF tools Create|Update|Read|Delete|Execute + * + * 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 = 'pipeline' +Service._services[serviceId] = true + +/** + * pipeline service. + * @version 1.0.0 + */ + +JDCloud.PIPELINE = class PIPELINE extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'pipeline.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询用户限制 + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer numberLimit 流水线数量限制 + * @param boolean canCreate 是否可以创建 + */ + + getLimits (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 getLimits" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pipeline/1.0.0' + } + + 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 getLimits 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 = this.makeRequest( + '/regions/{regionId}/limits', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount 记录数 + * @param nameLabelPair providers + */ + + getSourceProviders (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 getSourceProviders" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pipeline/1.0.0' + } + + 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 getSourceProviders 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 = this.makeRequest( + '/regions/{regionId}/options/sourceProviders', + '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.type] - 源提供商类型 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount 记录数 + * @param nameLabelPair providers + */ + + getOperationProviders (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 getOperationProviders" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.type !== undefined && opts.type !== null) { + queryParams['type'] = opts.type + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pipeline/1.0.0' + } + + 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 getOperationProviders 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 = this.makeRequest( + '/regions/{regionId}/options/operationProviders', + '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.type] - 源提供商类型 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount 可选地域总数 + * @param nameLabelPair regions + */ + + getRegions (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 getRegions" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.type !== undefined && opts.type !== null) { + queryParams['type'] = opts.type + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pipeline/1.0.0' + } + + 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 getRegions 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 = this.makeRequest( + '/regions/{regionId}/options/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) + } + ) + } + + /** + * 查询获取流水线任务列表,并显示最后一次执行的状态或结果信息 +/v1/regions/cn-south-1?sorts.1.name=startedAt&sorts.1.direction=desc&pageNumber=1&pageSize=10&filters.1.name=name&filters.1.values.1=我的pipeline + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[10, 100] optional + * @param {filter} [opts.filters] - 根据流水线名称查询 optional + * @param {sort} [opts.sorts] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount + * @param simplePipeline pipelines + */ + + getPipelines (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 getPipelines" + ) + } + + 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, this.buildFilterParam(opts.filters, 'filters')) + Object.assign(queryParams, this.buildSortParam(opts.sorts, 'sorts')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pipeline/1.0.0' + } + + 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 getPipelines 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 = this.makeRequest( + '/regions/{regionId}/pipeline', + '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 {pipelineParams} [opts.data] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string uuid 流水线任务uuid + * @param boolean result 创建成功则是true + */ + + createPipeline (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 createPipeline" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.data !== undefined && opts.data !== null) { + postBody['data'] = opts.data + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pipeline/1.0.0' + } + + 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 createPipeline 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 = this.makeRequest( + '/regions/{regionId}/pipeline', + '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) + } + ) + } + + /** + * 根据uuid获取流水线任务的配置信息 + * @param {Object} opts - parameters + * @param {string} opts.uuid - 流水线 uuid + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param pipeline pipeline + */ + + getPipeline (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 getPipeline" + ) + } + + opts = opts || {} + + if (opts.uuid === undefined || opts.uuid === null) { + throw new Error( + "Missing the required parameter 'opts.uuid' when calling getPipeline" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + uuid: opts.uuid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pipeline/1.0.0' + } + + 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 getPipeline 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 = this.makeRequest( + '/regions/{regionId}/pipeline/{uuid}', + '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.uuid - 流水线任务 uuid + * @param {pipelineParams} [opts.data] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string uuid 流水线任务uuid + * @param boolean result 更新成功则是true + */ + + updatePipeline (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 updatePipeline" + ) + } + + opts = opts || {} + + if (opts.uuid === undefined || opts.uuid === null) { + throw new Error( + "Missing the required parameter 'opts.uuid' when calling updatePipeline" + ) + } + + let postBody = {} + if (opts.data !== undefined && opts.data !== null) { + postBody['data'] = opts.data + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + uuid: opts.uuid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pipeline/1.0.0' + } + + 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 updatePipeline 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 = this.makeRequest( + '/regions/{regionId}/pipeline/{uuid}', + '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) + } + ) + } + + /** + * 删除一个流水线任务 + * @param {Object} opts - parameters + * @param {string} opts.uuid - 流水线任务uuid + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string uuid 流水线任务uuid + * @param boolean result 删除成功则是true + */ + + deletePipeline (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 deletePipeline" + ) + } + + opts = opts || {} + + if (opts.uuid === undefined || opts.uuid === null) { + throw new Error( + "Missing the required parameter 'opts.uuid' when calling deletePipeline" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + uuid: opts.uuid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pipeline/1.0.0' + } + + 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 deletePipeline 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 = this.makeRequest( + '/regions/{regionId}/pipeline/{uuid}', + '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) + } + ) + } + + /** + * 根据uuid启动一个流水线任务 + * @param {Object} opts - parameters + * @param {string} opts.uuid - 流水线uuid + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string instanceUuid 本次执行生成的实例的uuid + * @param string uuid 提交运行的流水线uuid + * @param boolean result 提交任务是否成功 + */ + + startPipeline (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 startPipeline" + ) + } + + opts = opts || {} + + if (opts.uuid === undefined || opts.uuid === null) { + throw new Error( + "Missing the required parameter 'opts.uuid' when calling startPipeline" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + uuid: opts.uuid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pipeline/1.0.0' + } + + 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 startPipeline 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 = this.makeRequest( + '/regions/{regionId}/pipeline/{uuid}:start', + '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.uuid - 流水线uuid + * @param {string} opts.instanceUuid - 流水线实例uuid + * @param {string} opts.actionUuid - 动作UUID + * @param {string} opts.status - 手动设置的状态,如SUCCESS,FAILED + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string instanceUuid + * @param string actionUuid + */ + + manualAction (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 manualAction" + ) + } + + opts = opts || {} + + if (opts.uuid === undefined || opts.uuid === null) { + throw new Error( + "Missing the required parameter 'opts.uuid' when calling manualAction" + ) + } + if (opts.instanceUuid === undefined || opts.instanceUuid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceUuid' when calling manualAction" + ) + } + if (opts.actionUuid === undefined || opts.actionUuid === null) { + throw new Error( + "Missing the required parameter 'opts.actionUuid' when calling manualAction" + ) + } + if (opts.status === undefined || opts.status === null) { + throw new Error( + "Missing the required parameter 'opts.status' when calling manualAction" + ) + } + + let postBody = {} + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + uuid: opts.uuid, + instanceUuid: opts.instanceUuid, + actionUuid: opts.actionUuid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pipeline/1.0.0' + } + + 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 manualAction 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 = this.makeRequest( + '/regions/{regionId}/pipeline/{uuid}/instances/{instanceUuid}/actions/{actionUuid}:manual', + '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.uuids - 流水线执行实例ID,多个ID用逗号分隔 + * @param {boolean} [opts.isSimple] - 流水线执行的状态,如果isSimple是true,只显示每个stage的状态, 而stage中的action状态将被忽略 optional + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[10, 100] optional + * @param {filter} [opts.filters] - 根据流水线名称查询 optional + * @param {sort} [opts.sorts] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param pipelineInstance pipelineInstances + */ + + getPipelineInstancesByUuids (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 getPipelineInstancesByUuids" + ) + } + + opts = opts || {} + + if (opts.uuids === undefined || opts.uuids === null) { + throw new Error( + "Missing the required parameter 'opts.uuids' when calling getPipelineInstancesByUuids" + ) + } + + let postBody = null + let queryParams = {} + if (opts.uuids !== undefined && opts.uuids !== null) { + queryParams['uuids'] = opts.uuids + } + if (opts.isSimple !== undefined && opts.isSimple !== null) { + queryParams['isSimple'] = opts.isSimple + } + 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, this.buildFilterParam(opts.filters, 'filters')) + Object.assign(queryParams, this.buildSortParam(opts.sorts, 'sorts')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pipeline/1.0.0' + } + + 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 getPipelineInstancesByUuids 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 = this.makeRequest( + '/regions/{regionId}/instances', + '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.uuid - 流水线uuid + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[10, 100] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount + * @param pipelineInstance instances + */ + + getPipelineInstances (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 getPipelineInstances" + ) + } + + opts = opts || {} + + if (opts.uuid === undefined || opts.uuid === null) { + throw new Error( + "Missing the required parameter 'opts.uuid' when calling getPipelineInstances" + ) + } + + 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, + uuid: opts.uuid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pipeline/1.0.0' + } + + 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 getPipelineInstances 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 = this.makeRequest( + '/regions/{regionId}/pipeline/{uuid}/instances', + '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.uuid - 流水线uuid + * @param {string} opts.instanceUuid - 流水线uuid执行历史记录的uuid, 也可以用 latest 字符串代替uuid, 来取得最近的状态 + * @param {boolean} [opts.isSimple] - 流水线执行的状态,如果isSimple是true,只显示每个stage的状态, 而stage中的action状态将被忽略 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param pipelineInstance pipelineInstance + */ + + getPipelineInstance (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 getPipelineInstance" + ) + } + + opts = opts || {} + + if (opts.uuid === undefined || opts.uuid === null) { + throw new Error( + "Missing the required parameter 'opts.uuid' when calling getPipelineInstance" + ) + } + if (opts.instanceUuid === undefined || opts.instanceUuid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceUuid' when calling getPipelineInstance" + ) + } + + let postBody = null + let queryParams = {} + if (opts.isSimple !== undefined && opts.isSimple !== null) { + queryParams['isSimple'] = opts.isSimple + } + + let pathParams = { + regionId: regionId, + uuid: opts.uuid, + instanceUuid: opts.instanceUuid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pipeline/1.0.0' + } + + 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 getPipelineInstance 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 = this.makeRequest( + '/regions/{regionId}/pipeline/{uuid}/instance/{instanceUuid}', + '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.uuid - 流水线uuid + * @param {string} opts.instanceUuid - 流水线执行的uuid + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string instanceUuid + * @param string actionUuid + */ + + stopPipelineInstance (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 stopPipelineInstance" + ) + } + + opts = opts || {} + + if (opts.uuid === undefined || opts.uuid === null) { + throw new Error( + "Missing the required parameter 'opts.uuid' when calling stopPipelineInstance" + ) + } + if (opts.instanceUuid === undefined || opts.instanceUuid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceUuid' when calling stopPipelineInstance" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + uuid: opts.uuid, + instanceUuid: opts.instanceUuid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pipeline/1.0.0' + } + + 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 stopPipelineInstance 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 = this.makeRequest( + '/regions/{regionId}/pipeline/{uuid}/instance/{instanceUuid}:stop', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean result + * @param string contents + */ + + readFile (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 readFile" + ) + } + + opts = opts || {} + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pipeline/1.0.0' + } + + 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 readFile 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 = this.makeRequest( + '/regions/{regionId}/file', + '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 = JDCloud.PIPELINE diff --git a/packages/libs/lib-jdcloud/src/repo/pod/v1/pod.js b/packages/libs/lib-jdcloud/src/repo/pod/v1/pod.js new file mode 100644 index 000000000..5461f7042 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/pod/v1/pod.js @@ -0,0 +1,5276 @@ +/* + * 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. + * + * 用户设置 + * 查询用户设置接口 + * + * 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 = 'pod' +Service._services[serviceId] = true + +/** + * pod service. + * @version 2.7.0 + */ + +class POD extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'pod.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 创建一个 configFile,存放文件内容(键值对)。 + + * @param {Object} opts - parameters + * @param {string} opts.name - ConfigFile 的名字,名称不能重复 +长度不超过63(命名字母小写,数字和-) + + * @param {array} [opts.data] - configFile数据,个数不超过32个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string name + */ + + createConfigFile (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 createConfigFile" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createConfigFile" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.data !== undefined && opts.data !== null) { + postBody['data'] = opts.data + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 createConfigFile 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}/configFiles', + '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) + } + ) + } + + /** + * 查询单个 configFile 详情 + + * @param {Object} opts - parameters + * @param {string} opts.name - Name + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param configFile configFile + */ + + describeConfigFile (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 describeConfigFile" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling describeConfigFile" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + name: opts.name + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 describeConfigFile 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}/configFiles/{name}', + '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) + } + ) + } + + /** + * 删除单个 configFile + + * @param {Object} opts - parameters + * @param {string} opts.name - Name + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteConfigFile (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 deleteConfigFile" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling deleteConfigFile" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + name: opts.name + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 deleteConfigFile 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}/configFiles/{name}', + '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) + } + ) + } + + /** + * 更新configFile信息 + + * @param {Object} opts - parameters + * @param {string} opts.name - Name + * @param {string} opts.name - 想要挂载的 ConfigFile 的名字,不能重复 + + * @param {array} [opts.data] - configFile数据,个数不超过32个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string name + */ + + updateConfigFile (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 updateConfigFile" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling updateConfigFile" + ) + } + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling updateConfigFile" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.data !== undefined && opts.data !== null) { + postBody['data'] = opts.data + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + name: opts.name + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 updateConfigFile 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}/configFiles/{name}:update', + '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) + } + ) + } + + /** + * 获取 pod 中某个容器的详情 + * @param {Object} opts - parameters + * @param {string} opts.podId - Pod ID + * @param {string} opts.containerName - container name + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param container container + */ + + describeContainer (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 describeContainer" + ) + } + + opts = opts || {} + + if (opts.podId === undefined || opts.podId === null) { + throw new Error( + "Missing the required parameter 'opts.podId' when calling describeContainer" + ) + } + if (opts.containerName === undefined || opts.containerName === null) { + throw new Error( + "Missing the required parameter 'opts.containerName' when calling describeContainer" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + podId: opts.podId, + containerName: opts.containerName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 describeContainer 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}/pods/{podId}/containers/{containerName}', + '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.podId - Pod ID + * @param {string} opts.containerName - container name + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + attach (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 attach" + ) + } + + opts = opts || {} + + if (opts.podId === undefined || opts.podId === null) { + throw new Error( + "Missing the required parameter 'opts.podId' when calling attach" + ) + } + if (opts.containerName === undefined || opts.containerName === null) { + throw new Error( + "Missing the required parameter 'opts.containerName' when calling attach" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + podId: opts.podId, + containerName: opts.containerName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 attach 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}/pods/{podId}/containers/{containerName}:attach', + '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) + } + ) + } + + /** + * 创建 exec + + * @param {Object} opts - parameters + * @param {string} opts.podId - Pod ID + * @param {string} opts.containerName - container name + * @param {array} [opts.command] - 执行的命令 optional + * @param {boolean} [opts.tty] - 执行命令是否分配tty。默认不分配 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string execId exec id + */ + + execCreate (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 execCreate" + ) + } + + opts = opts || {} + + if (opts.podId === undefined || opts.podId === null) { + throw new Error( + "Missing the required parameter 'opts.podId' when calling execCreate" + ) + } + if (opts.containerName === undefined || opts.containerName === null) { + throw new Error( + "Missing the required parameter 'opts.containerName' when calling execCreate" + ) + } + + let postBody = {} + if (opts.command !== undefined && opts.command !== null) { + postBody['command'] = opts.command + } + if (opts.tty !== undefined && opts.tty !== null) { + postBody['tty'] = opts.tty + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + podId: opts.podId, + containerName: opts.containerName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 execCreate 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}/pods/{podId}/containers/{containerName}:execCreate', + '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) + } + ) + } + + /** + * 获取exec退出码 + * @param {Object} opts - parameters + * @param {string} opts.podId - Pod ID + * @param {string} opts.containerName - container name + * @param {string} opts.execId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer execCode exec命令执行的退出码 + */ + + execGetExitCode (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 execGetExitCode" + ) + } + + opts = opts || {} + + if (opts.podId === undefined || opts.podId === null) { + throw new Error( + "Missing the required parameter 'opts.podId' when calling execGetExitCode" + ) + } + if (opts.containerName === undefined || opts.containerName === null) { + throw new Error( + "Missing the required parameter 'opts.containerName' when calling execGetExitCode" + ) + } + if (opts.execId === undefined || opts.execId === null) { + throw new Error( + "Missing the required parameter 'opts.execId' when calling execGetExitCode" + ) + } + + let postBody = null + let queryParams = {} + if (opts.execId !== undefined && opts.execId !== null) { + queryParams['execId'] = opts.execId + } + + let pathParams = { + regionId: regionId, + podId: opts.podId, + containerName: opts.containerName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 execGetExitCode 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}/pods/{podId}/containers/{containerName}:execGetExitCode', + '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) + } + ) + } + + /** + * 执行exec,此接口需要升级Http协议到WebSocket + * @param {Object} opts - parameters + * @param {string} opts.podId - Pod ID + * @param {string} opts.containerName - container name + * @param {string} opts.execId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + execStart (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 execStart" + ) + } + + opts = opts || {} + + if (opts.podId === undefined || opts.podId === null) { + throw new Error( + "Missing the required parameter 'opts.podId' when calling execStart" + ) + } + if (opts.containerName === undefined || opts.containerName === null) { + throw new Error( + "Missing the required parameter 'opts.containerName' when calling execStart" + ) + } + if (opts.execId === undefined || opts.execId === null) { + throw new Error( + "Missing the required parameter 'opts.execId' when calling execStart" + ) + } + + let postBody = null + let queryParams = {} + if (opts.execId !== undefined && opts.execId !== null) { + queryParams['execId'] = opts.execId + } + + let pathParams = { + regionId: regionId, + podId: opts.podId, + containerName: opts.containerName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 execStart 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}/pods/{podId}/containers/{containerName}:execStart', + '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) + } + ) + } + + /** + * 设置TTY大小 + * @param {Object} opts - parameters + * @param {string} opts.podId - Pod ID + * @param {string} opts.containerName - container name + * @param {integer} opts.height - tty row,取值范围:[10, 2000] + * @param {integer} opts.width - tty column,取值范围:[10, 1000] + * @param {string} [opts.execId] - exec ID optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + resizeTTY (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 resizeTTY" + ) + } + + opts = opts || {} + + if (opts.podId === undefined || opts.podId === null) { + throw new Error( + "Missing the required parameter 'opts.podId' when calling resizeTTY" + ) + } + if (opts.containerName === undefined || opts.containerName === null) { + throw new Error( + "Missing the required parameter 'opts.containerName' when calling resizeTTY" + ) + } + if (opts.height === undefined || opts.height === null) { + throw new Error( + "Missing the required parameter 'opts.height' when calling resizeTTY" + ) + } + if (opts.width === undefined || opts.width === null) { + throw new Error( + "Missing the required parameter 'opts.width' when calling resizeTTY" + ) + } + + let postBody = {} + if (opts.height !== undefined && opts.height !== null) { + postBody['height'] = opts.height + } + if (opts.width !== undefined && opts.width !== null) { + postBody['width'] = opts.width + } + if (opts.execId !== undefined && opts.execId !== null) { + postBody['execId'] = opts.execId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + podId: opts.podId, + containerName: opts.containerName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 resizeTTY 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}/pods/{podId}/containers/{containerName}:resizeTTY', + '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) + } + ) + } + + /** + * 创建一个镜像缓存信息。镜像缓存加速是将镜像预先拉取到一个云盘中并制作为云盘快照, +用户在创建Pod/NC时,若使用的镜像已经有镜像缓存,则可以直接基于该镜像缓存对应的快照制作云盘,并挂载为该容器的系统盘,避免重复拉取镜像并加快创建速度。 + + * @param {Object} opts - parameters + * @param {string} [opts.name] - 镜像缓存名称 optional + * @param {imageCacheSpec} opts.imageCacheSpec - 镜像缓存创建参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string imageCacheId + */ + + createImageCache (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 createImageCache" + ) + } + + opts = opts || {} + + if (opts.imageCacheSpec === undefined || opts.imageCacheSpec === null) { + throw new Error( + "Missing the required parameter 'opts.imageCacheSpec' when calling createImageCache" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.imageCacheSpec !== undefined && opts.imageCacheSpec !== null) { + postBody['imageCacheSpec'] = opts.imageCacheSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 createImageCache 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}/imageCache', + '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) + } + ) + } + + /** + * 批量查询镜像缓存。支持分页查询,默认每页20条。 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 100] optional + * @param {filter} [opts.filters] - imageCacheId - imageCacheId,精确匹配,支持多个 +status - 镜像缓存状态,精确匹配,支持多个 +name - 镜像缓存名称,模糊匹配,支持单个 +image - 镜像名称,模糊匹配,支持单个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param imageCache imageCaches + * @param number totalCount + */ + + describeImageCaches (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 describeImageCaches" + ) + } + + 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 pod/2.7.0' + } + + 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 describeImageCaches 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}/imageCaches', + '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.name] - 镜像缓存名称 + optional + * @param {array} [opts.imageCacheSpecs] - 镜像缓存创建参数 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string imageCacheId + */ + + createImageCaches (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 createImageCaches" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.imageCacheSpecs !== undefined && opts.imageCacheSpecs !== null) { + postBody['imageCacheSpecs'] = opts.imageCacheSpecs + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 createImageCaches 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}/imageCaches', + '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.imageCacheId - imageCacheId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param imageCache imageCache + */ + + describeImageCache (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 describeImageCache" + ) + } + + opts = opts || {} + + if (opts.imageCacheId === undefined || opts.imageCacheId === null) { + throw new Error( + "Missing the required parameter 'opts.imageCacheId' when calling describeImageCache" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + imageCacheId: opts.imageCacheId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 describeImageCache 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}/imageCache/{imageCacheId}', + '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) + } + ) + } + + /** + * 删除镜像缓存,镜像缓存状态必须为Ready或Error状态。 + + * @param {Object} opts - parameters + * @param {string} opts.imageCacheId - imageCacheId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteImageCache (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 deleteImageCache" + ) + } + + opts = opts || {} + + if (opts.imageCacheId === undefined || opts.imageCacheId === null) { + throw new Error( + "Missing the required parameter 'opts.imageCacheId' when calling deleteImageCache" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + imageCacheId: opts.imageCacheId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 deleteImageCache 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}/imageCache/{imageCacheId}', + '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.image - 镜像名称 + + * @param {string} [opts.secret] - 镜像仓库认证信息;使用Docker Hub和京东云CR的镜像不需要secret + optional + * @param {integer} [opts.size] - 限制返回的镜像缓存的大小不大于该值,用于避免镜像缓存大于系统盘导致创建失败的情况。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean found 是否匹配到镜像缓存 + * @param imageCache imageCache 镜像缓存详情 + */ + + getMostSuitableImageCache (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 getMostSuitableImageCache" + ) + } + + opts = opts || {} + + if (opts.image === undefined || opts.image === null) { + throw new Error( + "Missing the required parameter 'opts.image' when calling getMostSuitableImageCache" + ) + } + + let postBody = null + let queryParams = {} + if (opts.image !== undefined && opts.image !== null) { + queryParams['image'] = opts.image + } + if (opts.secret !== undefined && opts.secret !== null) { + queryParams['secret'] = opts.secret + } + if (opts.size !== undefined && opts.size !== null) { + queryParams['size'] = opts.size + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 getMostSuitableImageCache 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}/imageCache:getMostSuitable', + '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.imageCacheId - imageCacheId + * @param {string} [opts.name] - 新的镜像缓存名称 optional + * @param {integer} [opts.retentionDays] - 新的保留日期,以创建时间为准计算过期时间,新的过期时间不得为当前时间之前 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateImageCache (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 updateImageCache" + ) + } + + opts = opts || {} + + if (opts.imageCacheId === undefined || opts.imageCacheId === null) { + throw new Error( + "Missing the required parameter 'opts.imageCacheId' when calling updateImageCache" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.retentionDays !== undefined && opts.retentionDays !== null) { + postBody['retentionDays'] = opts.retentionDays + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + imageCacheId: opts.imageCacheId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 updateImageCache 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}/imageCache/{imageCacheId}:update', + 'PATCH', + 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 {filter} [opts.filters] - instanceTypes - 实例规格,精确匹配,支持多个 +az - 可用区,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instanceType instanceTypes + * @param instanceType specificInstanceTypes + * @param integer totalCount 总数量 + */ + + describeInstanceTypes (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 describeInstanceTypes" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 describeInstanceTypes 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}/instanceTypes', + '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) + } + ) + } + + /** + * 批量查询 pod 的详细信息<br> +此接口支持分页查询,默认每页20条。 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 100] optional + * @param {filter} [opts.filters] - podId - pod ID,精确匹配,支持多个 +privateIpAddress - 主网卡IP地址,模糊匹配,支持单个 +az - 可用区,精确匹配,支持多个 +vpcId - 私有网络ID,精确匹配,支持多个 +phase - pod 状态,精确匹配,支持多个 +name - 实例名称,模糊匹配,支持单个 +subnetId - 镜像ID,精确匹配,支持多个 +agId - 高可用组ID,精确匹配,支持多个 + optional + * @param {tagFilter} [opts.tags] - Tag筛选条件 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param pod pods + * @param number totalCount + */ + + describePods (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 describePods" + ) + } + + 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')) + Object.assign(queryParams, super.buildTagFilterParam(opts.tags, 'tags')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 describePods 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}/pods', + '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) + } + ) + } + + /** + * 创建一台或多台 pod +- 创建pod需要通过实名认证 +- 可用区 + - Pod所属的可用区 + - 创建Pod,需要使用中心可用区的相关资源: + - 具有中心可用区属性的子网 + - 公网IP服务商 +- hostname规范 + - 支持两种方式:以标签方式书写或以完整主机名方式书写 + - 标签规范 + - 0-9,a-z(不分大小写)和-(减号),其他的都是无效的字符串 + - 不能以减号开始,也不能以减号结尾 + - 最小1个字符,最大63个字符 + - 完整的主机名由一系列标签与点连接组成 + - 标签与标签之间使用“.”(点)进行连接 + - 不能以“.”(点)开始,也不能以“.”(点)结尾 + - 整个主机名(包括标签以及分隔点“.”)最多有63个ASCII字符 +- 网络配置 + - 指定主网卡配置信息 + - 必须指定subnetId + - 可以指定elasticIp规格来约束创建的弹性IP,带宽取值范围[1-100]Mbps,步进1Mbps + - 可以指定网卡的主IP(primaryIpAddress)和辅助IP(secondaryIpAddresses),此时maxCount只能为1 + - 可以设置网卡的自动删除autoDelete属性,指明是否删除实例时自动删除网卡 + - 安全组securityGroup需与子网Subnet在同一个私有网络VPC内 + - 一个 pod 创建时至多指定5个安全组 + - 主网卡deviceIndex设置为1 +- 存储 + - volume分为container system disk和pod data volume,container system disk的挂载目录是/,data volume的挂载目录可以随意指定 + - container system disk + - 支持cloud和local + - 云硬盘类型可以选择hdd.std1、ssd.gp1、ssd.io1 + - 磁盘大小 + - 所有类型:范围[20,100]GB,步长为10G + - 自动删除 + - 默认自动删除 + - 可以选择已存在的云硬盘 + - data volume + -cloudDisk + - 云硬盘类型可以选择hdd.std1、ssd.gp1、ssd.io1 + - 磁盘大小 + - 所有类型:范围[20,2000]GB,步长为10G + - 自动删除 + - 默认自动删除 + - 可以选择已存在的云硬盘 + - 可以从快照创建磁盘 + -CFS + - 从zbs去获取数据,挂载到当前的volume + -configFile + - 提前创建好configFile相关数据,然后挂载到volume + +- pod 容器日志 + - default:默认在本地分配10MB的存储空间,自动rotate +- DNS-1123 label规范 + - 支持数字、小写字母、英文中划线“-”,但不支持以“-”作为开始字符和结束字符,1~63字符。 + - 例子: my-name, 123-abc +- DNS-1123 subdomain规范 + - 由一或多个标签组成,标签之间用'.'分隔;标签可由小写字母、数字、英文中划线'-'构成,标签首尾不可为'-';所有字符总长度为1~253。 + - 例子: example.com, registry.docker-cn.com +- 其他 + - 创建完成后,pod 状态为running + - maxCount为最大努力,不保证一定能达到maxCount + + * @param {Object} opts - parameters + * @param {podSpec} opts.podSpec - pod 创建参数 + * @param {integer} opts.maxCount - 购买实例数量;取值范围:[1,100] + * @param {string} [opts.clientToken] - 保证请求幂等性的字符串;最大长度64个ASCII字符 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string podIds + */ + + createPods (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 createPods" + ) + } + + opts = opts || {} + + if (opts.podSpec === undefined || opts.podSpec === null) { + throw new Error( + "Missing the required parameter 'opts.podSpec' when calling createPods" + ) + } + if (opts.maxCount === undefined || opts.maxCount === null) { + throw new Error( + "Missing the required parameter 'opts.maxCount' when calling createPods" + ) + } + + let postBody = {} + if (opts.podSpec !== undefined && opts.podSpec !== null) { + postBody['podSpec'] = opts.podSpec + } + if (opts.maxCount !== undefined && opts.maxCount !== null) { + postBody['maxCount'] = opts.maxCount + } + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 createPods 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}/pods', + '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) + } + ) + } + + /** + * 批量查询 pod 的状态信息<br> +此接口支持分页查询,默认每页20条。 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 500] optional + * @param {filter} [opts.filters] - podId - pod ID,精确匹配,支持多个 +privateIpAddress - 主网卡IP地址,模糊匹配,支持单个 +az - 可用区,精确匹配,支持多个 +vpcId - 私有网络ID,精确匹配,支持多个 +phase - pod 状态,精确匹配,支持多个 +name - 实例名称,模糊匹配,支持单个 +subnetId - 镜像ID,精确匹配,支持多个 +agId - 高可用组ID,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param briefPodStatus podsStatus + * @param number totalCount + */ + + describePodsStatus (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 describePodsStatus" + ) + } + + 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 pod/2.7.0' + } + + 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 describePodsStatus 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}/podsStatus', + '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) + } + ) + } + + /** + * podName 是否符合命名规范,以及查询指定 podName 区域内是否已经存在。 + + * @param {Object} opts - parameters + * @param {string} opts.podName - 用户定义的 pod 名称,符合 DNS-1123 subdomain 规范。 + * @param {integer} [opts.maxCount] - 需要创建的 pod 总数,默认创建一个,不同的总数会对校验结果产生影响。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer code 用户指定 podName 是否通过校验 0 通过 1 名称为空 2 不符合规范 3 重名。 + * @param string reason code 字段非零时,给出详细原因。 + */ + + checkPodName (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 checkPodName" + ) + } + + opts = opts || {} + + if (opts.podName === undefined || opts.podName === null) { + throw new Error( + "Missing the required parameter 'opts.podName' when calling checkPodName" + ) + } + + let postBody = {} + if (opts.podName !== undefined && opts.podName !== null) { + postBody['podName'] = opts.podName + } + if (opts.maxCount !== undefined && opts.maxCount !== null) { + postBody['maxCount'] = opts.maxCount + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 checkPodName 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}/pods:checkPodName', + '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) + } + ) + } + + /** + * 查询一个 pod 的详细信息 + + * @param {Object} opts - parameters + * @param {string} opts.podId - Pod ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param pod pod + */ + + describePod (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 describePod" + ) + } + + opts = opts || {} + + if (opts.podId === undefined || opts.podId === null) { + throw new Error( + "Missing the required parameter 'opts.podId' when calling describePod" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + podId: opts.podId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 describePod 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}/pods/{podId}', + '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) + } + ) + } + + /** + * pod 状态必须为 stopped、running 或 error状态。 <br> +按量付费的实例,如不主动删除将一直运行,不再使用的实例,可通过本接口主动停用。<br> +只能支持主动删除按量计费类型的实例。包年包月过期的 pod 也可以删除,其它的情况还请发工单系统。计费状态异常的容器无法删除。 + [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.podId - Pod ID + * @param {boolean} [opts.deletePrimaryNetworkInterfaceAllElasticIp] - 是否删除主机的主网卡绑定的所有弹性公网IP,默认为否。可选值:`true`,`false`。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deletePod (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 deletePod" + ) + } + + opts = opts || {} + + if (opts.podId === undefined || opts.podId === null) { + throw new Error( + "Missing the required parameter 'opts.podId' when calling deletePod" + ) + } + + let postBody = null + let queryParams = {} + if ( + opts.deletePrimaryNetworkInterfaceAllElasticIp !== undefined && + opts.deletePrimaryNetworkInterfaceAllElasticIp !== null + ) { + queryParams['deletePrimaryNetworkInterfaceAllElasticIp'] = + opts.deletePrimaryNetworkInterfaceAllElasticIp + } + + let pathParams = { + regionId: regionId, + podId: opts.podId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 deletePod 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}/pods/{podId}', + '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) + } + ) + } + + /** + * 启动处于关闭状态的单个 pod ,处在任务执行中的 pod 无法启动。<br> +pod 实例或其绑定的云盘已欠费时,容器将无法正常启动。<br> + + * @param {Object} opts - parameters + * @param {string} opts.podId - Pod ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + startPod (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 startPod" + ) + } + + opts = opts || {} + + if (opts.podId === undefined || opts.podId === null) { + throw new Error( + "Missing the required parameter 'opts.podId' when calling startPod" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + podId: opts.podId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 startPod 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}/pods/{podId}:startPod', + '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) + } + ) + } + + /** + * 停止处于运行状态的单个实例,处于任务执行中的 pod 无法启动。 + + * @param {Object} opts - parameters + * @param {string} opts.podId - Pod ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + stopPod (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 stopPod" + ) + } + + opts = opts || {} + + if (opts.podId === undefined || opts.podId === null) { + throw new Error( + "Missing the required parameter 'opts.podId' when calling stopPod" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + podId: opts.podId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 stopPod 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}/pods/{podId}:stopPod', + '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) + } + ) + } + + /** + * 修改 pod 的描述。 + + * @param {Object} opts - parameters + * @param {string} opts.podId - Pod ID + * @param {string} [opts.description] - 修改后的描述 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyPodAttribute (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 modifyPodAttribute" + ) + } + + opts = opts || {} + + if (opts.podId === undefined || opts.podId === null) { + throw new Error( + "Missing the required parameter 'opts.podId' when calling modifyPodAttribute" + ) + } + + let postBody = {} + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + podId: opts.podId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 modifyPodAttribute 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}/pods/{podId}:modifyPodAttribute', + 'PATCH', + 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) + } + ) + } + + /** + * pod 绑定弹性公网 IP,绑定的是主网卡、主内网IP对应的弹性IP. <br> +一个 pod 只能绑定一个弹性公网 IP(主网卡),若主网卡已存在弹性公网IP,会返回错误。<br> +如果是黑名单中的用户,会返回错误。 + + * @param {Object} opts - parameters + * @param {string} opts.podId - Pod ID + * @param {string} opts.elasticIpId - 弹性IP ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + associateElasticIp (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 associateElasticIp" + ) + } + + opts = opts || {} + + if (opts.podId === undefined || opts.podId === null) { + throw new Error( + "Missing the required parameter 'opts.podId' when calling associateElasticIp" + ) + } + if (opts.elasticIpId === undefined || opts.elasticIpId === null) { + throw new Error( + "Missing the required parameter 'opts.elasticIpId' when calling associateElasticIp" + ) + } + + let postBody = {} + if (opts.elasticIpId !== undefined && opts.elasticIpId !== null) { + postBody['elasticIpId'] = opts.elasticIpId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + podId: opts.podId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 associateElasticIp 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}/pods/{podId}:associateElasticIp', + '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) + } + ) + } + + /** + * pod 解绑公网 IP,解绑的是主网卡、主内网 IP 对应的弹性 IP. + + * @param {Object} opts - parameters + * @param {string} opts.podId - Pod ID + * @param {string} opts.elasticIpId - 弹性IP ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + disassociateElasticIp (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 disassociateElasticIp" + ) + } + + opts = opts || {} + + if (opts.podId === undefined || opts.podId === null) { + throw new Error( + "Missing the required parameter 'opts.podId' when calling disassociateElasticIp" + ) + } + if (opts.elasticIpId === undefined || opts.elasticIpId === null) { + throw new Error( + "Missing the required parameter 'opts.elasticIpId' when calling disassociateElasticIp" + ) + } + + let postBody = {} + if (opts.elasticIpId !== undefined && opts.elasticIpId !== null) { + postBody['elasticIpId'] = opts.elasticIpId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + podId: opts.podId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 disassociateElasticIp 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}/pods/{podId}:disassociateElasticIp', + '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.podId - Pod ID + * @param {string} opts.containerName - container name + * @param {integer} [opts.tailLines] - 返回日志文件中倒数 tailLines 行,如不指定,默认从容器启动时或 sinceSeconds 指定的时间读取。 + optional + * @param {integer} [opts.sinceSeconds] - 返回相对于当前时间之前sinceSeconds之内的日志。 + optional + * @param {integer} [opts.limitBytes] - 限制返回的日志文件内容字节数,取值范围 [1-4]KB,最大 4KB. + optional + * @param {string} [opts.startTime] - 日志时间上限,不传表示不限时间 + optional + * @param {string} [opts.endTime] - 日志时间下限,不传表示不限时间 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param logs logs + */ + + getContainerLogs (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 getContainerLogs" + ) + } + + opts = opts || {} + + if (opts.podId === undefined || opts.podId === null) { + throw new Error( + "Missing the required parameter 'opts.podId' when calling getContainerLogs" + ) + } + if (opts.containerName === undefined || opts.containerName === null) { + throw new Error( + "Missing the required parameter 'opts.containerName' when calling getContainerLogs" + ) + } + + let postBody = null + let queryParams = {} + if (opts.tailLines !== undefined && opts.tailLines !== null) { + queryParams['tailLines'] = opts.tailLines + } + if (opts.sinceSeconds !== undefined && opts.sinceSeconds !== null) { + queryParams['sinceSeconds'] = opts.sinceSeconds + } + if (opts.limitBytes !== undefined && opts.limitBytes !== null) { + queryParams['limitBytes'] = opts.limitBytes + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: regionId, + podId: opts.podId, + containerName: opts.containerName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 getContainerLogs 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}/pods/{podId}/containers/{containerName}:getContainerLogs', + '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) + } + ) + } + + /** + * 对 pod 中的容器使用新的镜像进行重置,pod 需要处于关闭状态。 + + * @param {Object} opts - parameters + * @param {string} opts.podId - Pod ID + * @param {array} [opts.containers] - 重置容器相关参数 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + rebuildPod (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 rebuildPod" + ) + } + + opts = opts || {} + + if (opts.podId === undefined || opts.podId === null) { + throw new Error( + "Missing the required parameter 'opts.podId' when calling rebuildPod" + ) + } + + let postBody = {} + if (opts.containers !== undefined && opts.containers !== null) { + postBody['containers'] = opts.containers + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + podId: opts.podId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 rebuildPod 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}/pods/{podId}:rebuild', + '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) + } + ) + } + + /** + * 调整pod实例类型配置。 +- pod phase 需是停止状态; +- 支持升配、降配;**不支持原有规格** +- 计费类型不变 + - 包年包月:需要计算配置差价,如果所选配置价格高,需要补齐到期前的差价,到期时间不变;如果所选配置价格低,需要延长到期时间 + - 按配置:按照所选规格,进行计费 +- 支持对 pod 中的容器进行资源限制、资源需求的调整 + - 容器需求的总资源占用不得超过 pod 的实例类型 + - 容器资源限制不得超过 pod 的实例类型 + + * @param {Object} opts - parameters + * @param {string} opts.podId - Pod ID + * @param {string} opts.instanceType - 新实例类型,不可与原实例类型相同 + * @param {array} [opts.containerResources] - 新实例类型,不可与原实例类型相同 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + resizePod (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 resizePod" + ) + } + + opts = opts || {} + + if (opts.podId === undefined || opts.podId === null) { + throw new Error( + "Missing the required parameter 'opts.podId' when calling resizePod" + ) + } + if (opts.instanceType === undefined || opts.instanceType === null) { + throw new Error( + "Missing the required parameter 'opts.instanceType' when calling resizePod" + ) + } + + let postBody = {} + if (opts.instanceType !== undefined && opts.instanceType !== null) { + postBody['instanceType'] = opts.instanceType + } + if ( + opts.containerResources !== undefined && + opts.containerResources !== null + ) { + postBody['containerResources'] = opts.containerResources + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + podId: opts.podId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 resizePod 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}/pods/{podId}:resize', + '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) + } + ) + } + + /** + * 批量查询Pod模板。支持分页查询,默认每页20条。 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1。取值范围:[1,∞) optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 100] optional + * @param {filter} [opts.filters] - podTemplateIds - podTemplate ID,精确匹配,支持多个 +name - pod模板名称,模糊匹配,支持单个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param podTemplate podTemplates + * @param number totalCount + */ + + describePodTemplates (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 describePodTemplates" + ) + } + + 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 pod/2.7.0' + } + + 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 describePodTemplates 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}/podTemplates', + '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) + } + ) + } + + /** + * 创建Pod模板 + * @param {Object} opts - parameters + * @param {string} opts.name - pod模板的名称,参考 [公共参数规范](https://docs.jdcloud.com/virtual-machines/api/general_parameters)。 + * @param {string} [opts.description] - pod模板描述,参考 [公共参数规范](https://docs.jdcloud.com/virtual-machines/api/general_parameters)。 optional + * @param {podTemplateSpec} opts.podTemplateSpec - pod模板创建参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string podTemplateId Pod模板ID。 + */ + + createPodTemplate (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 createPodTemplate" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createPodTemplate" + ) + } + if (opts.podTemplateSpec === undefined || opts.podTemplateSpec === null) { + throw new Error( + "Missing the required parameter 'opts.podTemplateSpec' when calling createPodTemplate" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.podTemplateSpec !== undefined && opts.podTemplateSpec !== null) { + postBody['podTemplateSpec'] = opts.podTemplateSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 createPodTemplate 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}/podTemplates', + '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) + } + ) + } + + /** + * 查询Pod模板的详细信息 + * @param {Object} opts - parameters + * @param {string} opts.podTemplateId - Pod模板ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param podTemplate podTemplate + */ + + describePodTemplate (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 describePodTemplate" + ) + } + + opts = opts || {} + + if (opts.podTemplateId === undefined || opts.podTemplateId === null) { + throw new Error( + "Missing the required parameter 'opts.podTemplateId' when calling describePodTemplate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + podTemplateId: opts.podTemplateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 describePodTemplate 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}/podTemplates/{podTemplateId}', + '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) + } + ) + } + + /** + * 修改Pod模板的配置 + * @param {Object} opts - parameters + * @param {string} opts.podTemplateId - Pod模板ID + * @param {string} [opts.name] - pod模板的名称,参考 [公共参数规范](https://docs.jdcloud.com/virtual-machines/api/general_parameters)。 optional + * @param {string} [opts.description] - pod模板描述,参考 [公共参数规范](https://docs.jdcloud.com/virtual-machines/api/general_parameters)。 optional + * @param {updatePodTemplateSpec} [opts.podTemplateSpec] - pod模板修改参。如果没有指定,那么就意味着不进行修改。在不特殊说明的情况下,这个规则也适用于此结构体内的其他字段。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updatePodTemplate (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 updatePodTemplate" + ) + } + + opts = opts || {} + + if (opts.podTemplateId === undefined || opts.podTemplateId === null) { + throw new Error( + "Missing the required parameter 'opts.podTemplateId' when calling updatePodTemplate" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.podTemplateSpec !== undefined && opts.podTemplateSpec !== null) { + postBody['podTemplateSpec'] = opts.podTemplateSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + podTemplateId: opts.podTemplateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 updatePodTemplate 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}/podTemplates/{podTemplateId}', + 'PATCH', + 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) + } + ) + } + + /** + * 删除单个pod模板 + * @param {Object} opts - parameters + * @param {string} opts.podTemplateId - Pod模板ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deletePodTemplate (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 deletePodTemplate" + ) + } + + opts = opts || {} + + if (opts.podTemplateId === undefined || opts.podTemplateId === null) { + throw new Error( + "Missing the required parameter 'opts.podTemplateId' when calling deletePodTemplate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + podTemplateId: opts.podTemplateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 deletePodTemplate 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}/podTemplates/{podTemplateId}', + '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) + } + ) + } + + /** + * 校验pod模板的有效性。 + +## 接口说明 +- 调用该接口可以校验Pod模板是否有效,例如某些关联资源(如子网、镜像等)已经被删除了。 + + * @param {Object} opts - parameters + * @param {string} opts.podTemplateId - Pod模板ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + verifyPodTemplate (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 verifyPodTemplate" + ) + } + + opts = opts || {} + + if (opts.podTemplateId === undefined || opts.podTemplateId === null) { + throw new Error( + "Missing the required parameter 'opts.podTemplateId' when calling verifyPodTemplate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + podTemplateId: opts.podTemplateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 verifyPodTemplate 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}/podTemplates/{podTemplateId}:verify', + '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) + } + ) + } + + /** + * 查询资源的配额,支持:原生容器,pod,secret,镜像缓存,Pod模板 + + * @param {Object} opts - parameters + * @param {string} opts.resourceType - resourceType - 资源类型,支持 [container, pod, secret, imageCache,podTemplate] + + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param quota quota + */ + + describeQuota (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 describeQuota" + ) + } + + opts = opts || {} + + if (opts.resourceType === undefined || opts.resourceType === null) { + throw new Error( + "Missing the required parameter 'opts.resourceType' when calling describeQuota" + ) + } + + let postBody = null + let queryParams = {} + if (opts.resourceType !== undefined && opts.resourceType !== null) { + queryParams['resourceType'] = opts.resourceType + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 describeQuota 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}/quotas', + '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) + } + ) + } + + /** + * 查询 secret 列表。<br> +此接口支持分页查询,默认每页20条。 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为20;取值范围[10, 100] optional + * @param {filter} [opts.filters] - name - secret名称,支持模糊搜索 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param secret secrets + * @param number totalCount + */ + + describeSecrets (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 describeSecrets" + ) + } + + 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 pod/2.7.0' + } + + 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 describeSecrets 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}/secrets', + '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) + } + ) + } + + /** + * 创建一个 secret,用于存放镜像仓库机密相关信息。 + + * @param {Object} opts - parameters + * @param {string} opts.name - 机密数据名称,不能重复 + + * @param {string} opts.secretType - 机密数据的类型,目前仅支持:docker-registry 类型,用来和docker registry认证的类型。 + + * @param {dockerRegistryData} opts.data - 机密的数据。<br> +key 的有效字符包括字母、数字、-、_和.; <br> +value 是 Base64 编码的字符串,不能包含换行符(在 linux 下使用 base64 -w 0选项),每个value长度上限为4KB,整个data的长度不能超过256KB; <br> +必须包含server、username、password 字段,email 字段是可选的。<br> + + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string secretName + */ + + createSecret (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 createSecret" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createSecret" + ) + } + if (opts.secretType === undefined || opts.secretType === null) { + throw new Error( + "Missing the required parameter 'opts.secretType' when calling createSecret" + ) + } + if (opts.data === undefined || opts.data === null) { + throw new Error( + "Missing the required parameter 'opts.data' when calling createSecret" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.secretType !== undefined && opts.secretType !== null) { + postBody['secretType'] = opts.secretType + } + if (opts.data !== undefined && opts.data !== null) { + postBody['data'] = opts.data + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 createSecret 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}/secrets', + '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) + } + ) + } + + /** + * 查询单个 secret 详情 + + * @param {Object} opts - parameters + * @param {string} opts.name - Secret Name + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param secret secret + */ + + describeSecret (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 describeSecret" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling describeSecret" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + name: opts.name + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 describeSecret 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}/secrets/{name}', + '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) + } + ) + } + + /** + * 删除单个 secret + + * @param {Object} opts - parameters + * @param {string} opts.name - Secret Name + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteSecret (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 deleteSecret" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling deleteSecret" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + name: opts.name + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 pod/2.7.0' + } + + 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 deleteSecret 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}/secrets/{name}', + '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) + } + ) + } +} +module.exports = POD diff --git a/packages/libs/lib-jdcloud/src/repo/portal/v1/portal.js b/packages/libs/lib-jdcloud/src/repo/portal/v1/portal.js new file mode 100644 index 000000000..bc0c72d6f --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/portal/v1/portal.js @@ -0,0 +1,302 @@ +/* + * 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. + * + * search + * 搜索相关接口 + * + * 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 = 'portal' +Service._services[serviceId] = true + +/** + * portal service. + * @version 0.1.4 + */ + +JDCloud.PORTAL = class PORTAL extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'portal.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询产品的详细信息 + + * @param {Object} opts - parameters + * @param {string} opts.url - 产品url + * @param {string} opts.lang - 中文cn 英文en + * @param {string} opts.ak - 外部使用ak; + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param product result 产品详情 + */ + + describeProduct (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 describeProduct" + ) + } + + opts = opts || {} + + if (opts.url === undefined || opts.url === null) { + throw new Error( + "Missing the required parameter 'opts.url' when calling describeProduct" + ) + } + if (opts.lang === undefined || opts.lang === null) { + throw new Error( + "Missing the required parameter 'opts.lang' when calling describeProduct" + ) + } + if (opts.ak === undefined || opts.ak === null) { + throw new Error( + "Missing the required parameter 'opts.ak' when calling describeProduct" + ) + } + + let postBody = null + let queryParams = {} + if (opts.url !== undefined && opts.url !== null) { + queryParams['url'] = opts.url + } + if (opts.lang !== undefined && opts.lang !== null) { + queryParams['lang'] = opts.lang + } + if (opts.ak !== undefined && opts.ak !== null) { + queryParams['ak'] = opts.ak + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 portal/0.1.4' + } + + 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 describeProduct 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 = this.makeRequest( + '/regions/{regionId}/product', + '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.id - 语言类型;中文cn;英文en; + * @param {string} opts.ak - 外部使用ak; + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param navigation result + */ + + describeProductsById (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 describeProductsById" + ) + } + + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling describeProductsById" + ) + } + if (opts.ak === undefined || opts.ak === null) { + throw new Error( + "Missing the required parameter 'opts.ak' when calling describeProductsById" + ) + } + + let postBody = null + let queryParams = {} + if (opts.id !== undefined && opts.id !== null) { + queryParams['id'] = opts.id + } + if (opts.ak !== undefined && opts.ak !== null) { + queryParams['ak'] = opts.ak + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 portal/0.1.4' + } + + 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 describeProductsById 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 = this.makeRequest( + '/regions/{regionId}/getProductsById', + '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 = JDCloud.PORTAL diff --git a/packages/libs/lib-jdcloud/src/repo/privatezone/v1/privatezone.js b/packages/libs/lib-jdcloud/src/repo/privatezone/v1/privatezone.js new file mode 100644 index 000000000..e1f857805 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/privatezone/v1/privatezone.js @@ -0,0 +1,2098 @@ +/* + * 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. + * + * 私有域名zone + * 私有域名zone API + * + * 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 = 'privatezone' +Service._services[serviceId] = true + +/** + * privatezone service. + * @version 0.0.1 + */ + +class PRIVATEZONE extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'privatezone.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询操作日志 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageSize] - 页容量,默认10,取值范围(1 - 100) optional + * @param {integer} [opts.pageNumber] - 页序号,默认值1,不能小于1 optional + * @param {string} opts.start - 起始时间,格式:UTC时间例如2017-11-10T23:00:00Z + * @param {string} opts.end - 结束时间,格式:UTC时间例如2017-11-10T23:00:00Z + * @param {string} [opts.keyWord] - 日志模糊匹配的关键词 optional + * @param {boolean} [opts.success] - 操作结果 false->失败 true->成功 optional + * @param {string} [opts.actionType] - 日志类型,支持的类型有:CREATE_ZONE、DELETE_ZONE、LOCK_ZONE、CREATE_RR、MODIFY_RR、DELETE_RR、SET_RR_STATUS、RETRY_RECURSE_ZONE optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param describeActionLogsRes dataList + * @param integer currentCount 当前页记录数量 + * @param integer totalCount 总记录数量 + * @param integer totalPage 总页数 + */ + + describeActionLogs (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 describeActionLogs" + ) + } + + opts = opts || {} + + if (opts.start === undefined || opts.start === null) { + throw new Error( + "Missing the required parameter 'opts.start' when calling describeActionLogs" + ) + } + if (opts.end === undefined || opts.end === null) { + throw new Error( + "Missing the required parameter 'opts.end' when calling describeActionLogs" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + queryParams['pageNumber'] = opts.pageNumber + } + if (opts.start !== undefined && opts.start !== null) { + queryParams['start'] = opts.start + } + if (opts.end !== undefined && opts.end !== null) { + queryParams['end'] = opts.end + } + if (opts.keyWord !== undefined && opts.keyWord !== null) { + queryParams['keyWord'] = opts.keyWord + } + if (opts.success !== undefined && opts.success !== null) { + queryParams['success'] = opts.success + } + if (opts.actionType !== undefined && opts.actionType !== null) { + queryParams['actionType'] = opts.actionType + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 privatezone/0.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 describeActionLogs 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}/actionLogs', + '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.pageSize] - 页容量,默认10,取值范围(1 - 100) optional + * @param {integer} [opts.pageNumber] - 页序号,默认1,不能小于1 optional + * @param {string} [opts.instanceId] - 实例ID optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param describeInstancesRes dataList + * @param integer currentCount 当前页记录数量 + * @param integer totalCount 总记录数量 + * @param integer totalPage 总页数 + */ + + 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.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + queryParams['pageNumber'] = opts.pageNumber + } + if (opts.instanceId !== undefined && opts.instanceId !== null) { + queryParams['instanceId'] = opts.instanceId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 privatezone/0.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}/instances', + '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.zoneId - zone id + * @param {string} [opts.hostRecord] - 主机记录左右模糊查询 optional + * @param {integer} [opts.pageSize] - 页容量,默认10,取值范围(1 - 100) optional + * @param {integer} [opts.pageNumber] - 页序号,默认1,不能小于1 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param describeResourceRecordsRes dataList + * @param integer currentCount 当前页记录数量 + * @param integer totalCount 总记录数量 + * @param integer totalPage 总页数 + */ + + describeResourceRecords (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 describeResourceRecords" + ) + } + + opts = opts || {} + + if (opts.zoneId === undefined || opts.zoneId === null) { + throw new Error( + "Missing the required parameter 'opts.zoneId' when calling describeResourceRecords" + ) + } + + let postBody = null + let queryParams = {} + if (opts.hostRecord !== undefined && opts.hostRecord !== null) { + queryParams['hostRecord'] = opts.hostRecord + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + queryParams['pageNumber'] = opts.pageNumber + } + + let pathParams = { + regionId: regionId, + zoneId: opts.zoneId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 privatezone/0.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 describeResourceRecords 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}/zone/{zoneId}/resourceRecords', + '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.zoneId - zone id + * @param {} [opts.hostRecord] - 主机记录 optional + * @param {} [opts.hostValue] - 主机记录值 optional + * @param {} [opts.recordType] - 解析类型,目前支持类型 A AAAA CNAME TXT CAA SRV MX PTR optional + * @param {} [opts.ttl] - TTL值 optional + * @param {} [opts.priority] - 优先级,只存在于MX, SRV解析记录类型 optional + * @param {} [opts.port] - 端口,只存在于SRV解析记录类型 optional + * @param {} [opts.weight] - 解析记录的权重,目前支持权重的有:A/AAAA/CNAME,A/AAAA权重范围0-100,CNAME权重范围1-100。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + createResourceRecord (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 createResourceRecord" + ) + } + + opts = opts || {} + + if (opts.zoneId === undefined || opts.zoneId === null) { + throw new Error( + "Missing the required parameter 'opts.zoneId' when calling createResourceRecord" + ) + } + + let postBody = {} + if (opts.hostRecord !== undefined && opts.hostRecord !== null) { + postBody['hostRecord'] = opts.hostRecord + } + if (opts.hostValue !== undefined && opts.hostValue !== null) { + postBody['hostValue'] = opts.hostValue + } + if (opts.recordType !== undefined && opts.recordType !== null) { + postBody['recordType'] = opts.recordType + } + if (opts.ttl !== undefined && opts.ttl !== null) { + postBody['ttl'] = opts.ttl + } + if (opts.priority !== undefined && opts.priority !== null) { + postBody['priority'] = opts.priority + } + if (opts.port !== undefined && opts.port !== null) { + postBody['port'] = opts.port + } + if (opts.weight !== undefined && opts.weight !== null) { + postBody['weight'] = opts.weight + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + zoneId: opts.zoneId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 privatezone/0.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 createResourceRecord 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}/zone/{zoneId}/resourceRecords', + '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.zoneId - zone id + * @param {string} opts.resourceRecordId - 解析记录ID + * @param {} [opts.hostRecord] - 主机记录 optional + * @param {} [opts.hostValue] - 主机记录值 optional + * @param {} [opts.recordType] - 解析类型,目前支持类型 A AAAA CNAME TXT CAA SRV MX PTR optional + * @param {} [opts.ttl] - TTL值 optional + * @param {} [opts.priority] - 优先级,只存在于MX, SRV解析记录类型 optional + * @param {} [opts.port] - 端口,只存在于SRV解析记录类型 optional + * @param {} [opts.weight] - 解析记录的权重,目前支持权重的有:A/AAAA/CNAME,A/AAAA权重范围0-100,CNAME权重范围1-100。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyResourceRecord (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 modifyResourceRecord" + ) + } + + opts = opts || {} + + if (opts.zoneId === undefined || opts.zoneId === null) { + throw new Error( + "Missing the required parameter 'opts.zoneId' when calling modifyResourceRecord" + ) + } + if (opts.resourceRecordId === undefined || opts.resourceRecordId === null) { + throw new Error( + "Missing the required parameter 'opts.resourceRecordId' when calling modifyResourceRecord" + ) + } + + let postBody = {} + if (opts.hostRecord !== undefined && opts.hostRecord !== null) { + postBody['hostRecord'] = opts.hostRecord + } + if (opts.hostValue !== undefined && opts.hostValue !== null) { + postBody['hostValue'] = opts.hostValue + } + if (opts.recordType !== undefined && opts.recordType !== null) { + postBody['recordType'] = opts.recordType + } + if (opts.ttl !== undefined && opts.ttl !== null) { + postBody['ttl'] = opts.ttl + } + if (opts.priority !== undefined && opts.priority !== null) { + postBody['priority'] = opts.priority + } + if (opts.port !== undefined && opts.port !== null) { + postBody['port'] = opts.port + } + if (opts.weight !== undefined && opts.weight !== null) { + postBody['weight'] = opts.weight + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + zoneId: opts.zoneId, + resourceRecordId: opts.resourceRecordId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 privatezone/0.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 modifyResourceRecord 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}/zone/{zoneId}/resourceRecord/{resourceRecordId}', + '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) + } + ) + } + + /** + * 删除解析记录。批量删除时多个resourceRecordId用","分隔。批量删除每次最多不超过100个记录 + + * @param {Object} opts - parameters + * @param {string} opts.zoneId - zone id + * @param {string} opts.resourceRecordId - 解析记录ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteResourceRecords (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 deleteResourceRecords" + ) + } + + opts = opts || {} + + if (opts.zoneId === undefined || opts.zoneId === null) { + throw new Error( + "Missing the required parameter 'opts.zoneId' when calling deleteResourceRecords" + ) + } + if (opts.resourceRecordId === undefined || opts.resourceRecordId === null) { + throw new Error( + "Missing the required parameter 'opts.resourceRecordId' when calling deleteResourceRecords" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + zoneId: opts.zoneId, + resourceRecordId: opts.resourceRecordId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 privatezone/0.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 deleteResourceRecords 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}/zone/{zoneId}/resourceRecords/{resourceRecordId}', + '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) + } + ) + } + + /** + * 设置解析记录状态,STOP操作会将停止该记录的解析,直到再次START。批量设置时多个resourceRecordId用","分隔。批量设置时每次最多不超过100个记录 + + * @param {Object} opts - parameters + * @param {string} opts.zoneId - zone id + * @param {string} opts.resourceRecordId - 解析记录ID + * @param {string} opts.status - 解析记录状态 START->正常解析 STOP->停止解析 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + setResourceRecordsStatus (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 setResourceRecordsStatus" + ) + } + + opts = opts || {} + + if (opts.zoneId === undefined || opts.zoneId === null) { + throw new Error( + "Missing the required parameter 'opts.zoneId' when calling setResourceRecordsStatus" + ) + } + if (opts.resourceRecordId === undefined || opts.resourceRecordId === null) { + throw new Error( + "Missing the required parameter 'opts.resourceRecordId' when calling setResourceRecordsStatus" + ) + } + if (opts.status === undefined || opts.status === null) { + throw new Error( + "Missing the required parameter 'opts.status' when calling setResourceRecordsStatus" + ) + } + + let postBody = {} + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + zoneId: opts.zoneId, + resourceRecordId: opts.resourceRecordId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 privatezone/0.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 setResourceRecordsStatus 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}/zone/{zoneId}/resourceRecords/{resourceRecordId}/status', + '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) + } + ) + } + + /** + * 导出当前zone下所有解析记录,返回的数据是可以转换为csv文件格式的字符串 + + * @param {Object} opts - parameters + * @param {string} opts.zoneId - zone id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string data 导出数据结果,此结果是可以存储为csv文件格式的字符串 + */ + + exportResourceRecords (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 exportResourceRecords" + ) + } + + opts = opts || {} + + if (opts.zoneId === undefined || opts.zoneId === null) { + throw new Error( + "Missing the required parameter 'opts.zoneId' when calling exportResourceRecords" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + zoneId: opts.zoneId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 privatezone/0.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 exportResourceRecords 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}/zone/{zoneId}/resourceRecords:export', + '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) + } + ) + } + + /** + * 批量导入解析记录,批量导入每次不可超过100条记录 + + * @param {Object} opts - parameters + * @param {string} opts.zoneId - zone id + * @param {array} opts.importResourceRecordsReq - 导入的解析记录数据 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + importResourceRecords (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 importResourceRecords" + ) + } + + opts = opts || {} + + if (opts.zoneId === undefined || opts.zoneId === null) { + throw new Error( + "Missing the required parameter 'opts.zoneId' when calling importResourceRecords" + ) + } + if ( + opts.importResourceRecordsReq === undefined || + opts.importResourceRecordsReq === null + ) { + throw new Error( + "Missing the required parameter 'opts.importResourceRecordsReq' when calling importResourceRecords" + ) + } + + let postBody = {} + if ( + opts.importResourceRecordsReq !== undefined && + opts.importResourceRecordsReq !== null + ) { + postBody['importResourceRecordsReq'] = opts.importResourceRecordsReq + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + zoneId: opts.zoneId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 privatezone/0.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 importResourceRecords 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}/zone/{zoneId}/resourceRecords:import', + '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) + } + ) + } + + /** + * 统计zone的解析量 + + * @param {Object} opts - parameters + * @param {string} opts.start - 查询时间段的起始时间, UTC时间格式,例如2017-11-10T23:00:00Z + * @param {string} opts.end - 查询时间段的终止时间, UTC时间格式,例如2017-11-10T23:00:00Z + * @param {array} [opts.zoneIds] - 查询的zone id,默认查询所有zone optional + * @param {array} [opts.vpcIds] - 查询的vpc id,默认查询所有vpc optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer time + * @param integer traffic + */ + + zoneResolveCount (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 zoneResolveCount" + ) + } + + opts = opts || {} + + if (opts.start === undefined || opts.start === null) { + throw new Error( + "Missing the required parameter 'opts.start' when calling zoneResolveCount" + ) + } + if (opts.end === undefined || opts.end === null) { + throw new Error( + "Missing the required parameter 'opts.end' when calling zoneResolveCount" + ) + } + + let postBody = {} + if (opts.start !== undefined && opts.start !== null) { + postBody['start'] = opts.start + } + if (opts.end !== undefined && opts.end !== null) { + postBody['end'] = opts.end + } + if (opts.zoneIds !== undefined && opts.zoneIds !== null) { + postBody['zoneIds'] = opts.zoneIds + } + if (opts.vpcIds !== undefined && opts.vpcIds !== null) { + postBody['vpcIds'] = opts.vpcIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 privatezone/0.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 zoneResolveCount 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}/stat:zoneResolveCount', + '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) + } + ) + } + + /** + * 统计zone的流量 + + * @param {Object} opts - parameters + * @param {string} opts.start - 查询时间段的起始时间, UTC时间格式,例如2017-11-10T23:00:00Z + * @param {string} opts.end - 查询时间段的终止时间, UTC时间格式,例如2017-11-10T23:00:00Z + * @param {array} [opts.zoneIds] - 查询的zone id,默认查询所有zone optional + * @param {array} [opts.vpcIds] - 查询的vpc id,默认查询所有vpc optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer time + * @param string unit 数据序列的单位 + * @param number traffic + */ + + zoneFlowCount (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 zoneFlowCount" + ) + } + + opts = opts || {} + + if (opts.start === undefined || opts.start === null) { + throw new Error( + "Missing the required parameter 'opts.start' when calling zoneFlowCount" + ) + } + if (opts.end === undefined || opts.end === null) { + throw new Error( + "Missing the required parameter 'opts.end' when calling zoneFlowCount" + ) + } + + let postBody = {} + if (opts.start !== undefined && opts.start !== null) { + postBody['start'] = opts.start + } + if (opts.end !== undefined && opts.end !== null) { + postBody['end'] = opts.end + } + if (opts.zoneIds !== undefined && opts.zoneIds !== null) { + postBody['zoneIds'] = opts.zoneIds + } + if (opts.vpcIds !== undefined && opts.vpcIds !== null) { + postBody['vpcIds'] = opts.vpcIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 privatezone/0.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 zoneFlowCount 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}/stat:zoneFlowCount', + '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) + } + ) + } + + /** + * 查询私有解析zone列表 + + * @param {Object} opts - parameters + * @param {string} [opts.zone] - zone模块匹配查询 optional + * @param {string} [opts.instanceId] - 购买的套餐实例ID optional + * @param {string} [opts.zoneId] - 根据zoneId精准查询(zone模糊查询失效) optional + * @param {integer} [opts.pageSize] - 页容量,默认10,取值范围(1 - 100) optional + * @param {integer} [opts.pageNumber] - 页序号,默认1,不能小于1 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param describeZonesRes dataList + * @param integer currentCount 当前页记录数量 + * @param integer totalCount 总记录数量 + * @param integer totalPage 总页数 + */ + + describeZones (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 describeZones" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.zone !== undefined && opts.zone !== null) { + queryParams['zone'] = opts.zone + } + if (opts.instanceId !== undefined && opts.instanceId !== null) { + queryParams['instanceId'] = opts.instanceId + } + if (opts.zoneId !== undefined && opts.zoneId !== null) { + queryParams['zoneId'] = opts.zoneId + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + queryParams['pageNumber'] = opts.pageNumber + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 privatezone/0.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 describeZones 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}/zones', + '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) + } + ) + } + + /** + * - 添加一个私有解析的zone,可添加以下三种类型的zone +- 云内全局zone:zone的后缀是指定的后缀,如:local。该域名在云内自动全局生效,不用关联vpc即可在vpc内解析,该类型全局唯一,不能重复添加 +- 反向解析zone:zone的后缀是in-addr.arpa时,我们认为他是一个反向解析的zone,反向解析域名前缀目前支持10/172.16-31/192.168网段,如:10.in-addr.arpa、16.172.in-addr.arpa。反向解析的zone只能添加反向解析的记录 +- 私有解析zone:该类型的zone可以时任意符合格式的域名,私有解析zone需要关联vpc后,在vpc内生效解析 + + * @param {Object} opts - parameters + * @param {string} opts.zone - zone + * @param {string} opts.instanceId - 购买的套餐实例ID + * @param {string} opts.zoneType - 域名类型 LOCAL->云内全局 PTR->反向解析zone PV->私有zone + * @param {boolean} [opts.retryRecurse] - 解析失败后是否进行递归解析 optional + * @param {array} [opts.bindVpc] - 绑定的vpc信息 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + createZone (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 createZone" + ) + } + + opts = opts || {} + + if (opts.zone === undefined || opts.zone === null) { + throw new Error( + "Missing the required parameter 'opts.zone' when calling createZone" + ) + } + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createZone" + ) + } + if (opts.zoneType === undefined || opts.zoneType === null) { + throw new Error( + "Missing the required parameter 'opts.zoneType' when calling createZone" + ) + } + + let postBody = {} + if (opts.zone !== undefined && opts.zone !== null) { + postBody['zone'] = opts.zone + } + if (opts.instanceId !== undefined && opts.instanceId !== null) { + postBody['instanceId'] = opts.instanceId + } + if (opts.zoneType !== undefined && opts.zoneType !== null) { + postBody['zoneType'] = opts.zoneType + } + if (opts.retryRecurse !== undefined && opts.retryRecurse !== null) { + postBody['retryRecurse'] = opts.retryRecurse + } + if (opts.bindVpc !== undefined && opts.bindVpc !== null) { + postBody['bindVpc'] = opts.bindVpc + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 privatezone/0.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 createZone 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}/zones', + '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) + } + ) + } + + /** + * 删除zone,该zone下的解析记录和绑定的vpc关联关系将会被删除 + + * @param {Object} opts - parameters + * @param {string} opts.zoneId - zone id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteZone (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 deleteZone" + ) + } + + opts = opts || {} + + if (opts.zoneId === undefined || opts.zoneId === null) { + throw new Error( + "Missing the required parameter 'opts.zoneId' when calling deleteZone" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + zoneId: opts.zoneId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 privatezone/0.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 deleteZone 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}/zone/{zoneId}', + '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.zoneId - zone id + * @param {boolean} opts.retryRecurse - true->解析失败后尝试递归解析 false->解析失败后不进行递归解析 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + retryRecurse (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 retryRecurse" + ) + } + + opts = opts || {} + + if (opts.zoneId === undefined || opts.zoneId === null) { + throw new Error( + "Missing the required parameter 'opts.zoneId' when calling retryRecurse" + ) + } + if (opts.retryRecurse === undefined || opts.retryRecurse === null) { + throw new Error( + "Missing the required parameter 'opts.retryRecurse' when calling retryRecurse" + ) + } + + let postBody = {} + if (opts.retryRecurse !== undefined && opts.retryRecurse !== null) { + postBody['retryRecurse'] = opts.retryRecurse + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + zoneId: opts.zoneId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 privatezone/0.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 retryRecurse 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}/zone/{zoneId}:retryRecurse', + '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) + } + ) + } + + /** + * 绑定vpc +- vpc信息为空时,会将之前的绑定关系全部解除 +- 该接口为覆盖类的接口,请将需要的vpc全部进行绑定 + + * @param {Object} opts - parameters + * @param {string} opts.zoneId - zone id + * @param {array} [opts.bindVpc] - 绑定的vpc信息 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + bindVpc (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 bindVpc" + ) + } + + opts = opts || {} + + if (opts.zoneId === undefined || opts.zoneId === null) { + throw new Error( + "Missing the required parameter 'opts.zoneId' when calling bindVpc" + ) + } + + let postBody = {} + if (opts.bindVpc !== undefined && opts.bindVpc !== null) { + postBody['bindVpc'] = opts.bindVpc + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + zoneId: opts.zoneId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 privatezone/0.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 bindVpc 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}/zone/{zoneId}/vpc:bind', + '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) + } + ) + } +} +module.exports = PRIVATEZONE diff --git a/packages/libs/lib-jdcloud/src/repo/quota/v2/quota.js b/packages/libs/lib-jdcloud/src/repo/quota/v2/quota.js new file mode 100644 index 000000000..439996d00 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/quota/v2/quota.js @@ -0,0 +1,327 @@ +/* + * 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. + * + * JDCLOUD remote quota API + * API JDCLOUD remote quota API + * + * 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 = 'quota' +Service._services[serviceId] = true + +/** + * quota service. + * @version 0.0.2 + */ + +class QUOTA extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'quota.jdcloud-api.com' + options.basePath = '/v2' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 校验配额 + * @param {Object} opts - parameters + * @param {string} [opts.pin] - 用户pin optional + * @param {integer} [opts.siteType] - 站点类型 optional + * @param {string} [opts.appCode] - 业务线 optional + * @param {string} [opts.serviceCode] - 资源产品线 optional + * @param {string} [opts.region] - 地域 optional + * @param {string} [opts.parentResourceId] - 父层资源id(针对有两层结构的服务) optional + * @param {string} [opts.uid] - 业务唯一键 optional + * @param {integer} [opts.quotaAmount] - 配额数量 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success + * @param integer code + * @param string message + * @param verifyQuotaResVo data + * @param string requestId + */ + + verifyUserQuota (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 verifyUserQuota" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.pin !== undefined && opts.pin !== null) { + postBody['pin'] = opts.pin + } + if (opts.siteType !== undefined && opts.siteType !== null) { + postBody['siteType'] = opts.siteType + } + 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.parentResourceId !== undefined && opts.parentResourceId !== null) { + postBody['parentResourceId'] = opts.parentResourceId + } + if (opts.uid !== undefined && opts.uid !== null) { + postBody['uid'] = opts.uid + } + if (opts.quotaAmount !== undefined && opts.quotaAmount !== null) { + postBody['quotaAmount'] = opts.quotaAmount + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 quota/0.0.2' + } + + 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 verifyUserQuota 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}/userQuota:verify', + '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.pin] - 用户pin optional + * @param {integer} [opts.siteType] - 站点类型 optional + * @param {string} [opts.appCode] - 业务线 optional + * @param {string} [opts.serviceCode] - 资源产品线 optional + * @param {string} [opts.region] - 地域 optional + * @param {string} [opts.parentResourceId] - 父层资源id(针对有两层结构的服务) optional + * @param {string} [opts.uid] - 业务唯一键 optional + * @param {integer} [opts.quotaAmount] - 配额数量 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success + * @param integer code + * @param string message + * @param userQuotaResVo data + * @param string requestId + */ + + getUserQuotaDetail (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 getUserQuotaDetail" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.pin !== undefined && opts.pin !== null) { + postBody['pin'] = opts.pin + } + if (opts.siteType !== undefined && opts.siteType !== null) { + postBody['siteType'] = opts.siteType + } + 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.parentResourceId !== undefined && opts.parentResourceId !== null) { + postBody['parentResourceId'] = opts.parentResourceId + } + if (opts.uid !== undefined && opts.uid !== null) { + postBody['uid'] = opts.uid + } + if (opts.quotaAmount !== undefined && opts.quotaAmount !== null) { + postBody['quotaAmount'] = opts.quotaAmount + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 quota/0.0.2' + } + + 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 getUserQuotaDetail 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}/userQuota:getDetail', + '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 = QUOTA diff --git a/packages/libs/lib-jdcloud/src/repo/rds/v1/rds.js b/packages/libs/lib-jdcloud/src/repo/rds/v1/rds.js new file mode 100644 index 000000000..89145b09d --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/rds/v1/rds.js @@ -0,0 +1,15055 @@ +/* + * 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. + * + * 白名单 + * 白名单相关接口 + * + * 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 = 'rds' +Service._services[serviceId] = true + +/** + * rds service. + * @version 1.3.4 + */ + +class RDS extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'rds.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查看某个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 + */ + + describeAccounts (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 describeAccounts" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeAccounts" + ) + } + + 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 rds/1.3.4' + } + + 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 describeAccounts 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}/instances/{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 {} [opts.notes] - 备注信息,仅支持PostgreSQL optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + createAccount (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 createAccount" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createAccount" + ) + } + if (opts.accountName === undefined || opts.accountName === null) { + throw new Error( + "Missing the required parameter 'opts.accountName' when calling createAccount" + ) + } + if (opts.accountPassword === undefined || opts.accountPassword === null) { + throw new Error( + "Missing the required parameter 'opts.accountPassword' when calling createAccount" + ) + } + + let postBody = {} + if (opts.accountName !== undefined && opts.accountName !== null) { + postBody['accountName'] = opts.accountName + } + if (opts.accountPassword !== undefined && opts.accountPassword !== null) { + postBody['accountPassword'] = opts.accountPassword + } + if (opts.notes !== undefined && opts.notes !== null) { + postBody['notes'] = opts.notes + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 createAccount 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}/instances/{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实例的账号的权限信息 - 仅支持 MySQL,Percona,MariaDB + * @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 + * @param databasePrivilege databasePrivileges 数据库细粒度权限内容 + * @param string globalPrivileges + */ + + describeAccountPrivilege (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 describeAccountPrivilege" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeAccountPrivilege" + ) + } + if (opts.accountName === undefined || opts.accountName === null) { + throw new Error( + "Missing the required parameter 'opts.accountName' when calling describeAccountPrivilege" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + accountName: opts.accountName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeAccountPrivilege 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}/instances/{instanceId}/accounts/{accountName}', + '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 {string} opts.accountName - 账号名,在同一个实例中账号名不能重复 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteAccount (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 deleteAccount" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteAccount" + ) + } + if (opts.accountName === undefined || opts.accountName === null) { + throw new Error( + "Missing the required parameter 'opts.accountName' when calling deleteAccount" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + accountName: opts.accountName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 deleteAccount 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}/instances/{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 + */ + + grantPrivilege (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 grantPrivilege" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling grantPrivilege" + ) + } + if (opts.accountName === undefined || opts.accountName === null) { + throw new Error( + "Missing the required parameter 'opts.accountName' when calling grantPrivilege" + ) + } + if ( + opts.accountPrivileges === undefined || + opts.accountPrivileges === null + ) { + throw new Error( + "Missing the required parameter 'opts.accountPrivileges' when calling grantPrivilege" + ) + } + + 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 rds/1.3.4' + } + + 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 grantPrivilege 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}/instances/{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 rds/1.3.4' + } + + 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}/instances/{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.accountName - 账号名,在同一个实例中账号名不能重复 + * @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 + */ + + resetPassword (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 resetPassword" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling resetPassword" + ) + } + if (opts.accountName === undefined || opts.accountName === null) { + throw new Error( + "Missing the required parameter 'opts.accountName' when calling resetPassword" + ) + } + if (opts.accountPassword === undefined || opts.accountPassword === null) { + throw new Error( + "Missing the required parameter 'opts.accountPassword' when calling resetPassword" + ) + } + + let postBody = {} + if (opts.accountPassword !== undefined && opts.accountPassword !== null) { + postBody['accountPassword'] = opts.accountPassword + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + accountName: opts.accountName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 resetPassword 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}/instances/{instanceId}/accounts/{accountName}:resetPassword', + '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数据库实例。<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 + */ + + createSuperAccount (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 createSuperAccount" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createSuperAccount" + ) + } + if (opts.accountName === undefined || opts.accountName === null) { + throw new Error( + "Missing the required parameter 'opts.accountName' when calling createSuperAccount" + ) + } + if (opts.accountPassword === undefined || opts.accountPassword === null) { + throw new Error( + "Missing the required parameter 'opts.accountPassword' when calling createSuperAccount" + ) + } + + 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 rds/1.3.4' + } + + 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 createSuperAccount 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}/instances/{instanceId}/accounts:createSuperAccount', + '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) + } + ) + } + + /** + * 授予账号的数据库细粒度的访问权限 - 仅支持 MySQL,Percona,MariaDB + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} opts.accountName - 账号名,在同一个实例中账号名不能重复 + * @param {} [opts.databasePrivileges] - 设置数据库细粒度权限内容 optional + * @param {} [opts.globalPrivileges] - 设置全局权限,权限的具体定义参见[枚举参数定义](../Enum-Definitions/Enum-Definitions.md) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + grantAccountPrivilege (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 grantAccountPrivilege" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling grantAccountPrivilege" + ) + } + if (opts.accountName === undefined || opts.accountName === null) { + throw new Error( + "Missing the required parameter 'opts.accountName' when calling grantAccountPrivilege" + ) + } + + let postBody = {} + if ( + opts.databasePrivileges !== undefined && + opts.databasePrivileges !== null + ) { + postBody['databasePrivileges'] = opts.databasePrivileges + } + if (opts.globalPrivileges !== undefined && opts.globalPrivileges !== null) { + postBody['globalPrivileges'] = opts.globalPrivileges + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + accountName: opts.accountName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 grantAccountPrivilege 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}/instances/{instanceId}/accounts/{accountName}:grantAccountPrivilege', + '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实例下的运维账号信息。<br>- 仅支持 MySQL,Percona,MariaDB + * @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 dBInstanceAccountForOps accounts + * @param integer totalCount + */ + + describeAccountsForOps (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 describeAccountsForOps" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeAccountsForOps" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeAccountsForOps 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}/instances/{instanceId}/accountsForOps', + '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>如果在使用数据库过程中需要京东云提供技术支持,并且需要对您的实例进行操作,您可以把临时运维账号提供给技术支持人员。<br>临时运维账号默认授予全局Select、Process权限,且账号只能通过控制台或者OpenAPI进行创建、删除账号以及对账号授权等,用户不能通过SQL语句对账号进行相关操作。<br>- 仅支持 MySQL,Percona,MariaDB + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {} [opts.expiredTime] - 运维账号到期时间,UTC时间格式 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + createAccountForOps (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 createAccountForOps" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createAccountForOps" + ) + } + + let postBody = {} + if (opts.expiredTime !== undefined && opts.expiredTime !== null) { + postBody['expiredTime'] = opts.expiredTime + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 createAccountForOps 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}/instances/{instanceId}/accountsForOps', + '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>- 仅支持 MySQL,Percona,MariaDB + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {} [opts.expiredTime] - 运维账号到期时间,UTC时间格式 optional + * @param {} [opts.globalPrivileges] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyAccountForOps (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 modifyAccountForOps" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyAccountForOps" + ) + } + + let postBody = {} + if (opts.expiredTime !== undefined && opts.expiredTime !== null) { + postBody['expiredTime'] = opts.expiredTime + } + if (opts.globalPrivileges !== undefined && opts.globalPrivileges !== null) { + postBody['globalPrivileges'] = opts.globalPrivileges + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 modifyAccountForOps 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}/instances/{instanceId}/accountsForOps', + '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) + } + ) + } + + /** + * 查看当前实例已开启的审计选项。如当前实例未开启审计,则返回空<br>- 仅支持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 enabled 当前已开启的审计选项。如当前实例未开启审计,则返回空数组 + */ + + describeAudit (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 describeAudit" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeAudit" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeAudit 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}/instances/{instanceId}/audit', + '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) + } + ) + } + + /** + * 开启SQL Server的数据库审计功能,目前支持实例级的数据库审计。用户可以根据需要开启、关闭审计、自定义审计策略,并下载审计文件。审计文件为原生的SQL Server审计文件,缺省保存6个月。<br>- 仅支持SQL Server + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {} opts.enabled - 要开启的审计选项,各个选项之间用英文逗号或空格进行分割,例如:DATABASE_OBJECT_ACCESS_GROUP,ACKUP_RESTORE_GROU等<br>各个数据库版本支持的审计选项可以通过接口[describeAuditOptions](./describeAuditOptions.md)获得,各个审计项的具体含义可以参看微软的官方文档 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + createAudit (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 createAudit" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createAudit" + ) + } + if (opts.enabled === undefined || opts.enabled === null) { + throw new Error( + "Missing the required parameter 'opts.enabled' when calling createAudit" + ) + } + + let postBody = {} + if (opts.enabled !== undefined && opts.enabled !== null) { + postBody['enabled'] = opts.enabled + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 createAudit 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}/instances/{instanceId}/audit', + '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) + } + ) + } + + /** + * 关闭数据库审计。关闭数据库审计后,以前生成的审计结果文件并不会被立即删除。审计结果文件会过期后由系统自动删除,过期时间缺省为6个月<br>- 仅支持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 + */ + + deleteAudit (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 deleteAudit" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteAudit" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 deleteAudit 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}/instances/{instanceId}/audit', + '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>- 仅支持SQL Server + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} opts.name - 审计选项类别,**大小写敏感**,目前支持两种类型:<br>(1)AuditOptions开头:在disalbed参数中返回SQL Server各个版本支持的所有选项,支持的名称为<br>AuditOptions2008R2<br>AuditOptions2012<br>AuditOptions2014<br>AuditOptions2016<br>例如输入参数为"AuditOptions2016",则在disabled字段中返回SQL Server 2016 版本所支持的所有的审计选项<br>(2)AuditDefault开头:京东云建议的默认选项,在enabled参数中返回建议开启的选项,在disabled参数中返回不开启的选项,支持的名称为:<br>AuditDefault2008R2<br>AuditDefault2012<br>AuditDefault2014<br>AuditDefault2016<br>例如输入参数为"AuditDefault2016",则在enabled字段返回SQL Server 2016 版本中京东云建议开启的审计选项,在disabled字段中返回建议不开启的选项 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string enabled AuditDefault类模板:返回建议开启的审计选项。<br> AuditOptions类模板:不返回该参数 + * @param string disabled AuditDefault类模板:返回未开启的审计选项<br>AuditOptions类模板:返回所有的审计选项 + */ + + describeAuditOptions (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 describeAuditOptions" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeAuditOptions" + ) + } + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling describeAuditOptions" + ) + } + + let postBody = null + let queryParams = {} + if (opts.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeAuditOptions 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}/instances/{instanceId}/audit:describeAuditOptions', + '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) + } + ) + } + + /** + * 修改当前的审计选项。当前已有审计选项可以通过describeAudit获得,支持的全部选项可以通过getAuditOptions获得。<br>- 仅支持SQL Server + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {} [opts.add] - 在原有审计项基础上,增加新的审计项,多个审计项之间用英文逗号,分号或空格分隔,例如DATABASE_OBJECT_ACCESS_GROUP,ACKUP_RESTORE_GROUP optional + * @param {} [opts.drop] - 删除审计项,多个审计项之间用英文逗号,分号或空格分隔,例如DATABASE_OBJECT_ACCESS_GROUP,ACKUP_RESTORE_GROUP<br>如删除了所有审计项,则审计自动关闭 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyAudit (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 modifyAudit" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyAudit" + ) + } + + let postBody = {} + if (opts.add !== undefined && opts.add !== null) { + postBody['add'] = opts.add + } + if (opts.drop !== undefined && opts.drop !== null) { + postBody['drop'] = opts.drop + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 modifyAudit 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}/instances/{instanceId}/audit:modifyAudit', + '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>- 仅支持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 auditFile auditFiles + */ + + describeAuditFiles (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 describeAuditFiles" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeAuditFiles" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeAuditFiles 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}/instances/{instanceId}/audit:describeAuditFiles', + '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) + } + ) + } + + /** + * 获取某个审计文件的下载链接,同时支持内链和外链,链接的有效时间为24小时<br>- 仅支持SQL Server + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} opts.fileName - 审计文件名 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string publicURL 公网下载链接,若当前不可下载,则为空串 + * @param string internalURL 内网下载链接,若当前不可下载,则为空串 + */ + + describeAuditDownloadURL (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 describeAuditDownloadURL" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeAuditDownloadURL" + ) + } + if (opts.fileName === undefined || opts.fileName === null) { + throw new Error( + "Missing the required parameter 'opts.fileName' when calling describeAuditDownloadURL" + ) + } + + let postBody = null + let queryParams = {} + if (opts.fileName !== undefined && opts.fileName !== null) { + queryParams['fileName'] = opts.fileName + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeAuditDownloadURL 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}/instances/{instanceId}/audit:describeAuditDownloadURL', + '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) + } + ) + } + + /** + * 仅支持MySQL实例开启数据库审计<br>- 仅支持 MySQL 5.6, MySQL 5.7, Percona, MariaDB, PostgreSQL + * @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 + */ + + enableAudit (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 enableAudit" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling enableAudit" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 enableAudit 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}/instances/{instanceId}/audit:enableAudit', + '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) + } + ) + } + + /** + * 仅支持MySQL实例关闭数据库审计<br>- 仅支持 MySQL 5.6, MySQL 5.7, Percona, MariaDB, PostgreSQL + * @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 + */ + + disableAudit (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 disableAudit" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling disableAudit" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 disableAudit 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}/instances/{instanceId}/audit:disableAudit', + '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实例的审计内容<br>- 仅支持 MySQL 5.6, MySQL 5.7, Percona, MariaDB, PostgreSQL + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} opts.startTime - 查询开始时间,格式为:YYYY-MM-DD HH:mm:ss,开始时间不能早于当前时间3天 + * @param {string} opts.endTime - 查询截止时间,格式为:YYYY-MM-DD HH:mm:ss,开始时间到结束时间不能超过3天 + * @param {string} [opts.dbName] - 废弃,使用filter,数据库名 optional + * @param {string} [opts.accountName] - 废弃,使用filter,账号名 optional + * @param {integer} [opts.pageNumber] - 显示数据的页码,默认为1,取值范围:[-1,∞) optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[10,100] optional + * @param {filter} [opts.filters] - 过滤参数,多个过滤参数之间的关系为“与”(and支持以下属性的过滤(默认等值):) +- operation:仅第一个value生效,语句类型【create/alter/drop/truncate/select/insert/update/delete/replace/ddl/dml/disconnect/connect/failed_connect/query】,operator仅支持eq或者in +- account:实例账号名,operator仅支持eq或者in +- keyword:SQL 关键词,模糊查询,operator仅支持eq或者in +- database:实例库名,operator仅支持eq或者in +- threadId:会话id,operator仅支持eq或者in + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param auditResult auditResult + * @param integer totalCount + */ + + describeAuditResult (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 describeAuditResult" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeAuditResult" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeAuditResult" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeAuditResult" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.dbName !== undefined && opts.dbName !== null) { + queryParams['dbName'] = opts.dbName + } + if (opts.accountName !== undefined && opts.accountName !== null) { + queryParams['accountName'] = opts.accountName + } + 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, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeAuditResult 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}/instances/{instanceId}/audit:describeAuditResult', + '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数据库支持的可用区,不同类型的RDS支持的可用区不一样 + * @param {Object} opts - parameters + * @param {string} opts.engine - RDS引擎类型,参见[枚举参数定义](../Enum-Definitions/Enum-Definitions.md) + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string azs + * @param azInfo azInfos + */ + + describeAzs (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 describeAzs" + ) + } + + opts = opts || {} + + if (opts.engine === undefined || opts.engine === null) { + throw new Error( + "Missing the required parameter 'opts.engine' when calling describeAzs" + ) + } + + let postBody = null + let queryParams = {} + if (opts.engine !== undefined && opts.engine !== null) { + queryParams['engine'] = opts.engine + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeAzs 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}/azs', + '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实例下所有备份的详细信息,返回的备份列表按照备份开始时间(backupStartTime)降序排列。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS实例ID,唯一标识一个实例 + * @param {integer} [opts.auto] - 查询备份类型,0为手动备份,1为自动备份,不传表示全部. <br>**- 测试参数,仅支持SQL Server,后续可能被其他参数取代** optional + * @param {string} [opts.backupTypeFilter] - 返回backupType等于指定值的备份列表。full为全量备份,diff为增量备份<br>**- 测试参数,仅支持SQL Server,后续可能被其他参数取代** optional + * @param {string} [opts.dbNameFilter] - 返回dbName等于指定值的备份列表,不传或为空返回全部<br>**- 测试参数,仅支持SQL Server,后续可能被其他参数取代** optional + * @param {string} [opts.backupTimeRangeStartFilter] - 返回备份开始时间大于该时间的备份列表<br>**- 测试参数,仅支持SQL Server,后续可能被其他参数取代** optional + * @param {string} [opts.backupTimeRangeEndFilter] - 返回备份开始时间小于等于该时间的备份列表<br>**- 测试参数,仅支持SQL Server,后续可能被其他参数取代** optional + * @param {integer} opts.pageNumber - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageNumber为-1时,返回所有数据页码; + * @param {integer} opts.pageSize - 每页显示的数据条数,默认为10,取值范围:[10,100] + * @param {filter} [opts.filters] - 过滤参数,多个过滤参数之间的关系为“与”(and支持以下属性的过滤(默认等值):) +- instanceId:RDS实例ID,唯一标识一个实例,operator仅支持eq +- instanceName:RDS实例名称,模糊搜索,operator仅支持eq、like +- backupId:备份ID,唯一标识一个备份,operator仅支持eq +- backupName:备份名称,模糊搜索,operator仅支持eq、like +- auto:备份类型,0为手动备份,1为自动备份,operator仅支持eq +- backupMethod:返回backupMethod等于指定值的备份列表,physical为物理备份,snapshot为快照备份备注,operator仅支持eq + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param backup backup + * @param integer totalCount 总记录数 + */ + + describeBackups (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 describeBackups" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeBackups" + ) + } + if (opts.pageNumber === undefined || opts.pageNumber === null) { + throw new Error( + "Missing the required parameter 'opts.pageNumber' when calling describeBackups" + ) + } + if (opts.pageSize === undefined || opts.pageSize === null) { + throw new Error( + "Missing the required parameter 'opts.pageSize' when calling describeBackups" + ) + } + + let postBody = null + let queryParams = {} + if (opts.instanceId !== undefined && opts.instanceId !== null) { + queryParams['instanceId'] = opts.instanceId + } + if (opts.auto !== undefined && opts.auto !== null) { + queryParams['auto'] = opts.auto + } + if (opts.backupTypeFilter !== undefined && opts.backupTypeFilter !== null) { + queryParams['backupTypeFilter'] = opts.backupTypeFilter + } + if (opts.dbNameFilter !== undefined && opts.dbNameFilter !== null) { + queryParams['dbNameFilter'] = opts.dbNameFilter + } + if ( + opts.backupTimeRangeStartFilter !== undefined && + opts.backupTimeRangeStartFilter !== null + ) { + queryParams['backupTimeRangeStartFilter'] = + opts.backupTimeRangeStartFilter + } + if ( + opts.backupTimeRangeEndFilter !== undefined && + opts.backupTimeRangeEndFilter !== null + ) { + queryParams['backupTimeRangeEndFilter'] = opts.backupTimeRangeEndFilter + } + 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 rds/1.3.4' + } + + 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 describeBackups 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}/backups', + '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实例全量备份,可以对整个实例或者部分数据库(仅SQL Server支持)进行全量备份。同一时间点,只能有一个正在运行的备份任务 + * @param {Object} opts - parameters + * @param {string} [opts.instanceId] - RDS实例ID,唯一标识一个实例 optional + * @param {backupSpec} [opts.backupSpec] - 备份规格 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string backupId 备份Id + */ + + createBackup (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 createBackup" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.instanceId !== undefined && opts.instanceId !== null) { + postBody['instanceId'] = opts.instanceId + } + if (opts.backupSpec !== undefined && opts.backupSpec !== null) { + postBody['backupSpec'] = opts.backupSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 createBackup 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}/backups', + '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.backupId - 备份ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteBackup (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 deleteBackup" + ) + } + + opts = opts || {} + + if (opts.backupId === undefined || opts.backupId === null) { + throw new Error( + "Missing the required parameter 'opts.backupId' when calling deleteBackup" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + backupId: opts.backupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 deleteBackup 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}/backups/{backupId}', + '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>- 当输入参数中有文件名时,获取该文件的下载链接。<br>- 输入参数中无文件名时,获取整个备份的下载链接。<br>由于备份机制的差异,使用该接口下载备份时,SQL Server必须输入文件名,每个文件逐一下载,不支持下载整个备份。SQL Server备份中的文件名(不包括后缀)即为备份的数据库名。例如文件名为my_test_db.bak,表示该文件是my_test_db数据库的备份。<br>MySQL可下载整个备份集,但不支持单个文件的下载。 + * @param {Object} opts - parameters + * @param {string} opts.backupId - 备份ID + * @param {string} [opts.fileName] - 文件名称<br>- MySQL:不支持该参数<br>- SQL Server:必须输入该参数,指定该备份中需要获取下载链接的文件名称。备份中的文件名(不包括后缀)即为备份的数据库名。例如文件名为my_test_db.bak,表示该文件是my_test_db数据库的备份 optional + * @param {string} [opts.urlExpirationSecond] - 指定下载链接的过期时间,单位秒, 取值范围为 1 ~ 86400 秒;支持 SQL Server:缺省为 86400 秒。支持 MySQL, Percona, MariaDB:缺省为 300 秒。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string publicURL 公网下载链接,若当前不可下载,则为空串 + * @param string internalURL 内网下载链接,若当前不可下载,则为空串 + */ + + describeBackupDownloadURL (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 describeBackupDownloadURL" + ) + } + + opts = opts || {} + + if (opts.backupId === undefined || opts.backupId === null) { + throw new Error( + "Missing the required parameter 'opts.backupId' when calling describeBackupDownloadURL" + ) + } + + let postBody = null + let queryParams = {} + if (opts.fileName !== undefined && opts.fileName !== null) { + queryParams['fileName'] = opts.fileName + } + if ( + opts.urlExpirationSecond !== undefined && + opts.urlExpirationSecond !== null + ) { + queryParams['urlExpirationSecond'] = opts.urlExpirationSecond + } + + let pathParams = { + regionId: regionId, + backupId: opts.backupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeBackupDownloadURL 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}/backups/{backupId}:describeBackupDownloadURL', + '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] - 每页显示的数据条数,默认为10,取值范围:10、20、30、50、100 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param backupSynchronicity backupSynchronicities + * @param integer totalCount + */ + + describeBackupSynchronicities ( + 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 describeBackupSynchronicities" + ) + } + + 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 + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeBackupSynchronicities 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}/backupSynchronicities', + '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 {} opts.instanceId - 源实例ID + * @param {} opts.destRegion - 备份同步的目标地域 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string serviceId 跨地域备份同步服务ID + */ + + createBackupSynchronicity (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 createBackupSynchronicity" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createBackupSynchronicity" + ) + } + if (opts.destRegion === undefined || opts.destRegion === null) { + throw new Error( + "Missing the required parameter 'opts.destRegion' when calling createBackupSynchronicity" + ) + } + + let postBody = {} + if (opts.instanceId !== undefined && opts.instanceId !== null) { + postBody['instanceId'] = opts.instanceId + } + if (opts.destRegion !== undefined && opts.destRegion !== null) { + postBody['destRegion'] = opts.destRegion + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 createBackupSynchronicity 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}/backupSynchronicities', + '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.serviceId - 跨地域备份同步服务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteBackupSynchronicity (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 deleteBackupSynchronicity" + ) + } + + opts = opts || {} + + if (opts.serviceId === undefined || opts.serviceId === null) { + throw new Error( + "Missing the required parameter 'opts.serviceId' when calling deleteBackupSynchronicity" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + serviceId: opts.serviceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 deleteBackupSynchronicity 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}/backupSynchronicities/{serviceId}', + '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.restoreTime - 根据源实例的哪个时间点创建新实例 + * @param {string} opts.serviceId - 跨地域备份同步服务ID + * @param {restoredNewDBInstanceSpec} opts.instanceSpec - 新建实例规格 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string instanceId 新创建的实例ID + * @param string orderId 订单ID + */ + + createInstanceByTimeInCrossRegion ( + 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 createInstanceByTimeInCrossRegion" + ) + } + + opts = opts || {} + + if (opts.restoreTime === undefined || opts.restoreTime === null) { + throw new Error( + "Missing the required parameter 'opts.restoreTime' when calling createInstanceByTimeInCrossRegion" + ) + } + if (opts.serviceId === undefined || opts.serviceId === null) { + throw new Error( + "Missing the required parameter 'opts.serviceId' when calling createInstanceByTimeInCrossRegion" + ) + } + if (opts.instanceSpec === undefined || opts.instanceSpec === null) { + throw new Error( + "Missing the required parameter 'opts.instanceSpec' when calling createInstanceByTimeInCrossRegion" + ) + } + + let postBody = {} + if (opts.restoreTime !== undefined && opts.restoreTime !== null) { + postBody['restoreTime'] = opts.restoreTime + } + if (opts.serviceId !== undefined && opts.serviceId !== null) { + postBody['serviceId'] = opts.serviceId + } + 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 rds/1.3.4' + } + + 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 createInstanceByTimeInCrossRegion 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}/backupSynchronicities:createInstanceByTimeInCrossRegion', + '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) + } + ) + } + + /** + * 获取MySQL实例中binlog的详细信息<br>- 仅支持 MySQL, Percona, MariaDB + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {integer} [opts.pageNumber] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageNumber为-1时,返回所有数据页码; optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[10,100] optional + * @param {string} [opts.startTime] - 查询开始时间,格式为:YYYY-MM-DDTHH:mm:ssZ,开始时间到结束时间不超过7天 optional + * @param {string} [opts.endTime] - 查询结束时间,格式为:YYYY-MM-DDTHH:mm:ssZ,开始时间到结束时间不超过7天 optional + * @param {filter} [opts.filters] - 过滤参数,多个过滤参数之间的关系为“与”(and支持以下属性的过滤(默认等值):) +- instanceId:RDS实例ID,唯一标识一个实例,operator仅支持eq +- instanceName:RDS实例名称,模糊搜索,operator仅支持eq、like +- binlogId:Binlog ID,唯一标识一个备份,operator仅支持eq +- binlogName:Binlog名称,模糊搜索,operator仅支持eq、like + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount 总记录数 + * @param binlog binlogs + */ + + describeBinlogs (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 describeBinlogs" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeBinlogs" + ) + } + + 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.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeBinlogs 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}/instances/{instanceId}/binlogs', + '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) + } + ) + } + + /** + * 获取MySQL实例的binlog的下载链接<br>- 仅支持 MySQL, Percona, MariaDB + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} opts.binlogBackupId - binlog的备份ID,可以通过describeBinlogs获得 + * @param {integer} [opts.seconds] - 设置链接地址的过期时间,单位是秒,默认值是 300 秒,最长不能超过取值范围为 1 ~ 86400 秒 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string publicURL 公网下载链接 + * @param string internalURL 内网下载链接 + */ + + describeBinlogDownloadURL (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 describeBinlogDownloadURL" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeBinlogDownloadURL" + ) + } + if (opts.binlogBackupId === undefined || opts.binlogBackupId === null) { + throw new Error( + "Missing the required parameter 'opts.binlogBackupId' when calling describeBinlogDownloadURL" + ) + } + + let postBody = null + let queryParams = {} + if (opts.seconds !== undefined && opts.seconds !== null) { + queryParams['seconds'] = opts.seconds + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + binlogBackupId: opts.binlogBackupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeBinlogDownloadURL 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}/instances/{instanceId}/binlogs/{binlogBackupId}:describeBinlogDownloadURL', + '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) + } + ) + } + + /** + * 清理本地的binlog并释放空间。 系统只会清理已经备份到存储的binlog,不会影响MySQL实例的备份恢复<br>- 仅支持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 + */ + + clearBinlogs (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 clearBinlogs" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling clearBinlogs" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 clearBinlogs 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}/instances/{instanceId}/binlogs:clearBinlogs', + '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) + } + ) + } + + /** + * 获取MySQL实例的binlog的内网下载链接<br>- 仅支持 MySQL, Percona, MariaDB + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} opts.binlogBackupId - binlog的备份ID,可以通过describeBinlogs获得 + * @param {integer} [opts.seconds] - 设置链接地址的过期时间,单位是秒,默认值是 300 秒,最长不能超过取值范围为 1 ~ 86400 秒 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string internalURL 内网下载链接 + */ + + describeBinlogDownloadInternalURL ( + 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 describeBinlogDownloadInternalURL" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeBinlogDownloadInternalURL" + ) + } + if (opts.binlogBackupId === undefined || opts.binlogBackupId === null) { + throw new Error( + "Missing the required parameter 'opts.binlogBackupId' when calling describeBinlogDownloadInternalURL" + ) + } + + let postBody = null + let queryParams = {} + if (opts.seconds !== undefined && opts.seconds !== null) { + queryParams['seconds'] = opts.seconds + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + binlogBackupId: opts.binlogBackupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeBinlogDownloadInternalURL 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}/instances/{instanceId}/binlogs/{binlogBackupId}:describeBinlogDownloadInternalURL', + '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) + } + ) + } + + /** + * 通过 PT-OSC 服务来处理 DDL 命令, 避免锁表。此接口暂是对部分用户开放 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {} opts.database - DDL命令修改的库名 + * @param {} opts.table - DDL命令修改的表名 + * @param {} opts.command - 需要执行的的DDL命令 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + alterTableWithOnlineDDL (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 alterTableWithOnlineDDL" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling alterTableWithOnlineDDL" + ) + } + if (opts.database === undefined || opts.database === null) { + throw new Error( + "Missing the required parameter 'opts.database' when calling alterTableWithOnlineDDL" + ) + } + if (opts.table === undefined || opts.table === null) { + throw new Error( + "Missing the required parameter 'opts.table' when calling alterTableWithOnlineDDL" + ) + } + if (opts.command === undefined || opts.command === null) { + throw new Error( + "Missing the required parameter 'opts.command' when calling alterTableWithOnlineDDL" + ) + } + + let postBody = {} + if (opts.database !== undefined && opts.database !== null) { + postBody['database'] = opts.database + } + if (opts.table !== undefined && opts.table !== null) { + postBody['table'] = opts.table + } + if (opts.command !== undefined && opts.command !== null) { + postBody['command'] = opts.command + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 alterTableWithOnlineDDL 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}/instances/{instanceId}:alterTableWithOnlineDDL', + '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 的权限信息 - 仅支持 MySQL,Percona,MariaDB + * @param {Object} opts - parameters + * @param {string} opts.engine - 设置可见的引擎类型,如 MySQL 等 + * @param {string} [opts.instanceId] - RDS 实例ID,唯一标识一个RDS实例 optional + * @param {boolean} [opts.allAdminPrivileges] - true表示展示高权限,默认false optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string globalPrivileges + * @param string databasePrivileges + * @param string tablePrivileges + */ + + describePrivilege (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 describePrivilege" + ) + } + + opts = opts || {} + + if (opts.engine === undefined || opts.engine === null) { + throw new Error( + "Missing the required parameter 'opts.engine' when calling describePrivilege" + ) + } + + let postBody = null + let queryParams = {} + if (opts.engine !== undefined && opts.engine !== null) { + queryParams['engine'] = opts.engine + } + if (opts.instanceId !== undefined && opts.instanceId !== null) { + queryParams['instanceId'] = opts.instanceId + } + if ( + opts.allAdminPrivileges !== undefined && + opts.allAdminPrivileges !== null + ) { + queryParams['allAdminPrivileges'] = opts.allAdminPrivileges + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describePrivilege 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}/common:describePrivilege', + '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 - 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 + */ + + describeDatabases (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 describeDatabases" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeDatabases" + ) + } + + 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 rds/1.3.4' + } + + 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 describeDatabases 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}/instances/{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 + */ + + createDatabase (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 createDatabase" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createDatabase" + ) + } + if (opts.dbName === undefined || opts.dbName === null) { + throw new Error( + "Missing the required parameter 'opts.dbName' when calling createDatabase" + ) + } + if (opts.characterSetName === undefined || opts.characterSetName === null) { + throw new Error( + "Missing the required parameter 'opts.characterSetName' when calling createDatabase" + ) + } + + 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 rds/1.3.4' + } + + 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 createDatabase 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}/instances/{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 + */ + + deleteDatabase (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 deleteDatabase" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteDatabase" + ) + } + if (opts.dbName === undefined || opts.dbName === null) { + throw new Error( + "Missing the required parameter 'opts.dbName' when calling deleteDatabase" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + dbName: opts.dbName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 deleteDatabase 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}/instances/{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) + } + ) + } + + /** + * 从备份中恢复单个数据库,支持从其他实例(但必须是同一个账号下的实例)备份中恢复。例如可以从生产环境的数据库实例的备份恢复到测试环境的数据库中。<br>- 仅支持SQL Server + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} opts.dbName - 库名称 + * @param {} opts.backupId - 备份ID,可从备份查询接口describeBackups获取 + * @param {} opts.backupFileName - 指定该备份中用于恢复数据库的文件名称。通常情况下文件名(不包括后缀)即为备份的数据库名。例如文件名为my_test_db.bak,表示该文件是my_test_db数据库的备份 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + restoreDatabaseFromBackup (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 restoreDatabaseFromBackup" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling restoreDatabaseFromBackup" + ) + } + if (opts.dbName === undefined || opts.dbName === null) { + throw new Error( + "Missing the required parameter 'opts.dbName' when calling restoreDatabaseFromBackup" + ) + } + if (opts.backupId === undefined || opts.backupId === null) { + throw new Error( + "Missing the required parameter 'opts.backupId' when calling restoreDatabaseFromBackup" + ) + } + if (opts.backupFileName === undefined || opts.backupFileName === null) { + throw new Error( + "Missing the required parameter 'opts.backupFileName' when calling restoreDatabaseFromBackup" + ) + } + + let postBody = {} + if (opts.backupId !== undefined && opts.backupId !== null) { + postBody['backupId'] = opts.backupId + } + if (opts.backupFileName !== undefined && opts.backupFileName !== null) { + postBody['backupFileName'] = opts.backupFileName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + dbName: opts.dbName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 restoreDatabaseFromBackup 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}/instances/{instanceId}/databases/{dbName}:restoreDatabaseFromBackup', + '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>- 仅支持SQL Server + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} opts.dbName - 库名称 + * @param {} [opts.sharedFileGid] - 共享文件的全局ID,可从上传文件查询接口[describeImportFiles](../Cloud-on-Single-Database/describeImportFiles.md)获取;如果该文件不是共享文件,则不用输入该参数 optional + * @param {} opts.fileName - 用户上传的备份文件名称(包括文件后缀名),例如mydb1.bak + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + restoreDatabaseFromFile (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 restoreDatabaseFromFile" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling restoreDatabaseFromFile" + ) + } + if (opts.dbName === undefined || opts.dbName === null) { + throw new Error( + "Missing the required parameter 'opts.dbName' when calling restoreDatabaseFromFile" + ) + } + if (opts.fileName === undefined || opts.fileName === null) { + throw new Error( + "Missing the required parameter 'opts.fileName' when calling restoreDatabaseFromFile" + ) + } + + let postBody = {} + if (opts.sharedFileGid !== undefined && opts.sharedFileGid !== null) { + postBody['sharedFileGid'] = opts.sharedFileGid + } + if (opts.fileName !== undefined && opts.fileName !== null) { + postBody['fileName'] = opts.fileName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + dbName: opts.dbName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 restoreDatabaseFromFile 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}/instances/{instanceId}/databases/{dbName}:restoreDatabaseFromFile', + '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) + } + ) + } + + /** + * 从上传到OSS的备份文件中恢复单个数据库<br>- 仅支持SQL Server + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} opts.dbName - 库名称 + * @param {} opts.ossURL - 用户上传到对象存储OSS上的备份文件的路径。<br>例如用户备份上传的bucket为db_backup,文件为test_server/db1.bak,那么ossULR为db_backup/test_server/db1.bak。<br>**授权说明**:需要授予账户ID:785455908940,对这个bucket的读取权限,具体步骤可以查看[文档](https://docs.jdcloud.com/cn/object-storage-service/set-bucket-policy-2)。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + restoreDatabaseFromOSS (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 restoreDatabaseFromOSS" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling restoreDatabaseFromOSS" + ) + } + if (opts.dbName === undefined || opts.dbName === null) { + throw new Error( + "Missing the required parameter 'opts.dbName' when calling restoreDatabaseFromOSS" + ) + } + if (opts.ossURL === undefined || opts.ossURL === null) { + throw new Error( + "Missing the required parameter 'opts.ossURL' when calling restoreDatabaseFromOSS" + ) + } + + let postBody = {} + if (opts.ossURL !== undefined && opts.ossURL !== null) { + postBody['ossURL'] = opts.ossURL + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + dbName: opts.dbName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 restoreDatabaseFromOSS 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}/instances/{instanceId}/databases/{dbName}:restoreDatabaseFromOSS', + '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) + } + ) + } + + /** + * 修改数据库备注,仅支持MySQL + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} opts.dbName - 库名称 + * @param {} opts.comment - 数据库的备注信息,支持中午,ASCII字符,最大长度64 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyDatabaseComment (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 modifyDatabaseComment" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyDatabaseComment" + ) + } + if (opts.dbName === undefined || opts.dbName === null) { + throw new Error( + "Missing the required parameter 'opts.dbName' when calling modifyDatabaseComment" + ) + } + if (opts.comment === undefined || opts.comment === null) { + throw new Error( + "Missing the required parameter 'opts.comment' when calling modifyDatabaseComment" + ) + } + + let postBody = {} + if (opts.comment !== undefined && opts.comment !== null) { + postBody['comment'] = opts.comment + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + dbName: opts.dbName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 modifyDatabaseComment 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}/instances/{instanceId}/databases/{dbName}:modifyDatabaseComment', + '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) + } + ) + } + + /** + * 获取SQL Server 错误日志及下载信息<br>- 仅支持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 errorLog errorLogs + */ + + describeErrorLogs (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 describeErrorLogs" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeErrorLogs" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeErrorLogs 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}/instances/{instanceId}/errorLogs', + '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>- 仅支持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 importFile importFiles + */ + + describeImportFiles (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 describeImportFiles" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeImportFiles" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeImportFiles 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}/instances/{instanceId}/importFiles', + '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) + } + ) + } + + /** + * 获取单库上云工具上传文件的需要的Key。单库上云工具需要正确的key值方能连接到京东云<br>- 仅支持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 key 上传文件需要用到的Key + */ + + getUploadKey (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 getUploadKey" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling getUploadKey" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 getUploadKey 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}/instances/{instanceId}/importFiles:getUploadKey', + '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>- 仅支持SQL Server + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} opts.fileName - 单库上云文件名 + * @param {} opts.shared - 文件是否共享<br>true:共享<br>false:不共享 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + setImportFileShared (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 setImportFileShared" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling setImportFileShared" + ) + } + if (opts.fileName === undefined || opts.fileName === null) { + throw new Error( + "Missing the required parameter 'opts.fileName' when calling setImportFileShared" + ) + } + if (opts.shared === undefined || opts.shared === null) { + throw new Error( + "Missing the required parameter 'opts.shared' when calling setImportFileShared" + ) + } + + let postBody = {} + if (opts.shared !== undefined && opts.shared !== null) { + postBody['shared'] = opts.shared + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + fileName: opts.fileName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 setImportFileShared 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}/instances/{instanceId}/importFiles/{fileName}:setShared', + '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>- 仅支持SQL Server + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} opts.fileName - 单库上云文件名 + * @param {} [opts.sharedFileGid] - 共享文件的全局ID,可从上传文件查询接口describeImportFiles中获取;如果该文件不是共享文件,则无须输入该字段 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteImportFile (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 deleteImportFile" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteImportFile" + ) + } + if (opts.fileName === undefined || opts.fileName === null) { + throw new Error( + "Missing the required parameter 'opts.fileName' when calling deleteImportFile" + ) + } + + let postBody = null + let queryParams = {} + if (opts.sharedFileGid !== undefined && opts.sharedFileGid !== null) { + queryParams['sharedFileGid'] = opts.sharedFileGid + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + fileName: opts.fileName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 deleteImportFile 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}/instances/{instanceId}/importFiles/{fileName}', + '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) + } + ) + } + + /** + * 获取当前账号下所有RDS实例及MySQL/PostgreSQL只读实例的概要信息,例如实例类型,版本,计费信息等 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 显示数据的页码,默认为1,取值范围:[-1,∞]。pageNumber为-1时,返回所有数据页码; optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[10,100],且为10的整数倍 optional + * @param {filter} [opts.filters] - 过滤参数,多个过滤参数之间的关系为“与”(and) +支持以下属性的过滤: +instanceId, 支持operator选项:eq +instanceName, 支持operator选项:eq, like +engine, 支持operator选项:eq +engineVersion, 支持operator选项:eq +instanceStatus, 支持operator选项:eq +vpcId, 支持operator选项:eq +instanceType, 支持operator选项:eq +internalDomainName, 支持operator选项:eq +publicDomainName, 支持operator选项:eq +roInstanceProxyInternalDomainName, 支持operator选项:like +readWriteProxyInternalDomainName, 支持operator选项:like + optional + * @param {tagFilter} [opts.tagFilters] - 资源标签 optional + * @param {string} [opts.resourceGroupIds] - 资源组id optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dBInstance dbInstances + * @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 + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + Object.assign( + queryParams, + super.buildTagFilterParam(opts.tagFilters, 'tagFilters') + ) + Object.assign( + queryParams, + super.buildArrayParam(opts.resourceGroupIds, 'resourceGroupIds') + ) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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}/instances', + '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实例,用户可以使用相应的数据库客户端或者应用程序通过域名和端口链接到该RDS实例上,进行操作。 + * @param {Object} opts - parameters + * @param {dBInstanceSpec} opts.instanceSpec - 新建实例规格 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string instanceId + * @param string orderId + */ + + createInstance (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 createInstance" + ) + } + + opts = opts || {} + + if (opts.instanceSpec === undefined || opts.instanceSpec === null) { + throw new Error( + "Missing the required parameter 'opts.instanceSpec' when calling createInstance" + ) + } + + let postBody = {} + 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 rds/1.3.4' + } + + 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 createInstance 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}/instances', + '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实例(MySQL、SQL Server等)的详细信息以及MySQL/PostgreSQL只读实例详细信息 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {integer} [opts.instanceExistence] - 默认不传,返回当前未删除的实例的实例详情 **仅支持 MySQL,Percona,MariaDB。<br>请求参数:<br>- 0:当前存在的实例;<br>- 1:已删除的实例;<br>- 2:全部实例,不区分实例是否删除; optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dBInstanceAttribute dbInstanceAttributes + */ + + describeInstanceAttributes (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 describeInstanceAttributes" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeInstanceAttributes" + ) + } + + let postBody = null + let queryParams = {} + if ( + opts.instanceExistence !== undefined && + opts.instanceExistence !== null + ) { + queryParams['instanceExistence'] = opts.instanceExistence + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeInstanceAttributes 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}/instances/{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/PostgreSQL的只读实例。删除MySQL/PostgreSQL主实例时,会同时将对应的MySQL/PostgreSQL只读实例也删除 [MFA enabled] + * @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 + */ + + 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 || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteInstance" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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}/instances/{instanceId}', + '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) + } + ) + } + + /** + * 查看RDS实例备份策略。根据数据库类型的不同,支持的备份策略也略有差异,具体请看返回参数中的详细说明 + * @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 startWindow 自动备份开始时间窗口,范围00:00-23:59,时间范围差不得小于30分钟。<br>例如:00:00-01:00,表示0点到1点开始进行数据库自动备份,备份完成时间则跟实例大小有关,不一定在这个时间范围中 + * @param integer retentionPeriod 自动备份保留周期,单位天,默认为7 + * @param integer binlogRetentionPeriod binlog本地保留周期,单位小时,默认为24 + * @param integer binlogUsageLimit binlog本地占用空间上限,单位%,默认为30 + * @param string binlogSpaceProtection 空间保护是否开启,开启后,磁盘剩余空间小于20%或剩余空间不足5GB时,将自动清理本地binlog。开启:on,关闭:off,默认为off <br>- 仅支持MySQL + * @param integer cycleMode 自动备份循环模式<br>1:表示每天都是全量备份<br>2:表示自动备份按照全量、增量、增量这样的方式进行,例如第1天是全量备份,第2、3天是增量备份;第4天又是全量备份,以此类推.<br> - 仅支持 SQL Server + * @param string backupBinlog 是否备份binlog,默认为true<br>true:表示备份<br>false:表示不备份<br> - **仅支持 MySQL,Percona,MariaDB + * @param string enhancedBackup 是否开启增强备份模式<br>true:当前实例已开启增强备份模式<br>false或为空:表示当前实例未开启增强备份模式<br> - **仅支持 SQL Server + * @param string releasedKeepPolicy 已删除实例的备份保留策略,取值:<br>• CreateAndKeep:删除时新创建备份并保留<br>• All:全部保留<br>• None:不保留<br>- 仅支持 MySQL,Percona,MariaDB<br> - **仅支持 SQL Server + * @param string backupPeriod 备份周期 + * @param integer binlogRetentionNumber 本地binlog最大保留数量,默认为-1,不限保留个数。 + */ + + describeBackupPolicy (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 describeBackupPolicy" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeBackupPolicy" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeBackupPolicy 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}/instances/{instanceId}:describeBackupPolicy', + '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.startWindow] - 自动备份开始时间窗口,例如:00:00-01:00,表示0点到1点开始进行数据库自动备份,备份完成时间则跟实例大小有关,不一定在这个时间范围中<br>SQL Server:范围00:00-23:59,时间范围差不得小于30分钟。<br>MySQL,只能是以下取值:<br>00:00-01:00<br>01:00-02:00<br>......<br>23:00-24:00 optional + * @param {} [opts.binlogRetentionPeriod] - binlog本地保留周期,单位小时,范围1-168,默认为24 optional + * @param {} [opts.binlogUsageLimit] - binlog本地占用空间上限,单位%,范围5-50,默认为30 optional + * @param {} [opts.binlogSpaceProtection] - 设置空间保护,开启:on,关闭:off;开启后,磁盘剩余空间小于20%或剩余空间不足5GB时,将自动清理本地binlog。 <br>- 仅支持MySQL optional + * @param {} [opts.retentionPeriod] - 自动备份保留周期,单位天,范围7-730<br>SQL Server需要当enhancedBackup为true时才可修改 optional + * @param {} [opts.cycleMode] - 自动备份循环模式<br>1:表示每天都是全量备份<br>2:表示自动备份按照全量、增量、增量这样的方式进行,例如第1天是全量备份,第2、3天是增量备份;第4天又是全量备份,以此类推<br>当enhancedBackup为true时可修改<br>- 仅支持SQL Server optional + * @param {} [opts.releasedKeepPolicy] - 已删除实例的备份保留策略,取值:<br>• CreateAndKeep:删除时新创建备份并保留<br>• All:全部保留<br>• None:不保留 optional + * @param {} [opts.backupPeriod] - 备份周期。至少需要指定2天,取值:<br>• Monday:周一<br>• Tuesday:周二<br>• Wednesday:周三<br>• Thursday:周四<br>• Friday:周五<br>• Saturday:周六<br>• Sunday:周日 optional + * @param {} [opts.binlogRetentionNumber] - 本地binlog最大保留数量,支持设置保留个数为6-1000个,可传-1表示不限保留个数,默认为-1。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyBackupPolicy (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 modifyBackupPolicy" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyBackupPolicy" + ) + } + + let postBody = {} + if (opts.startWindow !== undefined && opts.startWindow !== null) { + postBody['startWindow'] = opts.startWindow + } + if ( + opts.binlogRetentionPeriod !== undefined && + opts.binlogRetentionPeriod !== null + ) { + postBody['binlogRetentionPeriod'] = opts.binlogRetentionPeriod + } + if (opts.binlogUsageLimit !== undefined && opts.binlogUsageLimit !== null) { + postBody['binlogUsageLimit'] = opts.binlogUsageLimit + } + if ( + opts.binlogSpaceProtection !== undefined && + opts.binlogSpaceProtection !== null + ) { + postBody['binlogSpaceProtection'] = opts.binlogSpaceProtection + } + if (opts.retentionPeriod !== undefined && opts.retentionPeriod !== null) { + postBody['retentionPeriod'] = opts.retentionPeriod + } + if (opts.cycleMode !== undefined && opts.cycleMode !== null) { + postBody['cycleMode'] = opts.cycleMode + } + if ( + opts.releasedKeepPolicy !== undefined && + opts.releasedKeepPolicy !== null + ) { + postBody['releasedKeepPolicy'] = opts.releasedKeepPolicy + } + if (opts.backupPeriod !== undefined && opts.backupPeriod !== null) { + postBody['backupPeriod'] = opts.backupPeriod + } + if ( + opts.binlogRetentionNumber !== undefined && + opts.binlogRetentionNumber !== null + ) { + postBody['binlogRetentionNumber'] = opts.binlogRetentionNumber + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 modifyBackupPolicy 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}/instances/{instanceId}:modifyBackupPolicy', + '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) + } + ) + } + + /** + * 开启增强备份模式,开启后,备份保留天数可大于7天。 免费备份额度外的备份将按照备份占用的空间收费。开启后,不支持关闭。<br>- 仅支持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 + */ + + enableEnhancedBackup (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 enableEnhancedBackup" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling enableEnhancedBackup" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 enableEnhancedBackup 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}/instances/{instanceId}:enableEnhancedBackup', + '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>- 仅支持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 number totalFreeSpace 当前地域下总的免费备份空间大小,单位GB + * @param number totalUsedSpace 当前地域下所有实例的备份大小,单位GB + * @param number current 当前实例的备份大小,单位GB + */ + + describeBackupSpace (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 describeBackupSpace" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeBackupSpace" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeBackupSpace 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}/instances/{instanceId}:describeBackupSpace', + '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) + } + ) + } + + /** + * 查询该用户pin关联的备份的计费信息。仅当该用户开启了增强备份后有效。如用户未开启增强备份,返回null<br>- 仅支持SQL Server + * @param {Object} opts - parameters + * @param {string} opts.engine - 实例引擎类型 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param charge charge 计费配置 + */ + + describeBackupCharge (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 describeBackupCharge" + ) + } + + opts = opts || {} + + if (opts.engine === undefined || opts.engine === null) { + throw new Error( + "Missing the required parameter 'opts.engine' when calling describeBackupCharge" + ) + } + + let postBody = null + let queryParams = {} + if (opts.engine !== undefined && opts.engine !== null) { + queryParams['engine'] = opts.engine + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeBackupCharge 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}/instances:describeBackupCharge', + '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) + } + ) + } + + /** + * 修改实例名称,可支持中文,实例名的具体规则可参见帮助中心文档:[名称及密码限制](../../../documentation/Database-and-Cache-Service/RDS/Introduction/Restrictions/SQLServer-Restrictions.md) + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {} opts.instanceName - 实例名称,名称支持中文,实例名的具体规则可参见帮助中心文档:[名称及密码限制](../../../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 + */ + + modifyInstanceName (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 modifyInstanceName" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyInstanceName" + ) + } + if (opts.instanceName === undefined || opts.instanceName === null) { + throw new Error( + "Missing the required parameter 'opts.instanceName' when calling modifyInstanceName" + ) + } + + let postBody = {} + if (opts.instanceName !== undefined && opts.instanceName !== null) { + postBody['instanceName'] = opts.instanceName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 modifyInstanceName 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}/instances/{instanceId}:modifyInstanceName', + '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实例进行主备切换。<br>注意:如果实例正在进行备份,那么主备切换将会终止备份操作。可以查看备份策略中的备份开始时间确认是否有备份正在运行。如果确实需要在实例备份时进行主备切换,建议切换完成 后,手工进行一次实例的全备<br>对于SQL Server,主备切换后30分钟内,不支持按时间点恢复/创建,例如在10:05分用户进行了主备切换,那么10:05 ~ 10:35这个时间段不能进行按时间点恢复/创建。<br>- 仅支持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 + */ + + failoverInstance (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 failoverInstance" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling failoverInstance" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 failoverInstance 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}/instances/{instanceId}:failoverInstance', + '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实例,例如修改了一些配置参数后,需要重启实例才能生效。可以结合主备切换的功能,轮流重启备机,降低对业务的影响<br>**注意:如果实例正在进行备份,那么重启主实例将会终止备份操作。** 可以查看备份策略中的备份开始时间确认是否有备份正在运行。如果确实需要在实例备份时重启主实例,建议重启后,手工进行一次实例的全备。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {} [opts.rebootMaster] - 是否重启主节点。<br> - 仅SQL Server 支持该参数 optional + * @param {} [opts.rebootSlave] - 是否重启备节点。<br> - 仅SQL Server 支持该参数 optional + * @param {} [opts.force] - 是否强制重启 <br>- 仅支持MySQL optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + rebootInstance (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 rebootInstance" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling rebootInstance" + ) + } + + let postBody = {} + if (opts.rebootMaster !== undefined && opts.rebootMaster !== null) { + postBody['rebootMaster'] = opts.rebootMaster + } + if (opts.rebootSlave !== undefined && opts.rebootSlave !== null) { + postBody['rebootSlave'] = opts.rebootSlave + } + if (opts.force !== undefined && opts.force !== null) { + postBody['force'] = opts.force + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 rebootInstance 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}/instances/{instanceId}:rebootInstance', + '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实例的外网访问功能。开启后,用户可以通过internet访问RDS实例 + * @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 + */ + + enableInternetAccess (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 enableInternetAccess" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling enableInternetAccess" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 enableInternetAccess 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}/instances/{instanceId}:enableInternetAccess', + '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实例的外网访问功能。关闭后,用户无法通过Internet访问RDS,但可以在京东云内网通过内网域名访问 + * @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 + */ + + disableInternetAccess (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 disableInternetAccess" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling disableInternetAccess" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 disableInternetAccess 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}/instances/{instanceId}:disableInternetAccess', + '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 {} [opts.backupId] - 用于恢复的备份Id,仅限于本实例生成的备份 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + restoreInstance (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 restoreInstance" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling restoreInstance" + ) + } + + let postBody = {} + if (opts.backupId !== undefined && opts.backupId !== null) { + postBody['backupId'] = opts.backupId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 restoreInstance 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}/instances/{instanceId}:restoreInstance', + '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>例如根据源实例A的一个全量备份“mybak”新建一个实例B,该备份是在“‘2018-8-18 03:23:54”创建的。那么新建实例B的数据状态跟实例A‘2018-8-18 03:23:54’的状态一致 + * @param {Object} opts - parameters + * @param {string} opts.backupId - 备份ID + * @param {string} opts.engine - 标识是创建什么类型的实例,例如MySQL,SQL Server等,具体可参见文档[枚举参数定义](../Enum-Definitions/Enum-Definitions.md)<br>**注意:备份来源实例的engine和要创建的实例的engine必须一致** + * @param {restoredNewDBInstanceSpec} opts.instanceSpec - 新建实例规格 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string instanceId + * @param string orderId + */ + + createInstanceFromBackup (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 createInstanceFromBackup" + ) + } + + opts = opts || {} + + if (opts.backupId === undefined || opts.backupId === null) { + throw new Error( + "Missing the required parameter 'opts.backupId' when calling createInstanceFromBackup" + ) + } + if (opts.engine === undefined || opts.engine === null) { + throw new Error( + "Missing the required parameter 'opts.engine' when calling createInstanceFromBackup" + ) + } + if (opts.instanceSpec === undefined || opts.instanceSpec === null) { + throw new Error( + "Missing the required parameter 'opts.instanceSpec' when calling createInstanceFromBackup" + ) + } + + let postBody = {} + if (opts.backupId !== undefined && opts.backupId !== null) { + postBody['backupId'] = opts.backupId + } + if (opts.engine !== undefined && opts.engine !== null) { + postBody['engine'] = opts.engine + } + 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 rds/1.3.4' + } + + 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 createInstanceFromBackup 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}/instances:createInstanceFromBackup', + '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) + } + ) + } + + /** + * 实例扩容,支持升级实例的CPU,内存及磁盘。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} opts.newInstanceClass - 扩容后实例规格 + * @param {integer} opts.newInstanceStorageGB - 扩容后实例磁盘大小 + * @param {string} [opts.newInstanceStorageType] - 存储类型,如果不指定,默认会采用实例原存储类型. optional + * @param {boolean} [opts.storageEncrypted] - 实例数据加密(存储类型为云硬盘才支持数据加密). false:不加密; true:加密. 如果实例从本地盘变为云硬盘,缺省为false. 如果实例本来就是使用云硬盘的,缺省和源实例保持一致 optional + * @param {string} [opts.subnetId] - 变配后的子网ID optional + * @param {string} [opts.effectiveTime] - 生效时间,取值:<br>immediate:立即生效<br>maintainTime:在可维护时间段内生效。<br>postpone:延后生效。 optional + * @param {integer} [opts.postponeTime] - 延后生效的时间,单位为分钟。effectiveTime为postpone时必传,取值1-1440分钟 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string orderId 生成的订单号 + */ + + 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.newInstanceClass === undefined || opts.newInstanceClass === null) { + throw new Error( + "Missing the required parameter 'opts.newInstanceClass' when calling modifyInstanceSpec" + ) + } + if ( + opts.newInstanceStorageGB === undefined || + opts.newInstanceStorageGB === null + ) { + throw new Error( + "Missing the required parameter 'opts.newInstanceStorageGB' when calling modifyInstanceSpec" + ) + } + + let postBody = {} + if (opts.newInstanceClass !== undefined && opts.newInstanceClass !== null) { + postBody['newInstanceClass'] = opts.newInstanceClass + } + if ( + opts.newInstanceStorageGB !== undefined && + opts.newInstanceStorageGB !== null + ) { + postBody['newInstanceStorageGB'] = opts.newInstanceStorageGB + } + if ( + opts.newInstanceStorageType !== undefined && + opts.newInstanceStorageType !== null + ) { + postBody['newInstanceStorageType'] = opts.newInstanceStorageType + } + if (opts.storageEncrypted !== undefined && opts.storageEncrypted !== null) { + postBody['storageEncrypted'] = opts.storageEncrypted + } + if (opts.subnetId !== undefined && opts.subnetId !== null) { + postBody['subnetId'] = opts.subnetId + } + if (opts.effectiveTime !== undefined && opts.effectiveTime !== null) { + postBody['effectiveTime'] = opts.effectiveTime + } + if (opts.postponeTime !== undefined && opts.postponeTime !== null) { + postBody['postponeTime'] = opts.postponeTime + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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}/instances/{instanceId}: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) + } + ) + } + + /** + * 根据源实例备份创建一个新实例,并通过追加日志的方式,将新实例的数据恢复到跟源实例指定时间点的数据状态一样。<br>例如根据实例A在“2018-06-18 23:00:00”时间点创建一个实例B,就是新建一个实例B,该实例B的数据跟实例A在“2018-06-18 23:00:00”这个时间点的数据完全一致。<br>对于SQL Server,主备切换后30分钟内,不支持按时间点恢复/创建,例如在10:05分用户进行了主备切换,那么10:05 ~ 10:35这个时间段不能进行按时间点恢复/创建。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} opts.restoreTime - 根据源实例的哪个时间点创建新实例 + * @param {restoredNewDBInstanceSpec} opts.instanceSpec - 新建实例规格 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string instanceId 新创建的实例ID + * @param string orderId 生成的订单号 + */ + + createInstanceByTime (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 createInstanceByTime" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createInstanceByTime" + ) + } + if (opts.restoreTime === undefined || opts.restoreTime === null) { + throw new Error( + "Missing the required parameter 'opts.restoreTime' when calling createInstanceByTime" + ) + } + if (opts.instanceSpec === undefined || opts.instanceSpec === null) { + throw new Error( + "Missing the required parameter 'opts.instanceSpec' when calling createInstanceByTime" + ) + } + + let postBody = {} + if (opts.restoreTime !== undefined && opts.restoreTime !== null) { + postBody['restoreTime'] = opts.restoreTime + } + if (opts.instanceSpec !== undefined && opts.instanceSpec !== null) { + postBody['instanceSpec'] = opts.instanceSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 createInstanceByTime 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}/instances/{instanceId}:createInstanceByTime', + '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) + } + ) + } + + /** + * 创建MySQL的只读实例<br> - 仅支持MySQL<br> - 创建的只读实例跟主实例在同一个VPC同一个子网中<br> * 只读实例只支持按配置计费 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} opts.instanceName - 实例名称,具体规则可参见帮助中心文档:[名称及密码限制](../../../documentation/Database-and-Cache-Service/RDS/Introduction/Restrictions/SQLServer-Restrictions.md) + * @param {string} opts.instanceClass - 只读实例规格FlavorId + * @param {string} [opts.instanceStorageType] - 存储类型,参见[枚举参数定义](../Enum-Definitions/Enum-Definitions.md),缺省值为:LOCAL_SSD optional + * @param {integer} opts.instanceStorageGB - 磁盘空间 + * @param {string} opts.azId - 可用区ID + * @param {string} [opts.vpcId] - VPC的ID,如果没有填写就保持和常规实例一样的VPC optional + * @param {string} [opts.subnetId] - 子网ID,如果没有填写就保持和常规实例一样的subnet optional + * @param {string} [opts.parameterGroup] - 参数组ID,缺省采用和常规实例一样的参数组 optional + * @param {boolean} [opts.storageEncrypted] - 实例数据加密(存储类型为云硬盘才支持数据加密)。false:不加密;true:加密。缺省为false。 optional + * @param {integer} [opts.count] - 创建只读实例的数目,缺省为1 optional + * @param {string} [opts.roInstanceProxy] - 只读代理服务的ID,缺省值为 “NULL”,表示不绑定代理服务 optional + * @param {array} [opts.tagSpec] - 标签信息 optional + * @param {string} [opts.resourceGroupId] - 资源组id optional + * @param {chargeSpec} [opts.chargeSpec] - 计费规格,包括计费类型,计费周期等 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string roInstanceId 新创建的只读实例ID + * @param string orderId 订单ID + */ + + createROInstance (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 createROInstance" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createROInstance" + ) + } + if (opts.instanceName === undefined || opts.instanceName === null) { + throw new Error( + "Missing the required parameter 'opts.instanceName' when calling createROInstance" + ) + } + if (opts.instanceClass === undefined || opts.instanceClass === null) { + throw new Error( + "Missing the required parameter 'opts.instanceClass' when calling createROInstance" + ) + } + if ( + opts.instanceStorageGB === undefined || + opts.instanceStorageGB === null + ) { + throw new Error( + "Missing the required parameter 'opts.instanceStorageGB' when calling createROInstance" + ) + } + if (opts.azId === undefined || opts.azId === null) { + throw new Error( + "Missing the required parameter 'opts.azId' when calling createROInstance" + ) + } + + let postBody = {} + if (opts.instanceName !== undefined && opts.instanceName !== null) { + postBody['instanceName'] = opts.instanceName + } + if (opts.instanceClass !== undefined && opts.instanceClass !== null) { + postBody['instanceClass'] = opts.instanceClass + } + if ( + opts.instanceStorageType !== undefined && + opts.instanceStorageType !== null + ) { + postBody['instanceStorageType'] = opts.instanceStorageType + } + if ( + opts.instanceStorageGB !== undefined && + opts.instanceStorageGB !== null + ) { + postBody['instanceStorageGB'] = opts.instanceStorageGB + } + if (opts.azId !== undefined && opts.azId !== null) { + postBody['azId'] = opts.azId + } + if (opts.vpcId !== undefined && opts.vpcId !== null) { + postBody['vpcId'] = opts.vpcId + } + if (opts.subnetId !== undefined && opts.subnetId !== null) { + postBody['subnetId'] = opts.subnetId + } + if (opts.parameterGroup !== undefined && opts.parameterGroup !== null) { + postBody['parameterGroup'] = opts.parameterGroup + } + if (opts.storageEncrypted !== undefined && opts.storageEncrypted !== null) { + postBody['storageEncrypted'] = opts.storageEncrypted + } + if (opts.count !== undefined && opts.count !== null) { + postBody['count'] = opts.count + } + if (opts.roInstanceProxy !== undefined && opts.roInstanceProxy !== null) { + postBody['roInstanceProxy'] = opts.roInstanceProxy + } + if (opts.tagSpec !== undefined && opts.tagSpec !== null) { + postBody['tagSpec'] = opts.tagSpec + } + if (opts.resourceGroupId !== undefined && opts.resourceGroupId !== null) { + postBody['resourceGroupId'] = opts.resourceGroupId + } + if (opts.chargeSpec !== undefined && opts.chargeSpec !== null) { + postBody['chargeSpec'] = opts.chargeSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 createROInstance 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}/instances/{instanceId}:createROInstance', + '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) + } + ) + } + + /** + * 修改MySQL实例的连接模式:标准模式(standard) 和高安全模式(security).<br>- **标准模式**:响应时间短,但没有 SQL 审计和拦截的能力。<br>- **高安全模式**:具备一定的 SQL注入拦截能力(通过分析表达式、关键系统函数等来实现防御 SQL 注入攻击),并可开启 SQL 审计,但会增加一定的响应时间。<br>- 仅支持MySQL + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} opts.connectionMode - 连接模式<br> - standard:标准模式(缺省),响应时间短,但没有 SQL 审计和拦截的能力 <br>- security:高安全模式,具备一定的 SQL注入拦截能力,并可开启 SQL 审计,但会增加一定的响应时间 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyConnectionMode (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 modifyConnectionMode" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyConnectionMode" + ) + } + if (opts.connectionMode === undefined || opts.connectionMode === null) { + throw new Error( + "Missing the required parameter 'opts.connectionMode' when calling modifyConnectionMode" + ) + } + + let postBody = {} + if (opts.connectionMode !== undefined && opts.connectionMode !== null) { + postBody['connectionMode'] = opts.connectionMode + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 modifyConnectionMode 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}/instances/{instanceId}:modifyConnectionMode', + '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) + } + ) + } + + /** + * 获取SQL Server实例按时间点恢复/创建时,可恢复到的最后的一个时间点<br>- 仅支持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 latestRestoreTime 实例按时间点恢复时,可恢复到的最后的一个时间点 + */ + + describeLatestRestoreTime (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 describeLatestRestoreTime" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeLatestRestoreTime" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeLatestRestoreTime 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}/instances/{instanceId}:describeLatestRestoreTime', + '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>- 仅支持MySQL + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {} opts.parameterGroupId - 参数组ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyParameterGroup (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 modifyParameterGroup" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyParameterGroup" + ) + } + if (opts.parameterGroupId === undefined || opts.parameterGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.parameterGroupId' when calling modifyParameterGroup" + ) + } + + let postBody = {} + if (opts.parameterGroupId !== undefined && opts.parameterGroupId !== null) { + postBody['parameterGroupId'] = opts.parameterGroupId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 modifyParameterGroup 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}/instances/{instanceId}:modifyParameterGroup', + '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) + } + ) + } + + /** + * 交换两个实例的域名,包括内网域名和外网域名。如果一个实例有外网域名,一个没有,则不允许交换。<br>- 仅支持SQL Server + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {} opts.targetInstanceId - 要交换的实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + exchangeInstanceDns (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 exchangeInstanceDns" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling exchangeInstanceDns" + ) + } + if (opts.targetInstanceId === undefined || opts.targetInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.targetInstanceId' when calling exchangeInstanceDns" + ) + } + + let postBody = {} + if (opts.targetInstanceId !== undefined && opts.targetInstanceId !== null) { + postBody['targetInstanceId'] = opts.targetInstanceId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 exchangeInstanceDns 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}/instances/{instanceId}:exchangeInstanceDns', + '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 {} opts.newAzId - 新可用区ID。 如果是单机实例,只需输入一个可用区;如果是主备实例,则必须输入两个可用区ID:第一个为主节点所在可用区,第二个为备节点所在可用区。主备两个可用区可以相同,也可以不同 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyInstanceAz (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 modifyInstanceAz" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyInstanceAz" + ) + } + if (opts.newAzId === undefined || opts.newAzId === null) { + throw new Error( + "Missing the required parameter 'opts.newAzId' when calling modifyInstanceAz" + ) + } + + let postBody = {} + if (opts.newAzId !== undefined && opts.newAzId !== null) { + postBody['newAzId'] = opts.newAzId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 modifyInstanceAz 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}/instances/{instanceId}:modifyInstanceAz', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean available 当前实例是否已经开启加密连接,如已开启,返回true,如未开启,返回false. + */ + + describeSSL (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 describeSSL" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeSSL" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeSSL 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}/instances/{instanceId}/ssl', + '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 - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + enableSSL (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 enableSSL" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling enableSSL" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 enableSSL 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}/instances/{instanceId}/ssl:enableSSL', + '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>- 仅支持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 + */ + + disableSSL (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 disableSSL" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling disableSSL" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 disableSSL 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}/instances/{instanceId}/ssl:disableSSL', + '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>- 仅支持MySQL + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {} opts.restoreTime - 根据源实例的哪个时间点创建新实例 + * @param {} opts.restoreSchema - 需要进行单库,单表恢复的概要信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + restoreInstanceByTime (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 restoreInstanceByTime" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling restoreInstanceByTime" + ) + } + if (opts.restoreTime === undefined || opts.restoreTime === null) { + throw new Error( + "Missing the required parameter 'opts.restoreTime' when calling restoreInstanceByTime" + ) + } + if (opts.restoreSchema === undefined || opts.restoreSchema === null) { + throw new Error( + "Missing the required parameter 'opts.restoreSchema' when calling restoreInstanceByTime" + ) + } + + let postBody = {} + if (opts.restoreTime !== undefined && opts.restoreTime !== null) { + postBody['restoreTime'] = opts.restoreTime + } + if (opts.restoreSchema !== undefined && opts.restoreSchema !== null) { + postBody['restoreSchema'] = opts.restoreSchema + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 restoreInstanceByTime 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}/instances/{instanceId}:restoreInstanceByTime', + '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) + } + ) + } + + /** + * 修改SQL Server对接的Active Directory 服务。支持SQL Server 2012 及2012以上以上的版本。<br>注意:修改目录服务后,需重启SQL Server实例才能生效 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {} opts.adResourceId - 目录服务的资源ID<br>- 加入目录服务:要加入的目录服务的资源ID<br>- 修改目录服务:新目录服务的资源ID<br>- 移除目录服务:传入字符串“none”,不区分大小写 + * @param {} opts.forceRestart - 修改后,是否强制重启实例,使修改生效。<br> - true 修改后立即重启<br>- false:默认值,修改后不重启,需用户自行重启 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyActiveDirectory (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 modifyActiveDirectory" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyActiveDirectory" + ) + } + if (opts.adResourceId === undefined || opts.adResourceId === null) { + throw new Error( + "Missing the required parameter 'opts.adResourceId' when calling modifyActiveDirectory" + ) + } + if (opts.forceRestart === undefined || opts.forceRestart === null) { + throw new Error( + "Missing the required parameter 'opts.forceRestart' when calling modifyActiveDirectory" + ) + } + + let postBody = {} + if (opts.adResourceId !== undefined && opts.adResourceId !== null) { + postBody['adResourceId'] = opts.adResourceId + } + if (opts.forceRestart !== undefined && opts.forceRestart !== null) { + postBody['forceRestart'] = opts.forceRestart + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 modifyActiveDirectory 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}/instances/{instanceId}:modifyActiveDirectory', + '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 {} [opts.maintainTime] - 实例的可维护时间段。格式:HH:mm-HH:mm,取值为一个小时整点 optional + * @param {} [opts.maintainPeriod] - 选择维护周期,可选择一周中的某一天或多天 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyInstanceMaintainTime (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 modifyInstanceMaintainTime" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyInstanceMaintainTime" + ) + } + + let postBody = {} + if (opts.maintainTime !== undefined && opts.maintainTime !== null) { + postBody['maintainTime'] = opts.maintainTime + } + if (opts.maintainPeriod !== undefined && opts.maintainPeriod !== null) { + postBody['maintainPeriod'] = opts.maintainPeriod + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 modifyInstanceMaintainTime 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}/instances/{instanceId}:modifyInstanceMaintainTime', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string maintainTime 实例的可维护时间段。格式:HH:mm-HH:mm + * @param string maintainPeriod Monday、Tuesday、Wednesday、Thursday、Friday、Saturday、Sunday + */ + + describeInstanceMaintainTime ( + 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 describeInstanceMaintainTime" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeInstanceMaintainTime" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeInstanceMaintainTime 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}/instances/{instanceId}:describeInstanceMaintainTime', + '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 - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + switchForModifyingInstanceSpec ( + 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 switchForModifyingInstanceSpec" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling switchForModifyingInstanceSpec" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 switchForModifyingInstanceSpec 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}/instances/{instanceId}:switchForModifyingInstanceSpec', + '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) + } + ) + } + + /** + * 获取当前数据库可升级到的版本,仅支持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 string versions + */ + + describeUpgradeVersions (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 describeUpgradeVersions" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeUpgradeVersions" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeUpgradeVersions 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}/instances/{instanceId}:describeUpgradeVersions', + '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) + } + ) + } + + /** + * 查询当前发起的数据库的升级计划,仅支持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 string newVersion 升级后的新版本 + * @param integer upgradeSchedule 计划开始升级的时间,1:立即开始升级,2:维护时间窗口升级 + */ + + describeUpgradePlan (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 describeUpgradePlan" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeUpgradePlan" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeUpgradePlan 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}/instances/{instanceId}:describeUpgradePlan', + '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) + } + ) + } + + /** + * 升级引擎版本,例如从5.7.21 升级到5.7.24,仅支持MySQL + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {} opts.upgradeSchedule - 计划开始升级的时间,1:立即开始升级,2:维护时间窗口升级,0:取消升级 + * @param {} [opts.newVersion] - 升级到的新版本,默认为当前实例可升级到的最新版本 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + upgradeEngineVersion (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 upgradeEngineVersion" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling upgradeEngineVersion" + ) + } + if (opts.upgradeSchedule === undefined || opts.upgradeSchedule === null) { + throw new Error( + "Missing the required parameter 'opts.upgradeSchedule' when calling upgradeEngineVersion" + ) + } + + let postBody = {} + if (opts.upgradeSchedule !== undefined && opts.upgradeSchedule !== null) { + postBody['upgradeSchedule'] = opts.upgradeSchedule + } + if (opts.newVersion !== undefined && opts.newVersion !== null) { + postBody['newVersion'] = opts.newVersion + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 upgradeEngineVersion 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}/instances/{instanceId}:upgradeEngineVersion', + '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>- 仅支持MySQL + * @param {Object} opts - parameters + * @param {string} opts.instanceId - Instance ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + enableIntercept (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 enableIntercept" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling enableIntercept" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 enableIntercept 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}/instances/{instanceId}/intercept:enableIntercept', + '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>- 仅支持MySQL + * @param {Object} opts - parameters + * @param {string} opts.instanceId - Instance ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + disableIntercept (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 disableIntercept" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling disableIntercept" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 disableIntercept 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}/instances/{instanceId}/intercept:disableIntercept', + '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) + } + ) + } + + /** + * 查看开启高安全模式后,当前实例的 SQL 拦截记录<br>- 仅支持MySQL + * @param {Object} opts - parameters + * @param {string} opts.instanceId - Instance ID + * @param {integer} [opts.pageNumber] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageNumber为-1时,返回所有数据页码; optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[10,100],且为10的整数倍 optional + * @param {filter} [opts.filters] - 过滤参数,多个过滤参数之间的关系为“与”(and); +支持以下属性的过滤:account,database,keyword; 支持operator选项:eq,in; 仅支持 MySQL,Percona,MariaDB + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param interceptResult interceptResult + * @param integer totalCount + */ + + describeInterceptResult (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 describeInterceptResult" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeInterceptResult" + ) + } + + 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, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeInterceptResult 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}/instances/{instanceId}/intercept:describeInterceptResult', + '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>- 仅支持MySQL + * @param {Object} opts - parameters + * @param {string} opts.instanceId - Instance ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean available + */ + + describeIntercept (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 describeIntercept" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeIntercept" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeIntercept 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}/instances/{instanceId}/intercept', + '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>- 仅支持PostgreSQL, MySQL, Percona, MariaDB + * @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 {filter} [opts.filters] - 过滤参数,多个过滤参数之间的关系为“与”(and) +支持以下属性的过滤:logType, 支持operator选项:eq, 仅支持 MySQL,Percona,MariaDB + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param log logs + * @param integer totalCount + */ + + describeLogs (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 describeLogs" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeLogs" + ) + } + + 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, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeLogs 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}/instances/{instanceId}/log:describeLogs', + '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) + } + ) + } + + /** + * 设置日志文件的下载链接过期时间,重新生成 PostgreSQL 的日志文件下载地址 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} opts.logId - 日志文件ID + * @param {} opts.seconds - 设置链接地址的过期时间,单位是秒,最长不能超过取值范围为 1 ~ 86400 秒 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string publicURL 公网下载链接 + * @param string internalURL 内网下载链接 + */ + + updateLogDownloadURLInternal ( + 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 updateLogDownloadURLInternal" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling updateLogDownloadURLInternal" + ) + } + if (opts.logId === undefined || opts.logId === null) { + throw new Error( + "Missing the required parameter 'opts.logId' when calling updateLogDownloadURLInternal" + ) + } + if (opts.seconds === undefined || opts.seconds === null) { + throw new Error( + "Missing the required parameter 'opts.seconds' when calling updateLogDownloadURLInternal" + ) + } + + let postBody = {} + if (opts.seconds !== undefined && opts.seconds !== null) { + postBody['seconds'] = opts.seconds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + logId: opts.logId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 updateLogDownloadURLInternal 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}/instances/{instanceId}/log/{logId}:updateLogDownloadURLInternal', + '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) + } + ) + } + + /** + * 根据日志文件的下载链接过期时间,生成日志文件下载地址 仅支持 PostgreSQL, MySQL, Percona, MariaDB + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} opts.logId - 日志文件ID + * @param {} [opts.seconds] - 设置链接地址的过期时间,单位是秒,默认值是 300 秒,最长不能超过取值范围为 1 ~ 86400 秒 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string publicURL 公网下载链接 + * @param string internalURL 内网下载链接 + */ + + describeLogDownloadURL (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 describeLogDownloadURL" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeLogDownloadURL" + ) + } + if (opts.logId === undefined || opts.logId === null) { + throw new Error( + "Missing the required parameter 'opts.logId' when calling describeLogDownloadURL" + ) + } + + let postBody = {} + if (opts.seconds !== undefined && opts.seconds !== null) { + postBody['seconds'] = opts.seconds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + logId: opts.logId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeLogDownloadURL 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}/instances/{instanceId}/log/{logId}:describeLogDownloadURL', + '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) + } + ) + } + + /** + * 查看SQL Server实例的配置参数<br>- 仅支持SQL Server + * @param {Object} opts - parameters + * @param {string} opts.instanceId - Instance ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dBInstanceParameter parameters + */ + + describeParameters (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 describeParameters" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeParameters" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeParameters 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}/instances/{instanceId}/parameters', + '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) + } + ) + } + + /** + * 修改SQL Server实例的配置参数,目前支持以下参数:max_worker_threads,max_degree_of_parallelism,max_server_memory_(MB)。 部分参数修改后,需要重启才能生效,具体可以参考微软的相关文档。<br>- 仅支持SQL Server + * @param {Object} opts - parameters + * @param {string} opts.instanceId - Instance ID + * @param {array} opts.parameters - 修改的实例参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyParameters (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 modifyParameters" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyParameters" + ) + } + if (opts.parameters === undefined || opts.parameters === null) { + throw new Error( + "Missing the required parameter 'opts.parameters' when calling modifyParameters" + ) + } + + let postBody = {} + if (opts.parameters !== undefined && opts.parameters !== null) { + postBody['parameters'] = opts.parameters + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 modifyParameters 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}/instances/{instanceId}/parameters', + '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) + } + ) + } + + /** + * 删除参数组<br>- 仅支持MySQL,Percona,MariaDB,PostgreSQL + * @param {Object} opts - parameters + * @param {string} opts.parameterGroupId - Parameter Group ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteParameterGroup (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 deleteParameterGroup" + ) + } + + opts = opts || {} + + if (opts.parameterGroupId === undefined || opts.parameterGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.parameterGroupId' when calling deleteParameterGroup" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + parameterGroupId: opts.parameterGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 deleteParameterGroup 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}/parameterGroups/{parameterGroupId}', + '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>- 仅支持MySQL,Percona,MariaDB,PostgreSQL + * @param {Object} opts - parameters + * @param {string} opts.parameterGroupId - Parameter Group ID + * @param {} opts.parameterGroupName - 参数组名称 + * @param {} [opts.description] - 参数组描述 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyParameterGroupAttribute ( + 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 modifyParameterGroupAttribute" + ) + } + + opts = opts || {} + + if (opts.parameterGroupId === undefined || opts.parameterGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.parameterGroupId' when calling modifyParameterGroupAttribute" + ) + } + if ( + opts.parameterGroupName === undefined || + opts.parameterGroupName === null + ) { + throw new Error( + "Missing the required parameter 'opts.parameterGroupName' when calling modifyParameterGroupAttribute" + ) + } + + let postBody = {} + if ( + opts.parameterGroupName !== undefined && + opts.parameterGroupName !== null + ) { + postBody['parameterGroupName'] = opts.parameterGroupName + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + parameterGroupId: opts.parameterGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 modifyParameterGroupAttribute 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}/parameterGroups/{parameterGroupId}:modifyParameterGroupAttribute', + '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) + } + ) + } + + /** + * 获取当前账号下所有的参数组列表<br>- 仅支持MySQL,Percona,MariaDB,PostgreSQL + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageNumber为-1时,返回所有数据页码; optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[10,100],且为10的整数倍 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param parameterGroup parameterGroups + * @param integer totalCount + */ + + describeParameterGroups (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 describeParameterGroups" + ) + } + + 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 + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeParameterGroups 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}/parameterGroups', + '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>- 仅支持MySQL,Percona,MariaDB,PostgreSQL + * @param {Object} opts - parameters + * @param {} opts.engine - 实例引擎类型,参见[枚举参数定义](../Enum-Definitions/Enum-Definitions.md) + * @param {} opts.engineVersion - 实例引擎版本,参见[枚举参数定义](../Enum-Definitions/Enum-Definitions.md) + * @param {} opts.parameterGroupName - 参数组的名字 + * @param {} [opts.description] - 参数组的描述 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string parameterGroupId + */ + + createParameterGroup (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 createParameterGroup" + ) + } + + opts = opts || {} + + if (opts.engine === undefined || opts.engine === null) { + throw new Error( + "Missing the required parameter 'opts.engine' when calling createParameterGroup" + ) + } + if (opts.engineVersion === undefined || opts.engineVersion === null) { + throw new Error( + "Missing the required parameter 'opts.engineVersion' when calling createParameterGroup" + ) + } + if ( + opts.parameterGroupName === undefined || + opts.parameterGroupName === null + ) { + throw new Error( + "Missing the required parameter 'opts.parameterGroupName' when calling createParameterGroup" + ) + } + + let postBody = {} + if (opts.engine !== undefined && opts.engine !== null) { + postBody['engine'] = opts.engine + } + if (opts.engineVersion !== undefined && opts.engineVersion !== null) { + postBody['engineVersion'] = opts.engineVersion + } + if ( + opts.parameterGroupName !== undefined && + opts.parameterGroupName !== null + ) { + postBody['parameterGroupName'] = opts.parameterGroupName + } + 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 rds/1.3.4' + } + + 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 createParameterGroup 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}/parameterGroups', + '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>- 仅支持MySQL,Percona,MariaDB,PostgreSQL + * @param {Object} opts - parameters + * @param {string} opts.parameterGroupId - Parameter Group ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param parameterGroupParameter parameters + */ + + describeParameterGroupParameters ( + 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 describeParameterGroupParameters" + ) + } + + opts = opts || {} + + if (opts.parameterGroupId === undefined || opts.parameterGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.parameterGroupId' when calling describeParameterGroupParameters" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + parameterGroupId: opts.parameterGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeParameterGroupParameters 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}/parameterGroups/{parameterGroupId}/parameters', + '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>- 仅支持MySQL,Percona,MariaDB,PostgreSQL + * @param {Object} opts - parameters + * @param {string} opts.parameterGroupId - Parameter Group ID + * @param {} opts.parameters - 修改的参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyParameterGroupParameters ( + 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 modifyParameterGroupParameters" + ) + } + + opts = opts || {} + + if (opts.parameterGroupId === undefined || opts.parameterGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.parameterGroupId' when calling modifyParameterGroupParameters" + ) + } + if (opts.parameters === undefined || opts.parameters === null) { + throw new Error( + "Missing the required parameter 'opts.parameters' when calling modifyParameterGroupParameters" + ) + } + + let postBody = {} + if (opts.parameters !== undefined && opts.parameters !== null) { + postBody['parameters'] = opts.parameters + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + parameterGroupId: opts.parameterGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 modifyParameterGroupParameters 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}/parameterGroups/{parameterGroupId}/parameters', + '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) + } + ) + } + + /** + * 查看参数的修改历史<br>- 仅支持MySQL,Percona,MariaDB,PostgreSQL + * @param {Object} opts - parameters + * @param {string} opts.parameterGroupId - Parameter Group ID + * @param {integer} [opts.pageNumber] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageNumber为-1时,返回所有数据页码; optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[10,100],且为10的整数倍 optional + * @param {string} [opts.startTime] - 查询开始时间,格式为:YYYY-MM-DD HH:mm:ss optional + * @param {string} [opts.endTime] - 查询结束时间,格式为:YYYY-MM-DD HH:mm:ss optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param parameterModifyRecords records + * @param integer totalCount + */ + + describeParameterModifyRecords ( + 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 describeParameterModifyRecords" + ) + } + + opts = opts || {} + + if (opts.parameterGroupId === undefined || opts.parameterGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.parameterGroupId' when calling describeParameterModifyRecords" + ) + } + + 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.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: regionId, + parameterGroupId: opts.parameterGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeParameterModifyRecords 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}/parameterGroups/{parameterGroupId}/records', + '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 {} opts.parameterGroupId - 参数组ID + * @param {} opts.parameterGroupName - 参数组的名字 + * @param {} [opts.description] - 参数组的描述 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string parameterGroupId + */ + + copyParameterGroup (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 copyParameterGroup" + ) + } + + opts = opts || {} + + if (opts.parameterGroupId === undefined || opts.parameterGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.parameterGroupId' when calling copyParameterGroup" + ) + } + if ( + opts.parameterGroupName === undefined || + opts.parameterGroupName === null + ) { + throw new Error( + "Missing the required parameter 'opts.parameterGroupName' when calling copyParameterGroup" + ) + } + + let postBody = {} + if (opts.parameterGroupId !== undefined && opts.parameterGroupId !== null) { + postBody['parameterGroupId'] = opts.parameterGroupId + } + if ( + opts.parameterGroupName !== undefined && + opts.parameterGroupName !== null + ) { + postBody['parameterGroupName'] = opts.parameterGroupName + } + 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 rds/1.3.4' + } + + 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 copyParameterGroup 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}/parameterGroups:copyParameterGroup', + '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>- 仅支持MySQL,Percona,MariaDB,PostgreSQL + * @param {Object} opts - parameters + * @param {string} opts.parameterGroupId - Parameter Group ID + * @param {integer} [opts.pageNumber] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageNumber为-1时,返回所有数据页码; optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[10,100],且为10的整数倍 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param attachedDBInstance instances + * @param integer totalCount + */ + + describeParameterGroupAttachedInstances ( + 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 describeParameterGroupAttachedInstances" + ) + } + + opts = opts || {} + + if (opts.parameterGroupId === undefined || opts.parameterGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.parameterGroupId' when calling describeParameterGroupAttachedInstances" + ) + } + + 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, + parameterGroupId: opts.parameterGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeParameterGroupAttachedInstances 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}/parameterGroups/{parameterGroupId}/instances', + '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>- 仅支持SQL Server + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} opts.queryType - 查询类型,不同的查询类型按照相应的字段从高到低返回结果。<br>支持如下类型:<br>Missing:缺失索引<br>Size:索引大小,单位KB<br>Updates:索引更新次数<br>Scans:表扫描次数<br>Used:最少使用<br> + * @param {string} [opts.db] - 需要查询的数据库名,多个数据库名之间用英文逗号分隔,默认所有数据库 optional + * @param {integer} [opts.pageNumber] - 显示数据的页码,默认为1,取值范围:[-1,∞]。pageNumber为-1时,返回所有数据页码; optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为50,取值范围:[1,100],只能为10的倍数,用于查询列表的接口 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param missingIndexResult missingIndexResult + * @param indexPerformanceResult indexPerformanceResult + * @param integer totalCount 总记录条数 + * @param integer pageNumber 当前数据的页码 + * @param integer pageSize 每页显示的数据条数 + */ + + describeIndexPerformance (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 describeIndexPerformance" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeIndexPerformance" + ) + } + if (opts.queryType === undefined || opts.queryType === null) { + throw new Error( + "Missing the required parameter 'opts.queryType' when calling describeIndexPerformance" + ) + } + + let postBody = null + let queryParams = {} + if (opts.queryType !== undefined && opts.queryType !== null) { + queryParams['queryType'] = opts.queryType + } + if (opts.db !== undefined && opts.db !== null) { + queryParams['db'] = opts.db + } + 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 rds/1.3.4' + } + + 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 describeIndexPerformance 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}/instances/{instanceId}/performance:describeIndexPerformance', + '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) + } + ) + } + + /** + * 根据用户定义的查询条件,获取SQL执行的性能统计信息,例如慢SQL等。用户可以根据这些信息查找与SQL执行相关的性能瓶颈,并进行优化。<br>- 仅支持SQL Server + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} opts.queryType - 查询类型,不同的查询类型按照相应的字段从高到低返回结果。<br>支持如下类型:<br>ExecutionCount:执行次数<br>LastRows:上次返回行数<br>ElapsedTime:平均执行时间<br>CPUTime:平均CPU时间<br>LogicalReads:平均逻辑读<br>LogicalWrites:平均逻辑写<br>PhysicalReads:平均物理读<br> + * @param {integer} [opts.threshold] - 只返回查询条件大于等于threshold的记录,默认为0 optional + * @param {integer} [opts.pageNumber] - 显示数据的页码,默认为1,取值范围:[-1,1000]。pageNumber为-1时,返回所有数据页码; optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为50,取值范围:[1,100],只能为10的倍数,用于查询列表的接口 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param queryPerformanceResult queryPerformanceResult + * @param integer totalCount 总记录条数 + * @param integer pageNumber 当前数据的页码 + * @param integer pageSize 每页显示的数据条数 + */ + + describeQueryPerformance (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 describeQueryPerformance" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeQueryPerformance" + ) + } + if (opts.queryType === undefined || opts.queryType === null) { + throw new Error( + "Missing the required parameter 'opts.queryType' when calling describeQueryPerformance" + ) + } + + let postBody = null + let queryParams = {} + if (opts.queryType !== undefined && opts.queryType !== null) { + queryParams['queryType'] = opts.queryType + } + if (opts.threshold !== undefined && opts.threshold !== null) { + queryParams['threshold'] = opts.threshold + } + 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 rds/1.3.4' + } + + 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 describeQueryPerformance 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}/instances/{instanceId}/performance:describeQueryPerformance', + '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) + } + ) + } + + /** + * 查询MySQL实例的慢日志的详细信息。<br>- 仅支持MySQL + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} opts.startTime - 慢日志开始时间,格式为:YYYY-MM-DD HH:mm:ss,开始时间到当前时间不能大于 7 天, 开始时间不能大于结束时间 + * @param {string} opts.endTime - 慢日志结束时间,格式为:YYYY-MM-DD HH:mm:ss,开始时间到当前时间不能大于 7 天, 开始时间不能大于结束时间 + * @param {string} [opts.dbName] - 废弃字段,查询哪个数据库的慢日志,不填表示返回所有数据库的慢日志。 optional + * @param {integer} [opts.pageNumber] - 显示数据的页码,默认为1,取值范围:[-1,∞]。pageNumber为-1时,返回所有数据页码 optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[10,100] optional + * @param {filter} [opts.filters] - 过滤参数,多个过滤参数之间的关系为“与”(and支持以下属性的过滤(默认等值):) +- account:实例账号名,operator仅支持eq或者in +- keyword:SQL 关键词,模糊查询,operator仅支持eq或者in + optional + * @param {sort} [opts.sorts] - 慢日志明细的排序规则,不指定时按上报日志的时间戳降序返回所有的日志 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param slowLogAttributes slowLogsAttributes + * @param integer totalCount 总记录条数 + */ + + describeSlowLogAttributes (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 describeSlowLogAttributes" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeSlowLogAttributes" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeSlowLogAttributes" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeSlowLogAttributes" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + 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 + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + Object.assign(queryParams, super.buildSortParam(opts.sorts, 'sorts')) + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeSlowLogAttributes 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}/instances/{instanceId}/performance:describeSlowLogAttributes', + '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) + } + ) + } + + /** + * 查询MySQL实例的慢日志的概要信息。<br>- 仅支持MySQL + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} opts.startTime - 慢日志开始时间,格式为:YYYY-MM-DD HH:mm:ss,开始时间到当前时间不能大于 7 天,开始时间不能大于结束时间 + * @param {string} opts.endTime - 慢日志结束时间,格式为:YYYY-MM-DD HH:mm:ss,开始时间到当前时间不能大于 7 天,开始时间不能大于结束时间 + * @param {string} [opts.dbName] - 废弃字段,查询哪个数据库的慢日志,不填表示返回所有数据库的慢日志 optional + * @param {integer} [opts.pageNumber] - 显示数据的页码,默认为1,取值范围:[-1,∞]。pageNumber为-1时,返回所有数据页码; optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[10,100] optional + * @param {filter} [opts.filters] - 过滤参数,多个过滤参数之间的关系为“与”(and支持以下属性的过滤(默认等值):) +- account:实例账号名,operator仅支持eq或者in +- keyword:SQL 关键词,模糊查询,operator仅支持eq或者in + optional + * @param {sort} [opts.sorts] - 排序参数,支持rowsExaminedSum、rowsSentSum、lockTimeSum、executionCount、executionTimeSum optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param slowLogDigest slowLogs + * @param integer totalCount 总记录条数 + */ + + describeSlowLogs (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 describeSlowLogs" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeSlowLogs" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeSlowLogs" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeSlowLogs" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + 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 + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + Object.assign(queryParams, super.buildSortParam(opts.sorts, 'sorts')) + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeSlowLogs 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}/instances/{instanceId}/performance:describeSlowLogs', + '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) + } + ) + } + + /** + * 根据用户定义的查询条件,获取正在执行中的SQL执行的性能信息。用户可以根据这些信息查找与SQL执行相关的性能瓶颈,并进行优化。<br>- 仅支持SQL Server + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} [opts.db] - 需要查询的数据库名,多个数据库名之间用英文逗号分隔,默认所有数据库 optional + * @param {integer} [opts.threshold] - 返回执行时间大于等于threshold的记录,默认10,单位秒 optional + * @param {integer} [opts.pageNumber] - 显示数据的页码,默认为1,取值范围:[-1,∞]。pageNumber为-1时,返回所有数据页码; optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为50,取值范围:[1,100],只能为10的倍数 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param activeQueryPerformanceResult activeQueryPerformanceResult + * @param integer totalCount 总记录条数 + * @param integer pageNumber 当前数据的页码 + * @param integer pageSize 每页显示的数据条数 + */ + + describeActiveQueryPerformance ( + 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 describeActiveQueryPerformance" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeActiveQueryPerformance" + ) + } + + let postBody = null + let queryParams = {} + if (opts.db !== undefined && opts.db !== null) { + queryParams['db'] = opts.db + } + if (opts.threshold !== undefined && opts.threshold !== null) { + queryParams['threshold'] = opts.threshold + } + 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 rds/1.3.4' + } + + 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 describeActiveQueryPerformance 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}/instances/{instanceId}/performance:describeActiveQueryPerformance', + '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 - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} opts.startTime - 错误日志开始时间,格式为:YYYY-MM-DD HH:mm:ss,开始时间到当前时间不能大于 7 天,开始时间不能大于结束时间,结束时间不能大于当前时间 + * @param {string} opts.endTime - 错误日志结束时间,格式为:YYYY-MM-DD HH:mm:ss,开始时间到当前时间不能大于 7 天,开始时间不能大于结束时间,结束时间不能大于当前时间 + * @param {string} [opts.dbName] - 查询哪个数据库的慢日志,不填表示返回所有数据库的错误日志。<br>- MySQL不支持 optional + * @param {integer} [opts.pageNumber] - 显示数据的页码,默认为1,取值范围:[-1,∞]。pageNumber为-1时,返回所有数据页码; optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为50,取值范围:[1,100],只能为10的倍数 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param errorLogDigest errorLogs + * @param integer totalCount 总记录条数 + */ + + describeErrorLog (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 describeErrorLog" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeErrorLog" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeErrorLog" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeErrorLog" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + 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 rds/1.3.4' + } + + 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 describeErrorLog 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}/instances/{instanceId}/performance:describeErrorLog', + '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>- 仅支持MySQL、PostgreSQL + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS实例ID,唯一标识一个实例 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param readWriteProxy readWriteProxies + * @param integer totalCount + */ + + describeReadWriteProxies (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 describeReadWriteProxies" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeReadWriteProxies" + ) + } + + 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 rds/1.3.4' + } + + 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 describeReadWriteProxies 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}/readWriteProxy', + '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>- 仅支持MySQL、PostgreSQL + * @param {Object} opts - parameters + * @param {} opts.instanceId - RDS 实例ID + * @param {} [opts.delayThreshold] - 延迟阈值,范围是1~1000,单位:秒,默认为100,仅MySQL optional + * @param {} [opts.walDelayThreshold] - wal日志延迟阈值,范围是1~1024,单位:MB,默认为200,仅PostgreSQL optional + * @param {} [opts.loadBalancerPolicy] - 读写分离代理后端实例负载均衡策略,默认值为LEAST_CURRENT_OPERATIONS;当前支持的负载均衡策略请查看[枚举参数定义](../Enum-Definitions/Enum-Definitions.md) optional + * @param {} [opts.healthCheckSpec] - 后端实例健康检查配置 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string readWriteProxyId RDS 读写分离代理服务ID + */ + + createReadWriteProxy (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 createReadWriteProxy" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createReadWriteProxy" + ) + } + + let postBody = {} + if (opts.instanceId !== undefined && opts.instanceId !== null) { + postBody['instanceId'] = opts.instanceId + } + if (opts.delayThreshold !== undefined && opts.delayThreshold !== null) { + postBody['delayThreshold'] = opts.delayThreshold + } + if ( + opts.walDelayThreshold !== undefined && + opts.walDelayThreshold !== null + ) { + postBody['walDelayThreshold'] = opts.walDelayThreshold + } + if ( + opts.loadBalancerPolicy !== undefined && + opts.loadBalancerPolicy !== null + ) { + postBody['loadBalancerPolicy'] = opts.loadBalancerPolicy + } + if (opts.healthCheckSpec !== undefined && opts.healthCheckSpec !== null) { + postBody['healthCheckSpec'] = opts.healthCheckSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 createReadWriteProxy 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}/readWriteProxy', + '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读写分离代理详情<br>- 仅支持MySQL、PostgreSQL + * @param {Object} opts - parameters + * @param {string} opts.readWriteProxyId - 读写分离代理服务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param readWriteProxy readWriteProxy + */ + + describeReadWriteProxyAttribute ( + 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 describeReadWriteProxyAttribute" + ) + } + + opts = opts || {} + + if (opts.readWriteProxyId === undefined || opts.readWriteProxyId === null) { + throw new Error( + "Missing the required parameter 'opts.readWriteProxyId' when calling describeReadWriteProxyAttribute" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + readWriteProxyId: opts.readWriteProxyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeReadWriteProxyAttribute 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}/readWriteProxy/{readWriteProxyId}', + '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>- 仅支持MySQL + * @param {Object} opts - parameters + * @param {string} opts.readWriteProxyId - 读写分离代理服务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteReadWriteProxy (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 deleteReadWriteProxy" + ) + } + + opts = opts || {} + + if (opts.readWriteProxyId === undefined || opts.readWriteProxyId === null) { + throw new Error( + "Missing the required parameter 'opts.readWriteProxyId' when calling deleteReadWriteProxy" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + readWriteProxyId: opts.readWriteProxyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 deleteReadWriteProxy 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}/readWriteProxy/{readWriteProxyId}', + '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) + } + ) + } + + /** + * 开启读写分离代理服务的外网访问功能。开启后,用户可以通过 internet 连接读写分离代理服务<br>- 仅支持MySQL、PostgreSQL + * @param {Object} opts - parameters + * @param {string} opts.readWriteProxyId - 读写分离代理服务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + enableReadWriteProxyInternetAccess ( + 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 enableReadWriteProxyInternetAccess" + ) + } + + opts = opts || {} + + if (opts.readWriteProxyId === undefined || opts.readWriteProxyId === null) { + throw new Error( + "Missing the required parameter 'opts.readWriteProxyId' when calling enableReadWriteProxyInternetAccess" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + readWriteProxyId: opts.readWriteProxyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 enableReadWriteProxyInternetAccess 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}/readWriteProxy/{readWriteProxyId}:enableReadWriteProxyInternetAccess', + '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) + } + ) + } + + /** + * 关闭读写分离代理服务的外网访问功能。关闭后,用户无法通过 Internet 连接读写分离代理服务,但可以在京东云内网通过内网域名连接<br>- 仅支持MySQL、PostgreSQL + * @param {Object} opts - parameters + * @param {string} opts.readWriteProxyId - 读写分离代理服务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + disableReadWriteProxyInternetAccess ( + 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 disableReadWriteProxyInternetAccess" + ) + } + + opts = opts || {} + + if (opts.readWriteProxyId === undefined || opts.readWriteProxyId === null) { + throw new Error( + "Missing the required parameter 'opts.readWriteProxyId' when calling disableReadWriteProxyInternetAccess" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + readWriteProxyId: opts.readWriteProxyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 disableReadWriteProxyInternetAccess 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}/readWriteProxy/{readWriteProxyId}:disableReadWriteProxyInternetAccess', + '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>- 仅支持MySQL、PostgreSQL + * @param {Object} opts - parameters + * @param {string} opts.readWriteProxyId - 读写分离代理服务ID + * @param {} [opts.delayThreshold] - 延迟阈值,范围是1~1000,单位:秒,默认为100,仅MySQL optional + * @param {} [opts.walDelayThreshold] - wal日志延迟阈值,范围是1~1024,单位:MB,默认为200,仅PostgreSQL optional + * @param {} [opts.loadBalancerPolicy] - 读写分离代理后端实例负载均衡策略,默认值为LEAST_CURRENT_OPERATIONS;当前支持的负载均衡策略请查看[枚举参数定义](../Enum-Definitions/Enum-Definitions.md) optional + * @param {} [opts.healthCheckSpec] - 后端实例健康检查配置 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyReadWriteProxy (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 modifyReadWriteProxy" + ) + } + + opts = opts || {} + + if (opts.readWriteProxyId === undefined || opts.readWriteProxyId === null) { + throw new Error( + "Missing the required parameter 'opts.readWriteProxyId' when calling modifyReadWriteProxy" + ) + } + + let postBody = {} + if (opts.delayThreshold !== undefined && opts.delayThreshold !== null) { + postBody['delayThreshold'] = opts.delayThreshold + } + if ( + opts.walDelayThreshold !== undefined && + opts.walDelayThreshold !== null + ) { + postBody['walDelayThreshold'] = opts.walDelayThreshold + } + if ( + opts.loadBalancerPolicy !== undefined && + opts.loadBalancerPolicy !== null + ) { + postBody['loadBalancerPolicy'] = opts.loadBalancerPolicy + } + if (opts.healthCheckSpec !== undefined && opts.healthCheckSpec !== null) { + postBody['healthCheckSpec'] = opts.healthCheckSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + readWriteProxyId: opts.readWriteProxyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 modifyReadWriteProxy 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}/readWriteProxy/{readWriteProxyId}:modifyReadWriteProxy', + '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) + } + ) + } + + /** + * 获取当前实例的指定库的表列表信息 - 仅支持 MySQL,Percona,MariaDB + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} opts.dbName - 库名称 + * @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 string tables + * @param integer totalCount + */ + + describeTables (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 describeTables" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeTables" + ) + } + if (opts.dbName === undefined || opts.dbName === null) { + throw new Error( + "Missing the required parameter 'opts.dbName' when calling describeTables" + ) + } + + 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, + dbName: opts.dbName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeTables 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}/instances/{instanceId}/databases/{dbName}/tables', + '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) + } + ) + } + + /** + * 查看当前实例是否开启TDE + * @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 status 当前实例是否已经开启TDE功能,如已开启,返回true;如未开启,返回false;开启中,返回pending;已开启未生效时返回inProgress + * @param statusDetail statusDetail TDE加密已开启未生效时返回实例重启状态的详细进度;TDE加密已开启未生效或未开启时返回空;<当实例类型为MySQL时有效> + */ + + describeTde (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 describeTde" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeTde" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeTde 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}/instances/{instanceId}/tde', + '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) + } + ) + } + + /** + * 开启数据库的TDE功能 + * @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 + */ + + enableTde (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 enableTde" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling enableTde" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 enableTde 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}/instances/{instanceId}/tde:enableTde', + '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实例当前白名单。白名单是允许访问当前实例的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 + */ + + describeWhiteList (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 describeWhiteList" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeWhiteList" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 describeWhiteList 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}/instances/{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,仅MySQL、Percona、MariaDB支持。修改允许访问实例的IP白名单。白名单是允许访问当前实例的IP/IP段列表,缺省情况下,白名单对本VPC开放。如果用户开启了外网访问的功能,还需要对外网的IP配置白名单。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {} opts.whiteListName - 白名单名称 + * @param {} 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 + */ + + createWhiteListGroup (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 createWhiteListGroup" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createWhiteListGroup" + ) + } + if (opts.whiteListName === undefined || opts.whiteListName === null) { + throw new Error( + "Missing the required parameter 'opts.whiteListName' when calling createWhiteListGroup" + ) + } + if (opts.ips === undefined || opts.ips === null) { + throw new Error( + "Missing the required parameter 'opts.ips' when calling createWhiteListGroup" + ) + } + + let postBody = {} + if (opts.whiteListName !== undefined && opts.whiteListName !== null) { + postBody['whiteListName'] = opts.whiteListName + } + 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 rds/1.3.4' + } + + 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 createWhiteListGroup 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}/instances/{instanceId}/whiteList', + '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) + } + ) + } + + /** + * 修改允许访问实例的IP白名单。白名单是允许访问当前实例的IP/IP段列表,缺省情况下,白名单对本VPC开放。如果用户开启了外网访问的功能,还需要对外网的IP配置白名单。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {} [opts.whiteListName] - 白名单名称,默认Default optional + * @param {} 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 + */ + + modifyWhiteList (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 modifyWhiteList" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyWhiteList" + ) + } + if (opts.ips === undefined || opts.ips === null) { + throw new Error( + "Missing the required parameter 'opts.ips' when calling modifyWhiteList" + ) + } + + let postBody = {} + if (opts.whiteListName !== undefined && opts.whiteListName !== null) { + postBody['whiteListName'] = opts.whiteListName + } + 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 rds/1.3.4' + } + + 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 modifyWhiteList 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}/instances/{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) + } + ) + } + + /** + * 当该白名单分组用户无需使用时,可进行删除。仅适用于MySQL、Percona、MariaDB。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} opts.whiteListName - 白名单名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteWhiteListGroup (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 deleteWhiteListGroup" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteWhiteListGroup" + ) + } + if (opts.whiteListName === undefined || opts.whiteListName === null) { + throw new Error( + "Missing the required parameter 'opts.whiteListName' when calling deleteWhiteListGroup" + ) + } + + let postBody = null + let queryParams = {} + if (opts.whiteListName !== undefined && opts.whiteListName !== null) { + queryParams['whiteListName'] = opts.whiteListName + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rds/1.3.4' + } + + 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 deleteWhiteListGroup 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}/instances/{instanceId}/whiteList', + '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) + } + ) + } +} +module.exports = RDS diff --git a/packages/libs/lib-jdcloud/src/repo/rdts/v2/rdts.js b/packages/libs/lib-jdcloud/src/repo/rdts/v2/rdts.js new file mode 100644 index 000000000..1015c40d1 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/rdts/v2/rdts.js @@ -0,0 +1,1183 @@ +/* + * 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. + * + * operation + * 查询异步请求结果 + * + * 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 = 'rdts' +Service._services[serviceId] = true + +/** + * rdts service. + * @version 2.5.3 + */ + +class RDTS extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'rdts.jdcloud-api.com' + options.basePath = '/v2' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 迁移任务列表,可分页、可排序、可搜索、可过滤 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码:取值范围[1,∞),默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小:取值范围[10,100],默认为10 optional + * @param {filter} [opts.filters] - 过滤条件: +- instanceIds:迁移任务ID,精确匹配,可选择多个 +- migrationName:迁移任务名称,模糊匹配 +- migrationStatuses:迁移任务状态,精确匹配,可选择多个(具体可参考迁移任务详情中的迁移状态) + optional + * @param {sort} [opts.sorts] - 排序属性: +- createdTime:按创建时间排序(asc表示按时间正序,desc表示按时间倒序) + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param listItem instances + * @param integer totalCount 迁移任务总数 + */ + + describeMigrations (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 describeMigrations" + ) + } + + 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')) + Object.assign(queryParams, super.buildSortParam(opts.sorts, 'sorts')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rdts/2.5.3' + } + + 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 describeMigrations 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}/instance', + '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 {migrateConfig} opts.migrateConfig - 迁移配置,创建成功后可修改 + * @param {azAndNetConfig} [opts.azAndNetConfig] - 可用区与网络配置,创建成功后不能修改 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string instanceId 迁移任务ID + */ + + createMigration (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 createMigration" + ) + } + + opts = opts || {} + + if (opts.migrateConfig === undefined || opts.migrateConfig === null) { + throw new Error( + "Missing the required parameter 'opts.migrateConfig' when calling createMigration" + ) + } + + let postBody = {} + if (opts.migrateConfig !== undefined && opts.migrateConfig !== null) { + postBody['migrateConfig'] = opts.migrateConfig + } + if (opts.azAndNetConfig !== undefined && opts.azAndNetConfig !== null) { + postBody['azAndNetConfig'] = opts.azAndNetConfig + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rdts/2.5.3' + } + + 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 createMigration 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}/instance', + '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 - 迁移任务的唯一标识 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instance instance 迁移任务详请 + */ + + describeMigration (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 describeMigration" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeMigration" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rdts/2.5.3' + } + + 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 describeMigration 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}/instance/{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.instanceId - 迁移任务的唯一标识 + * @param {migrateConfig} [opts.migrateConfig] - 迁移配置参数 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyMigration (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 modifyMigration" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyMigration" + ) + } + + let postBody = {} + if (opts.migrateConfig !== undefined && opts.migrateConfig !== null) { + postBody['migrateConfig'] = opts.migrateConfig + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rdts/2.5.3' + } + + 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 modifyMigration 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}/instance/{instanceId}', + 'PATCH', + 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 - 迁移任务的唯一标识 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteMigration (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 deleteMigration" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteMigration" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rdts/2.5.3' + } + + 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 deleteMigration 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}/instance/{instanceId}', + '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.instanceId - 迁移任务的唯一标识 + * @param {string} [opts.migrateName] - 迁移任务名 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyMigrationName (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 modifyMigrationName" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyMigrationName" + ) + } + + let postBody = {} + if (opts.migrateName !== undefined && opts.migrateName !== null) { + postBody['migrateName'] = opts.migrateName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rdts/2.5.3' + } + + 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 modifyMigrationName 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}/instance/{instanceId}:modifyMigrateName', + '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 - 迁移任务的唯一标识 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param migrateProgress migrationProgress 迁移进度 + */ + + getMigrationProgress (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 getMigrationProgress" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling getMigrationProgress" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rdts/2.5.3' + } + + 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 getMigrationProgress 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}/instance/{instanceId}:getMigrationProgress', + '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) + } + ) + } + + /** + * 创建迁移job,创建job之后无法修改迁移配置 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 迁移任务的唯一标识 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + createMigrationJob (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 createMigrationJob" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createMigrationJob" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rdts/2.5.3' + } + + 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 createMigrationJob 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}/instance/{instanceId}:start', + '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) + } + ) + } + + /** + * 启动迁移job,开始迁移数据 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 迁移任务的唯一标识 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + startMigrationJob (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 startMigrationJob" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling startMigrationJob" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rdts/2.5.3' + } + + 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 startMigrationJob 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}/instance/{instanceId}:migrate', + '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 - 迁移任务的唯一标识 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + restartMigrationJob (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 restartMigrationJob" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling restartMigrationJob" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rdts/2.5.3' + } + + 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 restartMigrationJob 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}/instance/{instanceId}:remigrate', + '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 = RDTS diff --git a/packages/libs/lib-jdcloud/src/repo/redis/v1/redis.js b/packages/libs/lib-jdcloud/src/repo/redis/v1/redis.js new file mode 100644 index 000000000..7a617ea0a --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/redis/v1/redis.js @@ -0,0 +1,7844 @@ +/* + * 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. + * + * Redis SpecConfig API + * 缓存Redis实例规格配置接口 + * + * 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 = 'redis' +Service._services[serviceId] = true + +/** + * redis service. + * @version 2.6.32 + */ + +class REDIS extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'redis.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询支持的地域列表 + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param availableRegion availableRegions + */ + + describeAvailableRegion (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 describeAvailableRegion" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeAvailableRegion 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}/availableRegion', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param availableResource availableResources + */ + + describeAvailableResource (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 describeAvailableResource" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeAvailableResource 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}/availableResource', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param availableResource availableResources + */ + + describeAvailableResource2 (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 describeAvailableResource2" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeAvailableResource2 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}/availableResource2', + '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) + } + ) + } + + /** + * 查询缓存Redis实例列表,可分页、可排序、可搜索、可过滤 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码:取值范围[1,∞),默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小:取值范围[10, 100],默认为10 optional + * @param {filter} [opts.filters] - 过滤属性: +cacheInstanceId - 实例Id,精确匹配,可选择多个 +cacheInstanceName - 实例名称,模糊匹配 +cacheInstanceStatus - 实例状态,精确匹配,可选择多个(running:运行中,error:错误,creating:创建中,changing:变配中,configuring:参数修改中,restoring:备份恢复中,deleting:删除中) +redisVersion - redis引擎版本,精确匹配,可选择2.8和4.0 +instanceType - 实例类型,精确匹配(redis表示主从版,redis_cluster表示集群版) +chargeMode - 计费类型,精确匹配(prepaid_by_duration表示包年包月预付费,postpaid_by_duration表示按配置后付费) + optional + * @param {tagFilter} [opts.tagFilters] - 标签的过滤条件 optional + * @param {sort} [opts.sorts] - 排序属性: +createTime - 按创建时间排序(asc表示按时间正序,desc表示按时间倒序) + optional + * @param {string} [opts.resourceGroupIds] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param cacheInstance cacheInstances + * @param integer totalCount 实例总数 + */ + + describeCacheInstances (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 describeCacheInstances" + ) + } + + 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')) + Object.assign( + queryParams, + super.buildTagFilterParam(opts.tagFilters, 'tagFilters') + ) + Object.assign(queryParams, super.buildSortParam(opts.sorts, 'sorts')) + Object.assign( + queryParams, + super.buildArrayParam(opts.resourceGroupIds, 'resourceGroupIds') + ) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeCacheInstances 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}/cacheInstance', + '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) + } + ) + } + + /** + * 创建一个指定配置的缓存Redis实例:可选择版本、类型、规格(按CPU核数、内存容量、磁盘容量、带宽等划分),自定义分片规格可通过describeSpecConfig接口获取,老规格代码请参考,https://docs.jdcloud.com/cn/jcs-for-redis/specifications + + * @param {Object} opts - parameters + * @param {cacheInstanceSpec} opts.cacheInstance - 实例的创建参数 + * @param {chargeSpec} [opts.charge] - 实例的计费类型 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string cacheInstanceId 实例ID + * @param string orderNum 订单编号 + * @param string buyId 购买ID + */ + + createCacheInstance (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 createCacheInstance" + ) + } + + opts = opts || {} + + if (opts.cacheInstance === undefined || opts.cacheInstance === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstance' when calling createCacheInstance" + ) + } + + let postBody = {} + if (opts.cacheInstance !== undefined && opts.cacheInstance !== null) { + postBody['cacheInstance'] = opts.cacheInstance + } + if (opts.charge !== undefined && opts.charge !== null) { + postBody['charge'] = opts.charge + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 createCacheInstance 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}/cacheInstance', + '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) + } + ) + } + + /** + * 查询缓存Redis实例的详细信息 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param cacheInstance cacheInstance 实例的详细信息 + */ + + describeCacheInstance (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 describeCacheInstance" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling describeCacheInstance" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeCacheInstance 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}/cacheInstance/{cacheInstanceId}', + '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) + } + ) + } + + /** + * 修改缓存Redis实例的资源名称或描述,二者至少选一 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} [opts.cacheInstanceName] - 实例的名称,名称只支持数字、字母、英文下划线、中文,且不少于2字符不超过32字符 optional + * @param {string} [opts.cacheInstanceDescription] - 实例的描述,不能超过256个字符 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyCacheInstanceAttribute ( + 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 modifyCacheInstanceAttribute" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling modifyCacheInstanceAttribute" + ) + } + + let postBody = {} + if ( + opts.cacheInstanceName !== undefined && + opts.cacheInstanceName !== null + ) { + postBody['cacheInstanceName'] = opts.cacheInstanceName + } + if ( + opts.cacheInstanceDescription !== undefined && + opts.cacheInstanceDescription !== null + ) { + postBody['cacheInstanceDescription'] = opts.cacheInstanceDescription + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 modifyCacheInstanceAttribute 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}/cacheInstance/{cacheInstanceId}', + 'PATCH', + 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) + } + ) + } + + /** + * 删除按配置计费、或包年包月已到期的缓存Redis实例,包年包月未到期不可删除。 +只有处于运行running或者错误error状态才可以删除,其余状态不可以删除。 +白名单用户不能删除包年包月已到期的缓存Redis实例。 + + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteCacheInstance (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 deleteCacheInstance" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling deleteCacheInstance" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 deleteCacheInstance 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}/cacheInstance/{cacheInstanceId}', + '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) + } + ) + } + + /** + * 变更缓存Redis实例规格(变配),实例运行时可以变配,新规格不能与之前的老规格相同,新规格内存大小不能小于实例的已使用内存 + + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} opts.cacheInstanceClass - 新规格 + * @param {integer} [opts.shardNumber] - 自定义分片数,只对自定义分片规格实例有效 optional + * @param {boolean} [opts.parallel] - 是否开启4.0集群并行变配 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string orderNum 订单编号 + * @param string buyId 购买ID + */ + + modifyCacheInstanceClass (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 modifyCacheInstanceClass" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling modifyCacheInstanceClass" + ) + } + if ( + opts.cacheInstanceClass === undefined || + opts.cacheInstanceClass === null + ) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceClass' when calling modifyCacheInstanceClass" + ) + } + + let postBody = {} + if ( + opts.cacheInstanceClass !== undefined && + opts.cacheInstanceClass !== null + ) { + postBody['cacheInstanceClass'] = opts.cacheInstanceClass + } + if (opts.shardNumber !== undefined && opts.shardNumber !== null) { + postBody['shardNumber'] = opts.shardNumber + } + if (opts.parallel !== undefined && opts.parallel !== null) { + postBody['parallel'] = opts.parallel + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 modifyCacheInstanceClass 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}/cacheInstance/{cacheInstanceId}:modifyCacheInstanceClass', + '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) + } + ) + } + + /** + * 查询缓存Red4.0实例是否支持新变配功能,是否支持并行变配, 变配需要的IP数量及变配预估时间 + + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} [opts.cacheInstanceClass] - 新规格。不传参只返回是否支持新变配功能。 optional + * @param {integer} [opts.shardNumber] - 自定义分片数。不传参只返回是否支持新变配功能。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean supportPScale 是否支持新变配 + * @param boolean supportParallel 是否支持并行变配 + * @param integer serialIpCount 串行变配需要的IP数量 + * @param integer serialTimeCost 串行变配预估时间 + * @param integer parallelIpCount 并行变配需要的IP数量 + * @param integer parallelTimeCost 并行变配预估时间 + */ + + describeResizeModeIpTimeInfo ( + 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 describeResizeModeIpTimeInfo" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling describeResizeModeIpTimeInfo" + ) + } + + let postBody = {} + if ( + opts.cacheInstanceClass !== undefined && + opts.cacheInstanceClass !== null + ) { + postBody['cacheInstanceClass'] = opts.cacheInstanceClass + } + if (opts.shardNumber !== undefined && opts.shardNumber !== null) { + postBody['shardNumber'] = opts.shardNumber + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeResizeModeIpTimeInfo 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}/cacheInstance/{cacheInstanceId}/describeResizeModeIpTimeInfo', + '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) + } + ) + } + + /** + * 修改缓存Redis实例的密码,可为空 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} [opts.password] - 密码,为空即为免密,不少于8字符不超过16字符 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + resetCacheInstancePassword (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 resetCacheInstancePassword" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling resetCacheInstancePassword" + ) + } + + let postBody = {} + if (opts.password !== undefined && opts.password !== null) { + postBody['password'] = opts.password + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 resetCacheInstancePassword 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}/cacheInstance/{cacheInstanceId}:resetCacheInstancePassword', + '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) + } + ) + } + + /** + * 查看缓存Redis实例的当前配置参数 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string unSupportConfigs + * @param configItem instanceConfig + */ + + describeInstanceConfig (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 describeInstanceConfig" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling describeInstanceConfig" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeInstanceConfig 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}/cacheInstance/{cacheInstanceId}/instanceConfig', + '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) + } + ) + } + + /** + * 修改缓存Redis实例的配置参数,支持部分配置参数修改 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {array} opts.instanceConfig - 配置参数名和参数值 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyInstanceConfig (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 modifyInstanceConfig" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling modifyInstanceConfig" + ) + } + if (opts.instanceConfig === undefined || opts.instanceConfig === null) { + throw new Error( + "Missing the required parameter 'opts.instanceConfig' when calling modifyInstanceConfig" + ) + } + + let postBody = {} + if (opts.instanceConfig !== undefined && opts.instanceConfig !== null) { + postBody['instanceConfig'] = opts.instanceConfig + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 modifyInstanceConfig 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}/cacheInstance/{cacheInstanceId}/instanceConfig', + '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.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string time -表示为关闭,HH:mm-HH:mm 时区,例如"01:00-02:00 +0800",表示东八区的1点到2点 + */ + + describeAnalysisTime (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 describeAnalysisTime" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling describeAnalysisTime" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeAnalysisTime 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}/cacheInstance/{cacheInstanceId}/analysisTime', + '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.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} opts.analysisTime - 自动缓存分析时间,设置为-表示关闭,否则为:HH:mm-HH:mm 时区,例如"01:00-02:00 +0800",表示东八区的1点到2点 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyAnalysisTime (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 modifyAnalysisTime" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling modifyAnalysisTime" + ) + } + if (opts.analysisTime === undefined || opts.analysisTime === null) { + throw new Error( + "Missing the required parameter 'opts.analysisTime' when calling modifyAnalysisTime" + ) + } + + let postBody = {} + if (opts.analysisTime !== undefined && opts.analysisTime !== null) { + postBody['analysisTime'] = opts.analysisTime + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 modifyAnalysisTime 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}/cacheInstance/{cacheInstanceId}/analysisTime', + '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.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} opts.date - 格式:yyyy-MM-dd,表示查询某一天的缓存分析列表 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param cacheAnalysis analyses + */ + + describeCacheAnalysisList (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 describeCacheAnalysisList" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling describeCacheAnalysisList" + ) + } + if (opts.date === undefined || opts.date === null) { + throw new Error( + "Missing the required parameter 'opts.date' when calling describeCacheAnalysisList" + ) + } + + let postBody = null + let queryParams = {} + if (opts.date !== undefined && opts.date !== null) { + queryParams['date'] = opts.date + } + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeCacheAnalysisList 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}/cacheInstance/{cacheInstanceId}/cacheAnalysis', + '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) + } + ) + } + + /** + * 创建缓存分析任务,一天最多创建12次分析任务 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} [opts.sizeMode] - 计算大key的方式。若为elementCounts,则使用元素个数计算大key;若为memorySize,则使用内存大小计算大key。默认为memorySize。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + createCacheAnalysis (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 createCacheAnalysis" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling createCacheAnalysis" + ) + } + + let postBody = {} + if (opts.sizeMode !== undefined && opts.sizeMode !== null) { + postBody['sizeMode'] = opts.sizeMode + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 createCacheAnalysis 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}/cacheInstance/{cacheInstanceId}/cacheAnalysis', + '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) + } + ) + } + + /** + * 查询缓存分析任务详情,最多查询到30天前的数据 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} opts.taskId - 任务ID,即request ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string startTime 任务开始时间, rfc3339格式 + * @param string finishTime 任务结束时间, rfc3339格式 + * @param integer analysisType 任务类型,0:手动分析,1自动分析 + * @param redisKey stringBigKeys + * @param redisKey otherBigKeys + * @param redisKey hotKeys + * @param redisCmd cmdCallTimesTop + * @param redisCmd cmdUseCpuTop + * @param object keyTypeDistribution key的类型分布 + * @param object keySizeDistribution key的大小分布 + */ + + describeCacheAnalysisResult (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 describeCacheAnalysisResult" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling describeCacheAnalysisResult" + ) + } + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling describeCacheAnalysisResult" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId, + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeCacheAnalysisResult 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}/cacheInstance/{cacheInstanceId}/cacheAnalysis/{taskId}', + '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列表 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param ips ips + */ + + describeClientList (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 describeClientList" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling describeClientList" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeClientList 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}/cacheInstance/{cacheInstanceId}/clientList', + '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的连接详细信息 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} opts.ip - 客户端IP + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param details details + */ + + describeClientIpDetail (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 describeClientIpDetail" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling describeClientIpDetail" + ) + } + if (opts.ip === undefined || opts.ip === null) { + throw new Error( + "Missing the required parameter 'opts.ip' when calling describeClientIpDetail" + ) + } + + let postBody = {} + if (opts.ip !== undefined && opts.ip !== null) { + postBody['ip'] = opts.ip + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeClientIpDetail 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}/cacheInstance/{cacheInstanceId}/clientIpDetail', + '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) + } + ) + } + + /** + * 查询缓存Redis实例的备份任务(文件)列表,可分页、可指定起止时间或备份任务ID + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[10, 100] optional + * @param {string} [opts.startTime] - 开始时间 optional + * @param {string} [opts.endTime] - 结束时间 optional + * @param {string} [opts.baseId] - 备份任务ID optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param backup backups + * @param integer totalCount 备份任务(文件)总数 + */ + + describeBackups (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 describeBackups" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling describeBackups" + ) + } + + 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.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.baseId !== undefined && opts.baseId !== null) { + queryParams['baseId'] = opts.baseId + } + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeBackups 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}/cacheInstance/{cacheInstanceId}/backup', + '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) + } + ) + } + + /** + * 创建并执行缓存Redis实例的备份任务,只能为手动备份,可设置备份文件名称 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} opts.fileName - 备份文件名称,只支持英文数字和下划线的组合,长度不超过32个字符 + * @param {integer} opts.backupType - 备份类型:手动备份为1,只能为手动备份 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string baseId 本次备份任务ID,可用于查询本次备份任务的结果 + */ + + createBackup (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 createBackup" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling createBackup" + ) + } + if (opts.fileName === undefined || opts.fileName === null) { + throw new Error( + "Missing the required parameter 'opts.fileName' when calling createBackup" + ) + } + if (opts.backupType === undefined || opts.backupType === null) { + throw new Error( + "Missing the required parameter 'opts.backupType' when calling createBackup" + ) + } + + let postBody = {} + if (opts.fileName !== undefined && opts.fileName !== null) { + postBody['fileName'] = opts.fileName + } + if (opts.backupType !== undefined && opts.backupType !== null) { + postBody['backupType'] = opts.backupType + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 createBackup 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}/cacheInstance/{cacheInstanceId}/backup', + '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) + } + ) + } + + /** + * 查询缓存Redis实例的自动备份策略 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean autoBackup 是否开启自动备份,true表示开启,false表示关闭 + * @param string backupPeriod 备份周期,包括:Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday,多个用逗号分隔 + * @param string backupTime 备份时间,格式为:HH:mm-HH:mm 时区,例如"01:00-02:00 +0800",表示东八区的1点到2点 + * @param string nextBackupTime 下次自动备份时间段,ISO 8601标准的UTC时间,格式为:YYYY-MM-DDTHH:mm:ssZ~YYYY-MM-DDTHH:mm:ssZ + */ + + describeBackupPolicy (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 describeBackupPolicy" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling describeBackupPolicy" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeBackupPolicy 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}/cacheInstance/{cacheInstanceId}/backupPolicy', + '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) + } + ) + } + + /** + * 开启或更新缓存Redis实例的自动备份策略,可修改备份周期和备份时间 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {boolean} [opts.autoBackup] - 是否开启自动备份,true表示开启,false表示关闭 optional + * @param {string} opts.backupTime - 设置自动备份时间,格式为:HH:mm-HH:mm 时区,例如"01:00-02:00 +0800",表示东八区的1点到2点 + * @param {string} opts.backupPeriod - 备份周期,包括:Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday,多个用逗号分隔 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyBackupPolicy (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 modifyBackupPolicy" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling modifyBackupPolicy" + ) + } + if (opts.backupTime === undefined || opts.backupTime === null) { + throw new Error( + "Missing the required parameter 'opts.backupTime' when calling modifyBackupPolicy" + ) + } + if (opts.backupPeriod === undefined || opts.backupPeriod === null) { + throw new Error( + "Missing the required parameter 'opts.backupPeriod' when calling modifyBackupPolicy" + ) + } + + let postBody = {} + if (opts.autoBackup !== undefined && opts.autoBackup !== null) { + postBody['autoBackup'] = opts.autoBackup + } + if (opts.backupTime !== undefined && opts.backupTime !== null) { + postBody['backupTime'] = opts.backupTime + } + if (opts.backupPeriod !== undefined && opts.backupPeriod !== null) { + postBody['backupPeriod'] = opts.backupPeriod + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 modifyBackupPolicy 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}/cacheInstance/{cacheInstanceId}/backupPolicy', + 'PATCH', + 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) + } + ) + } + + /** + * 恢复缓存Redis实例的某次备份 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} opts.baseId - 备份任务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + restoreInstance (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 restoreInstance" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling restoreInstance" + ) + } + if (opts.baseId === undefined || opts.baseId === null) { + throw new Error( + "Missing the required parameter 'opts.baseId' when calling restoreInstance" + ) + } + + let postBody = {} + if (opts.baseId !== undefined && opts.baseId !== null) { + postBody['baseId'] = opts.baseId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 restoreInstance 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}/cacheInstance/{cacheInstanceId}/restore', + '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) + } + ) + } + + /** + * 获取缓存Redis实例的备份文件临时下载地址(1个小时有效期) + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} opts.baseId - 备份任务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param downloadUrl downloadUrls + */ + + describeDownloadUrl (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 describeDownloadUrl" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling describeDownloadUrl" + ) + } + if (opts.baseId === undefined || opts.baseId === null) { + throw new Error( + "Missing the required parameter 'opts.baseId' when calling describeDownloadUrl" + ) + } + + let postBody = null + let queryParams = {} + if (opts.baseId !== undefined && opts.baseId !== null) { + queryParams['baseId'] = opts.baseId + } + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeDownloadUrl 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}/cacheInstance/{cacheInstanceId}/backup:describeDownloadUrl', + '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) + } + ) + } + + /** + * 查询Redis实例的集群内部信息 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param clusterInfo info 集群内部信息 + */ + + describeClusterInfo (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 describeClusterInfo" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling describeClusterInfo" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeClusterInfo 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}/cacheInstance/{cacheInstanceId}/clusterInfo', + '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) + } + ) + } + + /** + * 获取Redis实例的IP白名单(只有白名单内的IP、网络才能访问该实例) + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string ipWhiteList + */ + + describeIpWhiteList (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 describeIpWhiteList" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling describeIpWhiteList" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeIpWhiteList 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}/cacheInstance/{cacheInstanceId}/ipWhiteList', + '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) + } + ) + } + + /** + * 修改Redis实例的IP白名单 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {array} [opts.ipWhiteList] - 修改后的IP白名单列表,IP格式为CIDR表示法(x.x.x.x/x),0.0.0.0/0表示任何IP、网络都可以访问 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyIpWhiteList (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 modifyIpWhiteList" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling modifyIpWhiteList" + ) + } + + let postBody = {} + if (opts.ipWhiteList !== undefined && opts.ipWhiteList !== null) { + postBody['ipWhiteList'] = opts.ipWhiteList + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 modifyIpWhiteList 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}/cacheInstance/{cacheInstanceId}/ipWhiteList', + 'PATCH', + 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) + } + ) + } + + /** + * 获取缓存Redis实例的慢查询日志,可分页、可搜索 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[10, 100] optional + * @param {string} [opts.startTime] - 开始时间 optional + * @param {string} [opts.endTime] - 结束时间 optional + * @param {string} [opts.shardId] - 分片id optional + * @param {string} [opts.shardAddr] - 分片地址 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param slowLog slowLogs + * @param integer totalCount 慢查询日志总条数 + */ + + describeSlowLog (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 describeSlowLog" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling describeSlowLog" + ) + } + + 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.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.shardId !== undefined && opts.shardId !== null) { + queryParams['shardId'] = opts.shardId + } + if (opts.shardAddr !== undefined && opts.shardAddr !== null) { + queryParams['shardAddr'] = opts.shardAddr + } + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeSlowLog 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}/cacheInstance/{cacheInstanceId}/slowLog', + '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.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} [opts.taskType] - 任务类型:resize表示变配,upgrade表示升级 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param taskProgress taskProgresses + */ + + describeTaskProgressList (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 describeTaskProgressList" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling describeTaskProgressList" + ) + } + + let postBody = null + let queryParams = {} + if (opts.taskType !== undefined && opts.taskType !== null) { + queryParams['taskType'] = opts.taskType + } + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeTaskProgressList 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}/cacheInstance/{cacheInstanceId}/taskProgress', + '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.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param disableCommandsInfo disableCommandLists + */ + + getDisableCommands (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 getDisableCommands" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling getDisableCommands" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 getDisableCommands 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}/cacheInstance/{cacheInstanceId}/disableCommands', + '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) + } + ) + } + + /** + * 禁用redis命令 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {array} [opts.disableCommands] - 禁用命令列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + setDisableCommands (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 setDisableCommands" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling setDisableCommands" + ) + } + + let postBody = {} + if (opts.disableCommands !== undefined && opts.disableCommands !== null) { + postBody['disableCommands'] = opts.disableCommands + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 setDisableCommands 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}/cacheInstance/{cacheInstanceId}/disableCommands', + '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.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean isSupport 是否支持账号管理功能 + * @param accounts accountLists + */ + + describeAccounts (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 describeAccounts" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling describeAccounts" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeAccounts 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}/cacheInstance/{cacheInstanceId}/account', + '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.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} opts.accountName - 账号名称 + * @param {string} opts.accountPassword - 账号密码 + * @param {string} [opts.accountPrivilege] - 账号权限,默认为读写权限。支持RoleReadOnly(只读权限)、RoleReadWrite(读写权限) optional + * @param {string} [opts.accountDescription] - 账号描述 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + createAccount (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 createAccount" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling createAccount" + ) + } + if (opts.accountName === undefined || opts.accountName === null) { + throw new Error( + "Missing the required parameter 'opts.accountName' when calling createAccount" + ) + } + if (opts.accountPassword === undefined || opts.accountPassword === null) { + throw new Error( + "Missing the required parameter 'opts.accountPassword' when calling createAccount" + ) + } + + let postBody = {} + if (opts.accountName !== undefined && opts.accountName !== null) { + postBody['accountName'] = opts.accountName + } + if (opts.accountPassword !== undefined && opts.accountPassword !== null) { + postBody['accountPassword'] = opts.accountPassword + } + if (opts.accountPrivilege !== undefined && opts.accountPrivilege !== null) { + postBody['accountPrivilege'] = opts.accountPrivilege + } + if ( + opts.accountDescription !== undefined && + opts.accountDescription !== null + ) { + postBody['accountDescription'] = opts.accountDescription + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 createAccount 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}/cacheInstance/{cacheInstanceId}/account', + '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.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} opts.accountName - 账号名称 + * @param {string} [opts.accountPassword] - 账号密码 optional + * @param {string} [opts.accountPrivilege] - 账号权限。支持RoleReadOnly(只读权限)、RoleReadWrite(读写权限) optional + * @param {string} [opts.accountDescription] - 账号备注 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyAccount (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 modifyAccount" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling modifyAccount" + ) + } + if (opts.accountName === undefined || opts.accountName === null) { + throw new Error( + "Missing the required parameter 'opts.accountName' when calling modifyAccount" + ) + } + + let postBody = {} + if (opts.accountName !== undefined && opts.accountName !== null) { + postBody['accountName'] = opts.accountName + } + if (opts.accountPassword !== undefined && opts.accountPassword !== null) { + postBody['accountPassword'] = opts.accountPassword + } + if (opts.accountPrivilege !== undefined && opts.accountPrivilege !== null) { + postBody['accountPrivilege'] = opts.accountPrivilege + } + if ( + opts.accountDescription !== undefined && + opts.accountDescription !== null + ) { + postBody['accountDescription'] = opts.accountDescription + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 modifyAccount 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}/cacheInstance/{cacheInstanceId}/account', + 'PATCH', + 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.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} opts.accountName - 账号名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteAccount (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 deleteAccount" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling deleteAccount" + ) + } + if (opts.accountName === undefined || opts.accountName === null) { + throw new Error( + "Missing the required parameter 'opts.accountName' when calling deleteAccount" + ) + } + + let postBody = null + let queryParams = {} + if (opts.accountName !== undefined && opts.accountName !== null) { + queryParams['accountName'] = opts.accountName + } + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 deleteAccount 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}/cacheInstance/{cacheInstanceId}/account', + '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.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {array} [opts.accounts] - 要修改的账号列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyAccounts (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 modifyAccounts" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling modifyAccounts" + ) + } + + let postBody = {} + if (opts.accounts !== undefined && opts.accounts !== null) { + postBody['accounts'] = opts.accounts + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 modifyAccounts 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}/cacheInstance/{cacheInstanceId}/accounts', + 'PATCH', + 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.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} opts.clearType - 数据清理任务类型 + * @param {string} [opts.keyPattern] - 匹配模式, 如: test*、*test、ab*cc*, 当节点为AllData、ExpiredData时可以忽略此参数 optional + * @param {array} [opts.keyFilter] - key的过滤条件, 当节点为AllData、ExpiredData时可以忽略此参数 optional + * @param {integer} [opts.qpsLimit] - 数据遍历的速率 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + startClearData (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 startClearData" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling startClearData" + ) + } + if (opts.clearType === undefined || opts.clearType === null) { + throw new Error( + "Missing the required parameter 'opts.clearType' when calling startClearData" + ) + } + + let postBody = {} + if (opts.clearType !== undefined && opts.clearType !== null) { + postBody['clearType'] = opts.clearType + } + if (opts.keyPattern !== undefined && opts.keyPattern !== null) { + postBody['keyPattern'] = opts.keyPattern + } + if (opts.keyFilter !== undefined && opts.keyFilter !== null) { + postBody['keyFilter'] = opts.keyFilter + } + if (opts.qpsLimit !== undefined && opts.qpsLimit !== null) { + postBody['qpsLimit'] = opts.qpsLimit + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 startClearData 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}/cacheInstance/{cacheInstanceId}/startClearData', + '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.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + stopClearData (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 stopClearData" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling stopClearData" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 stopClearData 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}/cacheInstance/{cacheInstanceId}/stopClearData', + '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.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param clearDataTaskInfo clearDataTaskInfo + */ + + describeClearData (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 describeClearData" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling describeClearData" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeClearData 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}/cacheInstance/{cacheInstanceId}/describeClearData', + '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) + } + ) + } + + /** + * 查询大key分析任务列表 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} opts.date - 格式:yyyy-MM-dd,表示查询某一天的大key分析列表 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param cacheAnalysis analyses + */ + + describeBigKeyList (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 describeBigKeyList" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling describeBigKeyList" + ) + } + if (opts.date === undefined || opts.date === null) { + throw new Error( + "Missing the required parameter 'opts.date' when calling describeBigKeyList" + ) + } + + let postBody = null + let queryParams = {} + if (opts.date !== undefined && opts.date !== null) { + queryParams['date'] = opts.date + } + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeBigKeyList 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}/cacheInstance/{cacheInstanceId}/bigKey', + '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) + } + ) + } + + /** + * 创建大key分析任务 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {integer} [opts.stringSize] - String类型阈值 optional + * @param {integer} [opts.listSize] - List类型阈值 optional + * @param {integer} [opts.hashSize] - Hash类型阈值 optional + * @param {integer} [opts.setSize] - Set类型阈值 optional + * @param {integer} [opts.zsetSize] - Zset类型阈值 optional + * @param {integer} [opts.top] - top值,范围10~1000 optional + * @param {string} [opts.sizeMode] - 计算大key的方式。若为“elementCounts”,则使用元素个数计算大key;若为“memorySize”,则使用内存大小计算大key。默认为“elementCounts”。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + createBigKeyAnalysis (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 createBigKeyAnalysis" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling createBigKeyAnalysis" + ) + } + + let postBody = {} + if (opts.stringSize !== undefined && opts.stringSize !== null) { + postBody['stringSize'] = opts.stringSize + } + if (opts.listSize !== undefined && opts.listSize !== null) { + postBody['listSize'] = opts.listSize + } + if (opts.hashSize !== undefined && opts.hashSize !== null) { + postBody['hashSize'] = opts.hashSize + } + if (opts.setSize !== undefined && opts.setSize !== null) { + postBody['setSize'] = opts.setSize + } + if (opts.zsetSize !== undefined && opts.zsetSize !== null) { + postBody['zsetSize'] = opts.zsetSize + } + if (opts.top !== undefined && opts.top !== null) { + postBody['top'] = opts.top + } + if (opts.sizeMode !== undefined && opts.sizeMode !== null) { + postBody['sizeMode'] = opts.sizeMode + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 createBigKeyAnalysis 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}/cacheInstance/{cacheInstanceId}/bigKey', + '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) + } + ) + } + + /** + * 查询大key分析详情 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} opts.taskId - 任务id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string startTime 任务开始时间, rfc3339格式 + * @param string finishTime 任务结束时间, rfc3339格式 + * @param integer analysisType 任务类型,0:自动分析,1:手动分析 + * @param redisBigKey stringBigKeys + * @param redisBigKey hashBigKeys + * @param redisBigKey listBigKeys + * @param redisBigKey zsetBigKeys + * @param redisBigKey setBigKeys + */ + + describeBigKeyDetail (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 describeBigKeyDetail" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling describeBigKeyDetail" + ) + } + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling describeBigKeyDetail" + ) + } + + let postBody = null + let queryParams = {} + if (opts.taskId !== undefined && opts.taskId !== null) { + queryParams['taskId'] = opts.taskId + } + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeBigKeyDetail 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}/cacheInstance/{cacheInstanceId}/bigKeyDetail', + '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) + } + ) + } + + /** + * 获取大key自动缓存分析时间 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string time -表示为关闭,HH:mm-HH:mm 时区,例如"01:00-02:00 +0800",表示东八区的1点到2点 + */ + + describeBigKeyAnalysisTime (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 describeBigKeyAnalysisTime" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling describeBigKeyAnalysisTime" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeBigKeyAnalysisTime 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}/cacheInstance/{cacheInstanceId}/bigKeyAutoAnalysisTime', + '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) + } + ) + } + + /** + * 设置大key自动缓存分析时间 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} opts.analysisTime - -表示关闭,否则为:HH:mm-HH:mm 时区,例如"01:00-02:00 +0800",表示东八区的1点到2点 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyBigKeyAnalysisTime (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 modifyBigKeyAnalysisTime" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling modifyBigKeyAnalysisTime" + ) + } + if (opts.analysisTime === undefined || opts.analysisTime === null) { + throw new Error( + "Missing the required parameter 'opts.analysisTime' when calling modifyBigKeyAnalysisTime" + ) + } + + let postBody = {} + if (opts.analysisTime !== undefined && opts.analysisTime !== null) { + postBody['analysisTime'] = opts.analysisTime + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 modifyBigKeyAnalysisTime 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}/cacheInstance/{cacheInstanceId}/bigKeyAutoAnalysisTime', + '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.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + stopCacheAnalysis (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 stopCacheAnalysis" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling stopCacheAnalysis" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 stopCacheAnalysis 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}/cacheInstance/{cacheInstanceId}/stopCacheAnalysis', + '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.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer stringSize String类型的阈值 + * @param integer listSize List类型的阈值 + * @param integer hashSize Hash类型的阈值 + * @param integer setSize Set类型的阈值 + * @param integer zsetSize Zset类型的阈值 + * @param integer topSize top值 + */ + + describeAnalysisThreshold (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 describeAnalysisThreshold" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling describeAnalysisThreshold" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeAnalysisThreshold 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}/cacheInstance/{cacheInstanceId}/cacheAnalysisThreshold', + '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.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {integer} [opts.stringSize] - String类型阈值 optional + * @param {integer} [opts.listSize] - List类型阈值 optional + * @param {integer} [opts.hashSize] - Hash类型阈值 optional + * @param {integer} [opts.setSize] - Set类型阈值 optional + * @param {integer} [opts.zsetSize] - Zset类型阈值 optional + * @param {integer} [opts.top] - top值,范围10~1000 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyAnalysisThreshold (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 modifyAnalysisThreshold" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling modifyAnalysisThreshold" + ) + } + + let postBody = {} + if (opts.stringSize !== undefined && opts.stringSize !== null) { + postBody['stringSize'] = opts.stringSize + } + if (opts.listSize !== undefined && opts.listSize !== null) { + postBody['listSize'] = opts.listSize + } + if (opts.hashSize !== undefined && opts.hashSize !== null) { + postBody['hashSize'] = opts.hashSize + } + if (opts.setSize !== undefined && opts.setSize !== null) { + postBody['setSize'] = opts.setSize + } + if (opts.zsetSize !== undefined && opts.zsetSize !== null) { + postBody['zsetSize'] = opts.zsetSize + } + if (opts.top !== undefined && opts.top !== null) { + postBody['top'] = opts.top + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 modifyAnalysisThreshold 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}/cacheInstance/{cacheInstanceId}/cacheAnalysisThreshold', + '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) + } + ) + } + + /** + * 创建大key分析任务 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {integer} [opts.stringSize] - String类型阈值,最小10240 optional + * @param {integer} [opts.listSize] - List类型阈值,最小1000 optional + * @param {integer} [opts.hashSize] - Hash类型阈值,最小1000 optional + * @param {integer} [opts.setSize] - Set类型阈值,最小1000 optional + * @param {integer} [opts.zsetSize] - Zset类型阈值,最小1000 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + createBigKeyAnalysis2 (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 createBigKeyAnalysis2" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling createBigKeyAnalysis2" + ) + } + + let postBody = {} + if (opts.stringSize !== undefined && opts.stringSize !== null) { + postBody['stringSize'] = opts.stringSize + } + if (opts.listSize !== undefined && opts.listSize !== null) { + postBody['listSize'] = opts.listSize + } + if (opts.hashSize !== undefined && opts.hashSize !== null) { + postBody['hashSize'] = opts.hashSize + } + if (opts.setSize !== undefined && opts.setSize !== null) { + postBody['setSize'] = opts.setSize + } + if (opts.zsetSize !== undefined && opts.zsetSize !== null) { + postBody['zsetSize'] = opts.zsetSize + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 createBigKeyAnalysis2 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}/cacheInstance/{cacheInstanceId}/bigKeyAnalysis', + '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) + } + ) + } + + /** + * 查询大key分析任务列表 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[10, 100] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param clusterCacheAnalysis cacheAnalysisList + * @param integer totalCount 大key分析列表总条数 + */ + + describeBigKeyList2 (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 describeBigKeyList2" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling describeBigKeyList2" + ) + } + + 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, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeBigKeyList2 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}/cacheInstance/{cacheInstanceId}/bigKeyAnalysisResultList', + '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) + } + ) + } + + /** + * 查询大key分析详情 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} opts.taskId - 任务id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string taskId 任务id + * @param integer stringSize String类型的阈值 + * @param integer listSize List类型的阈值 + * @param integer setSize Set类型的阈值 + * @param integer hashSize Hash类型的阈值 + * @param integer zsetSize Zset类型的阈值 + * @param string status 大key分析任务状态(running, success, fail, manual_stop) + * @param string analysisTime 大key分析开始时间, rfc3339格式 + * @param string analysisDuration 大key分析时长 + * @param bigKeyAnalysisNode bigKeyAnalysisNodesList + */ + + describeBigKeyDetail2 (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 describeBigKeyDetail2" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling describeBigKeyDetail2" + ) + } + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling describeBigKeyDetail2" + ) + } + + let postBody = null + let queryParams = {} + if (opts.taskId !== undefined && opts.taskId !== null) { + queryParams['taskId'] = opts.taskId + } + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeBigKeyDetail2 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}/cacheInstance/{cacheInstanceId}/bigKeyAnalysisDetail', + '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) + } + ) + } + + /** + * 获取大key自动缓存分析时间 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string time -表示为关闭,HH:mm-HH:mm 时区,例如"01:00-02:00 +0800",表示东八区的1点到2点 + */ + + describeBigKeyAnalysisTime2 (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 describeBigKeyAnalysisTime2" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling describeBigKeyAnalysisTime2" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeBigKeyAnalysisTime2 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}/cacheInstance/{cacheInstanceId}/bigKeyAnalysisTime', + '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) + } + ) + } + + /** + * 设置大key自动缓存分析时间 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} opts.analysisTime - -表示关闭,否则为:HH:mm-HH:mm 时区,例如"01:00-02:00 +0800",表示东八区的1点到2点 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyBigKeyAnalysisTime2 (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 modifyBigKeyAnalysisTime2" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling modifyBigKeyAnalysisTime2" + ) + } + if (opts.analysisTime === undefined || opts.analysisTime === null) { + throw new Error( + "Missing the required parameter 'opts.analysisTime' when calling modifyBigKeyAnalysisTime2" + ) + } + + let postBody = {} + if (opts.analysisTime !== undefined && opts.analysisTime !== null) { + postBody['analysisTime'] = opts.analysisTime + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 modifyBigKeyAnalysisTime2 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}/cacheInstance/{cacheInstanceId}/bigKeyAnalysisTime', + '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.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer stringSize String类型的阈值 + * @param integer listSize List类型的阈值 + * @param integer hashSize Hash类型的阈值 + * @param integer setSize Set类型的阈值 + * @param integer zsetSize Zset类型的阈值 + */ + + describeAnalysisThreshold2 (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 describeAnalysisThreshold2" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling describeAnalysisThreshold2" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeAnalysisThreshold2 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}/cacheInstance/{cacheInstanceId}/bigKeyAnalysisThreshold', + '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.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {integer} [opts.stringSize] - String类型阈值,最小10240 optional + * @param {integer} [opts.listSize] - List类型阈值,最小1000 optional + * @param {integer} [opts.hashSize] - Hash类型阈值,最小1000 optional + * @param {integer} [opts.setSize] - Set类型阈值,最小1000 optional + * @param {integer} [opts.zsetSize] - Zset类型阈值,最小1000 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyAnalysisThreshold2 (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 modifyAnalysisThreshold2" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling modifyAnalysisThreshold2" + ) + } + + let postBody = {} + if (opts.stringSize !== undefined && opts.stringSize !== null) { + postBody['stringSize'] = opts.stringSize + } + if (opts.listSize !== undefined && opts.listSize !== null) { + postBody['listSize'] = opts.listSize + } + if (opts.hashSize !== undefined && opts.hashSize !== null) { + postBody['hashSize'] = opts.hashSize + } + if (opts.setSize !== undefined && opts.setSize !== null) { + postBody['setSize'] = opts.setSize + } + if (opts.zsetSize !== undefined && opts.zsetSize !== null) { + postBody['zsetSize'] = opts.zsetSize + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 modifyAnalysisThreshold2 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}/cacheInstance/{cacheInstanceId}/bigKeyAnalysisThreshold', + '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) + } + ) + } + + /** + * 查询热key分析结果 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param hotKeyAnalysisNode hotKeyAnalysisNodesList + */ + + describeHotKeyResult2 (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 describeHotKeyResult2" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling describeHotKeyResult2" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeHotKeyResult2 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}/cacheInstance/{cacheInstanceId}/hotKeyAnalysisResult', + '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) + } + ) + } + + /** + * 查询热key分析详情 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} opts.nodeId - 节点id + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[10, 100] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param redisHotKey hotHeys + * @param integer totalCount 热key总数量 + */ + + describeHotKeyDetail2 (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 describeHotKeyDetail2" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling describeHotKeyDetail2" + ) + } + if (opts.nodeId === undefined || opts.nodeId === null) { + throw new Error( + "Missing the required parameter 'opts.nodeId' when calling describeHotKeyDetail2" + ) + } + + let postBody = null + let queryParams = {} + if (opts.nodeId !== undefined && opts.nodeId !== null) { + queryParams['nodeId'] = opts.nodeId + } + 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, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeHotKeyDetail2 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}/cacheInstance/{cacheInstanceId}/hotKeyDetail', + '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) + } + ) + } + + /** + * 查询热key分析结果汇总 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} [opts.startTime] - 开始时间,RFC3339格式,最多可以查询30天内的数据 optional + * @param {string} [opts.endTime] - 结束时间,RFC3339格式,查询时间范围最多7天 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param hotKeyAnalysisNode hotKeyAnalysisNodesList + */ + + describeHotKeySummary (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 describeHotKeySummary" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling describeHotKeySummary" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeHotKeySummary 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}/cacheInstance/{cacheInstanceId}/hotKeyAnalysisSummary', + '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) + } + ) + } + + /** + * 查询热key分析详情 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} opts.nodeId - 节点id + * @param {integer} [opts.pageNumber] - 页码;默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[10, 100] optional + * @param {string} [opts.startTime] - 开始时间,RFC3339格式,最多可以查询30天内的数据 optional + * @param {string} [opts.endTime] - 结束时间,RFC3339格式,查询时间范围最多7天 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param redisHotKey hotHeys + * @param integer totalCount 热key总数量 + */ + + describeHotKeyDetail (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 describeHotKeyDetail" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling describeHotKeyDetail" + ) + } + if (opts.nodeId === undefined || opts.nodeId === null) { + throw new Error( + "Missing the required parameter 'opts.nodeId' when calling describeHotKeyDetail" + ) + } + + let postBody = null + let queryParams = {} + if (opts.nodeId !== undefined && opts.nodeId !== null) { + queryParams['nodeId'] = opts.nodeId + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + queryParams['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeHotKeyDetail 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}/cacheInstance/{cacheInstanceId}/hotKeyAnalysisDetail', + '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) + } + ) + } + + /** + * 重启4.0实例代理 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {array} [opts.proxyIds] - proxy节点id列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + restartProxy (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 restartProxy" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling restartProxy" + ) + } + + let postBody = {} + if (opts.proxyIds !== undefined && opts.proxyIds !== null) { + postBody['proxyIds'] = opts.proxyIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 restartProxy 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}/cacheInstance/{cacheInstanceId}/restartProxy', + '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) + } + ) + } + + /** + * 关闭4.0实例客户端连接 + * @param {Object} opts - parameters + * @param {string} opts.cacheInstanceId - 缓存Redis实例ID,是访问实例的唯一标识 + * @param {string} opts.option - 关闭属性, 支持addr/type/db三种属性 +addr - 根据客户端地址关闭连接 +type - 根据链接类型关闭连接 +db - 根据db关闭连接 + + * @param {string} opts.value - 筛选条件 +属性是addr时 - ip:port, port空表示此ip所有port +属性是type时 - 支持normal/pubsub/all三种条件 +属性是db时 - db列表, 0,1,2.. + + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + clientKill (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 clientKill" + ) + } + + opts = opts || {} + + if (opts.cacheInstanceId === undefined || opts.cacheInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.cacheInstanceId' when calling clientKill" + ) + } + if (opts.option === undefined || opts.option === null) { + throw new Error( + "Missing the required parameter 'opts.option' when calling clientKill" + ) + } + if (opts.value === undefined || opts.value === null) { + throw new Error( + "Missing the required parameter 'opts.value' when calling clientKill" + ) + } + + let postBody = {} + if (opts.option !== undefined && opts.option !== null) { + postBody['option'] = opts.option + } + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + cacheInstanceId: opts.cacheInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 clientKill 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}/cacheInstance/{cacheInstanceId}/clientKill', + '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) + } + ) + } + + /** + * 查询缓存Redis实例的规格列表 + * @param {Object} opts - parameters + * @param {string} [opts.redisVersion] - 缓存Redis的版本号:目前有2.8和4.0,默认为2.8 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instanceClass instanceClasses + * @param integer totalCount + */ + + describeInstanceClass (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 describeInstanceClass" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.redisVersion !== undefined && opts.redisVersion !== null) { + queryParams['redisVersion'] = opts.redisVersion + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeInstanceClass 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}/instanceClass', + '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) + } + ) + } + + /** + * 查询账户的缓存Redis配额信息 + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param quota quota + */ + + describeUserQuota (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 describeUserQuota" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeUserQuota 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}/quota', + '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) + } + ) + } + + /** + * 查询缓存Redis实例的规格配置信息 + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param object shardSpec 单分片规格,自定义分片规格集群实例才需要 + * @param instanceSpec instanceSpec 实例规格 + */ + + describeSpecConfig (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 describeSpecConfig" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 redis/2.6.32' + } + + 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 describeSpecConfig 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}/specConfig', + '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 = REDIS diff --git a/packages/libs/lib-jdcloud/src/repo/refund/v1/refund.js b/packages/libs/lib-jdcloud/src/repo/refund/v1/refund.js new file mode 100644 index 000000000..0ae3971a8 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/refund/v1/refund.js @@ -0,0 +1,289 @@ +/* + * 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. + * + * 退款策略中心 + * 退款策略中心接口 + * + * 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 = 'refund' +Service._services[serviceId] = true + +/** + * refund service. + * @version 0.0.1 + */ + +class REFUND extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'refund.jdcloud.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 退款并删除资源 + * @param {Object} opts - parameters + * @param {resourceRefundReq} [opts.jsonBody] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean success true-请求成功,false-请求失败 + * @param integer code 结果code + * @param string data 退款单号 + * @param string message 失败时显示原因 + */ + + submitResourceRefund (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 submitResourceRefund" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.jsonBody !== undefined && opts.jsonBody !== null) { + postBody['jsonBody'] = opts.jsonBody + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 refund/0.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 submitResourceRefund 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}/refund:resource', + '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.pin + * @param {string} [opts.refundId] optional + * @param {string} [opts.resourceId] optional + * @param {integer} [opts.pageNumber] - 第几页,默认值为0 optional + * @param {integer} [opts.pageSize] - 每页条数,默认为20 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param pageInfos pageInfos + * @param refundResult data + */ + + descirbeRefundStatus (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 descirbeRefundStatus" + ) + } + + opts = opts || {} + + if (opts.pin === undefined || opts.pin === null) { + throw new Error( + "Missing the required parameter 'opts.pin' when calling descirbeRefundStatus" + ) + } + + let postBody = {} + if (opts.pin !== undefined && opts.pin !== null) { + postBody['pin'] = opts.pin + } + if (opts.refundId !== undefined && opts.refundId !== null) { + postBody['refundId'] = opts.refundId + } + if (opts.resourceId !== undefined && opts.resourceId !== null) { + postBody['resourceId'] = opts.resourceId + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 refund/0.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 descirbeRefundStatus 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}/refund:status', + '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 = REFUND diff --git a/packages/libs/lib-jdcloud/src/repo/reservedinstance/v1/reservedinstance.js b/packages/libs/lib-jdcloud/src/repo/reservedinstance/v1/reservedinstance.js new file mode 100644 index 000000000..cd0ac4897 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/reservedinstance/v1/reservedinstance.js @@ -0,0 +1,317 @@ +/* + * 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. + * + * sysConfig APIs + * 系统参数配置 + * + * 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 = 'reservedinstance' +Service._services[serviceId] = true + +/** + * reservedinstance service. + * @version 0.1.2 + */ + +class RESERVEDINSTANCE extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'reservedinstance.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询实例券使用明细列表 + * @param {Object} opts - parameters + * @param {string} [opts.reservedInstanceType] - 实例券类型 optional + * @param {string} [opts.reservedInstanceId] - 实例券ID optional + * @param {string} [opts.instanceId] - 抵扣实例ID optional + * @param {string} [opts.startTime] - 使用开始时间 optional + * @param {string} [opts.endTime] - 使用结束时间 optional + * @param {integer} [opts.pageNo] - 页码,默认为1 optional + * @param {integer} [opts.pageSize] - 分页大小,默认10,最大100 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param pagination pagination + * @param deductionDetailVo result + */ + + describeDeductionDetails (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 describeDeductionDetails" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if ( + opts.reservedInstanceType !== undefined && + opts.reservedInstanceType !== null + ) { + queryParams['reservedInstanceType'] = opts.reservedInstanceType + } + if ( + opts.reservedInstanceId !== undefined && + opts.reservedInstanceId !== null + ) { + queryParams['reservedInstanceId'] = opts.reservedInstanceId + } + if (opts.instanceId !== undefined && opts.instanceId !== null) { + queryParams['instanceId'] = opts.instanceId + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.pageNo !== undefined && opts.pageNo !== null) { + queryParams['pageNo'] = opts.pageNo + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 reservedinstance/0.1.2' + } + + 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 describeDeductionDetails 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}/deductionDetails', + '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.voucherType] - 实例券类型 optional + * @param {integer} [opts.status] - 状态(全部:不传 1.生效 2.失效) optional + * @param {string} [opts.createTimeBegin] - 创建时间段开始时间 optional + * @param {string} [opts.createTimeEnd] - 创建时间段结束时间 optional + * @param {integer} [opts.pageNum] - 当前页序号(默认:1) optional + * @param {integer} [opts.pageSize] - 每页结果数量(默认:10) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param pagination pagination 分页信息 + * @param consoleInstanceVoucherVo data + */ + + describeConsoleInstanceVouchers ( + 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 describeConsoleInstanceVouchers" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.voucherType !== undefined && opts.voucherType !== null) { + queryParams['voucherType'] = opts.voucherType + } + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + if (opts.createTimeBegin !== undefined && opts.createTimeBegin !== null) { + queryParams['createTimeBegin'] = opts.createTimeBegin + } + if (opts.createTimeEnd !== undefined && opts.createTimeEnd !== null) { + queryParams['createTimeEnd'] = opts.createTimeEnd + } + if (opts.pageNum !== undefined && opts.pageNum !== null) { + queryParams['pageNum'] = opts.pageNum + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 reservedinstance/0.1.2' + } + + 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 describeConsoleInstanceVouchers 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}/instanceVoucher:describeConsoleInstanceVouchers', + '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 = RESERVEDINSTANCE diff --git a/packages/libs/lib-jdcloud/src/repo/resourcetag/v1/resourcetag.js b/packages/libs/lib-jdcloud/src/repo/resourcetag/v1/resourcetag.js new file mode 100644 index 000000000..04e7e0d62 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/resourcetag/v1/resourcetag.js @@ -0,0 +1,857 @@ +/* + * 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. + * + * Resource-Tag-APIs + * 资源标签接口 + * + * 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 = 'resourcetag' +Service._services[serviceId] = true + +/** + * resourcetag service. + * @version 0.6.0 + */ + +class RESOURCETAG extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'resource-tag.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 获得资源与对应标签列表详情,不含资源名称和可用区。<br/> +注意查询cdn的资源时url中regionId必须指定为cn-all。<br/> +该接口目前不支持分页功能。 + + * @param {Object} opts - parameters + * @param {resourceReqVo} opts.resourceVo - 资源标签参数对象 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param resourceResVo data 资源与对应标签列表详情 + */ + + describeResources (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 describeResources" + ) + } + + opts = opts || {} + + if (opts.resourceVo === undefined || opts.resourceVo === null) { + throw new Error( + "Missing the required parameter 'opts.resourceVo' when calling describeResources" + ) + } + + let postBody = {} + if (opts.resourceVo !== undefined && opts.resourceVo !== null) { + postBody['resourceVo'] = opts.resourceVo + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 resourcetag/0.6.0' + } + + 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 describeResources 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}/tags:describeResources', + '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/> +注意查询cdn资源的标签时url中regionId必须指定为cn-all。<br/> +注意查询不限制地域时url中regionId必须指定为all-region。 + + * @param {Object} opts - parameters + * @param {tagsReqVo} opts.tagKeysVo - 标签参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param tagsResVo data 获取标签结果详情 + */ + + describeTags (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 describeTags" + ) + } + + opts = opts || {} + + if (opts.tagKeysVo === undefined || opts.tagKeysVo === null) { + throw new Error( + "Missing the required parameter 'opts.tagKeysVo' when calling describeTags" + ) + } + + let postBody = {} + if (opts.tagKeysVo !== undefined && opts.tagKeysVo !== null) { + postBody['tagKeysVo'] = opts.tagKeysVo + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 resourcetag/0.6.0' + } + + 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 describeTags 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}/describeTags', + '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 {tagKeysReqVo} opts.tagKeysVo - 标签键参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param tagKeysResVo data 获取标签键结果详情 + */ + + describeKeys (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 describeKeys" + ) + } + + opts = opts || {} + + if (opts.tagKeysVo === undefined || opts.tagKeysVo === null) { + throw new Error( + "Missing the required parameter 'opts.tagKeysVo' when calling describeKeys" + ) + } + + let postBody = {} + if (opts.tagKeysVo !== undefined && opts.tagKeysVo !== null) { + postBody['tagKeysVo'] = opts.tagKeysVo + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 resourcetag/0.6.0' + } + + 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 describeKeys 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}/tags:describeKeys', + '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 {tagValuesReqVo} opts.tagValuesVo - 标签值参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param tagValuesResVo data 获取标签值结果详情 + */ + + describeValues (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 describeValues" + ) + } + + opts = opts || {} + + if (opts.tagValuesVo === undefined || opts.tagValuesVo === null) { + throw new Error( + "Missing the required parameter 'opts.tagValuesVo' when calling describeValues" + ) + } + + let postBody = {} + if (opts.tagValuesVo !== undefined && opts.tagValuesVo !== null) { + postBody['tagValuesVo'] = opts.tagValuesVo + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 resourcetag/0.6.0' + } + + 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 describeValues 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}/tags:describeValues', + '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/> +注意cdn资源绑定标签时url中regionId必须指定为cn-all。 + + * @param {Object} opts - parameters + * @param {tagResourcesReqVo} opts.tagResources - 绑定标签参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param tagResourcesResVo data 资源标签绑定结果详情 + */ + + tagResources (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 tagResources" + ) + } + + opts = opts || {} + + if (opts.tagResources === undefined || opts.tagResources === null) { + throw new Error( + "Missing the required parameter 'opts.tagResources' when calling tagResources" + ) + } + + let postBody = {} + if (opts.tagResources !== undefined && opts.tagResources !== null) { + postBody['tagResources'] = opts.tagResources + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 resourcetag/0.6.0' + } + + 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 tagResources 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}/tags:tagResources', + '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/> +注意cdn资源解绑标签时url中regionId必须指定为cn-all。 + + * @param {Object} opts - parameters + * @param {unTagResourcesReqVo} opts.unTagResources - 解绑标签参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param unTagResourcesResVo data 资源标签解绑结果详情 + */ + + unTagResources (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 unTagResources" + ) + } + + opts = opts || {} + + if (opts.unTagResources === undefined || opts.unTagResources === null) { + throw new Error( + "Missing the required parameter 'opts.unTagResources' when calling unTagResources" + ) + } + + let postBody = {} + if (opts.unTagResources !== undefined && opts.unTagResources !== null) { + postBody['unTagResources'] = opts.unTagResources + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 resourcetag/0.6.0' + } + + 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 unTagResources 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}/tags:unTagResources', + '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/> +若要查找cdn产品线的资源则url中的regionId必须指定为cn-all。 + + * @param {Object} opts - parameters + * @param {queryResourceReqVo} opts.queryResource - 查找资源id的参数对象 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string resourceIds + */ + + queryResource (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 queryResource" + ) + } + + opts = opts || {} + + if (opts.queryResource === undefined || opts.queryResource === null) { + throw new Error( + "Missing the required parameter 'opts.queryResource' when calling queryResource" + ) + } + + let postBody = {} + if (opts.queryResource !== undefined && opts.queryResource !== null) { + postBody['queryResource'] = opts.queryResource + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 resourcetag/0.6.0' + } + + 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 queryResource 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}/queryResource', + '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 = RESOURCETAG diff --git a/packages/libs/lib-jdcloud/src/repo/rms/v1/rms.js b/packages/libs/lib-jdcloud/src/repo/rms/v1/rms.js new file mode 100644 index 000000000..adaf9ec86 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/rms/v1/rms.js @@ -0,0 +1,677 @@ +/* + * 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. + * + * 短信内容接口 + * API related to Template + * + * 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 = 'rms' +Service._services[serviceId] = true + +/** + * rms service. + * @version 1.0.0 + */ + +JDCloud.RMS = class RMS extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'rms.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 指定短信Id群发短信 + * @param {Object} opts - parameters + * @param {sendBatchMsgSpec} opts.sendBatchMsgSpec - 指定短信Id群发短信请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param sendBatchMsg data 指定短信Id群发短信响应参数 + */ + + sendBatchMsg (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 sendBatchMsg" + ) + } + + opts = opts || {} + + if (opts.sendBatchMsgSpec === undefined || opts.sendBatchMsgSpec === null) { + throw new Error( + "Missing the required parameter 'opts.sendBatchMsgSpec' when calling sendBatchMsg" + ) + } + + let postBody = {} + if (opts.sendBatchMsgSpec !== undefined && opts.sendBatchMsgSpec !== null) { + postBody['sendBatchMsgSpec'] = opts.sendBatchMsgSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rms/1.0.0' + } + + 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 sendBatchMsg 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 = this.makeRequest( + '/regions/{regionId}/sendBatchMsg', + '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 {querySendStatusSpec} opts.querySendStatusSpec - 获取发送状态请求参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param querySendStatus data + */ + + querySendStatus (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 querySendStatus" + ) + } + + opts = opts || {} + + if ( + opts.querySendStatusSpec === undefined || + opts.querySendStatusSpec === null + ) { + throw new Error( + "Missing the required parameter 'opts.querySendStatusSpec' when calling querySendStatus" + ) + } + + let postBody = {} + if ( + opts.querySendStatusSpec !== undefined && + opts.querySendStatusSpec !== null + ) { + postBody['querySendStatusSpec'] = opts.querySendStatusSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rms/1.0.0' + } + + 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 querySendStatus 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 = this.makeRequest( + '/regions/{regionId}/querySendStatus', + '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.appId] - appId参数 optional + * @param {string} [opts.signType] - signType参数 optional + * @param {string} [opts.purpose] - purpose参数 optional + * @param {string} [opts.signCardType] - signCardType参数 optional + * @param {string} [opts.aptitudes] - aptitudes参数 optional + * @param {string} [opts.title] - title参数 optional + * @param {string} [opts.description] - description参数 optional + * @param {string} [opts.isTuiding] - isTuiding参数 optional + * @param {array} [opts.content] - content参数 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param respAddTemplateData data + * @param string message message参数 + * @param string status status参数 + */ + + addTemplate (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 addTemplate" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.signType !== undefined && opts.signType !== null) { + postBody['signType'] = opts.signType + } + if (opts.purpose !== undefined && opts.purpose !== null) { + postBody['purpose'] = opts.purpose + } + if (opts.signCardType !== undefined && opts.signCardType !== null) { + postBody['signCardType'] = opts.signCardType + } + if (opts.aptitudes !== undefined && opts.aptitudes !== null) { + postBody['aptitudes'] = opts.aptitudes + } + if (opts.title !== undefined && opts.title !== null) { + postBody['title'] = opts.title + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.isTuiding !== undefined && opts.isTuiding !== null) { + postBody['isTuiding'] = opts.isTuiding + } + if (opts.content !== undefined && opts.content !== null) { + postBody['content'] = opts.content + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rms/1.0.0' + } + + 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 addTemplate 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 = this.makeRequest( + '/regions/{regionId}/addTemplate', + '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.templateId] - templateId参数 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param respQueryOneTemplateResourceList data + * @param string description description参数 + * @param string mediaLength mediaLength参数 + * @param string type type参数 + * @param string title title参数 + * @param string isTuiding isTuiding参数 + * @param string message message参数 + * @param string status status参数 + */ + + queryOneTemplate (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 queryOneTemplate" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.templateId !== undefined && opts.templateId !== null) { + postBody['templateId'] = opts.templateId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rms/1.0.0' + } + + 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 queryOneTemplate 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 = this.makeRequest( + '/regions/{regionId}/queryOneTemplate', + '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.appId] - appId参数 optional + * @param {string} [opts.searchKey] - searchKey参数 optional + * @param {string} [opts.pageNum] - pageNum参数 optional + * @param {string} [opts.pageLimit] - pageLimit参数 optional + * @param {string} [opts.status] - status参数 optional + * @param {string} [opts.title] - title参数 optional + * @param {string} [opts.startTime] - startTime参数 optional + * @param {string} [opts.endTime] - endTime参数 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param respQueryTemplateListData data + * @param string message message参数 + * @param string totalElements totalElements参数 + * @param string status status参数 + */ + + queryTemplateList (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 queryTemplateList" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.searchKey !== undefined && opts.searchKey !== null) { + postBody['searchKey'] = opts.searchKey + } + if (opts.pageNum !== undefined && opts.pageNum !== null) { + postBody['pageNum'] = opts.pageNum + } + if (opts.pageLimit !== undefined && opts.pageLimit !== null) { + postBody['pageLimit'] = opts.pageLimit + } + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + if (opts.title !== undefined && opts.title !== null) { + postBody['title'] = opts.title + } + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rms/1.0.0' + } + + 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 queryTemplateList 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 = this.makeRequest( + '/regions/{regionId}/queryTemplateList', + '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 = JDCloud.RMS diff --git a/packages/libs/lib-jdcloud/src/repo/rms/v2/rms.js b/packages/libs/lib-jdcloud/src/repo/rms/v2/rms.js new file mode 100644 index 000000000..6a402fb01 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/rms/v2/rms.js @@ -0,0 +1,1951 @@ +/* + * 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. + * + * Message-Content-APIs + * 富媒体模板内容创建、查询相关接口 + * + * 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 = 'rms' +Service._services[serviceId] = true + +/** + * rms service. + * @version 1.4.0 + */ + +class RMS extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'rms.jdcloud-api.com' + options.basePath = '/v2' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 增加富媒体短信资质接口 + * @param {Object} opts - parameters + * @param {string} opts.appId - 应用ID + * @param {string} opts.name - 资质名称 + * @param {string} opts.description - 资质描述 + * @param {string} opts.businessLicense - 营业执照图片,必须是jpg图片的base64编码,只支持jpg图片 + * @param {string} opts.businessLicenseName - 营业执照名称 + * @param {string} opts.signedAuthorization - 签名授权书图片,必须是jpg图片的base64编码,只支持jpg图片 + * @param {string} opts.signedAuthorizationName - 签名授权书名称 + * @param {string} opts.informationSecurity - 信息安全保障责任书图片,必须是jpg图片的base64编码,只支持jpg图片 + * @param {string} opts.informationSecurityName - 信息安全保障责任书名称 + * @param {string} opts.membershipCertificate - 会员证明图片,必须是jpg图片的base64编码,只支持jpg图片 + * @param {string} opts.membershipCertificateName - 会员证明名称 + * @param {string} opts.otherCertificate - 其他证明图片,必须是jpg图片的base64编码,只支持jpg图片 + * @param {string} opts.otherCertificateName - 其他证明名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param respCreditData data 资质ID + * @param boolean status 请求状态 + * @param string code 错误码 + * @param string message 错误消息 + */ + + addCredit (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 addCredit" + ) + } + + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling addCredit" + ) + } + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling addCredit" + ) + } + if (opts.description === undefined || opts.description === null) { + throw new Error( + "Missing the required parameter 'opts.description' when calling addCredit" + ) + } + if (opts.businessLicense === undefined || opts.businessLicense === null) { + throw new Error( + "Missing the required parameter 'opts.businessLicense' when calling addCredit" + ) + } + if ( + opts.businessLicenseName === undefined || + opts.businessLicenseName === null + ) { + throw new Error( + "Missing the required parameter 'opts.businessLicenseName' when calling addCredit" + ) + } + if ( + opts.signedAuthorization === undefined || + opts.signedAuthorization === null + ) { + throw new Error( + "Missing the required parameter 'opts.signedAuthorization' when calling addCredit" + ) + } + if ( + opts.signedAuthorizationName === undefined || + opts.signedAuthorizationName === null + ) { + throw new Error( + "Missing the required parameter 'opts.signedAuthorizationName' when calling addCredit" + ) + } + if ( + opts.informationSecurity === undefined || + opts.informationSecurity === null + ) { + throw new Error( + "Missing the required parameter 'opts.informationSecurity' when calling addCredit" + ) + } + if ( + opts.informationSecurityName === undefined || + opts.informationSecurityName === null + ) { + throw new Error( + "Missing the required parameter 'opts.informationSecurityName' when calling addCredit" + ) + } + if ( + opts.membershipCertificate === undefined || + opts.membershipCertificate === null + ) { + throw new Error( + "Missing the required parameter 'opts.membershipCertificate' when calling addCredit" + ) + } + if ( + opts.membershipCertificateName === undefined || + opts.membershipCertificateName === null + ) { + throw new Error( + "Missing the required parameter 'opts.membershipCertificateName' when calling addCredit" + ) + } + if (opts.otherCertificate === undefined || opts.otherCertificate === null) { + throw new Error( + "Missing the required parameter 'opts.otherCertificate' when calling addCredit" + ) + } + if ( + opts.otherCertificateName === undefined || + opts.otherCertificateName === null + ) { + throw new Error( + "Missing the required parameter 'opts.otherCertificateName' when calling addCredit" + ) + } + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.businessLicense !== undefined && opts.businessLicense !== null) { + postBody['businessLicense'] = opts.businessLicense + } + if ( + opts.businessLicenseName !== undefined && + opts.businessLicenseName !== null + ) { + postBody['businessLicenseName'] = opts.businessLicenseName + } + if ( + opts.signedAuthorization !== undefined && + opts.signedAuthorization !== null + ) { + postBody['signedAuthorization'] = opts.signedAuthorization + } + if ( + opts.signedAuthorizationName !== undefined && + opts.signedAuthorizationName !== null + ) { + postBody['signedAuthorizationName'] = opts.signedAuthorizationName + } + if ( + opts.informationSecurity !== undefined && + opts.informationSecurity !== null + ) { + postBody['informationSecurity'] = opts.informationSecurity + } + if ( + opts.informationSecurityName !== undefined && + opts.informationSecurityName !== null + ) { + postBody['informationSecurityName'] = opts.informationSecurityName + } + if ( + opts.membershipCertificate !== undefined && + opts.membershipCertificate !== null + ) { + postBody['membershipCertificate'] = opts.membershipCertificate + } + if ( + opts.membershipCertificateName !== undefined && + opts.membershipCertificateName !== null + ) { + postBody['membershipCertificateName'] = opts.membershipCertificateName + } + if (opts.otherCertificate !== undefined && opts.otherCertificate !== null) { + postBody['otherCertificate'] = opts.otherCertificate + } + if ( + opts.otherCertificateName !== undefined && + opts.otherCertificateName !== null + ) { + postBody['otherCertificateName'] = opts.otherCertificateName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rms/1.4.0' + } + + 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 addCredit 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}/addCredit', + '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.signId - 资质ID + * @param {string} opts.appId - 应用ID + * @param {string} opts.name - 资质名称 + * @param {string} opts.description - 资质描述 + * @param {string} opts.businessLicense - 营业执照图片,必须是jpg图片的base64编码,只支持jpg图片 + * @param {string} opts.businessLicenseName - 营业执照名称 + * @param {string} opts.signedAuthorization - 签名授权书图片,必须是jpg图片的base64编码,只支持jpg图片 + * @param {string} opts.signedAuthorizationName - 签名授权书名称 + * @param {string} opts.informationSecurity - 信息安全保障责任书图片,必须是jpg图片的base64编码,只支持jpg图片 + * @param {string} opts.informationSecurityName - 信息安全保障责任书名称 + * @param {string} opts.membershipCertificate - 会员证明图片,必须是jpg图片的base64编码,只支持jpg图片 + * @param {string} opts.membershipCertificateName - 会员证明名称 + * @param {string} opts.otherCertificate - 其他证明图片,必须是jpg图片的base64编码,只支持jpg图片 + * @param {string} opts.otherCertificateName - 其他证明名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param respCreditData data 资质ID + * @param boolean status 请求状态 + * @param string code 错误码 + * @param string message 错误消息 + */ + + editCredit (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 editCredit" + ) + } + + opts = opts || {} + + if (opts.signId === undefined || opts.signId === null) { + throw new Error( + "Missing the required parameter 'opts.signId' when calling editCredit" + ) + } + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling editCredit" + ) + } + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling editCredit" + ) + } + if (opts.description === undefined || opts.description === null) { + throw new Error( + "Missing the required parameter 'opts.description' when calling editCredit" + ) + } + if (opts.businessLicense === undefined || opts.businessLicense === null) { + throw new Error( + "Missing the required parameter 'opts.businessLicense' when calling editCredit" + ) + } + if ( + opts.businessLicenseName === undefined || + opts.businessLicenseName === null + ) { + throw new Error( + "Missing the required parameter 'opts.businessLicenseName' when calling editCredit" + ) + } + if ( + opts.signedAuthorization === undefined || + opts.signedAuthorization === null + ) { + throw new Error( + "Missing the required parameter 'opts.signedAuthorization' when calling editCredit" + ) + } + if ( + opts.signedAuthorizationName === undefined || + opts.signedAuthorizationName === null + ) { + throw new Error( + "Missing the required parameter 'opts.signedAuthorizationName' when calling editCredit" + ) + } + if ( + opts.informationSecurity === undefined || + opts.informationSecurity === null + ) { + throw new Error( + "Missing the required parameter 'opts.informationSecurity' when calling editCredit" + ) + } + if ( + opts.informationSecurityName === undefined || + opts.informationSecurityName === null + ) { + throw new Error( + "Missing the required parameter 'opts.informationSecurityName' when calling editCredit" + ) + } + if ( + opts.membershipCertificate === undefined || + opts.membershipCertificate === null + ) { + throw new Error( + "Missing the required parameter 'opts.membershipCertificate' when calling editCredit" + ) + } + if ( + opts.membershipCertificateName === undefined || + opts.membershipCertificateName === null + ) { + throw new Error( + "Missing the required parameter 'opts.membershipCertificateName' when calling editCredit" + ) + } + if (opts.otherCertificate === undefined || opts.otherCertificate === null) { + throw new Error( + "Missing the required parameter 'opts.otherCertificate' when calling editCredit" + ) + } + if ( + opts.otherCertificateName === undefined || + opts.otherCertificateName === null + ) { + throw new Error( + "Missing the required parameter 'opts.otherCertificateName' when calling editCredit" + ) + } + + let postBody = {} + if (opts.signId !== undefined && opts.signId !== null) { + postBody['signId'] = opts.signId + } + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.businessLicense !== undefined && opts.businessLicense !== null) { + postBody['businessLicense'] = opts.businessLicense + } + if ( + opts.businessLicenseName !== undefined && + opts.businessLicenseName !== null + ) { + postBody['businessLicenseName'] = opts.businessLicenseName + } + if ( + opts.signedAuthorization !== undefined && + opts.signedAuthorization !== null + ) { + postBody['signedAuthorization'] = opts.signedAuthorization + } + if ( + opts.signedAuthorizationName !== undefined && + opts.signedAuthorizationName !== null + ) { + postBody['signedAuthorizationName'] = opts.signedAuthorizationName + } + if ( + opts.informationSecurity !== undefined && + opts.informationSecurity !== null + ) { + postBody['informationSecurity'] = opts.informationSecurity + } + if ( + opts.informationSecurityName !== undefined && + opts.informationSecurityName !== null + ) { + postBody['informationSecurityName'] = opts.informationSecurityName + } + if ( + opts.membershipCertificate !== undefined && + opts.membershipCertificate !== null + ) { + postBody['membershipCertificate'] = opts.membershipCertificate + } + if ( + opts.membershipCertificateName !== undefined && + opts.membershipCertificateName !== null + ) { + postBody['membershipCertificateName'] = opts.membershipCertificateName + } + if (opts.otherCertificate !== undefined && opts.otherCertificate !== null) { + postBody['otherCertificate'] = opts.otherCertificate + } + if ( + opts.otherCertificateName !== undefined && + opts.otherCertificateName !== null + ) { + postBody['otherCertificateName'] = opts.otherCertificateName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rms/1.4.0' + } + + 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 editCredit 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}/editCredit', + '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.signId - 资质ID + * @param {string} opts.appId - 应用ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param respCreditData data 资质ID + * @param boolean status 请求状态 + * @param string code 错误码 + * @param string message 错误消息 + */ + + deleteCredit (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 deleteCredit" + ) + } + + opts = opts || {} + + if (opts.signId === undefined || opts.signId === null) { + throw new Error( + "Missing the required parameter 'opts.signId' when calling deleteCredit" + ) + } + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling deleteCredit" + ) + } + + let postBody = {} + if (opts.signId !== undefined && opts.signId !== null) { + postBody['signId'] = opts.signId + } + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rms/1.4.0' + } + + 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 deleteCredit 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}/deleteCredit', + '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.appId - 应用ID + * @param {integer} opts.pageNum - 第几页 + * @param {integer} opts.pageSize - 每页多少条记录 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param respCreditPageResult data + * @param boolean status 请求状态 + * @param string code 错误码 + * @param string message 错误消息 + */ + + queryCreditList (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 queryCreditList" + ) + } + + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling queryCreditList" + ) + } + if (opts.pageNum === undefined || opts.pageNum === null) { + throw new Error( + "Missing the required parameter 'opts.pageNum' when calling queryCreditList" + ) + } + if (opts.pageSize === undefined || opts.pageSize === null) { + throw new Error( + "Missing the required parameter 'opts.pageSize' when calling queryCreditList" + ) + } + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.pageNum !== undefined && opts.pageNum !== null) { + postBody['pageNum'] = opts.pageNum + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rms/1.4.0' + } + + 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 queryCreditList 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}/queryCreditList', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param respPackageResult data 响应数据 + * @param boolean status 请求状态 + * @param string code 错误码 + * @param string message 错误消息 + */ + + queryPackageRemainder (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 queryPackageRemainder" + ) + } + + opts = opts || {} + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rms/1.4.0' + } + + 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 queryPackageRemainder 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}/queryPackageRemainder', + '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) + } + ) + } + + /** + * 指定短信Id群发短信 + * @param {Object} opts - parameters + * @param {string} opts.appId - 应用ID + * @param {string} opts.templateId - 短信ID + * @param {array} [opts.phone] - 群发的国内电话号码,群发时一次最多不要超过100个手机号 optional + * @param {array} [opts.params] - 短信模板变量对应的数据值,Array格式 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param sendBatchMsg data 指定短信Id群发短信响应参数 + * @param boolean status 请求状态 + * @param string code 错误码 + * @param string message 错误消息 + */ + + sendBatchMsg (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 sendBatchMsg" + ) + } + + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling sendBatchMsg" + ) + } + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling sendBatchMsg" + ) + } + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.templateId !== undefined && opts.templateId !== null) { + postBody['templateId'] = opts.templateId + } + if (opts.phone !== undefined && opts.phone !== null) { + postBody['phone'] = opts.phone + } + if (opts.params !== undefined && opts.params !== null) { + postBody['params'] = opts.params + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rms/1.4.0' + } + + 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 sendBatchMsg 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}/sendBatchMsg', + '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.appId - 应用ID + * @param {string} opts.sequenceNumber - 序列号 + * @param {string} [opts.phone] - 手机号 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param querySendStatus data + * @param boolean status 请求状态 + * @param string code 错误码 + * @param string message 错误消息 + */ + + querySendStatus (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 querySendStatus" + ) + } + + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling querySendStatus" + ) + } + if (opts.sequenceNumber === undefined || opts.sequenceNumber === null) { + throw new Error( + "Missing the required parameter 'opts.sequenceNumber' when calling querySendStatus" + ) + } + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.sequenceNumber !== undefined && opts.sequenceNumber !== null) { + postBody['sequenceNumber'] = opts.sequenceNumber + } + if (opts.phone !== undefined && opts.phone !== null) { + postBody['phone'] = opts.phone + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rms/1.4.0' + } + + 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 querySendStatus 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}/querySendStatus', + '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.appId - 应用ID + * @param {string} opts.aptitudesId - 资质ID + * @param {string} opts.title - 短信主题 + * @param {string} opts.description - 短信描述 + * @param {string} opts.signContent - 短信签名 + * @param {array} [opts.content] - 短信内容 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param respTemplateData data 短信ID + * @param boolean status 请求状态 + * @param string code 错误码 + * @param string message 错误消息 + */ + + addTemplateNew (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 addTemplateNew" + ) + } + + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling addTemplateNew" + ) + } + if (opts.aptitudesId === undefined || opts.aptitudesId === null) { + throw new Error( + "Missing the required parameter 'opts.aptitudesId' when calling addTemplateNew" + ) + } + if (opts.title === undefined || opts.title === null) { + throw new Error( + "Missing the required parameter 'opts.title' when calling addTemplateNew" + ) + } + if (opts.description === undefined || opts.description === null) { + throw new Error( + "Missing the required parameter 'opts.description' when calling addTemplateNew" + ) + } + if (opts.signContent === undefined || opts.signContent === null) { + throw new Error( + "Missing the required parameter 'opts.signContent' when calling addTemplateNew" + ) + } + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.aptitudesId !== undefined && opts.aptitudesId !== null) { + postBody['aptitudesId'] = opts.aptitudesId + } + if (opts.title !== undefined && opts.title !== null) { + postBody['title'] = opts.title + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.signContent !== undefined && opts.signContent !== null) { + postBody['signContent'] = opts.signContent + } + if (opts.content !== undefined && opts.content !== null) { + postBody['content'] = opts.content + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rms/1.4.0' + } + + 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 addTemplateNew 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}/addTemplateNew', + '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.templateId - 模板ID + * @param {string} opts.appId - 应用ID + * @param {string} opts.aptitudesId - 资质ID + * @param {string} opts.title - 短信主题 + * @param {string} opts.description - 短信描述 + * @param {string} opts.signContent - 短信签名 + * @param {array} [opts.content] - 短信内容 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param respTemplateData data 短信ID + * @param boolean status 请求状态 + * @param string code 错误码 + * @param string message 错误消息 + */ + + editTemplate (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 editTemplate" + ) + } + + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling editTemplate" + ) + } + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling editTemplate" + ) + } + if (opts.aptitudesId === undefined || opts.aptitudesId === null) { + throw new Error( + "Missing the required parameter 'opts.aptitudesId' when calling editTemplate" + ) + } + if (opts.title === undefined || opts.title === null) { + throw new Error( + "Missing the required parameter 'opts.title' when calling editTemplate" + ) + } + if (opts.description === undefined || opts.description === null) { + throw new Error( + "Missing the required parameter 'opts.description' when calling editTemplate" + ) + } + if (opts.signContent === undefined || opts.signContent === null) { + throw new Error( + "Missing the required parameter 'opts.signContent' when calling editTemplate" + ) + } + + let postBody = {} + if (opts.templateId !== undefined && opts.templateId !== null) { + postBody['templateId'] = opts.templateId + } + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.aptitudesId !== undefined && opts.aptitudesId !== null) { + postBody['aptitudesId'] = opts.aptitudesId + } + if (opts.title !== undefined && opts.title !== null) { + postBody['title'] = opts.title + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.signContent !== undefined && opts.signContent !== null) { + postBody['signContent'] = opts.signContent + } + if (opts.content !== undefined && opts.content !== null) { + postBody['content'] = opts.content + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rms/1.4.0' + } + + 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 editTemplate 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}/editTemplate', + '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.templateId - 模板ID + * @param {string} opts.appId - 应用ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param respTemplateData data 短信ID + * @param boolean status 请求状态 + * @param string code 错误码 + * @param string message 错误消息 + */ + + deleteTemplate (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 deleteTemplate" + ) + } + + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling deleteTemplate" + ) + } + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling deleteTemplate" + ) + } + + let postBody = {} + if (opts.templateId !== undefined && opts.templateId !== null) { + postBody['templateId'] = opts.templateId + } + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rms/1.4.0' + } + + 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 deleteTemplate 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}/deleteTemplate', + '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.templateId - 短信ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param respQueryTemplateListData data 响应数据 + * @param boolean status 请求状态 + * @param string code 错误码 + * @param string message 错误消息 + */ + + queryTemplateById (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 queryTemplateById" + ) + } + + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling queryTemplateById" + ) + } + + let postBody = {} + if (opts.templateId !== undefined && opts.templateId !== null) { + postBody['templateId'] = opts.templateId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rms/1.4.0' + } + + 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 queryTemplateById 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}/queryTemplateById', + '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.appId - 应用ID + * @param {string} [opts.title] - 查询标题关键词 optional + * @param {integer} opts.pageNum - 第几页 + * @param {integer} opts.pageLimit - 每页多少条记录 + * @param {string} [opts.status] - 审核状态:0: 审核中 1: 通过 2: 未通过 4:待提交 optional + * @param {string} [opts.startTime] - 开始时间,格式YYYY-MM-DD optional + * @param {string} [opts.endTime] - 结束时间,格式YYYY-MM-DD optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param respTemplatePageResult data + * @param boolean status 请求状态 + * @param string code 错误码 + * @param string message 错误消息 + */ + + queryTemplateList (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 queryTemplateList" + ) + } + + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling queryTemplateList" + ) + } + if (opts.pageNum === undefined || opts.pageNum === null) { + throw new Error( + "Missing the required parameter 'opts.pageNum' when calling queryTemplateList" + ) + } + if (opts.pageLimit === undefined || opts.pageLimit === null) { + throw new Error( + "Missing the required parameter 'opts.pageLimit' when calling queryTemplateList" + ) + } + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.title !== undefined && opts.title !== null) { + postBody['title'] = opts.title + } + if (opts.pageNum !== undefined && opts.pageNum !== null) { + postBody['pageNum'] = opts.pageNum + } + if (opts.pageLimit !== undefined && opts.pageLimit !== null) { + postBody['pageLimit'] = opts.pageLimit + } + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + if (opts.startTime !== undefined && opts.startTime !== null) { + postBody['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + postBody['endTime'] = opts.endTime + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 rms/1.4.0' + } + + 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 queryTemplateList 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}/queryTemplateList', + '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 = RMS diff --git a/packages/libs/lib-jdcloud/src/repo/smartdba/v2/smartdba.js b/packages/libs/lib-jdcloud/src/repo/smartdba/v2/smartdba.js new file mode 100644 index 000000000..856d2ffa6 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/smartdba/v2/smartdba.js @@ -0,0 +1,6730 @@ +/* + * 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. + * + * Table-Check + * 表诊断相关接口 + * + * 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 = 'smartdba' +Service._services[serviceId] = true + +/** + * smartdba service. + * @version 2.0.1 + */ + +class SMARTDBA extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'smartdba.jdcloud-api.com' + options.basePath = '/v2' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 近一小时告警列表,按级别倒序 + * @param {Object} opts - parameters + * @param {integer} [opts.pageIndex] - 显示数据的页码,默认为1,取值范围:[-1,∞) optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10 optional + * @param {string} [opts.dbType] - 数据库类型,默认MySQL optional + * @param {string} opts.endTime - null + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param alarmDetail data + * @param integer totalCount 总数 + */ + + describeAlarmResource (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 describeAlarmResource" + ) + } + + opts = opts || {} + + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeAlarmResource" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.dbType !== undefined && opts.dbType !== null) { + queryParams['dbType'] = opts.dbType + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeAlarmResource 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}/describeAlarmResource', + '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.pageIndex] - 显示数据的页码,默认为1,取值范围:[-1,∞) optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10 optional + * @param {string} opts.startTime - 查询开始时间,格式为:2021-11-11T15:04:05Z + * @param {string} opts.endTime - 查询截止时间,格式为:2021-11-11T15:04:05Z + * @param {string} [opts.dbType] - 数据库类型,默认MySQL optional + * @param {string} [opts.instanceGid] - 实例Id optional + * @param {string} [opts.instanceName] - 实例名称 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param alarmHistoryDetail data + * @param integer totalCount 总数 + */ + + describeAlarmHistory (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 describeAlarmHistory" + ) + } + + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeAlarmHistory" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeAlarmHistory" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.dbType !== undefined && opts.dbType !== null) { + queryParams['dbType'] = opts.dbType + } + if (opts.instanceGid !== undefined && opts.instanceGid !== null) { + queryParams['instanceGid'] = opts.instanceGid + } + if (opts.instanceName !== undefined && opts.instanceName !== null) { + queryParams['instanceName'] = opts.instanceName + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeAlarmHistory 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}/describeAlarmHistory', + '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) + } + ) + } + + /** + * 最近3小时,24小时,3天报警数量 + * @param {Object} opts - parameters + * @param {string} opts.endTime - 查询时间,格式为:2021-11-11T15:04:05Z + * @param {string} [opts.dbType] - 数据库类型,默认MySQL optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer count3h 最近3小时告警数量 + * @param integer count24h 最近24小时告警数量 + * @param integer count72h 最近72小时告警数量 + */ + + describeAlarmStatistic (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 describeAlarmStatistic" + ) + } + + opts = opts || {} + + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeAlarmStatistic" + ) + } + + let postBody = null + let queryParams = {} + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.dbType !== undefined && opts.dbType !== null) { + queryParams['dbType'] = opts.dbType + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeAlarmStatistic 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}/alarmStatistic', + '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) + } + ) + } + + /** + * 最近3小时,24小时,3天慢sql情况 + * @param {Object} opts - parameters + * @param {string} opts.endTime - 查询时间,格式为:2021-11-11T15:04:05Z + * @param {string} [opts.dbType] - 数据库类型,默认MySQL optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer count3h 最近3小时慢sql数量 + * @param integer count24h 最近24小时慢sql数量 + * @param integer count72h 最近72小时慢sql数量 + */ + + describeslowLogStatistic (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 describeslowLogStatistic" + ) + } + + opts = opts || {} + + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeslowLogStatistic" + ) + } + + let postBody = null + let queryParams = {} + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.dbType !== undefined && opts.dbType !== null) { + queryParams['dbType'] = opts.dbType + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeslowLogStatistic 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}/slowLogStatistic', + '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.startTime - 查询起始时间,格式为:2021-11-11T15:04:05Z + * @param {string} opts.endTime - 查询截止时间,格式为:2021-11-11T15:04:05Z + * @param {string} [opts.dbType] - 数据库类型,默认MySQL optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dataPoint itemData + * @param metric metricInfo metric元信息 + */ + + describeAlarmTrend (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 describeAlarmTrend" + ) + } + + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeAlarmTrend" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeAlarmTrend" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.dbType !== undefined && opts.dbType !== null) { + queryParams['dbType'] = opts.dbType + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeAlarmTrend 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}/alarmTrend', + '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) + } + ) + } + + /** + * 最近5分钟(或历史某点5分钟),top5的资源 + * @param {Object} opts - parameters + * @param {string} opts.metric - 监控指标 + * @param {string} opts.endTime - 查询时间,格式为:2021-11-11T15:04:05Z + * @param {string} [opts.dbType] - 数据库类型,默认MySQL optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param metricResourceModel data + */ + + getTopResourceByMetric (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 getTopResourceByMetric" + ) + } + + opts = opts || {} + + if (opts.metric === undefined || opts.metric === null) { + throw new Error( + "Missing the required parameter 'opts.metric' when calling getTopResourceByMetric" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling getTopResourceByMetric" + ) + } + + let postBody = null + let queryParams = {} + if (opts.metric !== undefined && opts.metric !== null) { + queryParams['metric'] = opts.metric + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.dbType !== undefined && opts.dbType !== null) { + queryParams['dbType'] = opts.dbType + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 getTopResourceByMetric 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}/getTopResource', + '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) + } + ) + } + + /** + * 获取一键诊断分数最低的top5 + * @param {Object} opts - parameters + * @param {string} opts.endTime - 查询时间,格式为:2021-11-11T15:04:05Z + * @param {string} [opts.dbType] - 数据库类型,默认MySQL optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param inspectTopResource data + */ + + describeDiagnoseTopResource (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 describeDiagnoseTopResource" + ) + } + + opts = opts || {} + + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeDiagnoseTopResource" + ) + } + + let postBody = null + let queryParams = {} + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.dbType !== undefined && opts.dbType !== null) { + queryParams['dbType'] = opts.dbType + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeDiagnoseTopResource 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}/diagnoseTopResource', + '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.instanceGid - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} opts.endTime - 查询时间,格式为:2021-11-11T15:04:05Z + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dataPoint data + */ + + describeDiagnoseTrend (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 describeDiagnoseTrend" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling describeDiagnoseTrend" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeDiagnoseTrend" + ) + } + + let postBody = null + let queryParams = {} + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeDiagnoseTrend 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}/instance/{instanceGid}/diagnoseTrend', + '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.instanceGid - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string taskId 巡检任务id + */ + + createDiagnose (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 createDiagnose" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling createDiagnose" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 createDiagnose 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}/instance/{instanceGid}/diagnose', + '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.instanceGid - RDS 实例ID,唯一标识一个RDS实例 + * @param {integer} [opts.pageIndex] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageIndex 为-1时,返回所有数据页码; optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[1,100],用于查询列表的接口 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount 总数 + * @param diagnoseDetail data + */ + + describeDiagnoseList (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 describeDiagnoseList" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling describeDiagnoseList" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeDiagnoseList 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}/instance/{instanceGid}/diagnoses', + '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.instanceGid - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} opts.diagnoseId - 诊断任务id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string status 巡检状态描述,取值 complete 或者 fail。如遇到云监控或者RDS服务异常,会出现fail。可提示用户诊断失败,请稍后重试。 + * @param diagnoseDetail data + */ + + describeDiagnose (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 describeDiagnose" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling describeDiagnose" + ) + } + if (opts.diagnoseId === undefined || opts.diagnoseId === null) { + throw new Error( + "Missing the required parameter 'opts.diagnoseId' when calling describeDiagnose" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid, + diagnoseId: opts.diagnoseId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeDiagnose 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}/instance/{instanceGid}/diagnoses/{diagnoseId}', + '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.startTime - 查询开始时间,格式为:2006-01-02T15:04:05Z + * @param {string} opts.endTime - 查询截止时间,格式为:2006-01-02T15:04:05Z + * @param {integer} [opts.pageIndex] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageIndex 为-1时,返回所有数据页码; optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[1,100],用于查询列表的接口 optional + * @param {string} [opts.instanceGid] - 实例id optional + * @param {string} [opts.instanceName] - 实例名称 optional + * @param {string} [opts.dbType] - 实例类型 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount 总数 + * @param inspectTaskModel data + */ + + describeInspectList (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 describeInspectList" + ) + } + + opts = opts || {} + + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeInspectList" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeInspectList" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.instanceGid !== undefined && opts.instanceGid !== null) { + queryParams['instanceGid'] = opts.instanceGid + } + if (opts.instanceName !== undefined && opts.instanceName !== null) { + queryParams['instanceName'] = opts.instanceName + } + if (opts.dbType !== undefined && opts.dbType !== null) { + queryParams['dbType'] = opts.dbType + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeInspectList 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}/inspects', + '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.instanceGid - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} opts.inspectId - 巡检任务id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer score 巡检分值 + * @param string beginTime 巡检范围的起始时间,如:2021-11-09T00:00:00Z + * @param string endTime 巡检范围的截至时间,如:2021-11-09T23:59:59Z + * @param systemView systemView 资源使用率 + * @param connectView connectView 连接数 + * @param engineView engineView 锁信息 + * @param schemaView schemaView 库表空间 + * @param diskView diskView 磁盘空间 + * @param slowLowView slowLowView 慢sql + * @param kV detail + */ + + describeInspect (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 describeInspect" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling describeInspect" + ) + } + if (opts.inspectId === undefined || opts.inspectId === null) { + throw new Error( + "Missing the required parameter 'opts.inspectId' when calling describeInspect" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid, + inspectId: opts.inspectId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeInspect 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}/instance/{instanceGid}/inspects/{inspectId}', + '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) + } + ) + } + + /** + * 获取待接入的mysql实例 + * @param {Object} opts - parameters + * @param {string} [opts.dbType] - 实例类型,支持MySQL/Percona,默认MySQL optional + * @param {integer} [opts.pageIndex] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageIndex 为-1时,返回所有数据页码; optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[1,100],用于查询列表的接口 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount 总数 + * @param instancesInfo data + */ + + toBeConnectClusters (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 toBeConnectClusters" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.dbType !== undefined && opts.dbType !== null) { + queryParams['dbType'] = opts.dbType + } + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 toBeConnectClusters 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}/waitcutin', + '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) + } + ) + } + + /** + * 获取已接入mysql实例列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageIndex] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageIndex 为-1时,返回所有数据页码; optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[1,100],用于查询列表的接口 optional + * @param {string} [opts.gid] - 实例gid optional + * @param {string} [opts.instanceName] - 实例名称 optional + * @param {string} [opts.dbSource] - 接入来源 optional + * @param {string} [opts.status] - 实例状态 optional + * @param {string} [opts.dbType] - 实例类型,默认MySQL optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount 总数 + * @param integer checkOkCount 连接正常数 + * @param integer checkFailCount 连接异常数 + * @param instancesInfo data + */ + + describeClusterList (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 describeClusterList" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.gid !== undefined && opts.gid !== null) { + queryParams['gid'] = opts.gid + } + if (opts.instanceName !== undefined && opts.instanceName !== null) { + queryParams['instanceName'] = opts.instanceName + } + if (opts.dbSource !== undefined && opts.dbSource !== null) { + queryParams['dbSource'] = opts.dbSource + } + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + if (opts.dbType !== undefined && opts.dbType !== null) { + queryParams['dbType'] = opts.dbType + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeClusterList 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}/hadcutin', + '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) + } + ) + } + + /** + * 新接入mysql实例 + * @param {Object} opts - parameters + * @param {array} opts.gidList - 待接入实例gid列表 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount 总数 + * @param instancesInfo data + */ + + createCluster (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 createCluster" + ) + } + + opts = opts || {} + + if (opts.gidList === undefined || opts.gidList === null) { + throw new Error( + "Missing the required parameter 'opts.gidList' when calling createCluster" + ) + } + + let postBody = {} + if (opts.gidList !== undefined && opts.gidList !== null) { + postBody['gidList'] = opts.gidList + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 createCluster 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}/newcutin', + '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 {array} opts.gidList - 取消的实例gid列表 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount 总数 + * @param instancesInfo data + */ + + cancleConnect (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 cancleConnect" + ) + } + + opts = opts || {} + + if (opts.gidList === undefined || opts.gidList === null) { + throw new Error( + "Missing the required parameter 'opts.gidList' when calling cancleConnect" + ) + } + + let postBody = {} + if (opts.gidList !== undefined && opts.gidList !== null) { + postBody['gidList'] = opts.gidList + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 cancleConnect 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}/cancelinstance', + '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.instanceGid - RDS 实例ID,唯一标识一个RDS实例。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param clusterDetail data + */ + + describeClusterDetail (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 describeClusterDetail" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling describeClusterDetail" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeClusterDetail 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}/instance/{instanceGid}/describeClusterDetail', + '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.instanceGid - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} opts.analyseId - 锁诊断Id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string analyseId 锁诊断记录Id + * @param string occurTime 锁发生时间 + * @param string deadLockLog 死锁日志详情 + * @param deadLockDetail data + */ + + describeLockAnalyse (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 describeLockAnalyse" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling describeLockAnalyse" + ) + } + if (opts.analyseId === undefined || opts.analyseId === null) { + throw new Error( + "Missing the required parameter 'opts.analyseId' when calling describeLockAnalyse" + ) + } + + let postBody = null + let queryParams = {} + if (opts.analyseId !== undefined && opts.analyseId !== null) { + queryParams['analyseId'] = opts.analyseId + } + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeLockAnalyse 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}/instance/{instanceGid}/lockAnalyse', + '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.instanceGid - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string analyseId 锁诊断id + * @param string state 诊断完成状态:complete\fail + * @param string message 状态说明信息 + */ + + createLockAnalyse (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 createLockAnalyse" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling createLockAnalyse" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 createLockAnalyse 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}/instance/{instanceGid}/lockAnalyse', + '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.instanceGid - RDS 实例ID,唯一标识一个RDS实例 + * @param {integer} [opts.pageIndex] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageIndex 为-1时,返回所有数据页码 optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[1,100],用于查询列表的接口 optional + * @param {string} opts.startTime - 查询开始时间,格式为:2006-01-02T15:04:05Z + * @param {string} opts.endTime - 查询截止时间,格式为:2006-01-02T15:04:05Z + * @param {boolean} [opts.state] - 是否只过滤死锁存在的记录 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount 总数 + * @param deadLockOverview data + */ + + describeAnalyseList (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 describeAnalyseList" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling describeAnalyseList" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeAnalyseList" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeAnalyseList" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.state !== undefined && opts.state !== null) { + queryParams['state'] = opts.state + } + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeAnalyseList 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}/instance/{instanceGid}/analyseList', + '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 {} [opts.name] - 监控大盘名称,最长32位 optional + * @param {} [opts.dbType] - 数据库类型,默认MySQL optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string name 监控大盘名称 + * @param string panelGid 监控大盘id + */ + + createPanel (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 createPanel" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.dbType !== undefined && opts.dbType !== null) { + postBody['dbType'] = opts.dbType + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 createPanel 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}/panel', + '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.dbType] - 数据库类型,默认MySQL optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param panel data + */ + + describePanelList (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 describePanelList" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.dbType !== undefined && opts.dbType !== null) { + queryParams['dbType'] = opts.dbType + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describePanelList 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}/panels', + '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.panelGid - 监控大盘id + * @param {string} [opts.dbType] - 数据库类型,默认MySQL optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param panelClusterItem data + */ + + getPanelRelateClusters (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 getPanelRelateClusters" + ) + } + + opts = opts || {} + + if (opts.panelGid === undefined || opts.panelGid === null) { + throw new Error( + "Missing the required parameter 'opts.panelGid' when calling getPanelRelateClusters" + ) + } + + let postBody = null + let queryParams = {} + if (opts.dbType !== undefined && opts.dbType !== null) { + queryParams['dbType'] = opts.dbType + } + + let pathParams = { + regionId: regionId, + panelGid: opts.panelGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 getPanelRelateClusters 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}/panels/{panelGid}', + '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.panelGid - 监控大盘id + * @param {} [opts.instanceIdList] optional + * @param {} [opts.dbType] - 数据库类型,默认MySQL optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updatePanelClusters (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 updatePanelClusters" + ) + } + + opts = opts || {} + + if (opts.panelGid === undefined || opts.panelGid === null) { + throw new Error( + "Missing the required parameter 'opts.panelGid' when calling updatePanelClusters" + ) + } + + let postBody = {} + if (opts.instanceIdList !== undefined && opts.instanceIdList !== null) { + postBody['instanceIdList'] = opts.instanceIdList + } + if (opts.dbType !== undefined && opts.dbType !== null) { + postBody['dbType'] = opts.dbType + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + panelGid: opts.panelGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 updatePanelClusters 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}/panels/{panelGid}', + '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.panelGid - 监控大盘id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deletePanel (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 deletePanel" + ) + } + + opts = opts || {} + + if (opts.panelGid === undefined || opts.panelGid === null) { + throw new Error( + "Missing the required parameter 'opts.panelGid' when calling deletePanel" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + panelGid: opts.panelGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 deletePanel 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}/panels/{panelGid}', + '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.panelGid - 监控大盘id + * @param {string} opts.metric - 监控指标,如: tps、qps 等,在supportMetrics接口有返回 + * @param {string} opts.startTime - 查询起始时间,格式为:2021-11-11T15:04:05Z + * @param {string} opts.endTime - 查询截止时间,格式为:2021-11-11T15:04:05Z + * @param {string} [opts.dbType] - 数据库类型,默认MySQL optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param metricData metricDatas + */ + + describePanelMetricValueByGid ( + 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 describePanelMetricValueByGid" + ) + } + + opts = opts || {} + + if (opts.panelGid === undefined || opts.panelGid === null) { + throw new Error( + "Missing the required parameter 'opts.panelGid' when calling describePanelMetricValueByGid" + ) + } + if (opts.metric === undefined || opts.metric === null) { + throw new Error( + "Missing the required parameter 'opts.metric' when calling describePanelMetricValueByGid" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describePanelMetricValueByGid" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describePanelMetricValueByGid" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.dbType !== undefined && opts.dbType !== null) { + queryParams['dbType'] = opts.dbType + } + + let pathParams = { + regionId: regionId, + panelGid: opts.panelGid, + metric: opts.metric + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describePanelMetricValueByGid 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}/panels/{panelGid}/metric/{metric}', + '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.panelType - 展示类型,取值为: real_time 表示实时监控页面支持的自定义类型, monitor 表示性能趋势页面支持的类型, market 表示监控大盘 + * @param {string} opts.dbType - 数据库库类型,目前只支持MySQL + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param supportMetric sys + * @param supportMetric server + */ + + describeSupportMetrics (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 describeSupportMetrics" + ) + } + + opts = opts || {} + + if (opts.panelType === undefined || opts.panelType === null) { + throw new Error( + "Missing the required parameter 'opts.panelType' when calling describeSupportMetrics" + ) + } + if (opts.dbType === undefined || opts.dbType === null) { + throw new Error( + "Missing the required parameter 'opts.dbType' when calling describeSupportMetrics" + ) + } + + let postBody = null + let queryParams = {} + if (opts.panelType !== undefined && opts.panelType !== null) { + queryParams['panelType'] = opts.panelType + } + if (opts.dbType !== undefined && opts.dbType !== null) { + queryParams['dbType'] = opts.dbType + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeSupportMetrics 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}/supportMetrics', + '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.gid - panelType为real_time/monitor时,代表实例Id, panelType为market时,代表大盘 panelGid + * @param {string} opts.panelType - 展示类型,取值为: real_time 表示实时监控页面支持的自定义类型, monitor 表示性能趋势页面支持的类型 + * @param {string} opts.dbType - 数据库库类型,目前只支持MySQL + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param supportMetric sys + * @param supportMetric server + */ + + getBindMetrics (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 getBindMetrics" + ) + } + + opts = opts || {} + + if (opts.gid === undefined || opts.gid === null) { + throw new Error( + "Missing the required parameter 'opts.gid' when calling getBindMetrics" + ) + } + if (opts.panelType === undefined || opts.panelType === null) { + throw new Error( + "Missing the required parameter 'opts.panelType' when calling getBindMetrics" + ) + } + if (opts.dbType === undefined || opts.dbType === null) { + throw new Error( + "Missing the required parameter 'opts.dbType' when calling getBindMetrics" + ) + } + + let postBody = null + let queryParams = {} + if (opts.panelType !== undefined && opts.panelType !== null) { + queryParams['panelType'] = opts.panelType + } + if (opts.dbType !== undefined && opts.dbType !== null) { + queryParams['dbType'] = opts.dbType + } + + let pathParams = { + regionId: regionId, + gid: opts.gid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 getBindMetrics 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}/instance/{gid}/getBindMetrics', + '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 {} [opts.metricIds] - 自定义的监控项id数组 optional + * @param {} [opts.panelType] - 展示类型,取值为: real_time 表示实时监控页面, monitor 表示性能趋势页面 market 表示监控大盘 optional + * @param {} [opts.gid] - RDS 实例ID,唯一标识一个RDS实例。如果全部实例生效,可以传all optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + bindMetrics (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 bindMetrics" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.metricIds !== undefined && opts.metricIds !== null) { + postBody['metricIds'] = opts.metricIds + } + if (opts.panelType !== undefined && opts.panelType !== null) { + postBody['panelType'] = opts.panelType + } + if (opts.gid !== undefined && opts.gid !== null) { + postBody['gid'] = opts.gid + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 bindMetrics 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}/bindMetrics', + '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.instanceGid - RDS 实例ID,唯一标识一个RDS实例。 + * @param {string} opts.metric - metric名称 + * @param {string} opts.startTime - 查询开始时间,格式为:2006-01-02T15:04:05Z + * @param {string} opts.endTime - 查询截止时间,格式为:2006-01-02T15:04:05Z + * @param {string} [opts.role] - 实例角色,默认master optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dataPoint itemData + * @param metric metricInfo metric元信息 + */ + + describeMetricValueByGid (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 describeMetricValueByGid" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling describeMetricValueByGid" + ) + } + if (opts.metric === undefined || opts.metric === null) { + throw new Error( + "Missing the required parameter 'opts.metric' when calling describeMetricValueByGid" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeMetricValueByGid" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeMetricValueByGid" + ) + } + + let postBody = null + let queryParams = {} + if (opts.metric !== undefined && opts.metric !== null) { + queryParams['metric'] = opts.metric + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.role !== undefined && opts.role !== null) { + queryParams['role'] = opts.role + } + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeMetricValueByGid 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}/instance/{instanceGid}/metrics', + '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.instanceGid - RDS 实例ID,唯一标识一个RDS实例。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer upTime 实例已运行时间,单位:s + * @param integer activeSession 运行中会话总数 + * @param integer maxActiveTime 运行中会话最长时间 + * @param integer waitSession 存在事务等待的会话 + * @param integer totalSession 会话总数 + * @param integer systemsSession DMS(系统)会话总数 + * @param integer totalCount 总数 + * @param session sessions 实时会话明细 + * @param userStatistic userStatistics 按用户统计 + * @param hostStatistic hostStatistics 按访问来源统计 + * @param dBStatistic dbStatistics 按数据库统计 + */ + + describeSessions (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 describeSessions" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling describeSessions" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeSessions 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}/instance/{instanceGid}/describeSessions', + '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.instanceGid - RDS 实例ID,唯一标识一个RDS实例。 + * @param {integer} [opts.pageIndex] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageIndex 为-1时,返回所有数据页码; optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[1,100],用于查询列表的接口 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount 总数 + * @param nowSession data 实时会话 + */ + + describeNowSessions (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 describeNowSessions" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling describeNowSessions" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeNowSessions 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}/instance/{instanceGid}/describeNowSessions', + '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.instanceGid - RDS 实例ID,唯一标识一个RDS实例。 + * @param {integer} [opts.pageIndex] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageIndex 为-1时,返回所有数据页码; optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[1,100],用于查询列表的接口 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount 总数 + * @param lockStatistic data 事务锁 + */ + + describeTrxLocks (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 describeTrxLocks" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling describeTrxLocks" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeTrxLocks 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}/instance/{instanceGid}/describeTrxLocks', + '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.instanceGid - RDS 实例ID,唯一标识一个RDS实例。 + * @param {integer} [opts.pageIndex] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageIndex 为-1时,返回所有数据页码; optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[1,100],用于查询列表的接口 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount 总数 + * @param untrxLock data 非事务锁 + */ + + describeUntrxLocks (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 describeUntrxLocks" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling describeUntrxLocks" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeUntrxLocks 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}/instance/{instanceGid}/describeUntrxLocks', + '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.instanceGid - RDS 实例ID,唯一标识一个RDS实例。 + * @param {integer} [opts.pageIndex] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageIndex 为-1时,返回所有数据页码; optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[1,100],用于查询列表的接口 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount 总数 + * @param unCommitTrx data 未提交事务 + */ + + describeUnCommitTrxs (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 describeUnCommitTrxs" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling describeUnCommitTrxs" + ) + } + + let postBody = null + let queryParams = {} + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeUnCommitTrxs 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}/instance/{instanceGid}/describeUnCommitTrxs', + '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) + } + ) + } + + /** + * kill当前实例指定的会话 + * @param {Object} opts - parameters + * @param {string} opts.instanceGid - RDS 实例ID,唯一标识一个RDS实例。 + * @param {} [opts.sessionId] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + killSession (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 killSession" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling killSession" + ) + } + + let postBody = {} + if (opts.sessionId !== undefined && opts.sessionId !== null) { + postBody['sessionId'] = opts.sessionId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 killSession 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}/instance/{instanceGid}/killSession', + '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) + } + ) + } + + /** + * 获取当前实例指定时间的慢SQL明细 + * @param {Object} opts - parameters + * @param {string} opts.instanceGid - 实例ID + * @param {string} opts.startTime - 查询开始时间,格式为:2006-01-02T15:04:05Z + * @param {string} opts.endTime - 查询截止时间,格式为:2006-01-02T15:04:05Z + * @param {string} [opts.dbName] - 过滤条件:数据库名 optional + * @param {string} [opts.userName] - 过滤条件:client 用户名 optional + * @param {string} [opts.clientIP] - 过滤条件:client IP optional + * @param {string} [opts.keyword4Search] - 模糊查询关键字,只支持单个单词 optional + * @param {string} [opts.field] - 排序的字段,支持 execTime,lockTime,rowsExamined,rowsSent,startTime 默认是 startTime optional + * @param {string} [opts.sort] - 排序方式,默认desc optional + * @param {integer} [opts.pageIndex] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageIndex 为-1时,返回所有数据页码; optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[1,100],用于查询列表的接口 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param slowLog data + * @param integer totalCount 总数 + */ + + describeSlowLog (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 describeSlowLog" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling describeSlowLog" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeSlowLog" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeSlowLog" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.dbName !== undefined && opts.dbName !== null) { + queryParams['dbName'] = opts.dbName + } + if (opts.userName !== undefined && opts.userName !== null) { + queryParams['userName'] = opts.userName + } + if (opts.clientIP !== undefined && opts.clientIP !== null) { + queryParams['clientIP'] = opts.clientIP + } + if (opts.keyword4Search !== undefined && opts.keyword4Search !== null) { + queryParams['keyword4Search'] = opts.keyword4Search + } + if (opts.field !== undefined && opts.field !== null) { + queryParams['field'] = opts.field + } + if (opts.sort !== undefined && opts.sort !== null) { + queryParams['sort'] = opts.sort + } + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeSlowLog 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}/instance/{instanceGid}/slowLog', + '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) + } + ) + } + + /** + * 获取当前实例指定时间的慢SQL统计 + * @param {Object} opts - parameters + * @param {string} opts.instanceGid - 实例ID + * @param {string} opts.startTime - 查询开始时间,格式为:2006-01-02T15:04:05Z + * @param {string} opts.endTime - 查询截止时间,格式为:2006-01-02T15:04:05Z + * @param {string} [opts.dbName] - 过滤条件:数据库名 optional + * @param {string} [opts.userName] - 过滤条件:client 用户名 optional + * @param {string} [opts.clientIP] - 过滤条件:client IP optional + * @param {string} [opts.keyword4Search] - 模糊查询关键字,只支持单个单词 optional + * @param {string} [opts.sort] - 按queryCount的排序方式,默认desc optional + * @param {integer} [opts.pageIndex] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageIndex 为-1时,返回所有数据页码; optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[1,100],用于查询列表的接口 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param slowDigestLog data + * @param integer totalCount 总数 + */ + + describeSlowDigestLog (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 describeSlowDigestLog" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling describeSlowDigestLog" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeSlowDigestLog" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeSlowDigestLog" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.dbName !== undefined && opts.dbName !== null) { + queryParams['dbName'] = opts.dbName + } + if (opts.userName !== undefined && opts.userName !== null) { + queryParams['userName'] = opts.userName + } + if (opts.clientIP !== undefined && opts.clientIP !== null) { + queryParams['clientIP'] = opts.clientIP + } + if (opts.keyword4Search !== undefined && opts.keyword4Search !== null) { + queryParams['keyword4Search'] = opts.keyword4Search + } + if (opts.sort !== undefined && opts.sort !== null) { + queryParams['sort'] = opts.sort + } + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeSlowDigestLog 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}/instance/{instanceGid}/slowDigestLog', + '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) + } + ) + } + + /** + * 获取实例时间范围内按 dbName、userName、clientIP 分组统计的慢sql条数信息 + * @param {Object} opts - parameters + * @param {string} opts.instanceGid - 实例ID + * @param {string} opts.startTime - 查询开始时间,格式为:2021-11-12T15:04:05Z + * @param {string} opts.endTime - 查询截止时间,格式为:2021-11-11T15:04:05Z + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param object dbName 数据库名信息 + * @param object userName 访问的用户名信息 + * @param object clientIP 客户端IP信息 + */ + + describeSlowLogDimensionsStatistic ( + 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 describeSlowLogDimensionsStatistic" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling describeSlowLogDimensionsStatistic" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeSlowLogDimensionsStatistic" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeSlowLogDimensionsStatistic" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeSlowLogDimensionsStatistic 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}/instance/{instanceGid}/SlowLogDimensionsStatistic', + '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) + } + ) + } + + /** + * SQL explain执行计划 + * @param {Object} opts - parameters + * @param {string} opts.instanceGid - 实例ID + * @param {} [opts.database] - 数据库名 optional + * @param {} [opts.sql] - SQL语句 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param executionPlan data + */ + + explainSql (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 explainSql" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling explainSql" + ) + } + + let postBody = {} + if (opts.database !== undefined && opts.database !== null) { + postBody['database'] = opts.database + } + if (opts.sql !== undefined && opts.sql !== null) { + postBody['sql'] = opts.sql + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 explainSql 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}/instance/{instanceGid}/explainSql', + '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) + } + ) + } + + /** + * SQL优化 + * @param {Object} opts - parameters + * @param {string} opts.instanceGid - 实例ID + * @param {} [opts.database] - 数据库名 optional + * @param {} [opts.sql] - SQL语句 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param tuningAdvice tuningAdvice 优化结果 + */ + + turningSql (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 turningSql" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling turningSql" + ) + } + + let postBody = {} + if (opts.database !== undefined && opts.database !== null) { + postBody['database'] = opts.database + } + if (opts.sql !== undefined && opts.sql !== null) { + postBody['sql'] = opts.sql + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 turningSql 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}/instance/{instanceGid}/tuningSql', + '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) + } + ) + } + + /** + * 查询慢sql次数及分布 + * @param {Object} opts - parameters + * @param {string} opts.instanceGid - 实例ID + * @param {string} opts.metric - metric名称 + * @param {string} opts.startTime - 查询开始时间,格式为:2021-11-11T15:04:05Z + * @param {string} opts.endTime - 查询截止时间,格式为:2021-11-11T15:04:05Z + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param dataPoint itemData + * @param metric metricInfo metric元信息 + */ + + describeSlowSqlMetric (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 describeSlowSqlMetric" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling describeSlowSqlMetric" + ) + } + if (opts.metric === undefined || opts.metric === null) { + throw new Error( + "Missing the required parameter 'opts.metric' when calling describeSlowSqlMetric" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeSlowSqlMetric" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeSlowSqlMetric" + ) + } + + let postBody = null + let queryParams = {} + if (opts.metric !== undefined && opts.metric !== null) { + queryParams['metric'] = opts.metric + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeSlowSqlMetric 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}/instance/{instanceGid}/sqlMetrics', + '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.instanceGid - RDS 实例ID,唯一标识一个RDS实例。 + * @param {string} opts.indexType - 索引类型 + * @param {integer} [opts.pageIndex] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageIndex 为-1时,返回所有数据页码; optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[1,100],用于查询列表的接口 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param indexInfo data + */ + + describeIndexs (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 describeIndexs" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling describeIndexs" + ) + } + if (opts.indexType === undefined || opts.indexType === null) { + throw new Error( + "Missing the required parameter 'opts.indexType' when calling describeIndexs" + ) + } + + let postBody = null + let queryParams = {} + if (opts.indexType !== undefined && opts.indexType !== null) { + queryParams['indexType'] = opts.indexType + } + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeIndexs 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}/instance/{instanceGid}/describeIndexs', + '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.instanceGid - RDS 实例ID,唯一标识一个RDS实例。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string totalDiskSize 总空间(单位:G) + * @param string usedDiskSize 已用空间(单位:G) + * @param string totalIncreaseSize 最近一周增长量(单位:G) + * @param string averageIncrease 最近一周平均增长率 + * @param string freeDiskSize 剩余空间(单位:G) + * @param string predictAvailableDays 预计剩余可用天数 + */ + + describeStorages (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 describeStorages" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling describeStorages" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeStorages 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}/instance/{instanceGid}/describeStorages', + '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.instanceGid - RDS 实例ID,唯一标识一个RDS实例。 + * @param {string} opts.startTime - 查询开始时间,格式为:2006-01-02T15:04:05Z + * @param {string} opts.endTime - 查询截止时间,格式为:2006-01-02T15:04:05Z + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param metricData data + */ + + describeStorageTrend (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 describeStorageTrend" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling describeStorageTrend" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling describeStorageTrend" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling describeStorageTrend" + ) + } + + let postBody = null + let queryParams = {} + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeStorageTrend 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}/instance/{instanceGid}/describeStorageTrend', + '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) + } + ) + } + + /** + * 表空间Top 10 + * @param {Object} opts - parameters + * @param {string} opts.instanceGid - RDS 实例ID,唯一标识一个RDS实例。 + * @param {string} [opts.sortField] - 排序字段:表空间(totalSize)、表数据空间(dataSize)、索引空间(idxSize)、碎片率(fragment)、行数(dataRows) optional + * @param {string} [opts.sortType] - 排序类型,desc 降序、asc 升序,默认降序 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param tableStorageInfo data + */ + + describeTableSpaceTop (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 describeTableSpaceTop" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling describeTableSpaceTop" + ) + } + + let postBody = null + let queryParams = {} + if (opts.sortField !== undefined && opts.sortField !== null) { + queryParams['sortField'] = opts.sortField + } + if (opts.sortType !== undefined && opts.sortType !== null) { + queryParams['sortType'] = opts.sortType + } + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeTableSpaceTop 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}/instance/{instanceGid}/tableSpaceTop', + '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) + } + ) + } + + /** + * 库空间Top 10 + * @param {Object} opts - parameters + * @param {string} opts.instanceGid - RDS 实例ID,唯一标识一个RDS实例。 + * @param {string} [opts.sortField] - 排序字段:表空间(totalSize)、表数据空间(dataSize)、索引空间(idxSize)、碎片率(fragment)、行数(dataRows) optional + * @param {string} [opts.sortType] - 排序类型,desc 降序、asc 升序,默认降序 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param tableStorageInfo data + */ + + describeSchemaSpaceTop (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 describeSchemaSpaceTop" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling describeSchemaSpaceTop" + ) + } + + let postBody = null + let queryParams = {} + if (opts.sortField !== undefined && opts.sortField !== null) { + queryParams['sortField'] = opts.sortField + } + if (opts.sortType !== undefined && opts.sortType !== null) { + queryParams['sortType'] = opts.sortType + } + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeSchemaSpaceTop 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}/instance/{instanceGid}/schemaSpaceTop', + '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.instanceGid - RDS 实例ID,唯一标识一个RDS实例。 + * @param {string} [opts.sortField] - 排序字段:表空间(totalSize)、表数据空间(dataSize)、索引空间(idxSize)、碎片率(fragment)、行数(dataRows) optional + * @param {string} [opts.sortType] - 排序类型,desc 降序、asc 升序,默认降序 optional + * @param {string} [opts.dbName] - 过滤的数据库名 optional + * @param {string} [opts.tableName] - 过滤的表名 optional + * @param {integer} [opts.pageIndex] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageIndex 为-1时,返回所有数据页码 optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[1,100],用于查询列表的接口 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param tableStorageInfo data + * @param integer totalCount 总数 + */ + + describeTableSpaceDetail (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 describeTableSpaceDetail" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling describeTableSpaceDetail" + ) + } + + let postBody = null + let queryParams = {} + if (opts.sortField !== undefined && opts.sortField !== null) { + queryParams['sortField'] = opts.sortField + } + if (opts.sortType !== undefined && opts.sortType !== null) { + queryParams['sortType'] = opts.sortType + } + if (opts.dbName !== undefined && opts.dbName !== null) { + queryParams['dbName'] = opts.dbName + } + if (opts.tableName !== undefined && opts.tableName !== null) { + queryParams['tableName'] = opts.tableName + } + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeTableSpaceDetail 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}/instance/{instanceGid}/tableSpaceDetail', + '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.instanceGid - RDS 实例ID,唯一标识一个RDS实例。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string data + */ + + describeAllDbInfo (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 describeAllDbInfo" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling describeAllDbInfo" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeAllDbInfo 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}/instance/{instanceGid}/allDbInfo', + '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.instanceGid - RDS 实例ID,唯一标识一个RDS实例。 + * @param {string} [opts.dbName] - 数据库名 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string data + */ + + describeAllTableInfoForDb (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 describeAllTableInfoForDb" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling describeAllTableInfoForDb" + ) + } + + let postBody = null + let queryParams = {} + if (opts.dbName !== undefined && opts.dbName !== null) { + queryParams['dbName'] = opts.dbName + } + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeAllTableInfoForDb 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}/instance/{instanceGid}/allTableInfoForDb', + '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.instanceGid - RDS 实例ID,唯一标识一个RDS实例 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param bufferPoolInfo bufferPoolInfo Buffer Pool信息 + * @param connectionInfo connectionInfo 连接信息 + * @param serverInfo serverInfo Server信息 + */ + + describeSystemInfo (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 describeSystemInfo" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling describeSystemInfo" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 describeSystemInfo 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}/instance/{instanceGid}/systemInfo', + '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.instanceGid - 实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param table data + */ + + checkTableTypes (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 checkTableTypes" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling checkTableTypes" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 checkTableTypes 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}/instance/{instanceGid}/checkTableTypes', + '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) + } + ) + } + + /** + * 根据诊断id进行表诊断 + * @param {Object} opts - parameters + * @param {string} opts.instanceGid - 实例ID + * @param {integer} opts.checkTypeId - 诊断类型id + * @param {integer} [opts.pageIndex] - 显示数据的页码,默认为1,取值范围:[-1,∞) pageIndex 为-1时,返回所有数据页码 optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[1,100] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param fieldList data + * @param integer totalCount 总条数 + */ + + checkTableByType (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 checkTableByType" + ) + } + + opts = opts || {} + + if (opts.instanceGid === undefined || opts.instanceGid === null) { + throw new Error( + "Missing the required parameter 'opts.instanceGid' when calling checkTableByType" + ) + } + if (opts.checkTypeId === undefined || opts.checkTypeId === null) { + throw new Error( + "Missing the required parameter 'opts.checkTypeId' when calling checkTableByType" + ) + } + + let postBody = null + let queryParams = {} + if (opts.checkTypeId !== undefined && opts.checkTypeId !== null) { + queryParams['checkTypeId'] = opts.checkTypeId + } + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + + let pathParams = { + regionId: regionId, + instanceGid: opts.instanceGid + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 smartdba/2.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 checkTableByType 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}/instance/{instanceGid}/checkTables', + '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 = SMARTDBA diff --git a/packages/libs/lib-jdcloud/src/repo/sms/v1/sms.js b/packages/libs/lib-jdcloud/src/repo/sms/v1/sms.js new file mode 100644 index 000000000..3d47b4938 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/sms/v1/sms.js @@ -0,0 +1,432 @@ +/* + * 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. + * + * Send-Message-Related-APIs + * 模版相关API + * + * 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 = 'sms' +Service._services[serviceId] = true + +/** + * sms service. + * @version 1.3.3 + */ + +class SMS extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'sms.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 指定模板群发短信接口。接口调用需要使用京东云统一鉴权的SDK方式接入,以下文档仅是接口出参、入参描述,并不是最终程序实现逻辑的范例,具体接口实现请查看SDK参考:https://docs.jdcloud.com/cn/text-message/java + * @param {Object} opts - parameters + * @param {string} opts.templateId - 模板Id + * @param {string} opts.signId - 签名Id + * @param {array} [opts.phoneList] - 群发的国内电话号码,群发时一次最多不要超过100个手机号 optional + * @param {array} [opts.params] - 短信模板变量对应的数据值,Array格式 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param batchSendResp data 指定短信Id群发短信响应参数 + * @param boolean status 请求状态 + * @param integer code 错误码 + * @param string message 错误消息 + */ + + batchSend (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 batchSend" + ) + } + + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling batchSend" + ) + } + if (opts.signId === undefined || opts.signId === null) { + throw new Error( + "Missing the required parameter 'opts.signId' when calling batchSend" + ) + } + + let postBody = {} + if (opts.templateId !== undefined && opts.templateId !== null) { + postBody['templateId'] = opts.templateId + } + if (opts.signId !== undefined && opts.signId !== null) { + postBody['signId'] = opts.signId + } + if (opts.phoneList !== undefined && opts.phoneList !== null) { + postBody['phoneList'] = opts.phoneList + } + if (opts.params !== undefined && opts.params !== null) { + postBody['params'] = opts.params + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 sms/1.3.3' + } + + 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 batchSend 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}/batchSend', + '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) + } + ) + } + + /** + * 短信发送回执接口。接口调用需要使用京东云统一鉴权的SDK方式接入,以下文档仅是接口出参、入参描述,并不是最终程序实现逻辑的范例,具体接口实现请查看SDK参考:https://docs.jdcloud.com/cn/text-message/java + * @param {Object} opts - parameters + * @param {string} opts.sequenceNumber - 发送短信的序列号 + * @param {array} [opts.phoneList] - 需要获取回执的手机号码列表,选填 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param statusReportResp data + * @param boolean status 请求状态 + * @param integer code 错误码 + * @param string message 错误消息 + */ + + statusReport (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 statusReport" + ) + } + + opts = opts || {} + + if (opts.sequenceNumber === undefined || opts.sequenceNumber === null) { + throw new Error( + "Missing the required parameter 'opts.sequenceNumber' when calling statusReport" + ) + } + + let postBody = {} + if (opts.sequenceNumber !== undefined && opts.sequenceNumber !== null) { + postBody['sequenceNumber'] = opts.sequenceNumber + } + if (opts.phoneList !== undefined && opts.phoneList !== null) { + postBody['phoneList'] = opts.phoneList + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 sms/1.3.3' + } + + 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 statusReport 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}/statusReport', + '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) + } + ) + } + + /** + * 短信回复接口。 接口调用需要使用京东云统一鉴权的SDK方式接入,以下文档仅是接口出参、入参描述,并不是最终程序实现逻辑的范例,具体接口实现请查看SDK参考:https://docs.jdcloud.com/cn/text-message/java + * @param {Object} opts - parameters + * @param {string} opts.appId - 应用Id + * @param {string} opts.dataDate - 查询时间 + * @param {array} [opts.phoneList] - 手机号列表(选填) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param replyResp data + * @param boolean status 请求状态 + * @param integer code 错误码 + * @param string message 错误消息 + */ + + reply (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 reply" + ) + } + + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling reply" + ) + } + if (opts.dataDate === undefined || opts.dataDate === null) { + throw new Error( + "Missing the required parameter 'opts.dataDate' when calling reply" + ) + } + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.dataDate !== undefined && opts.dataDate !== null) { + postBody['dataDate'] = opts.dataDate + } + if (opts.phoneList !== undefined && opts.phoneList !== null) { + postBody['phoneList'] = opts.phoneList + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 sms/1.3.3' + } + + 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 reply 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}/reply', + '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 = SMS diff --git a/packages/libs/lib-jdcloud/src/repo/sop/v1/sop.js b/packages/libs/lib-jdcloud/src/repo/sop/v1/sop.js new file mode 100644 index 000000000..9260a93d5 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/sop/v1/sop.js @@ -0,0 +1,282 @@ +/* + * 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. + * + * 敏感操作配置 + * 操作敏感操作配置接口 + * + * 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 = 'sop' +Service._services[serviceId] = true + +/** + * sop service. + * @version 0.1.0 + */ + +JDCloud.SOP = class SOP extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'sop.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 获取Token + * @param {Object} opts - parameters + * @param {getSecurityTokenInfo} opts.getSecurityTokenInfo - 获取SecurityToken参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string securityToken 安全令牌 + */ + + getSecurityToken (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 getSecurityToken" + ) + } + + opts = opts || {} + + if ( + opts.getSecurityTokenInfo === undefined || + opts.getSecurityTokenInfo === null + ) { + throw new Error( + "Missing the required parameter 'opts.getSecurityTokenInfo' when calling getSecurityToken" + ) + } + + let postBody = {} + if ( + opts.getSecurityTokenInfo !== undefined && + opts.getSecurityTokenInfo !== null + ) { + postBody['getSecurityTokenInfo'] = opts.getSecurityTokenInfo + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 sop/0.1.0' + } + + 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 getSecurityToken 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 = this.makeRequest( + '/regions/{regionId}/securityToken:getSecurityToken', + '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.action - 操作action serviceName:actionName + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer status 操作保护启用状态:0-未启用, 1-已启用 + * @param integer type 操作保护验证方式:0-无, 1-短信, 2-邮箱, 3-MFA + * @param string extInfo 扩展信息,type=1时为掩码后的手机号码 type=2时为掩码后的邮箱地址 + */ + + getSensitiveOpSetting (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 getSensitiveOpSetting" + ) + } + + opts = opts || {} + + if (opts.action === undefined || opts.action === null) { + throw new Error( + "Missing the required parameter 'opts.action' when calling getSensitiveOpSetting" + ) + } + + let postBody = null + let queryParams = {} + if (opts.action !== undefined && opts.action !== null) { + queryParams['action'] = opts.action + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 sop/0.1.0' + } + + 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 getSensitiveOpSetting 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 = this.makeRequest( + '/regions/{regionId}/sensitiveOpSetting', + '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 = JDCloud.SOP diff --git a/packages/libs/lib-jdcloud/src/repo/ssl/v1/ssl.js b/packages/libs/lib-jdcloud/src/repo/ssl/v1/ssl.js new file mode 100644 index 000000000..5d1d3afdc --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/ssl/v1/ssl.js @@ -0,0 +1,828 @@ +/* + * 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. + * + * SSL Certificate Manager + * SSL数字证书信息管理接口 + * + * 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 = 'ssl' +Service._services[serviceId] = true + +/** + * ssl service. + * @version 1.0.2 + */ + +JDCloud.SSL = class SSL extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'ssl.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查看证书列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 第几页,从1开始计数 optional + * @param {integer} [opts.pageSize] - 每页显示的数目 optional + * @param {string} [opts.domainName] - 域名,支持按照域名检索证书 optional + * @param {string} [opts.certIds] - 证书id/别名 optional + * @param {string} callback - callback + @return {Object} result + * @param certListDetail certListDetails + * @param integer totalCount 总数量 + */ + + describeCerts (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 + } + if (opts.domainName !== undefined && opts.domainName !== null) { + queryParams['domainName'] = opts.domainName + } + if (opts.certIds !== undefined && opts.certIds !== null) { + queryParams['certIds'] = opts.certIds + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ssl/1.0.2' + } + + 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 describeCerts 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 = this.makeRequest( + '/sslCert', + '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.certId - 证书 Id + * @param {integer} [opts.pageNumber] - 第几页,从1开始计数 optional + * @param {integer} [opts.pageSize] - 每页显示的数目 optional + * @param {string} callback - callback + @return {Object} result + * @param certDescDetail certDescDetail + */ + + describeCert (opts, callback) { + opts = opts || {} + + if (opts.certId === undefined || opts.certId === null) { + throw new Error( + "Missing the required parameter 'opts.certId' when calling describeCert" + ) + } + + 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: 'jdcloud', + certId: opts.certId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ssl/1.0.2' + } + + 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 describeCert 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 = this.makeRequest( + '/sslCert/{certId}', + '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) + } + ) + } + + /** + * 删除证书 [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.certId - 证书 Id + * @param {string} callback - callback + @return {Object} result + * @param integer code 状态码 + * @param string message 消息 + */ + + deleteCerts (opts, callback) { + opts = opts || {} + + if (opts.certId === undefined || opts.certId === null) { + throw new Error( + "Missing the required parameter 'opts.certId' when calling deleteCerts" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + certId: opts.certId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ssl/1.0.2' + } + + 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 deleteCerts 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 = this.makeRequest( + '/sslCert/{certId}', + '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.certName - 证书名称 + * @param {string} opts.keyFile - 私钥 + * @param {string} opts.certFile - 证书 + * @param {string} [opts.aliasName] - 证书别名 optional + * @param {string} callback - callback + @return {Object} result + * @param string certId + * @param string digest 对私钥文件使用sha256算法计算的摘要信息 + */ + + uploadCert (opts, callback) { + opts = opts || {} + + if (opts.certName === undefined || opts.certName === null) { + throw new Error( + "Missing the required parameter 'opts.certName' when calling uploadCert" + ) + } + if (opts.keyFile === undefined || opts.keyFile === null) { + throw new Error( + "Missing the required parameter 'opts.keyFile' when calling uploadCert" + ) + } + if (opts.certFile === undefined || opts.certFile === null) { + throw new Error( + "Missing the required parameter 'opts.certFile' when calling uploadCert" + ) + } + + let postBody = {} + if (opts.certName !== undefined && opts.certName !== null) { + postBody['certName'] = opts.certName + } + if (opts.keyFile !== undefined && opts.keyFile !== null) { + postBody['keyFile'] = opts.keyFile + } + if (opts.certFile !== undefined && opts.certFile !== null) { + postBody['certFile'] = opts.certFile + } + if (opts.aliasName !== undefined && opts.aliasName !== null) { + postBody['aliasName'] = opts.aliasName + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ssl/1.0.2' + } + + 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 uploadCert 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 = this.makeRequest( + '/sslCert:upload', + '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) + } + ) + } + + /** + * 下载证书 [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.certId - 证书 Id + * @param {string} opts.serverType - 证书应用的服务器类型(Nginx Apache Tomcat IIS Other) + * @param {string} callback - callback + @return {Object} result + * @param downloadCertDesc certDesc + */ + + downloadCert (opts, callback) { + opts = opts || {} + + if (opts.certId === undefined || opts.certId === null) { + throw new Error( + "Missing the required parameter 'opts.certId' when calling downloadCert" + ) + } + if (opts.serverType === undefined || opts.serverType === null) { + throw new Error( + "Missing the required parameter 'opts.serverType' when calling downloadCert" + ) + } + + let postBody = null + let queryParams = {} + if (opts.serverType !== undefined && opts.serverType !== null) { + queryParams['serverType'] = opts.serverType + } + + let pathParams = { + regionId: 'jdcloud', + certId: opts.certId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ssl/1.0.2' + } + + 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 downloadCert 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 = this.makeRequest( + '/sslCert/{certId}:download', + '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.certId - 证书Id + * @param {string} opts.certName - 证书名称 + * @param {string} callback - callback + @return {Object} result + * @param integer code 状态码 + * @param string message 消息 + */ + + updateCertName (opts, callback) { + opts = opts || {} + + if (opts.certId === undefined || opts.certId === null) { + throw new Error( + "Missing the required parameter 'opts.certId' when calling updateCertName" + ) + } + if (opts.certName === undefined || opts.certName === null) { + throw new Error( + "Missing the required parameter 'opts.certName' when calling updateCertName" + ) + } + + let postBody = {} + if (opts.certId !== undefined && opts.certId !== null) { + postBody['certId'] = opts.certId + } + if (opts.certName !== undefined && opts.certName !== null) { + postBody['certName'] = opts.certName + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ssl/1.0.2' + } + + 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 updateCertName 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 = this.makeRequest( + '/sslCert:updateName', + '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) + } + ) + } + + /** + * 更新证书 [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.certId - 证书ID + * @param {string} opts.keyFile - 私钥 + * @param {string} opts.certFile - 证书 + * @param {string} callback - callback + @return {Object} result + * @param string certId 待更新证书ID + * @param string digest 对私钥文件使用sha256算法计算的摘要信息 + */ + + updateCert (opts, callback) { + opts = opts || {} + + if (opts.certId === undefined || opts.certId === null) { + throw new Error( + "Missing the required parameter 'opts.certId' when calling updateCert" + ) + } + if (opts.keyFile === undefined || opts.keyFile === null) { + throw new Error( + "Missing the required parameter 'opts.keyFile' when calling updateCert" + ) + } + if (opts.certFile === undefined || opts.certFile === null) { + throw new Error( + "Missing the required parameter 'opts.certFile' when calling updateCert" + ) + } + + let postBody = {} + if (opts.certId !== undefined && opts.certId !== null) { + postBody['certId'] = opts.certId + } + if (opts.keyFile !== undefined && opts.keyFile !== null) { + postBody['keyFile'] = opts.keyFile + } + if (opts.certFile !== undefined && opts.certFile !== null) { + postBody['certFile'] = opts.certFile + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ssl/1.0.2' + } + + 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 updateCert 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 = this.makeRequest( + '/sslCert:updateCert', + '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 = JDCloud.SSL diff --git a/packages/libs/lib-jdcloud/src/repo/starshield/v1/starshield.js b/packages/libs/lib-jdcloud/src/repo/starshield/v1/starshield.js new file mode 100644 index 000000000..127f95d1a --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/starshield/v1/starshield.js @@ -0,0 +1,23752 @@ +/* + * 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. + * + * Zone-Settings + * A Zone setting changes how the Zone works in relation to caching, security, or other features of JDC StarShield + * + * 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 = 'starshield' +Service._services[serviceId] = true + +/** + * starshield service. + * @version 0.0.14 + */ + +class STARSHIELD extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'starshield.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * The dashboard view provides both totals and timeseries data for the given zone and time period across the entire scdn network. + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} opts.zoneName + * @param {string} opts.since + * @param {string} opts.until + * @param {string} [opts.category] optional + * @param {} [opts.filters] optional + * @param {string} callback - callback + @return {Object} result + * @param zoneAnalytics zoneAnalytics + */ + + dashboard (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling dashboard" + ) + } + if (opts.zoneName === undefined || opts.zoneName === null) { + throw new Error( + "Missing the required parameter 'opts.zoneName' when calling dashboard" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling dashboard" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling dashboard" + ) + } + + let postBody = null + let queryParams = {} + if (opts.zoneName !== undefined && opts.zoneName !== null) { + queryParams['zoneName'] = opts.zoneName + } + if (opts.since !== undefined && opts.since !== null) { + queryParams['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + queryParams['until'] = opts.until + } + if (opts.category !== undefined && opts.category !== null) { + queryParams['category'] = opts.category + } + if (opts.filters !== undefined && opts.filters !== null) { + queryParams['filters'] = opts.filters + } + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 dashboard 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( + '/zones/{zone_identifier}/analytics$$dashboard', + '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) + } + ) + } + + /** + * 按请求次数统计。获取国家/地区的请求分布情况;获取路径、主机、设备类型的TopK. + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.zoneName] optional + * @param {} [opts.since] optional + * @param {} [opts.until] optional + * @param {} [opts.topK] optional + * @param {} [opts.filters] optional + * @param {string} callback - callback + @return {Object} result + * @param topkAnalytics topkAnalytics + */ + + topK (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling topK" + ) + } + + let postBody = {} + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + if (opts.topK !== undefined && opts.topK !== null) { + postBody['topK'] = opts.topK + } + if (opts.filters !== undefined && opts.filters !== null) { + postBody['filters'] = opts.filters + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 topK 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( + '/zones/{zone_identifier}/analytics$$topK', + '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) + } + ) + } + + /** + * 按响应带宽统计。获取国家/地区的请求分布情况;获取路径、主机、设备类型的TopK. + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.zoneName] optional + * @param {} [opts.since] optional + * @param {} [opts.until] optional + * @param {} [opts.topK] optional + * @param {} [opts.filters] optional + * @param {string} callback - callback + @return {Object} result + * @param topkAnalytics topkAnalytics + */ + + bandwidthTopK (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling bandwidthTopK" + ) + } + + let postBody = {} + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + if (opts.topK !== undefined && opts.topK !== null) { + postBody['topK'] = opts.topK + } + if (opts.filters !== undefined && opts.filters !== null) { + postBody['filters'] = opts.filters + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 bandwidthTopK 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( + '/zones/{zone_identifier}/analytics$$bandwidthTopK', + '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.zone_identifier + * @param {} [opts.zoneName] optional + * @param {} [opts.since] optional + * @param {} [opts.until] optional + * @param {} [opts.topK] optional + * @param {} [opts.criterionName] optional + * @param {} [opts.filters] optional + * @param {string} callback - callback + @return {Object} result + * @param dateHistogram dateHistograms + * @param number timeScope + * @param string since + * @param string util + */ + + dateHistogram (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling dateHistogram" + ) + } + + let postBody = {} + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + if (opts.topK !== undefined && opts.topK !== null) { + postBody['topK'] = opts.topK + } + if (opts.criterionName !== undefined && opts.criterionName !== null) { + postBody['criterionName'] = opts.criterionName + } + if (opts.filters !== undefined && opts.filters !== null) { + postBody['filters'] = opts.filters + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 dateHistogram 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( + '/zones/{zone_identifier}/analytics$$dateHistogram', + '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.zone_identifier + * @param {} [opts.zoneName] optional + * @param {} [opts.since] optional + * @param {} [opts.until] optional + * @param {} [opts.topK] optional + * @param {} [opts.criterionName] optional + * @param {} [opts.filters] optional + * @param {string} callback - callback + @return {Object} result + * @param dateHistogram dateHistograms + * @param number timeScope + * @param string since + * @param string util + */ + + dateHistogramBandwidth (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling dateHistogramBandwidth" + ) + } + + let postBody = {} + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + if (opts.topK !== undefined && opts.topK !== null) { + postBody['topK'] = opts.topK + } + if (opts.criterionName !== undefined && opts.criterionName !== null) { + postBody['criterionName'] = opts.criterionName + } + if (opts.filters !== undefined && opts.filters !== null) { + postBody['filters'] = opts.filters + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 dateHistogramBandwidth 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( + '/zones/{zone_identifier}/analytics$$dateHistogramBandwidth', + '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.zone_identifier + * @param {} [opts.zoneName] optional + * @param {} [opts.since] optional + * @param {} [opts.until] optional + * @param {} [opts.direction] optional + * @param {string} callback - callback + @return {Object} result + * @param simpleDateHistogram data + */ + + bandwidthTrend (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling bandwidthTrend" + ) + } + + let postBody = {} + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + if (opts.direction !== undefined && opts.direction !== null) { + postBody['direction'] = opts.direction + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 bandwidthTrend 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( + '/zones/{zone_identifier}/analytics$$bandwidthTrend', + '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) + } + ) + } + + /** + * 按请求次数统计。获取内容类型、路径、主机、设备类型、国家/地区、状态代码的TopK. + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.zoneName] optional + * @param {} [opts.since] optional + * @param {} [opts.until] optional + * @param {} [opts.topK] optional + * @param {} [opts.filters] optional + * @param {string} callback - callback + @return {Object} result + * @param topkAnalytics topkAnalytics + */ + + cacheTopK (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling cacheTopK" + ) + } + + let postBody = {} + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + if (opts.topK !== undefined && opts.topK !== null) { + postBody['topK'] = opts.topK + } + if (opts.filters !== undefined && opts.filters !== null) { + postBody['filters'] = opts.filters + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 cacheTopK 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( + '/zones/{zone_identifier}/analytics$$cacheTopK', + '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) + } + ) + } + + /** + * 按响应带宽统计。获取内容类型、路径、主机、设备类型、国家/地区、状态代码的TopK. + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.zoneName] optional + * @param {} [opts.since] optional + * @param {} [opts.until] optional + * @param {} [opts.topK] optional + * @param {} [opts.filters] optional + * @param {string} callback - callback + @return {Object} result + * @param topkAnalytics topkAnalytics + */ + + cacheBandwidthTopK (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling cacheBandwidthTopK" + ) + } + + let postBody = {} + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + if (opts.topK !== undefined && opts.topK !== null) { + postBody['topK'] = opts.topK + } + if (opts.filters !== undefined && opts.filters !== null) { + postBody['filters'] = opts.filters + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 cacheBandwidthTopK 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( + '/zones/{zone_identifier}/analytics$$cacheBandwidthTopK', + '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.zone_identifier + * @param {} [opts.zoneName] optional + * @param {} [opts.since] optional + * @param {} [opts.until] optional + * @param {} [opts.topK] optional + * @param {} [opts.criterionName] optional + * @param {} [opts.filters] optional + * @param {string} callback - callback + @return {Object} result + * @param dateHistogram dateHistograms + * @param number timeScope + * @param string since + * @param string util + */ + + cacheDateHistogram (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling cacheDateHistogram" + ) + } + + let postBody = {} + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + if (opts.topK !== undefined && opts.topK !== null) { + postBody['topK'] = opts.topK + } + if (opts.criterionName !== undefined && opts.criterionName !== null) { + postBody['criterionName'] = opts.criterionName + } + if (opts.filters !== undefined && opts.filters !== null) { + postBody['filters'] = opts.filters + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 cacheDateHistogram 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( + '/zones/{zone_identifier}/analytics$$cacheDateHistogram', + '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.zone_identifier + * @param {} [opts.zoneName] optional + * @param {} [opts.since] optional + * @param {} [opts.until] optional + * @param {} [opts.topK] optional + * @param {} [opts.criterionName] optional + * @param {} [opts.filters] optional + * @param {string} callback - callback + @return {Object} result + * @param dateHistogram dateHistograms + * @param number timeScope + * @param string since + * @param string util + */ + + cacheDateHistogramBandwidth (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling cacheDateHistogramBandwidth" + ) + } + + let postBody = {} + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + if (opts.topK !== undefined && opts.topK !== null) { + postBody['topK'] = opts.topK + } + if (opts.criterionName !== undefined && opts.criterionName !== null) { + postBody['criterionName'] = opts.criterionName + } + if (opts.filters !== undefined && opts.filters !== null) { + postBody['filters'] = opts.filters + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 cacheDateHistogramBandwidth 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( + '/zones/{zone_identifier}/analytics$$cacheDateHistogramBandwidth', + '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) + } + ) + } + + /** + * 按防火墙事件数量统计。获取IP地址、用户代理、路径、主机、国家/地区、HTTP方法的TopK。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.zoneName] optional + * @param {} [opts.since] optional + * @param {} [opts.until] optional + * @param {} [opts.topK] optional + * @param {} [opts.filters] optional + * @param {string} callback - callback + @return {Object} result + * @param topkAnalytics topkAnalytics + */ + + firewallTopK (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling firewallTopK" + ) + } + + let postBody = {} + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + if (opts.topK !== undefined && opts.topK !== null) { + postBody['topK'] = opts.topK + } + if (opts.filters !== undefined && opts.filters !== null) { + postBody['filters'] = opts.filters + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 firewallTopK 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( + '/zones/{zone_identifier}/analytics$$firewallTopK', + '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.zone_identifier + * @param {} [opts.zoneName] optional + * @param {} [opts.since] optional + * @param {} [opts.until] optional + * @param {} [opts.topK] optional + * @param {} [opts.criterionName] optional + * @param {} [opts.filters] optional + * @param {string} callback - callback + @return {Object} result + * @param dateHistogram dateHistograms + * @param number timeScope + * @param string since + * @param string util + */ + + firewallDateHistogram (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling firewallDateHistogram" + ) + } + + let postBody = {} + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + if (opts.topK !== undefined && opts.topK !== null) { + postBody['topK'] = opts.topK + } + if (opts.criterionName !== undefined && opts.criterionName !== null) { + postBody['criterionName'] = opts.criterionName + } + if (opts.filters !== undefined && opts.filters !== null) { + postBody['filters'] = opts.filters + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 firewallDateHistogram 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( + '/zones/{zone_identifier}/analytics$$firewallDateHistogram', + '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) + } + ) + } + + /** + * qps on Zone + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.zoneName] optional + * @param {} [opts.queryMode] optional + * @param {} [opts.since] optional + * @param {} [opts.until] optional + * @param {string} callback - callback + @return {Object} result + * @param simpleDateHistogram data + */ + + qpsZone (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling qpsZone" + ) + } + + let postBody = {} + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.queryMode !== undefined && opts.queryMode !== null) { + postBody['queryMode'] = opts.queryMode + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 qpsZone 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( + '/zones/{zone_identifier}/qps', + '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) + } + ) + } + + /** + * 域的每秒指标,request/bandwidth/waf/l7ddos/firewallRules + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.zoneName] optional + * @param {} [opts.queryMode] optional + * @param {} [opts.since] optional + * @param {} [opts.until] optional + * @param {string} callback - callback + @return {Object} result + * @param simpleDateHistogram data + */ + + xps (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling xps" + ) + } + + let postBody = {} + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.queryMode !== undefined && opts.queryMode !== null) { + postBody['queryMode'] = opts.queryMode + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 xps 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( + '/zones/{zone_identifier}/xps', + '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) + } + ) + } + + /** + * qps + * @param {Object} opts - parameters + * @param {string} opts.instanceId + * @param {} [opts.queryMode] optional + * @param {} [opts.since] optional + * @param {} [opts.until] optional + * @param {string} callback - callback + @return {Object} result + * @param simpleDateHistogram data + */ + + qpsInstance (opts, callback) { + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling qpsInstance" + ) + } + + let postBody = {} + if (opts.queryMode !== undefined && opts.queryMode !== null) { + postBody['queryMode'] = opts.queryMode + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 qpsInstance 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( + '/instances/{instanceId}/qps', + '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) + } + ) + } + + /** + * bps on Zone + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.zoneName] optional + * @param {} [opts.queryMode] optional + * @param {} [opts.since] optional + * @param {} [opts.until] optional + * @param {string} callback - callback + @return {Object} result + * @param simpleDateHistogram data + */ + + bpsZone (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling bpsZone" + ) + } + + let postBody = {} + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.queryMode !== undefined && opts.queryMode !== null) { + postBody['queryMode'] = opts.queryMode + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 bpsZone 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( + '/zones/{zone_identifier}/bps', + '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) + } + ) + } + + /** + * bps + * @param {Object} opts - parameters + * @param {string} opts.instanceId + * @param {} [opts.queryMode] optional + * @param {} [opts.since] optional + * @param {} [opts.until] optional + * @param {string} callback - callback + @return {Object} result + * @param simpleDateHistogram data + */ + + bpsInstance (opts, callback) { + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling bpsInstance" + ) + } + + let postBody = {} + if (opts.queryMode !== undefined && opts.queryMode !== null) { + postBody['queryMode'] = opts.queryMode + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 bpsInstance 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( + '/instances/{instanceId}/bps', + '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.zone_identifier + * @param {} [opts.zoneName] optional + * @param {} [opts.since] optional + * @param {} [opts.until] optional + * @param {} [opts.pageNumber] optional + * @param {} [opts.pageSize] optional + * @param {} [opts.filters] optional + * @param {string} callback - callback + @return {Object} result + * @param number total + * @param activityLog activityLogs + */ + + firewallActivityLog (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling firewallActivityLog" + ) + } + + let postBody = {} + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + if (opts.filters !== undefined && opts.filters !== null) { + postBody['filters'] = opts.filters + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 firewallActivityLog 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( + '/zones/{zone_identifier}/analytics$$firewallActivityLog', + '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.zone_identifier + * @param {} [opts.zoneName] optional + * @param {} [opts.since] optional + * @param {} [opts.until] optional + * @param {} [opts.pageNumber] optional + * @param {} [opts.pageSize] optional + * @param {} [opts.filters] optional + * @param {string} callback - callback + @return {Object} result + * @param number total + * @param accessLog dataList + */ + + accessLog (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling accessLog" + ) + } + + let postBody = {} + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + if (opts.filters !== undefined && opts.filters !== null) { + postBody['filters'] = opts.filters + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 accessLog 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( + '/zones/{zone_identifier}/analytics$$accessLog', + '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.zone_identifier + * @param {string} opts.zoneName + * @param {string} opts.since + * @param {string} opts.until + * @param {string} opts.criterionName + * @param {string} callback - callback + @return {Object} result + * @param item items + */ + + groupBy (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling groupBy" + ) + } + if (opts.zoneName === undefined || opts.zoneName === null) { + throw new Error( + "Missing the required parameter 'opts.zoneName' when calling groupBy" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling groupBy" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling groupBy" + ) + } + if (opts.criterionName === undefined || opts.criterionName === null) { + throw new Error( + "Missing the required parameter 'opts.criterionName' when calling groupBy" + ) + } + + let postBody = null + let queryParams = {} + if (opts.zoneName !== undefined && opts.zoneName !== null) { + queryParams['zoneName'] = opts.zoneName + } + if (opts.since !== undefined && opts.since !== null) { + queryParams['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + queryParams['until'] = opts.until + } + if (opts.criterionName !== undefined && opts.criterionName !== null) { + queryParams['criterionName'] = opts.criterionName + } + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 groupBy 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( + '/zones/{zone_identifier}/analytics$$groupBy', + '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) + } + ) + } + + /** + * listAvailablePageRuleSetting + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param availablePageRule dataList + * @param integer currentCount 当前页记录数量 + * @param integer totalCount 总记录数量 + * @param integer totalPage 总页数 + */ + + listAvailablePageRuleSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling listAvailablePageRuleSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 listAvailablePageRuleSetting 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( + '/zones/{zone_identifier}/pagerules$$settings', + '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) + } + ) + } + + /** + * Bot日期直方图. + * @param {Object} opts - parameters + * @param {string} opts.zoneId - 域名标识 + * @param {string} opts.since - 开始时间 + * @param {string} opts.until - 结束时间 + * @param {botFilter} [opts.filters] optional + * @param {string} callback - callback + @return {Object} result + * @param botDateHistogram botDateHistogram + */ + + botDateHistogram (opts, callback) { + opts = opts || {} + + if (opts.zoneId === undefined || opts.zoneId === null) { + throw new Error( + "Missing the required parameter 'opts.zoneId' when calling botDateHistogram" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling botDateHistogram" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling botDateHistogram" + ) + } + + let postBody = null + let queryParams = {} + if (opts.since !== undefined && opts.since !== null) { + queryParams['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + queryParams['until'] = opts.until + } + Object.assign(queryParams, super.buildArrayParam(opts.filters, 'filters')) + + let pathParams = { + regionId: 'jdcloud', + zoneId: opts.zoneId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 botDateHistogram 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( + '/zones/{zoneId}/analyticsBotDateHistogram', + '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.zone_identifier + * @param {string} [opts.status] - 包括所有状态的证书包,而不仅仅是激活状态的证书包。 optional + * @param {number} [opts.page] - 分页结果的页码 optional + * @param {number} [opts.per_page] - 每页的域数 optional + * @param {string} callback - callback + @return {Object} result + * @param certificatePack dataList + * @param integer currentCount 当前页记录数量 + * @param integer totalCount 总记录数量 + * @param integer totalPage 总页数 + */ + + listCertificatePacks (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling listCertificatePacks" + ) + } + + let postBody = null + let queryParams = {} + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + if (opts.page !== undefined && opts.page !== null) { + queryParams['page'] = opts.page + } + if (opts.per_page !== undefined && opts.per_page !== null) { + queryParams['per_page'] = opts.per_page + } + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 listCertificatePacks 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( + '/zones/{zone_identifier}/ssl$$certificate_packs', + '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.zone_identifier + * @param {string} opts.identifier + * @param {string} callback - callback + @return {Object} result + * @param string data + */ + + deleteAdvancedCertificateManagerCertificatePack (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling deleteAdvancedCertificateManagerCertificatePack" + ) + } + if (opts.identifier === undefined || opts.identifier === null) { + throw new Error( + "Missing the required parameter 'opts.identifier' when calling deleteAdvancedCertificateManagerCertificatePack" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier, + identifier: opts.identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 deleteAdvancedCertificateManagerCertificatePack 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( + '/zones/{zone_identifier}/ssl$$certificate_packs/{identifier}', + '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.zone_identifier + * @param {} [opts.ty_pe] - 证书包的类型 optional + * @param {} [opts.hosts] - 以逗号分隔的证书包的有效主机名称列表。必须包含域的顶级域名,不得包含50个以上的主机,也不得为空。 optional + * @param {} [opts.validation_method] - 为订阅选择的验证方法 optional + * @param {} [opts.validity_days] - 为订阅选择的有效日期 optional + * @param {} [opts.certificate_authority] - 为该订阅选择的证书颁发机构。选择Let's Encrypt将减少对其他字段的定制。 +validation_method必须是'txt',validity_days必须是90,cloudflare_branding必须省略,hosts必须只包含两个条目。 +一个是域名,一个是域名的子域通配符(例如 example.com, *.example.com)。 + optional + * @param {} [opts.cloudflare_branding] - 是否为订阅添加星盾品牌。 optional + * @param {string} callback - callback + @return {Object} result + * @param certificatePack data + */ + + orderAdvancedCertificateManagerCertificatePack (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling orderAdvancedCertificateManagerCertificatePack" + ) + } + + let postBody = {} + if (opts.ty_pe !== undefined && opts.ty_pe !== null) { + postBody['ty_pe'] = opts.ty_pe + } + if (opts.hosts !== undefined && opts.hosts !== null) { + postBody['hosts'] = opts.hosts + } + if ( + opts.validation_method !== undefined && + opts.validation_method !== null + ) { + postBody['validation_method'] = opts.validation_method + } + if (opts.validity_days !== undefined && opts.validity_days !== null) { + postBody['validity_days'] = opts.validity_days + } + if ( + opts.certificate_authority !== undefined && + opts.certificate_authority !== null + ) { + postBody['certificate_authority'] = opts.certificate_authority + } + if ( + opts.cloudflare_branding !== undefined && + opts.cloudflare_branding !== null + ) { + postBody['cloudflare_branding'] = opts.cloudflare_branding + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 orderAdvancedCertificateManagerCertificatePack 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( + '/zones/{zone_identifier}/ssl$$certificate_packs$$order', + '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.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param customPage dataList + * @param integer currentCount 当前页记录数量 + * @param integer totalCount 总记录数量 + * @param integer totalPage 总页数 + */ + + listAvailableCustomPages (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling listAvailableCustomPages" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 listAvailableCustomPages 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( + '/zones/{zone_identifier}/custom_pages', + '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) + } + ) + } + + /** + * 更新自定义页面URL + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} opts.identifier + * @param {} [opts.url] - 与自定义页面关联的URL。 optional + * @param {} [opts.state] - 自定义页面状态 optional + * @param {string} callback - callback + @return {Object} result + * @param customPage data + */ + + updateCustomPageURL (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling updateCustomPageURL" + ) + } + if (opts.identifier === undefined || opts.identifier === null) { + throw new Error( + "Missing the required parameter 'opts.identifier' when calling updateCustomPageURL" + ) + } + + let postBody = {} + if (opts.url !== undefined && opts.url !== null) { + postBody['url'] = opts.url + } + if (opts.state !== undefined && opts.state !== null) { + postBody['state'] = opts.state + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier, + identifier: opts.identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 updateCustomPageURL 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( + '/zones/{zone_identifier}/custom_pages/{identifier}', + '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) + } + ) + } + + /** + * 列出、搜索和筛选所有自定义SSL证书。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} [opts.status] - 域的自定义SSL的状态 optional + * @param {number} [opts.page] - 分页结果的页码 optional + * @param {number} [opts.per_page] - 每页的域数 optional + * @param {string} [opts.match] - 是否匹配所有搜索要求或至少一个(任何) optional + * @param {string} callback - callback + @return {Object} result + * @param customSSL dataList + */ + + listSSLConfigurations (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling listSSLConfigurations" + ) + } + + let postBody = null + let queryParams = {} + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + if (opts.page !== undefined && opts.page !== null) { + queryParams['page'] = opts.page + } + if (opts.per_page !== undefined && opts.per_page !== null) { + queryParams['per_page'] = opts.per_page + } + if (opts.match !== undefined && opts.match !== null) { + queryParams['match'] = opts.match + } + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 listSSLConfigurations 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( + '/zones/{zone_identifier}/custom_certificates', + '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) + } + ) + } + + /** + * 上载域的新SSL证书 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.certificate] - 域的SSL证书或证书以及中间证书 optional + * @param {} [opts.private_key] - 域的私钥 optional + * @param {} [opts.bundle_method] - 合法值ubiquitous/optimal/force,默认值ubiquitous。 +ubiquitous:SSL泛捆绑在各处有着最高的概率被验证,甚至能被使用过时的或不寻常的信任存储的客户端验证。 +optimal:最佳捆绑使用最短的认证链和最新的中间证书。 +force:强制捆绑会验证证书链,但不以其他方式修改证书链。 + optional + * @param {} [opts.geo_restrictions] optional + * @param {} [opts.ty_pe] - “legacy_custom”类型支持在TLS握手中不包含SNI的传统客户端。 +合法值: +legacy_custom +sni_custom + optional + * @param {string} callback - callback + @return {Object} result + * @param customSSL data + */ + + createSSLConfiguration (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling createSSLConfiguration" + ) + } + + let postBody = {} + if (opts.certificate !== undefined && opts.certificate !== null) { + postBody['certificate'] = opts.certificate + } + if (opts.private_key !== undefined && opts.private_key !== null) { + postBody['private_key'] = opts.private_key + } + if (opts.bundle_method !== undefined && opts.bundle_method !== null) { + postBody['bundle_method'] = opts.bundle_method + } + if (opts.geo_restrictions !== undefined && opts.geo_restrictions !== null) { + postBody['geo_restrictions'] = opts.geo_restrictions + } + if (opts.ty_pe !== undefined && opts.ty_pe !== null) { + postBody['ty_pe'] = opts.ty_pe + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 createSSLConfiguration 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( + '/zones/{zone_identifier}/custom_certificates', + '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) + } + ) + } + + /** + * 上传SSL证书的新私钥和/或PEM/CRT。 +注意,更新sni_custom证书的配置将导致返回新的资源id,并删除之前的资源id。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} opts.identifier + * @param {} [opts.private_key] - 域的私钥 optional + * @param {} [opts.certificate] - 域的SSL证书或证书以及中间证书 optional + * @param {} [opts.bundle_method] - 合法值ubiquitous/optimal/force,默认值ubiquitous。 +ubiquitous:SSL泛捆绑在各处有着最高的概率被验证,甚至能被使用过时的或不寻常的信任存储的客户端验证。 +optimal:最佳捆绑使用最短的认证链和最新的中间证书。 +force:强制捆绑会验证证书链,但不以其他方式修改证书链。 + optional + * @param {} [opts.geo_restrictions] optional + * @param {string} callback - callback + @return {Object} result + * @param customSSL data + */ + + editSSLConfiguration (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling editSSLConfiguration" + ) + } + if (opts.identifier === undefined || opts.identifier === null) { + throw new Error( + "Missing the required parameter 'opts.identifier' when calling editSSLConfiguration" + ) + } + + let postBody = {} + if (opts.private_key !== undefined && opts.private_key !== null) { + postBody['private_key'] = opts.private_key + } + if (opts.certificate !== undefined && opts.certificate !== null) { + postBody['certificate'] = opts.certificate + } + if (opts.bundle_method !== undefined && opts.bundle_method !== null) { + postBody['bundle_method'] = opts.bundle_method + } + if (opts.geo_restrictions !== undefined && opts.geo_restrictions !== null) { + postBody['geo_restrictions'] = opts.geo_restrictions + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier, + identifier: opts.identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 editSSLConfiguration 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( + '/zones/{zone_identifier}/custom_certificates/{identifier}', + 'PATCH', + 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) + } + ) + } + + /** + * 从域中删除SSL证书。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} opts.identifier + * @param {string} callback - callback + @return {Object} result + * @param string data + */ + + deleteSSLConfiguration (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling deleteSSLConfiguration" + ) + } + if (opts.identifier === undefined || opts.identifier === null) { + throw new Error( + "Missing the required parameter 'opts.identifier' when calling deleteSSLConfiguration" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier, + identifier: opts.identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 deleteSSLConfiguration 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( + '/zones/{zone_identifier}/custom_certificates/{identifier}', + '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) + } + ) + } + + /** + * 列出、搜索、排序和筛选域的DNS记录。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} [opts.match] - 是否匹配所有搜索要求或至少一个(任何) optional + * @param {string} [opts.name] - DNS record name optional + * @param {string} [opts.order] - 用于排序的字段 optional + * @param {number} [opts.page] - 分页结果的页码 optional + * @param {number} [opts.per_page] - 每页的DNS记录数 optional + * @param {string} [opts.content] - DNS记录内容 optional + * @param {string} [opts.type] - DNS记录类型 optional + * @param {boolean} [opts.proxied] - DNS记录代理状态 optional + * @param {string} [opts.direction] - asc - 升序;desc - 降序 optional + * @param {string} callback - callback + @return {Object} result + * @param dnsRecord dataList + * @param integer currentCount 当前页记录数量 + * @param integer totalCount 总记录数量 + * @param integer totalPage 总页数 + */ + + listDNSRecords (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling listDNSRecords" + ) + } + + let postBody = null + let queryParams = {} + if (opts.match !== undefined && opts.match !== null) { + queryParams['match'] = opts.match + } + if (opts.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + if (opts.order !== undefined && opts.order !== null) { + queryParams['order'] = opts.order + } + if (opts.page !== undefined && opts.page !== null) { + queryParams['page'] = opts.page + } + if (opts.per_page !== undefined && opts.per_page !== null) { + queryParams['per_page'] = opts.per_page + } + if (opts.content !== undefined && opts.content !== null) { + queryParams['content'] = opts.content + } + if (opts.type !== undefined && opts.type !== null) { + queryParams['type'] = opts.type + } + if (opts.proxied !== undefined && opts.proxied !== null) { + queryParams['proxied'] = opts.proxied + } + if (opts.direction !== undefined && opts.direction !== null) { + queryParams['direction'] = opts.direction + } + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 listDNSRecords 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( + '/zones/{zone_identifier}/dns_records', + '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) + } + ) + } + + /** + * 创建DNS记录 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.ty_pe] - DNS记录类型 optional + * @param {} opts.name - DNS记录名称 + * @param {} opts.content - DNS记录内容 + * @param {} opts.ttl - DNS记录的生存时间。值为1是 "自动"。 + * @param {} [opts.priority] - 与一些记录如MX和SRV一起使用,以确定优先级。如果你没有为MX记录提供一个优先级,默认值为0将被设置。 optional + * @param {} [opts.proxied] - 是否利用星盾的性能和安全优势 optional + * @param {} [opts.srvData] optional + * @param {} [opts.caaData] optional + * @param {string} callback - callback + @return {Object} result + * @param dnsRecord data + */ + + createDNSRecord (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling createDNSRecord" + ) + } + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createDNSRecord" + ) + } + if (opts.content === undefined || opts.content === null) { + throw new Error( + "Missing the required parameter 'opts.content' when calling createDNSRecord" + ) + } + if (opts.ttl === undefined || opts.ttl === null) { + throw new Error( + "Missing the required parameter 'opts.ttl' when calling createDNSRecord" + ) + } + + let postBody = {} + if (opts.ty_pe !== undefined && opts.ty_pe !== null) { + postBody['ty_pe'] = opts.ty_pe + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.content !== undefined && opts.content !== null) { + postBody['content'] = opts.content + } + if (opts.ttl !== undefined && opts.ttl !== null) { + postBody['ttl'] = opts.ttl + } + if (opts.priority !== undefined && opts.priority !== null) { + postBody['priority'] = opts.priority + } + if (opts.proxied !== undefined && opts.proxied !== null) { + postBody['proxied'] = opts.proxied + } + if (opts.srvData !== undefined && opts.srvData !== null) { + postBody['srvData'] = opts.srvData + } + if (opts.caaData !== undefined && opts.caaData !== null) { + postBody['caaData'] = opts.caaData + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 createDNSRecord 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( + '/zones/{zone_identifier}/dns_records', + '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) + } + ) + } + + /** + * updateDNSRecord + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} opts.identifier + * @param {} [opts.ty_pe] - DNS记录类型 optional + * @param {} opts.name - DNS记录名称 + * @param {} opts.content - DNS记录内容 + * @param {} opts.ttl - DNS记录的生存时间。值为1是 "自动"。 + * @param {} [opts.proxied] - 是否利用星盾的性能和安全优势 optional + * @param {} [opts.priority] - 如果是MX记录,该属性是必需的 optional + * @param {} [opts.srvData] optional + * @param {} [opts.caaData] optional + * @param {string} callback - callback + @return {Object} result + * @param dnsRecord data + */ + + updateDNSRecord (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling updateDNSRecord" + ) + } + if (opts.identifier === undefined || opts.identifier === null) { + throw new Error( + "Missing the required parameter 'opts.identifier' when calling updateDNSRecord" + ) + } + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling updateDNSRecord" + ) + } + if (opts.content === undefined || opts.content === null) { + throw new Error( + "Missing the required parameter 'opts.content' when calling updateDNSRecord" + ) + } + if (opts.ttl === undefined || opts.ttl === null) { + throw new Error( + "Missing the required parameter 'opts.ttl' when calling updateDNSRecord" + ) + } + + let postBody = {} + if (opts.ty_pe !== undefined && opts.ty_pe !== null) { + postBody['ty_pe'] = opts.ty_pe + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.content !== undefined && opts.content !== null) { + postBody['content'] = opts.content + } + if (opts.ttl !== undefined && opts.ttl !== null) { + postBody['ttl'] = opts.ttl + } + if (opts.proxied !== undefined && opts.proxied !== null) { + postBody['proxied'] = opts.proxied + } + if (opts.priority !== undefined && opts.priority !== null) { + postBody['priority'] = opts.priority + } + if (opts.srvData !== undefined && opts.srvData !== null) { + postBody['srvData'] = opts.srvData + } + if (opts.caaData !== undefined && opts.caaData !== null) { + postBody['caaData'] = opts.caaData + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier, + identifier: opts.identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 updateDNSRecord 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( + '/zones/{zone_identifier}/dns_records/{identifier}', + '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) + } + ) + } + + /** + * deleteDNSRecord + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} opts.identifier + * @param {string} callback - callback + @return {Object} result + * @param string data + */ + + deleteDNSRecord (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling deleteDNSRecord" + ) + } + if (opts.identifier === undefined || opts.identifier === null) { + throw new Error( + "Missing the required parameter 'opts.identifier' when calling deleteDNSRecord" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier, + identifier: opts.identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 deleteDNSRecord 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( + '/zones/{zone_identifier}/dns_records/{identifier}', + '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.zone_identifier + * @param {} [opts.filters] optional + * @param {string} callback - callback + @return {Object} result + * @param filter dataList + */ + + createFilters (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling createFilters" + ) + } + + let postBody = {} + if (opts.filters !== undefined && opts.filters !== null) { + postBody['filters'] = opts.filters + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 createFilters 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( + '/zones/{zone_identifier}/filters', + '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.zone_identifier + * @param {string} opts.id + * @param {} [opts.expression] - 要使用的筛选器表达式 optional + * @param {} [opts.paused] - 此筛选器当前是否已暂停 optional + * @param {} [opts.description] - 可用于描述过滤器用途的注释 optional + * @param {} [opts.ref] - 短引用标记,用于快速选择相关规则。 optional + * @param {string} callback - callback + @return {Object} result + * @param filter data + */ + + updateIndividualFilter (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling updateIndividualFilter" + ) + } + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling updateIndividualFilter" + ) + } + + let postBody = {} + if (opts.expression !== undefined && opts.expression !== null) { + postBody['expression'] = opts.expression + } + if (opts.paused !== undefined && opts.paused !== null) { + postBody['paused'] = opts.paused + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.ref !== undefined && opts.ref !== null) { + postBody['ref'] = opts.ref + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 updateIndividualFilter 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( + '/zones/{zone_identifier}/filters/{id}', + '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) + } + ) + } + + /** + * 列出当前定义的所有防火墙规则。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} [opts.id] - 防火墙规则标识符 optional + * @param {string} [opts.description] - 描述中不区分大小写的搜索 optional + * @param {string} [opts.action] - 规则操作上的精确匹配 optional + * @param {boolean} [opts.paused] - 此防火墙规则当前是否已暂停。 optional + * @param {number} [opts.page] - 分页结果的页码 optional + * @param {number} [opts.per_page] - 每页的防火墙规则数 optional + * @param {string} callback - callback + @return {Object} result + * @param firewallRule dataList + * @param integer currentCount 当前页记录数量 + * @param integer totalCount 总记录数量 + * @param integer totalPage 总页数 + */ + + listOfFirewallRules (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling listOfFirewallRules" + ) + } + + let postBody = null + let queryParams = {} + if (opts.id !== undefined && opts.id !== null) { + queryParams['id'] = opts.id + } + if (opts.description !== undefined && opts.description !== null) { + queryParams['description'] = opts.description + } + if (opts.action !== undefined && opts.action !== null) { + queryParams['action'] = opts.action + } + if (opts.paused !== undefined && opts.paused !== null) { + queryParams['paused'] = opts.paused + } + if (opts.page !== undefined && opts.page !== null) { + queryParams['page'] = opts.page + } + if (opts.per_page !== undefined && opts.per_page !== null) { + queryParams['per_page'] = opts.per_page + } + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 listOfFirewallRules 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( + '/zones/{zone_identifier}/firewall$$rules', + '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.zone_identifier + * @param {} [opts.firewallRules] optional + * @param {string} callback - callback + @return {Object} result + * @param firewallRule dataList + * @param integer currentCount 当前页记录数量 + * @param integer totalCount 总记录数量 + * @param integer totalPage 总页数 + */ + + createFirewallRules (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling createFirewallRules" + ) + } + + let postBody = {} + if (opts.firewallRules !== undefined && opts.firewallRules !== null) { + postBody['firewallRules'] = opts.firewallRules + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 createFirewallRules 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( + '/zones/{zone_identifier}/firewall$$rules', + '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.zone_identifier + * @param {string} opts.id + * @param {} [opts.action] - 应用于匹配请求的行动。注意,行动 "log "只适用于企业客户。 optional + * @param {} [opts.filter] optional + * @param {} [opts.products] optional + * @param {} [opts.priority] - 规则的优先级,允许控制处理顺序。一个较小的数字表示高优先级。如果不提供,任何有优先权的规则将在没有优先权的规则之前排序。 optional + * @param {} [opts.paused] - 此防火墙规则当前是否已暂停。 optional + * @param {} [opts.ref] - 短引用标记,用于快速选择相关规则。 optional + * @param {} [opts.action_parameters] optional + * @param {} [opts.description] - 对规则的描述,以帮助识别它。 optional + * @param {string} callback - callback + @return {Object} result + * @param firewallRule data + */ + + updateIndividualFirewallRule (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling updateIndividualFirewallRule" + ) + } + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling updateIndividualFirewallRule" + ) + } + + let postBody = {} + if (opts.action !== undefined && opts.action !== null) { + postBody['action'] = opts.action + } + if (opts.filter !== undefined && opts.filter !== null) { + postBody['filter'] = opts.filter + } + if (opts.products !== undefined && opts.products !== null) { + postBody['products'] = opts.products + } + if (opts.priority !== undefined && opts.priority !== null) { + postBody['priority'] = opts.priority + } + if (opts.paused !== undefined && opts.paused !== null) { + postBody['paused'] = opts.paused + } + if (opts.ref !== undefined && opts.ref !== null) { + postBody['ref'] = opts.ref + } + if ( + opts.action_parameters !== undefined && + opts.action_parameters !== null + ) { + postBody['action_parameters'] = opts.action_parameters + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 updateIndividualFirewallRule 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( + '/zones/{zone_identifier}/firewall$$rules/{id}', + '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) + } + ) + } + + /** + * 删除现有防火墙规则。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} opts.id + * @param {boolean} [opts.delete_filter_if_unused] optional + * @param {string} callback - callback + @return {Object} result + * @param firewallRule data + */ + + deleteIndividualFirewallRules (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling deleteIndividualFirewallRules" + ) + } + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling deleteIndividualFirewallRules" + ) + } + + let postBody = null + let queryParams = {} + if ( + opts.delete_filter_if_unused !== undefined && + opts.delete_filter_if_unused !== null + ) { + queryParams['delete_filter_if_unused'] = opts.delete_filter_if_unused + } + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier, + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 deleteIndividualFirewallRules 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( + '/zones/{zone_identifier}/firewall$$rules/{id}', + '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) + } + ) + } + + /** + * 查询Bot开启状态 + * @param {Object} opts - parameters + * @param {string} opts.zoneId + * @param {string} callback - callback + @return {Object} result + * @param string zoneId zone id + * @param string instanceId 套餐实例id + * @param string subscriptionType 订阅类型 + * @param string subscriptionId 订阅id + * @param string switchStatus 开关状态 + */ + + describeBotStatus (opts, callback) { + opts = opts || {} + + if (opts.zoneId === undefined || opts.zoneId === null) { + throw new Error( + "Missing the required parameter 'opts.zoneId' when calling describeBotStatus" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zoneId: opts.zoneId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 describeBotStatus 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( + '/bot/{zoneId}', + '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) + } + ) + } + + /** + * 开启BOT + * @param {Object} opts - parameters + * @param {string} opts.zoneId + * @param {string} callback - callback + @return {Object} result + * @param boolean success 操作是否成功 + */ + + openFirewallBot (opts, callback) { + opts = opts || {} + + if (opts.zoneId === undefined || opts.zoneId === null) { + throw new Error( + "Missing the required parameter 'opts.zoneId' when calling openFirewallBot" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zoneId: opts.zoneId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 openFirewallBot 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( + '/bot/{zoneId}', + '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) + } + ) + } + + /** + * 关闭BOT + * @param {Object} opts - parameters + * @param {string} opts.zoneId + * @param {string} callback - callback + @return {Object} result + * @param boolean success 操作是否成功 + */ + + closeFirewallBot (opts, callback) { + opts = opts || {} + + if (opts.zoneId === undefined || opts.zoneId === null) { + throw new Error( + "Missing the required parameter 'opts.zoneId' when calling closeFirewallBot" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zoneId: opts.zoneId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 closeFirewallBot 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( + '/bot/{zoneId}', + '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.pageSize] - 页容量,默认10, 范围(1-100) optional + * @param {integer} [opts.pageNumber] - 页序号,默认1,不能小于1 optional + * @param {string} [opts.instanceName] - 实例名称 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param describeInstancesRes dataList + * @param integer currentCount 当前页记录数量 + * @param integer totalCount 总记录数量 + * @param integer totalPage 总页数 + */ + + 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.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + queryParams['pageNumber'] = opts.pageNumber + } + if (opts.instanceName !== undefined && opts.instanceName !== null) { + queryParams['instanceName'] = opts.instanceName + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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}/instances', + '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 {} [opts.chargeMode] - 计费模式(CONFIG、FLOW、MONTHLY、ONCE) +CONFIG 按配置 +FLOW 按用量 +MONTHLY 包年包月 +ONCE 一次性 + optional + * @param {} [opts.packType] - 套餐类型(BASIC、PROFESSIONAL、ENTERPRISE、ULTIMATE、SMB_EXPERIENCE、SMB_BASIC、SMB_BUSINESS) +BASIC 包年包月 基础版 +PROFESSIONAL 包年包月 专业版 +ENTERPRISE 包年包月 企业版 +ULTIMATE 包年包月 旗舰版 +-------------------------- +SMB_EXPERIENCE 按流量 体验版 +SMB_BASIC 按流量 基础版 +SMB_BUSINESS 按流量 商业版 + optional + * @param {} [opts.zonePackNum] - 域名增量包数量 optional + * @param {} [opts.duration] - 计费时长 optional + * @param {} [opts.durationUnit] - 计费时长单位(MONTH、YEAR) optional + * @param {} [opts.autoRenewStatus] - 自动续费状态(OPEN->开通自动续费 CLOSE->关闭自动续费) optional + * @param {} [opts.instanceName] - 实例名称 optional + * @param {} [opts.memo] - 备注 optional + * @param {} [opts.returnUrl] - 支付成功返回路径 optional + * @param {} [opts.buyScenario] - 购买上下文JSON字符串 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string buyId 购买ID,可通过调用describeInstanceByOrderNo接口获取实例详情 + */ + + createInstance (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 createInstance" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.chargeMode !== undefined && opts.chargeMode !== null) { + postBody['chargeMode'] = opts.chargeMode + } + if (opts.packType !== undefined && opts.packType !== null) { + postBody['packType'] = opts.packType + } + if (opts.zonePackNum !== undefined && opts.zonePackNum !== null) { + postBody['zonePackNum'] = opts.zonePackNum + } + if (opts.duration !== undefined && opts.duration !== null) { + postBody['duration'] = opts.duration + } + if (opts.durationUnit !== undefined && opts.durationUnit !== null) { + postBody['durationUnit'] = opts.durationUnit + } + if (opts.autoRenewStatus !== undefined && opts.autoRenewStatus !== null) { + postBody['autoRenewStatus'] = opts.autoRenewStatus + } + if (opts.instanceName !== undefined && opts.instanceName !== null) { + postBody['instanceName'] = opts.instanceName + } + if (opts.memo !== undefined && opts.memo !== null) { + postBody['memo'] = opts.memo + } + if (opts.returnUrl !== undefined && opts.returnUrl !== null) { + postBody['returnUrl'] = opts.returnUrl + } + if (opts.buyScenario !== undefined && opts.buyScenario !== null) { + postBody['buyScenario'] = opts.buyScenario + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 createInstance 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}/instances', + '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 - 实例ID + * @param {} [opts.fixedFlowPackType] - 定量流量包类型(1->10TB 2->50TB 3->200TB 4->1PB 5->5PB) optional + * @param {} [opts.fixedFlowPackNum] - 定量流量包数量 optional + * @param {} [opts.flowPackNum] - 按需购买流量包数量 optional + * @param {} [opts.returnUrl] - 支付成功返回路径 optional + * @param {} [opts.buyScenario] - 购买上下文JSON字符串 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string buyId 购买ID,购买ID,可通过调用describeInstanceByOrderNo接口获取流量包实例详情 + */ + + createFlowPack (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 createFlowPack" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createFlowPack" + ) + } + + let postBody = {} + if ( + opts.fixedFlowPackType !== undefined && + opts.fixedFlowPackType !== null + ) { + postBody['fixedFlowPackType'] = opts.fixedFlowPackType + } + if (opts.fixedFlowPackNum !== undefined && opts.fixedFlowPackNum !== null) { + postBody['fixedFlowPackNum'] = opts.fixedFlowPackNum + } + if (opts.flowPackNum !== undefined && opts.flowPackNum !== null) { + postBody['flowPackNum'] = opts.flowPackNum + } + if (opts.returnUrl !== undefined && opts.returnUrl !== null) { + postBody['returnUrl'] = opts.returnUrl + } + if (opts.buyScenario !== undefined && opts.buyScenario !== null) { + postBody['buyScenario'] = opts.buyScenario + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 createFlowPack 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}/instances/{instanceId}/flowPack', + '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 - 实例ID + * @param {} [opts.packType] - 套餐类型 optional + * @param {} [opts.zonePackNum] - 域名增量包数量 optional + * @param {} [opts.returnUrl] - 支付成功后返回到该路径 optional + * @param {} [opts.buyScenario] - 购买上下文JSON字符串 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string buyId 购买ID + */ + + 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" + ) + } + + let postBody = {} + if (opts.packType !== undefined && opts.packType !== null) { + postBody['packType'] = opts.packType + } + if (opts.zonePackNum !== undefined && opts.zonePackNum !== null) { + postBody['zonePackNum'] = opts.zonePackNum + } + if (opts.returnUrl !== undefined && opts.returnUrl !== null) { + postBody['returnUrl'] = opts.returnUrl + } + if (opts.buyScenario !== undefined && opts.buyScenario !== null) { + postBody['buyScenario'] = opts.buyScenario + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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}/instance/{instanceId}', + '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) + } + ) + } + + /** + * 根据订单号查询套餐实例详情 + * @param {Object} opts - parameters + * @param {string} opts.orderNumber + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param describeInstancesRes describeInstancesRes + */ + + describeInstanceByOrderNo (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 describeInstanceByOrderNo" + ) + } + + opts = opts || {} + + if (opts.orderNumber === undefined || opts.orderNumber === null) { + throw new Error( + "Missing the required parameter 'opts.orderNumber' when calling describeInstanceByOrderNo" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + orderNumber: opts.orderNumber + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 describeInstanceByOrderNo 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}/instance/{orderNumber}/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) + } + ) + } + + /** + * 套餐实例续费回调查询 + * @param {Object} opts - parameters + * @param {string} opts.resourceList - 资源列表 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param object data + */ + + selectDetailList (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 selectDetailList" + ) + } + + opts = opts || {} + + if (opts.resourceList === undefined || opts.resourceList === null) { + throw new Error( + "Missing the required parameter 'opts.resourceList' when calling selectDetailList" + ) + } + + let postBody = null + let queryParams = {} + if (opts.resourceList !== undefined && opts.resourceList !== null) { + queryParams['resourceList'] = opts.resourceList + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 selectDetailList 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}/instances:selectDetailList', + '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.instanceName - 实例名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + checkInstancesName (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 checkInstancesName" + ) + } + + opts = opts || {} + + if (opts.instanceName === undefined || opts.instanceName === null) { + throw new Error( + "Missing the required parameter 'opts.instanceName' when calling checkInstancesName" + ) + } + + let postBody = null + let queryParams = {} + if (opts.instanceName !== undefined && opts.instanceName !== null) { + queryParams['instanceName'] = opts.instanceName + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 checkInstancesName 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}/instances:checkName', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string jdcloudCidrs + */ + + ips (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 ips" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 ips 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}/ips', + '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 {} [opts.buyId] - 购买ID optional + * @param {} [opts.autoPay] - 自动支付标识,当为true,才会发生自动支付,后付费的订单直接支付0元,预付费的订单(余额+代金劵)> 订单应付金额,成功,否则支付失败 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string orderNumber 订单号 + * @param boolean autoPay 自动支付标识 + * @param string message 下单结果消息 + */ + + submitOrder (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 submitOrder" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.buyId !== undefined && opts.buyId !== null) { + postBody['buyId'] = opts.buyId + } + if (opts.autoPay !== undefined && opts.autoPay !== null) { + postBody['autoPay'] = opts.autoPay + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 submitOrder 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}/instances:submitOrder', + '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) + } + ) + } + + /** + * 平均峰值带宽。查询范围最近6个月、查询最大跨度1个月。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例标识 + * @param {} opts.queryMode - all - 所有 +normal - 业务 +mitigation - 缓解 +cache - 缓存 +origin - 回源 + + * @param {} opts.since - 查询开始时间 + * @param {} opts.until - 查询结束时间 + * @param {string} callback - callback + @return {Object} result + * @param cdnSingleMetric cdnSingleMetric + */ + + instanceBandwidthAvg (opts, callback) { + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling instanceBandwidthAvg" + ) + } + if (opts.queryMode === undefined || opts.queryMode === null) { + throw new Error( + "Missing the required parameter 'opts.queryMode' when calling instanceBandwidthAvg" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling instanceBandwidthAvg" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling instanceBandwidthAvg" + ) + } + + let postBody = {} + if (opts.queryMode !== undefined && opts.queryMode !== null) { + postBody['queryMode'] = opts.queryMode + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 instanceBandwidthAvg 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( + '/instances/{instanceId}/instanceBandwidthAvg', + '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) + } + ) + } + + /** + * 带宽峰值。查询范围最近6个月、查询最大跨度1个月。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例标识 + * @param {} opts.queryMode - all - 所有 +normal - 业务 +mitigation - 缓解 +cache - 缓存 +origin - 回源 + + * @param {} opts.since - 查询开始时间 + * @param {} opts.until - 查询结束时间 + * @param {string} callback - callback + @return {Object} result + * @param cdnBandwidthMax cdnBandwidthMax + */ + + instanceBandwidthMax (opts, callback) { + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling instanceBandwidthMax" + ) + } + if (opts.queryMode === undefined || opts.queryMode === null) { + throw new Error( + "Missing the required parameter 'opts.queryMode' when calling instanceBandwidthMax" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling instanceBandwidthMax" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling instanceBandwidthMax" + ) + } + + let postBody = {} + if (opts.queryMode !== undefined && opts.queryMode !== null) { + postBody['queryMode'] = opts.queryMode + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 instanceBandwidthMax 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( + '/instances/{instanceId}/instanceBandwidthMax', + '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) + } + ) + } + + /** + * 95峰值带宽。查询范围最近6个月、查询最大跨度1个月。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例标识 + * @param {} opts.queryMode - all - 所有 +normal - 业务 +mitigation - 缓解 +cache - 缓存 +origin - 回源 + + * @param {} opts.since - 查询开始时间 + * @param {} opts.until - 查询结束时间 + * @param {string} callback - callback + @return {Object} result + * @param cdnSingleMetric cdnSingleMetric + */ + + instanceBandwidthP95 (opts, callback) { + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling instanceBandwidthP95" + ) + } + if (opts.queryMode === undefined || opts.queryMode === null) { + throw new Error( + "Missing the required parameter 'opts.queryMode' when calling instanceBandwidthP95" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling instanceBandwidthP95" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling instanceBandwidthP95" + ) + } + + let postBody = {} + if (opts.queryMode !== undefined && opts.queryMode !== null) { + postBody['queryMode'] = opts.queryMode + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 instanceBandwidthP95 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( + '/instances/{instanceId}/instanceBandwidthP95', + '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) + } + ) + } + + /** + * 带宽图。查询范围最近6个月、查询最大跨度1个月。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例标识 + * @param {} opts.queryMode - all - 所有 +normal - 业务 +mitigation - 缓解 +cache - 缓存 +origin - 回源 + + * @param {} opts.since - 查询开始时间 + * @param {} opts.until - 查询结束时间 + * @param {string} callback - callback + @return {Object} result + * @param simpleDateHistogram data + */ + + instanceBandwidthDateHistogram (opts, callback) { + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling instanceBandwidthDateHistogram" + ) + } + if (opts.queryMode === undefined || opts.queryMode === null) { + throw new Error( + "Missing the required parameter 'opts.queryMode' when calling instanceBandwidthDateHistogram" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling instanceBandwidthDateHistogram" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling instanceBandwidthDateHistogram" + ) + } + + let postBody = {} + if (opts.queryMode !== undefined && opts.queryMode !== null) { + postBody['queryMode'] = opts.queryMode + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 instanceBandwidthDateHistogram 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( + '/instances/{instanceId}/instanceBandwidthDateHistogram', + '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) + } + ) + } + + /** + * 多指标的带宽图。查询范围最近6个月、查询最大跨度1个月。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例标识 + * @param {} opts.queryModes - all - 所有 +normal - 业务 +mitigation - 缓解 +cache - 缓存 +origin - 回源 +all/normal/mitigation/cache/origin的任意组合 + + * @param {} opts.since - 查询开始时间 + * @param {} opts.until - 查询结束时间 + * @param {string} callback - callback + @return {Object} result + * @param dateHistogram dateHistograms + * @param number timeScope + * @param string since + * @param string util + */ + + instanceBandwidthMultiDateHistogram (opts, callback) { + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling instanceBandwidthMultiDateHistogram" + ) + } + if (opts.queryModes === undefined || opts.queryModes === null) { + throw new Error( + "Missing the required parameter 'opts.queryModes' when calling instanceBandwidthMultiDateHistogram" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling instanceBandwidthMultiDateHistogram" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling instanceBandwidthMultiDateHistogram" + ) + } + + let postBody = {} + if (opts.queryModes !== undefined && opts.queryModes !== null) { + postBody['queryModes'] = opts.queryModes + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 instanceBandwidthMultiDateHistogram 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( + '/instances/{instanceId}/instanceBandwidthMultiDateHistogram', + '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) + } + ) + } + + /** + * TopK域名的带宽图。查询范围最近6个月、查询最大跨度1个月。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例标识 + * @param {} opts.queryMode - all - 所有 +normal - 业务 +mitigation - 缓解 +cache - 缓存 +origin - 回源 + + * @param {} opts.since - 查询开始时间 + * @param {} opts.until - 查询结束时间 + * @param {string} callback - callback + @return {Object} result + * @param dateHistogram dateHistograms + * @param number timeScope + * @param string since + * @param string util + */ + + bandwidthDateHistogramTopK (opts, callback) { + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling bandwidthDateHistogramTopK" + ) + } + if (opts.queryMode === undefined || opts.queryMode === null) { + throw new Error( + "Missing the required parameter 'opts.queryMode' when calling bandwidthDateHistogramTopK" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling bandwidthDateHistogramTopK" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling bandwidthDateHistogramTopK" + ) + } + + let postBody = {} + if (opts.queryMode !== undefined && opts.queryMode !== null) { + postBody['queryMode'] = opts.queryMode + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 bandwidthDateHistogramTopK 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( + '/instances/{instanceId}/bandwidthDateHistogramTopK', + '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) + } + ) + } + + /** + * 按域名的TopK峰值带宽。查询范围最近6个月、查询最大跨度1个月。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例标识 + * @param {} opts.queryMode - all - 所有 +normal - 业务 +mitigation - 缓解 +cache - 缓存 +origin - 回源 + + * @param {} opts.since - 查询开始时间 + * @param {} opts.until - 查询结束时间 + * @param {string} callback - callback + @return {Object} result + * @param topK data + */ + + bandwidthTopK (opts, callback) { + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling bandwidthTopK" + ) + } + if (opts.queryMode === undefined || opts.queryMode === null) { + throw new Error( + "Missing the required parameter 'opts.queryMode' when calling bandwidthTopK" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling bandwidthTopK" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling bandwidthTopK" + ) + } + + let postBody = {} + if (opts.queryMode !== undefined && opts.queryMode !== null) { + postBody['queryMode'] = opts.queryMode + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 bandwidthTopK 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( + '/instances/{instanceId}/bandwidthTopK', + '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) + } + ) + } + + /** + * 域名带宽列表,按带宽降序排列。查询范围最近6个月、查询最大跨度1个月。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例标识 + * @param {} opts.queryMode - all - 所有 +normal - 业务 +mitigation - 缓解 +cache - 缓存 +origin - 回源 + + * @param {} opts.since - 查询开始时间 + * @param {} opts.until - 查询结束时间 + * @param {} opts.pageNumber - 页码。当页码为-1时,返回所有记录 + * @param {} [opts.pageSize] - 每页显示记录数。当pageNumber的值大于0时,该字段必须赋值 optional + * @param {string} callback - callback + @return {Object} result + * @param number total + * @param cdnZoneBandwidth cdnZoneBandwidths + */ + + instanceBandwidthList (opts, callback) { + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling instanceBandwidthList" + ) + } + if (opts.queryMode === undefined || opts.queryMode === null) { + throw new Error( + "Missing the required parameter 'opts.queryMode' when calling instanceBandwidthList" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling instanceBandwidthList" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling instanceBandwidthList" + ) + } + if (opts.pageNumber === undefined || opts.pageNumber === null) { + throw new Error( + "Missing the required parameter 'opts.pageNumber' when calling instanceBandwidthList" + ) + } + + let postBody = {} + if (opts.queryMode !== undefined && opts.queryMode !== null) { + postBody['queryMode'] = opts.queryMode + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 instanceBandwidthList 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( + '/instances/{instanceId}/instanceBandwidthList', + '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) + } + ) + } + + /** + * 总流量。查询范围最近6个月、查询最大跨度1个月。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例标识 + * @param {} opts.queryMode - all - 所有 +normal - 业务 +mitigation - 缓解 +cache - 缓存 +origin - 回源 + + * @param {} opts.since - 查询开始时间 + * @param {} opts.until - 查询结束时间 + * @param {string} callback - callback + @return {Object} result + * @param cdnSingleMetric cdnSingleMetric + */ + + instanceTrafficSum (opts, callback) { + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling instanceTrafficSum" + ) + } + if (opts.queryMode === undefined || opts.queryMode === null) { + throw new Error( + "Missing the required parameter 'opts.queryMode' when calling instanceTrafficSum" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling instanceTrafficSum" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling instanceTrafficSum" + ) + } + + let postBody = {} + if (opts.queryMode !== undefined && opts.queryMode !== null) { + postBody['queryMode'] = opts.queryMode + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 instanceTrafficSum 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( + '/instances/{instanceId}/instanceTrafficSum', + '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) + } + ) + } + + /** + * 流量图。查询范围最近6个月、查询最大跨度1个月。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例标识 + * @param {} opts.queryMode - all - 所有 +normal - 业务 +mitigation - 缓解 +cache - 缓存 +origin - 回源 + + * @param {} opts.since - 查询开始时间 + * @param {} opts.until - 查询结束时间 + * @param {string} callback - callback + @return {Object} result + * @param simpleDateHistogram data + */ + + instanceTrafficDateHistogram (opts, callback) { + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling instanceTrafficDateHistogram" + ) + } + if (opts.queryMode === undefined || opts.queryMode === null) { + throw new Error( + "Missing the required parameter 'opts.queryMode' when calling instanceTrafficDateHistogram" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling instanceTrafficDateHistogram" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling instanceTrafficDateHistogram" + ) + } + + let postBody = {} + if (opts.queryMode !== undefined && opts.queryMode !== null) { + postBody['queryMode'] = opts.queryMode + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 instanceTrafficDateHistogram 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( + '/instances/{instanceId}/instanceTrafficDateHistogram', + '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) + } + ) + } + + /** + * 多指标的流量图。查询范围最近6个月、查询最大跨度1个月。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例标识 + * @param {} opts.queryModes - all - 所有 +normal - 业务 +mitigation - 缓解 +cache - 缓存 +origin - 回源 +all/normal/mitigation/cache/origin的任意组合 + + * @param {} opts.since - 查询开始时间 + * @param {} opts.until - 查询结束时间 + * @param {string} callback - callback + @return {Object} result + * @param dateHistogram dateHistograms + * @param number timeScope + * @param string since + * @param string util + */ + + instanceTrafficMultiDateHistogram (opts, callback) { + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling instanceTrafficMultiDateHistogram" + ) + } + if (opts.queryModes === undefined || opts.queryModes === null) { + throw new Error( + "Missing the required parameter 'opts.queryModes' when calling instanceTrafficMultiDateHistogram" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling instanceTrafficMultiDateHistogram" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling instanceTrafficMultiDateHistogram" + ) + } + + let postBody = {} + if (opts.queryModes !== undefined && opts.queryModes !== null) { + postBody['queryModes'] = opts.queryModes + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 instanceTrafficMultiDateHistogram 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( + '/instances/{instanceId}/instanceTrafficMultiDateHistogram', + '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) + } + ) + } + + /** + * TopK域名的流量图。查询范围最近6个月、查询最大跨度1个月。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例标识 + * @param {} opts.queryMode - all - 所有 +normal - 业务 +mitigation - 缓解 +cache - 缓存 +origin - 回源 + + * @param {} opts.since - 查询开始时间 + * @param {} opts.until - 查询结束时间 + * @param {string} callback - callback + @return {Object} result + * @param dateHistogram dateHistograms + * @param number timeScope + * @param string since + * @param string util + */ + + trafficDateHistogramTopK (opts, callback) { + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling trafficDateHistogramTopK" + ) + } + if (opts.queryMode === undefined || opts.queryMode === null) { + throw new Error( + "Missing the required parameter 'opts.queryMode' when calling trafficDateHistogramTopK" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling trafficDateHistogramTopK" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling trafficDateHistogramTopK" + ) + } + + let postBody = {} + if (opts.queryMode !== undefined && opts.queryMode !== null) { + postBody['queryMode'] = opts.queryMode + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 trafficDateHistogramTopK 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( + '/instances/{instanceId}/trafficDateHistogramTopK', + '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) + } + ) + } + + /** + * 按域名的TopK总流量。查询范围最近6个月、查询最大跨度1个月。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例标识 + * @param {} opts.queryMode - all - 所有 +normal - 业务 +mitigation - 缓解 +cache - 缓存 +origin - 回源 + + * @param {} opts.since - 查询开始时间 + * @param {} opts.until - 查询结束时间 + * @param {string} callback - callback + @return {Object} result + * @param topK data + */ + + trafficTopK (opts, callback) { + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling trafficTopK" + ) + } + if (opts.queryMode === undefined || opts.queryMode === null) { + throw new Error( + "Missing the required parameter 'opts.queryMode' when calling trafficTopK" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling trafficTopK" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling trafficTopK" + ) + } + + let postBody = {} + if (opts.queryMode !== undefined && opts.queryMode !== null) { + postBody['queryMode'] = opts.queryMode + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 trafficTopK 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( + '/instances/{instanceId}/trafficTopK', + '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) + } + ) + } + + /** + * 总请求量。查询范围最近6个月、查询最大跨度1个月。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例标识 + * @param {} opts.queryMode - all - 所有 +normal - 业务 +mitigation - 缓解 +cache - 缓存 +origin - 回源 + + * @param {} opts.since - 查询开始时间 + * @param {} opts.until - 查询结束时间 + * @param {string} callback - callback + @return {Object} result + * @param cdnSingleMetric cdnSingleMetric + */ + + instanceRequestSum (opts, callback) { + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling instanceRequestSum" + ) + } + if (opts.queryMode === undefined || opts.queryMode === null) { + throw new Error( + "Missing the required parameter 'opts.queryMode' when calling instanceRequestSum" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling instanceRequestSum" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling instanceRequestSum" + ) + } + + let postBody = {} + if (opts.queryMode !== undefined && opts.queryMode !== null) { + postBody['queryMode'] = opts.queryMode + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 instanceRequestSum 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( + '/instances/{instanceId}/instanceRequestSum', + '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) + } + ) + } + + /** + * 请求量图。查询范围最近6个月、查询最大跨度1个月。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例标识 + * @param {} opts.queryMode - all - 所有 +normal - 业务 +mitigation - 缓解 +cache - 缓存 +origin - 回源 + + * @param {} opts.since - 查询开始时间 + * @param {} opts.until - 查询结束时间 + * @param {string} callback - callback + @return {Object} result + * @param simpleDateHistogram data + */ + + instanceRequestDateHistogram (opts, callback) { + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling instanceRequestDateHistogram" + ) + } + if (opts.queryMode === undefined || opts.queryMode === null) { + throw new Error( + "Missing the required parameter 'opts.queryMode' when calling instanceRequestDateHistogram" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling instanceRequestDateHistogram" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling instanceRequestDateHistogram" + ) + } + + let postBody = {} + if (opts.queryMode !== undefined && opts.queryMode !== null) { + postBody['queryMode'] = opts.queryMode + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 instanceRequestDateHistogram 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( + '/instances/{instanceId}/instanceRequestDateHistogram', + '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) + } + ) + } + + /** + * 多指标的请求量图。查询范围最近6个月、查询最大跨度1个月。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例标识 + * @param {} opts.queryModes - all - 所有 +normal - 业务 +mitigation - 缓解 +cache - 缓存 +origin - 回源 +all/normal/mitigation/cache/origin的任意组合 + + * @param {} opts.since - 查询开始时间 + * @param {} opts.until - 查询结束时间 + * @param {string} callback - callback + @return {Object} result + * @param dateHistogram dateHistograms + * @param number timeScope + * @param string since + * @param string util + */ + + instanceRequestMultiDateHistogram (opts, callback) { + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling instanceRequestMultiDateHistogram" + ) + } + if (opts.queryModes === undefined || opts.queryModes === null) { + throw new Error( + "Missing the required parameter 'opts.queryModes' when calling instanceRequestMultiDateHistogram" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling instanceRequestMultiDateHistogram" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling instanceRequestMultiDateHistogram" + ) + } + + let postBody = {} + if (opts.queryModes !== undefined && opts.queryModes !== null) { + postBody['queryModes'] = opts.queryModes + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 instanceRequestMultiDateHistogram 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( + '/instances/{instanceId}/instanceRequestMultiDateHistogram', + '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) + } + ) + } + + /** + * TopK域名的请求量图。查询范围最近6个月、查询最大跨度1个月。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例标识 + * @param {} opts.queryMode - all - 所有 +normal - 业务 +mitigation - 缓解 +cache - 缓存 +origin - 回源 + + * @param {} opts.since - 查询开始时间 + * @param {} opts.until - 查询结束时间 + * @param {string} callback - callback + @return {Object} result + * @param dateHistogram dateHistograms + * @param number timeScope + * @param string since + * @param string util + */ + + requestDateHistogramTopK (opts, callback) { + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling requestDateHistogramTopK" + ) + } + if (opts.queryMode === undefined || opts.queryMode === null) { + throw new Error( + "Missing the required parameter 'opts.queryMode' when calling requestDateHistogramTopK" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling requestDateHistogramTopK" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling requestDateHistogramTopK" + ) + } + + let postBody = {} + if (opts.queryMode !== undefined && opts.queryMode !== null) { + postBody['queryMode'] = opts.queryMode + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 requestDateHistogramTopK 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( + '/instances/{instanceId}/requestDateHistogramTopK', + '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) + } + ) + } + + /** + * 按域名的TopK总请求量。查询范围最近6个月、查询最大跨度1个月。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例标识 + * @param {} opts.queryMode - all - 所有 +normal - 业务 +mitigation - 缓解 +cache - 缓存 +origin - 回源 + + * @param {} opts.since - 查询开始时间 + * @param {} opts.until - 查询结束时间 + * @param {string} callback - callback + @return {Object} result + * @param topK data + */ + + requestTopK (opts, callback) { + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling requestTopK" + ) + } + if (opts.queryMode === undefined || opts.queryMode === null) { + throw new Error( + "Missing the required parameter 'opts.queryMode' when calling requestTopK" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling requestTopK" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling requestTopK" + ) + } + + let postBody = {} + if (opts.queryMode !== undefined && opts.queryMode !== null) { + postBody['queryMode'] = opts.queryMode + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 requestTopK 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( + '/instances/{instanceId}/requestTopK', + '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.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param logpushJob dataList + */ + + listLogpushJobs (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling listLogpushJobs" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 listLogpushJobs 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( + '/zones/{zone_identifier}/logpush$$jobs', + '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.zone_identifier + * @param {} [opts.zone_name] - 域名 optional + * @param {} [opts.destination_conf] - 唯一标识数据推送目的地的字符串。可能包括目的地支持的其他参数。 +例如:splunk://splunk.cf-analytics.com:8088/services/collector/raw?channel=xxx&header_Authorization=Splunk xxx&sourcetype=xxx&insecure-skip-verify=false + optional + * @param {} [opts.name] - 可选的用户可读的作业名称。不是独一无二的。使用户更容易识别工作。建议包含域名称。 optional + * @param {} [opts.enabled] - 默认值false optional + * @param {} [opts.dataset] - 要推送的数据集。合法值为:http/firewall。 optional + * @param {} [opts.logpull_options] - 它指定了诸如请求的字段和时间戳格式之类的内容。例如:fields=fieldName1,fieldName2,fileNamek&timestamps=rfc3339&sample=0.1 optional + * @param {string} callback - callback + @return {Object} result + * @param logpushJob data + */ + + createLogpushJob (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling createLogpushJob" + ) + } + + let postBody = {} + if (opts.zone_name !== undefined && opts.zone_name !== null) { + postBody['zone_name'] = opts.zone_name + } + if (opts.destination_conf !== undefined && opts.destination_conf !== null) { + postBody['destination_conf'] = opts.destination_conf + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.enabled !== undefined && opts.enabled !== null) { + postBody['enabled'] = opts.enabled + } + if (opts.dataset !== undefined && opts.dataset !== null) { + postBody['dataset'] = opts.dataset + } + if (opts.logpull_options !== undefined && opts.logpull_options !== null) { + postBody['logpull_options'] = opts.logpull_options + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 createLogpushJob 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( + '/zones/{zone_identifier}/logpush$$jobs', + '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.zone_identifier + * @param {string} opts.dataset + * @param {string} callback - callback + @return {Object} result + * @param logModule dataList + */ + + fields (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling fields" + ) + } + if (opts.dataset === undefined || opts.dataset === null) { + throw new Error( + "Missing the required parameter 'opts.dataset' when calling fields" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier, + dataset: opts.dataset + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 fields 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( + '/zones/{zone_identifier}/logpush$$datasets/{dataset}/fields', + '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.zone_identifier + * @param {string} opts.dataset + * @param {string} callback - callback + @return {Object} result + * @param logModule dataList + */ + + fieldsDefault (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling fieldsDefault" + ) + } + if (opts.dataset === undefined || opts.dataset === null) { + throw new Error( + "Missing the required parameter 'opts.dataset' when calling fieldsDefault" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier, + dataset: opts.dataset + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 fieldsDefault 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( + '/zones/{zone_identifier}/logpush$$datasets/{dataset}/fieldsDefault', + '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.zone_identifier + * @param {string} opts.job_identifier + * @param {} [opts.enabled] optional + * @param {} [opts.logpull_options] - 它指定了诸如请求的字段和时间戳格式之类的内容。例如:fields=fieldName1,fieldName2,fileNamek&timestamps=rfc3339&sample=0.1 optional + * @param {} [opts.destination_conf] - 唯一标识数据推送目的地的字符串。可能包括目的地支持的其他参数。 optional + * @param {string} callback - callback + @return {Object} result + * @param logpushJob data + */ + + updateLogpushJob (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling updateLogpushJob" + ) + } + if (opts.job_identifier === undefined || opts.job_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.job_identifier' when calling updateLogpushJob" + ) + } + + let postBody = {} + if (opts.enabled !== undefined && opts.enabled !== null) { + postBody['enabled'] = opts.enabled + } + if (opts.logpull_options !== undefined && opts.logpull_options !== null) { + postBody['logpull_options'] = opts.logpull_options + } + if (opts.destination_conf !== undefined && opts.destination_conf !== null) { + postBody['destination_conf'] = opts.destination_conf + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier, + job_identifier: opts.job_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 updateLogpushJob 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( + '/zones/{zone_identifier}/logpush$$jobs/{job_identifier}', + '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) + } + ) + } + + /** + * 删除日志推送作业 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} opts.job_identifier + * @param {string} callback - callback + @return {Object} result + * @param logpushJob data + */ + + deleteLogpushJob (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling deleteLogpushJob" + ) + } + if (opts.job_identifier === undefined || opts.job_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.job_identifier' when calling deleteLogpushJob" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier, + job_identifier: opts.job_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 deleteLogpushJob 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( + '/zones/{zone_identifier}/logpush$$jobs/{job_identifier}', + '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.zone_identifier + * @param {} [opts.destination_conf] - 唯一标识数据推送目的地的字符串。可能包括目的地支持的其他参数。 +例如:splunk://splunk.cf-analytics.com:8088/services/collector/raw?channel=xxx&header_Authorization=Splunk xxx&sourcetype=xxx&insecure-skip-verify=false + optional + * @param {string} callback - callback + @return {Object} result + * @param boolean data + */ + + checkDestinationExists (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling checkDestinationExists" + ) + } + + let postBody = {} + if (opts.destination_conf !== undefined && opts.destination_conf !== null) { + postBody['destination_conf'] = opts.destination_conf + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 checkDestinationExists 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( + '/zones/{zone_identifier}/logpush$$validate$$destination$$exists', + '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.pageSize] - 页容量,默认10, 范围(1-100) optional + * @param {integer} [opts.pageNumber] - 页序号,默认1,不能小于1 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param describePackRes dataList + * @param integer currentCount 当前页记录数量 + * @param integer totalCount 总记录数量 + * @param integer totalPage 总页数 + */ + + describePackages (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 describePackages" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + queryParams['pageNumber'] = opts.pageNumber + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 describePackages 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}/packages', + '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.packType - 套餐类型 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param describePackRes describePackRes + */ + + describePackage (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 describePackage" + ) + } + + opts = opts || {} + + if (opts.packType === undefined || opts.packType === null) { + throw new Error( + "Missing the required parameter 'opts.packType' when calling describePackage" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + packType: opts.packType + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 describePackage 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}/packages/{packType}', + '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.zone_identifier + * @param {string} [opts.status] - 页面规则的状态 optional + * @param {string} [opts.order] - 用于按顺序排列页面规则的字段 optional + * @param {string} [opts.direction] - asc - 升序;desc - 降序 optional + * @param {string} [opts.match] - 是否匹配所有搜索要求或至少一个(任何) optional + * @param {string} callback - callback + @return {Object} result + * @param pageRule dataList + * @param integer currentCount 当前页记录数量 + * @param integer totalCount 总记录数量 + * @param integer totalPage 总页数 + */ + + listPageRules (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling listPageRules" + ) + } + + let postBody = null + let queryParams = {} + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + if (opts.order !== undefined && opts.order !== null) { + queryParams['order'] = opts.order + } + if (opts.direction !== undefined && opts.direction !== null) { + queryParams['direction'] = opts.direction + } + if (opts.match !== undefined && opts.match !== null) { + queryParams['match'] = opts.match + } + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 listPageRules 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( + '/zones/{zone_identifier}/pagerules', + '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.zone_identifier + * @param {} [opts.targets] - 根据请求评估的目标 optional + * @param {} [opts.actions] - 如果此规则的目标与请求匹配,则要执行的操作集。操作可以将url重定向到另一个url或覆盖设置(但不能同时覆盖两者) optional + * @param {} [opts.priority] - 一个数字,表示一个页面规则优先于另一个页面规则。 +如果您可能有一个全面的页面规则(例如#1 “/images/”) +但是想要更具体的规则优先(例如#2 '/images/special/'), +您需要在后者(#2)上指定更高的优先级,以便它将覆盖第一个优先级。 + optional + * @param {} [opts.status] - 页面规则的状态 optional + * @param {string} callback - callback + @return {Object} result + * @param pageRule data + */ + + createPageRule (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling createPageRule" + ) + } + + let postBody = {} + if (opts.targets !== undefined && opts.targets !== null) { + postBody['targets'] = opts.targets + } + if (opts.actions !== undefined && opts.actions !== null) { + postBody['actions'] = opts.actions + } + if (opts.priority !== undefined && opts.priority !== null) { + postBody['priority'] = opts.priority + } + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 createPageRule 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( + '/zones/{zone_identifier}/pagerules', + '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.zone_identifier + * @param {string} opts.identifier + * @param {} [opts.targets] - 根据请求评估的目标 optional + * @param {} [opts.actions] - 如果此规则的目标与请求匹配,则要执行的操作集。操作可以将url重定向到另一个url或覆盖设置(但不能同时覆盖两者) optional + * @param {} [opts.priority] - 一个数字,表示一个页面规则优先于另一个页面规则。 +如果您可能有一个全面的页面规则(例如#1 “/images/”) +但是想要更具体的规则优先(例如#2 '/images/special/'), +您需要在后者(#2)上指定更高的优先级,以便它将覆盖第一个优先级。 + optional + * @param {} [opts.status] - 页面规则的状态 optional + * @param {string} callback - callback + @return {Object} result + * @param pageRule data + */ + + updatePageRule (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling updatePageRule" + ) + } + if (opts.identifier === undefined || opts.identifier === null) { + throw new Error( + "Missing the required parameter 'opts.identifier' when calling updatePageRule" + ) + } + + let postBody = {} + if (opts.targets !== undefined && opts.targets !== null) { + postBody['targets'] = opts.targets + } + if (opts.actions !== undefined && opts.actions !== null) { + postBody['actions'] = opts.actions + } + if (opts.priority !== undefined && opts.priority !== null) { + postBody['priority'] = opts.priority + } + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier, + identifier: opts.identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 updatePageRule 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( + '/zones/{zone_identifier}/pagerules/{identifier}', + '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) + } + ) + } + + /** + * 删除页面规则 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} opts.identifier + * @param {string} callback - callback + @return {Object} result + * @param string data + */ + + deletePageRule (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling deletePageRule" + ) + } + if (opts.identifier === undefined || opts.identifier === null) { + throw new Error( + "Missing the required parameter 'opts.identifier' when calling deletePageRule" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier, + identifier: opts.identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 deletePageRule 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( + '/zones/{zone_identifier}/pagerules/{identifier}', + '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.zone_id + * @param {string} opts.phase - 执行规则集的阶段,有效值http_ratelimit(速率限制阶段)/http_request_late_transform(转换阶段)/http_request_firewall_custom(防火墙规则)/http_request_firewall_managed(托管阶段) + * @param {string} callback - callback + @return {Object} result + * @param ruleSet data + */ + + getRuleSet (opts, callback) { + opts = opts || {} + + if (opts.zone_id === undefined || opts.zone_id === null) { + throw new Error( + "Missing the required parameter 'opts.zone_id' when calling getRuleSet" + ) + } + if (opts.phase === undefined || opts.phase === null) { + throw new Error( + "Missing the required parameter 'opts.phase' when calling getRuleSet" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_id: opts.zone_id, + phase: opts.phase + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getRuleSet 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( + '/zones/{zone_id}/rulesets$$phases/{phase}/entrypoint', + '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.zone_id + * @param {string} opts.phase - 执行规则集的阶段,有效值http_ratelimit http_request_late_transform。 + * @param {} [opts.rules] optional + * @param {string} callback - callback + @return {Object} result + * @param ruleSet data + */ + + createRuleSet (opts, callback) { + opts = opts || {} + + if (opts.zone_id === undefined || opts.zone_id === null) { + throw new Error( + "Missing the required parameter 'opts.zone_id' when calling createRuleSet" + ) + } + if (opts.phase === undefined || opts.phase === null) { + throw new Error( + "Missing the required parameter 'opts.phase' when calling createRuleSet" + ) + } + + let postBody = {} + if (opts.rules !== undefined && opts.rules !== null) { + postBody['rules'] = opts.rules + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_id: opts.zone_id, + phase: opts.phase + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 createRuleSet 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( + '/zones/{zone_id}/rulesets$$phases/{phase}/entrypoint', + '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) + } + ) + } + + /** + * 创建规则 + * @param {Object} opts - parameters + * @param {string} opts.zone_id + * @param {string} opts.ruleset_id + * @param {} [opts.enabled] - 是否开启规则,有效值true/false。 optional + * @param {} [opts.description] - 规则的描述。 optional + * @param {} [opts.expression] - 表达式。 optional + * @param {} [opts.action] - 当表达式匹配时,采取的措施。有效值block(阻止)/challenge(交互式质询)/js_challenge(JS质询)/managed_challenge(托管质询)/log(记录)/rewrite/skip(跳过)/execute。 optional + * @param {} [opts.action_parameters] optional + * @param {} [opts.ratelimit] optional + * @param {string} callback - callback + @return {Object} result + * @param ruleSet data + */ + + createRule (opts, callback) { + opts = opts || {} + + if (opts.zone_id === undefined || opts.zone_id === null) { + throw new Error( + "Missing the required parameter 'opts.zone_id' when calling createRule" + ) + } + if (opts.ruleset_id === undefined || opts.ruleset_id === null) { + throw new Error( + "Missing the required parameter 'opts.ruleset_id' when calling createRule" + ) + } + + let postBody = {} + if (opts.enabled !== undefined && opts.enabled !== null) { + postBody['enabled'] = opts.enabled + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.expression !== undefined && opts.expression !== null) { + postBody['expression'] = opts.expression + } + if (opts.action !== undefined && opts.action !== null) { + postBody['action'] = opts.action + } + if ( + opts.action_parameters !== undefined && + opts.action_parameters !== null + ) { + postBody['action_parameters'] = opts.action_parameters + } + if (opts.ratelimit !== undefined && opts.ratelimit !== null) { + postBody['ratelimit'] = opts.ratelimit + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_id: opts.zone_id, + ruleset_id: opts.ruleset_id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 createRule 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( + '/zones/{zone_id}/rulesets/{ruleset_id}/rules', + '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.zone_id + * @param {string} opts.ruleset_id + * @param {string} opts.rule_id + * @param {} [opts.enabled] - 是否开启规则,有效值true/false。 optional + * @param {} [opts.description] - 规则的描述。 optional + * @param {} [opts.expression] - 表达式。 optional + * @param {} [opts.action] - 当表达式匹配时,采取的措施。有效值block(阻止)/challenge(交互式质询)/js_challenge(JS质询)/managed_challenge(托管质询)/log(记录)/rewrite/skip(跳过)。 optional + * @param {} [opts.action_parameters] optional + * @param {} [opts.ratelimit] optional + * @param {} [opts.logging] optional + * @param {} [opts.position] optional + * @param {} [opts.id] - 规则标识。 optional + * @param {} [opts.version] - 规则版本。 optional + * @param {} [opts.last_updated] - 最近更新时间。 optional + * @param {} [opts.ref] - 规则引用(默认是规则标识)。 optional + * @param {string} callback - callback + @return {Object} result + * @param ruleSet data + */ + + updateRule (opts, callback) { + opts = opts || {} + + if (opts.zone_id === undefined || opts.zone_id === null) { + throw new Error( + "Missing the required parameter 'opts.zone_id' when calling updateRule" + ) + } + if (opts.ruleset_id === undefined || opts.ruleset_id === null) { + throw new Error( + "Missing the required parameter 'opts.ruleset_id' when calling updateRule" + ) + } + if (opts.rule_id === undefined || opts.rule_id === null) { + throw new Error( + "Missing the required parameter 'opts.rule_id' when calling updateRule" + ) + } + + let postBody = {} + if (opts.enabled !== undefined && opts.enabled !== null) { + postBody['enabled'] = opts.enabled + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.expression !== undefined && opts.expression !== null) { + postBody['expression'] = opts.expression + } + if (opts.action !== undefined && opts.action !== null) { + postBody['action'] = opts.action + } + if ( + opts.action_parameters !== undefined && + opts.action_parameters !== null + ) { + postBody['action_parameters'] = opts.action_parameters + } + if (opts.ratelimit !== undefined && opts.ratelimit !== null) { + postBody['ratelimit'] = opts.ratelimit + } + if (opts.logging !== undefined && opts.logging !== null) { + postBody['logging'] = opts.logging + } + if (opts.position !== undefined && opts.position !== null) { + postBody['position'] = opts.position + } + if (opts.id !== undefined && opts.id !== null) { + postBody['id'] = opts.id + } + if (opts.version !== undefined && opts.version !== null) { + postBody['version'] = opts.version + } + if (opts.last_updated !== undefined && opts.last_updated !== null) { + postBody['last_updated'] = opts.last_updated + } + if (opts.ref !== undefined && opts.ref !== null) { + postBody['ref'] = opts.ref + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_id: opts.zone_id, + ruleset_id: opts.ruleset_id, + rule_id: opts.rule_id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 updateRule 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( + '/zones/{zone_id}/rulesets/{ruleset_id}/rules/{rule_id}', + 'PATCH', + 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.zone_id + * @param {string} opts.ruleset_id + * @param {string} opts.rule_id + * @param {string} callback - callback + @return {Object} result + * @param ruleSet data + */ + + deleteRule (opts, callback) { + opts = opts || {} + + if (opts.zone_id === undefined || opts.zone_id === null) { + throw new Error( + "Missing the required parameter 'opts.zone_id' when calling deleteRule" + ) + } + if (opts.ruleset_id === undefined || opts.ruleset_id === null) { + throw new Error( + "Missing the required parameter 'opts.ruleset_id' when calling deleteRule" + ) + } + if (opts.rule_id === undefined || opts.rule_id === null) { + throw new Error( + "Missing the required parameter 'opts.rule_id' when calling deleteRule" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_id: opts.zone_id, + ruleset_id: opts.ruleset_id, + rule_id: opts.rule_id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 deleteRule 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( + '/zones/{zone_id}/rulesets/{ruleset_id}/rules/{rule_id}', + '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) + } + ) + } + + /** + * 实例Spectrum应用流量统计. + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例标识 + * @param {string} opts.since - 开始时间 + * @param {string} opts.until - 结束时间 + * @param {string} callback - callback + @return {Object} result + * @param paDateHistogram paDateHistogram + */ + + instanceTrafficDateHistogram4Pa (opts, callback) { + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling instanceTrafficDateHistogram4Pa" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling instanceTrafficDateHistogram4Pa" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling instanceTrafficDateHistogram4Pa" + ) + } + + let postBody = null + let queryParams = {} + if (opts.since !== undefined && opts.since !== null) { + queryParams['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + queryParams['until'] = opts.until + } + + let pathParams = { + regionId: 'jdcloud', + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 instanceTrafficDateHistogram4Pa 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( + '/instances/{instanceId}/paTrafficDateHistogram', + '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) + } + ) + } + + /** + * 域名Spectrum应用流量统计. + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例标识 + * @param {string} opts.zoneId - 域名标识 + * @param {string} opts.since - 开始时间 + * @param {string} opts.until - 结束时间 + * @param {string} callback - callback + @return {Object} result + * @param paDateHistogram paDateHistogram + */ + + zoneTrafficDateHistogram4Pa (opts, callback) { + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling zoneTrafficDateHistogram4Pa" + ) + } + if (opts.zoneId === undefined || opts.zoneId === null) { + throw new Error( + "Missing the required parameter 'opts.zoneId' when calling zoneTrafficDateHistogram4Pa" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling zoneTrafficDateHistogram4Pa" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling zoneTrafficDateHistogram4Pa" + ) + } + + let postBody = null + let queryParams = {} + if (opts.since !== undefined && opts.since !== null) { + queryParams['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + queryParams['until'] = opts.until + } + + let pathParams = { + regionId: 'jdcloud', + instanceId: opts.instanceId, + zoneId: opts.zoneId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 zoneTrafficDateHistogram4Pa 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( + '/instances/{instanceId}/zones/{zoneId}/paTrafficDateHistogram', + '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) + } + ) + } + + /** + * Spectrum应用流量统计. + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例标识 + * @param {string} opts.zoneId - 域名标识 + * @param {string} opts.spectrumAppId - 应用标识 + * @param {string} opts.since - 开始时间 + * @param {string} opts.until - 结束时间 + * @param {string} callback - callback + @return {Object} result + * @param paDateHistogram paDateHistogram + */ + + spectrumAppTrafficDateHistogram (opts, callback) { + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling spectrumAppTrafficDateHistogram" + ) + } + if (opts.zoneId === undefined || opts.zoneId === null) { + throw new Error( + "Missing the required parameter 'opts.zoneId' when calling spectrumAppTrafficDateHistogram" + ) + } + if (opts.spectrumAppId === undefined || opts.spectrumAppId === null) { + throw new Error( + "Missing the required parameter 'opts.spectrumAppId' when calling spectrumAppTrafficDateHistogram" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling spectrumAppTrafficDateHistogram" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling spectrumAppTrafficDateHistogram" + ) + } + + let postBody = null + let queryParams = {} + if (opts.since !== undefined && opts.since !== null) { + queryParams['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + queryParams['until'] = opts.until + } + + let pathParams = { + regionId: 'jdcloud', + instanceId: opts.instanceId, + zoneId: opts.zoneId, + spectrumAppId: opts.spectrumAppId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 spectrumAppTrafficDateHistogram 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( + '/instances/{instanceId}/zones/{zoneId}/spectrumApps/{spectrumAppId}/paTrafficDateHistogram', + '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) + } + ) + } + + /** + * 实例Spectrum应用带宽统计. + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例标识 + * @param {string} opts.since - 开始时间 + * @param {string} opts.until - 结束时间 + * @param {string} callback - callback + @return {Object} result + * @param paDateHistogram paDateHistogram + */ + + instanceBandwidthDateHistogram4Pa (opts, callback) { + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling instanceBandwidthDateHistogram4Pa" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling instanceBandwidthDateHistogram4Pa" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling instanceBandwidthDateHistogram4Pa" + ) + } + + let postBody = null + let queryParams = {} + if (opts.since !== undefined && opts.since !== null) { + queryParams['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + queryParams['until'] = opts.until + } + + let pathParams = { + regionId: 'jdcloud', + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 instanceBandwidthDateHistogram4Pa 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( + '/instances/{instanceId}/paBandwidthDateHistogram', + '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) + } + ) + } + + /** + * 域名Spectrum应用带宽统计. + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例标识 + * @param {string} opts.zoneId - 域名标识 + * @param {string} opts.since - 开始时间 + * @param {string} opts.until - 结束时间 + * @param {string} callback - callback + @return {Object} result + * @param paDateHistogram paDateHistogram + */ + + zoneBandwidthDateHistogram4Pa (opts, callback) { + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling zoneBandwidthDateHistogram4Pa" + ) + } + if (opts.zoneId === undefined || opts.zoneId === null) { + throw new Error( + "Missing the required parameter 'opts.zoneId' when calling zoneBandwidthDateHistogram4Pa" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling zoneBandwidthDateHistogram4Pa" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling zoneBandwidthDateHistogram4Pa" + ) + } + + let postBody = null + let queryParams = {} + if (opts.since !== undefined && opts.since !== null) { + queryParams['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + queryParams['until'] = opts.until + } + + let pathParams = { + regionId: 'jdcloud', + instanceId: opts.instanceId, + zoneId: opts.zoneId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 zoneBandwidthDateHistogram4Pa 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( + '/instances/{instanceId}/zones/{zoneId}/paBandwidthDateHistogram', + '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) + } + ) + } + + /** + * Spectrum应用带宽统计. + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例标识 + * @param {string} opts.zoneId - 域名标识 + * @param {string} opts.spectrumAppId - 应用标识 + * @param {string} opts.since - 开始时间 + * @param {string} opts.until - 结束时间 + * @param {string} callback - callback + @return {Object} result + * @param paDateHistogram paDateHistogram + */ + + spectrumAppBandwidthDateHistogram (opts, callback) { + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling spectrumAppBandwidthDateHistogram" + ) + } + if (opts.zoneId === undefined || opts.zoneId === null) { + throw new Error( + "Missing the required parameter 'opts.zoneId' when calling spectrumAppBandwidthDateHistogram" + ) + } + if (opts.spectrumAppId === undefined || opts.spectrumAppId === null) { + throw new Error( + "Missing the required parameter 'opts.spectrumAppId' when calling spectrumAppBandwidthDateHistogram" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling spectrumAppBandwidthDateHistogram" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling spectrumAppBandwidthDateHistogram" + ) + } + + let postBody = null + let queryParams = {} + if (opts.since !== undefined && opts.since !== null) { + queryParams['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + queryParams['until'] = opts.until + } + + let pathParams = { + regionId: 'jdcloud', + instanceId: opts.instanceId, + zoneId: opts.zoneId, + spectrumAppId: opts.spectrumAppId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 spectrumAppBandwidthDateHistogram 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( + '/instances/{instanceId}/zones/{zoneId}/spectrumApps/{spectrumAppId}/paBandwidthDateHistogram', + '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) + } + ) + } + + /** + * 获取域的通用SSL证书设置 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param universalSSLSetting data + */ + + universalSSLSettingsDetails (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling universalSSLSettingsDetails" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 universalSSLSettingsDetails 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( + '/zones/{zone_identifier}/ssl$$universal$$settings', + '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) + } + ) + } + + /** + * 修补域的通用SSL设置 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.enabled] - 禁用通用SSL将从边缘上删除域的所有当前激活的通用SSL证书并且防止将来订购任何通用SSL证书。如果没有为域上载专用证书或自定义证书,访问者将无法通过HTTPS访问域。 +通过禁用通用SSL,您知道以下星盾设置和首选项将导致访问者无法访问您的域,除非您上载了自定义证书或购买了专用证书。 + * HSTS + * Always Use HTTPS + * Opportunistic Encryption + * Onion Routing + * Any Page Rules redirecting traffic to HTTPS +类似地,在启用星盾代理时,在源站将任何HTTP重定向到HTTPS将导致用户在星盾的边缘没有有效证书的情况下无法访问您的站点。 +如果您在星盾的边缘没有有效的自定义或专用证书,并且不确定是否启用了上述任何星盾设置,或者如果您的源站存在任何HTTP重定向,我们建议您的域保持启用通用SSL。 + optional + * @param {string} callback - callback + @return {Object} result + * @param universalSSLSetting data + */ + + editUniversalSSLSettings (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling editUniversalSSLSettings" + ) + } + + let postBody = {} + if (opts.enabled !== undefined && opts.enabled !== null) { + postBody['enabled'] = opts.enabled + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 editUniversalSSLSettings 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( + '/zones/{zone_identifier}/ssl$$universal$$settings', + 'PATCH', + 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.zone_identifier + * @param {string} opts.package_identifier + * @param {string} [opts.name] - 防火墙规则组名称 optional + * @param {string} [opts.mode] - 此组中包含的规则是否可配置/可用 optional + * @param {number} [opts.rules_count] - 此组中包含多少条规则 optional + * @param {number} [opts.page] - 分页结果的页码 optional + * @param {number} [opts.per_page] - 每页的组数 optional + * @param {string} [opts.order] - 按字段对组进行排序 optional + * @param {string} [opts.direction] - asc-升序;desc-降序 optional + * @param {string} [opts.match] - 是否匹配所有搜索要求或至少一个(任何) optional + * @param {string} callback - callback + @return {Object} result + * @param wAFRuleGroup dataList + */ + + listRuleGroups (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling listRuleGroups" + ) + } + if ( + opts.package_identifier === undefined || + opts.package_identifier === null + ) { + throw new Error( + "Missing the required parameter 'opts.package_identifier' when calling listRuleGroups" + ) + } + + let postBody = null + let queryParams = {} + if (opts.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + if (opts.mode !== undefined && opts.mode !== null) { + queryParams['mode'] = opts.mode + } + if (opts.rules_count !== undefined && opts.rules_count !== null) { + queryParams['rules_count'] = opts.rules_count + } + if (opts.page !== undefined && opts.page !== null) { + queryParams['page'] = opts.page + } + if (opts.per_page !== undefined && opts.per_page !== null) { + queryParams['per_page'] = opts.per_page + } + if (opts.order !== undefined && opts.order !== null) { + queryParams['order'] = opts.order + } + if (opts.direction !== undefined && opts.direction !== null) { + queryParams['direction'] = opts.direction + } + if (opts.match !== undefined && opts.match !== null) { + queryParams['match'] = opts.match + } + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier, + package_identifier: opts.package_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 listRuleGroups 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( + '/zones/{zone_identifier}/firewall$$waf$$packages/{package_identifier}/groups', + '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.zone_identifier + * @param {string} opts.package_identifier + * @param {string} opts.identifier + * @param {string} callback - callback + @return {Object} result + * @param wAFRuleGroup data + */ + + ruleGroupDetails (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling ruleGroupDetails" + ) + } + if ( + opts.package_identifier === undefined || + opts.package_identifier === null + ) { + throw new Error( + "Missing the required parameter 'opts.package_identifier' when calling ruleGroupDetails" + ) + } + if (opts.identifier === undefined || opts.identifier === null) { + throw new Error( + "Missing the required parameter 'opts.identifier' when calling ruleGroupDetails" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier, + package_identifier: opts.package_identifier, + identifier: opts.identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 ruleGroupDetails 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( + '/zones/{zone_identifier}/firewall$$waf$$packages/{package_identifier}/groups/{identifier}', + '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.zone_identifier + * @param {string} opts.package_identifier + * @param {string} opts.identifier + * @param {} [opts.mode] - 该组中包含的规则是否可配置/可使用 optional + * @param {string} callback - callback + @return {Object} result + * @param wAFRuleGroup data + */ + + editRuleGroup (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling editRuleGroup" + ) + } + if ( + opts.package_identifier === undefined || + opts.package_identifier === null + ) { + throw new Error( + "Missing the required parameter 'opts.package_identifier' when calling editRuleGroup" + ) + } + if (opts.identifier === undefined || opts.identifier === null) { + throw new Error( + "Missing the required parameter 'opts.identifier' when calling editRuleGroup" + ) + } + + let postBody = {} + if (opts.mode !== undefined && opts.mode !== null) { + postBody['mode'] = opts.mode + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier, + package_identifier: opts.package_identifier, + identifier: opts.identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 editRuleGroup 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( + '/zones/{zone_identifier}/firewall$$waf$$packages/{package_identifier}/groups/{identifier}', + 'PATCH', + 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.zone_identifier + * @param {string} [opts.name] - Name of the firewall package optional + * @param {number} [opts.page] - Page number of paginated results optional + * @param {number} [opts.per_page] - 每页的包数 optional + * @param {string} [opts.order] - 按字段对包排序 optional + * @param {string} [opts.direction] - asc - 升序;desc - 降序 optional + * @param {string} [opts.match] - 是否匹配所有搜索要求或至少一个(任何) optional + * @param {string} callback - callback + @return {Object} result + * @param wAFRulePackage dataList + */ + + listFirewallPackages (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling listFirewallPackages" + ) + } + + let postBody = null + let queryParams = {} + if (opts.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + if (opts.page !== undefined && opts.page !== null) { + queryParams['page'] = opts.page + } + if (opts.per_page !== undefined && opts.per_page !== null) { + queryParams['per_page'] = opts.per_page + } + if (opts.order !== undefined && opts.order !== null) { + queryParams['order'] = opts.order + } + if (opts.direction !== undefined && opts.direction !== null) { + queryParams['direction'] = opts.direction + } + if (opts.match !== undefined && opts.match !== null) { + queryParams['match'] = opts.match + } + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 listFirewallPackages 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( + '/zones/{zone_identifier}/firewall$$waf$$packages', + '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.zone_identifier + * @param {string} opts.identifier + * @param {string} callback - callback + @return {Object} result + * @param wAFRulePackage data + */ + + firewallPackageDetails (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling firewallPackageDetails" + ) + } + if (opts.identifier === undefined || opts.identifier === null) { + throw new Error( + "Missing the required parameter 'opts.identifier' when calling firewallPackageDetails" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier, + identifier: opts.identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 firewallPackageDetails 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( + '/zones/{zone_identifier}/firewall$$waf$$packages/{identifier}', + '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) + } + ) + } + + /** + * 更改异常检测类型WAF规则包的灵敏度和操作 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} opts.identifier + * @param {} [opts.sensitivity] - 防火墙包的敏感度。 optional + * @param {} [opts.action_mode] - 将对防火墙包下的规则执行的默认操作。 optional + * @param {string} callback - callback + @return {Object} result + * @param wAFRulePackage data + */ + + editFirewallPackage (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling editFirewallPackage" + ) + } + if (opts.identifier === undefined || opts.identifier === null) { + throw new Error( + "Missing the required parameter 'opts.identifier' when calling editFirewallPackage" + ) + } + + let postBody = {} + if (opts.sensitivity !== undefined && opts.sensitivity !== null) { + postBody['sensitivity'] = opts.sensitivity + } + if (opts.action_mode !== undefined && opts.action_mode !== null) { + postBody['action_mode'] = opts.action_mode + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier, + identifier: opts.identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 editFirewallPackage 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( + '/zones/{zone_identifier}/firewall$$waf$$packages/{identifier}', + 'PATCH', + 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.zone_id + * @param {string} opts.package_id + * @param {string} [opts.mode] - 已将规则覆盖到的设置 optional + * @param {string} [opts.priority] - 在相关组中执行单个规则的顺序 optional + * @param {string} [opts.match] - 是否匹配所有搜索要求或至少一个(任何) optional + * @param {string} [opts.order] - 按指定字段排序 optional + * @param {number} [opts.page] - 分页结果的页码 optional + * @param {number} [opts.per_page] - 每页的规则数 optional + * @param {string} [opts.group_id] - WAF组标识符标签 optional + * @param {string} [opts.description] - 规则的公开说明 optional + * @param {string} [opts.direction] - asc-升序;desc-降序 optional + * @param {string} callback - callback + @return {Object} result + * @param wAFRule dataList + */ + + listRules (opts, callback) { + opts = opts || {} + + if (opts.zone_id === undefined || opts.zone_id === null) { + throw new Error( + "Missing the required parameter 'opts.zone_id' when calling listRules" + ) + } + if (opts.package_id === undefined || opts.package_id === null) { + throw new Error( + "Missing the required parameter 'opts.package_id' when calling listRules" + ) + } + + let postBody = null + let queryParams = {} + if (opts.mode !== undefined && opts.mode !== null) { + queryParams['mode'] = opts.mode + } + if (opts.priority !== undefined && opts.priority !== null) { + queryParams['priority'] = opts.priority + } + if (opts.match !== undefined && opts.match !== null) { + queryParams['match'] = opts.match + } + if (opts.order !== undefined && opts.order !== null) { + queryParams['order'] = opts.order + } + if (opts.page !== undefined && opts.page !== null) { + queryParams['page'] = opts.page + } + if (opts.per_page !== undefined && opts.per_page !== null) { + queryParams['per_page'] = opts.per_page + } + if (opts.group_id !== undefined && opts.group_id !== null) { + queryParams['group_id'] = opts.group_id + } + if (opts.description !== undefined && opts.description !== null) { + queryParams['description'] = opts.description + } + if (opts.direction !== undefined && opts.direction !== null) { + queryParams['direction'] = opts.direction + } + + let pathParams = { + regionId: 'jdcloud', + zone_id: opts.zone_id, + package_id: opts.package_id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 listRules 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( + '/zones/{zone_id}/firewall$$waf$$packages/{package_id}/rules', + '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) + } + ) + } + + /** + * Individual information about a rule + * @param {Object} opts - parameters + * @param {string} opts.zone_id + * @param {string} opts.package_id + * @param {string} opts.identifier + * @param {string} callback - callback + @return {Object} result + * @param wAFRule data + */ + + ruleDetails (opts, callback) { + opts = opts || {} + + if (opts.zone_id === undefined || opts.zone_id === null) { + throw new Error( + "Missing the required parameter 'opts.zone_id' when calling ruleDetails" + ) + } + if (opts.package_id === undefined || opts.package_id === null) { + throw new Error( + "Missing the required parameter 'opts.package_id' when calling ruleDetails" + ) + } + if (opts.identifier === undefined || opts.identifier === null) { + throw new Error( + "Missing the required parameter 'opts.identifier' when calling ruleDetails" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_id: opts.zone_id, + package_id: opts.package_id, + identifier: opts.identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 ruleDetails 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( + '/zones/{zone_id}/firewall$$waf$$packages/{package_id}/rules/{identifier}', + '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.zone_id + * @param {string} opts.package_id + * @param {string} opts.identifier + * @param {} [opts.mode] - 触发规则时使用的模式。值基于规则的allowed_modes进行限制。有效值default/disable/simulate/block/challenge/on/off optional + * @param {string} callback - callback + @return {Object} result + * @param wAFRule data + */ + + editRule (opts, callback) { + opts = opts || {} + + if (opts.zone_id === undefined || opts.zone_id === null) { + throw new Error( + "Missing the required parameter 'opts.zone_id' when calling editRule" + ) + } + if (opts.package_id === undefined || opts.package_id === null) { + throw new Error( + "Missing the required parameter 'opts.package_id' when calling editRule" + ) + } + if (opts.identifier === undefined || opts.identifier === null) { + throw new Error( + "Missing the required parameter 'opts.identifier' when calling editRule" + ) + } + + let postBody = {} + if (opts.mode !== undefined && opts.mode !== null) { + postBody['mode'] = opts.mode + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_id: opts.zone_id, + package_id: opts.package_id, + identifier: opts.identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 editRule 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( + '/zones/{zone_id}/firewall$$waf$$packages/{package_id}/rules/{identifier}', + 'PATCH', + 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) + } + ) + } + + /** + * 平均峰值带宽。查询范围最近6个月、查询最大跨度1个月。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier - 域名标识 + * @param {} opts.queryMode - all - 所有 +normal - 业务 +mitigation - 缓解 +cache - 缓存 +origin - 回源 + + * @param {} opts.zoneName - 域名 + * @param {} opts.since - 开始时间 + * @param {} opts.until - 结束时间 + * @param {string} callback - callback + @return {Object} result + * @param cdnSingleMetric cdnSingleMetric + */ + + zoneBandwidthAvg (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling zoneBandwidthAvg" + ) + } + if (opts.queryMode === undefined || opts.queryMode === null) { + throw new Error( + "Missing the required parameter 'opts.queryMode' when calling zoneBandwidthAvg" + ) + } + if (opts.zoneName === undefined || opts.zoneName === null) { + throw new Error( + "Missing the required parameter 'opts.zoneName' when calling zoneBandwidthAvg" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling zoneBandwidthAvg" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling zoneBandwidthAvg" + ) + } + + let postBody = {} + if (opts.queryMode !== undefined && opts.queryMode !== null) { + postBody['queryMode'] = opts.queryMode + } + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 zoneBandwidthAvg 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( + '/zones/{zone_identifier}/zoneBandwidthAvg', + '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) + } + ) + } + + /** + * 带宽峰值。查询范围最近6个月、查询最大跨度1个月。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier - 域名标识 + * @param {} opts.queryMode - all - 所有 +normal - 业务 +mitigation - 缓解 +cache - 缓存 +origin - 回源 + + * @param {} opts.zoneName - 域名 + * @param {} opts.since - 开始时间 + * @param {} opts.until - 结束时间 + * @param {string} callback - callback + @return {Object} result + * @param cdnBandwidthMax cdnBandwidthMax + */ + + zoneBandwidthMax (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling zoneBandwidthMax" + ) + } + if (opts.queryMode === undefined || opts.queryMode === null) { + throw new Error( + "Missing the required parameter 'opts.queryMode' when calling zoneBandwidthMax" + ) + } + if (opts.zoneName === undefined || opts.zoneName === null) { + throw new Error( + "Missing the required parameter 'opts.zoneName' when calling zoneBandwidthMax" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling zoneBandwidthMax" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling zoneBandwidthMax" + ) + } + + let postBody = {} + if (opts.queryMode !== undefined && opts.queryMode !== null) { + postBody['queryMode'] = opts.queryMode + } + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 zoneBandwidthMax 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( + '/zones/{zone_identifier}/zoneBandwidthMax', + '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) + } + ) + } + + /** + * 95峰值带宽。查询范围最近6个月、查询最大跨度1个月。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier - 域名标识 + * @param {} opts.queryMode - all - 所有 +normal - 业务 +mitigation - 缓解 +cache - 缓存 +origin - 回源 + + * @param {} opts.zoneName - 域名 + * @param {} opts.since - 开始时间 + * @param {} opts.until - 结束时间 + * @param {string} callback - callback + @return {Object} result + * @param cdnSingleMetric cdnSingleMetric + */ + + zoneBandwidthP95 (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling zoneBandwidthP95" + ) + } + if (opts.queryMode === undefined || opts.queryMode === null) { + throw new Error( + "Missing the required parameter 'opts.queryMode' when calling zoneBandwidthP95" + ) + } + if (opts.zoneName === undefined || opts.zoneName === null) { + throw new Error( + "Missing the required parameter 'opts.zoneName' when calling zoneBandwidthP95" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling zoneBandwidthP95" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling zoneBandwidthP95" + ) + } + + let postBody = {} + if (opts.queryMode !== undefined && opts.queryMode !== null) { + postBody['queryMode'] = opts.queryMode + } + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 zoneBandwidthP95 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( + '/zones/{zone_identifier}/zoneBandwidthP95', + '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) + } + ) + } + + /** + * 带宽图。查询范围最近6个月、查询最大跨度1个月。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier - 域名标识 + * @param {} opts.queryMode - all - 所有 +normal - 业务 +mitigation - 缓解 +cache - 缓存 +origin - 回源 + + * @param {} opts.zoneName - 域名 + * @param {} opts.since - 开始时间 + * @param {} opts.until - 结束时间 + * @param {string} callback - callback + @return {Object} result + * @param simpleDateHistogram data + */ + + zoneBandwidthDateHistogram (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling zoneBandwidthDateHistogram" + ) + } + if (opts.queryMode === undefined || opts.queryMode === null) { + throw new Error( + "Missing the required parameter 'opts.queryMode' when calling zoneBandwidthDateHistogram" + ) + } + if (opts.zoneName === undefined || opts.zoneName === null) { + throw new Error( + "Missing the required parameter 'opts.zoneName' when calling zoneBandwidthDateHistogram" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling zoneBandwidthDateHistogram" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling zoneBandwidthDateHistogram" + ) + } + + let postBody = {} + if (opts.queryMode !== undefined && opts.queryMode !== null) { + postBody['queryMode'] = opts.queryMode + } + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 zoneBandwidthDateHistogram 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( + '/zones/{zone_identifier}/zoneBandwidthDateHistogram', + '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) + } + ) + } + + /** + * 多指标的带宽图。查询范围最近6个月、查询最大跨度1个月。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier - 域名标识 + * @param {} opts.queryModes - all - 所有 +normal - 业务 +mitigation - 缓解 +cache - 缓存 +origin - 回源 +all/normal/mitigation/cache/origin的任意组合 + + * @param {} opts.zoneName - 域名 + * @param {} opts.since - 开始时间 + * @param {} opts.until - 结束时间 + * @param {string} callback - callback + @return {Object} result + * @param dateHistogram dateHistograms + * @param number timeScope + * @param string since + * @param string util + */ + + zoneBandwidthMultiDateHistogram (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling zoneBandwidthMultiDateHistogram" + ) + } + if (opts.queryModes === undefined || opts.queryModes === null) { + throw new Error( + "Missing the required parameter 'opts.queryModes' when calling zoneBandwidthMultiDateHistogram" + ) + } + if (opts.zoneName === undefined || opts.zoneName === null) { + throw new Error( + "Missing the required parameter 'opts.zoneName' when calling zoneBandwidthMultiDateHistogram" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling zoneBandwidthMultiDateHistogram" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling zoneBandwidthMultiDateHistogram" + ) + } + + let postBody = {} + if (opts.queryModes !== undefined && opts.queryModes !== null) { + postBody['queryModes'] = opts.queryModes + } + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 zoneBandwidthMultiDateHistogram 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( + '/zones/{zone_identifier}/zoneBandwidthMultiDateHistogram', + '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) + } + ) + } + + /** + * 总流量。查询范围最近6个月、查询最大跨度1个月。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier - 域名标识 + * @param {} opts.queryMode - all - 所有 +normal - 业务 +mitigation - 缓解 +cache - 缓存 +origin - 回源 + + * @param {} opts.zoneName - 域名 + * @param {} opts.since - 开始时间 + * @param {} opts.until - 结束时间 + * @param {string} callback - callback + @return {Object} result + * @param cdnSingleMetric cdnSingleMetric + */ + + zoneTrafficSum (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling zoneTrafficSum" + ) + } + if (opts.queryMode === undefined || opts.queryMode === null) { + throw new Error( + "Missing the required parameter 'opts.queryMode' when calling zoneTrafficSum" + ) + } + if (opts.zoneName === undefined || opts.zoneName === null) { + throw new Error( + "Missing the required parameter 'opts.zoneName' when calling zoneTrafficSum" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling zoneTrafficSum" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling zoneTrafficSum" + ) + } + + let postBody = {} + if (opts.queryMode !== undefined && opts.queryMode !== null) { + postBody['queryMode'] = opts.queryMode + } + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 zoneTrafficSum 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( + '/zones/{zone_identifier}/zoneTrafficSum', + '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) + } + ) + } + + /** + * 流量图。查询范围最近6个月、查询最大跨度1个月。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier - 域名标识 + * @param {} opts.queryMode - all - 所有 +normal - 业务 +mitigation - 缓解 +cache - 缓存 +origin - 回源 + + * @param {} opts.zoneName - 域名 + * @param {} opts.since - 开始时间 + * @param {} opts.until - 结束时间 + * @param {string} callback - callback + @return {Object} result + * @param simpleDateHistogram data + */ + + zoneTrafficDateHistogram (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling zoneTrafficDateHistogram" + ) + } + if (opts.queryMode === undefined || opts.queryMode === null) { + throw new Error( + "Missing the required parameter 'opts.queryMode' when calling zoneTrafficDateHistogram" + ) + } + if (opts.zoneName === undefined || opts.zoneName === null) { + throw new Error( + "Missing the required parameter 'opts.zoneName' when calling zoneTrafficDateHistogram" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling zoneTrafficDateHistogram" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling zoneTrafficDateHistogram" + ) + } + + let postBody = {} + if (opts.queryMode !== undefined && opts.queryMode !== null) { + postBody['queryMode'] = opts.queryMode + } + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 zoneTrafficDateHistogram 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( + '/zones/{zone_identifier}/zoneTrafficDateHistogram', + '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) + } + ) + } + + /** + * 多指标的流量图。查询范围最近6个月、查询最大跨度1个月。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier - 域名标识 + * @param {} opts.queryModes - all - 所有 +normal - 业务 +mitigation - 缓解 +cache - 缓存 +origin - 回源 +all/normal/mitigation/cache/origin的任意组合 + + * @param {} opts.zoneName - 域名 + * @param {} opts.since - 开始时间 + * @param {} opts.until - 结束时间 + * @param {string} callback - callback + @return {Object} result + * @param dateHistogram dateHistograms + * @param number timeScope + * @param string since + * @param string util + */ + + zoneTrafficMultiDateHistogram (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling zoneTrafficMultiDateHistogram" + ) + } + if (opts.queryModes === undefined || opts.queryModes === null) { + throw new Error( + "Missing the required parameter 'opts.queryModes' when calling zoneTrafficMultiDateHistogram" + ) + } + if (opts.zoneName === undefined || opts.zoneName === null) { + throw new Error( + "Missing the required parameter 'opts.zoneName' when calling zoneTrafficMultiDateHistogram" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling zoneTrafficMultiDateHistogram" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling zoneTrafficMultiDateHistogram" + ) + } + + let postBody = {} + if (opts.queryModes !== undefined && opts.queryModes !== null) { + postBody['queryModes'] = opts.queryModes + } + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 zoneTrafficMultiDateHistogram 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( + '/zones/{zone_identifier}/zoneTrafficMultiDateHistogram', + '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) + } + ) + } + + /** + * 总请求量。查询范围最近6个月、查询最大跨度1个月。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier - 域名标识 + * @param {} opts.queryMode - all - 所有 +normal - 业务 +mitigation - 缓解 +cache - 缓存 +origin - 回源 + + * @param {} opts.zoneName - 域名 + * @param {} opts.since - 开始时间 + * @param {} opts.until - 结束时间 + * @param {string} callback - callback + @return {Object} result + * @param cdnSingleMetric cdnSingleMetric + */ + + zoneRequestSum (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling zoneRequestSum" + ) + } + if (opts.queryMode === undefined || opts.queryMode === null) { + throw new Error( + "Missing the required parameter 'opts.queryMode' when calling zoneRequestSum" + ) + } + if (opts.zoneName === undefined || opts.zoneName === null) { + throw new Error( + "Missing the required parameter 'opts.zoneName' when calling zoneRequestSum" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling zoneRequestSum" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling zoneRequestSum" + ) + } + + let postBody = {} + if (opts.queryMode !== undefined && opts.queryMode !== null) { + postBody['queryMode'] = opts.queryMode + } + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 zoneRequestSum 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( + '/zones/{zone_identifier}/zoneRequestSum', + '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) + } + ) + } + + /** + * 请求量图。查询范围最近6个月、查询最大跨度1个月。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier - 域名标识 + * @param {} opts.queryMode - all - 所有 +normal - 业务 +mitigation - 缓解 +cache - 缓存 +origin - 回源 + + * @param {} opts.zoneName - 域名 + * @param {} opts.since - 开始时间 + * @param {} opts.until - 结束时间 + * @param {string} callback - callback + @return {Object} result + * @param simpleDateHistogram data + */ + + zoneRequestDateHistogram (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling zoneRequestDateHistogram" + ) + } + if (opts.queryMode === undefined || opts.queryMode === null) { + throw new Error( + "Missing the required parameter 'opts.queryMode' when calling zoneRequestDateHistogram" + ) + } + if (opts.zoneName === undefined || opts.zoneName === null) { + throw new Error( + "Missing the required parameter 'opts.zoneName' when calling zoneRequestDateHistogram" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling zoneRequestDateHistogram" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling zoneRequestDateHistogram" + ) + } + + let postBody = {} + if (opts.queryMode !== undefined && opts.queryMode !== null) { + postBody['queryMode'] = opts.queryMode + } + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 zoneRequestDateHistogram 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( + '/zones/{zone_identifier}/zoneRequestDateHistogram', + '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) + } + ) + } + + /** + * 多指标的请求量图。查询范围最近6个月、查询最大跨度1个月。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier - 域名标识 + * @param {} opts.queryModes - all - 所有 +normal - 业务 +mitigation - 缓解 +cache - 缓存 +origin - 回源 +all/normal/mitigation/cache/origin的任意组合 + + * @param {} opts.zoneName - 域名 + * @param {} opts.since - 开始时间 + * @param {} opts.until - 结束时间 + * @param {string} callback - callback + @return {Object} result + * @param dateHistogram dateHistograms + * @param number timeScope + * @param string since + * @param string util + */ + + zoneRequestMultiDateHistogram (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling zoneRequestMultiDateHistogram" + ) + } + if (opts.queryModes === undefined || opts.queryModes === null) { + throw new Error( + "Missing the required parameter 'opts.queryModes' when calling zoneRequestMultiDateHistogram" + ) + } + if (opts.zoneName === undefined || opts.zoneName === null) { + throw new Error( + "Missing the required parameter 'opts.zoneName' when calling zoneRequestMultiDateHistogram" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling zoneRequestMultiDateHistogram" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling zoneRequestMultiDateHistogram" + ) + } + + let postBody = {} + if (opts.queryModes !== undefined && opts.queryModes !== null) { + postBody['queryModes'] = opts.queryModes + } + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 zoneRequestMultiDateHistogram 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( + '/zones/{zone_identifier}/zoneRequestMultiDateHistogram', + '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.zone_identifier - 域名标识 + * @param {} opts.zoneName - 域名 + * @param {} opts.since - 开始时间 + * @param {} opts.until - 结束时间 + * @param {string} callback - callback + @return {Object} result + * @param zoneSecurityReport zoneSecurityReport + */ + + zoneSecurityReport (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling zoneSecurityReport" + ) + } + if (opts.zoneName === undefined || opts.zoneName === null) { + throw new Error( + "Missing the required parameter 'opts.zoneName' when calling zoneSecurityReport" + ) + } + if (opts.since === undefined || opts.since === null) { + throw new Error( + "Missing the required parameter 'opts.since' when calling zoneSecurityReport" + ) + } + if (opts.until === undefined || opts.until === null) { + throw new Error( + "Missing the required parameter 'opts.until' when calling zoneSecurityReport" + ) + } + + let postBody = {} + if (opts.zoneName !== undefined && opts.zoneName !== null) { + postBody['zoneName'] = opts.zoneName + } + if (opts.since !== undefined && opts.since !== null) { + postBody['since'] = opts.since + } + if (opts.until !== undefined && opts.until !== null) { + postBody['until'] = opts.until + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 zoneSecurityReport 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( + '/zones/{zone_identifier}/zoneSecurityReport', + '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.match] - 是否匹配所有搜索要求或至少一个(任何) optional + * @param {string} [opts.name] - 域名 optional + * @param {string} [opts.__account__name] - 帐户名 optional + * @param {string} [opts.order] - 按字段对域进行排序 optional + * @param {number} [opts.page] - 分页结果的页码 optional + * @param {number} [opts.per_page] - 每页的域数 optional + * @param {string} [opts.status] - 域的状态 optional + * @param {string} [opts.__account__id] - 帐户标识符标签 optional + * @param {string} [opts.direction] - asc - 升序;desc - 降序 optional + * @param {string} callback - callback + @return {Object} result + * @param zone dataList + * @param integer currentCount 当前页记录数量 + * @param integer totalCount 总记录数量 + * @param integer totalPage 总页数 + */ + + listZones (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.match !== undefined && opts.match !== null) { + queryParams['match'] = opts.match + } + if (opts.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + if (opts.__account__name !== undefined && opts.__account__name !== null) { + queryParams['__account__name'] = opts.__account__name + } + if (opts.order !== undefined && opts.order !== null) { + queryParams['order'] = opts.order + } + if (opts.page !== undefined && opts.page !== null) { + queryParams['page'] = opts.page + } + if (opts.per_page !== undefined && opts.per_page !== null) { + queryParams['per_page'] = opts.per_page + } + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + if (opts.__account__id !== undefined && opts.__account__id !== null) { + queryParams['__account__id'] = opts.__account__id + } + if (opts.direction !== undefined && opts.direction !== null) { + queryParams['direction'] = opts.direction + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 listZones 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( + '/zones', + '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 {} opts.name - 域名 + * @param {} opts.account + * @param {} [opts.jump_start] - 自动尝试获取现有DNS记录 optional + * @param {} [opts.ty_pe] - 全接入域意味着DNS由星盾托管。半接入域通常是合作伙伴托管的域或CNAME设置。 optional + * @param {string} callback - callback + @return {Object} result + * @param zone data + */ + + createZone (opts, callback) { + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createZone" + ) + } + if (opts.account === undefined || opts.account === null) { + throw new Error( + "Missing the required parameter 'opts.account' when calling createZone" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.account !== undefined && opts.account !== null) { + postBody['account'] = opts.account + } + if (opts.jump_start !== undefined && opts.jump_start !== null) { + postBody['jump_start'] = opts.jump_start + } + if (opts.ty_pe !== undefined && opts.ty_pe !== null) { + postBody['ty_pe'] = opts.ty_pe + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 createZone 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( + '/zones', + '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.identifier + * @param {string} callback - callback + @return {Object} result + * @param zone data + */ + + deleteZone (opts, callback) { + opts = opts || {} + + if (opts.identifier === undefined || opts.identifier === null) { + throw new Error( + "Missing the required parameter 'opts.identifier' when calling deleteZone" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + identifier: opts.identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 deleteZone 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( + '/zones/{identifier}', + '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.identifier + * @param {} opts.purge_everything - 指示星盾缓存中的所有资源都应该删除的标志。 +注意,执行此操作后,可能会对源服务器负载产生显著影响。 + + * @param {string} callback - callback + @return {Object} result + * @param zone data + */ + + purgeAllFiles (opts, callback) { + opts = opts || {} + + if (opts.identifier === undefined || opts.identifier === null) { + throw new Error( + "Missing the required parameter 'opts.identifier' when calling purgeAllFiles" + ) + } + if (opts.purge_everything === undefined || opts.purge_everything === null) { + throw new Error( + "Missing the required parameter 'opts.purge_everything' when calling purgeAllFiles" + ) + } + + let postBody = {} + if (opts.purge_everything !== undefined && opts.purge_everything !== null) { + postBody['purge_everything'] = opts.purge_everything + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + identifier: opts.identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 purgeAllFiles 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( + '/zones/{identifier}/purge_cache__purgeAllFiles', + '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) + } + ) + } + + /** + * 通过指定URL,从星盾的缓存中细化删除一个或多个文件。 +要清除带有自定义缓存key的文件,请包括用于计算缓存key的报头。 +例如要清除缓存key中含有${geo}或${devicetype}的文件,请包括CF-Device-Type或CF-IPCountry报头。 +注意:当包含源报头时,请确保包括scheme协议和hostname主机名。如果是默认端口,可以省略端口号(http为80,https为443),否则必须包含端口号。 + + * @param {Object} opts - parameters + * @param {string} opts.identifier + * @param {} [opts.files] - 应从缓存中删除的URL数组 optional + * @param {string} callback - callback + @return {Object} result + * @param zone data + */ + + purgeFilesByURL (opts, callback) { + opts = opts || {} + + if (opts.identifier === undefined || opts.identifier === null) { + throw new Error( + "Missing the required parameter 'opts.identifier' when calling purgeFilesByURL" + ) + } + + let postBody = {} + if (opts.files !== undefined && opts.files !== null) { + postBody['files'] = opts.files + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + identifier: opts.identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 purgeFilesByURL 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( + '/zones/{identifier}/purge_cache__purgeFilesByURL', + '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) + } + ) + } + + /** + * 通过指定主机、关联的缓存标记或前缀,从星盾的缓存中精确删除一个或多个文件。 +注意,缓存标记、主机和前缀清除每24小时的速率限制为30000次清除API调用。一次API调用最多可以清除30个标记、主机或前缀。 +对于需要以更大容量进行清除的客户,可以提高此速率限制。 + + * @param {Object} opts - parameters + * @param {string} opts.identifier + * @param {} [opts.tags] - 如何资产携带Cache-Tag头,并且它的值与提供的值之一匹配的话,该资产将从星盾缓存中清除 optional + * @param {} [opts.hosts] - 如果资产的URL中的host与提供的值之一匹配的话,该资产将从星盾缓存中清除 optional + * @param {} [opts.prefixes] - URL上与前缀匹配的任何资产都将从星盾缓存中清除。 +例如, a.com/b 意味着 a.com/b/c/d.png 会被删除,而 a.com/bc.png 不会被删除。前缀a.com/b和a.com/b/c是冗余的。 + optional + * @param {string} callback - callback + @return {Object} result + * @param zone data + */ + + purgeFilesByCache_TagsAndHostOrPrefix (opts, callback) { + opts = opts || {} + + if (opts.identifier === undefined || opts.identifier === null) { + throw new Error( + "Missing the required parameter 'opts.identifier' when calling purgeFilesByCache_TagsAndHostOrPrefix" + ) + } + + let postBody = {} + if (opts.tags !== undefined && opts.tags !== null) { + postBody['tags'] = opts.tags + } + if (opts.hosts !== undefined && opts.hosts !== null) { + postBody['hosts'] = opts.hosts + } + if (opts.prefixes !== undefined && opts.prefixes !== null) { + postBody['prefixes'] = opts.prefixes + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + identifier: opts.identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 purgeFilesByCache_TagsAndHostOrPrefix 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( + '/zones/{identifier}/purge_cache__purgeFilesByCache_TagsAndHostOrPrefix', + '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.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param zoneSetting dataList + */ + + getAllZoneSettings (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getAllZoneSettings" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getAllZoneSettings 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( + '/zones/{zone_identifier}/settings', + '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.zone_identifier + * @param {} [opts.items] - 一或多个域配置对象。必须包含ID和值。 optional + * @param {string} callback - callback + @return {Object} result + */ + + editZoneSettingsInfo (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling editZoneSettingsInfo" + ) + } + + let postBody = {} + if (opts.items !== undefined && opts.items !== null) { + postBody['items'] = opts.items + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 editZoneSettingsInfo 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( + '/zones/{zone_identifier}/settings', + 'PATCH', + 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) + } + ) + } + + /** + * 对您的网站进行高级保护,防止分布式拒绝服务(DDoS)攻击。这是一个不可编辑的值。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param advancedDDoSProtection data + */ + + getAdvancedDDOSSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getAdvancedDDOSSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getAdvancedDDOSSetting 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( + '/zones/{zone_identifier}/settings$$advanced_ddos', + '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) + } + ) + } + + /** + * 获取当前Always Online的配置。当Always Online开启时,在你的源站离线期间,星盾会提供已缓存过的页面。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param alwaysOnlineMode data + */ + + getAlwaysOnlineSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getAlwaysOnlineSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getAlwaysOnlineSetting 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( + '/zones/{zone_identifier}/settings$$always_online', + '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.zone_identifier + * @param {} [opts.value] - on - 开启;off - 关闭 optional + * @param {string} callback - callback + @return {Object} result + * @param alwaysOnlineMode data + */ + + changeAlwaysOnlineSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeAlwaysOnlineSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeAlwaysOnlineSetting 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( + '/zones/{zone_identifier}/settings$$always_online', + 'PATCH', + 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) + } + ) + } + + /** + * 对所有使用"http"的URL的请求,用301重定向到相应的 "https" URL。如果你只想对一个子集的请求进行重定向,可以考虑创建一个"Always use HTTPS"的页面规则。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param zoneSetting data + */ + + getAlwaysUseHTTPSSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getAlwaysUseHTTPSSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getAlwaysUseHTTPSSetting 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( + '/zones/{zone_identifier}/settings$$always_use_https', + '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) + } + ) + } + + /** + * 对所有使用"http"的URL的请求,用301重定向到相应的 "https" URL。如果你只想对一个子集的请求进行重定向,可以考虑创建一个"Always use HTTPS"的页面规则。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.value] - on - 开启;off - 关闭 optional + * @param {string} callback - callback + @return {Object} result + * @param zoneSetting data + */ + + changeAlwaysUseHTTPSSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeAlwaysUseHTTPSSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeAlwaysUseHTTPSSetting 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( + '/zones/{zone_identifier}/settings$$always_use_https', + 'PATCH', + 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) + } + ) + } + + /** + * 为该域启用自动HTTPS重写功能。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param zoneSetting data + */ + + getAutomaticHTTPSRewritesSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getAutomaticHTTPSRewritesSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getAutomaticHTTPSRewritesSetting 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( + '/zones/{zone_identifier}/settings$$automatic_https_rewrites', + '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) + } + ) + } + + /** + * 为该域启用自动HTTPS重写功能。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.value] - on - 开启;off - 关闭 optional + * @param {string} callback - callback + @return {Object} result + * @param zoneSetting data + */ + + changeAutomaticHTTPSRewritesSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeAutomaticHTTPSRewritesSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeAutomaticHTTPSRewritesSetting 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( + '/zones/{zone_identifier}/settings$$automatic_https_rewrites', + 'PATCH', + 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) + } + ) + } + + /** + * 浏览器缓存TTL(以秒为单位)指定星盾缓存资源将在访问者的计算机上保留多长时间。星盾将遵守服务器指定的任何更长时间。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param browserCacheTTL data + */ + + getBrowserCacheTTLSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getBrowserCacheTTLSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getBrowserCacheTTLSetting 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( + '/zones/{zone_identifier}/settings$$browser_cache_ttl', + '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) + } + ) + } + + /** + * 浏览器缓存TTL(以秒为单位)指定星盾缓存资源将在访问者的计算机上保留多长时间。星盾将遵守服务器指定的任何更长时间。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.value] - 该设置的有效值 optional + * @param {string} callback - callback + @return {Object} result + * @param browserCacheTTL data + */ + + changeBrowserCacheTTLSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeBrowserCacheTTLSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeBrowserCacheTTLSetting 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( + '/zones/{zone_identifier}/settings$$browser_cache_ttl', + 'PATCH', + 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) + } + ) + } + + /** + * 浏览器完整性检查与不良行为检查类似,寻找最常被垃圾邮件发送者滥用的常见HTTP头,并拒绝他们访问您的页面。它还会对没有用户代理或非标准用户代理(也是滥用机器人、爬虫或访客常用的)的访客提出挑战质询。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param browserCheck data + */ + + getBrowserCheckSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getBrowserCheckSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getBrowserCheckSetting 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( + '/zones/{zone_identifier}/settings$$browser_check', + '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) + } + ) + } + + /** + * 浏览器完整性检查与不良行为检查类似,寻找最常被垃圾邮件发送者滥用的常见HTTP头,并拒绝他们访问您的页面。它还会对没有用户代理或非标准用户代理(也是滥用机器人、爬虫或访客常用的)的访客提出挑战质询。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.value] - on - 开启;off - 关闭 optional + * @param {string} callback - callback + @return {Object} result + * @param browserCheck data + */ + + changeBrowserCheckSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeBrowserCheckSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeBrowserCheckSetting 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( + '/zones/{zone_identifier}/settings$$browser_check', + 'PATCH', + 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) + } + ) + } + + /** + * 缓存级别的功能是基于设置的级别。 +basic设置将缓存大多数静态资源(即css、图片和JavaScript)。 +simplified设置将在提供缓存的资源时忽略查询字符串。 +aggressive设置将缓存所有的静态资源,包括有查询字符串的资源。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.value] - 该设置的有效值 optional + * @param {string} callback - callback + @return {Object} result + * @param cloudflareCacheLevel data + */ + + changeCacheLevelSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeCacheLevelSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeCacheLevelSetting 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( + '/zones/{zone_identifier}/settings$$cache_level', + 'PATCH', + 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) + } + ) + } + + /** + * 指定访问者在成功完成一项挑战(如验证码)后允许访问您的网站多长时间。在TTL过期后,访问者将不得不完成新的挑战。我们建议设置为15-45分钟,并将尝试遵守任何超过45分钟的设置。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param challengePageTTL data + */ + + getChallengeTTLSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getChallengeTTLSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getChallengeTTLSetting 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( + '/zones/{zone_identifier}/settings$$challenge_ttl', + '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) + } + ) + } + + /** + * 指定访问者在成功完成一项挑战(如验证码)后允许访问您的网站多长时间。在TTL过期后,访问者将不得不完成新的挑战。我们建议设置为15-45分钟,并将尝试遵守任何超过45分钟的设置。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.value] - 该设置的有效值 optional + * @param {string} callback - callback + @return {Object} result + * @param challengePageTTL data + */ + + changeChallengeTTLSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeChallengeTTLSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeChallengeTTLSetting 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( + '/zones/{zone_identifier}/settings$$challenge_ttl', + 'PATCH', + 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) + } + ) + } + + /** + * 如果你需要对你的网站进行修改,开发模式可以让你暂时进入网站的开发模式。这将绕过星盾的加速缓存,并降低您的网站速度。 +但如果您正在对可缓存的内容(如图片、css 或 JavaScript)进行更改,并希望立即看到这些更改,这时就很有用。一旦进入,开发模式将持续3小时,然后自动切换关闭。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param developmentMode data + */ + + getDevelopmentModeSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getDevelopmentModeSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getDevelopmentModeSetting 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( + '/zones/{zone_identifier}/settings$$development_mode', + '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) + } + ) + } + + /** + * 如果你需要对你的网站进行修改,开发模式可以让你暂时进入网站的开发模式。这将绕过星盾的加速缓存,并降低您的网站速度。 +但如果您正在对可缓存的内容(如图片、css 或 JavaScript)进行更改,并希望立即看到这些更改,这时就很有用。一旦进入,开发模式将持续3小时,然后自动切换关闭。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.value] - on - 开启;off - 关闭 optional + * @param {string} callback - callback + @return {Object} result + * @param developmentMode data + */ + + changeDevelopmentModeSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeDevelopmentModeSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeDevelopmentModeSetting 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( + '/zones/{zone_identifier}/settings$$development_mode', + 'PATCH', + 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.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param emailObfuscation data + */ + + getEmailObfuscationSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getEmailObfuscationSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getEmailObfuscationSetting 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( + '/zones/{zone_identifier}/settings$$email_obfuscation', + '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.zone_identifier + * @param {} [opts.value] - on - 开启;off - 关闭 optional + * @param {string} callback - callback + @return {Object} result + * @param emailObfuscation data + */ + + changeEmailObfuscationSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeEmailObfuscationSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeEmailObfuscationSetting 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( + '/zones/{zone_identifier}/settings$$email_obfuscation', + 'PATCH', + 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.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param hotlinkProtection data + */ + + getHotlinkProtectionSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getHotlinkProtectionSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getHotlinkProtectionSetting 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( + '/zones/{zone_identifier}/settings$$hotlink_protection', + '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.zone_identifier + * @param {} [opts.value] - on - 开启;off - 关闭 optional + * @param {string} callback - callback + @return {Object} result + * @param hotlinkProtection data + */ + + changeHotlinkProtectionSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeHotlinkProtectionSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeHotlinkProtectionSetting 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( + '/zones/{zone_identifier}/settings$$hotlink_protection', + 'PATCH', + 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地理定位,让星盾对您网站的访问者进行地理定位,并将国家代码传递给您。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param iPGeolocation data + */ + + getIPGeolocationSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getIPGeolocationSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getIPGeolocationSetting 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( + '/zones/{zone_identifier}/settings$$ip_geolocation', + '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地理定位,让星盾对您网站的访问者进行地理定位,并将国家代码传递给您。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.value] - on - 开启;off - 关闭 optional + * @param {string} callback - callback + @return {Object} result + * @param iPGeolocation data + */ + + changeIPGeolocationSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeIPGeolocationSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeIPGeolocationSetting 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( + '/zones/{zone_identifier}/settings$$ip_geolocation', + 'PATCH', + 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) + } + ) + } + + /** + * 在所有启用星盾的子域上启用 IPv6。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param iPv6 data + */ + + getIPv6Setting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getIPv6Setting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getIPv6Setting 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( + '/zones/{zone_identifier}/settings$$ipv6', + '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) + } + ) + } + + /** + * 在所有启用星盾的子域上启用 IPv6。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.value] - on - 开启;off - 关闭 optional + * @param {string} callback - callback + @return {Object} result + * @param iPv6 data + */ + + changeIPv6Setting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeIPv6Setting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeIPv6Setting 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( + '/zones/{zone_identifier}/settings$$ipv6', + 'PATCH', + 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.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param auto_MinifyAssets data + */ + + getMinifySetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getMinifySetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getMinifySetting 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( + '/zones/{zone_identifier}/settings$$minify', + '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.zone_identifier + * @param {} [opts.value] optional + * @param {string} callback - callback + @return {Object} result + * @param auto_MinifyAssets data + */ + + changeMinifySetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeMinifySetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeMinifySetting 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( + '/zones/{zone_identifier}/settings$$minify', + 'PATCH', + 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.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param mobileRedirect data + */ + + getMobileRedirectSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getMobileRedirectSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getMobileRedirectSetting 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( + '/zones/{zone_identifier}/settings$$mobile_redirect', + '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.zone_identifier + * @param {} [opts.value] optional + * @param {string} callback - callback + @return {Object} result + * @param mobileRedirect data + */ + + changeMobileRedirectSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeMobileRedirectSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeMobileRedirectSetting 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( + '/zones/{zone_identifier}/settings$$mobile_redirect', + 'PATCH', + 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.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param mirageImageOptimization data + */ + + getMirageSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getMirageSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getMirageSetting 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( + '/zones/{zone_identifier}/settings$$mirage', + '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.zone_identifier + * @param {} [opts.value] - on - 开启;off - 关闭 optional + * @param {string} callback - callback + @return {Object} result + * @param mirageImageOptimization data + */ + + changeMirageSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeMirageSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeMirageSetting 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( + '/zones/{zone_identifier}/settings$$mirage', + 'PATCH', + 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) + } + ) + } + + /** + * 星盾将代源服务器上任何 502、504 错误的客户错误页面,而不是显示默认的星盾错误页面。这不适用于 522 错误,并且仅限于企业级域。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param zoneSetting data + */ + + getEnableErrorPagesOnSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getEnableErrorPagesOnSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getEnableErrorPagesOnSetting 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( + '/zones/{zone_identifier}/settings$$origin_error_page_pass_thru', + '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) + } + ) + } + + /** + * 星盾将代理源服务器上任何 502、504 错误的客户错误页面,而不是显示默认的星盾错误页面。这不适用于 522 错误,并且仅限于企业级域。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.value] - on - 开启;off - 关闭 optional + * @param {string} callback - callback + @return {Object} result + * @param zoneSetting data + */ + + changeEnableErrorPagesOnSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeEnableErrorPagesOnSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeEnableErrorPagesOnSetting 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( + '/zones/{zone_identifier}/settings$$origin_error_page_pass_thru', + 'PATCH', + 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.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param zoneEnableOpportunisticEncryption data + */ + + getOpportunisticEncryptionSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getOpportunisticEncryptionSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getOpportunisticEncryptionSetting 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( + '/zones/{zone_identifier}/settings$$opportunistic_encryption', + '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.zone_identifier + * @param {} [opts.value] - on - 开启;off - 关闭 optional + * @param {string} callback - callback + @return {Object} result + * @param zoneEnableOpportunisticEncryption data + */ + + changeOpportunisticEncryptionSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeOpportunisticEncryptionSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeOpportunisticEncryptionSetting 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( + '/zones/{zone_identifier}/settings$$opportunistic_encryption', + 'PATCH', + 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) + } + ) + } + + /** + * 剥离元数据并压缩你的图像,以加快页面加载时间。 +Basic(无损),减少PNG、JPEG和GIF文件的大小 - 对视觉质量没有影响。 +Basic+JPEG(有损),进一步减少JPEG文件的大小,以加快图像加载。 +较大的JPEG文件被转换为渐进式图像,首先加载较低分辨率的图像,最后是较高的分辨率版本。 +不建议用于高像素的摄影网站。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param polishImageOptimization data + */ + + getPolishSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getPolishSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getPolishSetting 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( + '/zones/{zone_identifier}/settings$$polish', + '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) + } + ) + } + + /** + * 剥离元数据并压缩你的图像,以加快页面加载时间。 +Basic(无损),减少PNG、JPEG和GIF文件的大小 - 对视觉质量没有影响。 +Basic+JPEG(有损),进一步减少JPEG文件的大小,以加快图像加载。 +较大的JPEG文件被转换为渐进式图像,首先加载较低分辨率的图像,最后是较高的分辨率版本。 +不建议用于高像素的摄影网站。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.value] - 该设置的有效值 optional + * @param {string} callback - callback + @return {Object} result + * @param polishImageOptimization data + */ + + changePolishSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changePolishSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changePolishSetting 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( + '/zones/{zone_identifier}/settings$$polish', + 'PATCH', + 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) + } + ) + } + + /** + * 当请求图像的客户端支持WebP图像编解码器时。当WebP比原始图像格式具有性能优势时,星盾将提供WebP版本的图像。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param polishWebPConversion data + */ + + getWebPSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getWebPSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getWebPSetting 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( + '/zones/{zone_identifier}/settings$$webp', + '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) + } + ) + } + + /** + * 当请求图像的客户端支持WebP图像编解码器时。当WebP比原始图像格式具有性能优势时,星盾将提供WebP版本的图像。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.value] - on - 开启;off - 关闭 optional + * @param {string} callback - callback + @return {Object} result + * @param polishWebPConversion data + */ + + changeWebPSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeWebPSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeWebPSetting 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( + '/zones/{zone_identifier}/settings$$webp', + 'PATCH', + 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) + } + ) + } + + /** + * 当请求资产的客户端支持brotli压缩算法时,星盾将提供资产的brotli压缩版本。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.value] - on - 开启;off - 关闭 optional + * @param {string} callback - callback + @return {Object} result + * @param brotliCompression data + */ + + changeBrotliSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeBrotliSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeBrotliSetting 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( + '/zones/{zone_identifier}/settings$$brotli', + 'PATCH', + 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) + } + ) + } + + /** + * 星盾将预取包含在响应标头中的任何 URL。这只限于企业级域。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param zoneSetting data + */ + + getPrefetchPreloadSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getPrefetchPreloadSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getPrefetchPreloadSetting 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( + '/zones/{zone_identifier}/settings$$prefetch_preload', + '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) + } + ) + } + + /** + * 星盾将预取包含在响应标头中的任何 URL。这只限于企业级域。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.value] - on - 开启;off - 关闭 optional + * @param {string} callback - callback + @return {Object} result + * @param prefetchPreload data + */ + + changePrefetchPreloadSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changePrefetchPreloadSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changePrefetchPreloadSetting 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( + '/zones/{zone_identifier}/settings$$prefetch_preload', + 'PATCH', + 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) + } + ) + } + + /** + * Privacy Pass是一个由Privacy Pass团队开发的浏览器扩展,旨在改善您的访客的浏览体验。启用Privacy Pass将减少显示给你的访客的验证码的数量。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param privacyPass data + */ + + getPrivacyPassSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getPrivacyPassSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getPrivacyPassSetting 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( + '/zones/{zone_identifier}/settings$$privacy_pass', + '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) + } + ) + } + + /** + * Privacy Pass是一个由Privacy Pass团队开发的浏览器扩展,旨在改善您的访客的浏览体验。启用Privacy Pass将减少显示给你的访客的验证码的数量。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.value] - on - 开启;off - 关闭 optional + * @param {string} callback - callback + @return {Object} result + * @param privacyPass data + */ + + changePrivacyPassSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changePrivacyPassSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changePrivacyPassSetting 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( + '/zones/{zone_identifier}/settings$$privacy_pass', + 'PATCH', + 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) + } + ) + } + + /** + * Rocket Loader是一个通用的异步JavaScript优化,它优先渲染你的内容同时异步加载你的网站的Javascript。 +开启Rocket Loader将立即改善网页的渲染时间,有时以首次绘制时间(TTFP)以及window.onload时间(假设页面上有JavaScript)来衡量,这对你的搜索排名会产生积极影响。 +当打开时,Rocket Loader将自动推迟加载你的HTML中引用的所有Javascript,而不需要配置。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param rocketLoader data + */ + + getRocketLoaderSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getRocketLoaderSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getRocketLoaderSetting 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( + '/zones/{zone_identifier}/settings$$rocket_loader', + '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) + } + ) + } + + /** + * Rocket Loader是一个通用的异步JavaScript优化,它优先渲染你的内容同时异步加载你的网站的Javascript。 +开启Rocket Loader将立即改善网页的渲染时间,有时以首次绘制时间(TTFP)以及window.onload时间(假设页面上有JavaScript)来衡量,这对你的搜索排名会产生积极影响。 +当打开时,Rocket Loader将自动推迟加载你的HTML中引用的所有Javascript,而不需要配置。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.value] - on - 开启;off - 关闭 optional + * @param {string} callback - callback + @return {Object} result + * @param rocketLoader data + */ + + changeRocketLoaderSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeRocketLoaderSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeRocketLoaderSetting 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( + '/zones/{zone_identifier}/settings$$rocket_loader', + 'PATCH', + 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.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param securityHeader data + */ + + getSecurityHeaderHSTSSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getSecurityHeaderHSTSSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getSecurityHeaderHSTSSetting 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( + '/zones/{zone_identifier}/settings$$security_header', + '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.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param securityLevel data + */ + + getSecurityLevelSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getSecurityLevelSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getSecurityLevelSetting 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( + '/zones/{zone_identifier}/settings$$security_level', + '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.zone_identifier + * @param {} [opts.value] - 该设置的有效值 optional + * @param {string} callback - callback + @return {Object} result + * @param securityLevel data + */ + + changeSecurityLevelSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeSecurityLevelSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeSecurityLevelSetting 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( + '/zones/{zone_identifier}/settings$$security_level', + 'PATCH', + 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) + } + ) + } + + /** + * 如果你的网站上有敏感的内容,你想让真正的访问者看到,但你想对可疑的访问者进行隐藏,你所要做的就是用星盾SSE标签来包装这些内容。 +用下面的SSE标签包住任何你想不让可疑访客看到的内容,<!--sse--><!--/sse-->。 +例如,<!--sse-->不好的访问者不会看到我的电话号码,555-555-5555<!--/sse-->。注意,SSE只对HTML起作用。 +如果你启用了HTML最小化功能,当你的HTML源代码通过星盾提供服务时,你不会看到SSE标签。 +在这种情况下,SSE 仍将发挥作用,因为星盾的 HTML 缩减和 SSE 功能是在资源通过我们的网络传输给我们时即时发生的。当资源通过我们的网络移动到访问者的计算机上时,SSE 仍会发挥作用。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param serverSideExclude data + */ + + getServerSideExcludeSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getServerSideExcludeSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getServerSideExcludeSetting 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( + '/zones/{zone_identifier}/settings$$server_side_exclude', + '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) + } + ) + } + + /** + * 如果你的网站上有敏感的内容,你想让真正的访问者看到,但你想对可疑的访问者进行隐藏,你所要做的就是用星盾SSE标签来包装这些内容。 +用下面的SSE标签包住任何你想不让可疑访客看到的内容,<!--sse--><!--/sse-->。 +例如,<!--sse-->不好的访问者不会看到我的电话号码,555-555-5555<!--/sse-->。注意,SSE只对HTML起作用。 +如果你启用了HTML最小化功能,当你的HTML源代码通过星盾提供服务时,你不会看到SSE标签。 +在这种情况下,SSE 仍将发挥作用,因为星盾的 HTML 缩减和 SSE 功能是在资源通过我们的网络传输给我们时即时发生的。当资源通过我们的网络移动到访问者的计算机上时,SSE 仍会发挥作用。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.value] - on - 开启;off - 关闭 optional + * @param {string} callback - callback + @return {Object} result + * @param serverSideExclude data + */ + + changeServerSideExcludeSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeServerSideExcludeSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeServerSideExcludeSetting 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( + '/zones/{zone_identifier}/settings$$server_side_exclude', + 'PATCH', + 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.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param zoneSetting data + */ + + getEnableQueryStringSortSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getEnableQueryStringSortSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getEnableQueryStringSortSetting 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( + '/zones/{zone_identifier}/settings$$sort_query_string_for_cache', + '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.zone_identifier + * @param {} [opts.value] - on - 开启;off - 关闭 optional + * @param {string} callback - callback + @return {Object} result + * @param zoneSetting data + */ + + changeEnableQueryStringSortSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeEnableQueryStringSortSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeEnableQueryStringSortSetting 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( + '/zones/{zone_identifier}/settings$$sort_query_string_for_cache', + 'PATCH', + 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) + } + ) + } + + /** + * SSL对访问者的连接进行加密,并保护信用卡号码和其他进出网站的个人数据。 +SSL最多需要5分钟才能完全激活。需要在星盾激活你的根域或www域。 +Off,访客和星盾之间没有SSL,星盾和你的Web服务器之间也没有SSL(所有HTTP流量)。 +Flexible, 访客和星盾之间的 SSL -- 访客在你的网站上看到 HTTPS,但星盾和你的 Web 服务器之间没有 SSL。您不需要在您的 Web 服务器上安装 SSL 证书,但您的访客仍会看到启用 HTTPS 的网站。 +Full, 访客和星盾之间的 SSL -- 访客在你的网站上看到 HTTPS,以及星盾和你的 Web 服务器之间的 SSL。您至少需要有自己的 SSL 证书或自签名的证书。 +Full (Strict), 访客和星盾之间的 SSL -- 访客在您的网站上看到 HTTPS,以及星盾和您的 Web 服务器之间的 SSL。你需要在你的网络服务器上安装一个有效的SSL证书。 +这个证书必须由一个证书机构签署,有一个在未来的到期日,并为请求的域名(主机名)作出回应。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param sSL data + */ + + getSSLSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getSSLSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getSSLSetting 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( + '/zones/{zone_identifier}/settings$$ssl', + '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) + } + ) + } + + /** + * SSL对访问者的连接进行加密,并保护信用卡号码和其他进出网站的个人数据。 +SSL最多需要5分钟才能完全激活。需要在星盾激活你的根域或www域。 +Off,访客和星盾之间没有SSL,星盾和你的Web服务器之间也没有SSL(所有HTTP流量)。 +Flexible, 访客和星盾之间的 SSL -- 访客在你的网站上看到 HTTPS,但星盾和你的 Web 服务器之间没有 SSL。您不需要在您的 Web 服务器上安装 SSL 证书,但您的访客仍会看到启用 HTTPS 的网站。 +Full, 访客和星盾之间的 SSL -- 访客在你的网站上看到 HTTPS,以及星盾和你的 Web 服务器之间的 SSL。您至少需要有自己的 SSL 证书或自签名的证书。 +Full (Strict), 访客和星盾之间的 SSL -- 访客在您的网站上看到 HTTPS,以及星盾和您的 Web 服务器之间的 SSL。你需要在你的网络服务器上安装一个有效的SSL证书。 +这个证书必须由一个证书机构签署,有一个在未来的到期日,并为请求的域名(主机名)作出回应。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.value] - 该设置的有效值,off/flexible/full/strict optional + * @param {string} callback - callback + @return {Object} result + * @param sSL data + */ + + changeSSLSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeSSLSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeSSLSetting 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( + '/zones/{zone_identifier}/settings$$ssl', + 'PATCH', + 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) + } + ) + } + + /** + * 获取HTTPS请求允许使用的TLS协议的最低版本。例如,如果是TLS 1.1,那么TLS 1.0连接将被拒绝,而1.1、1.2和1.3(如果启用)将被允许。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param zoneSetting data + */ + + getMinimumTLSVersionSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getMinimumTLSVersionSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getMinimumTLSVersionSetting 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( + '/zones/{zone_identifier}/settings$$min_tls_version', + '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) + } + ) + } + + /** + * 设置HTTPS请求使用的TLS协议的最低版本。例如,如果选择TLS 1.1,那么TLS 1.0连接将被拒绝,而1.1、1.2和1.3(如果启用)将被允许。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.value] - TLS协议版本 optional + * @param {string} callback - callback + @return {Object} result + * @param zoneSetting data + */ + + changeMinimumTLSVersionSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeMinimumTLSVersionSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeMinimumTLSVersionSetting 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( + '/zones/{zone_identifier}/settings$$min_tls_version', + 'PATCH', + 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) + } + ) + } + + /** + * 一个用于TLS终端的密码允许列表。这些密码必须是BoringSSL的格式。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param string dataList + */ + + getCiphersSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getCiphersSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getCiphersSetting 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( + '/zones/{zone_identifier}/settings$$ciphers', + '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) + } + ) + } + + /** + * 一个用于TLS终端的密码允许列表。这些密码必须是BoringSSL的格式。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.value] - 该设置的值 optional + * @param {string} callback - callback + @return {Object} result + * @param string dataList + */ + + changeCiphersSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeCiphersSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeCiphersSetting 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( + '/zones/{zone_identifier}/settings$$ciphers', + 'PATCH', + 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) + } + ) + } + + /** + * 为该域启用加密TLS 1.3功能。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param zoneSetting data + */ + + getZoneEnableTLS1_3Setting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getZoneEnableTLS1_3Setting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getZoneEnableTLS1_3Setting 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( + '/zones/{zone_identifier}/settings$$tls_1_3', + '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) + } + ) + } + + /** + * 为该域启用加密TLS 1.3功能。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.value] - 该设置的有效值 optional + * @param {string} callback - callback + @return {Object} result + * @param zoneSetting data + */ + + changeTLS1_3Setting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeTLS1_3Setting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeTLS1_3Setting 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( + '/zones/{zone_identifier}/settings$$tls_1_3', + 'PATCH', + 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) + } + ) + } + + /** + * TLS 客户端授权要求星盾使用客户端证书连接到您的源服务器(Enterprise Only)。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param tLSClientAuthentication data + */ + + getTLSClientAuthSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getTLSClientAuthSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getTLSClientAuthSetting 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( + '/zones/{zone_identifier}/settings$$tls_client_auth', + '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) + } + ) + } + + /** + * TLS 客户端授权要求星盾使用客户端证书连接到您的源服务器(Enterprise Only)。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.value] - on - 开启;off - 关闭 optional + * @param {string} callback - callback + @return {Object} result + * @param tLSClientAuthentication data + */ + + changeTLSClientAuthSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeTLSClientAuthSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeTLSClientAuthSetting 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( + '/zones/{zone_identifier}/settings$$tls_client_auth', + 'PATCH', + 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。这只限于企业级域。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param zoneSetting data + */ + + getTrueClientIPSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getTrueClientIPSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getTrueClientIPSetting 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( + '/zones/{zone_identifier}/settings$$true_client_ip_header', + '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。这只限于企业级域。 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.value] - on - 开启;off - 关闭 optional + * @param {string} callback - callback + @return {Object} result + * @param zoneSetting data + */ + + changeTrueClientIPSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeTrueClientIPSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeTrueClientIPSetting 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( + '/zones/{zone_identifier}/settings$$true_client_ip_header', + 'PATCH', + 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) + } + ) + } + + /** + * WAF检查对您网站的HTTP请求。它检查GET和POST请求,并应用规则来帮助从合法的网站访问者中过滤出非法流量。星盾 WAF 检查网站地址或 URL 以检测任何不正常的东西。 +如果星盾 WAF确定了可疑的用户行为。那么 WAF 将用一个页面 "挑战 "网络访客,要求他们成功提交验证码以继续其行动。 +如果挑战失败,行动将被停止。这意味着 星盾 的 WAF 将在任何被识别为非法的流量到达您的源网络服务器之前将其阻止。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param webApplicationFirewall data + */ + + getWebApplicationFirewallWAFSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getWebApplicationFirewallWAFSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getWebApplicationFirewallWAFSetting 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( + '/zones/{zone_identifier}/settings$$waf', + '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) + } + ) + } + + /** + * WAF检查对您网站的HTTP请求。它检查GET和POST请求,并应用规则来帮助从合法的网站访问者中过滤出非法流量。星盾 WAF 检查网站地址或 URL 以检测任何不正常的东西。 +如果星盾 WAF确定了可疑的用户行为。那么 WAF 将用一个页面 "挑战 "网络访客,要求他们成功提交验证码以继续其行动。 +如果挑战失败,行动将被停止。这意味着 星盾 的 WAF 将在任何被识别为非法的流量到达您的源网络服务器之前将其阻止。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.value] - on - 开启;off - 关闭 optional + * @param {string} callback - callback + @return {Object} result + * @param webApplicationFirewall data + */ + + changeWebApplicationFirewallWAFSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeWebApplicationFirewallWAFSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeWebApplicationFirewallWAFSetting 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( + '/zones/{zone_identifier}/settings$$waf', + 'PATCH', + 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) + } + ) + } + + /** + * 获取HTTP2设置的状态 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param hTTP2Value data + */ + + getHTTP2Setting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getHTTP2Setting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getHTTP2Setting 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( + '/zones/{zone_identifier}/settings$$http2', + '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) + } + ) + } + + /** + * 开启/关闭HTTP2 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.value] - on - 开启;off - 关闭 optional + * @param {string} callback - callback + @return {Object} result + * @param hTTP2Value data + */ + + changeHTTP2Setting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeHTTP2Setting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeHTTP2Setting 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( + '/zones/{zone_identifier}/settings$$http2', + 'PATCH', + 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) + } + ) + } + + /** + * 获取HTTP3设置的状态 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param hTTP3Value data + */ + + getHTTP3Setting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getHTTP3Setting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getHTTP3Setting 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( + '/zones/{zone_identifier}/settings$$http3', + '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) + } + ) + } + + /** + * 开启/关闭HTTP3 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.value] - on - 开启;off - 关闭 optional + * @param {string} callback - callback + @return {Object} result + * @param hTTP3Value data + */ + + changeHTTP3Setting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeHTTP3Setting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeHTTP3Setting 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( + '/zones/{zone_identifier}/settings$$http3', + 'PATCH', + 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) + } + ) + } + + /** + * Value of the 0-RTT setting + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param zero_RTTValue data + */ + + get0_RTTSessionResumptionSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling get0_RTTSessionResumptionSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 get0_RTTSessionResumptionSetting 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( + '/zones/{zone_identifier}/settings$$0rtt', + '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) + } + ) + } + + /** + * 开启/关闭 0-RTT + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.value] - on - 开启;off - 关闭 optional + * @param {string} callback - callback + @return {Object} result + * @param zero_RTTValue data + */ + + change0_RTTSessionResumptionSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling change0_RTTSessionResumptionSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 change0_RTTSessionResumptionSetting 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( + '/zones/{zone_identifier}/settings$$0rtt', + 'PATCH', + 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) + } + ) + } + + /** + * 获取Pseudo IPv4(IPv6到IPv4的转换服务)的设置 + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param pseudoIPv4Value data + */ + + getPseudoIPv4Setting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getPseudoIPv4Setting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getPseudoIPv4Setting 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( + '/zones/{zone_identifier}/settings$$pseudo_ipv4', + '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) + } + ) + } + + /** + * 设置Pseudo IPv4(IPv6到IPv4的转换服务) + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.value] - 该设置的有效值 optional + * @param {string} callback - callback + @return {Object} result + * @param pseudoIPv4Value data + */ + + changePseudoIPv4Setting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changePseudoIPv4Setting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changePseudoIPv4Setting 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( + '/zones/{zone_identifier}/settings$$pseudo_ipv4', + 'PATCH', + 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) + } + ) + } + + /** + * WebSockets是客户端和源服务器之间持续的开放连接。在WebSockets连接中,客户端和源服务器可以来回传递数据,而不需要重新建立会话。 +这使得在WebSockets连接中的数据交换非常快。WebSockets经常被用于实时应用,如即时聊天和游戏。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param webSockets data + */ + + getWebSocketsSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getWebSocketsSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getWebSocketsSetting 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( + '/zones/{zone_identifier}/settings$$websockets', + '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) + } + ) + } + + /** + * WebSockets是客户端和源服务器之间持续的开放连接。在WebSockets连接中,客户端和源服务器可以来回传递数据,而不需要重新建立会话。 +这使得在WebSockets连接中的数据交换非常快。WebSockets经常被用于实时应用,如即时聊天和游戏。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.value] - on - 开启;off - 关闭 optional + * @param {string} callback - callback + @return {Object} result + * @param webSockets data + */ + + changeWebSocketsSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeWebSocketsSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeWebSocketsSetting 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( + '/zones/{zone_identifier}/settings$$websockets', + 'PATCH', + 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.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param imageResizing data + */ + + getImageResizingSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getImageResizingSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getImageResizingSetting 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( + '/zones/{zone_identifier}/settings$$image_resizing', + '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) + } + ) + } + + /** + * HTTP/2边缘优化,优化了通过HTTP/2提供的资源交付,提高了页面加载性能。当与Worker结合使用时,它还支持对内容交付的精细控制。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {string} callback - callback + @return {Object} result + * @param hTTP2EdgePrioritization data + */ + + getHTTP2EdgePrioritizationSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling getHTTP2EdgePrioritizationSetting" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 getHTTP2EdgePrioritizationSetting 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( + '/zones/{zone_identifier}/settings$$h2_prioritization', + '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) + } + ) + } + + /** + * HTTP/2边缘优化,优化了通过HTTP/2提供的资源交付,提高了页面加载性能。当与Worker结合使用时,它还支持对内容交付的精细控制。 + + * @param {Object} opts - parameters + * @param {string} opts.zone_identifier + * @param {} [opts.value] - 该设置的有效值 optional + * @param {string} callback - callback + @return {Object} result + * @param hTTP2EdgePrioritization data + */ + + changeHTTP2EdgePrioritizationSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeHTTP2EdgePrioritizationSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeHTTP2EdgePrioritizationSetting 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( + '/zones/{zone_identifier}/settings$$h2_prioritization', + 'PATCH', + 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.zone_identifier + * @param {} [opts.value] optional + * @param {string} callback - callback + @return {Object} result + * @param maxUpload data + */ + + changeMaxUploadSetting (opts, callback) { + opts = opts || {} + + if (opts.zone_identifier === undefined || opts.zone_identifier === null) { + throw new Error( + "Missing the required parameter 'opts.zone_identifier' when calling changeMaxUploadSetting" + ) + } + + let postBody = {} + if (opts.value !== undefined && opts.value !== null) { + postBody['value'] = opts.value + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + zone_identifier: opts.zone_identifier + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 starshield/0.0.14' + } + + 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 changeMaxUploadSetting 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( + '/zones/{zone_identifier}/settings$$max_upload', + 'PATCH', + 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 = STARSHIELD diff --git a/packages/libs/lib-jdcloud/src/repo/streambus/v1/streambus.js b/packages/libs/lib-jdcloud/src/repo/streambus/v1/streambus.js new file mode 100644 index 000000000..8497657f8 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/streambus/v1/streambus.js @@ -0,0 +1,956 @@ +/* + * 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. + * + * ConsumerGroup相关 API + * 流数据总线ConsumerGroup相关信息接口 + * + * 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 = 'streambus' +Service._services[serviceId] = true + +/** + * streambus service. + * @version 1.0.1 + */ + +JDCloud.STREAMBUS = class STREAMBUS extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'streambus.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询topic列表,返回topic的集合 + * @param {Object} opts - parameters + * @param {string} [opts.keyword] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param topicListInfo topic + */ + + getTopicList (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 getTopicList" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.keyword !== undefined && opts.keyword !== null) { + queryParams['keyword'] = opts.keyword + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 streambus/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 getTopicList 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 = this.makeRequest( + '/regions/{regionId}/topicList', + '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.name + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param topicModel topic + */ + + describeTopic (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 describeTopic" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling describeTopic" + ) + } + + let postBody = null + let queryParams = {} + if (opts.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 streambus/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 describeTopic 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 = this.makeRequest( + '/regions/{regionId}/topic', + '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) + } + ) + } + + /** + * 创建topic时,topicModel中只需要传topic参数,另外两个参数可为空 + * @param {Object} opts - parameters + * @param {topicModel} opts.topicModel - 示例:{"topicModel":{"topic":{"archived":0,"id":"","name":"create","remark":"备注","shardNum":1,"partitionNum":2,"lifecycle":3}}} + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status + * @param string message 状态信息 + */ + + addTopic (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 addTopic" + ) + } + + opts = opts || {} + + if (opts.topicModel === undefined || opts.topicModel === null) { + throw new Error( + "Missing the required parameter 'opts.topicModel' when calling addTopic" + ) + } + + let postBody = {} + if (opts.topicModel !== undefined && opts.topicModel !== null) { + postBody['topicModel'] = opts.topicModel + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 streambus/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 addTopic 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 = this.makeRequest( + '/regions/{regionId}/topic', + '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 {topicModel} opts.topicModel - 当更新主题时只需要修改topicModel中的topic中的属性即可;创建归档需要指定target以及归档的目的地(mysql,京东云 Elasticsearch,对象存储,数据计算服务)参数 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status + * @param string message 状态信息 + */ + + updateTopic (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 updateTopic" + ) + } + + opts = opts || {} + + if (opts.topicModel === undefined || opts.topicModel === null) { + throw new Error( + "Missing the required parameter 'opts.topicModel' when calling updateTopic" + ) + } + + let postBody = {} + if (opts.topicModel !== undefined && opts.topicModel !== null) { + postBody['topicModel'] = opts.topicModel + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 streambus/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 updateTopic 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 = this.makeRequest( + '/regions/{regionId}/topic', + '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) + } + ) + } + + /** + * 删除topic + * @param {Object} opts - parameters + * @param {string} opts.name + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status + * @param string message 状态信息 + */ + + deleteTopic (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 deleteTopic" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling deleteTopic" + ) + } + + let postBody = null + let queryParams = {} + if (opts.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 streambus/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 deleteTopic 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 = this.makeRequest( + '/regions/{regionId}/topic', + '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.topicId - 主题id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param consumerGroup consumerGroup + */ + + getConsumerGroupList (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 getConsumerGroupList" + ) + } + + opts = opts || {} + + if (opts.topicId === undefined || opts.topicId === null) { + throw new Error( + "Missing the required parameter 'opts.topicId' when calling getConsumerGroupList" + ) + } + + let postBody = null + let queryParams = {} + if (opts.topicId !== undefined && opts.topicId !== null) { + queryParams['topicId'] = opts.topicId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 streambus/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 getConsumerGroupList 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 = this.makeRequest( + '/regions/{regionId}/consumerGroupList', + '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) + } + ) + } + + /** + * 创建consumerGroupName + * @param {Object} opts - parameters + * @param {consumerGroup} [opts.consumerGroupStr] - 消费组对象 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string message + * @param boolean status + */ + + createConsumerGroup (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 createConsumerGroup" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.consumerGroupStr !== undefined && opts.consumerGroupStr !== null) { + postBody['consumerGroupStr'] = opts.consumerGroupStr + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 streambus/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 createConsumerGroup 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 = this.makeRequest( + '/regions/{regionId}/consumerGroup', + '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) + } + ) + } + + /** + * 删除consumerGroupName + * @param {Object} opts - parameters + * @param {integer} opts.topicId - 主题ID + * @param {integer} opts.consumerGroupId - 消费组ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string message + * @param boolean status + */ + + deleteConsumerGroup (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 deleteConsumerGroup" + ) + } + + opts = opts || {} + + if (opts.topicId === undefined || opts.topicId === null) { + throw new Error( + "Missing the required parameter 'opts.topicId' when calling deleteConsumerGroup" + ) + } + if (opts.consumerGroupId === undefined || opts.consumerGroupId === null) { + throw new Error( + "Missing the required parameter 'opts.consumerGroupId' when calling deleteConsumerGroup" + ) + } + + let postBody = null + let queryParams = {} + if (opts.topicId !== undefined && opts.topicId !== null) { + queryParams['topicId'] = opts.topicId + } + if (opts.consumerGroupId !== undefined && opts.consumerGroupId !== null) { + queryParams['consumerGroupId'] = opts.consumerGroupId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 streambus/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 deleteConsumerGroup 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 = this.makeRequest( + '/regions/{regionId}/consumerGroup', + '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) + } + ) + } +} +module.exports = JDCloud.STREAMBUS diff --git a/packages/libs/lib-jdcloud/src/repo/streamcomputer/v1/streamcomputer.js b/packages/libs/lib-jdcloud/src/repo/streamcomputer/v1/streamcomputer.js new file mode 100644 index 000000000..1de5287c4 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/streamcomputer/v1/streamcomputer.js @@ -0,0 +1,1787 @@ +/* + * 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. + * + * storage相关 API + * 流计算storage相关信息接口 + * + * 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 = 'streamcomputer' +Service._services[serviceId] = true + +/** + * streamcomputer service. + * @version 1.0.1 + */ + +JDCloud.STREAMCOMPUTER = class STREAMCOMPUTER extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'streamcompute.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询指定作业详情 + * @param {Object} opts - parameters + * @param {integer} opts.jobId + * @param {integer} opts.namespaceId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param jobStr jobStr + */ + + describeJob (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 describeJob" + ) + } + + opts = opts || {} + + if (opts.jobId === undefined || opts.jobId === null) { + throw new Error( + "Missing the required parameter 'opts.jobId' when calling describeJob" + ) + } + if (opts.namespaceId === undefined || opts.namespaceId === null) { + throw new Error( + "Missing the required parameter 'opts.namespaceId' when calling describeJob" + ) + } + + let postBody = null + let queryParams = {} + if (opts.jobId !== undefined && opts.jobId !== null) { + queryParams['jobId'] = opts.jobId + } + if (opts.namespaceId !== undefined && opts.namespaceId !== null) { + queryParams['namespaceId'] = opts.namespaceId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 streamcomputer/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 describeJob 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 = this.makeRequest( + '/regions/{regionId}/job', + '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) + } + ) + } + + /** + * 添加或者更新job + * @param {Object} opts - parameters + * @param {jobStr} opts.jobStr - 创建作业的详情 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param okInfo okInfo 成功结果对象 + */ + + addOrUpdateJob (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 addOrUpdateJob" + ) + } + + opts = opts || {} + + if (opts.jobStr === undefined || opts.jobStr === null) { + throw new Error( + "Missing the required parameter 'opts.jobStr' when calling addOrUpdateJob" + ) + } + + let postBody = {} + if (opts.jobStr !== undefined && opts.jobStr !== null) { + postBody['jobStr'] = opts.jobStr + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 streamcomputer/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 addOrUpdateJob 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 = this.makeRequest( + '/regions/{regionId}/job', + '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.namespaceId + * @param {integer} opts.jobId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string message 删除job返回信息 + * @param boolean status + */ + + deleteJob (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 deleteJob" + ) + } + + opts = opts || {} + + if (opts.namespaceId === undefined || opts.namespaceId === null) { + throw new Error( + "Missing the required parameter 'opts.namespaceId' when calling deleteJob" + ) + } + if (opts.jobId === undefined || opts.jobId === null) { + throw new Error( + "Missing the required parameter 'opts.jobId' when calling deleteJob" + ) + } + + let postBody = null + let queryParams = {} + if (opts.namespaceId !== undefined && opts.namespaceId !== null) { + queryParams['namespaceId'] = opts.namespaceId + } + if (opts.jobId !== undefined && opts.jobId !== null) { + queryParams['jobId'] = opts.jobId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 streamcomputer/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 deleteJob 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 = this.makeRequest( + '/regions/{regionId}/job', + '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) + } + ) + } + + /** + * 查询指定应用下的所有job + * @param {Object} opts - parameters + * @param {string} opts.namespaceId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param jobStr data + */ + + getJobList (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 getJobList" + ) + } + + opts = opts || {} + + if (opts.namespaceId === undefined || opts.namespaceId === null) { + throw new Error( + "Missing the required parameter 'opts.namespaceId' when calling getJobList" + ) + } + + let postBody = null + let queryParams = {} + if (opts.namespaceId !== undefined && opts.namespaceId !== null) { + queryParams['namespaceId'] = opts.namespaceId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 streamcomputer/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 getJobList 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 = this.makeRequest( + '/regions/{regionId}/jobList', + '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) + } + ) + } + + /** + * 运行job + * @param {Object} opts - parameters + * @param {string} opts.namespaceId + * @param {integer} opts.jobId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string message 是否成功提交作业 + */ + + startJob (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 startJob" + ) + } + + opts = opts || {} + + if (opts.namespaceId === undefined || opts.namespaceId === null) { + throw new Error( + "Missing the required parameter 'opts.namespaceId' when calling startJob" + ) + } + if (opts.jobId === undefined || opts.jobId === null) { + throw new Error( + "Missing the required parameter 'opts.jobId' when calling startJob" + ) + } + + let postBody = null + let queryParams = {} + if (opts.namespaceId !== undefined && opts.namespaceId !== null) { + queryParams['namespaceId'] = opts.namespaceId + } + if (opts.jobId !== undefined && opts.jobId !== null) { + queryParams['jobId'] = opts.jobId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 streamcomputer/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 startJob 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 = this.makeRequest( + '/regions/{regionId}/job:start', + '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) + } + ) + } + + /** + * 停止作业运行job + * @param {Object} opts - parameters + * @param {string} opts.namespaceId + * @param {integer} opts.jobId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string message 成功启动作业返回信息 + */ + + stopJob (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 stopJob" + ) + } + + opts = opts || {} + + if (opts.namespaceId === undefined || opts.namespaceId === null) { + throw new Error( + "Missing the required parameter 'opts.namespaceId' when calling stopJob" + ) + } + if (opts.jobId === undefined || opts.jobId === null) { + throw new Error( + "Missing the required parameter 'opts.jobId' when calling stopJob" + ) + } + + let postBody = null + let queryParams = {} + if (opts.namespaceId !== undefined && opts.namespaceId !== null) { + queryParams['namespaceId'] = opts.namespaceId + } + if (opts.jobId !== undefined && opts.jobId !== null) { + queryParams['jobId'] = opts.jobId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 streamcomputer/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 stopJob 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 = this.makeRequest( + '/regions/{regionId}/job:stop', + '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.keyword] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param namespace namespaces + */ + + queryNamespaces (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 queryNamespaces" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.keyword !== undefined && opts.keyword !== null) { + queryParams['keyword'] = opts.keyword + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 streamcomputer/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 queryNamespaces 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 = this.makeRequest( + '/regions/{regionId}/namespaces', + '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.namespaceId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param namespace namespace 查询出的namespace对象 + */ + + queryNamespaceDetail (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 queryNamespaceDetail" + ) + } + + opts = opts || {} + + if (opts.namespaceId === undefined || opts.namespaceId === null) { + throw new Error( + "Missing the required parameter 'opts.namespaceId' when calling queryNamespaceDetail" + ) + } + + let postBody = null + let queryParams = {} + if (opts.namespaceId !== undefined && opts.namespaceId !== null) { + queryParams['namespaceId'] = opts.namespaceId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 streamcomputer/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 queryNamespaceDetail 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 = this.makeRequest( + '/regions/{regionId}/namespaceDetail', + '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) + } + ) + } + + /** + * 创建namespace + * @param {Object} opts - parameters + * @param {namespace} opts.namespaceStr + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status 创建成功标志 + */ + + createNamespace (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 createNamespace" + ) + } + + opts = opts || {} + + if (opts.namespaceStr === undefined || opts.namespaceStr === null) { + throw new Error( + "Missing the required parameter 'opts.namespaceStr' when calling createNamespace" + ) + } + + let postBody = {} + if (opts.namespaceStr !== undefined && opts.namespaceStr !== null) { + postBody['namespaceStr'] = opts.namespaceStr + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 streamcomputer/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 createNamespace 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 = this.makeRequest( + '/regions/{regionId}/namespace', + '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) + } + ) + } + + /** + * 更新namespace + * @param {Object} opts - parameters + * @param {namespace} opts.namespaceStr + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status 更新成功标志 + */ + + updateNamespace (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 updateNamespace" + ) + } + + opts = opts || {} + + if (opts.namespaceStr === undefined || opts.namespaceStr === null) { + throw new Error( + "Missing the required parameter 'opts.namespaceStr' when calling updateNamespace" + ) + } + + let postBody = {} + if (opts.namespaceStr !== undefined && opts.namespaceStr !== null) { + postBody['namespaceStr'] = opts.namespaceStr + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 streamcomputer/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 updateNamespace 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 = this.makeRequest( + '/regions/{regionId}/namespace', + '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) + } + ) + } + + /** + * 删除namespace,如果旗下关联有其他资源,不允许删除 + * @param {Object} opts - parameters + * @param {integer} opts.namespaceId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status 删除namespace成功标志 + */ + + deleteNamespace (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 deleteNamespace" + ) + } + + opts = opts || {} + + if (opts.namespaceId === undefined || opts.namespaceId === null) { + throw new Error( + "Missing the required parameter 'opts.namespaceId' when calling deleteNamespace" + ) + } + + let postBody = null + let queryParams = {} + if (opts.namespaceId !== undefined && opts.namespaceId !== null) { + queryParams['namespaceId'] = opts.namespaceId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 streamcomputer/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 deleteNamespace 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 = this.makeRequest( + '/regions/{regionId}/namespace', + '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.storageId - storageId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param storage data + */ + + describeStorage (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 describeStorage" + ) + } + + opts = opts || {} + + if (opts.storageId === undefined || opts.storageId === null) { + throw new Error( + "Missing the required parameter 'opts.storageId' when calling describeStorage" + ) + } + + let postBody = null + let queryParams = {} + if (opts.storageId !== undefined && opts.storageId !== null) { + queryParams['storageId'] = opts.storageId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 streamcomputer/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 describeStorage 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 = this.makeRequest( + '/regions/{regionId}/storage', + '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) + } + ) + } + + /** + * 创建或者更新storage + * @param {Object} opts - parameters + * @param {storage} opts.storageStr - 创建或者更新storage的详情 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string message + * @param boolean status + */ + + addOrUpdateStorage (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 addOrUpdateStorage" + ) + } + + opts = opts || {} + + if (opts.storageStr === undefined || opts.storageStr === null) { + throw new Error( + "Missing the required parameter 'opts.storageStr' when calling addOrUpdateStorage" + ) + } + + let postBody = {} + if (opts.storageStr !== undefined && opts.storageStr !== null) { + postBody['storageStr'] = opts.storageStr + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 streamcomputer/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 addOrUpdateStorage 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 = this.makeRequest( + '/regions/{regionId}/storage', + '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.storageId - storageId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string message + */ + + deleteStorage (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 deleteStorage" + ) + } + + opts = opts || {} + + if (opts.storageId === undefined || opts.storageId === null) { + throw new Error( + "Missing the required parameter 'opts.storageId' when calling deleteStorage" + ) + } + + let postBody = null + let queryParams = {} + if (opts.storageId !== undefined && opts.storageId !== null) { + queryParams['storageId'] = opts.storageId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 streamcomputer/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 deleteStorage 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 = this.makeRequest( + '/regions/{regionId}/storage', + '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) + } + ) + } + + /** + * 创建或者更新storage + * @param {Object} opts - parameters + * @param {string} opts.storageType - storage类型 + * @param {string} opts.namespaceId - namespaceId + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param storage storageList + */ + + getStorageList (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 getStorageList" + ) + } + + opts = opts || {} + + if (opts.storageType === undefined || opts.storageType === null) { + throw new Error( + "Missing the required parameter 'opts.storageType' when calling getStorageList" + ) + } + if (opts.namespaceId === undefined || opts.namespaceId === null) { + throw new Error( + "Missing the required parameter 'opts.namespaceId' when calling getStorageList" + ) + } + + let postBody = null + let queryParams = {} + if (opts.storageType !== undefined && opts.storageType !== null) { + queryParams['storageType'] = opts.storageType + } + if (opts.namespaceId !== undefined && opts.namespaceId !== null) { + queryParams['namespaceId'] = opts.namespaceId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 streamcomputer/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 getStorageList 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 = this.makeRequest( + '/regions/{regionId}/storageList', + '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 = JDCloud.STREAMCOMPUTER diff --git a/packages/libs/lib-jdcloud/src/repo/sts/v1/sts.js b/packages/libs/lib-jdcloud/src/repo/sts/v1/sts.js new file mode 100644 index 000000000..706289c2a --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/sts/v1/sts.js @@ -0,0 +1,149 @@ +/* + * 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. + * + * Security Token Service + * Security Token Service API + * + * 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 = 'sts' +Service._services[serviceId] = true + +/** + * sts service. + * @version 0.1.0 + */ + +JDCloud.STS = class STS extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'sts.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 扮演用户角色,获取临时凭证 + * @param {Object} opts - parameters + * @param {assumeRoleInfo} opts.assumeRoleInfo - 扮演角色参数 + * @param {string} callback - callback + @return {Object} result + * @param credentials credentials 凭证信息 + */ + + assumeRole (opts, callback) { + opts = opts || {} + + if (opts.assumeRoleInfo === undefined || opts.assumeRoleInfo === null) { + throw new Error( + "Missing the required parameter 'opts.assumeRoleInfo' when calling assumeRole" + ) + } + + let postBody = {} + if (opts.assumeRoleInfo !== undefined && opts.assumeRoleInfo !== null) { + postBody['assumeRoleInfo'] = opts.assumeRoleInfo + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 sts/0.1.0' + } + + 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 assumeRole 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 = this.makeRequest( + '/sessionToken:assumeRole', + '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 = JDCloud.STS diff --git a/packages/libs/lib-jdcloud/src/repo/tidb/v1/tidb.js b/packages/libs/lib-jdcloud/src/repo/tidb/v1/tidb.js new file mode 100644 index 000000000..c89d833cf --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/tidb/v1/tidb.js @@ -0,0 +1,5664 @@ +/* + * 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. + * + * White-List + * 白名单相关接口 + * + * 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 = 'tidb' +Service._services[serviceId] = true + +/** + * tidb service. + * @version 1.0.6 + */ + +class TIDB extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'tidb.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查看当前实例下的账号信息。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string accountName 账号名称 + * @param string accountStatus 账号状态("BUILDING","RUNNING","RESETING") + * @param string createTime 创建时间,格式为:YYYY-MM-DD HH:mm:ss + */ + + describeAccounts (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 describeAccounts" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeAccounts" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 describeAccounts 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}/instances/{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) + } + ) + } + + /** + * 创建数据库的高权限管理账号,用户可以使用客户端、应用程序等通过该账号和密码登录 TiDB 实例,然后通过SQL创建数据库和其他用户。一个数据库实例只能创建一个高权限账号。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {} opts.accountName - 账号名 + * @param {} opts.accountPassword - 密码 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + createAccount (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 createAccount" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createAccount" + ) + } + if (opts.accountName === undefined || opts.accountName === null) { + throw new Error( + "Missing the required parameter 'opts.accountName' when calling createAccount" + ) + } + if (opts.accountPassword === undefined || opts.accountPassword === null) { + throw new Error( + "Missing the required parameter 'opts.accountPassword' when calling createAccount" + ) + } + + 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 tidb/1.0.6' + } + + 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 createAccount 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}/instances/{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) + } + ) + } + + /** + * 重置 TiDB 实例的高权限账号的密码。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {string} opts.accountName - 账号名 + * @param {} opts.accountPassword - 新密码 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + resetPassword (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 resetPassword" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling resetPassword" + ) + } + if (opts.accountName === undefined || opts.accountName === null) { + throw new Error( + "Missing the required parameter 'opts.accountName' when calling resetPassword" + ) + } + if (opts.accountPassword === undefined || opts.accountPassword === null) { + throw new Error( + "Missing the required parameter 'opts.accountPassword' when calling resetPassword" + ) + } + + let postBody = {} + if (opts.accountPassword !== undefined && opts.accountPassword !== null) { + postBody['accountPassword'] = opts.accountPassword + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + accountName: opts.accountName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 resetPassword 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}/instances/{instanceId}/accounts/{accountName}:resetPassword', + '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 - 实例ID,唯一标识一个实例 + * @param {integer} [opts.pageNumber] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageNumber为-1时,返回所有数据页码;超过总页数时,显示最后一页。 optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为10,取值范围:[10,100],且为10的整数倍。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param backup backups + * @param integer totalCount 总记录数 + */ + + describeBackups (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 describeBackups" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeBackups" + ) + } + + let postBody = null + let queryParams = {} + if (opts.instanceId !== undefined && opts.instanceId !== null) { + queryParams['instanceId'] = opts.instanceId + } + 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 + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 describeBackups 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}/backups', + '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) + } + ) + } + + /** + * 进行 TiDB 实例的全量备份,对实例中所有的数据库进行备份。同一时间,只能有一个正在运行的备份任务。 + * @param {Object} opts - parameters + * @param {} opts.instanceId - 实例ID,唯一标识一个实例 + * @param {} opts.backupSpec - 备份创建信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string backupId 备份ID + */ + + createBackup (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 createBackup" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createBackup" + ) + } + if (opts.backupSpec === undefined || opts.backupSpec === null) { + throw new Error( + "Missing the required parameter 'opts.backupSpec' when calling createBackup" + ) + } + + let postBody = {} + if (opts.instanceId !== undefined && opts.instanceId !== null) { + postBody['instanceId'] = opts.instanceId + } + if (opts.backupSpec !== undefined && opts.backupSpec !== null) { + postBody['backupSpec'] = opts.backupSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 createBackup 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}/backups', + '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) + } + ) + } + + /** + * 删除TiDB的备份,仅允许删除用户创建的备份,系统的自动备份不允许删除。 + * @param {Object} opts - parameters + * @param {string} opts.backupId - 备份ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteBackup (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 deleteBackup" + ) + } + + opts = opts || {} + + if (opts.backupId === undefined || opts.backupId === null) { + throw new Error( + "Missing the required parameter 'opts.backupId' when calling deleteBackup" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + backupId: opts.backupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 deleteBackup 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}/backups/{backupId}', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer engineStatus + * @param az orderableAZs + */ + + describeOrderableInstanceType ( + 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 describeOrderableInstanceType" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 describeOrderableInstanceType 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}/orderableInstanceType', + '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) + } + ) + } + + /** + * 查询指定地域下 TiDB 服务支持的数据库版本。 + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string versions + */ + + describeVersions (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 describeVersions" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 describeVersions 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}/versions', + '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) + } + ) + } + + /** + * 创建一个 TiDB 实例。创建时需要指定 TiDB 各类节点的数目,规格,存储空间等。 TiFlash和TiCDC节点在创建时不是必须的,可以在需要时,通过扩容的功能创建TiFlash和TiCDC节点。 + * @param {Object} opts - parameters + * @param {tidbInstanceSpec} opts.instanceSpec - 新建实例规格 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string instanceId + * @param string orderId + */ + + createInstance (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 createInstance" + ) + } + + opts = opts || {} + + if (opts.instanceSpec === undefined || opts.instanceSpec === null) { + throw new Error( + "Missing the required parameter 'opts.instanceSpec' when calling createInstance" + ) + } + + let postBody = {} + 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 tidb/1.0.6' + } + + 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 createInstance 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}/instances', + '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) + } + ) + } + + /** + * 查询 TiDB 实例的详细信息,例如TiDB的具体版本号,各个节点的规格、存储空间以及连接信息等等。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param tidbInstanceAttribute tidbInstanceAttributes + */ + + describeInstanceAttributes (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 describeInstanceAttributes" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeInstanceAttributes" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 describeInstanceAttributes 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}/instances/{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) + } + ) + } + + /** + * 删除指定的 TiDB 实例。实例删除后,数据不可恢复,请谨慎使用。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + 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 || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteInstance" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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}/instances/{instanceId}', + '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) + } + ) + } + + /** + * 查询当前账号下所有的 TiDB 实例。 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageNumber为-1时,返回所有数据页码;超过总页数时,显示最后一页; optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为100,取值范围:[10,100],用于查询列表的接口 optional + * @param {filter} [opts.filters] - 过滤参数,多个过滤参数之间的关系为“与”(and) +支持以下属性的过滤: +instanceId, 支持operator选项:eq,ne +instanceName, 支持operator选项:eq,ne,like +instanceStatus, 支持operator选项:eq,ne + optional + * @param {tagFilter} [opts.tagFilters] - 资源标签 optional + * @param {string} [opts.resourceGroupIds] - 资源组id optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instance instances + * @param number 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 + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + Object.assign( + queryParams, + super.buildTagFilterParam(opts.tagFilters, 'tagFilters') + ) + Object.assign( + queryParams, + super.buildArrayParam(opts.resourceGroupIds, 'resourceGroupIds') + ) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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}/instances: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) + } + ) + } + + /** + * 获取各种 TiDB 节点支持的具体规格。 + * @param {Object} opts - parameters + * @param {string} opts.storageType - 存储类型,目前只支持本地SSD; + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param nodeFlavor tidbFlavors + * @param nodeFlavor tikvFlavors + * @param nodeFlavor pdFlavors + * @param nodeFlavor monitorFlavors + * @param nodeFlavor tiflashFlavors + * @param nodeFlavor ticdcFlavors + */ + + describeInstanceClasses (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 describeInstanceClasses" + ) + } + + opts = opts || {} + + if (opts.storageType === undefined || opts.storageType === null) { + throw new Error( + "Missing the required parameter 'opts.storageType' when calling describeInstanceClasses" + ) + } + + let postBody = null + let queryParams = {} + if (opts.storageType !== undefined && opts.storageType !== null) { + queryParams['storageType'] = opts.storageType + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 describeInstanceClasses 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}/instances:describeInstanceClasses', + '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) + } + ) + } + + /** + * 根据日志备份创建一个新的 TiDB 实例 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {} opts.restoreTime - 根据源实例的哪个时间点创建新实例, 北京时间,格式为"YYYY-MM-DD HH:mm:ss" + * @param {} opts.instanceSpec - 新建实例规格 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string instanceId + * @param string orderId + */ + + createInstanceByTime (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 createInstanceByTime" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createInstanceByTime" + ) + } + if (opts.restoreTime === undefined || opts.restoreTime === null) { + throw new Error( + "Missing the required parameter 'opts.restoreTime' when calling createInstanceByTime" + ) + } + if (opts.instanceSpec === undefined || opts.instanceSpec === null) { + throw new Error( + "Missing the required parameter 'opts.instanceSpec' when calling createInstanceByTime" + ) + } + + let postBody = {} + if (opts.restoreTime !== undefined && opts.restoreTime !== null) { + postBody['restoreTime'] = opts.restoreTime + } + if (opts.instanceSpec !== undefined && opts.instanceSpec !== null) { + postBody['instanceSpec'] = opts.instanceSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 createInstanceByTime 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}/instances/{instanceId}:createInstanceByTime', + '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) + } + ) + } + + /** + * 创建一个新的 TiDB 实例,并将指定的备份恢复到该实例上。 + * @param {Object} opts - parameters + * @param {} opts.backupId - 要恢复的备份的ID + * @param {} opts.instanceSpec - 新建实例规格 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string instanceId + * @param string orderId + */ + + createInstanceFromBackup (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 createInstanceFromBackup" + ) + } + + opts = opts || {} + + if (opts.backupId === undefined || opts.backupId === null) { + throw new Error( + "Missing the required parameter 'opts.backupId' when calling createInstanceFromBackup" + ) + } + if (opts.instanceSpec === undefined || opts.instanceSpec === null) { + throw new Error( + "Missing the required parameter 'opts.instanceSpec' when calling createInstanceFromBackup" + ) + } + + let postBody = {} + if (opts.backupId !== undefined && opts.backupId !== null) { + postBody['backupId'] = opts.backupId + } + 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 tidb/1.0.6' + } + + 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 createInstanceFromBackup 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}/instances:createInstanceFromBackup', + '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 - 实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string startTime 实例按时间点创建时,可恢复到的最早时间点, 北京时间, 格式为"YYYY-MM-DD HH:mm:ss"; 字段值为空字符串表示没有最早时间点 + + * @param string endTime 实例按时间点创建时,可恢复到的最新时间点, 北京时间, 格式为"YYYY-MM-DD HH:mm:ss";字段值为空字符串表示没有最新时间点 + + */ + + describeRestoreTimeInterval (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 describeRestoreTimeInterval" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeRestoreTimeInterval" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 describeRestoreTimeInterval 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}/instances/{instanceId}:describeRestoreTimeInterval', + '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 string startWindow 自动备份开始时间窗口,范围00:00-23:59,时间范围差不得小于30分钟。 +例如:00:00-01:00,表示0点到1点开始进行数据库自动备份,备份完成时间则跟实例大小有关,不保证在这个时间范围中完成 + + * @param integer retentionPeriod 自动备份保留周期,单位天,缺省为7天,范围7-730 + * @param string backupPeriod 自动备份的周期,多个取值用英文逗号分隔,支持以下参数,不区分大小写: +- Monday:周一 +- Tuesday:周二 +- Wednesday:周三 +- Thursday:周四 +- Friday:周五 +- Saturday:周六 +- Sunday:周日 +例如定义周一和周三备份,则输入为Monday,Wednesday + + * @param boolean autoIncBackup 是否开启自动增量备份 + */ + + describeBackupPolicy (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 describeBackupPolicy" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeBackupPolicy" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 describeBackupPolicy 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}/instances/{instanceId}:describeBackupPolicy', + '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) + } + ) + } + + /** + * 修改 TiDB 实例备份策略,例如全量备份的日期,时间等。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {} [opts.startWindow] - 自动备份开始时间窗口,例如:00:00-01:00,表示0点到1点开始进行数据库自动备份,备份完成时间则跟实例大小有关,不一定在这个时间范围中该参数只能是以下取值:00:00-01:0001:00-02:00......23:00-24:00 optional + * @param {} [opts.backupPeriod] - 自动备份的周期,多个取值用英文逗号分隔,支持以下参数,不区分大小写:- Monday:周一 - Tuesday:周二 - Wednesday:周三 - Thursday:周四 - Friday:周五- Saturday:周六- Sunday:周日 例如定义周一和周三备份,则输入为Monday,Wednesday optional + * @param {} [opts.autoIncBackup] - 是否开启自动增量备份。 开启后会在没有全量备份的日期自动进行一次增量备份 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyBackupPolicy (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 modifyBackupPolicy" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyBackupPolicy" + ) + } + + let postBody = {} + if (opts.startWindow !== undefined && opts.startWindow !== null) { + postBody['startWindow'] = opts.startWindow + } + if (opts.backupPeriod !== undefined && opts.backupPeriod !== null) { + postBody['backupPeriod'] = opts.backupPeriod + } + if (opts.autoIncBackup !== undefined && opts.autoIncBackup !== null) { + postBody['autoIncBackup'] = opts.autoIncBackup + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 modifyBackupPolicy 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}/instances/{instanceId}:modifyBackupPolicy', + '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 - 实例ID + * @param {} opts.instanceName - 实例名称,名称支持中文,实例名的具体规则可参见帮助中心文档 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyInstanceName (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 modifyInstanceName" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyInstanceName" + ) + } + if (opts.instanceName === undefined || opts.instanceName === null) { + throw new Error( + "Missing the required parameter 'opts.instanceName' when calling modifyInstanceName" + ) + } + + let postBody = {} + if (opts.instanceName !== undefined && opts.instanceName !== null) { + postBody['instanceName'] = opts.instanceName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 modifyInstanceName 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}/instances/{instanceId}:modifyInstanceName', + '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) + } + ) + } + + /** + * 修改 TiDB 实例中各类节点的数量。如果当前实例无TiFlash和TiCDC节点,那么在增加TiFlash和TiCDC节点数目时,可同时指定其规格。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {} [opts.tidbNodeNum] - 调整后的tidb节点数 optional + * @param {} [opts.tikvNodeNum] - 调整后的tikv节点数 optional + * @param {} [opts.pdNodeNum] - 调整后的pd节点数 optional + * @param {} [opts.tiflashNodeSpec] - TiFlash节点规格和数目 optional + * @param {} [opts.ticdcNodeSpec] - Ticdc节点规格和数目 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string orderId + */ + + modifyNodeNum (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 modifyNodeNum" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyNodeNum" + ) + } + + let postBody = {} + if (opts.tidbNodeNum !== undefined && opts.tidbNodeNum !== null) { + postBody['tidbNodeNum'] = opts.tidbNodeNum + } + if (opts.tikvNodeNum !== undefined && opts.tikvNodeNum !== null) { + postBody['tikvNodeNum'] = opts.tikvNodeNum + } + if (opts.pdNodeNum !== undefined && opts.pdNodeNum !== null) { + postBody['pdNodeNum'] = opts.pdNodeNum + } + if (opts.tiflashNodeSpec !== undefined && opts.tiflashNodeSpec !== null) { + postBody['tiflashNodeSpec'] = opts.tiflashNodeSpec + } + if (opts.ticdcNodeSpec !== undefined && opts.ticdcNodeSpec !== null) { + postBody['ticdcNodeSpec'] = opts.ticdcNodeSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 modifyNodeNum 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}/instances/{instanceId}:modifyNodeNum', + '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) + } + ) + } + + /** + * 修改 TiDB 实例中各类节点中的数目与规格。支持 TiDB 节点和 Monitor 节点数目和规格的同时调整。 如果当前实例无 TiFlash 和 TiCDC 节点,那么在增加 TiFlash 和 TiCDC 节点数目时,可同时指定其规格。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {} [opts.tikvNodeNum] - 调整后的tikv节点数 optional + * @param {} [opts.pdNodeNum] - 调整后的pd节点数 optional + * @param {} [opts.tidbNodeSpec] - TiDB节点规格和数目 optional + * @param {} [opts.tiflashNodeSpec] - TiFlash节点规格和数目 optional + * @param {} [opts.ticdcNodeSpec] - Ticdc节点规格和数目 optional + * @param {} [opts.monitorNodeSpec] - Monitor节点规格和数目 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string orderId + */ + + 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" + ) + } + + let postBody = {} + if (opts.tikvNodeNum !== undefined && opts.tikvNodeNum !== null) { + postBody['tikvNodeNum'] = opts.tikvNodeNum + } + if (opts.pdNodeNum !== undefined && opts.pdNodeNum !== null) { + postBody['pdNodeNum'] = opts.pdNodeNum + } + if (opts.tidbNodeSpec !== undefined && opts.tidbNodeSpec !== null) { + postBody['tidbNodeSpec'] = opts.tidbNodeSpec + } + if (opts.tiflashNodeSpec !== undefined && opts.tiflashNodeSpec !== null) { + postBody['tiflashNodeSpec'] = opts.tiflashNodeSpec + } + if (opts.ticdcNodeSpec !== undefined && opts.ticdcNodeSpec !== null) { + postBody['ticdcNodeSpec'] = opts.ticdcNodeSpec + } + if (opts.monitorNodeSpec !== undefined && opts.monitorNodeSpec !== null) { + postBody['monitorNodeSpec'] = opts.monitorNodeSpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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}/instances/{instanceId}: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) + } + ) + } + + /** + * 获取某个实例下的所有节点的主要性能信息,如CPU,内存,存储空间等。 该性能信息从云监控获取,为上一个监控周期的数据。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {integer} [opts.pageNumber] - 显示数据的页码,默认为1,取值范围:[-1,∞)。pageNumber为-1时,返回所有数据页码;超过总页数时,显示最后一页; optional + * @param {integer} [opts.pageSize] - 每页显示的数据条数,默认为50,取值范围:[50,100],用于查询列表的接口 optional + * @param {filter} [opts.filters] - nodeType, 支持operator选项:eq,ne +nodeStatus, 支持operator选项:eq ne + optional + * @param {sort} [opts.sorts] - cpuUtil - CPU使用率 +memeryUtil - 内存使用率 +diskUsage - 磁盘使用率 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param tiDBNode nodes + * @param number totalCount 总记录数 + */ + + describeNodes (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 describeNodes" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeNodes" + ) + } + + 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')) + Object.assign(queryParams, super.buildSortParam(opts.sorts, 'sorts')) + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 describeNodes 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}/instances/{instanceId}/nodes', + '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) + } + ) + } + + /** + * 查看TiDB实例的主要配置参数。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param describeParam parameters + */ + + describeParameters (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 describeParameters" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeParameters" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 describeParameters 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}/instances/{instanceId}/parameters', + '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) + } + ) + } + + /** + * 修改TiDB实例的配置参数。部分参数修改后,需要重启才能生效,具体可以参考PingCAP的相关文档。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {} opts.parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyParameters (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 modifyParameters" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyParameters" + ) + } + if (opts.parameters === undefined || opts.parameters === null) { + throw new Error( + "Missing the required parameter 'opts.parameters' when calling modifyParameters" + ) + } + + let postBody = {} + if (opts.parameters !== undefined && opts.parameters !== null) { + postBody['parameters'] = opts.parameters + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 modifyParameters 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}/instances/{instanceId}/parameters', + '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) + } + ) + } + + /** + * 重启实例的某类节点。重启采用滚动重启的方式,如果该类节点有多个,通常不会中断实例的服务。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {} opts.nodeType - 重启指定类型的pod,支持Tikv,TiDB,PD,TiFlash + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + rebootPod (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 rebootPod" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling rebootPod" + ) + } + if (opts.nodeType === undefined || opts.nodeType === null) { + throw new Error( + "Missing the required parameter 'opts.nodeType' when calling rebootPod" + ) + } + + let postBody = {} + if (opts.nodeType !== undefined && opts.nodeType !== null) { + postBody['nodeType'] = opts.nodeType + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 rebootPod 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}/instances/{instanceId}:rebootpod', + '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) + } + ) + } + + /** + * 升级TiDB引擎版本,例如从4.0.8 升级到 5.4.0等。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {} [opts.version] - 升级后的版本号 optional + * @param {} [opts.timing] - 版本升级的时间点,时间格式yyyy-mm-dd hh:mm:ss。不传或者传入空表示取消升级 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + upgradeEngineVersion (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 upgradeEngineVersion" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling upgradeEngineVersion" + ) + } + + let postBody = {} + if (opts.version !== undefined && opts.version !== null) { + postBody['version'] = opts.version + } + if (opts.timing !== undefined && opts.timing !== null) { + postBody['timing'] = opts.timing + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 upgradeEngineVersion 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}/instances/{instanceId}:upgradeEngineVersion', + '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) + } + ) + } + + /** + * 获取当前 TiDB 实例可升级到的目标版本。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string versions + */ + + describeUpgradeVersions (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 describeUpgradeVersions" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeUpgradeVersions" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 describeUpgradeVersions 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}/instances/{instanceId}:describeUpgradeVersions', + '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) + } + ) + } + + /** + * 查询当前 TiDB 实例的升级计划。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string newVersion 升级后的新版本 + * @param string upgradeTime 计划开始升级的时间 + * @param string status 任务状态 - 未开始 - 进行中 - 失败 + */ + + describeUpgradePlan (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 describeUpgradePlan" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeUpgradePlan" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 describeUpgradePlan 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}/instances/{instanceId}:describeUpgradePlan', + '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) + } + ) + } + + /** + * 开启 TiDB 实例的 Internet 公网服务。开启后,并配置 IP 白名单后,可以在 VPC 外通过公网域名访问 TiDB 实例。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {string} opts.serviceType - 按照service type (database pd monitor)开启公网域名 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + enableInternetAccess (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 enableInternetAccess" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling enableInternetAccess" + ) + } + if (opts.serviceType === undefined || opts.serviceType === null) { + throw new Error( + "Missing the required parameter 'opts.serviceType' when calling enableInternetAccess" + ) + } + + let postBody = {} + if (opts.serviceType !== undefined && opts.serviceType !== null) { + postBody['serviceType'] = opts.serviceType + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 enableInternetAccess 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}/instances/{instanceId}:enableInternetAccess', + '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) + } + ) + } + + /** + * 关闭 TiDB 实例的 Internet 公网服务。 关闭后,将不能在 VPC 外访问 TiDB 实例。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {string} opts.serviceType - 按照service type (database pd monitor)关闭公网域名 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + disableInternetAccess (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 disableInternetAccess" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling disableInternetAccess" + ) + } + if (opts.serviceType === undefined || opts.serviceType === null) { + throw new Error( + "Missing the required parameter 'opts.serviceType' when calling disableInternetAccess" + ) + } + + let postBody = {} + if (opts.serviceType !== undefined && opts.serviceType !== null) { + postBody['serviceType'] = opts.serviceType + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 disableInternetAccess 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}/instances/{instanceId}:disableInternetAccess', + '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) + } + ) + } + + /** + * 开启 TiDB 和 MySQL 客户端之间的 SSL 连接功能。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + enableSSL (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 enableSSL" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling enableSSL" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 enableSSL 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}/instances/{instanceId}/ssl:enableSSL', + '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) + } + ) + } + + /** + * 关闭 TiDB 和 MySQL 客户端之间的 SSL 连接功能。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + disableSSL (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 disableSSL" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling disableSSL" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 disableSSL 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}/instances/{instanceId}/ssl:disableSSL', + '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) + } + ) + } + + /** + * 查询 TiDB 实例的 SSL 的开启状态。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean available SSL开启状态,已开启为true,关闭为false + */ + + describeSSL (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 describeSSL" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeSSL" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 describeSSL 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}/instances/{instanceId}/ssl', + '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) + } + ) + } + + /** + * 查询 TiDB支持的基本信息。 + * @param {Object} opts - parameters + * @param {string} [opts.azs] - 用户可用区[多个使用,分隔] optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string engineVersion + * @param string architectureType + * @param architectureVersion architectureVersion + */ + + describeAvailableDBInfoInternel ( + 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 describeAvailableDBInfoInternel" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.azs !== undefined && opts.azs !== null) { + queryParams['azs'] = opts.azs + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 describeAvailableDBInfoInternel 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}/instances:describeAvailableDBInfoInternel', + '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) + } + ) + } + + /** + * 查询 TiDB 数据迁移任务的详细信息,例如任务的开始、完成时间,任务状态等等。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {string} [opts.queryStartTime] - 查询迁移任务的起始时间,结束时间为当前时间。按任务开始时间查询,默认查询7天(包含当天) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param migrationTask migrationTasks + */ + + describeDataMigration (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 describeDataMigration" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeDataMigration" + ) + } + + let postBody = null + let queryParams = {} + if (opts.queryStartTime !== undefined && opts.queryStartTime !== null) { + queryParams['queryStartTime'] = opts.queryStartTime + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 describeDataMigration 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}/instances/{instanceId}/migration', + '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) + } + ) + } + + /** + * 创建一个数据迁移任务,可以将对象存储 OSS 中的数据导入到 TiDB 实例中,具体可以参考帮助文档。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {} opts.migrationType - 迁移任务类型,支持以下类型(大小写不敏感):<br>-FULL_IMPORT:全量数据导入 + * @param {} opts.importTask - 使用 TiDB Lightning 进行的数据迁移任务 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + createDataMigration (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 createDataMigration" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createDataMigration" + ) + } + if (opts.migrationType === undefined || opts.migrationType === null) { + throw new Error( + "Missing the required parameter 'opts.migrationType' when calling createDataMigration" + ) + } + if (opts.importTask === undefined || opts.importTask === null) { + throw new Error( + "Missing the required parameter 'opts.importTask' when calling createDataMigration" + ) + } + + let postBody = {} + if (opts.migrationType !== undefined && opts.migrationType !== null) { + postBody['migrationType'] = opts.migrationType + } + if (opts.importTask !== undefined && opts.importTask !== null) { + postBody['importTask'] = opts.importTask + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 createDataMigration 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}/instances/{instanceId}/migration', + '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) + } + ) + } + + /** + * 校验需要导入的备份文件在OSS上是否存在,需要的读取权限是否具备。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {} opts.ossLink - 要校验的文件bucket及路径,例如Bucket为db_bak,文件路径为test_server/db1/20181013.bak,则ossLink为db_bak/test_server/db1/20181013.bak + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string success true:成功false:失败,文件不存在,类型不对或需要的权限不正确 + * @param string errMsg 具体的错误信息 + */ + + verifyFilefromOSS (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 verifyFilefromOSS" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling verifyFilefromOSS" + ) + } + if (opts.ossLink === undefined || opts.ossLink === null) { + throw new Error( + "Missing the required parameter 'opts.ossLink' when calling verifyFilefromOSS" + ) + } + + let postBody = {} + if (opts.ossLink !== undefined && opts.ossLink !== null) { + postBody['ossLink'] = opts.ossLink + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 verifyFilefromOSS 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}/instances/{instanceId}/migration:verifyFilefromOSS', + '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 - 实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer totalCount 总记录数 + * @param replicationTask replications 要复制的对象 + */ + + describeReplications (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 describeReplications" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeReplications" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 describeReplications 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}/instances/{instanceId}/replications', + '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) + } + ) + } + + /** + * 创建一个数据复制任务,可以将 TiDB 的增量数据同步到下游的 MySQL, TiDB 或者 Kafka 中。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {replicationSpec} opts.replication - 数据复制任务的详细信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string replicationId 复制任务ID + */ + + createReplication (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 createReplication" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createReplication" + ) + } + if (opts.replication === undefined || opts.replication === null) { + throw new Error( + "Missing the required parameter 'opts.replication' when calling createReplication" + ) + } + + let postBody = {} + if (opts.replication !== undefined && opts.replication !== null) { + postBody['replication'] = opts.replication + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 createReplication 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}/instances/{instanceId}/replications', + '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 - 实例ID + * @param {string} opts.taskId - 复制任务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteReplication (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 deleteReplication" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteReplication" + ) + } + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling deleteReplication" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 deleteReplication 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}/instances/{instanceId}/replications/{taskId}', + '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.instanceId - 实例ID + * @param {string} opts.taskId - 复制任务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + resumeReplication (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 resumeReplication" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling resumeReplication" + ) + } + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling resumeReplication" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 resumeReplication 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}/instances/{instanceId}/replications/{taskId}:resumeReplication', + '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) + } + ) + } + + /** + * 暂停指定的复制任务。注意:如果暂停的时间过长,会导致 TiCDC 节点的磁盘空间写满,导致复制任务错误或失败。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {string} opts.taskId - 复制任务ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + stopReplication (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 stopReplication" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling stopReplication" + ) + } + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling stopReplication" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 stopReplication 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}/instances/{instanceId}/replications/{taskId}:stopReplication', + '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 - 实例ID + * @param {string} opts.taskId - 复制任务ID + * @param {string} opts.taskId - 复制任务ID + * @param {string} [opts.targetComment] - 目标实例备注说明 optional + * @param {string} [opts.targetUser] - 目标类型为TiDB或MySQL时,连接目标实例的用户名 optional + * @param {string} [opts.targetPassword] - 目标类型为TiDB或MySQL时,连接目标实例的密码 optional + * @param {string} [opts.kafkaTopic] - Kafka的Topic optional + * @param {string} [opts.kafkaVersion] - Kafka的版本 optional + * @param {array} [opts.replicationObjects] - 过滤规则列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyReplication (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 modifyReplication" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyReplication" + ) + } + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling modifyReplication" + ) + } + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling modifyReplication" + ) + } + + let postBody = {} + if (opts.taskId !== undefined && opts.taskId !== null) { + postBody['taskId'] = opts.taskId + } + if (opts.targetComment !== undefined && opts.targetComment !== null) { + postBody['targetComment'] = opts.targetComment + } + if (opts.targetUser !== undefined && opts.targetUser !== null) { + postBody['targetUser'] = opts.targetUser + } + if (opts.targetPassword !== undefined && opts.targetPassword !== null) { + postBody['targetPassword'] = opts.targetPassword + } + if (opts.kafkaTopic !== undefined && opts.kafkaTopic !== null) { + postBody['kafkaTopic'] = opts.kafkaTopic + } + if (opts.kafkaVersion !== undefined && opts.kafkaVersion !== null) { + postBody['kafkaVersion'] = opts.kafkaVersion + } + if ( + opts.replicationObjects !== undefined && + opts.replicationObjects !== null + ) { + postBody['replicationObjects'] = opts.replicationObjects + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId, + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 modifyReplication 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}/instances/{instanceId}/replications/{taskId}:modifyReplication', + '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) + } + ) + } + + /** + * 查看实例当前白名单。白名单是允许访问当前实例的IP/IP段列表,缺省情况下,白名单对本VPC开放。如果用户开启了外网访问的功能,还需要对外网的IP配置白名单。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param whiteList whiteLists + */ + + describeWhiteList (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 describeWhiteList" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeWhiteList" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 describeWhiteList 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}/instances/{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 白名单。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {} opts.name - 白名单分组名 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + addWhiteListGroup (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 addWhiteListGroup" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling addWhiteListGroup" + ) + } + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling addWhiteListGroup" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 addWhiteListGroup 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}/instances/{instanceId}/whiteList', + '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) + } + ) + } + + /** + * 修改允许访问实例的IP白名单。白名单是允许访问当前实例的IP/IP段列表,缺省情况下,白名单对本VPC开放。如果用户开启了外网访问的功能,还需要对外网的IP配置白名单。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {string} opts.ips - IP或IP段,不同的IP/IP段之间用英文逗号分隔,例如0.0.0.0/0,192.168.0.10 + * @param {string} opts.name - 白名单分组名 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyWhiteList (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 modifyWhiteList" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyWhiteList" + ) + } + if (opts.ips === undefined || opts.ips === null) { + throw new Error( + "Missing the required parameter 'opts.ips' when calling modifyWhiteList" + ) + } + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling modifyWhiteList" + ) + } + + let postBody = {} + if (opts.ips !== undefined && opts.ips !== null) { + postBody['ips'] = opts.ips + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 modifyWhiteList 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}/instances/{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) + } + ) + } + + /** + * 删除指定的白名单分组。 + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 实例ID + * @param {string} opts.name - 白名单分组名 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteWhiteListGroup (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 deleteWhiteListGroup" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteWhiteListGroup" + ) + } + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling deleteWhiteListGroup" + ) + } + + let postBody = null + let queryParams = {} + if (opts.name !== undefined && opts.name !== null) { + queryParams['name'] = opts.name + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 tidb/1.0.6' + } + + 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 deleteWhiteListGroup 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}/instances/{instanceId}/whiteList', + '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) + } + ) + } +} +module.exports = TIDB diff --git a/packages/libs/lib-jdcloud/src/repo/user/v1/user.js b/packages/libs/lib-jdcloud/src/repo/user/v1/user.js new file mode 100644 index 000000000..c6d1ae65d --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/user/v1/user.js @@ -0,0 +1,237 @@ +/* + * 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. + * + * 账号报备管理 + * 账号报备管理接口 + * + * 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 = 'user' +Service._services[serviceId] = true + +/** + * user service. + * @version 0.2.8 + */ + +class USER extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'user.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询用户信息 + * @param {Object} opts - parameters + * @param {string} callback - callback + @return {Object} result + * @param string pin 用户Pin + * @param string loginName 登录名 + * @param string accountId 用户唯一id + * @param integer userAuth 实名认证状态:0-未认证 1-已认证(个人) 2-已认证(企业) 3-已认证(个人和企业) + */ + + describeUser (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 user/0.2.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 describeUser 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( + '/describeUser', + '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) + } + ) + } + + /** + * 创建免登录ticket + * @param {Object} opts - parameters + * @param {} [opts.expire] - 有效期(默认24,最小1,最大24,单位小时) optional + * @param {string} callback - callback + @return {Object} result + * @param string ticket 免登录ticket + */ + + createTicket (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.expire !== undefined && opts.expire !== null) { + postBody['expire'] = opts.expire + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 user/0.2.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 createTicket 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( + '/user:createTicket', + '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 = USER diff --git a/packages/libs/lib-jdcloud/src/repo/userpool/v1/userpool.js b/packages/libs/lib-jdcloud/src/repo/userpool/v1/userpool.js new file mode 100644 index 000000000..fca069a69 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/userpool/v1/userpool.js @@ -0,0 +1,477 @@ +/* + * 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. + * + * 用户管理 + * 用户管理接口 + * + * 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 = 'userpool' +Service._services[serviceId] = true + +/** + * userpool service. + * @version 0.1.0 + */ + +JDCloud.USERPOOL = class USERPOOL extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'userpool.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 批量查询Pool用户信息 + * @param {Object} opts - parameters + * @param {string} opts.poolName - PoolName + * @param {string} [opts.userNames] - 用户信息(userName) optional + * @param {string} callback - callback + @return {Object} result + * @param poolUserResVo poolUsers + */ + + adminGetUsers (opts, callback) { + opts = opts || {} + + if (opts.poolName === undefined || opts.poolName === null) { + throw new Error( + "Missing the required parameter 'opts.poolName' when calling adminGetUsers" + ) + } + + let postBody = null + let queryParams = {} + Object.assign( + queryParams, + this.buildArrayParam(opts.userNames, 'userNames') + ) + + let pathParams = { + regionId: 'jdcloud', + poolName: opts.poolName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 userpool/0.1.0' + } + + 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 adminGetUsers 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 = this.makeRequest( + '/poolName/{poolName}/user', + '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) + } + ) + } + + /** + * 创建Mine craft用户 + * @param {Object} opts - parameters + * @param {string} opts.poolName - PoolName + * @param {array} opts.poolUsers - Pool用户信息列表 + * @param {string} callback - callback + @return {Object} result + * @param failedMsg failedList + * @param poolUserResVo users + */ + + adminCreateUser (opts, callback) { + opts = opts || {} + + if (opts.poolName === undefined || opts.poolName === null) { + throw new Error( + "Missing the required parameter 'opts.poolName' when calling adminCreateUser" + ) + } + if (opts.poolUsers === undefined || opts.poolUsers === null) { + throw new Error( + "Missing the required parameter 'opts.poolUsers' when calling adminCreateUser" + ) + } + + let postBody = {} + if (opts.poolUsers !== undefined && opts.poolUsers !== null) { + postBody['poolUsers'] = opts.poolUsers + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + poolName: opts.poolName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 userpool/0.1.0' + } + + 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 adminCreateUser 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 = this.makeRequest( + '/poolName/{poolName}/user', + '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) + } + ) + } + + /** + * 批量查询Pool用户信息 + * @param {Object} opts - parameters + * @param {string} opts.poolName - PoolName + * @param {integer} [opts.currentPage] - 页号(起始页1) optional + * @param {integer} [opts.pageSize] - 页大小(最大100,默认10) optional + * @param {string} callback - callback + @return {Object} result + * @param pageInfo pageInfo + * @param poolUserResVo poolUsers + */ + + listUsers (opts, callback) { + opts = opts || {} + + if (opts.poolName === undefined || opts.poolName === null) { + throw new Error( + "Missing the required parameter 'opts.poolName' when calling listUsers" + ) + } + + let postBody = null + let queryParams = {} + if (opts.currentPage !== undefined && opts.currentPage !== null) { + queryParams['currentPage'] = opts.currentPage + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + + let pathParams = { + regionId: 'jdcloud', + poolName: opts.poolName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 userpool/0.1.0' + } + + 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 listUsers 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 = this.makeRequest( + '/poolName/{poolName}/user:list', + '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) + } + ) + } + + /** + * 管理员批量设置Pool用户密码 + * @param {Object} opts - parameters + * @param {string} opts.poolName - PoolName + * @param {array} opts.userPasswords - Pool用户名和密码 + * @param {string} callback - callback + @return {Object} result + */ + + adminSetUsersPassword (opts, callback) { + opts = opts || {} + + if (opts.poolName === undefined || opts.poolName === null) { + throw new Error( + "Missing the required parameter 'opts.poolName' when calling adminSetUsersPassword" + ) + } + if (opts.userPasswords === undefined || opts.userPasswords === null) { + throw new Error( + "Missing the required parameter 'opts.userPasswords' when calling adminSetUsersPassword" + ) + } + + let postBody = {} + if (opts.userPasswords !== undefined && opts.userPasswords !== null) { + postBody['userPasswords'] = opts.userPasswords + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + poolName: opts.poolName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 userpool/0.1.0' + } + + 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 adminSetUsersPassword 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 = this.makeRequest( + '/poolName/{poolName}/user:adminSetUsersPassword', + '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 = JDCloud.USERPOOL diff --git a/packages/libs/lib-jdcloud/src/repo/vm/v1/vm.js b/packages/libs/lib-jdcloud/src/repo/vm/v1/vm.js new file mode 100644 index 000000000..e429ec02e --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/vm/v1/vm.js @@ -0,0 +1,8361 @@ +/* + * 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. + * + * Task + * 与任务相关的接口 + * + * 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 = 'vm' +Service._services[serviceId] = true + +/** + * vm service. + * @version 1.6.1 + */ + +class VM extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'vm.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * +查询镜像详情。 + +详细操作说明请参考帮助文档:[镜像概述](https://docs.jdcloud.com/cn/virtual-machines/image-overview) + +## 接口说明 +- 该接口与查询镜像信息列表返回的信息一致。 +- 只需要查询单个镜像信息的时候可以调用该接口。 + + * @param {Object} opts - parameters + * @param {string} opts.imageId - 镜像ID。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param image image 镜像信息。 + */ + + describeImage (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 describeImage" + ) + } + + opts = opts || {} + + if (opts.imageId === undefined || opts.imageId === null) { + throw new Error( + "Missing the required parameter 'opts.imageId' when calling describeImage" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + imageId: opts.imageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 describeImage 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}/images/{imageId}', + '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) + } + ) + } + + /** + * +删除一个私有镜像。 + +详细操作说明请参考帮助文档:[删除私有镜像](https://docs.jdcloud.com/cn/virtual-machines/delete-private-image) + +## 接口说明 +- 已共享的私有镜像在取消共享关系前不可以删除,如私有镜像已共享给其他用户,请取消共享后再进行删除。 +- 本地系统盘镜像在有基于其创建的云主机时,将无法删除。 +- 只能操作私有镜像。 +- 私有镜像没有正在处理中的任务时才可以删除。 + + * @param {Object} opts - parameters + * @param {string} opts.imageId - 镜像ID。 + * @param {boolean} [opts.deleteSnapshot] - 删除镜像时是否删除关联的快照。默认为 `false`;如果指定为 `true`, 将会删除镜像关联的快照。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteImage (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 deleteImage" + ) + } + + opts = opts || {} + + if (opts.imageId === undefined || opts.imageId === null) { + throw new Error( + "Missing the required parameter 'opts.imageId' when calling deleteImage" + ) + } + + let postBody = null + let queryParams = {} + if (opts.deleteSnapshot !== undefined && opts.deleteSnapshot !== null) { + queryParams['deleteSnapshot'] = opts.deleteSnapshot + } + + let pathParams = { + regionId: regionId, + imageId: opts.imageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 deleteImage 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}/images/{imageId}', + '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) + } + ) + } + + /** + * +基于快照制作私有镜像,支持指定单个快照创建系统盘镜像;指定多个快照组合创建整机镜像 + +## 接口说明 +- 快照须为可用状态,且需有指定快照的权限,快照数量为1-8块。 +- 单块快照创建镜像,设备名必须为vda;多块快照创建镜像,设备名必须包含vda。 +- 设置云盘的容量需大于快照容量。 +- 调用接口后,需要等待镜像状态变为 ready 后,才能正常使用镜像。 + + * @param {Object} opts - parameters + * @param {string} opts.name - 镜像名称,长度为2\~32个字符,只允许中文、数字、大小写字母、英文下划线(\_)、连字符(-)及点(.)。 + + * @param {string} [opts.description] - 镜像描述,256字符以内。 + optional + * @param {string} opts.platform - 镜像的操作系统类型, 可选值:CentOS、Ubuntu、Windows Server、OpenEuler、Rocky Linux、Others Linux。 + + * @param {string} [opts.osVersion] - 操作系统版本。如:7.9 + optional + * @param {string} opts.architecture - 操作系统架构, 可选值:x86_64、arm64。 + + * @param {array} [opts.cloudDisks] - 云盘快照信息。 + optional + * @param {string} [opts.clientToken] - 用于保证请求的幂等性。由客户端生成,并确保不同请求中该参数唯一,长度不能超过64个字符。 + optional + * @param {string} opts.bootMode - 启动模式,支持uefi、bios。 + + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string imageId 镜像ID。 + */ + + createImageFromSnapshots (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 createImageFromSnapshots" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createImageFromSnapshots" + ) + } + if (opts.platform === undefined || opts.platform === null) { + throw new Error( + "Missing the required parameter 'opts.platform' when calling createImageFromSnapshots" + ) + } + if (opts.architecture === undefined || opts.architecture === null) { + throw new Error( + "Missing the required parameter 'opts.architecture' when calling createImageFromSnapshots" + ) + } + if (opts.bootMode === undefined || opts.bootMode === null) { + throw new Error( + "Missing the required parameter 'opts.bootMode' when calling createImageFromSnapshots" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.platform !== undefined && opts.platform !== null) { + postBody['platform'] = opts.platform + } + if (opts.osVersion !== undefined && opts.osVersion !== null) { + postBody['osVersion'] = opts.osVersion + } + if (opts.architecture !== undefined && opts.architecture !== null) { + postBody['architecture'] = opts.architecture + } + if (opts.cloudDisks !== undefined && opts.cloudDisks !== null) { + postBody['cloudDisks'] = opts.cloudDisks + } + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.bootMode !== undefined && opts.bootMode !== null) { + postBody['bootMode'] = opts.bootMode + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 createImageFromSnapshots 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}/images:createImageFromSnapshots', + '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) + } + ) + } + + /** + * +查询镜像信息列表。 + +详细操作说明请参考帮助文档:[镜像概述](https://docs.jdcloud.com/cn/virtual-machines/image-overview) + +## 接口说明 +- 通过此接口可以查询到京东云官方镜像、第三方镜像、镜像市场、私有镜像、或其他用户共享给您的镜像。 +- 请求参数即过滤条件,每个条件之间的关系为逻辑与(AND)的关系。 +- 如果使用子帐号查询,只会查询到该子帐号有权限的镜像。关于资源权限请参考 [IAM概述](https://docs.jdcloud.com/cn/iam/product-overview)。 +- 单次查询最大可查询100条镜像信息。 +- 尽量一次调用接口查询多条数据,不建议使用该批量查询接口一次查询一条数据,如果使用不当导致查询过于密集,可能导致网关触发限流。 +- 由于该接口为 `GET` 方式请求,最终参数会转换为 `URL` 上的参数,但是 `HTTP` 协议下的 `GET` 请求参数长度是有大小限制的,使用者需要注意参数超长的问题。 + + * @param {Object} opts - parameters + * @param {string} [opts.imageSource] - 镜像来源,如果没有指定 `ids` 参数,此参数必传。取值范围: +`public`:官方镜像。 +`thirdparty`:镜像市场镜像。 +`private`:用户自己的私有镜像。 +`shared`:其他用户分享的镜像。 +`community`:社区镜像。 + optional + * @param {boolean} [opts.offline] - 查询已经下线的镜像时使用。 +只有查询 `官方镜像` 或者 `镜像市场镜像` 时,此参数才有意义,其它情况下此参数无效。 +指定 `ids` 查询时,此参数无效。 + optional + * @param {string} [opts.platform] - 根据镜像的操作系统发行版查询。 +取值范围:`Ubuntu、CentOS、Windows Server`。 + optional + * @param {string} [opts.imageName] - 根据镜像名称模糊查询。 optional + * @param {string} [opts.rootDeviceType] - 根据镜像支持的系统盘类型查询。支持范围:`localDisk` 本地系统盘镜像;`cloudDisk` 云盘系统盘镜像。 optional + * @param {string} [opts.launchPermission] - 根据镜像的使用权限查询,可选参数,仅当 `imageSource` 为 `private` 时有效。取值范围: +`all`:没有限制,所有人均可以使用。 +`specifiedUsers`:只有共享用户可以使用。 +`ownerOnly`:镜像拥有者自己可以使用。 + optional + * @param {string} [opts.status] - 根据镜像状态查询。参考 [镜像状态](https://docs.jdcloud.com/virtual-machines/api/image_status) optional + * @param {string} [opts.serviceCode] - 已废弃。 optional + * @param {string} [opts.architecture] - CPU架构。支持范围:`x86_64`、`arm64`。 optional + * @param {integer} [opts.pageNumber] - 页码;默认为1。 optional + * @param {integer} [opts.pageSize] - 分页大小;<br>默认为20;取值范围[10, 100]。 optional + * @param {string} [opts.bootMode] - 镜像启动模式,默认bios,支持范围:`bios`、`uefi`。 optional + * @param {string} [opts.ids] - 指定镜像ID查询,如果指定了此参数,其它参数可以不传。 + optional + * @param {string} [opts.instanceIds] - 虚机ID, 精确匹配 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param image images + * @param integer totalCount 本次查询可匹配到的总记录数,使用者需要结合 `pageNumber` 和 `pageSize` 计算是否可以继续分页。 + */ + + describeImages (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 describeImages" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.imageSource !== undefined && opts.imageSource !== null) { + queryParams['imageSource'] = opts.imageSource + } + if (opts.offline !== undefined && opts.offline !== null) { + queryParams['offline'] = opts.offline + } + if (opts.platform !== undefined && opts.platform !== null) { + queryParams['platform'] = opts.platform + } + if (opts.imageName !== undefined && opts.imageName !== null) { + queryParams['imageName'] = opts.imageName + } + if (opts.rootDeviceType !== undefined && opts.rootDeviceType !== null) { + queryParams['rootDeviceType'] = opts.rootDeviceType + } + if (opts.launchPermission !== undefined && opts.launchPermission !== null) { + queryParams['launchPermission'] = opts.launchPermission + } + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + if (opts.serviceCode !== undefined && opts.serviceCode !== null) { + queryParams['serviceCode'] = opts.serviceCode + } + if (opts.architecture !== undefined && opts.architecture !== null) { + queryParams['architecture'] = opts.architecture + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + queryParams['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.bootMode !== undefined && opts.bootMode !== null) { + queryParams['bootMode'] = opts.bootMode + } + Object.assign(queryParams, super.buildArrayParam(opts.ids, 'ids')) + Object.assign( + queryParams, + super.buildArrayParam(opts.instanceIds, 'instanceIds') + ) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 describeImages 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}/images', + '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) + } + ) + } + + /** + * +查询单个镜像的实例规格限制。 + +详细操作说明请参考帮助文档:[镜像概述](https://docs.jdcloud.com/cn/virtual-machines/image-overview) + +## 接口说明 +- 该接口与批量查询镜像的实例规格限制返回的信息一致。 +- 通过此接口可以查询镜像的实例规格限制信息。 +- 只有官方镜像、第三方镜像有实例规格的限制,用户的私有镜像没有此限制。 + + * @param {Object} opts - parameters + * @param {string} opts.imageId - 镜像ID。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param imageConstraint imageConstraints 镜像限制信息。 + */ + + describeImageConstraints (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 describeImageConstraints" + ) + } + + opts = opts || {} + + if (opts.imageId === undefined || opts.imageId === null) { + throw new Error( + "Missing the required parameter 'opts.imageId' when calling describeImageConstraints" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + imageId: opts.imageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 describeImageConstraints 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}/images/{imageId}/constraints', + '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) + } + ) + } + + /** + * +批量查询镜像的实例规格限制。 + +详细操作说明请参考帮助文档:[镜像概述](https://docs.jdcloud.com/cn/virtual-machines/image-overview) + +## 接口说明 +- 通过此接口可以查询镜像的实例规格限制信息。 +- 只有官方镜像、第三方镜像有实例规格的限制,用户的私有镜像没有此限制。 + + * @param {Object} opts - parameters + * @param {string} [opts.ids] - 要查询的镜像ID列表,只支持官方镜像和第三方镜像。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param imageConstraint imageConstraints + */ + + describeImageConstraintsBatch ( + 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 describeImageConstraintsBatch" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + Object.assign(queryParams, super.buildArrayParam(opts.ids, 'ids')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 describeImageConstraintsBatch 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}/imageConstraints', + '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) + } + ) + } + + /** + * +共享私有镜像。 + +详细操作说明请参考帮助文档:[共享私有镜像](https://docs.jdcloud.com/cn/virtual-machines/share-image) + +## 接口说明 +- 只允许共享用户的私有镜像。 +- 单个镜像最多可以共享给20个京东云帐户、不可以共享给自己。 +- 带有加密快照的打包镜像无法共享。 + + * @param {Object} opts - parameters + * @param {string} opts.imageId - 镜像ID。 + * @param {array} [opts.pins] - 共享的目标用户pin列表。 optional + * @param {array} [opts.loginNames] - 共享的目标京东云帐户列表。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + shareImage (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 shareImage" + ) + } + + opts = opts || {} + + if (opts.imageId === undefined || opts.imageId === null) { + throw new Error( + "Missing the required parameter 'opts.imageId' when calling shareImage" + ) + } + + let postBody = {} + if (opts.pins !== undefined && opts.pins !== null) { + postBody['pins'] = opts.pins + } + if (opts.loginNames !== undefined && opts.loginNames !== null) { + postBody['loginNames'] = opts.loginNames + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + imageId: opts.imageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 shareImage 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}/images/{imageId}:share', + '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) + } + ) + } + + /** + * +取消共享私有镜像。 + +详细操作说明请参考帮助文档:[取消共享私有镜像](https://docs.jdcloud.com/cn/virtual-machines/cancel-share-image) + +## 接口说明 +- 只允许操作用户的私有镜像。 +- 原被共享用户将无法再使用该镜像创建云主机实例,同时使用该镜像创建的云主机实例也无法重置为原始系统状态。 + + * @param {Object} opts - parameters + * @param {string} opts.imageId - 镜像ID。 + * @param {array} [opts.pins] - 需要取消的用户pin列表。 optional + * @param {array} [opts.loginNames] - 需要取消的京东云帐户列表。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + unShareImage (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 unShareImage" + ) + } + + opts = opts || {} + + if (opts.imageId === undefined || opts.imageId === null) { + throw new Error( + "Missing the required parameter 'opts.imageId' when calling unShareImage" + ) + } + + let postBody = {} + if (opts.pins !== undefined && opts.pins !== null) { + postBody['pins'] = opts.pins + } + if (opts.loginNames !== undefined && opts.loginNames !== null) { + postBody['loginNames'] = opts.loginNames + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + imageId: opts.imageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 unShareImage 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}/images/{imageId}:unshare', + '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) + } + ) + } + + /** + * +发布社区镜像。 + +详细操作说明请参考帮助文档:[镜像概述](https://docs.jdcloud.com/cn/virtual-machines/image-overview) + +## 接口说明 +- 只允许发布用户的私有镜像。 +- 仅支持云盘系统盘的私有镜像。 +- 带有加密快照的打包镜像无法发布为社区镜像。 +- 发布为社区镜像后会撤销共享关系。 + + * @param {Object} opts - parameters + * @param {string} opts.imageId - 镜像ID。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + releaseImage (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 releaseImage" + ) + } + + opts = opts || {} + + if (opts.imageId === undefined || opts.imageId === null) { + throw new Error( + "Missing the required parameter 'opts.imageId' when calling releaseImage" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + imageId: opts.imageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 releaseImage 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}/images/{imageId}:release', + '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) + } + ) + } + + /** + * +撤销社区镜像。 + +详细操作说明请参考帮助文档:[镜像概述](https://docs.jdcloud.com/cn/virtual-machines/image-overview) + +## 接口说明 +- 只允许撤销用户的私有镜像。 + + * @param {Object} opts - parameters + * @param {string} opts.imageId - 镜像ID。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + unReleaseImage (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 unReleaseImage" + ) + } + + opts = opts || {} + + if (opts.imageId === undefined || opts.imageId === null) { + throw new Error( + "Missing the required parameter 'opts.imageId' when calling unReleaseImage" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + imageId: opts.imageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 unReleaseImage 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}/images/{imageId}:unrelease', + '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) + } + ) + } + + /** + * +查询私有镜像共享给哪些京东云帐户。 + +详细操作说明请参考帮助文档:[共享私有镜像](https://docs.jdcloud.com/cn/virtual-machines/share-image) + +## 接口说明 +- 只允许查询用户的私有镜像。 + + * @param {Object} opts - parameters + * @param {string} opts.imageId - 镜像ID。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string pins + * @param string loginNames + */ + + describeImageMembers (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 describeImageMembers" + ) + } + + opts = opts || {} + + if (opts.imageId === undefined || opts.imageId === null) { + throw new Error( + "Missing the required parameter 'opts.imageId' when calling describeImageMembers" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + imageId: opts.imageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 describeImageMembers 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}/images/{imageId}/members', + '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) + } + ) + } + + /** + * +镜像复制。 + +详细操作说明请参考帮助文档:[镜像复制](https://docs.jdcloud.com/cn/virtual-machines/copy-image) + +## 接口说明 +- 调用该接口可以复制私有或共享镜像。 +- 复制私有镜像时,只允许镜像拥有者进行复制。 +- 复制共享镜像时,允许共享的用户将镜像复制为私有镜像。 +- 支持同地域复制镜像。 +- 只支持云盘系统盘的镜像。 +- 不支持带有加密快照的镜像。 + + * @param {Object} opts - parameters + * @param {array} [opts.sourceImageIds] - 要复制的私有镜像ID列表,最多支持10个。 optional + * @param {string} opts.destinationRegion - 目标地域。 + * @param {string} [opts.name] - 复制出新镜像的名称,长度为1\~32个字符,只允许中文、数字、大小写字母、英文下划线(\_)、连字符(-)及点(.)。 +指定该参数时,所有复制出的镜像都设置相同的名称。 +不指定该参数时,复制的镜像使用源镜像名称。 + optional + * @param {string} [opts.description] - 复制出新镜像的描述,不超过256个字符。 +指定该参数时,所有复制出的镜像都设置相同的描述。 +不指定该参数时,复制的镜像使用系统生成的描述信息。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param copyImage copyImages + */ + + copyImages (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 copyImages" + ) + } + + opts = opts || {} + + if ( + opts.destinationRegion === undefined || + opts.destinationRegion === null + ) { + throw new Error( + "Missing the required parameter 'opts.destinationRegion' when calling copyImages" + ) + } + + let postBody = {} + if (opts.sourceImageIds !== undefined && opts.sourceImageIds !== null) { + postBody['sourceImageIds'] = opts.sourceImageIds + } + if ( + opts.destinationRegion !== undefined && + opts.destinationRegion !== null + ) { + postBody['destinationRegion'] = opts.destinationRegion + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + 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 vm/1.6.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 copyImages 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}/images:copyImages', + '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) + } + ) + } + + /** + * +修改镜像属性。 + +详细操作说明请参考帮助文档:[镜像概述](https://docs.jdcloud.com/cn/virtual-machines/image-overview) + +## 接口说明 +- 只支持修改镜像名称或描述。 + + * @param {Object} opts - parameters + * @param {string} opts.imageId - 镜像ID。 + * @param {string} [opts.name] - 镜像名称。参考 [公共参数规范](https://docs.jdcloud.com/virtual-machines/api/general_parameters)。 optional + * @param {string} [opts.description] - 镜像描述。参考 [公共参数规范](https://docs.jdcloud.com/virtual-machines/api/general_parameters)。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyImageAttribute (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 modifyImageAttribute" + ) + } + + opts = opts || {} + + if (opts.imageId === undefined || opts.imageId === null) { + throw new Error( + "Missing the required parameter 'opts.imageId' when calling modifyImageAttribute" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + imageId: opts.imageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 modifyImageAttribute 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}/images/{imageId}:modifyImageAttribute', + '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) + } + ) + } + + /** + * +导入私有镜像。 + +详细操作说明请参考帮助文档:[导入私有镜像](https://docs.jdcloud.com/cn/virtual-machines/import-private-image) + +## 接口说明 +- 导入后的镜像将以 `云硬盘系统盘镜像` 格式作为私有镜像使用,同时会自动生成与导入镜像关联的快照。 + + * @param {Object} opts - parameters + * @param {string} opts.architecture - 镜像架构。取值范围:`x86_64、arm64`。 + * @param {string} opts.osType - 镜像的操作系统类型。取值范围:`windows、linux`。 + * @param {string} opts.platform - 镜像的操作系统平台名称。 +取值范围:`Ubuntu、CentOS、Windows Server、Other Linux、Other Windows`。 + + * @param {string} opts.diskFormat - 磁盘格式,取值范围:`qcow2、vhd、vmdk、raw`。 + * @param {integer} opts.systemDiskSizeGB - 以此镜像需要制作的系统盘的默认大小,单位GB。最小值40,最大值500,要求值是10的整数倍。 + * @param {string} opts.imageUrl - 要导入镜像的对象存储外链地址。 + * @param {string} [opts.osVersion] - 镜像的操作系统版本。 optional + * @param {string} opts.imageName - 导入镜像的自定义名称。参考 [公共参数规范](https://docs.jdcloud.com/virtual-machines/api/general_parameters)。 + * @param {string} [opts.description] - 导入镜像的描述信息。参考 [公共参数规范](https://docs.jdcloud.com/virtual-machines/api/general_parameters)。 optional + * @param {boolean} [opts.forceImport] - 是否强制导入。强制导入会忽略镜像的合规性检测。默认为false。 optional + * @param {array} [opts.dataDisks] - 云盘快照信息。 + optional + * @param {string} [opts.clientToken] - 用户导出镜像的幂等性保证。每次导出请传入不同的值,如果传值与某次的clientToken相同,则返还同一个请求结果,不能超过64个字符。 optional + * @param {string} [opts.bootMode] - 镜像启动模式,默认bios,支持范围:`bios`、`uefi`。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string imageId 镜像id。 + * @param string taskId 导入任务id。 + */ + + importImage (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 importImage" + ) + } + + opts = opts || {} + + if (opts.architecture === undefined || opts.architecture === null) { + throw new Error( + "Missing the required parameter 'opts.architecture' when calling importImage" + ) + } + if (opts.osType === undefined || opts.osType === null) { + throw new Error( + "Missing the required parameter 'opts.osType' when calling importImage" + ) + } + if (opts.platform === undefined || opts.platform === null) { + throw new Error( + "Missing the required parameter 'opts.platform' when calling importImage" + ) + } + if (opts.diskFormat === undefined || opts.diskFormat === null) { + throw new Error( + "Missing the required parameter 'opts.diskFormat' when calling importImage" + ) + } + if (opts.systemDiskSizeGB === undefined || opts.systemDiskSizeGB === null) { + throw new Error( + "Missing the required parameter 'opts.systemDiskSizeGB' when calling importImage" + ) + } + if (opts.imageUrl === undefined || opts.imageUrl === null) { + throw new Error( + "Missing the required parameter 'opts.imageUrl' when calling importImage" + ) + } + if (opts.imageName === undefined || opts.imageName === null) { + throw new Error( + "Missing the required parameter 'opts.imageName' when calling importImage" + ) + } + + let postBody = {} + if (opts.architecture !== undefined && opts.architecture !== null) { + postBody['architecture'] = opts.architecture + } + if (opts.osType !== undefined && opts.osType !== null) { + postBody['osType'] = opts.osType + } + if (opts.platform !== undefined && opts.platform !== null) { + postBody['platform'] = opts.platform + } + if (opts.diskFormat !== undefined && opts.diskFormat !== null) { + postBody['diskFormat'] = opts.diskFormat + } + if (opts.systemDiskSizeGB !== undefined && opts.systemDiskSizeGB !== null) { + postBody['systemDiskSizeGB'] = opts.systemDiskSizeGB + } + if (opts.imageUrl !== undefined && opts.imageUrl !== null) { + postBody['imageUrl'] = opts.imageUrl + } + if (opts.osVersion !== undefined && opts.osVersion !== null) { + postBody['osVersion'] = opts.osVersion + } + if (opts.imageName !== undefined && opts.imageName !== null) { + postBody['imageName'] = opts.imageName + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.forceImport !== undefined && opts.forceImport !== null) { + postBody['forceImport'] = opts.forceImport + } + if (opts.dataDisks !== undefined && opts.dataDisks !== null) { + postBody['dataDisks'] = opts.dataDisks + } + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.bootMode !== undefined && opts.bootMode !== null) { + postBody['bootMode'] = opts.bootMode + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 importImage 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}/images:import', + '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) + } + ) + } + + /** + * +导出私有镜像。 + +将京东云私有镜像导出至京东云以外环境。 + +详细操作说明请参考帮助文档:[导出私有镜像](https://docs.jdcloud.com/cn/virtual-machines/export-private-image) + +## 接口说明 +- 调用此接口将私有镜像导出到京东云对象存储空间中。 +- 仅支持系统盘镜像导出,即使镜像有关联的数据盘快照,也仅会导出系统盘镜像文件。 +- 导出的镜像文件格式为QCOW2。 +- `Windows Server` 操作系统的镜像不支持导出(若镜像来源为导入镜像,则无此限制)。 +- 镜像必须为 `云硬盘系统盘` 镜像,如您的镜像是 `本地盘系统盘` 镜像,可以通过镜像类型转换功能转换为云盘系统盘镜像后再导出。 + + * @param {Object} opts - parameters + * @param {string} opts.imageId - 镜像ID。 + * @param {string} opts.roleName - 用户创建的服务角色名称。 + * @param {string} opts.ossUrl - 存储导出镜像文件的 `oss bucket` 的域名,请填写以 https:// 开头的完整url。 + * @param {string} [opts.ossPrefix] - 导出镜像文件名前缀,仅支持英文字母和数字,不能超过32个字符。 optional + * @param {string} [opts.clientToken] - 用户导出镜像的幂等性保证。每次导出请传入不同的值,如果传值与某次的clientToken相同,则返还同一个请求结果,不能超过64个字符。 optional + * @param {boolean} [opts.isAllDisk] - 是否导出整机镜像(包含数据盘),默认为false,仅导出系统盘。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string taskId 导出任务id。 + */ + + exportImage (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 exportImage" + ) + } + + opts = opts || {} + + if (opts.imageId === undefined || opts.imageId === null) { + throw new Error( + "Missing the required parameter 'opts.imageId' when calling exportImage" + ) + } + if (opts.roleName === undefined || opts.roleName === null) { + throw new Error( + "Missing the required parameter 'opts.roleName' when calling exportImage" + ) + } + if (opts.ossUrl === undefined || opts.ossUrl === null) { + throw new Error( + "Missing the required parameter 'opts.ossUrl' when calling exportImage" + ) + } + + let postBody = {} + if (opts.roleName !== undefined && opts.roleName !== null) { + postBody['roleName'] = opts.roleName + } + if (opts.ossUrl !== undefined && opts.ossUrl !== null) { + postBody['ossUrl'] = opts.ossUrl + } + if (opts.ossPrefix !== undefined && opts.ossPrefix !== null) { + postBody['ossPrefix'] = opts.ossPrefix + } + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.isAllDisk !== undefined && opts.isAllDisk !== null) { + postBody['isAllDisk'] = opts.isAllDisk + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + imageId: opts.imageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 exportImage 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}/images/{imageId}:exportImage', + '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) + } + ) + } + + /** + * +查询镜像任务详情。 + +将京东云私有镜像导出至京东云以外环境。 + +详细操作说明请参考帮助文档: +[导入私有镜像](https://docs.jdcloud.com/cn/virtual-machines/import-private-image) +[导出私有镜像](https://docs.jdcloud.com/cn/virtual-machines/export-private-image) + +## 接口说明 +- 调用该接口可查询镜像导入或导出的任务详情。 + + * @param {Object} opts - parameters + * @param {string} [opts.taskAction] - 任务操作类型。支持范围:`ImportImage、ExportImage`。 optional + * @param {string} [opts.taskStatus] - 任务状态。支持范围:`pending、running、failed、finished`。 optional + * @param {string} [opts.startTime] - 任务开始时间 optional + * @param {string} [opts.endTime] - 任务结束时间 optional + * @param {integer} [opts.pageNumber] - 页码;默认为1。 optional + * @param {integer} [opts.pageSize] - 分页大小;取值范围[10, 100]。 optional + * @param {string} [opts.taskIds] - 任务id列表。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param taskInfo taskSet + * @param integer totalCount 总数量 + */ + + imageTasks (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 imageTasks" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.taskAction !== undefined && opts.taskAction !== null) { + queryParams['taskAction'] = opts.taskAction + } + if (opts.taskStatus !== undefined && opts.taskStatus !== null) { + queryParams['taskStatus'] = opts.taskStatus + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + 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.buildArrayParam(opts.taskIds, 'taskIds')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 imageTasks 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}/imageTasks', + '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) + } + ) + } + + /** + * +查询一台或多台云主机实例的详细信息。 + +详细操作说明请参考帮助文档:[查找实例](https://docs.jdcloud.com/cn/virtual-machines/search-instance) + +## 接口说明 +- 使用 `filters` 过滤器进行条件筛选,每个 `filter` 之间的关系为逻辑与(AND)的关系。 +- 如果使用子帐号查询,只会查询到该子帐号有权限的云主机实例。关于资源权限请参考 [IAM概述](https://docs.jdcloud.com/cn/iam/product-overview)。 +- 单次查询最大可查询100条云主机实例数据。 +- 尽量一次调用接口查询多条数据,不建议使用该批量查询接口一次查询一条数据,如果使用不当导致查询过于密集,可能导致网关触发限流。 +- 由于该接口为 `GET` 方式请求,最终参数会转换为 `URL` 上的参数,但是 `HTTP` 协议下的 `GET` 请求参数长度是有大小限制的,使用者需要注意参数超长的问题。 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1。 optional + * @param {integer} [opts.pageSize] - 分页大小;<br>默认为20;取值范围[10, 100]。 optional + * @param {filter} [opts.filters] - <b>filters 中支持使用以下关键字进行过滤</b> +`instanceId`: 云主机ID,精确匹配,支持多个 +`privateIpAddress`: 云主机挂载的网卡内网主IP地址,模糊匹配,支持多个 +`az`: 可用区,精确匹配,支持多个 +`vpcId`: 私有网络ID,精确匹配,支持多个 +`status`: 云主机状态,精确匹配,支持多个,参考 [云主机状态](https://docs.jdcloud.com/virtual-machines/api/vm_status) +`name`: 云主机名称,模糊匹配,支持单个 +`imageId`: 镜像ID,精确匹配,支持多个 +`networkInterfaceId`: 弹性网卡ID,精确匹配,支持多个 +`subnetId`: 子网ID,精确匹配,支持多个 +`agId`: 使用可用组id,支持单个 +`faultDomain`: 错误域,支持多个 +`dedicatedHostId`: 专有宿主机ID,精确匹配,支持多个 +`dedicatedPoolId`: 专有宿主机池ID,精确匹配,支持多个 +`instanceType`: 实例规格,精确匹配,支持多个,可通过查询 [DescribeInstanceTypes](https://docs.jdcloud.com/virtual-machines/api/describeinstancetypes) 接口获得实例规格 +`elasticIpAddress`: 公网IP地址,精确匹配,支持单个。该条件会将公网IP转换成 `networkInterfaceId` 进行查询,所以与 `networkInterfaceId` 为或者的关系。 + optional + * @param {tagFilter} [opts.tags] - Tag筛选条件。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instance instances + * @param number totalCount 本次查询可匹配到的总记录数,使用者需要结合 `pageNumber` 和 `pageSize` 计算是否可以继续分页。 + */ + + 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 + } + 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 vm/1.6.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}/instances', + '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) + } + ) + } + + /** + * +创建一台或多台指定配置的云主机实例。 + +实例有三种创建方式,不同方式下传参详见下方的请求[参数说明](createInstance#requestparameters),也可参考请求[示例](createInstance#examples)。 + +1、自定义创建:按配置要求逐一指定参数创建; +2、使用实例模板创建:[实例模板](https://docs.jdcloud.com/virtual-machines/instance-template-overview)是实例配置信息的预配置,通过实例模板可快速创建实例,省去逐一配置参数的步骤。指定实例模板创建时,如不额外指定模板包含的参数将以模板为准创建实例,模板中未包含的参数,如可用区、内网IPv4地址、名称等仍需指定; +3、基于高可用组创建:[高可用组](https://docs.jdcloud.com/availability-group/product-overview)是一种高可用部署解决方案,提供了组内实例在数据中心内横跨多个故障域均衡部署的机制。高可用组须搭配实例模板使用,基于高可用组创建的实例将在其指定的可用区内以实例模板配置按一定分散机制创建实例。此创建方式下,实例创建参数除内网IPv4地址、名称等外均以实例模板为准且不支持再次指定。 + +详细操作说明请参考帮助文档:[创建实例](https://docs.jdcloud.com/cn/virtual-machines/create-instance) + +## 接口说明 +- 创建实例前,请参考 [创建前准备](https://docs.jdcloud.com/virtual-machines/account-preparation-linux) 完成实名认证、支付方式确认、计费类型选择等准备工作。 +- 创建实例的配置说明和选择指导,请参考 [配置项说明](https://docs.jdcloud.com/cn/virtual-machines/select-configuration-linux)。 +- 各地域下实例及关联资源(云硬盘、弹性公网IP)的可创建数量受配额限制,创建前请通过 [DescribeQuotas](https://docs.jdcloud.com/cn/virtual-machines/api/describequotas?content=API) 确认配额,如须提升请[提交工单](https://ticket.jdcloud.com/applyorder/submit)或联系京东云客服。 +- 不同地域及可用区下售卖的实例规格有差异,可通过 [DescribeInstanceTypes](https://docs.jdcloud.com/virtual-machines/api/describeinstancetypes?content=API) 查询在售规格及规格详细信息。 +- 通过本接口创建包年包月实例时将自动从账户扣款(代金券优先),如需使用第三方支付方式请通过控制台创建。 +- 单次请求最多支持创建 `100` 台实例。 +- 本接口为异步接口,请求下发成功后会返回RequestId和实例ID,此时实例处于 `Pending`(创建中)状态。如创建成功则实例自动变为 `Running`(运行中)状态;如创建失败则短暂处于 `Error`(错误)状态,随后将自动删除(创建失败的实例不会收费且会自动释放占用的配额)。实例状态可以通过 [describeInstanceStatus](https://docs.jdcloud.com/virtual-machines/api/describeinstancestatus?content=API) 接口查询。 +- 批量创建多台实例时系统将尽可能完成目标创建数量,但受底层资源、配额等因素影响,可能存在部分成功部分失败的情况,还请关注最终完成数量,如有失败情况请尝试重新申请或联系客服。 + + * @param {Object} opts - parameters + * @param {instanceSpec} opts.instanceSpec - 实例配置。 + + * @param {integer} [opts.maxCount] - 创建实例的数量,不能超过用户配额。 +取值范围:[1,100];默认值:1。 + optional + * @param {string} [opts.clientToken] - 用于保证请求的幂等性。由客户端生成,并确保不同请求中该参数唯一,长度不能超过64个字符。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string 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.instanceSpec !== undefined && opts.instanceSpec !== null) { + postBody['instanceSpec'] = opts.instanceSpec + } + if (opts.maxCount !== undefined && opts.maxCount !== null) { + postBody['maxCount'] = opts.maxCount + } + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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}/instances', + '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) + } + ) + } + + /** + * +查询一台或多台云主机实例的详细信息。该接口为轻量级接口,不返回云盘、网络、计费、标签等关联信息。如果不需要关联资源属性,尽量选择使用该接口。 + +详细操作说明请参考帮助文档:[查找实例](https://docs.jdcloud.com/cn/virtual-machines/search-instance) + +## 接口说明 +- 使用 `filters` 过滤器进行条件筛选,每个 `filter` 之间的关系为逻辑与(AND)的关系。 +- 如果使用子帐号查询,只会查询到该子帐号有权限的云主机实例。关于资源权限请参考 [IAM概述](https://docs.jdcloud.com/cn/iam/product-overview)。 +- 单次查询最大可查询100条云主机实例数据。 +- 尽量一次调用接口查询多条数据,不建议使用该批量查询接口一次查询一条数据,如果使用不当导致查询过于密集,可能导致网关触发限流。 +- 由于该接口为 `GET` 方式请求,最终参数会转换为 `URL` 上的参数,但是 `HTTP` 协议下的 `GET` 请求参数长度是有大小限制的,使用者需要注意参数超长的问题。 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1。 optional + * @param {integer} [opts.pageSize] - 分页大小;<br>默认为20;取值范围[10, 100]。 optional + * @param {filter} [opts.filters] - <b>filters 中支持使用以下关键字进行过滤</b> +`instanceId`: 云主机ID,精确匹配,支持多个 +`privateIpAddress`: 云主机挂载的网卡内网主IP地址,模糊匹配,支持多个 +`az`: 可用区,精确匹配,支持多个 +`vpcId`: 私有网络ID,精确匹配,支持多个 +`status`: 云主机状态,精确匹配,支持多个,参考 [云主机状态](https://docs.jdcloud.com/virtual-machines/api/vm_status) +`name`: 云主机名称,模糊匹配,支持单个 +`imageId`: 镜像ID,精确匹配,支持多个 +`networkInterfaceId`: 弹性网卡ID,精确匹配,支持多个 +`subnetId`: 子网ID,精确匹配,支持多个 +`agId`: 使用可用组id,支持单个 +`faultDomain`: 错误域,支持多个 +`dedicatedHostId`: 专有宿主机ID,精确匹配,支持多个 +`dedicatedPoolId`: 专有宿主机池ID,精确匹配,支持多个 +`instanceType`: 实例规格,精确匹配,支持多个,可通过查询 [DescribeInstanceTypes](https://docs.jdcloud.com/virtual-machines/api/describeinstancetypes) 接口获得实例规格 +`elasticIpAddress`: 公网IP地址,精确匹配,支持单个。该条件会将公网IP转换成 `networkInterfaceId` 进行查询,所以与 `networkInterfaceId` 为或者的关系。 + optional + * @param {tagFilter} [opts.tags] - Tag筛选条件 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param briefInstance instances + * @param number totalCount 本次查询可匹配到的总记录数,用户需要结合 `pageNumber` 和 `pageSize` 计算是否可以继续分页。 + */ + + describeBriefInstances (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 describeBriefInstances" + ) + } + + 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')) + Object.assign(queryParams, super.buildTagFilterParam(opts.tags, 'tags')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 describeBriefInstances 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}/instances:describeBriefInstances', + '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) + } + ) + } + + /** + * +查询一台云主机实例的详细信息。 + +详细操作说明请参考帮助文档:[查找实例](https://docs.jdcloud.com/cn/virtual-machines/search-instance) + +## 接口说明 +- 该接口与查询云主机列表返回的信息一致。 +- 只需要查询单个云主机实例详细信息的时候可以调用该接口。 + + * @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 响应结果。 + */ + + 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 || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeInstance" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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}/instances/{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) + } + ) + } + + /** + * +删除一台云主机实例。 + +详细操作说明请参考帮助文档:[删除实例](https://docs.jdcloud.com/cn/virtual-machines/delete-instance) + +## 接口说明 +- 不可以删除包年包月未到期的云主机。如果云主机为包年包月已到期的,并且用户处于白名单中,也不允许删除。 +- 不可以删除没有计费信息的云主机,该情况只限于创建过程中出现了异常。 +- 云主机状态必须为运行 `running`、停止 `stopped`、错误 `error`、状态,同时云主机没有正在进行中的任务才可以删除。 +- 如果云主机中挂载的数据盘为按配置计费的云硬盘且 `AutoDelete` 属性为 `true`,那么数据盘会随云主机一起删除。 +- 云主机中绑定的弹性公网IP可以选择是否随云主机一起删除。 +- 如出现不能删除的情况请 [提交工单](https://ticket.jdcloud.com/applyorder/submit) 或联系京东云客服。 + [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云主机ID。 + * @param {boolean} [opts.deletePrimaryNetworkInterfaceAllElasticIp] - 是否删除主机的主网卡绑定的所有弹性公网IP,默认为否。可选值:`true`,`false`。 +当回收站功能关闭的时候,此参数生效。 +当回收站功能开启的时候,且参数 `destroy` 为 `true` 的时候,此参数生效。 +当回收站功能开启的时候,且参数 `destroy` 为 `false` 的时候,此参数不生效。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + 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 || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling deleteInstance" + ) + } + + let postBody = null + let queryParams = {} + if ( + opts.deletePrimaryNetworkInterfaceAllElasticIp !== undefined && + opts.deletePrimaryNetworkInterfaceAllElasticIp !== null + ) { + queryParams['deletePrimaryNetworkInterfaceAllElasticIp'] = + opts.deletePrimaryNetworkInterfaceAllElasticIp + } + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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}/instances/{instanceId}', + '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) + } + ) + } + + /** + * +查询一台或多台云主机实例的状态。 + +云主机实例的状态说明请参考帮助文档:[云主机状态](https://docs.jdcloud.com/cn/virtual-machines/api/vm_status) + +## 接口说明 +- 使用 `filters` 过滤器进行条件筛选,每个 `filter` 之间的关系为逻辑与(AND)的关系。 +- 单次查询最大可查询100条云主机状态。 +- 尽量一次调用接口查询多条数据,不建议使用该批量查询接口一次查询一条数据,如果使用不当导致查询过于密集,可能导致网关触发限流。 +- 由于该接口为 `GET` 方式请求,最终参数会转换为 `URL` 上的参数,但是 `HTTP` 协议下的 `GET` 请求参数长度是有大小限制的,使用者需要注意参数超长的问题。 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1。 optional + * @param {integer} [opts.pageSize] - 分页大小;<br>默认为20;取值范围[10, 100]。 optional + * @param {filter} [opts.filters] - <b>filters 中支持使用以下关键字进行过滤</b> +`instanceId`: 云主机ID,精确匹配,支持多个 +`privateIpAddress`: 主网卡内网主IP地址,模糊匹配,支持多个 +`vpcId`: 私有网络ID,精确匹配,支持多个 +`status`: 云主机状态,精确匹配,支持多个,参考 [云主机状态](https://docs.jdcloud.com/virtual-machines/api/vm_status) +`name`: 云主机名称,模糊匹配,支持单个 +`imageId`: 镜像ID,精确匹配,支持多个 +`agId`: 使用可用组id,支持单个 +`faultDomain`: 错误域,支持多个 +`networkInterfaceId`: 弹性网卡ID,精确匹配,支持多个 +`subnetId`: 子网ID,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instanceStatus instanceStatuses + * @param number totalCount 本次查询可匹配到的总记录数,使用者需要结合 `pageNumber` 和 `pageSize` 计算是否可以继续分页。 + */ + + describeInstanceStatus (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 describeInstanceStatus" + ) + } + + 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 vm/1.6.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 describeInstanceStatus 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}/instanceStatus', + '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地址。 + +弹性网卡说明请参考帮助文档:[弹性网卡](https://docs.jdcloud.com/cn/virtual-machines/attach-eni) + +## 接口说明 +- 使用 `filters` 过滤器进行条件筛选,每个 `filter` 之间的关系为逻辑与(AND)的关系。 +- 单次查询最大可查询100条云主机实例数据。 +- 尽量一次调用接口查询多条数据,不建议使用该批量查询接口一次查询一条数据,如果使用不当导致查询过于密集,可能导致网关触发限流。 +- 由于该接口为 `GET` 方式请求,最终参数会转换为 `URL` 上的参数,但是 `HTTP` 协议下的 `GET` 请求参数长度是有大小限制的,使用者需要注意参数超长的问题。 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1。 optional + * @param {integer} [opts.pageSize] - 分页大小;<br>默认为20;取值范围[10, 100]。 optional + * @param {filter} [opts.filters] - <b>filters 中支持使用以下关键字进行过滤</b> +`instanceId`: 云主机ID,精确匹配,支持多个 +`privateIpAddress`: 主网卡内网主IP地址,模糊匹配,支持多个 +`vpcId`: 私有网络ID,精确匹配,支持多个 +`status`: 云主机状态,精确匹配,支持多个,参考 [云主机状态](https://docs.jdcloud.com/virtual-machines/api/vm_status) +`name`: 云主机名称,模糊匹配,支持单个 +`imageId`: 镜像ID,精确匹配,支持多个 +`agId`: 使用可用组id,支持单个 +`faultDomain`: 错误域,支持多个 +`networkInterfaceId`: 弹性网卡ID,精确匹配,支持多个 +`subnetId`: 子网ID,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instancePrivateIpAddress instancePrivateIpAddress + * @param number totalCount 本次查询可匹配到的总记录数,用户需要结合 `pageNumber` 和 `pageSize` 计算是否可以继续分页。 + */ + + describeInstancePrivateIpAddress ( + 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 describeInstancePrivateIpAddress" + ) + } + + 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 vm/1.6.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 describeInstancePrivateIpAddress 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}/instancePrivateIpAddress', + '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) + } + ) + } + + /** + * +停止云主机实例。 + +详细操作说明请参考帮助文档:[停止实例](https://docs.jdcloud.com/cn/virtual-machines/stop-instance) + +## 接口说明 +- 实例状态必须为运行 `running` 状态,同时实例没有正在进行中的任务时才可停止。 +- 如果云主机实例属性 `chargeOnStopped` 的值为 `stopCharging`,实例关机之后,实例部分将停止计费,且释放实例自身包含的资源(CPU/内存/GPU/本地数据盘)。需要使用者注意的是,实例一旦释放自身资源,再次启动时有可能因为库存资源不足而导致无法启动。 +- `chargeOnStopped` 该参数仅对按配置计费且系统盘为云硬盘的实例生效,并且不是专有宿主机中的实例。 + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云主机ID。 + * @param {string} [opts.chargeOnStopped] - 停机不计费模式。 +该参数仅对按配置计费且系统盘为云硬盘的实例生效,并且不是专有宿主机中的实例。 +配置停机不计费且停机后,实例部分将停止计费,且释放实例自身包含的资源(CPU/内存/GPU/本地数据盘)。 +可选值: +`keepCharging`:停机后保持计费,不释放资源。 +`stopCharging`:停机后停止计费,释放实例资源。默认值为空。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + 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.chargeOnStopped !== undefined && opts.chargeOnStopped !== null) { + postBody['chargeOnStopped'] = opts.chargeOnStopped + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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}/instances/{instanceId}: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) + } + ) + } + + /** + * +启动云主机实例。 + +详细操作说明请参考帮助文档:[启动实例](https://docs.jdcloud.com/cn/virtual-machines/start-instance) + +## 接口说明 +- 实例状态必须为停止 `stopped` 状态,同时实例没有正在进行中的任务时才可以启动。 +- 如果实例为停机不计费模式,启动时有可能因为库存资源不足而导致无法启动。 +- 如果云主机实例已欠费或已到期,则无法启动。 +- 如果实例系统盘是云硬盘,启动之前请确保系统盘处于正常挂载状态。 + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云主机ID。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + 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 = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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}/instances/{instanceId}: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) + } + ) + } + + /** + * +重启云主机实例。 + +详细操作说明请参考帮助文档:[重启实例](https://docs.jdcloud.com/cn/virtual-machines/reboot-instance) + +## 接口说明 +- 实例状态必须为运行 `running` 状态,同时实例没有正在进行中的任务时才可以重启。 +- 如果云主机实例已欠费或已到期,则无法重启。 + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云主机ID。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + rebootInstance (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 rebootInstance" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling rebootInstance" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 rebootInstance 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}/instances/{instanceId}:rebootInstance', + '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) + } + ) + } + + /** + * +重新部署主机实例。 + +详细操作说明请参考帮助文档:[重新部署实例](https://docs.jdcloud.com/cn/virtual-machines/redeploy-instance) + +## 接口说明 +- 必须是已隔离的实例,推荐关机状态。 + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云主机ID。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + redeployInstance (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 redeployInstance" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling redeployInstance" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 redeployInstance 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}/instances/{instanceId}:redeployInstance', + '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) + } + ) + } + + /** + * +为云主机绑定弹性网卡。 + +详细操作说明请参考帮助文档:[绑定弹性网卡](https://docs.jdcloud.com/cn/virtual-machines/attach-eni) + +## 接口说明 +- 实例状态必须为 `running` 或 `stopped` 状态,同时实例没有正在进行中的任务时才可以操作。 +- 实例中的主网卡是不可以解绑和绑定的,绑定弹性网卡只支持绑定辅助网卡。 +- 目标弹性网卡上如果绑定了弹性公网IP,那么其所在的可用区需要与云主机的可用区保持一致,或者弹性公网IP是全可用区类型的,才允许绑定该弹性网卡。 +- 弹性网卡与云主机必须在相同vpc下。 +- 对于受管网卡,授权中不能含有 `instance-attach` 用户才可以挂载。 +- 对于授信网卡,授权中必须含有 `instance-attach` 用户才可以挂载。 +- 实例挂载弹性网卡的数量,不能超过实例规格的限制。可查询 [DescribeInstanceTypes](https://docs.jdcloud.com/virtual-machines/api/describeinstancetypes) 接口获得指定规格可挂载弹性网卡的数量上限。 + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云主机ID。 + * @param {string} opts.networkInterfaceId - 弹性网卡ID。 + * @param {boolean} [opts.autoDelete] - 随云主机实例自动删除,默认为False。 +受管网卡或授信网卡默认为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 vm/1.6.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 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}/instances/{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) + } + ) + } + + /** + * +为云主机解绑弹性网卡。 + +详细操作说明请参考帮助文档:[解绑弹性网卡](https://docs.jdcloud.com/cn/virtual-machines/detach-eni) + +## 接口说明 +- 实例状态必须为 `running` 或 `stopped` 状态,同时实例没有正在进行中的任务时才可以操作。 +- 实例中的主网卡是不可以解绑和绑定的,解绑弹性网卡只支持解绑辅助网卡。 + + * @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 vm/1.6.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 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}/instances/{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) + } + ) + } + + /** + * +修改云主机弹性网卡属性。 + +详细操作说明请参考帮助文档:[配置弹性网卡删除属性](https://docs.jdcloud.com/cn/virtual-machines/configurate-eni-delete-attributes) + +## 接口说明 +- 当前只支持修改随云主机实例删除的属性。 +- 不支持修改主网卡。 + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云主机ID。 + * @param {array} [opts.networks] - 弹性网卡列表。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyInstanceNetworkAttribute ( + 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 modifyInstanceNetworkAttribute" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyInstanceNetworkAttribute" + ) + } + + let postBody = {} + if (opts.networks !== undefined && opts.networks !== null) { + postBody['networks'] = opts.networks + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 modifyInstanceNetworkAttribute 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}/instances/{instanceId}:modifyInstanceNetworkAttribute', + '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) + } + ) + } + + /** + * +为云主机绑定弹性公网IP。 + +详细操作说明请参考帮助文档:[绑定弹性公网IP](https://docs.jdcloud.com/cn/virtual-machines/associate-elastic-ip) + +## 接口说明 +- 该接口只支持在实例的主网卡的主内网IP上绑定弹性公网IP。 +- 一台云主机的主网卡的主内网IP只能绑定一个弹性公网IP,若已绑定弹性公网IP,操作绑定会返回错误。 +- 弹性公网IP所在的可用区需要与云主机的可用区保持一致,或者弹性公网IP是全可用区类型的,才允许绑定操作。 + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云主机ID。 + * @param {string} opts.elasticIpId - 弹性公网IP的ID。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + associateElasticIp (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 associateElasticIp" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling associateElasticIp" + ) + } + if (opts.elasticIpId === undefined || opts.elasticIpId === null) { + throw new Error( + "Missing the required parameter 'opts.elasticIpId' when calling associateElasticIp" + ) + } + + let postBody = {} + if (opts.elasticIpId !== undefined && opts.elasticIpId !== null) { + postBody['elasticIpId'] = opts.elasticIpId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 associateElasticIp 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}/instances/{instanceId}:associateElasticIp', + '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) + } + ) + } + + /** + * +为云主机解绑弹性公网IP。 + +详细操作说明请参考帮助文档:[解绑弹性公网IP](https://docs.jdcloud.com/cn/virtual-machines/disassociate-elastic-ip) + +## 接口说明 +- 该接口只支持解绑实例的主网卡的主内网IP上的弹性公网IP。 + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云主机ID。 + * @param {string} opts.elasticIpId - 弹性公网IP的ID。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + disassociateElasticIp (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 disassociateElasticIp" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling disassociateElasticIp" + ) + } + if (opts.elasticIpId === undefined || opts.elasticIpId === null) { + throw new Error( + "Missing the required parameter 'opts.elasticIpId' when calling disassociateElasticIp" + ) + } + + let postBody = {} + if (opts.elasticIpId !== undefined && opts.elasticIpId !== null) { + postBody['elasticIpId'] = opts.elasticIpId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 disassociateElasticIp 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}/instances/{instanceId}:disassociateElasticIp', + '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) + } + ) + } + + /** + * +为云主机制作私有镜像。 + +详细操作说明请参考帮助文档:[基于实例创建私有镜像](https://docs.jdcloud.com/cn/virtual-machines/create-private-image) + +## 接口说明 +- 云主机实例没有正在进行中的任务时才可制作镜像。 +- 本地系统盘的实例,仅支持关机(已停止)状态下制作私有镜像。 +- 云盘系统盘的实例,支持开机(运行中)/关机(已停止)状态下制作私有镜像。 +- 调用接口后,需要等待镜像状态变为 `ready` 后,才能正常使用镜像。 +- 若当前实例系统盘为本地盘,则创建完成后的私有镜像为本地盘系统盘镜像;若当前实例系统盘为云硬盘,则创建完成后的私有镜像为云硬盘系统盘镜像。您可通过镜像类型转换 [convertImage](https://docs.jdcloud.com/Image/api/convertimage) 将本地盘系统盘镜像转换为云硬盘系统盘镜像后使用。 +- 默认情况下,制作的镜像中包括数据盘中的云硬盘(制作快照),但是不包含本地数据盘。 +- 如果需要变更打包镜像中的一些数据盘、或排除一些数据盘不需要制作快照,可通过 `dataDisks` 中的参数进行控制。 + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云主机ID。 + * @param {string} opts.name - 镜像名称,长度为2\~32个字符,只允许中文、数字、大小写字母、英文下划线(\_)、连字符(-)及点(.)。 + + * @param {string} [opts.description] - 镜像描述。256字符以内。 + optional + * @param {array} [opts.dataDisks] - 数据盘列表。 +在不指定该参数的情况下,制作镜像的过程中会将该实例中的所有云盘数据盘制作快照,并与系统盘一起,制作成打包镜像。 +如果不希望将实例中的某个云盘数据盘制作快照,可使用 `noDevice` 的方式排除,例如:`deviceName=vdb`、`noDevice=true` 就不会将 `vdb` 制作快照。 +如果希望在打包镜像中插入一块新盘,该盘不在实例中,可通过指定新的 `deviceName` 的方式实现,例如:`deviceName=vdx` 将会在打包镜像中插入一块盘符为 `vdx` 的新盘,支持新盘使用或不使用快照都可以。 +如果使用 `deviceName` 指定了与实例中相同的盘符,那么实例中对应的云盘数据盘也不会制作快照,并使用新指定的参数进行替换。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string imageId 镜像ID。 + */ + + createImage (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 createImage" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling createImage" + ) + } + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createImage" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.dataDisks !== undefined && opts.dataDisks !== null) { + postBody['dataDisks'] = opts.dataDisks + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 createImage 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}/instances/{instanceId}:createImage', + '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) + } + ) + } + + /** + * +为一台云主机挂载云硬盘。 + +详细操作说明请参考帮助文档:[挂载云硬盘](https://docs.jdcloud.com/cn/virtual-machines/attach-cloud-disk) + +## 接口说明 +- 云主机和云硬盘都没有正在进行中的的任务时才可以操作。 +- 云主机状态必须是 `running` 或 `stopped` 状态。操作系统盘时必须先停止实例。 +- 实例挂载云硬盘的数量,不能超过实例规格的限制。可查询 [DescribeInstanceTypes](https://docs.jdcloud.com/virtual-machines/api/describeinstancetypes) 接口获得指定规格可挂载云硬盘的数量上限。 +- 实例可挂载的云硬盘类型,受实例规格限制。可查询 [DescribeInstanceTypes](https://docs.jdcloud.com/virtual-machines/api/describeinstancetypes) 接口获得指定规格支持挂载的云硬盘类型。 +- 云硬盘作为系统盘时,容量不能小于40GB,并且不能超过500GB。 +- 待挂载的云硬盘与云主机实例必须在同一个可用区下。 +- 共享型云硬盘最多可挂载16个云主机实例,并且只能用作数据盘,不能用于系统盘。非共享型云盘最多只能挂载一个云主机实例。 + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云主机ID。 + * @param {string} opts.diskId - 云硬盘ID。 + * @param {string} [opts.deviceName] - 磁盘逻辑挂载点。 +**系统盘**:必须指定并且只能是vda。 +**数据盘**:取值范围:`[vdb~vdbm]`。 + optional + * @param {boolean} [opts.autoDelete] - 是否随实例一起删除,即删除实例时是否自动删除此磁盘。此参数仅对按配置计费的非多点挂载云硬盘生效。 +可选值: +`true`:随实例删除。 +`false`(默认值):不随实例删除。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + attachDisk (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 attachDisk" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling attachDisk" + ) + } + if (opts.diskId === undefined || opts.diskId === null) { + throw new Error( + "Missing the required parameter 'opts.diskId' when calling attachDisk" + ) + } + + let postBody = {} + if (opts.diskId !== undefined && opts.diskId !== null) { + postBody['diskId'] = opts.diskId + } + if (opts.deviceName !== undefined && opts.deviceName !== null) { + postBody['deviceName'] = opts.deviceName + } + 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 vm/1.6.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 attachDisk 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}/instances/{instanceId}:attachDisk', + '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) + } + ) + } + + /** + * +为一台云主机缷载云硬盘 + +详细操作说明请参考帮助文档:[缷载云硬盘](https://docs.jdcloud.com/cn/virtual-machines/detach-cloud-disk) + +## 接口说明 +- 云主机和云硬盘都没有正在进行中的的任务时才可以操作。 +- 云主机状态必须是 `running` 或 `stopped` 状态。操作系统盘时必须先停止实例。 + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云主机ID。 + * @param {string} opts.diskId - 云硬盘ID。 + * @param {boolean} [opts.force] - 是否强制缷载,默认False。 +如果此参数传值为True,数据盘的IO会被强制断掉。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + detachDisk (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 detachDisk" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling detachDisk" + ) + } + if (opts.diskId === undefined || opts.diskId === null) { + throw new Error( + "Missing the required parameter 'opts.diskId' when calling detachDisk" + ) + } + + let postBody = {} + if (opts.diskId !== undefined && opts.diskId !== null) { + postBody['diskId'] = opts.diskId + } + if (opts.force !== undefined && opts.force !== null) { + postBody['force'] = opts.force + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 detachDisk 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}/instances/{instanceId}:detachDisk', + '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) + } + ) + } + + /** + * +修改一台云主机中的云硬盘属性。 + +详细操作说明请参考帮助文档:[配置云硬盘删除属性](https://docs.jdcloud.com/cn/virtual-machines/configurate-delete-attributes) + +## 接口说明 +- 该接口当前只能修改实例中的云硬盘随实例删除属性。 +- 仅按配置计费、并且非共享型的云硬盘支持修改。 +- 包年包月计费的云硬盘该属性不生效,实例删除时云硬盘将保留。 + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云主机ID。 + * @param {array} [opts.dataDisks] - 云硬盘列表。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyInstanceDiskAttribute (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 modifyInstanceDiskAttribute" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyInstanceDiskAttribute" + ) + } + + let postBody = {} + if (opts.dataDisks !== undefined && opts.dataDisks !== null) { + postBody['dataDisks'] = opts.dataDisks + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 modifyInstanceDiskAttribute 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}/instances/{instanceId}:modifyInstanceDiskAttribute', + '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) + } + ) + } + + /** + * +修改一台云主机的属性。 + +详细操作说明请参考帮助文档: +[修改实例名称](https://docs.jdcloud.com/cn/virtual-machines/modify-instance-name) +[自定义数据](https://docs.jdcloud.com/cn/virtual-machines/userdata) +[实例元数据](https://docs.jdcloud.com/cn/virtual-machines/instance-metadata) + +## 接口说明 +- 支持修改实例的名称、描述、hostname、自定义数据、实例元数据。 + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云主机ID。 + * @param {string} [opts.name] - 实例名称。长度为2\~128个字符,只允许中文、数字、大小写字母、英文下划线(\_)、连字符(-)及点(.),不能以(.)作为首尾。 + optional + * @param {string} [opts.description] - 实例描述。256字符以内。 + optional + * @param {string} [opts.hostname] - 实例hostname。 +**Windows系统**:长度为2\~15个字符,允许大小写字母、数字或连字符(-),不能以连字符(-)开头或结尾,不能连续使用连字符(-),也不能全部使用数字。不支持点号(.)。 +**Linux系统**:长度为2-64个字符,允许支持多个点号,点之间为一段,每段允许使用大小写字母、数字或连字符(-),但不能连续使用点号(.)或连字符(-),不能以点号(.)或连字符(-)开头或结尾。 + optional + * @param {array} [opts.metadata] - 用户自定义元数据。 +以 `key-value` 键值对形式指定,可在实例系统内通过元数据服务查询获取。最多支持40对键值对,且 `key` 不超过256字符,`value` 不超过16KB,不区分大小写。 +注意:`key` 不要以连字符(-)结尾,否则此 `key` 不生效。 + optional + * @param {array} [opts.userdata] - 自定义脚本。 +目前仅支持启动脚本,即 `launch-script`,须Base64编码且编码前数据长度不能超过16KB。 +**linux系统**:支持bash和python,编码前须分别以 `#!/bin/bash` 和 `#!/usr/bin/env python` 作为内容首行。 +**Windows系统**:支持 `bat` 和 `powershell` ,编码前须分别以 `<cmd></cmd>和<powershell></powershell>` 作为内容首、尾行。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyInstanceAttribute (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 modifyInstanceAttribute" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyInstanceAttribute" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.hostname !== undefined && opts.hostname !== null) { + postBody['hostname'] = opts.hostname + } + if (opts.metadata !== undefined && opts.metadata !== null) { + postBody['metadata'] = opts.metadata + } + if (opts.userdata !== undefined && opts.userdata !== null) { + postBody['userdata'] = opts.userdata + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 modifyInstanceAttribute 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}/instances/{instanceId}:modifyInstanceAttribute', + '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) + } + ) + } + + /** + * +修改一台云主机的子网或内网IP地址。 + +详细操作说明请参考帮助文档:[修改网络配置](https://docs.jdcloud.com/cn/virtual-machines/modify-vpc-attribute) + +## 接口说明 +- 调该接口之前实例必须处于停止 `stopped` 状态。 +- 修改VPC及子网 + - 内网IPv4:可指定或由系统分配。 + - IPv6:如新子网支持IPv6,可选是否分配,如果选择分配但不指定Ipv6地址,系统会自动分配。 + - 安全组:须指定新VPC下的安全组。 +- 不修改VPC,仅修改子网 + - 内网IPv4:可指定或由系统分配。 + - IPv6:如新子网支持IPv6,可选是否分配,如分配仅支持系统分配。 + - 安全组:不支持绑定新安全组。 +- 不修改VPC及子网,仅更换内网IP + - 内网IPv4:须指定IP地址。 + - IPv6:不支持修改。 + - 安全组:不支持绑定新安全组。 +- 一些限制及注意事项: + - 已加入负载均衡-后端服务器组中的实例不允许修改。 + - 绑定弹性网卡的实例不支持修改VPC,仅支持在同VPC下修改子网和内网IP。 + - 主网卡分配了辅助内网IP的实例不支持修改VPC和子网,仅支持在同子网下修改内网IP。 + - 如实例在高可用组内,则不允许修改VPC,仅可在同VPC内修改子网或内网IPv4地址。 + - 仅在更换VPC时传入安全组ID才有效,且安全组须隶属于目标VPC。 + - 如指定内网IPv4,须确保IP地址在子网网段内且未被占用;如不指定则随机分配,须确保子网可用IP充足。 + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云主机ID。 + * @param {string} opts.subnetId - 子网Id。 + * @param {boolean} [opts.assignIpv6] - `true`: 分配IPV6地址。 +`false`: 不分配IPV6地址。 + optional + * @param {string} [opts.ipv6Address] - 切换子网后的IPV6地址,不可与assignIpv6同时指定。 + optional + * @param {string} [opts.privateIpAddress] - Ipv4地址。 +不变更 `vpc` 及子网时必须指定Ipv4地址 + optional + * @param {array} [opts.securityGroups] - 安全组列表。 +更换 `vpc` 时必须指定新的安全组。 +不更换 `vpc` 时不可以指定安全组。 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyInstanceVpcAttribute (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 modifyInstanceVpcAttribute" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyInstanceVpcAttribute" + ) + } + if (opts.subnetId === undefined || opts.subnetId === null) { + throw new Error( + "Missing the required parameter 'opts.subnetId' when calling modifyInstanceVpcAttribute" + ) + } + + let postBody = {} + if (opts.subnetId !== undefined && opts.subnetId !== null) { + postBody['subnetId'] = opts.subnetId + } + if (opts.assignIpv6 !== undefined && opts.assignIpv6 !== null) { + postBody['assignIpv6'] = opts.assignIpv6 + } + if (opts.ipv6Address !== undefined && opts.ipv6Address !== null) { + postBody['ipv6Address'] = opts.ipv6Address + } + if (opts.privateIpAddress !== undefined && opts.privateIpAddress !== null) { + postBody['privateIpAddress'] = opts.privateIpAddress + } + if (opts.securityGroups !== undefined && opts.securityGroups !== null) { + postBody['securityGroups'] = opts.securityGroups + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 modifyInstanceVpcAttribute 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}/instances/{instanceId}:modifyInstanceVpcAttribute', + '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) + } + ) + } + + /** + * +修改云主机密码。 + +详细操作说明请参考帮助文档:[重置密码](https://docs.jdcloud.com/cn/virtual-machines/reset-password) + +## 接口说明 +- 实例没有正在进行中的任务时才可操作。 +- 重置密码后,需要重启云主机后生效。 + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云主机ID。 + * @param {string} opts.password - 实例密码。 +可用于SSH登录和VNC登录。 +长度为8\~30个字符,必须同时包含大、小写英文字母、数字和特殊符号中的三类字符。特殊符号包括:`\(\)\`~!@#$%^&\*\_-+=\|{}\[ ]:";'<>,.?/,`。 +更多密码输入要求请参见 [公共参数规范](https://docs.jdcloud.com/virtual-machines/api/general_parameters)。 + + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyInstancePassword (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 modifyInstancePassword" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyInstancePassword" + ) + } + if (opts.password === undefined || opts.password === null) { + throw new Error( + "Missing the required parameter 'opts.password' when calling modifyInstancePassword" + ) + } + + let postBody = {} + if (opts.password !== undefined && opts.password !== null) { + postBody['password'] = opts.password + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 modifyInstancePassword 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}/instances/{instanceId}:modifyInstancePassword', + '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) + } + ) + } + + /** + * +获取云主机vnc地址。 + +详细操作说明请参考帮助文档:[连接实例](https://docs.jdcloud.com/cn/virtual-machines/connect-to-instance) + +## 接口说明 +- 实例仅 `running` 状态时才可获取到 `vnc` 地址。 +- 调用该接口可获取云主机 `vnc` 地址,用于远程连接管理云主机。 +- `vnc` 地址的有效期为1个小时,调用接口获取vnc地址后如果1个小时内没有使用,`vnc` 地址将自动失效,再次使用需要重新获取。 +- 裸金属实例目前不支持通过 `vnc` 登录。 + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云主机ID。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string vncUrl 远程vnc地址。 + */ + + describeInstanceVncUrl (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 describeInstanceVncUrl" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling describeInstanceVncUrl" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 describeInstanceVncUrl 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}/instances/{instanceId}/vnc', + '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) + } + ) + } + + /** + * +变更云主机实例配置。 + +详细操作说明请参考帮助文档:[调整配置](https://docs.jdcloud.com/cn/virtual-machines/resize-instance) + +## 接口说明 + - 云主机的状态必须为 `stopped` 状态。 + - 16年创建的云硬盘做系统盘的云主机,实例规格不允许跨代调配。 + - 若当前实例系统盘为本地盘,则不允许跨代调配,例如第一代云主机不允许与第二代云主机互相调配,且不允许调整至第一代存储优化大数据型 `s.d1` 及第二代存储优化大数据型 `s.d2`。 + - 若当前实例在高可用组内,则不允许调配至除GPU类型外的第一代云主机,受限于高可用组支持的规格情况。 + - 若当前实例已挂载加密云盘,则不允许调配至第一代云主机,受限于支持加密盘的规格情况。 + - 裸金属实例规格主机暂不支持调配,即不支持从其他规格调整为裸金属规格或从裸金属规格调整为其他规格。 + - 对于按配置计费实例,调整配置后将按照新规格计费,调整前规格会立即出账结算(即对上次整点结算时间至当前时间产生的费用进行结算)。 + - 若当前实例带有本地数据盘,需清除本地盘内数据才可调整配置,还请谨慎操作。 + - 对于包年包月计费云主机: + - 若调配后规格价格低于调配前规格价格,则将延长云主机到期时间; + - 若调配后规格价格高于调配前规格价格,需要支付到期前的差价。 + - 如果当前主机中的弹性网卡数量,超过了目标实例规格允许的弹性网卡数量,会返回错误。可查询 [DescribeInstanceTypes](https://docs.jdcloud.com/virtual-machines/api/describeinstancetypes) 接口获得实例规格允许的弹性网卡数量。 + - 如果当前主机中的云硬盘数据,超过了目标实例规格允许的云硬盘数量,会返回错误。可查询 [DescribeInstanceTypes](https://docs.jdcloud.com/virtual-machines/api/describeinstancetypes) 接口获得实例规格允许的云硬盘数量。 + - 当前主机所使用的镜像,需要支持目标实例规格,否则返回错误。可查询 [DescribeImageConstraints](docs.jdcloud.com/virtual-machines/api/describeimageconstraints) 接口获得指定镜像的实例规格限制信息。 + - 云主机欠费或到期时,无法更改实例规格。 + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云主机ID。 + * @param {string} opts.instanceType - 实例规格,可查询 [DescribeInstanceTypes](https://docs.jdcloud.com/virtual-machines/api/describeinstancetypes) 接口获得指定地域或可用区的规格信息。 + * @param {boolean} [opts.force] - 是否强制调配,默认为 `false`。如果指定为 `true`, 将会清除本地数据盘。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + resizeInstance (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 resizeInstance" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling resizeInstance" + ) + } + if (opts.instanceType === undefined || opts.instanceType === null) { + throw new Error( + "Missing the required parameter 'opts.instanceType' when calling resizeInstance" + ) + } + + let postBody = {} + if (opts.instanceType !== undefined && opts.instanceType !== null) { + postBody['instanceType'] = opts.instanceType + } + if (opts.force !== undefined && opts.force !== null) { + postBody['force'] = opts.force + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 resizeInstance 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}/instances/{instanceId}:resizeInstance', + '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) + } + ) + } + + /** + * +重置云主机系统。 + +需要注意的是,重装系统会导致系统盘的内容全部丢失,数据盘的数据不受影响(但需要重新识别)。因此,在需要保留系统运行数据的情况下,强烈建议您在重置系统前制作私有镜像,之后重置时选择该私有镜像即可实现保留系统运行数据。 + +详细操作说明请参考帮助文档:[重置系统](https://docs.jdcloud.com/cn/virtual-machines/rebuild-instance) + +## 接口说明 +- 云主机的状态必须为 `stopped` 状态。 +- 若实例基于私有镜像创建,而私有镜像已被删除,则无法使用原镜像重置系统,即无法恢复至刚创建时的系统状态,建议保留被实例引用的私有镜像。 +- 重置系统需要重新指定密码,对于 `Linux` 系统您还可以重新指定 `SSH密钥`。 +- 对于云盘作系统盘的实例,当前系统盘大小不能超过目标镜像对应系统盘快照的容量。 +- 云主机系统盘类型必须与待更换镜像支持的系统盘类型保持一致,若当前云主机系统盘为 `local` 类型,则更换镜像的系统盘类型必须为 `loaclDisk` 类型;同理,若当前云主机系统盘为 `cloud` 类型,则更换镜像的系统盘类型必须为 `cloudDisk` 类型。可查询 [DescribeImages](https://docs.jdcloud.com/virtual-machines/api/describeimages) 接口获得指定地域的镜像信息。 +- 指定的镜像必须能够支持当前主机的实例规格 `instanceType`,否则会返回错误。可查询 [DescribeImageConstraints](docs.jdcloud.com/virtual-machines/api/describeimageconstraints) 接口获得指定镜像支持的系统盘类型信息。 + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云主机ID。 + * @param {string} [opts.password] - 实例密码。 +可用于SSH登录和VNC登录。 +长度为8\~30个字符,必须同时包含大、小写英文字母、数字和特殊符号中的三类字符。特殊符号包括:`\(\)\`~!@#$%^&\*\_-+=\|{}\[ ]:";'<>,.?/,`。 +更多密码输入要求请参见 [公共参数规范](https://docs.jdcloud.com/virtual-machines/api/general_parameters)。 + optional + * @param {string} [opts.imageId] - 镜像ID。 +若不指定镜像ID,默认使用当前主机的原镜像重置系统。 +可查询 [DescribeImages](https://docs.jdcloud.com/virtual-machines/api/describeimages) 接口获得指定地域的镜像信息。 + optional + * @param {array} [opts.keyNames] - 密钥对名称。仅Linux系统下该参数生效,当前仅支持输入单个密钥。 + optional + * @param {string} [opts.hostname] - 实例hostname。 +若不指定hostname,则默认以实例名称`name`作为hostname,但是会以RFC 952和RFC 1123命名规范做一定转义。 +**Windows系统**:长度为2\~15个字符,允许大小写字母、数字或连字符(-),不能以连字符(-)开头或结尾,不能连续使用连字符(-),也不能全部使用数字。不支持点号(.)。 +**Linux系统**:长度为2-64个字符,允许支持多个点号,点之间为一段,每段允许使用大小写字母、数字或连字符(-),但不能连续使用点号(.)或连字符(-),不能以点号(.)或连字符(-)开头或结尾。 + optional + * @param {array} [opts.metadata] - 用户自定义元数据。 +以 `key-value` 键值对形式指定,可在实例系统内通过元数据服务查询获取。最多支持40对键值对,且 `key` 不超过256字符,`value` 不超过16KB,不区分大小写。 +注意:`key` 不要以连字符(-)结尾,否则此 `key` 不生效。 + optional + * @param {array} [opts.userdata] - 自定义脚本。 +目前仅支持启动脚本,即 `launch-script`,须Base64编码且编码前数据长度不能超过16KB。 +**linux系统**:支持bash和python,编码前须分别以 `#!/bin/bash` 和 `#!/usr/bin/env python` 作为内容首行。 +**Windows系统**:支持 `bat` 和 `powershell`,编码前须分别以 `<cmd></cmd>和<powershell></powershell>` 作为内容首、尾行。 + optional + * @param {string} [opts.passWordAuth] - 密码授权,若存在密匙,则根据此参数决定是否使用密码,若没有密匙,此参数无效,会强制使用密码。 +若不使用密码,且密匙对解绑后,用户需重置密码,方可使用密码登录。 +此参数在windows系统中必须为yes。 + optional + * @param {string} [opts.imageInherit] - 继承镜像中的登录验证方式,"yes"为使用,"no"为不使用,""默认为"no" optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + rebuildInstance (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 rebuildInstance" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling rebuildInstance" + ) + } + + let postBody = {} + if (opts.password !== undefined && opts.password !== null) { + postBody['password'] = opts.password + } + if (opts.imageId !== undefined && opts.imageId !== null) { + postBody['imageId'] = opts.imageId + } + if (opts.keyNames !== undefined && opts.keyNames !== null) { + postBody['keyNames'] = opts.keyNames + } + if (opts.hostname !== undefined && opts.hostname !== null) { + postBody['hostname'] = opts.hostname + } + if (opts.metadata !== undefined && opts.metadata !== null) { + postBody['metadata'] = opts.metadata + } + if (opts.userdata !== undefined && opts.userdata !== null) { + postBody['userdata'] = opts.userdata + } + if (opts.passWordAuth !== undefined && opts.passWordAuth !== null) { + postBody['passWordAuth'] = opts.passWordAuth + } + if (opts.imageInherit !== undefined && opts.imageInherit !== null) { + postBody['imageInherit'] = opts.imageInherit + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 rebuildInstance 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}/instances/{instanceId}:rebuildInstance', + '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) + } + ) + } + + /** + * +批量查询云主机用户自定义元数据。 + +详细操作说明请参考帮助文档:[自定义元数据](https://docs.jdcloud.com/cn/virtual-machines/userdata) + +## 接口说明 +- 使用 `filters` 过滤器进行条件筛选,每个 `filter` 之间的关系为逻辑与(AND)的关系。 +- 单次查询最大可查询10台云主机实例自定义元数据。 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1。 optional + * @param {integer} [opts.pageSize] - 分页大小;默认为10;取值范围[1, 10]。 optional + * @param {filter} [opts.filters] - <b>filters 中支持使用以下关键字进行过滤</b> +`instanceId`: 云主机ID,精确匹配,支持多个 +`privateIpAddress`: 主网卡内网主IP地址,模糊匹配,支持多个 +`vpcId`: 私有网络ID,精确匹配,支持多个 +`status`: 云主机状态,精确匹配,支持多个,参考 [云主机状态](https://docs.jdcloud.com/virtual-machines/api/vm_status) +`name`: 云主机名称,模糊匹配,支持单个 +`imageId`: 镜像ID,精确匹配,支持多个 +`agId`: 使用可用组id,支持单个 +`faultDomain`: 错误域,支持多个 +`networkInterfaceId`: 弹性网卡ID,精确匹配,支持多个 +`subnetId`: 子网ID,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param customData customData + * @param number totalCount 本次查询可匹配到的总记录数,使用者需要结合`pageNumber`和`pageSize`计算是否可以继续分页。 + */ + + describeInstancesCustomData (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 describeInstancesCustomData" + ) + } + + 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 vm/1.6.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 describeInstancesCustomData 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}/instancesCustomData', + '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、vGPU(以P开头)外的一代机暂不支持调整高可用组。 +- 与该高可用组关联实例模板的VPC不同的不支持调整高可用组。 +- 与该高可用组可用区不匹配的实例不支持调整高可用组。 +- 本地系统盘机型不支持强制均衡。 +- 仅支持实例状态为已停止的实例强制均衡调整高可用组。 +- 若不强制均衡,仅支持实例状态为运行中或已停止的实例调整高可用组。 +- 若强制均衡,带本地数据盘的实例需确认清除本地盘数据。 + + * @param {Object} opts - parameters + * @param {string} opts.instanceId - 云主机ID。 + * @param {string} [opts.agId] - 高可用组Id,必填项。 +可查询 [DescribeAgs](https://docs.jdcloud.com/cn/availability-group/api/describeags) 接口获得高可用组信息。 + optional + * @param {boolean} [opts.balance] - 是否强制均衡,默认 false + optional + * @param {boolean} [opts.clearLocalDisk] - 是否确认清除本地盘数据,默认 false + optional + * @param {boolean} [opts.isManaged] - 是否托管实例的生命周期,默认为false;若为包年包月实例,可加入但不支持托管;该字段仅AG开启AS时生效。托管实例将在缩容或健康检查失败时被删除,非托管实例仅移出伸缩组 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyInstancePlacement (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 modifyInstancePlacement" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling modifyInstancePlacement" + ) + } + + let postBody = {} + if (opts.agId !== undefined && opts.agId !== null) { + postBody['agId'] = opts.agId + } + if (opts.balance !== undefined && opts.balance !== null) { + postBody['balance'] = opts.balance + } + if (opts.clearLocalDisk !== undefined && opts.clearLocalDisk !== null) { + postBody['clearLocalDisk'] = opts.clearLocalDisk + } + if (opts.isManaged !== undefined && opts.isManaged !== null) { + postBody['isManaged'] = opts.isManaged + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 modifyInstancePlacement 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}/instances/{instanceId}:modifyInstancePlacement', + '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 - 云主机ID。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + suspendInstance (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 suspendInstance" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling suspendInstance" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 suspendInstance 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}/instances/{instanceId}:suspendInstance', + '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 - 云主机ID。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + resumeInstance (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 resumeInstance" + ) + } + + opts = opts || {} + + if (opts.instanceId === undefined || opts.instanceId === null) { + throw new Error( + "Missing the required parameter 'opts.instanceId' when calling resumeInstance" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceId: opts.instanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 resumeInstance 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}/instances/{instanceId}:resumeInstance', + '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 {array} [opts.instanceIds] - 需要更改定时删除信息的云主机id列表。 + optional + * @param {string} [opts.autoReleaseTime] - | 为云主机设置或修改定时删除时间,如果为空,若云主机存在定时删除任务,则取消其定时删除任务。 支持的时间范围为当前时间+1小时至当前时间+10年。示例:"2025-01-01 00:00:00" optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyInstanceReleaseTime (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 modifyInstanceReleaseTime" + ) + } + + opts = opts || {} + + let postBody = {} + if (opts.instanceIds !== undefined && opts.instanceIds !== null) { + postBody['instanceIds'] = opts.instanceIds + } + if (opts.autoReleaseTime !== undefined && opts.autoReleaseTime !== null) { + postBody['autoReleaseTime'] = opts.autoReleaseTime + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 modifyInstanceReleaseTime 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}/instances:modifyInstanceReleaseTime', + '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) + } + ) + } + + /** + * +查询实例模板列表。 + +详细操作说明请参考帮助文档:[实例模板](https://docs.jdcloud.com/cn/virtual-machines/instance-template-overview) + +## 接口说明 +- 使用 `filters` 过滤器进行条件筛选,每个 `filter` 之间的关系为逻辑与(AND)的关系。 +- 单次查询最大可查询100条实例模板数据。 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1。 optional + * @param {integer} [opts.pageSize] - 分页大小;<br>默认为20;取值范围[10, 100]。 optional + * @param {filter} [opts.filters] - <b>filters 中支持使用以下关键字进行过滤</b> +`name`: 实例模板名称,模糊匹配,支持多个 +`instanceTemplateId`: 实例模板ID,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instanceTemplate instanceTemplates + * @param number totalCount 本次查询可匹配到的总记录数,使用者需要结合 `pageNumber` 和 `pageSize` 计算是否可以继续分页。 + */ + + describeInstanceTemplates (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 describeInstanceTemplates" + ) + } + + 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 vm/1.6.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 describeInstanceTemplates 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}/instanceTemplates', + '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) + } + ) + } + + /** + * +创建实例模板。 + +实例模板是创建云主机实例的配置信息模板,包括镜像、实例规格、系统盘及数据盘类型和容量、私有网络及子网配置、安全组及登录信息等。实例模板可用于创建实例及用于配置高可用组(创建高可用组时必须指定实例模板)。使用实例模板创建实例时,无需重新指定实例模板已包括的参数,缩短您的部署时间。 + +请注意:实例模板一经创建后其属性将不能编辑,如需调整参数请重新创建实例模板替换使用。 + +详细操作说明请参考帮助文档:[创建实例模板](https://docs.jdcloud.com/cn/virtual-machines/create-instance-template) + +## 接口说明 +- 创建实例模板的限制基本与创建云主机一致,可参考 [创建云主机](https://docs.jdcloud.com/cn/virtual-machines/create-instance)。 +- 实例模板中包含创建云主机的大部分配置参数,可以避免每次创建云主机时的重复性配置参数的工作。 +- 使用实例模板创建云主机时,如果再次指定了某些参数,并且与实例模板中的参数相冲突,那么新指定的参数会替换模板中的参数,以新指定的参数为准。 +- 使用实例模板创建云主机时,如果再次指定了镜像ID,并且与模板中的镜像ID不一致,那么模板中的 `systemDisk` 和 `dataDisks` 配置会失效,以新指定的镜像为准。 +- 如果使用高可用组(Ag)创建云主机,那么Ag所关联的模板中的参数都不可以被调整,只能以模板为准。 + + * @param {Object} opts - parameters + * @param {instanceTemplateSpec} opts.instanceTemplateData - 实例模板配置信息。 + * @param {string} opts.name - 实例模板的名称,参考 [公共参数规范](https://docs.jdcloud.com/virtual-machines/api/general_parameters)。 + * @param {string} [opts.description] - 实例模板的描述,参考 [公共参数规范](https://docs.jdcloud.com/virtual-machines/api/general_parameters)。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string instanceTemplateId 实例模板ID。 + */ + + createInstanceTemplate (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 createInstanceTemplate" + ) + } + + opts = opts || {} + + if ( + opts.instanceTemplateData === undefined || + opts.instanceTemplateData === null + ) { + throw new Error( + "Missing the required parameter 'opts.instanceTemplateData' when calling createInstanceTemplate" + ) + } + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createInstanceTemplate" + ) + } + + let postBody = {} + if ( + opts.instanceTemplateData !== undefined && + opts.instanceTemplateData !== null + ) { + postBody['instanceTemplateData'] = opts.instanceTemplateData + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + 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 vm/1.6.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 createInstanceTemplate 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}/instanceTemplates', + '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) + } + ) + } + + /** + * +查询实例模板详情。 + +详细操作说明请参考帮助文档:[实例模板](https://docs.jdcloud.com/cn/virtual-machines/instance-template-overview) + +## 接口说明 +- 该接口与查询实例模板列表返回的信息一致。 +- 只需要查询单个实例模板详细信息的时候可以调用该接口。 + + * @param {Object} opts - parameters + * @param {string} opts.instanceTemplateId - 实例模板ID。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instanceTemplate instanceTemplate 响应结果。 + */ + + describeInstanceTemplate (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 describeInstanceTemplate" + ) + } + + opts = opts || {} + + if ( + opts.instanceTemplateId === undefined || + opts.instanceTemplateId === null + ) { + throw new Error( + "Missing the required parameter 'opts.instanceTemplateId' when calling describeInstanceTemplate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceTemplateId: opts.instanceTemplateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 describeInstanceTemplate 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}/instanceTemplates/{instanceTemplateId}', + '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) + } + ) + } + + /** + * +修改实例模板属性。 + +详细操作说明请参考帮助文档:[实例模板](https://docs.jdcloud.com/cn/virtual-machines/instance-template-overview) + +## 接口说明 +- 名称、描述、实例模板配置信息至少要传一项。 +- 参数为 null 时,对应的参数不做更改。 + + * @param {Object} opts - parameters + * @param {string} opts.instanceTemplateId - 实例模板ID。 + * @param {string} [opts.name] - 实例模板的名称,参考 [公共参数规范](https://docs.jdcloud.com/virtual-machines/api/general_parameters)。 optional + * @param {string} [opts.description] - 实例模板的描述,参考 [公共参数规范](https://docs.jdcloud.com/virtual-machines/api/general_parameters)。 optional + * @param {updateInstanceTemplateSpec} [opts.instanceTemplateData] - 实例模板配置信息。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateInstanceTemplate (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 updateInstanceTemplate" + ) + } + + opts = opts || {} + + if ( + opts.instanceTemplateId === undefined || + opts.instanceTemplateId === null + ) { + throw new Error( + "Missing the required parameter 'opts.instanceTemplateId' when calling updateInstanceTemplate" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if ( + opts.instanceTemplateData !== undefined && + opts.instanceTemplateData !== null + ) { + postBody['instanceTemplateData'] = opts.instanceTemplateData + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceTemplateId: opts.instanceTemplateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 updateInstanceTemplate 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}/instanceTemplates/{instanceTemplateId}', + 'PATCH', + 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) + } + ) + } + + /** + * +删除单个实例模板。 + +详细操作说明请参考帮助文档:[删除实例模板](https://docs.jdcloud.com/cn/virtual-machines/delete-instance-template) + +## 接口说明 +- 关联了高可用组的实例模板不可以删除。 + + * @param {Object} opts - parameters + * @param {string} opts.instanceTemplateId - 实例模板ID。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteInstanceTemplate (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 deleteInstanceTemplate" + ) + } + + opts = opts || {} + + if ( + opts.instanceTemplateId === undefined || + opts.instanceTemplateId === null + ) { + throw new Error( + "Missing the required parameter 'opts.instanceTemplateId' when calling deleteInstanceTemplate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceTemplateId: opts.instanceTemplateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 deleteInstanceTemplate 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}/instanceTemplates/{instanceTemplateId}', + '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) + } + ) + } + + /** + * +校验实例模板的有效性。 + +详细操作说明请参考帮助文档:[实例模板](https://docs.jdcloud.com/cn/virtual-machines/instance-template-overview) + +## 接口说明 +- 调用该接口可以校验实例模板是否有效,例如某些关联资源可能已经被删除了,此刻实例模板可能已经失效了。 + + * @param {Object} opts - parameters + * @param {string} opts.instanceTemplateId - 实例模板ID。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + verifyInstanceTemplate (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 verifyInstanceTemplate" + ) + } + + opts = opts || {} + + if ( + opts.instanceTemplateId === undefined || + opts.instanceTemplateId === null + ) { + throw new Error( + "Missing the required parameter 'opts.instanceTemplateId' when calling verifyInstanceTemplate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + instanceTemplateId: opts.instanceTemplateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 verifyInstanceTemplate 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}/instanceTemplates/{instanceTemplateId}:verify', + '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) + } + ) + } + + /** + * +查询实例模板上的自定义元数据。 + +详细操作说明请参考帮助文档:[实例模板](https://docs.jdcloud.com/cn/virtual-machines/instance-template-overview) + +## 接口说明 +- 一般情况下由于自定义元数据比较大,所以限制每次最多查询10个实例模板。 + + * @param {Object} opts - parameters + * @param {filter} [opts.filters] - <b>filters 中支持使用以下关键字进行过滤</b> +`instanceTemplateId`: 实例模板ID,精确匹配,最多支持10个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instanceTemplateCustomData instanceTemplatesCustomData + * @param number totalCount 本次查询的总记录数。 + */ + + describeInstanceTemplatesCustomdata ( + 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 describeInstanceTemplatesCustomdata" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 describeInstanceTemplatesCustomdata 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}/instanceTemplatesCustomData', + '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) + } + ) + } + + /** + * +查询实例规格列表。 + +详细操作说明请参考帮助文档:[实例规格类型](https://docs.jdcloud.com/cn/virtual-machines/instance-type-family) + +## 接口说明 +- 调用该接口可查询全量实例规格信息。 +- 可查询实例规格的CPU、内存大小、可绑定的弹性网卡数量、可挂载的云硬盘数量,是否售卖等信息。 +- GPU 或 本地存储型的规格可查询 GPU型号、GPU卡数量、本地盘数量。 +- 尽量使用过滤器查询关心的实例规格,并适当缓存这些信息。否则全量查询可能响应较慢。 + + * @param {Object} opts - parameters + * @param {string} [opts.serviceName] - 产品线类型,默认为 `vm`。支持范围:`vm` 云主机,`nc` 原生容器。 optional + * @param {string} [opts.chargeMode] - 目前支持postpaid_by_spot:抢占式实例(后付费)。 optional + * @param {filter} [opts.filters] - <b>filters 中支持使用以下关键字进行过滤</b> +`instanceTypes`: 实例规格,精确匹配,支持多个 +`az`: 可用区,精确匹配,支持多个 +`architecture`: CPU架构,精确匹配,支持单个,可选范围:x86_64或arm64 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param instanceType instanceTypes + * @param instanceType specificInstanceTypes + * @param integer totalCount 本次查询到的所有实例规格数量。 + */ + + describeInstanceTypes (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 describeInstanceTypes" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.serviceName !== undefined && opts.serviceName !== null) { + queryParams['serviceName'] = opts.serviceName + } + if (opts.chargeMode !== undefined && opts.chargeMode !== null) { + queryParams['chargeMode'] = opts.chargeMode + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 describeInstanceTypes 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}/instanceTypes', + '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) + } + ) + } + + /** + * +批量查询密钥对。 + +详细操作说明请参考帮助文档:[密钥概述](https://docs.jdcloud.com/cn/virtual-machines/keypair-overview) + +## 接口说明 +- 使用 `filters` 过滤器进行条件筛选,每个 `filter` 之间的关系为逻辑与(AND)的关系。 +- 单次查询最大可查询100条密钥数据。 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认为1。 optional + * @param {integer} [opts.pageSize] - 分页大小;<br>默认为20;取值范围[10, 100]。 optional + * @param {filter} [opts.filters] - <b>filters 中支持使用以下关键字进行过滤</b> +`keyNames`: 密钥对名称,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param keypair keypairs + * @param number totalCount 本次查询可匹配到的总记录数,使用者需要结合 `pageNumber` 和 `pageSize` 计算是否可以继续分页。 + */ + + describeKeypairs (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 describeKeypairs" + ) + } + + 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 vm/1.6.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 describeKeypairs 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}/keypairs', + '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) + } + ) + } + + /** + * +创建密钥。 + +公钥和私钥都由京东云生成,公钥保存在京东云,私钥返回给用户,由用户保存。 + +详细操作说明请参考帮助文档:[创建密钥](https://docs.jdcloud.com/cn/virtual-machines/create-keypair) + +## 接口说明 +- 调用该接口创建密钥后,公钥部分存储在京东云,并返回未加密的 `PEM` 编码的 `PKCS#8` 格式私钥,您只有一次机会保存您的私钥。请妥善保管。 + + * @param {Object} opts - parameters + * @param {string} opts.keyName - 密钥对名称,需要全局唯一。 +只允许数字、大小写字母、下划线“_”及中划线“-”,不超过32个字符。 + + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string keyName 密钥对名称。 + * @param string privateKey 密钥对的私钥部分,`PEM PKCS#8` 格式。 + * @param string keyFingerprint 密钥对的指纹,根据 `RFC4716` 定义的公钥指纹格式,采用 `MD5` 信息摘要算法。 + */ + + createKeypair (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 createKeypair" + ) + } + + opts = opts || {} + + if (opts.keyName === undefined || opts.keyName === null) { + throw new Error( + "Missing the required parameter 'opts.keyName' when calling createKeypair" + ) + } + + let postBody = {} + if (opts.keyName !== undefined && opts.keyName !== null) { + postBody['keyName'] = opts.keyName + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 createKeypair 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}/keypairs', + '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) + } + ) + } + + /** + * +导入密钥。 + +与创建密钥不同的是,导入的密钥是由用户生成的。生成之后将公钥部分导入到京东云。 + +详细操作说明请参考帮助文档:[创建密钥](https://docs.jdcloud.com/cn/virtual-machines/create-keypair) + +## 接口说明 +- 调用该接口导入由其他工具生成的密钥对的公钥部分。 + + * @param {Object} opts - parameters + * @param {string} opts.keyName - 密钥对名称,需要全局唯一。 +只允许数字、大小写字母、下划线“_”及中划线“-”,不超过32个字符。 + + * @param {string} opts.publicKey - 密钥对的公钥部分。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string keyName 密钥对名称。 + * @param string keyFingerprint 密钥对的指纹,根据 `RFC4716` 定义的公钥指纹格式,采用 `MD5` 信息摘要算法。 + */ + + importKeypair (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 importKeypair" + ) + } + + opts = opts || {} + + if (opts.keyName === undefined || opts.keyName === null) { + throw new Error( + "Missing the required parameter 'opts.keyName' when calling importKeypair" + ) + } + if (opts.publicKey === undefined || opts.publicKey === null) { + throw new Error( + "Missing the required parameter 'opts.publicKey' when calling importKeypair" + ) + } + + let postBody = {} + if (opts.keyName !== undefined && opts.keyName !== null) { + postBody['keyName'] = opts.keyName + } + if (opts.publicKey !== undefined && opts.publicKey !== null) { + postBody['publicKey'] = opts.publicKey + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 importKeypair 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}/keypairs:import', + '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) + } + ) + } + + /** + * +删除密钥。 + +详细操作说明请参考帮助文档:[删除密钥](https://docs.jdcloud.com/cn/virtual-machines/delete-keypair) + +## 接口说明 +- 密钥删除后,使用该密钥的实例仍可正常使用与之匹配的本地私钥登录,且密钥仍会显示在实例详情中。 +- 密钥删除后,与之关联的实例模板将变为不可用,并且与该实例模板关联的高可用组也会变为不可用。 + + * @param {Object} opts - parameters + * @param {string} opts.keyName - 密钥名称。 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteKeypair (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 deleteKeypair" + ) + } + + opts = opts || {} + + if (opts.keyName === undefined || opts.keyName === null) { + throw new Error( + "Missing the required parameter 'opts.keyName' when calling deleteKeypair" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + keyName: opts.keyName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 deleteKeypair 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}/keypairs/{keyName}', + '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) + } + ) + } + + /** + * +为云主机实例绑定密钥。 + +详细操作说明请参考帮助文档:[绑定密钥](https://docs.jdcloud.com/cn/virtual-machines/bind-keypair) + +## 接口说明 +- 只支持为 linux 云主机实例绑定密钥。 +- 每台云主机实例只支持绑定一个密钥。如果云主机绑定的密钥被删除了,那么该云主机还可以再次绑定密钥。 + + * @param {Object} opts - parameters + * @param {string} opts.keyName - 密钥名称。 + * @param {array} [opts.instanceIds] - 要绑定的云主机Id列表。 optional + * @param {string} opts.passWordAuth - 绑定密钥后,根据此参数决定是否允许使用密码登录。可选范围: +`yes`:允许SSH密码登录。 +`no`:禁止SSH密码登录。 + + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string successInstanceId + * @param string failInstanceId + */ + + attachKeypair (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 attachKeypair" + ) + } + + opts = opts || {} + + if (opts.keyName === undefined || opts.keyName === null) { + throw new Error( + "Missing the required parameter 'opts.keyName' when calling attachKeypair" + ) + } + if (opts.passWordAuth === undefined || opts.passWordAuth === null) { + throw new Error( + "Missing the required parameter 'opts.passWordAuth' when calling attachKeypair" + ) + } + + let postBody = {} + if (opts.instanceIds !== undefined && opts.instanceIds !== null) { + postBody['instanceIds'] = opts.instanceIds + } + if (opts.passWordAuth !== undefined && opts.passWordAuth !== null) { + postBody['passWordAuth'] = opts.passWordAuth + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + keyName: opts.keyName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 attachKeypair 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}/keypairs/{keyName}:attach', + '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) + } + ) + } + + /** + * +为云主机实例解绑密钥。 + +详细操作说明请参考帮助文档:[绑定密钥](https://docs.jdcloud.com/cn/virtual-machines/bind-keypair) + +## 接口说明 +- 调用该接口解绑云主机实例中的密钥。 + + * @param {Object} opts - parameters + * @param {string} opts.keyName - 密钥名称。 + * @param {array} [opts.instanceIds] - 要解绑的云主机实例ID列表。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string successInstanceId + * @param string failInstanceId + */ + + detachKeypair (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 detachKeypair" + ) + } + + opts = opts || {} + + if (opts.keyName === undefined || opts.keyName === null) { + throw new Error( + "Missing the required parameter 'opts.keyName' when calling detachKeypair" + ) + } + + let postBody = {} + if (opts.instanceIds !== undefined && opts.instanceIds !== null) { + postBody['instanceIds'] = opts.instanceIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + keyName: opts.keyName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 detachKeypair 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}/keypairs/{keyName}:detach', + '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) + } + ) + } + + /** + * +查询资源配额。 + +## 接口说明 +- 调用该接口可查询 `云主机`、`云主机的CPU`、`云主机的内存`、`云主机的本地盘`、`镜像`、`密钥`、`实例模板`、`镜像共享` 的配额。 + + * @param {Object} opts - parameters + * @param {string} [opts.imageId] - 私有镜像Id。 +查询镜像共享 `imageShare` 的配额时,此参数必传。 + optional + * @param {filter} [opts.filters] - <b>filters 中支持使用以下关键字进行过滤</b> +`resourceTypes`: 资源类型,支持多个,可选范围:`instance、instance_cpu、instance_memory、instance_local_disk、keypair、image、instanceTemplate、imageShare` + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param quota quotas + */ + + describeQuotas (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 describeQuotas" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.imageId !== undefined && opts.imageId !== null) { + queryParams['imageId'] = opts.imageId + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vm/1.6.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 describeQuotas 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}/quotas', + '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 = VM diff --git a/packages/libs/lib-jdcloud/src/repo/vod/v1/vod.js b/packages/libs/lib-jdcloud/src/repo/vod/v1/vod.js new file mode 100644 index 000000000..2a491f6fb --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/vod/v1/vod.js @@ -0,0 +1,9134 @@ +/* + * 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. + * + * Watermark + * 水印管理相关接口 + * + * 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 = 'vod' +Service._services[serviceId] = true + +/** + * vod service. + * @version 1.2.1 + */ + +class VOD extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'vod.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询分类列表。按照分页方式,返回分类列表信息。 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认值为 1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认值为 10;取值范围 [10, 100] optional + * @param {sort} [opts.sorts] optional + * @param {string} callback - callback + @return {Object} result + * @param listCategoriesResultObject resultObject + */ + + listCategories (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.buildSortParam(opts.sorts, 'sorts')) + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 listCategories 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( + '/categories', + '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.name - 分类名称 + * @param {integer} [opts.parentId] - 父分类ID,取值为 0 或 null 时,表示该分类为一级分类 + optional + * @param {string} [opts.description] - 分类描述信息 optional + * @param {string} callback - callback + @return {Object} result + * @param categoryObject resultObject + */ + + createCategory (opts, callback) { + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createCategory" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.parentId !== undefined && opts.parentId !== null) { + postBody['parentId'] = opts.parentId + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 createCategory 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( + '/categories', + '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 {boolean} [opts.flatMode] - 是否返回平坦结构结果,默认为false(flatMode和treeMode不能同时为false) optional + * @param {boolean} [opts.treeMode] - 是否返回树结构结果,默认为false(flatMode和treeMode不能同时为false) optional + * @param {string} callback - callback + @return {Object} result + * @param listAllCategoriesResultObject resultObject + */ + + listAllCategories (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.flatMode !== undefined && opts.flatMode !== null) { + queryParams['flatMode'] = opts.flatMode + } + if (opts.treeMode !== undefined && opts.treeMode !== null) { + queryParams['treeMode'] = opts.treeMode + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 listAllCategories 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( + '/categories:listAll', + '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) + } + ) + } + + /** + * 查询分类及其子分类,若指定的分类ID为0,则返回一个根分类及其子分类(即一级分类). + * @param {Object} opts - parameters + * @param {integer} opts.categoryId - 分类ID + * @param {string} callback - callback + @return {Object} result + * @param getCategoryWithChildrenResultObject resultObject + */ + + getCategoryWithChildren (opts, callback) { + opts = opts || {} + + if (opts.categoryId === undefined || opts.categoryId === null) { + throw new Error( + "Missing the required parameter 'opts.categoryId' when calling getCategoryWithChildren" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + categoryId: opts.categoryId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 getCategoryWithChildren 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( + '/categories/{categoryId}:getWithChildren', + '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.categoryId - 分类ID + * @param {string} callback - callback + @return {Object} result + * @param categoryObject resultObject + */ + + getCategory (opts, callback) { + opts = opts || {} + + if (opts.categoryId === undefined || opts.categoryId === null) { + throw new Error( + "Missing the required parameter 'opts.categoryId' when calling getCategory" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + categoryId: opts.categoryId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 getCategory 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( + '/categories/{categoryId}', + '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.categoryId - 分类ID + * @param {string} [opts.name] - 分类名称 optional + * @param {integer} [opts.parentId] - 父分类ID,取值为 0 或 null 时,表示该分类为一级分类 + optional + * @param {string} [opts.description] - 分类描述信息 optional + * @param {string} callback - callback + @return {Object} result + * @param categoryObject resultObject + */ + + updateCategory (opts, callback) { + opts = opts || {} + + if (opts.categoryId === undefined || opts.categoryId === null) { + throw new Error( + "Missing the required parameter 'opts.categoryId' when calling updateCategory" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.parentId !== undefined && opts.parentId !== null) { + postBody['parentId'] = opts.parentId + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + categoryId: opts.categoryId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 updateCategory 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( + '/categories/{categoryId}', + '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) + } + ) + } + + /** + * 删除分类 + * @param {Object} opts - parameters + * @param {integer} opts.categoryId - 分类ID + * @param {string} callback - callback + @return {Object} result + */ + + deleteCategory (opts, callback) { + opts = opts || {} + + if (opts.categoryId === undefined || opts.categoryId === null) { + throw new Error( + "Missing the required parameter 'opts.categoryId' when calling deleteCategory" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + categoryId: opts.categoryId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 deleteCategory 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( + '/categories/{categoryId}', + '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 optional + * @param {integer} [opts.pageSize] - 分页大小;默认值为 10;取值范围 [10, 100] optional + * @param {sort} [opts.sorts] optional + * @param {string} callback - callback + @return {Object} result + * @param listDomainsResultObject resultObject + */ + + listDomains (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.buildSortParam(opts.sorts, 'sorts')) + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 listDomains 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( + '/domains', + '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.name - 域名名称 + * @param {string} callback - callback + @return {Object} result + * @param domainObject resultObject + */ + + createDomain (opts, callback) { + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createDomain" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 createDomain 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( + '/domains', + '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.domainId - 域名ID + * @param {string} callback - callback + @return {Object} result + * @param domainObject resultObject + */ + + getDomain (opts, callback) { + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling getDomain" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 getDomain 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( + '/domains/{domainId}', + '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.domainId - 域名ID + * @param {string} callback - callback + @return {Object} result + */ + + deleteDomain (opts, callback) { + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling deleteDomain" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 deleteDomain 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( + '/domains/{domainId}', + '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.domainId - 域名ID + * @param {string} callback - callback + @return {Object} result + */ + + enableDomain (opts, callback) { + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling enableDomain" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 enableDomain 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( + '/domains/{domainId}:enable', + '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.domainId - 域名ID + * @param {string} callback - callback + @return {Object} result + */ + + disableDomain (opts, callback) { + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling disableDomain" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 disableDomain 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( + '/domains/{domainId}:disable', + '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.domainId - 域名ID + * @param {string} callback - callback + @return {Object} result + */ + + setDefaultDomain (opts, callback) { + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling setDefaultDomain" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 setDefaultDomain 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( + '/domains/{domainId}:setDefault', + '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.domainId - 域名ID + * @param {string} opts.headerName - 头参数名。当前支持的访问头参数取值范围: + Content-Disposition + Content-Language + Expires + Access-Control-Allow-Origin + Access-Control-Allow-Methods + Access-Control-Max-Age + Access-Control-Expose-Headers + + * @param {string} opts.headerValue - 头参数值 + * @param {string} opts.headerType - 头参数类型,取值范围:req、resp + * @param {string} callback - callback + @return {Object} result + */ + + setHeader (opts, callback) { + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling setHeader" + ) + } + if (opts.headerName === undefined || opts.headerName === null) { + throw new Error( + "Missing the required parameter 'opts.headerName' when calling setHeader" + ) + } + if (opts.headerValue === undefined || opts.headerValue === null) { + throw new Error( + "Missing the required parameter 'opts.headerValue' when calling setHeader" + ) + } + if (opts.headerType === undefined || opts.headerType === null) { + throw new Error( + "Missing the required parameter 'opts.headerType' when calling setHeader" + ) + } + + let postBody = {} + if (opts.headerName !== undefined && opts.headerName !== null) { + postBody['headerName'] = opts.headerName + } + if (opts.headerValue !== undefined && opts.headerValue !== null) { + postBody['headerValue'] = opts.headerValue + } + if (opts.headerType !== undefined && opts.headerType !== null) { + postBody['headerType'] = opts.headerType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 setHeader 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( + '/domains/{domainId}:setHeader', + '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.domainId - 域名ID + * @param {string} callback - callback + @return {Object} result + * @param listHeadersResultObject resultObject + */ + + listHeaders (opts, callback) { + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling listHeaders" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 listHeaders 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( + '/domains/{domainId}:listHeaders', + '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.domainId - 域名ID + * @param {string} opts.headerName - 头参数名。当前支持的访问头参数取值范围: + Content-Disposition + Content-Language + Expires + Access-Control-Allow-Origin + Access-Control-Allow-Methods + Access-Control-Max-Age + Access-Control-Expose-Headers + + * @param {string} opts.headerType - 头参数类型,取值范围:req、resp + * @param {string} callback - callback + @return {Object} result + */ + + deleteHeader (opts, callback) { + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling deleteHeader" + ) + } + if (opts.headerName === undefined || opts.headerName === null) { + throw new Error( + "Missing the required parameter 'opts.headerName' when calling deleteHeader" + ) + } + if (opts.headerType === undefined || opts.headerType === null) { + throw new Error( + "Missing the required parameter 'opts.headerType' when calling deleteHeader" + ) + } + + let postBody = {} + if (opts.headerName !== undefined && opts.headerName !== null) { + postBody['headerName'] = opts.headerName + } + if (opts.headerType !== undefined && opts.headerType !== null) { + postBody['headerType'] = opts.headerType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 deleteHeader 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( + '/domains/{domainId}:deleteHeader', + '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) + } + ) + } + + /** + * 设置CDN域名Referer防盗链规则 + * @param {Object} opts - parameters + * @param {integer} opts.domainId - 域名ID + * @param {refererRuleConfigObject} opts.config - Referer防盗链规则配置对象 + * @param {boolean} opts.enabled - 是否启用该规则 + * @param {string} callback - callback + @return {Object} result + */ + + setRefererRule (opts, callback) { + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling setRefererRule" + ) + } + if (opts.config === undefined || opts.config === null) { + throw new Error( + "Missing the required parameter 'opts.config' when calling setRefererRule" + ) + } + if (opts.enabled === undefined || opts.enabled === null) { + throw new Error( + "Missing the required parameter 'opts.enabled' when calling setRefererRule" + ) + } + + let postBody = {} + if (opts.config !== undefined && opts.config !== null) { + postBody['config'] = opts.config + } + if (opts.enabled !== undefined && opts.enabled !== null) { + postBody['enabled'] = opts.enabled + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 setRefererRule 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( + '/domains/{domainId}:setRefererRule', + '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) + } + ) + } + + /** + * 查询CDN域名Referer防盗链规则配置 + * @param {Object} opts - parameters + * @param {integer} opts.domainId - 域名ID + * @param {string} callback - callback + @return {Object} result + * @param getRefererRuleResultObject resultObject + */ + + getRefererRule (opts, callback) { + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling getRefererRule" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 getRefererRule 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( + '/domains/{domainId}:getRefererRule', + '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) + } + ) + } + + /** + * 设置CDN域名URL鉴权规则 + * @param {Object} opts - parameters + * @param {integer} opts.domainId - 域名ID + * @param {uRLRuleConfigObject} opts.config - URL鉴权规则配置对象 + * @param {boolean} opts.enabled - 是否启用该规则 + * @param {string} callback - callback + @return {Object} result + */ + + setURLRule (opts, callback) { + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling setURLRule" + ) + } + if (opts.config === undefined || opts.config === null) { + throw new Error( + "Missing the required parameter 'opts.config' when calling setURLRule" + ) + } + if (opts.enabled === undefined || opts.enabled === null) { + throw new Error( + "Missing the required parameter 'opts.enabled' when calling setURLRule" + ) + } + + let postBody = {} + if (opts.config !== undefined && opts.config !== null) { + postBody['config'] = opts.config + } + if (opts.enabled !== undefined && opts.enabled !== null) { + postBody['enabled'] = opts.enabled + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 setURLRule 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( + '/domains/{domainId}:setURLRule', + '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) + } + ) + } + + /** + * 查询CDN域名URL鉴权规则配置 + * @param {Object} opts - parameters + * @param {integer} opts.domainId - 域名ID + * @param {string} callback - callback + @return {Object} result + * @param getURLRuleResultObject resultObject + */ + + getURLRule (opts, callback) { + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling getURLRule" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 getURLRule 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( + '/domains/{domainId}:getURLRule', + '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) + } + ) + } + + /** + * 设置CDN域名IP黑名单规则 + * @param {Object} opts - parameters + * @param {integer} opts.domainId - 域名ID + * @param {iPRuleConfigObject} opts.config - IP黑名单规则配置对象 + * @param {boolean} opts.enabled - 是否启用该规则 + * @param {string} callback - callback + @return {Object} result + */ + + setIPRule (opts, callback) { + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling setIPRule" + ) + } + if (opts.config === undefined || opts.config === null) { + throw new Error( + "Missing the required parameter 'opts.config' when calling setIPRule" + ) + } + if (opts.enabled === undefined || opts.enabled === null) { + throw new Error( + "Missing the required parameter 'opts.enabled' when calling setIPRule" + ) + } + + let postBody = {} + if (opts.config !== undefined && opts.config !== null) { + postBody['config'] = opts.config + } + if (opts.enabled !== undefined && opts.enabled !== null) { + postBody['enabled'] = opts.enabled + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 setIPRule 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( + '/domains/{domainId}:setIPRule', + '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) + } + ) + } + + /** + * 查询CDN域名IP黑名单规则配置 + * @param {Object} opts - parameters + * @param {integer} opts.domainId - 域名ID + * @param {string} callback - callback + @return {Object} result + * @param getIPRuleResultObject resultObject + */ + + getIPRule (opts, callback) { + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling getIPRule" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 getIPRule 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( + '/domains/{domainId}:getIPRule', + '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) + } + ) + } + + /** + * 设置CDN域名SSL配置 + * @param {Object} opts - parameters + * @param {integer} opts.domainId - 域名ID + * @param {string} [opts.source] - 证书来源。取值范围:default optional + * @param {string} [opts.title] - 证书标题 optional + * @param {string} [opts.sslCert] - 证书内容 optional + * @param {string} [opts.sslKey] - 证书私钥 optional + * @param {string} [opts.jumpType] - 跳转类型。取值范围: +default - 采用回源域名的默认协议 +http - 强制采用http协议回源 +https - 强制采用https协议回源 + optional + * @param {boolean} [opts.enabled] - SSL配置启用状态 optional + * @param {string} callback - callback + @return {Object} result + */ + + setHttpSsl (opts, callback) { + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling setHttpSsl" + ) + } + + let postBody = {} + if (opts.source !== undefined && opts.source !== null) { + postBody['source'] = opts.source + } + if (opts.title !== undefined && opts.title !== null) { + postBody['title'] = opts.title + } + if (opts.sslCert !== undefined && opts.sslCert !== null) { + postBody['sslCert'] = opts.sslCert + } + if (opts.sslKey !== undefined && opts.sslKey !== null) { + postBody['sslKey'] = opts.sslKey + } + if (opts.jumpType !== undefined && opts.jumpType !== null) { + postBody['jumpType'] = opts.jumpType + } + if (opts.enabled !== undefined && opts.enabled !== null) { + postBody['enabled'] = opts.enabled + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 setHttpSsl 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( + '/domains/{domainId}:setHttpSsl', + '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) + } + ) + } + + /** + * 查询CDN域名SSL配置 + * @param {Object} opts - parameters + * @param {integer} opts.domainId - 域名ID + * @param {string} callback - callback + @return {Object} result + * @param getHttpSslResultObject resultObject + */ + + getHttpSsl (opts, callback) { + opts = opts || {} + + if (opts.domainId === undefined || opts.domainId === null) { + throw new Error( + "Missing the required parameter 'opts.domainId' when calling getHttpSsl" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + domainId: opts.domainId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 getHttpSsl 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( + '/domains/{domainId}:getHttpSsl', + '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.title - 视频标题 + * @param {string} opts.fileName - 文件名称 + * @param {integer} [opts.fileSize] - 文件大小 optional + * @param {string} [opts.coverUrl] - 封面地址 optional + * @param {string} [opts.description] - 视频描述 optional + * @param {integer} [opts.categoryId] - 分类ID optional + * @param {array} [opts.tags] - 视频标签集合 optional + * @param {string} [opts.transcodeTemplateGroupId] - 转码模板组ID。若此字段不为空,则将以模板组方式提交转码作业,transcodeTemplateIds字段将被忽略。 optional + * @param {array} [opts.transcodeTemplateIds] - 转码模板ID集合 optional + * @param {array} [opts.watermarkIds] - 水印ID集合 optional + * @param {string} opts.publishDomain - 推流域名 + * @param {string} opts.appName - 应用名称 + * @param {string} opts.streamName - 流名称 + * @param {array} [opts.recordTimes] - 录制时间段集合 +- 支持自定义1-10个时间段,拼接成一个文件 +- 每个时间段不小于10s +- 总跨度不超过12小时 +- 时间段按升序排列且无重叠 + optional + * @param {string} opts.recordFileType - 录制文件类型: +- 取值: ts, flv, mp4 +- 不区分大小写 + + * @param {string} [opts.taskExternalId] - 直播录制任务外键 optional + * @param {string} [opts.priority] - 任务优先级: +- 取值: low, medium, high +- 不区分大小写 + optional + * @param {string} callback - callback + @return {Object} result + * @param string flowId 业务流ID + */ + + createLiveToVodTask (opts, callback) { + opts = opts || {} + + if (opts.title === undefined || opts.title === null) { + throw new Error( + "Missing the required parameter 'opts.title' when calling createLiveToVodTask" + ) + } + if (opts.fileName === undefined || opts.fileName === null) { + throw new Error( + "Missing the required parameter 'opts.fileName' when calling createLiveToVodTask" + ) + } + if (opts.publishDomain === undefined || opts.publishDomain === null) { + throw new Error( + "Missing the required parameter 'opts.publishDomain' when calling createLiveToVodTask" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling createLiveToVodTask" + ) + } + if (opts.streamName === undefined || opts.streamName === null) { + throw new Error( + "Missing the required parameter 'opts.streamName' when calling createLiveToVodTask" + ) + } + if (opts.recordFileType === undefined || opts.recordFileType === null) { + throw new Error( + "Missing the required parameter 'opts.recordFileType' when calling createLiveToVodTask" + ) + } + + let postBody = {} + if (opts.title !== undefined && opts.title !== null) { + postBody['title'] = opts.title + } + if (opts.fileName !== undefined && opts.fileName !== null) { + postBody['fileName'] = opts.fileName + } + if (opts.fileSize !== undefined && opts.fileSize !== null) { + postBody['fileSize'] = opts.fileSize + } + if (opts.coverUrl !== undefined && opts.coverUrl !== null) { + postBody['coverUrl'] = opts.coverUrl + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.categoryId !== undefined && opts.categoryId !== null) { + postBody['categoryId'] = opts.categoryId + } + if (opts.tags !== undefined && opts.tags !== null) { + postBody['tags'] = opts.tags + } + if ( + opts.transcodeTemplateGroupId !== undefined && + opts.transcodeTemplateGroupId !== null + ) { + postBody['transcodeTemplateGroupId'] = opts.transcodeTemplateGroupId + } + if ( + opts.transcodeTemplateIds !== undefined && + opts.transcodeTemplateIds !== null + ) { + postBody['transcodeTemplateIds'] = opts.transcodeTemplateIds + } + if (opts.watermarkIds !== undefined && opts.watermarkIds !== null) { + postBody['watermarkIds'] = opts.watermarkIds + } + if (opts.publishDomain !== undefined && opts.publishDomain !== null) { + postBody['publishDomain'] = opts.publishDomain + } + if (opts.appName !== undefined && opts.appName !== null) { + postBody['appName'] = opts.appName + } + if (opts.streamName !== undefined && opts.streamName !== null) { + postBody['streamName'] = opts.streamName + } + if (opts.recordTimes !== undefined && opts.recordTimes !== null) { + postBody['recordTimes'] = opts.recordTimes + } + if (opts.recordFileType !== undefined && opts.recordFileType !== null) { + postBody['recordFileType'] = opts.recordFileType + } + if (opts.taskExternalId !== undefined && opts.taskExternalId !== null) { + postBody['taskExternalId'] = opts.taskExternalId + } + if (opts.priority !== undefined && opts.priority !== null) { + postBody['priority'] = opts.priority + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 createLiveToVodTask 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( + '/createLiveToVodTask', + '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.httpMethod] - HTTP 请求方法,上传支持 PUT 和 POST 方法,默认值为 PUT 。 +通过该接口获取到上传地址和凭证之后,后续的上传动作,必须使用和该值一致的方法进行文件上传。 + optional + * @param {string} opts.title - 视频标题 + * @param {string} opts.fileName - 文件名称 + * @param {integer} [opts.fileSize] - 文件大小 optional + * @param {string} [opts.coverUrl] - 封面地址 optional + * @param {string} [opts.description] - 视频描述 optional + * @param {integer} [opts.categoryId] - 分类ID optional + * @param {array} [opts.tags] - 视频标签集合 optional + * @param {string} [opts.transcodeTemplateGroupId] - 转码模板组ID optional + * @param {array} [opts.transcodeTemplateIds] - 转码模板ID集合 optional + * @param {array} [opts.watermarkIds] - 水印ID集合 optional + * @param {string} [opts.userData] - 自定义数据 optional + * @param {string} callback - callback + @return {Object} result + * @param videoUploadTaskObject resultObject + */ + + createVideoUploadTask (opts, callback) { + opts = opts || {} + + if (opts.title === undefined || opts.title === null) { + throw new Error( + "Missing the required parameter 'opts.title' when calling createVideoUploadTask" + ) + } + if (opts.fileName === undefined || opts.fileName === null) { + throw new Error( + "Missing the required parameter 'opts.fileName' when calling createVideoUploadTask" + ) + } + + let postBody = {} + if (opts.httpMethod !== undefined && opts.httpMethod !== null) { + postBody['httpMethod'] = opts.httpMethod + } + if (opts.title !== undefined && opts.title !== null) { + postBody['title'] = opts.title + } + if (opts.fileName !== undefined && opts.fileName !== null) { + postBody['fileName'] = opts.fileName + } + if (opts.fileSize !== undefined && opts.fileSize !== null) { + postBody['fileSize'] = opts.fileSize + } + if (opts.coverUrl !== undefined && opts.coverUrl !== null) { + postBody['coverUrl'] = opts.coverUrl + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.categoryId !== undefined && opts.categoryId !== null) { + postBody['categoryId'] = opts.categoryId + } + if (opts.tags !== undefined && opts.tags !== null) { + postBody['tags'] = opts.tags + } + if ( + opts.transcodeTemplateGroupId !== undefined && + opts.transcodeTemplateGroupId !== null + ) { + postBody['transcodeTemplateGroupId'] = opts.transcodeTemplateGroupId + } + if ( + opts.transcodeTemplateIds !== undefined && + opts.transcodeTemplateIds !== null + ) { + postBody['transcodeTemplateIds'] = opts.transcodeTemplateIds + } + if (opts.watermarkIds !== undefined && opts.watermarkIds !== null) { + postBody['watermarkIds'] = opts.watermarkIds + } + if (opts.userData !== undefined && opts.userData !== null) { + postBody['userData'] = opts.userData + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 createVideoUploadTask 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( + '/videoUploadTask', + '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.videoId - 视频地址 + * @param {string} callback - callback + @return {Object} result + * @param videoUploadTaskObject resultObject + */ + + refreshVideoUploadTask (opts, callback) { + opts = opts || {} + + if (opts.videoId === undefined || opts.videoId === null) { + throw new Error( + "Missing the required parameter 'opts.videoId' when calling refreshVideoUploadTask" + ) + } + + let postBody = null + let queryParams = {} + if (opts.videoId !== undefined && opts.videoId !== null) { + queryParams['videoId'] = opts.videoId + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 refreshVideoUploadTask 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( + '/videoUploadTask:refresh', + '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.httpMethod] - HTTP 请求方法,上传支持 PUT 和 POST 方法,默认值为 PUT 。 optional + * @param {string} opts.fileName - 文件名称 + * @param {integer} [opts.fileSize] - 文件大小 optional + * @param {string} callback - callback + @return {Object} result + * @param imageUploadTaskObject resultObject + */ + + createImageUploadTask (opts, callback) { + opts = opts || {} + + if (opts.fileName === undefined || opts.fileName === null) { + throw new Error( + "Missing the required parameter 'opts.fileName' when calling createImageUploadTask" + ) + } + + let postBody = {} + if (opts.httpMethod !== undefined && opts.httpMethod !== null) { + postBody['httpMethod'] = opts.httpMethod + } + if (opts.fileName !== undefined && opts.fileName !== null) { + postBody['fileName'] = opts.fileName + } + if (opts.fileSize !== undefined && opts.fileSize !== null) { + postBody['fileSize'] = opts.fileSize + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 createImageUploadTask 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( + '/imageUploadTask', + '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.mediaId] - 媒资ID optional + * @param {array} [opts.templateIds] - 质检模板ID列表 optional + * @param {string} callback - callback + @return {Object} result + */ + + submitQualityDetectionJob (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.mediaId !== undefined && opts.mediaId !== null) { + postBody['mediaId'] = opts.mediaId + } + if (opts.templateIds !== undefined && opts.templateIds !== null) { + postBody['templateIds'] = opts.templateIds + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 submitQualityDetectionJob 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( + '/qualityDetectionJobs:submit', + '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 {array} [opts.bulkItems] optional + * @param {string} callback - callback + @return {Object} result + */ + + batchSubmitQualityDetectionJobs (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.bulkItems !== undefined && opts.bulkItems !== null) { + postBody['bulkItems'] = opts.bulkItems + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 batchSubmitQualityDetectionJobs 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( + '/qualityDetectionJobs:batchSubmit', + '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.pageNumber] - 页码;默认值为 1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认值为 10;取值范围 [10, 100] optional + * @param {string} callback - callback + @return {Object} result + * @param listQualityDetectionTemplatesResultObject resultObject + */ + + listQualityDetectionTemplates (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 + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 listQualityDetectionTemplates 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( + '/qualityDetectionTemplates', + '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.name - 模板名称。长度不超过128个字符。UTF-8编码。 + + * @param {string} opts.templateType - 模板类型,区分该模板的检测内容。目前只支持 video 。 + * @param {array} [opts.detections] - 检测项列表。取值范围: + blackScreen - 黑场 + pureColor - 纯色 + colorCast - 偏色 + frozenFrame - 静帧 + brightness - 亮度 + contrast - 对比度 + optional + * @param {string} callback - callback + @return {Object} result + * @param qualityDetectionTemplateObject resultObject + */ + + createQualityDetectionTemplate (opts, callback) { + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createQualityDetectionTemplate" + ) + } + if (opts.templateType === undefined || opts.templateType === null) { + throw new Error( + "Missing the required parameter 'opts.templateType' when calling createQualityDetectionTemplate" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.templateType !== undefined && opts.templateType !== null) { + postBody['templateType'] = opts.templateType + } + if (opts.detections !== undefined && opts.detections !== null) { + postBody['detections'] = opts.detections + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 createQualityDetectionTemplate 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( + '/qualityDetectionTemplates', + '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.templateId - 模板ID + * @param {string} callback - callback + @return {Object} result + * @param qualityDetectionTemplateObject resultObject + */ + + getQualityDetectionTemplate (opts, callback) { + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling getQualityDetectionTemplate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 getQualityDetectionTemplate 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( + '/qualityDetectionTemplates/{templateId}', + '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.templateId - 模板ID + * @param {string} [opts.name] - 模板名称。长度不超过128个字符。UTF-8编码。 + optional + * @param {array} [opts.detections] - 检测项列表。取值范围: + blackScreen - 黑场 + pureColor - 纯色 + colorCast - 偏色 + frozenFrame - 静帧 + brightness - 亮度 + contrast - 对比度 + optional + * @param {string} callback - callback + @return {Object} result + * @param qualityDetectionTemplateObject resultObject + */ + + updateQualityDetectionTemplate (opts, callback) { + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling updateQualityDetectionTemplate" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.detections !== undefined && opts.detections !== null) { + postBody['detections'] = opts.detections + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 updateQualityDetectionTemplate 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( + '/qualityDetectionTemplates/{templateId}', + '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) + } + ) + } + + /** + * 删除质检模板 + * @param {Object} opts - parameters + * @param {integer} opts.templateId - 模板ID + * @param {string} callback - callback + @return {Object} result + */ + + deleteQualityDetectionTemplate (opts, callback) { + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling deleteQualityDetectionTemplate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 deleteQualityDetectionTemplate 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( + '/qualityDetectionTemplates/{templateId}', + '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 {array} [opts.videoIds] - 视频ID列表 optional + * @param {array} [opts.templateIds] - 转码模板ID列表 optional + * @param {string} callback - callback + @return {Object} result + * @param submitSnapshotJobsResult resultObject + */ + + submitSnapshotTask (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.videoIds !== undefined && opts.videoIds !== null) { + postBody['videoIds'] = opts.videoIds + } + if (opts.templateIds !== undefined && opts.templateIds !== null) { + postBody['templateIds'] = opts.templateIds + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 submitSnapshotTask 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( + '/snapshotJobs:submit', + '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) + } + ) + } + + /** + * 查询视频截图任务列表 +支持过滤查询: + - createTime,ge 最早任务创建时间 + - createTime,le 最晚任务创建时间 + - status,in 任务状态IN查询 + - taskId,eq 任务ID精确查询 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认值为 1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认值为 10;取值范围 [10, 100] optional + * @param {filter} [opts.filters] optional + * @param {string} callback - callback + @return {Object} result + * @param snapshotTaskSummaryPageInfo resultObject + */ + + listSnapshotTasks (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 vod/1.2.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 listSnapshotTasks 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( + '/snapshotTasks', + '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) + } + ) + } + + /** + * 查询截图模板列表。 +允许通过条件过滤查询,支持的过滤字段如下: + - snapshotType[eq] 按模板类型精确查询 + - templateId[eq] 按模板ID精确查询 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认值为 1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认值为 10;取值范围 [10, 100] optional + * @param {filter} [opts.filters] optional + * @param {string} callback - callback + @return {Object} result + * @param snapshotTemplatePageInfo resultObject + */ + + listSnapshotTemplates (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 vod/1.2.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 listSnapshotTemplates 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( + '/snapshotTemplates', + '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.templateName - 模板标题。长度不超过 128 个字节。UTF-8 编码。 + * @param {string} [opts.snapshotType] - 模板类型。取值范围: + sample - 采样截图模板 + sprite - 雪碧图模板 + optional + * @param {imageSampleConfig} [opts.imageSampleConfig] - 采样截图模板配置 optional + * @param {imageSpriteConfig} [opts.imageSpriteConfig] - 雪碧图模板配置 optional + * @param {string} callback - callback + @return {Object} result + * @param snapshotTemplateInfo resultObject + */ + + createSnapshotTemplate (opts, callback) { + opts = opts || {} + + if (opts.templateName === undefined || opts.templateName === null) { + throw new Error( + "Missing the required parameter 'opts.templateName' when calling createSnapshotTemplate" + ) + } + + let postBody = {} + if (opts.templateName !== undefined && opts.templateName !== null) { + postBody['templateName'] = opts.templateName + } + if (opts.snapshotType !== undefined && opts.snapshotType !== null) { + postBody['snapshotType'] = opts.snapshotType + } + if ( + opts.imageSampleConfig !== undefined && + opts.imageSampleConfig !== null + ) { + postBody['imageSampleConfig'] = opts.imageSampleConfig + } + if ( + opts.imageSpriteConfig !== undefined && + opts.imageSpriteConfig !== null + ) { + postBody['imageSpriteConfig'] = opts.imageSpriteConfig + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 createSnapshotTemplate 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( + '/snapshotTemplates', + '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.templateId - 模板ID + * @param {string} callback - callback + @return {Object} result + * @param snapshotTemplateInfo resultObject + */ + + getSnapshotTemplate (opts, callback) { + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling getSnapshotTemplate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 getSnapshotTemplate 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( + '/snapshotTemplates/{templateId}', + '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.templateId - 模板ID + * @param {string} [opts.templateName] - 模板标题。长度不超过 128 个字节。UTF-8 编码。 optional + * @param {string} [opts.snapshotType] - 模板类型。取值范围: + sample - 采样截图模板 + sprite - 雪碧图模板 + optional + * @param {imageSampleConfig} [opts.imageSampleConfig] - 采样截图模板配置 optional + * @param {imageSpriteConfig} [opts.imageSpriteConfig] - 雪碧图模板配置 optional + * @param {string} callback - callback + @return {Object} result + * @param snapshotTemplateInfo resultObject + */ + + updateSnapshotTemplate (opts, callback) { + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling updateSnapshotTemplate" + ) + } + + let postBody = {} + if (opts.templateName !== undefined && opts.templateName !== null) { + postBody['templateName'] = opts.templateName + } + if (opts.snapshotType !== undefined && opts.snapshotType !== null) { + postBody['snapshotType'] = opts.snapshotType + } + if ( + opts.imageSampleConfig !== undefined && + opts.imageSampleConfig !== null + ) { + postBody['imageSampleConfig'] = opts.imageSampleConfig + } + if ( + opts.imageSpriteConfig !== undefined && + opts.imageSpriteConfig !== null + ) { + postBody['imageSpriteConfig'] = opts.imageSpriteConfig + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 updateSnapshotTemplate 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( + '/snapshotTemplates/{templateId}', + '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) + } + ) + } + + /** + * 删除截图模板 + * @param {Object} opts - parameters + * @param {string} opts.templateId - 模板ID + * @param {string} callback - callback + @return {Object} result + */ + + deleteSnapshotTemplate (opts, callback) { + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling deleteSnapshotTemplate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 deleteSnapshotTemplate 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( + '/snapshotTemplates/{templateId}', + '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.videoId] - 视频ID optional + * @param {string} [opts.templateGroupId] - 转码模板组ID。若此字段不为空,则以模板组方式提交作业,templateIds字段将被忽略。 optional + * @param {array} [opts.templateIds] - 转码模板ID列表 optional + * @param {array} [opts.watermarkIds] - 水印ID列表 optional + * @param {string} callback - callback + @return {Object} result + * @param submitTranscodeJobResultObject resultObject + */ + + submitTranscodeJob (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.videoId !== undefined && opts.videoId !== null) { + postBody['videoId'] = opts.videoId + } + if (opts.templateGroupId !== undefined && opts.templateGroupId !== null) { + postBody['templateGroupId'] = opts.templateGroupId + } + if (opts.templateIds !== undefined && opts.templateIds !== null) { + postBody['templateIds'] = opts.templateIds + } + if (opts.watermarkIds !== undefined && opts.watermarkIds !== null) { + postBody['watermarkIds'] = opts.watermarkIds + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 submitTranscodeJob 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( + '/transcodeTasks:submitJob', + '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 {array} [opts.bulkItems] optional + * @param {string} callback - callback + @return {Object} result + * @param batchSubmitTranscodeJobsResultObject resultObject + */ + + batchSubmitTranscodeJobs (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.bulkItems !== undefined && opts.bulkItems !== null) { + postBody['bulkItems'] = opts.bulkItems + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 batchSubmitTranscodeJobs 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( + '/transcodeTasks:batchSubmitJobs', + '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.videoIds] optional + * @param {string} callback - callback + @return {Object} result + * @param transcodeSummaries resultObject + */ + + getTranscodeSummaries (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + Object.assign(queryParams, super.buildArrayParam(opts.videoIds, 'videoIds')) + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 getTranscodeSummaries 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( + '/transcode:summary', + '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.jobIds] optional + * @param {string} callback - callback + @return {Object} result + * @param transcodeJobSummaries resultObject + */ + + getTranscodeJobSummaries (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + Object.assign(queryParams, super.buildArrayParam(opts.jobIds, 'jobIds')) + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 getTranscodeJobSummaries 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( + '/transcodeJobs:summary', + '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.taskIds] optional + * @param {string} callback - callback + @return {Object} result + * @param transcodeTaskSummaries resultObject + */ + + getTranscodeTaskSummaries (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + Object.assign(queryParams, super.buildArrayParam(opts.taskIds, 'taskIds')) + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 getTranscodeTaskSummaries 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( + '/transcodeTasks:summary', + '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.videoId] - 视频ID optional + * @param {array} [opts.templateIds] - 转码模板ID列表 optional + * @param {array} [opts.watermarkIds] - 水印ID列表 optional + * @param {string} callback - callback + @return {Object} result + * @param submitTranscodeJobResultObject resultObject + */ + + submitTranscodeJob (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.videoId !== undefined && opts.videoId !== null) { + postBody['videoId'] = opts.videoId + } + if (opts.templateIds !== undefined && opts.templateIds !== null) { + postBody['templateIds'] = opts.templateIds + } + if (opts.watermarkIds !== undefined && opts.watermarkIds !== null) { + postBody['watermarkIds'] = opts.watermarkIds + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 submitTranscodeJob 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( + '/transcodeTasks:submitJob', + '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 {array} [opts.bulkItems] optional + * @param {string} callback - callback + @return {Object} result + * @param batchSubmitTranscodeJobsResultObject resultObject + */ + + batchSubmitTranscodeJobs (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.bulkItems !== undefined && opts.bulkItems !== null) { + postBody['bulkItems'] = opts.bulkItems + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 batchSubmitTranscodeJobs 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( + '/transcodeTasks:batchSubmitJobs', + '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) + } + ) + } + + /** + * 查询转码模板列表。 +允许通过条件过滤查询,支持的过滤字段如下: + - source[eq] 按模板来源精确查询 + - templateType[eq] 按模板类型精确查询 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认值为 1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认值为 10;取值范围 [10, 100] optional + * @param {filter} [opts.filters] optional + * @param {string} callback - callback + @return {Object} result + * @param listTranscodeTemplatesResultObject resultObject + */ + + listTranscodeTemplates (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 vod/1.2.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 listTranscodeTemplates 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( + '/transcodeTemplates', + '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.name - 模板名称。长度不超过128个字符。UTF-8编码。 + + * @param {video} opts.video - 视频参数配置 + * @param {audio} opts.audio - 音频参数配置 + * @param {encapsulation} opts.encapsulation - 封装配置 + * @param {outFile} [opts.outFile] - 输出文件配置 optional + * @param {string} opts.definition - 清晰度规格标记。取值范围: + SD - 标清 + HD - 高清 + FHD - 超清 + 2K + 4K + + * @param {string} [opts.templateType] - 模板类型。取值范围: + jdchd - 京享超清 + jdchs - 极速转码 + optional + * @param {string} callback - callback + @return {Object} result + * @param transcodeTemplateObject resultObject + */ + + createTranscodeTemplate (opts, callback) { + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createTranscodeTemplate" + ) + } + if (opts.video === undefined || opts.video === null) { + throw new Error( + "Missing the required parameter 'opts.video' when calling createTranscodeTemplate" + ) + } + if (opts.audio === undefined || opts.audio === null) { + throw new Error( + "Missing the required parameter 'opts.audio' when calling createTranscodeTemplate" + ) + } + if (opts.encapsulation === undefined || opts.encapsulation === null) { + throw new Error( + "Missing the required parameter 'opts.encapsulation' when calling createTranscodeTemplate" + ) + } + if (opts.definition === undefined || opts.definition === null) { + throw new Error( + "Missing the required parameter 'opts.definition' when calling createTranscodeTemplate" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.video !== undefined && opts.video !== null) { + postBody['video'] = opts.video + } + if (opts.audio !== undefined && opts.audio !== null) { + postBody['audio'] = opts.audio + } + if (opts.encapsulation !== undefined && opts.encapsulation !== null) { + postBody['encapsulation'] = opts.encapsulation + } + if (opts.outFile !== undefined && opts.outFile !== null) { + postBody['outFile'] = opts.outFile + } + if (opts.definition !== undefined && opts.definition !== null) { + postBody['definition'] = opts.definition + } + if (opts.templateType !== undefined && opts.templateType !== null) { + postBody['templateType'] = opts.templateType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 createTranscodeTemplate 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( + '/transcodeTemplates', + '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.templateId - 模板ID + * @param {string} callback - callback + @return {Object} result + * @param transcodeTemplateObject resultObject + */ + + getTranscodeTemplate (opts, callback) { + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling getTranscodeTemplate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 getTranscodeTemplate 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( + '/transcodeTemplates/{templateId}', + '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.templateId - 模板ID + * @param {string} [opts.name] - 模板名称。长度不超过128个字符。UTF-8编码。 + optional + * @param {video} [opts.video] - 视频参数配置 optional + * @param {audio} [opts.audio] - 音频参数配置 optional + * @param {encapsulation} [opts.encapsulation] - 封装配置 optional + * @param {outFile} [opts.outFile] - 输出文件配置 optional + * @param {string} [opts.definition] - 清晰度规格标记。取值范围: + SD - 标清 + HD - 高清 + FHD - 超清 + 2K + 4K + optional + * @param {string} [opts.templateType] - 模板类型。取值范围: + jdchd - 京享超清 + jdchs - 极速转码 + optional + * @param {string} callback - callback + @return {Object} result + * @param transcodeTemplateObject resultObject + */ + + updateTranscodeTemplate (opts, callback) { + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling updateTranscodeTemplate" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.video !== undefined && opts.video !== null) { + postBody['video'] = opts.video + } + if (opts.audio !== undefined && opts.audio !== null) { + postBody['audio'] = opts.audio + } + if (opts.encapsulation !== undefined && opts.encapsulation !== null) { + postBody['encapsulation'] = opts.encapsulation + } + if (opts.outFile !== undefined && opts.outFile !== null) { + postBody['outFile'] = opts.outFile + } + if (opts.definition !== undefined && opts.definition !== null) { + postBody['definition'] = opts.definition + } + if (opts.templateType !== undefined && opts.templateType !== null) { + postBody['templateType'] = opts.templateType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 updateTranscodeTemplate 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( + '/transcodeTemplates/{templateId}', + '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) + } + ) + } + + /** + * 删除转码模板 + * @param {Object} opts - parameters + * @param {integer} opts.templateId - 模板ID + * @param {string} callback - callback + @return {Object} result + */ + + deleteTranscodeTemplate (opts, callback) { + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling deleteTranscodeTemplate" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 deleteTranscodeTemplate 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( + '/transcodeTemplates/{templateId}', + '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 optional + * @param {integer} [opts.pageSize] - 分页大小;默认值为 10;取值范围 [10, 100] optional + * @param {filter} [opts.filters] optional + * @param {string} callback - callback + @return {Object} result + * @param transcodeTemplateGroupPageData resultObject + */ + + listTranscodeTemplateGroups (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 vod/1.2.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 listTranscodeTemplateGroups 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( + '/transcodeTemplateGroups', + '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.groupName] - 转码模板组名称 optional + * @param {array} [opts.templates] optional + * @param {string} callback - callback + @return {Object} result + * @param transcodeTemplateGroupData resultObject + */ + + createTranscodeTemplateGroup (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.groupName !== undefined && opts.groupName !== null) { + postBody['groupName'] = opts.groupName + } + if (opts.templates !== undefined && opts.templates !== null) { + postBody['templates'] = opts.templates + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 createTranscodeTemplateGroup 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( + '/transcodeTemplateGroups', + '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.groupId - 模板组ID + * @param {string} callback - callback + @return {Object} result + * @param transcodeTemplateGroupData resultObject + */ + + getTranscodeTemplateGroup (opts, callback) { + opts = opts || {} + + if (opts.groupId === undefined || opts.groupId === null) { + throw new Error( + "Missing the required parameter 'opts.groupId' when calling getTranscodeTemplateGroup" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + groupId: opts.groupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 getTranscodeTemplateGroup 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( + '/transcodeTemplateGroups/{groupId}', + '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.groupId - 模板组ID + * @param {string} [opts.groupName] - 转码模板组名称 optional + * @param {array} [opts.templates] optional + * @param {string} callback - callback + @return {Object} result + * @param transcodeTemplateGroupData resultObject + */ + + updateTranscodeTemplateGroup (opts, callback) { + opts = opts || {} + + if (opts.groupId === undefined || opts.groupId === null) { + throw new Error( + "Missing the required parameter 'opts.groupId' when calling updateTranscodeTemplateGroup" + ) + } + + let postBody = {} + if (opts.groupName !== undefined && opts.groupName !== null) { + postBody['groupName'] = opts.groupName + } + if (opts.templates !== undefined && opts.templates !== null) { + postBody['templates'] = opts.templates + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + groupId: opts.groupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 updateTranscodeTemplateGroup 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( + '/transcodeTemplateGroups/{groupId}', + '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) + } + ) + } + + /** + * 删除转码模板组 + * @param {Object} opts - parameters + * @param {string} opts.groupId - 模板组ID + * @param {string} callback - callback + @return {Object} result + */ + + deleteTranscodeTemplateGroup (opts, callback) { + opts = opts || {} + + if (opts.groupId === undefined || opts.groupId === null) { + throw new Error( + "Missing the required parameter 'opts.groupId' when calling deleteTranscodeTemplateGroup" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + groupId: opts.groupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 deleteTranscodeTemplateGroup 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( + '/transcodeTemplateGroups/{groupId}', + '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.groupId] - 模板组ID optional + * @param {integer} [opts.templateIds] - 待删除的模板ID列表 optional + * @param {string} callback - callback + @return {Object} result + * @param deleteGroupedTranscodeTemplatesResData resultObject + */ + + deleteGroupedTranscodeTemplates (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.groupId !== undefined && opts.groupId !== null) { + postBody['groupId'] = opts.groupId + } + if (opts.templateIds !== undefined && opts.templateIds !== null) { + postBody['templateIds'] = opts.templateIds + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 deleteGroupedTranscodeTemplates 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( + '/transcodeTemplateGroups:deleteGroupedTranscodeTemplates', + '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.projectName - 工程名称 + * @param {string} [opts.description] - 工程描述 optional + * @param {timeline} opts.timeline - 时间线信息 + * @param {mediaMetadata} [opts.mediaMetadata] - 剪辑合成媒资元数据 optional + * @param {string} [opts.userData] - 用户数据,JSON格式的字符串。 +在Timeline中的所有MediaClip中,若有2个或以上的不同MediaId,即素材片段来源于2个或以上不同视频,则在提交剪辑作业时,必须在UserData中指明合并后的视频画面的宽高。 +如 {\"extendData\": {\"width\": 720, \"height\": 500}},其中width和height必须为[16, 4096]之间的偶数 +videoMode 支持 normal 普通模式 screen_record 屏幕录制模式 两种模式,默认为 normal。 +如 "{\"extendData\":{\"videoMode\":\"screen_record\"}}" + optional + * @param {string} callback - callback + @return {Object} result + * @param submittedVeditJob resultObject + */ + + createVeditJob (opts, callback) { + opts = opts || {} + + if (opts.projectName === undefined || opts.projectName === null) { + throw new Error( + "Missing the required parameter 'opts.projectName' when calling createVeditJob" + ) + } + if (opts.timeline === undefined || opts.timeline === null) { + throw new Error( + "Missing the required parameter 'opts.timeline' when calling createVeditJob" + ) + } + + let postBody = {} + if (opts.projectName !== undefined && opts.projectName !== null) { + postBody['projectName'] = opts.projectName + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.timeline !== undefined && opts.timeline !== null) { + postBody['timeline'] = opts.timeline + } + if (opts.mediaMetadata !== undefined && opts.mediaMetadata !== null) { + postBody['mediaMetadata'] = opts.mediaMetadata + } + if (opts.userData !== undefined && opts.userData !== null) { + postBody['userData'] = opts.userData + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 createVeditJob 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( + '/veditJobs', + '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.projectId - 工程ID + * @param {mediaMetadata} [opts.mediaMetadata] - 合成媒资元数据 optional + * @param {string} [opts.userData] - 用户数据,JSON格式的字符串。 +在Timeline中的所有MediaClip中,若有2个或以上的不同MediaId,即素材片段来源于2个或以上不同视频,则在提交剪辑作业时,必须在UserData中指明合并后的视频画面的宽高。 +如 {\"extendData\": {\"width\": 720, \"height\": 500}},其中width和height必须为[16, 4096]之间的偶数 +videoMode 支持 normal 普通模式 screen_record 屏幕录制模式 两种模式,默认为 normal。 +如 "{\"extendData\":{\"videoMode\":\"screen_record\"}}" + optional + * @param {string} callback - callback + @return {Object} result + * @param submittedVeditJob resultObject + */ + + submitVeditJob (opts, callback) { + opts = opts || {} + + if (opts.projectId === undefined || opts.projectId === null) { + throw new Error( + "Missing the required parameter 'opts.projectId' when calling submitVeditJob" + ) + } + + let postBody = {} + if (opts.projectId !== undefined && opts.projectId !== null) { + postBody['projectId'] = opts.projectId + } + if (opts.mediaMetadata !== undefined && opts.mediaMetadata !== null) { + postBody['mediaMetadata'] = opts.mediaMetadata + } + if (opts.userData !== undefined && opts.userData !== null) { + postBody['userData'] = opts.userData + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 submitVeditJob 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( + '/veditJobs:submit', + '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) + } + ) + } + + /** + * 查询视频剪辑工程列表。 +允许通过条件过滤查询,支持的过滤字段如下: + - projectId[eq] 按照工程ID精确查询 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认值为 1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认值为 10;取值范围 [10, 100] optional + * @param {filter} [opts.filters] optional + * @param {string} callback - callback + @return {Object} result + * @param veditProjectPageData resultObject + */ + + listVeditProjects (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 vod/1.2.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 listVeditProjects 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( + '/veditProjects', + '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.projectName - 工程名称 + * @param {string} [opts.description] - 工程描述 optional + * @param {timeline} opts.timeline - 时间线信息 + * @param {string} callback - callback + @return {Object} result + * @param veditProjectData resultObject + */ + + createVeditProject (opts, callback) { + opts = opts || {} + + if (opts.projectName === undefined || opts.projectName === null) { + throw new Error( + "Missing the required parameter 'opts.projectName' when calling createVeditProject" + ) + } + if (opts.timeline === undefined || opts.timeline === null) { + throw new Error( + "Missing the required parameter 'opts.timeline' when calling createVeditProject" + ) + } + + let postBody = {} + if (opts.projectName !== undefined && opts.projectName !== null) { + postBody['projectName'] = opts.projectName + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.timeline !== undefined && opts.timeline !== null) { + postBody['timeline'] = opts.timeline + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 createVeditProject 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( + '/veditProjects', + '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.projectId - 视频剪辑工程ID + * @param {string} callback - callback + @return {Object} result + * @param veditProjectData resultObject + */ + + getVeditProject (opts, callback) { + opts = opts || {} + + if (opts.projectId === undefined || opts.projectId === null) { + throw new Error( + "Missing the required parameter 'opts.projectId' when calling getVeditProject" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + projectId: opts.projectId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 getVeditProject 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( + '/veditProjects/{projectId}', + '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.projectId - 视频剪辑工程ID + * @param {string} [opts.projectName] - 工程名称 optional + * @param {string} [opts.description] - 工程描述 optional + * @param {timeline} [opts.timeline] - 时间线信息 optional + * @param {string} callback - callback + @return {Object} result + * @param veditProjectData resultObject + */ + + updateVeditProject (opts, callback) { + opts = opts || {} + + if (opts.projectId === undefined || opts.projectId === null) { + throw new Error( + "Missing the required parameter 'opts.projectId' when calling updateVeditProject" + ) + } + + let postBody = {} + if (opts.projectName !== undefined && opts.projectName !== null) { + postBody['projectName'] = opts.projectName + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.timeline !== undefined && opts.timeline !== null) { + postBody['timeline'] = opts.timeline + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + projectId: opts.projectId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 updateVeditProject 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( + '/veditProjects/{projectId}', + '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) + } + ) + } + + /** + * 删除视频剪辑工程 + * @param {Object} opts - parameters + * @param {integer} opts.projectId - 视频剪辑工程ID + * @param {string} callback - callback + @return {Object} result + */ + + deleteVeditProject (opts, callback) { + opts = opts || {} + + if (opts.projectId === undefined || opts.projectId === null) { + throw new Error( + "Missing the required parameter 'opts.projectId' when calling deleteVeditProject" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + projectId: opts.projectId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 deleteVeditProject 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( + '/veditProjects/{projectId}', + '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) + } + ) + } + + /** + * 查询视频列表信息。 +允许通过条件过滤查询,支持的过滤字段如下: + - status[eq] 按视频状态精确查询 + - categoryId[eq] 按分类ID精确查询 + - videoId[eq] 按视频ID精确查询 + - name[eq] 按视频名称精确查询 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码;默认值为 1 optional + * @param {integer} [opts.pageSize] - 分页大小;默认值为 10;取值范围 [10, 100] optional + * @param {filter} [opts.filters] optional + * @param {sort} [opts.sorts] optional + * @param {string} callback - callback + @return {Object} result + * @param listVideosResultObject resultObject + */ + + listVideos (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')) + Object.assign(queryParams, super.buildSortParam(opts.sorts, 'sorts')) + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 listVideos 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( + '/videos', + '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.videoId - 视频ID + * @param {string} callback - callback + @return {Object} result + * @param videoObject resultObject + */ + + getVideo (opts, callback) { + opts = opts || {} + + if (opts.videoId === undefined || opts.videoId === null) { + throw new Error( + "Missing the required parameter 'opts.videoId' when calling getVideo" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + videoId: opts.videoId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 getVideo 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( + '/videos/{videoId}', + '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.videoId - 视频ID + * @param {string} [opts.name] - 视频名称 optional + * @param {integer} [opts.categoryId] - 分类ID optional + * @param {array} [opts.tags] - 标签 optional + * @param {string} [opts.coverUrl] - 封面地址 optional + * @param {string} [opts.description] - 视频描述信息 optional + * @param {string} callback - callback + @return {Object} result + * @param videoObject resultObject + */ + + updateVideo (opts, callback) { + opts = opts || {} + + if (opts.videoId === undefined || opts.videoId === null) { + throw new Error( + "Missing the required parameter 'opts.videoId' when calling updateVideo" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.categoryId !== undefined && opts.categoryId !== null) { + postBody['categoryId'] = opts.categoryId + } + if (opts.tags !== undefined && opts.tags !== null) { + postBody['tags'] = opts.tags + } + if (opts.coverUrl !== undefined && opts.coverUrl !== null) { + postBody['coverUrl'] = opts.coverUrl + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + videoId: opts.videoId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 updateVideo 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( + '/videos/{videoId}', + '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) + } + ) + } + + /** + * 删除视频,调用该接口会同时删除与指定视频相关的所有信息,包括转码任务信息、转码流数据等,同时清除云存储中相关文件资源。 + * @param {Object} opts - parameters + * @param {string} opts.videoId - 视频ID + * @param {string} callback - callback + @return {Object} result + */ + + deleteVideo (opts, callback) { + opts = opts || {} + + if (opts.videoId === undefined || opts.videoId === null) { + throw new Error( + "Missing the required parameter 'opts.videoId' when calling deleteVideo" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + videoId: opts.videoId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 deleteVideo 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( + '/videos/{videoId}', + '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 {array} [opts.videoIds] - 视频ID集合 optional + * @param {string} callback - callback + @return {Object} result + * @param batchDeleteVideosResultObject resultObject + */ + + batchDeleteVideos (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.videoIds !== undefined && opts.videoIds !== null) { + postBody['videoIds'] = opts.videoIds + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 batchDeleteVideos 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( + '/videos:batchDelete', + '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 {array} [opts.bulkItems] - 批量更新视频的条目集合 optional + * @param {string} callback - callback + @return {Object} result + * @param batchUpdateVideosResultObject resultObject + */ + + batchUpdateVideos (opts, callback) { + opts = opts || {} + + let postBody = {} + if (opts.bulkItems !== undefined && opts.bulkItems !== null) { + postBody['bulkItems'] = opts.bulkItems + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 batchUpdateVideos 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( + '/videos:batchUpdate', + '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.videoId - 视频ID + * @param {string} callback - callback + @return {Object} result + * @param getPlayInfoResultObject resultObject + */ + + getVideoPlayInfo (opts, callback) { + opts = opts || {} + + if (opts.videoId === undefined || opts.videoId === null) { + throw new Error( + "Missing the required parameter 'opts.videoId' when calling getVideoPlayInfo" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + videoId: opts.videoId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 getVideoPlayInfo 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( + '/videos/{videoId}:getPlayInfo', + '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.videoId - 视频ID + * @param {array} [opts.taskIds] optional + * @param {string} callback - callback + @return {Object} result + * @param deleteVideoStreamsResultObject resultObject + */ + + deleteVideoStreams (opts, callback) { + opts = opts || {} + + if (opts.videoId === undefined || opts.videoId === null) { + throw new Error( + "Missing the required parameter 'opts.videoId' when calling deleteVideoStreams" + ) + } + + let postBody = {} + if (opts.taskIds !== undefined && opts.taskIds !== null) { + postBody['taskIds'] = opts.taskIds + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + videoId: opts.videoId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 deleteVideoStreams 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( + '/videos/{videoId}:deleteStreams', + '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.videoId - 视频ID + * @param {string} opts.auditResult - 审核结果,取值范围: + block(封禁) + unblock(解封) + + * @param {string} callback - callback + @return {Object} result + */ + + videoAudit (opts, callback) { + opts = opts || {} + + if (opts.videoId === undefined || opts.videoId === null) { + throw new Error( + "Missing the required parameter 'opts.videoId' when calling videoAudit" + ) + } + if (opts.auditResult === undefined || opts.auditResult === null) { + throw new Error( + "Missing the required parameter 'opts.auditResult' when calling videoAudit" + ) + } + + let postBody = {} + if (opts.auditResult !== undefined && opts.auditResult !== null) { + postBody['auditResult'] = opts.auditResult + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + videoId: opts.videoId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 videoAudit 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( + '/videos/{videoId}:audit', + '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.videoId - 视频ID + * @param {string} callback - callback + @return {Object} result + * @param getPlayInfoResultObject resultObject + */ + + getVideoSourceInfo (opts, callback) { + opts = opts || {} + + if (opts.videoId === undefined || opts.videoId === null) { + throw new Error( + "Missing the required parameter 'opts.videoId' when calling getVideoSourceInfo" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + videoId: opts.videoId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 getVideoSourceInfo 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( + '/videos/{videoId}:getSourceInfo', + '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 optional + * @param {integer} [opts.pageSize] - 分页大小;默认值为 10;取值范围 [10, 100] optional + * @param {string} callback - callback + @return {Object} result + * @param listWatermarksResultObject resultObject + */ + + listWatermarks (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 + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 listWatermarks 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( + '/watermarks', + '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.name - 水印名称。只支持中英文、数字。长度不超过128个字符。UTF-8编码。 + + * @param {string} opts.imgUrl - 图片地址 + * @param {string} opts.width - 水印宽度。 +当 sizeUnit = pixel 时,取值范围为 [8, 4096] 整数 +当 sizeUnit = percent 时,取值范围为 [0, 100] 小数 + + * @param {string} opts.height - 水印高度。 +当 sizeUnit = pixel 时,取值范围为 [8, 4096] 整数 +当 sizeUnit = percent 时,取值范围为 [0, 100] 小数 + + * @param {string} [opts.sizeUnit] - 尺寸单位。取值范围: + pixel - 像素 + percent - 百分比 +默认值为 pixel + optional + * @param {string} [opts.widthRef] optional + * @param {string} [opts.heightRef] - 高度参考,仅当 siteUnit = percent 时生效。 +取值说明: + w: 输出水印高度 = height * 水印原图高度 + v: 等同于 vh + vw: 输出水印高度 = height * 输出视频宽度 + vh: 输出水印高度 = height * 输出视频高度 + vls: 输出水印高度 = height * 输出视频长边 + vss: 输出水印高度 = height * 输出视频短边 + optional + * @param {string} opts.position - 水印位置。取值范围: + LT - 左上 + RT - 右上 + LB - 左下 + RB - 右下 + + * @param {string} opts.offsetX - 水平偏移。 +当 offsetUnit = pixel 时,取值范围为 [8, 4088] 整数 +当 offsetUnit = percent 时,取值范围为 [0, 100] 小数 + + * @param {string} opts.offsetY - 竖直偏移。 +当 offsetUnit = pixel 时,取值范围为 [8, 4088] 整数 +当 offsetUnit = percent 时,取值范围为 [0, 100] 小数 + + * @param {string} [opts.offsetUnit] - 偏移单位。取值范围: + pixel - 像素 + percent - 百分比 +默认值为 pixel + optional + * @param {string} callback - callback + @return {Object} result + * @param watermarkObject resultObject + */ + + createWatermark (opts, callback) { + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createWatermark" + ) + } + if (opts.imgUrl === undefined || opts.imgUrl === null) { + throw new Error( + "Missing the required parameter 'opts.imgUrl' when calling createWatermark" + ) + } + if (opts.width === undefined || opts.width === null) { + throw new Error( + "Missing the required parameter 'opts.width' when calling createWatermark" + ) + } + if (opts.height === undefined || opts.height === null) { + throw new Error( + "Missing the required parameter 'opts.height' when calling createWatermark" + ) + } + if (opts.position === undefined || opts.position === null) { + throw new Error( + "Missing the required parameter 'opts.position' when calling createWatermark" + ) + } + if (opts.offsetX === undefined || opts.offsetX === null) { + throw new Error( + "Missing the required parameter 'opts.offsetX' when calling createWatermark" + ) + } + if (opts.offsetY === undefined || opts.offsetY === null) { + throw new Error( + "Missing the required parameter 'opts.offsetY' when calling createWatermark" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.imgUrl !== undefined && opts.imgUrl !== null) { + postBody['imgUrl'] = opts.imgUrl + } + if (opts.width !== undefined && opts.width !== null) { + postBody['width'] = opts.width + } + if (opts.height !== undefined && opts.height !== null) { + postBody['height'] = opts.height + } + if (opts.sizeUnit !== undefined && opts.sizeUnit !== null) { + postBody['sizeUnit'] = opts.sizeUnit + } + if (opts.widthRef !== undefined && opts.widthRef !== null) { + postBody['widthRef'] = opts.widthRef + } + if (opts.heightRef !== undefined && opts.heightRef !== null) { + postBody['heightRef'] = opts.heightRef + } + if (opts.position !== undefined && opts.position !== null) { + postBody['position'] = opts.position + } + if (opts.offsetX !== undefined && opts.offsetX !== null) { + postBody['offsetX'] = opts.offsetX + } + if (opts.offsetY !== undefined && opts.offsetY !== null) { + postBody['offsetY'] = opts.offsetY + } + if (opts.offsetUnit !== undefined && opts.offsetUnit !== null) { + postBody['offsetUnit'] = opts.offsetUnit + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 createWatermark 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( + '/watermarks', + '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.watermarkId - 水印ID + * @param {string} callback - callback + @return {Object} result + * @param watermarkObject resultObject + */ + + getWatermark (opts, callback) { + opts = opts || {} + + if (opts.watermarkId === undefined || opts.watermarkId === null) { + throw new Error( + "Missing the required parameter 'opts.watermarkId' when calling getWatermark" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + watermarkId: opts.watermarkId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 getWatermark 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( + '/watermarks/{watermarkId}', + '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.watermarkId - 水印ID + * @param {string} [opts.name] - 水印名称。只支持中英文、数字。长度不超过128个字符。UTF-8编码。 + optional + * @param {string} [opts.imgUrl] - 图片地址 optional + * @param {string} [opts.width] - 水印宽度。 +当 sizeUnit = pixel 时,取值范围为 [8, 4096] 整数 +当 sizeUnit = percent 时,取值范围为 [0, 100] 小数 + optional + * @param {string} [opts.height] - 水印高度。 +当 sizeUnit = pixel 时,取值范围为 [8, 4096] 整数 +当 sizeUnit = percent 时,取值范围为 [0, 100] 小数 + optional + * @param {string} [opts.sizeUnit] - 尺寸单位。取值范围: + pixel - 像素 + percent - 百分比 +默认值为 pixel + optional + * @param {string} [opts.widthRef] optional + * @param {string} [opts.heightRef] - 高度参考,仅当 siteUnit = percent 时生效。 +取值说明: + w: 输出水印高度 = height * 水印原图高度 + v: 等同于 vh + vw: 输出水印高度 = height * 输出视频宽度 + vh: 输出水印高度 = height * 输出视频高度 + vls: 输出水印高度 = height * 输出视频长边 + vss: 输出水印高度 = height * 输出视频短边 + optional + * @param {string} [opts.position] - 水印位置。取值范围: + LT - 左上 + RT - 右上 + LB - 左下 + RB - 右下 + optional + * @param {string} [opts.offsetX] - 水平偏移。 +当 offsetUnit = pixel 时,取值范围为 [8, 4088] 整数 +当 offsetUnit = percent 时,取值范围为 [0, 100] 小数 + optional + * @param {string} [opts.offsetY] - 竖直偏移。 +当 offsetUnit = pixel 时,取值范围为 [8, 4088] 整数 +当 offsetUnit = percent 时,取值范围为 [0, 100] 小数 + optional + * @param {string} [opts.offsetUnit] - 偏移单位。取值范围: + pixel - 像素 + percent - 百分比 +默认值为 pixel + optional + * @param {string} callback - callback + @return {Object} result + * @param watermarkObject resultObject + */ + + updateWatermark (opts, callback) { + opts = opts || {} + + if (opts.watermarkId === undefined || opts.watermarkId === null) { + throw new Error( + "Missing the required parameter 'opts.watermarkId' when calling updateWatermark" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.imgUrl !== undefined && opts.imgUrl !== null) { + postBody['imgUrl'] = opts.imgUrl + } + if (opts.width !== undefined && opts.width !== null) { + postBody['width'] = opts.width + } + if (opts.height !== undefined && opts.height !== null) { + postBody['height'] = opts.height + } + if (opts.sizeUnit !== undefined && opts.sizeUnit !== null) { + postBody['sizeUnit'] = opts.sizeUnit + } + if (opts.widthRef !== undefined && opts.widthRef !== null) { + postBody['widthRef'] = opts.widthRef + } + if (opts.heightRef !== undefined && opts.heightRef !== null) { + postBody['heightRef'] = opts.heightRef + } + if (opts.position !== undefined && opts.position !== null) { + postBody['position'] = opts.position + } + if (opts.offsetX !== undefined && opts.offsetX !== null) { + postBody['offsetX'] = opts.offsetX + } + if (opts.offsetY !== undefined && opts.offsetY !== null) { + postBody['offsetY'] = opts.offsetY + } + if (opts.offsetUnit !== undefined && opts.offsetUnit !== null) { + postBody['offsetUnit'] = opts.offsetUnit + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + watermarkId: opts.watermarkId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 updateWatermark 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( + '/watermarks/{watermarkId}', + '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) + } + ) + } + + /** + * 删除水印 + * @param {Object} opts - parameters + * @param {integer} opts.watermarkId - 水印ID + * @param {string} callback - callback + @return {Object} result + */ + + deleteWatermark (opts, callback) { + opts = opts || {} + + if (opts.watermarkId === undefined || opts.watermarkId === null) { + throw new Error( + "Missing the required parameter 'opts.watermarkId' when calling deleteWatermark" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + watermarkId: opts.watermarkId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vod/1.2.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 deleteWatermark 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( + '/watermarks/{watermarkId}', + '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) + } + ) + } +} +module.exports = VOD diff --git a/packages/libs/lib-jdcloud/src/repo/vpc/v1/vpc.js b/packages/libs/lib-jdcloud/src/repo/vpc/v1/vpc.js new file mode 100644 index 000000000..eb0b3d00b --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/vpc/v1/vpc.js @@ -0,0 +1,9983 @@ +/* + * 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. + * + * Vpc-Policy + * vpc支持oss权限访问控制相关接口 + * + * 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 = 'vpc' +Service._services[serviceId] = true + +/** + * vpc service. + * @version 1.1.5 + */ + +class VPC extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'vpc.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * +查询共享带宽包列表 + +## 接口说明 + +- 使用 `filters` 过滤器进行条件筛选,每个 `filter` 之间的关系为逻辑与(AND)的关系。 + +- 如果使用子帐号查询,只会查询到该子帐号有权限的云主机实例。关于资源权限请参考 [IAM概述](https://docs.jdcloud.com/cn/iam/product-overview)。 + +- 单次查询最大可查询100条共享带宽包数据。 + +- 尽量一次调用接口查询多条数据,不建议使用该批量查询接口一次查询一条数据,如果使用不当导致查询过于密集,可能导致网关触发限流。 + +- 由于该接口为 `GET` 方式请求,最终参数会转换为 `URL` 上的参数,但是 `HTTP` 协议下的 `GET` 请求参数长度是有大小限制的,使用者需要注意参数超长的问题。 + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞), 页码超过总页数时, 显示最后一页 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围为[10,100] optional + * @param {filter} [opts.filters] - bwpIds - 共享带宽包ID,支持多个进行精确搜索 +name - 共享带宽包名称,支持单个进行精确搜索 + optional + * @param {tagFilter} [opts.tags] - Tag筛选条件 optional + * @param {string} [opts.resourceGroupIds] - 资源组筛选条件 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param bandwidthPackage bandwidthPackages + * @param integer totalCount 总数量 + */ + + describeBandwidthPackages (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 describeBandwidthPackages" + ) + } + + 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')) + Object.assign(queryParams, super.buildTagFilterParam(opts.tags, 'tags')) + Object.assign( + queryParams, + super.buildArrayParam(opts.resourceGroupIds, 'resourceGroupIds') + ) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 describeBandwidthPackages 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}/bandwidthPackages/', + '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) + } + ) + } + + /** + * 指定地域创建共享带宽包实例。 + +## 接口说明 + +- 需要接口完成实名认证、支付方式确认、计费类型选择等准备工作。 + +- 各地域下包年包月和按配置计费的共享带宽包不受配额限制,按用量计费的共享带宽包可创建数量受配额限制,创建前请通过 [DescribeQuotas](https://docs.jdcloud.com/cn/shared-bandwidth-package/api/describequotas?content=API) 确认配额,如须提升请[提交工单](https://ticket.jdcloud.com/applyorder/submit)或联系京东云客服。 + +- 通过本接口创建包年包月资源时将自动从账户扣款(代金券优先),如需使用第三方支付方式请通过控制台创建。 + +- 按用量计费模式需提工单申请使用权限,默认支持增强95消峰计费。 + + * @param {Object} opts - parameters + * @param {string} opts.name - 名称,只支持中文、数字、大小写字母、英文下划线“_”及中划线“-”,且长度不超过32个字符 + * @param {string} [opts.description] - 描述,长度不超过256个字符 optional + * @param {integer} opts.bandwidthMbps - 共享带宽包带宽上限,取值范围200-5000,单位为Mbps,保底带宽 = 共享带宽包带宽上限 * 20% + * @param {string} [opts.provider] - 线路信息,默认bgp,目前只支持中心节点的BGP线路 optional + * @param {chargeSpec} [opts.chargeSpec] - 计费配置。支持包年包月、按配置、按用量计费模式 optional + * @param {array} [opts.userTags] - 用户标签 optional + * @param {string} [opts.resourceGroupId] - 资源所属资源组ID optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string bandwidthPackageId 共享带宽包ID + * @param string requestId 请求ID + */ + + createBandwidthPackage (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 createBandwidthPackage" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createBandwidthPackage" + ) + } + if (opts.bandwidthMbps === undefined || opts.bandwidthMbps === null) { + throw new Error( + "Missing the required parameter 'opts.bandwidthMbps' when calling createBandwidthPackage" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.bandwidthMbps !== undefined && opts.bandwidthMbps !== null) { + postBody['bandwidthMbps'] = opts.bandwidthMbps + } + if (opts.provider !== undefined && opts.provider !== null) { + postBody['provider'] = opts.provider + } + if (opts.chargeSpec !== undefined && opts.chargeSpec !== null) { + postBody['chargeSpec'] = opts.chargeSpec + } + if (opts.userTags !== undefined && opts.userTags !== null) { + postBody['userTags'] = opts.userTags + } + if (opts.resourceGroupId !== undefined && opts.resourceGroupId !== null) { + postBody['resourceGroupId'] = opts.resourceGroupId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 createBandwidthPackage 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}/bandwidthPackages/', + '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.bandwidthPackageId - 共享带宽包ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param bandwidthPackage bandwidthPackage 共享带宽包资源信息 + */ + + describeBandwidthPackage (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 describeBandwidthPackage" + ) + } + + opts = opts || {} + + if ( + opts.bandwidthPackageId === undefined || + opts.bandwidthPackageId === null + ) { + throw new Error( + "Missing the required parameter 'opts.bandwidthPackageId' when calling describeBandwidthPackage" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + bandwidthPackageId: opts.bandwidthPackageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 describeBandwidthPackage 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}/bandwidthPackages/{bandwidthPackageId}', + '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的带宽上限值。 + +- 欠费或到期的共享带宽包资源不支持修改带宽上限。 + + * @param {Object} opts - parameters + * @param {string} opts.bandwidthPackageId - 共享带宽包ID + * @param {integer} [opts.bandwidthMbps] - 共享带宽包带宽上限,取值范围200-5000,单位为Mbps,且不能低于共享带宽包内公网IP带宽上限 optional + * @param {string} [opts.name] - 名称,只支持中文、数字、大小写字母、英文下划线“_”及中划线“-”,且长度不超过32个字符 optional + * @param {string} [opts.description] - 描述,长度不超过256个字符 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyBandwidthPackage (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 modifyBandwidthPackage" + ) + } + + opts = opts || {} + + if ( + opts.bandwidthPackageId === undefined || + opts.bandwidthPackageId === null + ) { + throw new Error( + "Missing the required parameter 'opts.bandwidthPackageId' when calling modifyBandwidthPackage" + ) + } + + let postBody = {} + if (opts.bandwidthMbps !== undefined && opts.bandwidthMbps !== null) { + postBody['bandwidthMbps'] = opts.bandwidthMbps + } + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + bandwidthPackageId: opts.bandwidthPackageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 modifyBandwidthPackage 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}/bandwidthPackages/{bandwidthPackageId}', + 'PATCH', + 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存在时、包年包月类型的共享带宽包未到期时、按用量计费的共享带宽包使用时长未满一个完整的自然月时均不支持删除共享带宽包 + + * @param {Object} opts - parameters + * @param {string} opts.bandwidthPackageId - 共享带宽包ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteBandwidthPackage (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 deleteBandwidthPackage" + ) + } + + opts = opts || {} + + if ( + opts.bandwidthPackageId === undefined || + opts.bandwidthPackageId === null + ) { + throw new Error( + "Missing the required parameter 'opts.bandwidthPackageId' when calling deleteBandwidthPackage" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + bandwidthPackageId: opts.bandwidthPackageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 deleteBandwidthPackage 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}/bandwidthPackages/{bandwidthPackageId}', + '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) + } + ) + } + + /** + * +向共享带宽包内增加公网IP + +## 接口说明 + +- 确保已有至少一个共享带宽包资源。 + +- 添加弹性公网IP前,需确保弹性公网IP所在地域与共享带宽包地域和线路相同,弹性公网IP的计费模式为按配置或按用量计费,且未加入其他的共享带宽包资源。 + +- 已欠费的、包年包月的公网IP不能加入共享带宽包。 + +- 一个公网IP同时只能加入一个共享带宽包。 + +- 共享带宽包中可添加的弹性公网IP受配额限制,添加前请通过 [DescribeQuotas](https://docs.jdcloud.com/cn/shared-bandwidth-package/api/describequotas?content=API) 确认配额,如须提升请[提交工单](https://ticket.jdcloud.com/applyorder/submit)或联系京东云客服。 + +- 弹性公网IP加入共享带宽包后,弹性公网 IP 会原有的计费和带宽上限暂时失效,已共享带宽包进行计费,带宽上限默认为共享带宽包的带宽上限,可通过[modifyBandwidthPackageIpBandwidth](https://docs.jdcloud.com/cn/shared-bandwidth-package/api/modifybandwidthpackageIpbandwidth)进行修改。 + +- 共享带宽包欠费或到期停服后不支持添加弹性公网IP。 + + * @param {Object} opts - parameters + * @param {string} opts.bandwidthPackageId - 共享带宽包ID + * @param {array} [opts.bandwidthPackageIPSpecs] - Ip列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + addBandwidthPackageIP (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 addBandwidthPackageIP" + ) + } + + opts = opts || {} + + if ( + opts.bandwidthPackageId === undefined || + opts.bandwidthPackageId === null + ) { + throw new Error( + "Missing the required parameter 'opts.bandwidthPackageId' when calling addBandwidthPackageIP" + ) + } + + let postBody = {} + if ( + opts.bandwidthPackageIPSpecs !== undefined && + opts.bandwidthPackageIPSpecs !== null + ) { + postBody['bandwidthPackageIPSpecs'] = opts.bandwidthPackageIPSpecs + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + bandwidthPackageId: opts.bandwidthPackageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 addBandwidthPackageIP 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}/bandwidthPackages/{bandwidthPackageId}:addBandwidthPackageIP', + '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) + } + ) + } + + /** + * +从共享带宽包内移除公网IP + +## 接口说明 + +- 弹性公网IP从共享带宽包中移除后,恢复原有的计费模式和带宽上限。 + +- 共享带宽包是否计费与共享带宽包中有无弹性公网IP无关,如共享带宽包中无弹性公网IP资源时请及时删除资源,避免产生额外费用 + + * @param {Object} opts - parameters + * @param {string} opts.bandwidthPackageId - 共享带宽包ID + * @param {array} [opts.bandwidthPackageIPSpecs] - 公网IP列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + removeBandwidthPackageIP (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 removeBandwidthPackageIP" + ) + } + + opts = opts || {} + + if ( + opts.bandwidthPackageId === undefined || + opts.bandwidthPackageId === null + ) { + throw new Error( + "Missing the required parameter 'opts.bandwidthPackageId' when calling removeBandwidthPackageIP" + ) + } + + let postBody = {} + if ( + opts.bandwidthPackageIPSpecs !== undefined && + opts.bandwidthPackageIPSpecs !== null + ) { + postBody['bandwidthPackageIPSpecs'] = opts.bandwidthPackageIPSpecs + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + bandwidthPackageId: opts.bandwidthPackageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 removeBandwidthPackageIP 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}/bandwidthPackages/{bandwidthPackageId}:removeBandwidthPackageIP', + '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) + } + ) + } + + /** + * +修改共享带宽包内弹性公网 IP 的带宽上限。 + +## 接口说明 + +- 共享带宽包中弹性公网IP的带宽上限不能高于共享带宽包的带宽上限。 + + * @param {Object} opts - parameters + * @param {string} opts.bandwidthPackageId - 共享带宽包ID + * @param {array} [opts.bandwidthPackageIPSpecs] - Ip列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyBandwidthPackageIpBandwidth ( + 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 modifyBandwidthPackageIpBandwidth" + ) + } + + opts = opts || {} + + if ( + opts.bandwidthPackageId === undefined || + opts.bandwidthPackageId === null + ) { + throw new Error( + "Missing the required parameter 'opts.bandwidthPackageId' when calling modifyBandwidthPackageIpBandwidth" + ) + } + + let postBody = {} + if ( + opts.bandwidthPackageIPSpecs !== undefined && + opts.bandwidthPackageIPSpecs !== null + ) { + postBody['bandwidthPackageIPSpecs'] = opts.bandwidthPackageIPSpecs + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + bandwidthPackageId: opts.bandwidthPackageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 modifyBandwidthPackageIpBandwidth 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}/bandwidthPackages/{bandwidthPackageId}:modifyBandwidthPackageIpBandwidth', + '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) + } + ) + } + + /** + * 查询弹性公网IP列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞), 页码超过总页数时, 显示最后一页 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {filter} [opts.filters] - elasticIpIds - elasticip id数组条件,支持多个 +elasticIpAddress - eip的IP地址,支持单个 +chargeStatus - eip的费用支付状态,normal(正常状态) or overdue(预付费已到期) or arrear(欠费状态),支持单个 +ipType - eip类型,取值:all(所有类型)、standard(标准弹性IP)、edge(边缘弹性IP),默认standard,支持单个 +azs - eip可用区,支持多个 +bandwidthPackageId - 共享带宽包ID,支持单个 +status - IP是否被绑定,取值:ASSOCIATED(被绑定)、NOT_ASSOCIATED(未被绑定)、ALL(全部)。支持单个 + optional + * @param {tagFilter} [opts.tags] - Tag筛选条件 optional + * @param {string} [opts.resourceGroupIds] - 资源组筛选条件 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param elasticIp elasticIps + * @param integer totalCount 总数量 + */ + + describeElasticIps (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 describeElasticIps" + ) + } + + 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')) + Object.assign(queryParams, super.buildTagFilterParam(opts.tags, 'tags')) + Object.assign( + queryParams, + super.buildArrayParam(opts.resourceGroupIds, 'resourceGroupIds') + ) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 describeElasticIps 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}/elasticIps/', + '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 + * @param {Object} opts - parameters + * @param {integer} opts.maxCount - 购买弹性ip数量;取值范围:[1,100] + * @param {string} [opts.elasticIpAddress] - 指定弹性ip地址进行创建,当申请创建多个弹性ip时,必须为空 optional + * @param {elasticIpSpec} opts.elasticIpSpec - 弹性ip规格 + * @param {array} [opts.userTags] - 用户标签 optional + * @param {string} [opts.ipType] - 弹性ip类型,取值:standard(标准公网IP),edge(边缘公网IP),默认为standard optional + * @param {string} [opts.resourceGroupId] - 资源所属资源组ID optional + * @param {boolean} [opts.dryRun] - 预检标识,默认false,dryRun为true时只作检查,不做变更 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string elasticIpIds 弹性公网IP ID + * @param string requestId 请求ID + */ + + createElasticIps (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 createElasticIps" + ) + } + + opts = opts || {} + + if (opts.maxCount === undefined || opts.maxCount === null) { + throw new Error( + "Missing the required parameter 'opts.maxCount' when calling createElasticIps" + ) + } + if (opts.elasticIpSpec === undefined || opts.elasticIpSpec === null) { + throw new Error( + "Missing the required parameter 'opts.elasticIpSpec' when calling createElasticIps" + ) + } + + let postBody = {} + if (opts.maxCount !== undefined && opts.maxCount !== null) { + postBody['maxCount'] = opts.maxCount + } + if (opts.elasticIpAddress !== undefined && opts.elasticIpAddress !== null) { + postBody['elasticIpAddress'] = opts.elasticIpAddress + } + if (opts.elasticIpSpec !== undefined && opts.elasticIpSpec !== null) { + postBody['elasticIpSpec'] = opts.elasticIpSpec + } + if (opts.userTags !== undefined && opts.userTags !== null) { + postBody['userTags'] = opts.userTags + } + if (opts.ipType !== undefined && opts.ipType !== null) { + postBody['ipType'] = opts.ipType + } + if (opts.resourceGroupId !== undefined && opts.resourceGroupId !== null) { + postBody['resourceGroupId'] = opts.resourceGroupId + } + 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 vpc/1.1.5' + } + + 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 createElasticIps 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}/elasticIps/', + '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) + } + ) + } + + /** + * ElasticIp资源信息详情 + * @param {Object} opts - parameters + * @param {string} opts.elasticIpId - ElasticIp ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param elasticIp elasticIp elasticIp资源信息 + */ + + describeElasticIp (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 describeElasticIp" + ) + } + + opts = opts || {} + + if (opts.elasticIpId === undefined || opts.elasticIpId === null) { + throw new Error( + "Missing the required parameter 'opts.elasticIpId' when calling describeElasticIp" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + elasticIpId: opts.elasticIpId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 describeElasticIp 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}/elasticIps/{elasticIpId}', + '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限速需要调用共享带宽包的接口(修改共享带宽包内公网IP带宽上限) + * @param {Object} opts - parameters + * @param {string} opts.elasticIpId - ElasticIp ID + * @param {integer} opts.bandwidthMbps - 弹性公网IP的限速(单位:Mbps),取值范围为[1-200] + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyElasticIp (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 modifyElasticIp" + ) + } + + opts = opts || {} + + if (opts.elasticIpId === undefined || opts.elasticIpId === null) { + throw new Error( + "Missing the required parameter 'opts.elasticIpId' when calling modifyElasticIp" + ) + } + if (opts.bandwidthMbps === undefined || opts.bandwidthMbps === null) { + throw new Error( + "Missing the required parameter 'opts.bandwidthMbps' when calling modifyElasticIp" + ) + } + + let postBody = {} + if (opts.bandwidthMbps !== undefined && opts.bandwidthMbps !== null) { + postBody['bandwidthMbps'] = opts.bandwidthMbps + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + elasticIpId: opts.elasticIpId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 modifyElasticIp 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}/elasticIps/{elasticIpId}', + 'PATCH', + 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不能删除,需要先从共享带宽包移出 + * @param {Object} opts - parameters + * @param {string} opts.elasticIpId - ElasticIp ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteElasticIp (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 deleteElasticIp" + ) + } + + opts = opts || {} + + if (opts.elasticIpId === undefined || opts.elasticIpId === null) { + throw new Error( + "Missing the required parameter 'opts.elasticIpId' when calling deleteElasticIp" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + elasticIpId: opts.elasticIpId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 deleteElasticIp 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}/elasticIps/{elasticIpId}', + '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) + } + ) + } + + /** + * 查询NAT网关列表接口 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞), 页码超过总页数时, 显示最后一页 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {filter} [opts.filters] - natGatewayIds - NAT网关ID列表,支持多个 +natGatewayNames - NAT网关名称列表,支持多个 +natGatewayPublicIp - NAT网关公网IP,支持单个,即将废弃,请使用elasticIpAddress +elasticIpAddress - 公网IP,支持单个 +natGatewayPrivateIp - NAT网关私网IP,支持单个 +vpcId - NAT网关所属VPC ID,支持单个 +subnetId - NAT网关所属子网ID,支持单个 + optional + * @param {tagFilter} [opts.tags] - Tag筛选条件 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param natGateway natGateways + * @param number totalCount 总数量 + */ + + describeNatGateways (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 describeNatGateways" + ) + } + + 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')) + Object.assign(queryParams, super.buildTagFilterParam(opts.tags, 'tags')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 describeNatGateways 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}/natGateways/', + '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) + } + ) + } + + /** + * 创建NAT网关接口 + * @param {Object} opts - parameters + * @param {string} opts.natGatewayName - NAT网关名称 + * @param {string} [opts.natGatewaySpec] - NAT网关规格,取值small(100万并发连接数),medium(300万并发连接数),large(1000万并发连接数),默认small optional + * @param {string} opts.vpcId - 私有网络ID + * @param {string} opts.subnetId - 子网ID + * @param {array} [opts.azIpSpecs] - NAT网关的可用区属性,即将废弃 optional + * @param {array} [opts.azs] - NAT网关可用区 optional + * @param {array} [opts.elasticIpIds] - 选择已有公网IP列表。选择已有和新购公网IP可以同时配置,也可以配置其一 optional + * @param {integer} [opts.elasticIpCount] - 新购公网IP数量 optional + * @param {elasticIpSpec} [opts.elasticIpSpec] - 新购公网IP配置。NAT网关仅支持打包创建标准公网IP,不支持边缘公网IP。且标准公网IP仅支持按配置、按用量两种计费模式。 optional + * @param {chargeSpec} [opts.natGatewayCharge] - 计费配置,仅支持按配置,默认按配置 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 natGatewayId NAT网关ID + */ + + createNatGateway (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 createNatGateway" + ) + } + + opts = opts || {} + + if (opts.natGatewayName === undefined || opts.natGatewayName === null) { + throw new Error( + "Missing the required parameter 'opts.natGatewayName' when calling createNatGateway" + ) + } + if (opts.vpcId === undefined || opts.vpcId === null) { + throw new Error( + "Missing the required parameter 'opts.vpcId' when calling createNatGateway" + ) + } + if (opts.subnetId === undefined || opts.subnetId === null) { + throw new Error( + "Missing the required parameter 'opts.subnetId' when calling createNatGateway" + ) + } + + let postBody = {} + if (opts.natGatewayName !== undefined && opts.natGatewayName !== null) { + postBody['natGatewayName'] = opts.natGatewayName + } + if (opts.natGatewaySpec !== undefined && opts.natGatewaySpec !== null) { + postBody['natGatewaySpec'] = opts.natGatewaySpec + } + if (opts.vpcId !== undefined && opts.vpcId !== null) { + postBody['vpcId'] = opts.vpcId + } + if (opts.subnetId !== undefined && opts.subnetId !== null) { + postBody['subnetId'] = opts.subnetId + } + if (opts.azIpSpecs !== undefined && opts.azIpSpecs !== null) { + postBody['azIpSpecs'] = opts.azIpSpecs + } + if (opts.azs !== undefined && opts.azs !== null) { + postBody['azs'] = opts.azs + } + if (opts.elasticIpIds !== undefined && opts.elasticIpIds !== null) { + postBody['elasticIpIds'] = opts.elasticIpIds + } + if (opts.elasticIpCount !== undefined && opts.elasticIpCount !== null) { + postBody['elasticIpCount'] = opts.elasticIpCount + } + if (opts.elasticIpSpec !== undefined && opts.elasticIpSpec !== null) { + postBody['elasticIpSpec'] = opts.elasticIpSpec + } + if (opts.natGatewayCharge !== undefined && opts.natGatewayCharge !== null) { + postBody['natGatewayCharge'] = opts.natGatewayCharge + } + 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 vpc/1.1.5' + } + + 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 createNatGateway 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}/natGateways/', + '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) + } + ) + } + + /** + * 查询NAT网关信息详情接口 + * @param {Object} opts - parameters + * @param {string} opts.natGatewayId - natGateway ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param natGateway natGateway natGateway资源信息 + */ + + describeNatGateway (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 describeNatGateway" + ) + } + + opts = opts || {} + + if (opts.natGatewayId === undefined || opts.natGatewayId === null) { + throw new Error( + "Missing the required parameter 'opts.natGatewayId' when calling describeNatGateway" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + natGatewayId: opts.natGatewayId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 describeNatGateway 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}/natGateways/{natGatewayId}', + '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) + } + ) + } + + /** + * 修改NAT网关接口,修改网关规格或带宽需要先停止网关 + * @param {Object} opts - parameters + * @param {string} opts.natGatewayId - natGateway ID + * @param {string} [opts.natGatewayName] - NAT网关名称 optional + * @param {string} [opts.description] - 描述,允许输入UTF-8编码下的全部字符,不超过256字符 optional + * @param {string} [opts.natGatewaySpec] - NAT网关规格,取值small(100万并发连接数),medium(300万并发连接数),large(1000万并发连接数) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyNatGateway (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 modifyNatGateway" + ) + } + + opts = opts || {} + + if (opts.natGatewayId === undefined || opts.natGatewayId === null) { + throw new Error( + "Missing the required parameter 'opts.natGatewayId' when calling modifyNatGateway" + ) + } + + let postBody = {} + if (opts.natGatewayName !== undefined && opts.natGatewayName !== null) { + postBody['natGatewayName'] = opts.natGatewayName + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.natGatewaySpec !== undefined && opts.natGatewaySpec !== null) { + postBody['natGatewaySpec'] = opts.natGatewaySpec + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + natGatewayId: opts.natGatewayId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 modifyNatGateway 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}/natGateways/{natGatewayId}', + 'PATCH', + 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) + } + ) + } + + /** + * 删除NAT网关接口,NAT网关需要先停止再删除 + * @param {Object} opts - parameters + * @param {string} opts.natGatewayId - natGateway ID + * @param {boolean} [opts.deleteElasticIp] - 是否打包删除公网IP,取值范围:true、false,默认false。true表示删除NAT网关时打包删除其绑定的所有公网IP;false表示删除NAT网关时不删除其绑定的所有公网IP。包年包月公网IP不支持打包删除 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param failedIp failedList + */ + + deleteNatGateway (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 deleteNatGateway" + ) + } + + opts = opts || {} + + if (opts.natGatewayId === undefined || opts.natGatewayId === null) { + throw new Error( + "Missing the required parameter 'opts.natGatewayId' when calling deleteNatGateway" + ) + } + + let postBody = null + let queryParams = {} + if (opts.deleteElasticIp !== undefined && opts.deleteElasticIp !== null) { + queryParams['deleteElasticIp'] = opts.deleteElasticIp + } + + let pathParams = { + regionId: regionId, + natGatewayId: opts.natGatewayId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 deleteNatGateway 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}/natGateways/{natGatewayId}', + '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) + } + ) + } + + /** + * 启动NAT网关接口,欠费停服客户不允许启动 + * @param {Object} opts - parameters + * @param {string} opts.natGatewayId - natGateway ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + startNatGateway (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 startNatGateway" + ) + } + + opts = opts || {} + + if (opts.natGatewayId === undefined || opts.natGatewayId === null) { + throw new Error( + "Missing the required parameter 'opts.natGatewayId' when calling startNatGateway" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + natGatewayId: opts.natGatewayId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 startNatGateway 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}/natGateways/{natGatewayId}:startNatGateway', + '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) + } + ) + } + + /** + * 停止NAT网关接口,非欠费停服,由客户自己停止的NAT网关继续计费 + * @param {Object} opts - parameters + * @param {string} opts.natGatewayId - natGateway ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + stopNatGateway (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 stopNatGateway" + ) + } + + opts = opts || {} + + if (opts.natGatewayId === undefined || opts.natGatewayId === null) { + throw new Error( + "Missing the required parameter 'opts.natGatewayId' when calling stopNatGateway" + ) + } + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: regionId, + natGatewayId: opts.natGatewayId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 stopNatGateway 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}/natGateways/{natGatewayId}:stopNatGateway', + '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) + } + ) + } + + /** + * NAT网关绑定已有公网IP接口,NAT网关支持绑定一个或多个公网IP。当NAT网关绑定多个公网IP时,同一内网服务器的业务流量出公网将随机选取其中一个公网IP。由于每个内网服务器的业务流量大小不同,可能出现NAT多公网IP流量不均的情况。建议将多公网IP加入同一个共享带宽包,避免因业务流量达到单公网IP带宽上限,影响业务转发。 + * @param {Object} opts - parameters + * @param {string} opts.natGatewayId - natGateway ID + * @param {array} opts.elasticIpIds - 公网IP列表 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + associateElasticIps (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 associateElasticIps" + ) + } + + opts = opts || {} + + if (opts.natGatewayId === undefined || opts.natGatewayId === null) { + throw new Error( + "Missing the required parameter 'opts.natGatewayId' when calling associateElasticIps" + ) + } + if (opts.elasticIpIds === undefined || opts.elasticIpIds === null) { + throw new Error( + "Missing the required parameter 'opts.elasticIpIds' when calling associateElasticIps" + ) + } + + let postBody = {} + if (opts.elasticIpIds !== undefined && opts.elasticIpIds !== null) { + postBody['elasticIpIds'] = opts.elasticIpIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + natGatewayId: opts.natGatewayId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 associateElasticIps 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}/natGateways/{natGatewayId}:associateElasticIps', + '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) + } + ) + } + + /** + * 解绑NAT网关上的公网IP接口 + * @param {Object} opts - parameters + * @param {string} opts.natGatewayId - natGateway ID + * @param {array} [opts.elasticIpIds] - 公网IP ID,当为弹性公网IP时,为elasticIpId。 optional + * @param {boolean} [opts.deleteElasticIp] - 解绑后是否删除公网IP,取值范围:true、false,默认为false.true表示解绑公网IP时删除该公网IP;false表示解绑公网IP时不删除公网IP optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param failedIp failedList + */ + + disassociateElasticIps (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 disassociateElasticIps" + ) + } + + opts = opts || {} + + if (opts.natGatewayId === undefined || opts.natGatewayId === null) { + throw new Error( + "Missing the required parameter 'opts.natGatewayId' when calling disassociateElasticIps" + ) + } + + let postBody = {} + if (opts.elasticIpIds !== undefined && opts.elasticIpIds !== null) { + postBody['elasticIpIds'] = opts.elasticIpIds + } + if (opts.deleteElasticIp !== undefined && opts.deleteElasticIp !== null) { + postBody['deleteElasticIp'] = opts.deleteElasticIp + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + natGatewayId: opts.natGatewayId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 disassociateElasticIps 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}/natGateways/{natGatewayId}:disassociateElasticIps', + '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) + } + ) + } + + /** + * 设置NAT网关已绑定的公网IP状态接口 + * @param {Object} opts - parameters + * @param {string} opts.natGatewayId - natGateway ID + * @param {array} [opts.elasticIpIds] - 公网IP列表 optional + * @param {string} opts.status - 公网ip状态,取值范围:online、offline。online表示将NAT绑定的公网IP上线,上线后公网IP可正常转发流量;offline表示将NAT绑定的公网IP下线,下线后,公网IP将不再接受新建连接,已有连接将继续转发流量,从而实现公网IP平滑下线。已下线的公网IP不会自动从NAT网关解绑,如需解绑请执行解绑操作 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + setElasticIpStatus (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 setElasticIpStatus" + ) + } + + opts = opts || {} + + if (opts.natGatewayId === undefined || opts.natGatewayId === null) { + throw new Error( + "Missing the required parameter 'opts.natGatewayId' when calling setElasticIpStatus" + ) + } + if (opts.status === undefined || opts.status === null) { + throw new Error( + "Missing the required parameter 'opts.status' when calling setElasticIpStatus" + ) + } + + let postBody = {} + if (opts.elasticIpIds !== undefined && opts.elasticIpIds !== null) { + postBody['elasticIpIds'] = opts.elasticIpIds + } + if (opts.status !== undefined && opts.status !== null) { + postBody['status'] = opts.status + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + natGatewayId: opts.natGatewayId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 setElasticIpStatus 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}/natGateways/{natGatewayId}:setElasticIpStatus', + '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) + } + ) + } + + /** + * 查询Acl列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞), 页码超过总页数时, 显示最后一页 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {filter} [opts.filters] - networkAclIds - networkAcl ID列表,支持多个 +networkAclNames - networkAcl名称列表,支持多个 +vpcId - networkAcl所属vpc Id,支持单个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param networkAcl networkAcls + * @param number totalCount 总数量 + */ + + describeNetworkAcls (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 describeNetworkAcls" + ) + } + + 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 vpc/1.1.5' + } + + 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 describeNetworkAcls 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}/networkAcls/', + '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) + } + ) + } + + /** + * 创建networkAcl接口 + * @param {Object} opts - parameters + * @param {string} opts.vpcId - 私有网络id + * @param {string} opts.networkAclName - networkAcl名称 + * @param {string} [opts.description] - 描述,允许输入UTF-8编码下的全部字符,不超过256字符 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string networkAclId networkAcl ID + */ + + createNetworkAcl (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 createNetworkAcl" + ) + } + + opts = opts || {} + + if (opts.vpcId === undefined || opts.vpcId === null) { + throw new Error( + "Missing the required parameter 'opts.vpcId' when calling createNetworkAcl" + ) + } + if (opts.networkAclName === undefined || opts.networkAclName === null) { + throw new Error( + "Missing the required parameter 'opts.networkAclName' when calling createNetworkAcl" + ) + } + + let postBody = {} + if (opts.vpcId !== undefined && opts.vpcId !== null) { + postBody['vpcId'] = opts.vpcId + } + if (opts.networkAclName !== undefined && opts.networkAclName !== null) { + postBody['networkAclName'] = opts.networkAclName + } + 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 vpc/1.1.5' + } + + 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 createNetworkAcl 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}/networkAcls/', + '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) + } + ) + } + + /** + * 查询networkAcl资源详情 + * @param {Object} opts - parameters + * @param {string} opts.networkAclId - networkAclId ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param networkAcl networkAcl networkAcl资源信息 + */ + + describeNetworkAcl (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 describeNetworkAcl" + ) + } + + opts = opts || {} + + if (opts.networkAclId === undefined || opts.networkAclId === null) { + throw new Error( + "Missing the required parameter 'opts.networkAclId' when calling describeNetworkAcl" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + networkAclId: opts.networkAclId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 describeNetworkAcl 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}/networkAcls/{networkAclId}', + '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) + } + ) + } + + /** + * 修改networkAcl接口 + * @param {Object} opts - parameters + * @param {string} opts.networkAclId - networkAclId ID + * @param {string} [opts.networkAclName] - networkAcl名称,只允许输入中文、数字、大小写字母、英文下划线“_”及中划线“-”,不允许为空且不超过32字符 optional + * @param {string} [opts.description] - 描述,允许输入UTF-8编码下的全部字符,不超过256字符 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyNetworkAcl (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 modifyNetworkAcl" + ) + } + + opts = opts || {} + + if (opts.networkAclId === undefined || opts.networkAclId === null) { + throw new Error( + "Missing the required parameter 'opts.networkAclId' when calling modifyNetworkAcl" + ) + } + + let postBody = {} + if (opts.networkAclName !== undefined && opts.networkAclName !== null) { + postBody['networkAclName'] = opts.networkAclName + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + networkAclId: opts.networkAclId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 modifyNetworkAcl 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}/networkAcls/{networkAclId}', + 'PATCH', + 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) + } + ) + } + + /** + * 删除networkAcl接口 + * @param {Object} opts - parameters + * @param {string} opts.networkAclId - networkAclId ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteNetworkAcl (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 deleteNetworkAcl" + ) + } + + opts = opts || {} + + if (opts.networkAclId === undefined || opts.networkAclId === null) { + throw new Error( + "Missing the required parameter 'opts.networkAclId' when calling deleteNetworkAcl" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + networkAclId: opts.networkAclId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 deleteNetworkAcl 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}/networkAcls/{networkAclId}', + '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) + } + ) + } + + /** + * 给子网绑定networkAcl接口 + * @param {Object} opts - parameters + * @param {string} opts.networkAclId - networkAclId ID + * @param {array} opts.subnetIds - networkAcl要绑定的子网ID列表, subnet已被其他networkAcl绑定时,自动解绑 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + associateNetworkAcl (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 associateNetworkAcl" + ) + } + + opts = opts || {} + + if (opts.networkAclId === undefined || opts.networkAclId === null) { + throw new Error( + "Missing the required parameter 'opts.networkAclId' when calling associateNetworkAcl" + ) + } + if (opts.subnetIds === undefined || opts.subnetIds === null) { + throw new Error( + "Missing the required parameter 'opts.subnetIds' when calling associateNetworkAcl" + ) + } + + let postBody = {} + if (opts.subnetIds !== undefined && opts.subnetIds !== null) { + postBody['subnetIds'] = opts.subnetIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + networkAclId: opts.networkAclId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 associateNetworkAcl 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}/networkAcls/{networkAclId}:associateNetworkAcl', + '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) + } + ) + } + + /** + * 给子网解绑NetworkAcl接口 + * @param {Object} opts - parameters + * @param {string} opts.networkAclId - networkAclId ID + * @param {string} opts.subnetId - networkAcl要解绑的子网ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + disassociateNetworkAcl (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 disassociateNetworkAcl" + ) + } + + opts = opts || {} + + if (opts.networkAclId === undefined || opts.networkAclId === null) { + throw new Error( + "Missing the required parameter 'opts.networkAclId' when calling disassociateNetworkAcl" + ) + } + if (opts.subnetId === undefined || opts.subnetId === null) { + throw new Error( + "Missing the required parameter 'opts.subnetId' when calling disassociateNetworkAcl" + ) + } + + let postBody = {} + if (opts.subnetId !== undefined && opts.subnetId !== null) { + postBody['subnetId'] = opts.subnetId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + networkAclId: opts.networkAclId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 disassociateNetworkAcl 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}/networkAcls/{networkAclId}:disassociateNetworkAcl', + '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) + } + ) + } + + /** + * 添加networkAcl规则接口 + * @param {Object} opts - parameters + * @param {string} opts.networkAclId - networkAclId ID + * @param {array} [opts.networkAclRuleSpecs] - networkAcl规则列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + addNetworkAclRules (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 addNetworkAclRules" + ) + } + + opts = opts || {} + + if (opts.networkAclId === undefined || opts.networkAclId === null) { + throw new Error( + "Missing the required parameter 'opts.networkAclId' when calling addNetworkAclRules" + ) + } + + let postBody = {} + if ( + opts.networkAclRuleSpecs !== undefined && + opts.networkAclRuleSpecs !== null + ) { + postBody['networkAclRuleSpecs'] = opts.networkAclRuleSpecs + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + networkAclId: opts.networkAclId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 addNetworkAclRules 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}/networkAcls/{networkAclId}:addNetworkAclRules', + '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) + } + ) + } + + /** + * 移除networkAcl规则 + * @param {Object} opts - parameters + * @param {string} opts.networkAclId - networkAclId ID + * @param {array} opts.ruleIds - networkAcl规则ID列表 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + removeNetworkAclRules (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 removeNetworkAclRules" + ) + } + + opts = opts || {} + + if (opts.networkAclId === undefined || opts.networkAclId === null) { + throw new Error( + "Missing the required parameter 'opts.networkAclId' when calling removeNetworkAclRules" + ) + } + if (opts.ruleIds === undefined || opts.ruleIds === null) { + throw new Error( + "Missing the required parameter 'opts.ruleIds' when calling removeNetworkAclRules" + ) + } + + let postBody = {} + if (opts.ruleIds !== undefined && opts.ruleIds !== null) { + postBody['ruleIds'] = opts.ruleIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + networkAclId: opts.networkAclId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 removeNetworkAclRules 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}/networkAcls/{networkAclId}:removeNetworkAclRules', + '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) + } + ) + } + + /** + * 修改networkAcl接口 + * @param {Object} opts - parameters + * @param {string} opts.networkAclId - networkAclId ID + * @param {array} [opts.modifyNetworkAclRuleSpecs] - networkAcl规则列表 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyNetworkAclRules (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 modifyNetworkAclRules" + ) + } + + opts = opts || {} + + if (opts.networkAclId === undefined || opts.networkAclId === null) { + throw new Error( + "Missing the required parameter 'opts.networkAclId' when calling modifyNetworkAclRules" + ) + } + + let postBody = {} + if ( + opts.modifyNetworkAclRuleSpecs !== undefined && + opts.modifyNetworkAclRuleSpecs !== null + ) { + postBody['modifyNetworkAclRuleSpecs'] = opts.modifyNetworkAclRuleSpecs + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + networkAclId: opts.networkAclId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 modifyNetworkAclRules 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}/networkAcls/{networkAclId}:modifyNetworkAclRules', + '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.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 (受管网卡),支持多个 +azType - 网卡 az类型,取值:all(全部类型),standard(标准Az网卡),edge(边缘Az网卡),默认为all,支持单个 +azs - 可用区 az名,支持多个 + 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 vpc/1.1.5' + } + + 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}/networkInterfaces/', + '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 vpc/1.1.5' + } + + 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}/networkInterfaces/', + '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 vpc/1.1.5' + } + + 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}/networkInterfaces/{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} [opts.networkInterfaceName] - 弹性网卡名称,只允许输入中文、数字、大小写字母、英文下划线“_”及中划线“-”,不允许为空且不超过32字符 optional + * @param {string} [opts.description] - 描述,允许输入UTF-8编码下的全部字符,不超过256字符 optional + * @param {array} [opts.securityGroups] - 以覆盖原有安全组的方式更新的安全组。如果更新安全组ID列表,最多5个安全组 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyNetworkInterface (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 modifyNetworkInterface" + ) + } + + opts = opts || {} + + if ( + opts.networkInterfaceId === undefined || + opts.networkInterfaceId === null + ) { + throw new Error( + "Missing the required parameter 'opts.networkInterfaceId' when calling modifyNetworkInterface" + ) + } + + let postBody = {} + if ( + opts.networkInterfaceName !== undefined && + opts.networkInterfaceName !== null + ) { + postBody['networkInterfaceName'] = opts.networkInterfaceName + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.securityGroups !== undefined && opts.securityGroups !== null) { + postBody['securityGroups'] = opts.securityGroups + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + networkInterfaceId: opts.networkInterfaceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 modifyNetworkInterface 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}/networkInterfaces/{networkInterfaceId}', + 'PATCH', + 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 vpc/1.1.5' + } + + 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}/networkInterfaces/{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) + } + ) + } + + /** + * 给网卡绑定弹性Ip接口 + * @param {Object} opts - parameters + * @param {string} opts.networkInterfaceId - networkInterface ID + * @param {string} [opts.elasticIpId] - 绑定的弹性Ip Id optional + * @param {string} [opts.privateIpAddress] - 绑定弹性Ip到指定的privateIp optional + * @param {string} [opts.elasticIpAddress] - 绑定的弹性Ip地址 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + associateElasticIp (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 associateElasticIp" + ) + } + + opts = opts || {} + + if ( + opts.networkInterfaceId === undefined || + opts.networkInterfaceId === null + ) { + throw new Error( + "Missing the required parameter 'opts.networkInterfaceId' when calling associateElasticIp" + ) + } + + let postBody = {} + if (opts.elasticIpId !== undefined && opts.elasticIpId !== null) { + postBody['elasticIpId'] = opts.elasticIpId + } + if (opts.privateIpAddress !== undefined && opts.privateIpAddress !== null) { + postBody['privateIpAddress'] = opts.privateIpAddress + } + if (opts.elasticIpAddress !== undefined && opts.elasticIpAddress !== null) { + postBody['elasticIpAddress'] = opts.elasticIpAddress + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + networkInterfaceId: opts.networkInterfaceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 associateElasticIp 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}/networkInterfaces/{networkInterfaceId}:associateElasticIp', + '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) + } + ) + } + + /** + * 给网卡解绑弹性Ip接口 + * @param {Object} opts - parameters + * @param {string} opts.networkInterfaceId - networkInterface ID + * @param {string} [opts.elasticIpId] - 指定解绑的弹性Ip Id optional + * @param {string} [opts.elasticIpAddress] - 指定解绑的弹性Ip地址 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + disassociateElasticIp (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 disassociateElasticIp" + ) + } + + opts = opts || {} + + if ( + opts.networkInterfaceId === undefined || + opts.networkInterfaceId === null + ) { + throw new Error( + "Missing the required parameter 'opts.networkInterfaceId' when calling disassociateElasticIp" + ) + } + + let postBody = {} + if (opts.elasticIpId !== undefined && opts.elasticIpId !== null) { + postBody['elasticIpId'] = opts.elasticIpId + } + if (opts.elasticIpAddress !== undefined && opts.elasticIpAddress !== null) { + postBody['elasticIpAddress'] = opts.elasticIpAddress + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + networkInterfaceId: opts.networkInterfaceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 disassociateElasticIp 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}/networkInterfaces/{networkInterfaceId}:disassociateElasticIp', + '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 {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 vpc/1.1.5' + } + + 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}/networkInterfaces/{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 vpc/1.1.5' + } + + 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}/networkInterfaces/{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 {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞), 页码超过总页数时, 显示最后一页 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {filter} [opts.filters] - networkSecurityGroupIds - 安全组ID列表,支持多个 +networkSecurityGroupNames - 安全组名称列表,支持多个 +vpcId - 安全组所属vpc Id,支持单个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param networkSecurityGroup networkSecurityGroups + * @param number totalCount 总数量 + */ + + describeNetworkSecurityGroups ( + 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 describeNetworkSecurityGroups" + ) + } + + 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 vpc/1.1.5' + } + + 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 describeNetworkSecurityGroups 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}/networkSecurityGroups/', + '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 - 私有网络ID + * @param {string} opts.networkSecurityGroupName - 安全组名称,只允许输入中文、数字、大小写字母、英文下划线“_”及中划线“-”,不允许为空且不超过32字符。 + * @param {string} [opts.description] - 描述,​ 允许输入UTF-8编码下的全部字符,不超过256字符 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string networkSecurityGroupId 安全组ID + */ + + createNetworkSecurityGroup (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 createNetworkSecurityGroup" + ) + } + + opts = opts || {} + + if (opts.vpcId === undefined || opts.vpcId === null) { + throw new Error( + "Missing the required parameter 'opts.vpcId' when calling createNetworkSecurityGroup" + ) + } + if ( + opts.networkSecurityGroupName === undefined || + opts.networkSecurityGroupName === null + ) { + throw new Error( + "Missing the required parameter 'opts.networkSecurityGroupName' when calling createNetworkSecurityGroup" + ) + } + + let postBody = {} + if (opts.vpcId !== undefined && opts.vpcId !== null) { + postBody['vpcId'] = opts.vpcId + } + if ( + opts.networkSecurityGroupName !== undefined && + opts.networkSecurityGroupName !== null + ) { + postBody['networkSecurityGroupName'] = opts.networkSecurityGroupName + } + 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 vpc/1.1.5' + } + + 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 createNetworkSecurityGroup 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}/networkSecurityGroups/', + '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.networkSecurityGroupId - NetworkSecurityGroup ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param networkSecurityGroup networkSecurityGroup 安全组资源信息 + */ + + describeNetworkSecurityGroup ( + 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 describeNetworkSecurityGroup" + ) + } + + opts = opts || {} + + if ( + opts.networkSecurityGroupId === undefined || + opts.networkSecurityGroupId === null + ) { + throw new Error( + "Missing the required parameter 'opts.networkSecurityGroupId' when calling describeNetworkSecurityGroup" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + networkSecurityGroupId: opts.networkSecurityGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 describeNetworkSecurityGroup 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}/networkSecurityGroups/{networkSecurityGroupId}', + '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.networkSecurityGroupId - NetworkSecurityGroup ID + * @param {string} [opts.networkSecurityGroupName] - 安全组的名字。名称取值范围:1-32个中文、英文大小写的字母、数字和下划线分隔符 optional + * @param {string} [opts.description] - 安全组的描述,取值范围:0-256个UTF-8编码下的全部字符 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyNetworkSecurityGroup (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 modifyNetworkSecurityGroup" + ) + } + + opts = opts || {} + + if ( + opts.networkSecurityGroupId === undefined || + opts.networkSecurityGroupId === null + ) { + throw new Error( + "Missing the required parameter 'opts.networkSecurityGroupId' when calling modifyNetworkSecurityGroup" + ) + } + + let postBody = {} + if ( + opts.networkSecurityGroupName !== undefined && + opts.networkSecurityGroupName !== null + ) { + postBody['networkSecurityGroupName'] = opts.networkSecurityGroupName + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + networkSecurityGroupId: opts.networkSecurityGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 modifyNetworkSecurityGroup 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}/networkSecurityGroups/{networkSecurityGroupId}', + 'PATCH', + 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.networkSecurityGroupId - NetworkSecurityGroup ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteNetworkSecurityGroup (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 deleteNetworkSecurityGroup" + ) + } + + opts = opts || {} + + if ( + opts.networkSecurityGroupId === undefined || + opts.networkSecurityGroupId === null + ) { + throw new Error( + "Missing the required parameter 'opts.networkSecurityGroupId' when calling deleteNetworkSecurityGroup" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + networkSecurityGroupId: opts.networkSecurityGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 deleteNetworkSecurityGroup 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}/networkSecurityGroups/{networkSecurityGroupId}', + '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.networkSecurityGroupId - NetworkSecurityGroup ID + * @param {array} [opts.networkSecurityGroupRuleSpecs] - 安全组规则信息 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param securityGroupRule securityGroupRules + */ + + addNetworkSecurityGroupRules ( + 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 addNetworkSecurityGroupRules" + ) + } + + opts = opts || {} + + if ( + opts.networkSecurityGroupId === undefined || + opts.networkSecurityGroupId === null + ) { + throw new Error( + "Missing the required parameter 'opts.networkSecurityGroupId' when calling addNetworkSecurityGroupRules" + ) + } + + let postBody = {} + if ( + opts.networkSecurityGroupRuleSpecs !== undefined && + opts.networkSecurityGroupRuleSpecs !== null + ) { + postBody['networkSecurityGroupRuleSpecs'] = + opts.networkSecurityGroupRuleSpecs + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + networkSecurityGroupId: opts.networkSecurityGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 addNetworkSecurityGroupRules 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}/networkSecurityGroups/{networkSecurityGroupId}:addNetworkSecurityGroupRules', + '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.networkSecurityGroupId - NetworkSecurityGroup ID + * @param {array} opts.ruleIds - 安全组规则Id列表 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + removeNetworkSecurityGroupRules ( + 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 removeNetworkSecurityGroupRules" + ) + } + + opts = opts || {} + + if ( + opts.networkSecurityGroupId === undefined || + opts.networkSecurityGroupId === null + ) { + throw new Error( + "Missing the required parameter 'opts.networkSecurityGroupId' when calling removeNetworkSecurityGroupRules" + ) + } + if (opts.ruleIds === undefined || opts.ruleIds === null) { + throw new Error( + "Missing the required parameter 'opts.ruleIds' when calling removeNetworkSecurityGroupRules" + ) + } + + let postBody = {} + if (opts.ruleIds !== undefined && opts.ruleIds !== null) { + postBody['ruleIds'] = opts.ruleIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + networkSecurityGroupId: opts.networkSecurityGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 removeNetworkSecurityGroupRules 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}/networkSecurityGroups/{networkSecurityGroupId}:removeNetworkSecurityGroupRules', + '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.networkSecurityGroupId - NetworkSecurityGroup ID + * @param {array} [opts.modifySecurityGroupRuleSpecs] - 安全组规则信息 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyNetworkSecurityGroupRules ( + 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 modifyNetworkSecurityGroupRules" + ) + } + + opts = opts || {} + + if ( + opts.networkSecurityGroupId === undefined || + opts.networkSecurityGroupId === null + ) { + throw new Error( + "Missing the required parameter 'opts.networkSecurityGroupId' when calling modifyNetworkSecurityGroupRules" + ) + } + + let postBody = {} + if ( + opts.modifySecurityGroupRuleSpecs !== undefined && + opts.modifySecurityGroupRuleSpecs !== null + ) { + postBody['modifySecurityGroupRuleSpecs'] = + opts.modifySecurityGroupRuleSpecs + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + networkSecurityGroupId: opts.networkSecurityGroupId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 modifyNetworkSecurityGroupRules 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}/networkSecurityGroups/{networkSecurityGroupId}:modifyNetworkSecurityGroupRules', + '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.type - 资源类型,取值范围:vpc、elastic_ip、subnet、security_group、vpcpeering、network_interface(配额只统计辅助网卡)、acl、aclRule、routeTable、staticRoute、propagatedRoute、securityGroupRule、network_interface_cidr、bwpByUsage、bandwidthPackageIp、natGateway、natGatewayFip、trafficMirrorSession、trafficMirrorFilter、trafficMirrorFilterRule、trafficMirrorSource,haVip,haVipBinding + * @param {string} [opts.parentResourceId] - type为vpc、elastic_ip、network_interface、bwpByUsage、natGateway、trafficMirrorSession、trafficMirrorFilter不设置, type为subnet、security_group、vpcpeering、acl、routeTable设置为vpcId, type为aclRule设置为aclId, type为staticRoute、propagatedRoute设置为routeTableId, type为securityGroupRule为securityGroupId, type为network_interface_cidr设置为networkInterfaceId,type为bandwidthPackageIp设置为bandwidthPackageId,natGatewayFip设置为natGatewayId,trafficMirrorFilterRule设置为trafficMirrorFilterId,trafficMirrorSource设置为trafficMirrorSessionId,haVip设置为vpcId,haVipBinding设置为haVipId optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param object quota + */ + + describeQuota (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 describeQuota" + ) + } + + opts = opts || {} + + if (opts.type === undefined || opts.type === null) { + throw new Error( + "Missing the required parameter 'opts.type' when calling describeQuota" + ) + } + + let postBody = null + let queryParams = {} + if (opts.type !== undefined && opts.type !== null) { + queryParams['type'] = opts.type + } + if (opts.parentResourceId !== undefined && opts.parentResourceId !== null) { + queryParams['parentResourceId'] = opts.parentResourceId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 describeQuota 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}/quotas/', + '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 {filter} [opts.filters] - routeTableIds - 路由表ID列表,支持多个 +routeTableNames - 路由表名称列表,支持多个 +vpcId - 路由表所属vpc Id,支持单个 +azType - 路由表az类型,取值:all(全部类型),standard(标准路由表),edge(边缘路由表),默认standard ,支持单个 +associateType - 绑定资源类型,取值:subnet,gateway,支持单个 +azs - 可用区,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param routeTable routeTables + * @param number totalCount 总数量 + */ + + describeRouteTables (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 describeRouteTables" + ) + } + + 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 vpc/1.1.5' + } + + 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 describeRouteTables 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}/routeTables/', + '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 - 路由表所属的私有网络ID + * @param {string} opts.routeTableName - 路由表名称,只允许输入中文、数字、大小写字母、英文下划线“_”及中划线“-”,不允许为空且不超过32字符。 + * @param {string} [opts.description] - 描述,允许输入UTF-8编码下的全部字符,不超过256字符 optional + * @param {string} [opts.associateType] - 绑定资源类型,取值:subnet(缺省时默认值),gateway optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string routeTableId 路由表ID + */ + + createRouteTable (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 createRouteTable" + ) + } + + opts = opts || {} + + if (opts.vpcId === undefined || opts.vpcId === null) { + throw new Error( + "Missing the required parameter 'opts.vpcId' when calling createRouteTable" + ) + } + if (opts.routeTableName === undefined || opts.routeTableName === null) { + throw new Error( + "Missing the required parameter 'opts.routeTableName' when calling createRouteTable" + ) + } + + let postBody = {} + if (opts.vpcId !== undefined && opts.vpcId !== null) { + postBody['vpcId'] = opts.vpcId + } + if (opts.routeTableName !== undefined && opts.routeTableName !== null) { + postBody['routeTableName'] = opts.routeTableName + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.associateType !== undefined && opts.associateType !== null) { + postBody['associateType'] = opts.associateType + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 createRouteTable 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}/routeTables/', + '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.routeTableId - RouteTable ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param routeTable routeTable 路由表资源信息 + */ + + describeRouteTable (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 describeRouteTable" + ) + } + + opts = opts || {} + + if (opts.routeTableId === undefined || opts.routeTableId === null) { + throw new Error( + "Missing the required parameter 'opts.routeTableId' when calling describeRouteTable" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + routeTableId: opts.routeTableId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 describeRouteTable 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}/routeTables/{routeTableId}', + '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.routeTableId - RouteTable ID + * @param {string} [opts.routeTableName] - 路由表的名字。名称取值范围:1-32个中文、英文大小写的字母、数字和下划线分隔符 optional + * @param {string} [opts.description] - 路由表的描述,取值范围:0-256个UTF-8编码下的全部字符 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyRouteTable (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 modifyRouteTable" + ) + } + + opts = opts || {} + + if (opts.routeTableId === undefined || opts.routeTableId === null) { + throw new Error( + "Missing the required parameter 'opts.routeTableId' when calling modifyRouteTable" + ) + } + + let postBody = {} + if (opts.routeTableName !== undefined && opts.routeTableName !== null) { + postBody['routeTableName'] = opts.routeTableName + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + routeTableId: opts.routeTableId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 modifyRouteTable 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}/routeTables/{routeTableId}', + 'PATCH', + 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.routeTableId - RouteTable ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteRouteTable (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 deleteRouteTable" + ) + } + + opts = opts || {} + + if (opts.routeTableId === undefined || opts.routeTableId === null) { + throw new Error( + "Missing the required parameter 'opts.routeTableId' when calling deleteRouteTable" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + routeTableId: opts.routeTableId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 deleteRouteTable 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}/routeTables/{routeTableId}', + '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.routeTableId - RouteTable ID + * @param {array} [opts.routeTableRuleSpecs] - 路由表规则信息 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + addRouteTableRules (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 addRouteTableRules" + ) + } + + opts = opts || {} + + if (opts.routeTableId === undefined || opts.routeTableId === null) { + throw new Error( + "Missing the required parameter 'opts.routeTableId' when calling addRouteTableRules" + ) + } + + let postBody = {} + if ( + opts.routeTableRuleSpecs !== undefined && + opts.routeTableRuleSpecs !== null + ) { + postBody['routeTableRuleSpecs'] = opts.routeTableRuleSpecs + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + routeTableId: opts.routeTableId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 addRouteTableRules 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}/routeTables/{routeTableId}:addRouteTableRules', + '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.routeTableId - RouteTable ID + * @param {array} opts.ruleIds - 路由表规则Id列表 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + removeRouteTableRules (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 removeRouteTableRules" + ) + } + + opts = opts || {} + + if (opts.routeTableId === undefined || opts.routeTableId === null) { + throw new Error( + "Missing the required parameter 'opts.routeTableId' when calling removeRouteTableRules" + ) + } + if (opts.ruleIds === undefined || opts.ruleIds === null) { + throw new Error( + "Missing the required parameter 'opts.ruleIds' when calling removeRouteTableRules" + ) + } + + let postBody = {} + if (opts.ruleIds !== undefined && opts.ruleIds !== null) { + postBody['ruleIds'] = opts.ruleIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + routeTableId: opts.routeTableId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 removeRouteTableRules 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}/routeTables/{routeTableId}:removeRouteTableRules', + '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.routeTableId - RouteTable ID + * @param {array} [opts.modifyRouteTableRuleSpecs] - 路由表规则信息 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyRouteTableRules (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 modifyRouteTableRules" + ) + } + + opts = opts || {} + + if (opts.routeTableId === undefined || opts.routeTableId === null) { + throw new Error( + "Missing the required parameter 'opts.routeTableId' when calling modifyRouteTableRules" + ) + } + + let postBody = {} + if ( + opts.modifyRouteTableRuleSpecs !== undefined && + opts.modifyRouteTableRuleSpecs !== null + ) { + postBody['modifyRouteTableRuleSpecs'] = opts.modifyRouteTableRuleSpecs + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + routeTableId: opts.routeTableId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 modifyRouteTableRules 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}/routeTables/{routeTableId}:modifyRouteTableRules', + '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.routeTableId - RouteTable ID + * @param {array} [opts.subnetIds] - 路由表要绑定的子网ID列表, 只有associateType是subnet类型的路由表才支持绑定;subnet已被其他路由表绑定时,自动解绑。路由表绑定的子网属性要相同,或者都是标准子网,或者都是相同边缘可用区的边缘子网。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + associateRouteTable (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 associateRouteTable" + ) + } + + opts = opts || {} + + if (opts.routeTableId === undefined || opts.routeTableId === null) { + throw new Error( + "Missing the required parameter 'opts.routeTableId' when calling associateRouteTable" + ) + } + + let postBody = {} + if (opts.subnetIds !== undefined && opts.subnetIds !== null) { + postBody['subnetIds'] = opts.subnetIds + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + routeTableId: opts.routeTableId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 associateRouteTable 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}/routeTables/{routeTableId}:associateRouteTable', + '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.routeTableId - RouteTable ID + * @param {string} opts.subnetId - 路由表要解绑的子网ID,解绑后子网绑定默认路由表 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + disassociateRouteTable (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 disassociateRouteTable" + ) + } + + opts = opts || {} + + if (opts.routeTableId === undefined || opts.routeTableId === null) { + throw new Error( + "Missing the required parameter 'opts.routeTableId' when calling disassociateRouteTable" + ) + } + if (opts.subnetId === undefined || opts.subnetId === null) { + throw new Error( + "Missing the required parameter 'opts.subnetId' when calling disassociateRouteTable" + ) + } + + let postBody = {} + if (opts.subnetId !== undefined && opts.subnetId !== null) { + postBody['subnetId'] = opts.subnetId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + routeTableId: opts.routeTableId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 disassociateRouteTable 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}/routeTables/{routeTableId}:disassociateRouteTable', + '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) + } + ) + } + + /** + * 查询边缘公网IP可用线路列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞), 页码超过总页数时, 显示最后一页 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {filter} [opts.filters] - providers - 边缘公网IP的线路,命名规则:[线路接入区].[资源关联范围].[服务类型],示例如cn-n1-jinan1.ez.bgp,支持多个 +pointsOfAccess - 边缘公网IP的线路接入区,提供线路接入区具体位置信息,支持多个 +associationScope - 边缘公网IP的资源关联范围,取值ez(边缘可用区)和az(中心可用区,暂不支持),支持单个 +serviceTypes - 边缘公网IP的服务类型,取值:bgp(动态),unicom(联通),telecom(电信),mobile(移动),支持多个 +azs - 边缘公网IP的可用区,分为全可用区(暂不支持)和边缘可用区ID(同线路接入区]),示例如cn-n1-sqxx1,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param edgeIpProvider edgeIpProviders + * @param integer totalCount 总数量 + */ + + describeEdgeIpProviders (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 describeEdgeIpProviders" + ) + } + + 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 vpc/1.1.5' + } + + 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 describeEdgeIpProviders 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}/edgeIpProviders/', + '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 {filter} [opts.filters] - subnetIds - subnet ID列表,支持多个 +subnetNames - subnet名称列表,支持多个 +routeTableId - 子网关联路由表Id,支持单个 +aclId - 子网关联acl Id,支持单个 +vpcId - 子网所属VPC Id,支持单个 +subnetType - 子网类型,取值:all(全部类型),standard(标准子网),edge(边缘子网),默认standard ,支持单个 +azs - 可用区,支持多个 +azType - VPC az类型,取值:all(全部类型),standard(标准可用区子网),edge(边缘可用区子网),默认all,支持单个 + 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 + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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}/subnets/', + '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 vpc/1.1.5' + } + + 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}/subnets/', + '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 vpc/1.1.5' + } + + 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}/subnets/{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} [opts.subnetName] - 子网名称,只允许输入中文、数字、大小写字母、英文下划线“_”及中划线“-”,不允许为空且不超过32字符。 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 {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifySubnet (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 modifySubnet" + ) + } + + opts = opts || {} + + if (opts.subnetId === undefined || opts.subnetId === null) { + throw new Error( + "Missing the required parameter 'opts.subnetId' when calling modifySubnet" + ) + } + + let postBody = {} + if (opts.subnetName !== undefined && opts.subnetName !== null) { + postBody['subnetName'] = opts.subnetName + } + 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 + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + subnetId: opts.subnetId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 modifySubnet 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}/subnets/{subnetId}', + 'PATCH', + 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 vpc/1.1.5' + } + + 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}/subnets/{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) + } + ) + } + + /** + * 查询私有网络列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞), 页码超过总页数时, 显示最后一页 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {filter} [opts.filters] - vpcIds - vpc ID列表,支持多个 +vpcNames - vpc名称列表,支持多个 +azType - VPC az类型,取值:all(全部类型),standard(标准VPC),edge(边缘VPC),默认all,支持单个 +azs - 可用区,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param vpc vpcs + * @param number totalCount 总数量 + */ + + describeVpcs (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 describeVpcs" + ) + } + + 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 vpc/1.1.5' + } + + 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 describeVpcs 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}/vpcs/', + '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.vpcName - 私有网络名称,只允许输入中文、数字、大小写字母、英文下划线“_”及中划线“-”,不允许为空且不超过32字符。 + * @param {string} [opts.addressPrefix] - 如果为空,则不限制网段,如果不为空,10.0.0.0/8、172.16.0.0/12和192.168.0.0/16及它们包含的子网,且子网掩码长度为16-28之间 optional + * @param {string} [opts.description] - vpc描述,允许输入UTF-8编码下的全部字符,不超过256字符。 optional + * @param {boolean} [opts.enableMulticast] - 取值包括true、false,默认为false,不开启组播。 optional + * @param {string} [opts.azType] - VPC az类型,取值:standard(标准VPC),edge(边缘VPC) optional + * @param {string} [opts.az] - VPC可用区,边缘VPC必须指定可用区 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string vpcId 私有网络ID + */ + + createVpc (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 createVpc" + ) + } + + opts = opts || {} + + if (opts.vpcName === undefined || opts.vpcName === null) { + throw new Error( + "Missing the required parameter 'opts.vpcName' when calling createVpc" + ) + } + + let postBody = {} + if (opts.vpcName !== undefined && opts.vpcName !== null) { + postBody['vpcName'] = opts.vpcName + } + if (opts.addressPrefix !== undefined && opts.addressPrefix !== null) { + postBody['addressPrefix'] = opts.addressPrefix + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.enableMulticast !== undefined && opts.enableMulticast !== null) { + postBody['enableMulticast'] = opts.enableMulticast + } + if (opts.azType !== undefined && opts.azType !== null) { + postBody['azType'] = opts.azType + } + 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 vpc/1.1.5' + } + + 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 createVpc 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}/vpcs/', + '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.vpcId - Vpc ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param vpc vpc Vpc资源信息 + */ + + describeVpc (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 describeVpc" + ) + } + + opts = opts || {} + + if (opts.vpcId === undefined || opts.vpcId === null) { + throw new Error( + "Missing the required parameter 'opts.vpcId' when calling describeVpc" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + vpcId: opts.vpcId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 describeVpc 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}/vpcs/{vpcId}', + '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.vpcName] - 私有网络名称,只允许输入中文、数字、大小写字母、英文下划线“_”及中划线“-”,不允许为空且不超过32字符。 optional + * @param {string} [opts.description] - vpc描述,允许输入UTF-8编码下的全部字符,不超过256字符。 optional + * @param {boolean} [opts.enableMulticast] - 取值包括true、false,默认为false,不开启组播。 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyVpc (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 modifyVpc" + ) + } + + opts = opts || {} + + if (opts.vpcId === undefined || opts.vpcId === null) { + throw new Error( + "Missing the required parameter 'opts.vpcId' when calling modifyVpc" + ) + } + + let postBody = {} + if (opts.vpcName !== undefined && opts.vpcName !== null) { + postBody['vpcName'] = opts.vpcName + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.enableMulticast !== undefined && opts.enableMulticast !== null) { + postBody['enableMulticast'] = opts.enableMulticast + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + vpcId: opts.vpcId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 modifyVpc 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}/vpcs/{vpcId}', + 'PATCH', + 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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteVpc (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 deleteVpc" + ) + } + + opts = opts || {} + + if (opts.vpcId === undefined || opts.vpcId === null) { + throw new Error( + "Missing the required parameter 'opts.vpcId' when calling deleteVpc" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + vpcId: opts.vpcId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 deleteVpc 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}/vpcs/{vpcId}', + '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) + } + ) + } + + /** + * 查询VpcPeering资源列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞), 页码超过总页数时, 显示最后一页 optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {filter} [opts.filters] - vpcPeeringIds - vpcPeering ID,支持多个 +vpcPeeringNames - vpcPeering名称列表,支持多个 +vpcId - vpcPeering本端Vpc Id,支持单个 +remoteVpcId - vpcPeering对端Vpc Id,支持单个 +azType - vpcPeering本端VPC az类型,取值:all(全部类型),standard(标准VPC),edge(边缘VPC),默认standard ,支持单个 +azs - vpcPeering本端VPC可用区,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param vpcPeering vpcPeerings + * @param number totalCount 总数量 + */ + + describeVpcPeerings (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 describeVpcPeerings" + ) + } + + 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 vpc/1.1.5' + } + + 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 describeVpcPeerings 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}/vpcPeerings/', + '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) + } + ) + } + + /** + * 创建VpcPeering接口 + * @param {Object} opts - parameters + * @param {string} opts.vpcPeeringName - VpcPeering的名字,不为空。名称取值范围:1-32个中文、英文大小写的字母、数字和下划线分隔符 + * @param {string} opts.vpcId - VpcPeering本端Vpc的Id + * @param {string} opts.remoteVpcId - VpcPeering对端Vpc的Id + * @param {string} [opts.description] - VpcPeering 描述,取值范围:0-256个中文、英文大小写的字母、数字和下划线分隔符 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param vpcPeering vpcPeering VpcPeering资源信息 + */ + + createVpcPeering (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 createVpcPeering" + ) + } + + opts = opts || {} + + if (opts.vpcPeeringName === undefined || opts.vpcPeeringName === null) { + throw new Error( + "Missing the required parameter 'opts.vpcPeeringName' when calling createVpcPeering" + ) + } + if (opts.vpcId === undefined || opts.vpcId === null) { + throw new Error( + "Missing the required parameter 'opts.vpcId' when calling createVpcPeering" + ) + } + if (opts.remoteVpcId === undefined || opts.remoteVpcId === null) { + throw new Error( + "Missing the required parameter 'opts.remoteVpcId' when calling createVpcPeering" + ) + } + + let postBody = {} + if (opts.vpcPeeringName !== undefined && opts.vpcPeeringName !== null) { + postBody['vpcPeeringName'] = opts.vpcPeeringName + } + if (opts.vpcId !== undefined && opts.vpcId !== null) { + postBody['vpcId'] = opts.vpcId + } + if (opts.remoteVpcId !== undefined && opts.remoteVpcId !== null) { + postBody['remoteVpcId'] = opts.remoteVpcId + } + 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 vpc/1.1.5' + } + + 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 createVpcPeering 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}/vpcPeerings/', + '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) + } + ) + } + + /** + * 查询VpcPeering资源详情 + * @param {Object} opts - parameters + * @param {string} opts.vpcPeeringId - vpcPeeringId ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param vpcPeering vpcPeering VpcPeering资源信息 + */ + + describeVpcPeering (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 describeVpcPeering" + ) + } + + opts = opts || {} + + if (opts.vpcPeeringId === undefined || opts.vpcPeeringId === null) { + throw new Error( + "Missing the required parameter 'opts.vpcPeeringId' when calling describeVpcPeering" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + vpcPeeringId: opts.vpcPeeringId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 describeVpcPeering 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}/vpcPeerings/{vpcPeeringId}', + '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) + } + ) + } + + /** + * 修改VpcPeering接口 + * @param {Object} opts - parameters + * @param {string} opts.vpcPeeringId - vpcPeeringId ID + * @param {string} [opts.vpcPeeringName] - VpcPeering的名字,不为空。名称取值范围:1-32个中文、英文大小写的字母、数字和下划线分隔符 optional + * @param {string} [opts.description] - VpcPeering 描述,取值范围:0-256个中文、英文大小写的字母、数字和下划线分隔符 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyVpcPeering (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 modifyVpcPeering" + ) + } + + opts = opts || {} + + if (opts.vpcPeeringId === undefined || opts.vpcPeeringId === null) { + throw new Error( + "Missing the required parameter 'opts.vpcPeeringId' when calling modifyVpcPeering" + ) + } + + let postBody = {} + if (opts.vpcPeeringName !== undefined && opts.vpcPeeringName !== null) { + postBody['vpcPeeringName'] = opts.vpcPeeringName + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + vpcPeeringId: opts.vpcPeeringId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 modifyVpcPeering 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}/vpcPeerings/{vpcPeeringId}', + '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) + } + ) + } + + /** + * 删除VpcPeering接口 + * @param {Object} opts - parameters + * @param {string} opts.vpcPeeringId - vpcPeeringId ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteVpcPeering (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 deleteVpcPeering" + ) + } + + opts = opts || {} + + if (opts.vpcPeeringId === undefined || opts.vpcPeeringId === null) { + throw new Error( + "Missing the required parameter 'opts.vpcPeeringId' when calling deleteVpcPeering" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + vpcPeeringId: opts.vpcPeeringId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 deleteVpcPeering 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}/vpcPeerings/{vpcPeeringId}', + '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) + } + ) + } + + /** + * 创建VpcPolicy接口 + * @param {Object} opts - parameters + * @param {string} opts.vpcPolicyName - 访问控制策略名称。取值范围:1-32个中文、英文大小写的字母、数字和下划线分隔符 + * @param {string} opts.vpcId - 访问控制策略所属vpc id + * @param {string} opts.policyDocument - 具体策略内容(格式参考样例) + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string vpcPolicyId 访问控制策略ID + */ + + createVpcPolicy (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 createVpcPolicy" + ) + } + + opts = opts || {} + + if (opts.vpcPolicyName === undefined || opts.vpcPolicyName === null) { + throw new Error( + "Missing the required parameter 'opts.vpcPolicyName' when calling createVpcPolicy" + ) + } + if (opts.vpcId === undefined || opts.vpcId === null) { + throw new Error( + "Missing the required parameter 'opts.vpcId' when calling createVpcPolicy" + ) + } + if (opts.policyDocument === undefined || opts.policyDocument === null) { + throw new Error( + "Missing the required parameter 'opts.policyDocument' when calling createVpcPolicy" + ) + } + + let postBody = {} + if (opts.vpcPolicyName !== undefined && opts.vpcPolicyName !== null) { + postBody['vpcPolicyName'] = opts.vpcPolicyName + } + if (opts.vpcId !== undefined && opts.vpcId !== null) { + postBody['vpcId'] = opts.vpcId + } + if (opts.policyDocument !== undefined && opts.policyDocument !== null) { + postBody['policyDocument'] = opts.policyDocument + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 createVpcPolicy 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}/vpcPolicy/', + '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) + } + ) + } + + /** + * 查询VpcPolicy资源详情 + * @param {Object} opts - parameters + * @param {string} opts.vpcPolicyId - policy ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param vpcPolicy vpcPolicy Vpc访问控制策略资源信息 + */ + + describeVpcPolicy (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 describeVpcPolicy" + ) + } + + opts = opts || {} + + if (opts.vpcPolicyId === undefined || opts.vpcPolicyId === null) { + throw new Error( + "Missing the required parameter 'opts.vpcPolicyId' when calling describeVpcPolicy" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + vpcPolicyId: opts.vpcPolicyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 describeVpcPolicy 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}/vpcPolicy/{vpcPolicyId}', + '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) + } + ) + } + + /** + * 修改VPC Policy接口 + * @param {Object} opts - parameters + * @param {string} opts.vpcPolicyId - policy ID + * @param {string} opts.vpcPolicyId - 访问控制策略的Id + * @param {string} [opts.vpcPolicyName] - VpcPolicy的名称,不为空(有变更再传)。取值范围:1-32个中文、英文大小写的字母、数字和下划线分隔符 optional + * @param {string} [opts.policyDocument] - 具体策略内容(格式参考样例) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyVpcPolicy (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 modifyVpcPolicy" + ) + } + + opts = opts || {} + + if (opts.vpcPolicyId === undefined || opts.vpcPolicyId === null) { + throw new Error( + "Missing the required parameter 'opts.vpcPolicyId' when calling modifyVpcPolicy" + ) + } + if (opts.vpcPolicyId === undefined || opts.vpcPolicyId === null) { + throw new Error( + "Missing the required parameter 'opts.vpcPolicyId' when calling modifyVpcPolicy" + ) + } + + let postBody = {} + if (opts.vpcPolicyId !== undefined && opts.vpcPolicyId !== null) { + postBody['vpcPolicyId'] = opts.vpcPolicyId + } + if (opts.vpcPolicyName !== undefined && opts.vpcPolicyName !== null) { + postBody['vpcPolicyName'] = opts.vpcPolicyName + } + if (opts.policyDocument !== undefined && opts.policyDocument !== null) { + postBody['policyDocument'] = opts.policyDocument + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + vpcPolicyId: opts.vpcPolicyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 modifyVpcPolicy 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}/vpcPolicy/{vpcPolicyId}', + 'PATCH', + 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) + } + ) + } + + /** + * 删除VpcPolicy接口 + * @param {Object} opts - parameters + * @param {string} opts.vpcPolicyId - policy ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteVpcPolicy (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 deleteVpcPolicy" + ) + } + + opts = opts || {} + + if (opts.vpcPolicyId === undefined || opts.vpcPolicyId === null) { + throw new Error( + "Missing the required parameter 'opts.vpcPolicyId' when calling deleteVpcPolicy" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + vpcPolicyId: opts.vpcPolicyId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 vpc/1.1.5' + } + + 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 deleteVpcPolicy 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}/vpcPolicy/{vpcPolicyId}', + '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) + } + ) + } +} +module.exports = VPC diff --git a/packages/libs/lib-jdcloud/src/repo/waf/v1/waf.js b/packages/libs/lib-jdcloud/src/repo/waf/v1/waf.js new file mode 100644 index 000000000..c195a5b66 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/waf/v1/waf.js @@ -0,0 +1,4841 @@ +/* + * 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. + * + * Warning + * Warning API + * + * 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 = 'waf' +Service._services[serviceId] = true + +/** + * waf service. + * @version 1.0.8 + */ + +class WAF extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'waf.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 获取回源ip段 + * @param {Object} opts - parameters + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param object list + */ + + describeLbOutIp (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 describeLbOutIp" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 describeLbOutIp 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}/admin:lboutIp', + '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.wafInstanceId - 实例Id + * @param {orderReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string buyId 订单编号 + * @param string wafInstanceId wafInstancdId + * @param string orderNumber orderNumber + */ + + upgradeInstance (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 upgradeInstance" + ) + } + + opts = opts || {} + + if (opts.wafInstanceId === undefined || opts.wafInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.wafInstanceId' when calling upgradeInstance" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling upgradeInstance" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + wafInstanceId: opts.wafInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 upgradeInstance 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}/wafInstanceIds/{wafInstanceId}/billing:upgradeInstance', + '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) + } + ) + } + + /** + * 创建waf实例 + * @param {Object} opts - parameters + * @param {orderReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string buyId buyId + * @param string wafInstanceId wafInstanceId + * @param string orderNumber orderNumber + */ + + createInstance (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 createInstance" + ) + } + + opts = opts || {} + + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling createInstance" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 createInstance 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}/billing:createInstance', + '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.wafInstanceId - 实例Id + * @param {getAvailableCertReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string bindCertId 现绑定证书id + * @param string bindCertName 现绑定证书名称 + * @param string certIds + * @param string certNames + * @param integer count 可用证书个数 + * @param string domain 域名 + */ + + getAvailableCertForDomain (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 getAvailableCertForDomain" + ) + } + + opts = opts || {} + + if (opts.wafInstanceId === undefined || opts.wafInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.wafInstanceId' when calling getAvailableCertForDomain" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling getAvailableCertForDomain" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + wafInstanceId: opts.wafInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 getAvailableCertForDomain 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}/wafInstanceIds/{wafInstanceId}/cert:availableForDomain', + '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.wafInstanceId - 实例Id + * @param {assignCertReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + bindCert (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 bindCert" + ) + } + + opts = opts || {} + + if (opts.wafInstanceId === undefined || opts.wafInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.wafInstanceId' when calling bindCert" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling bindCert" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + wafInstanceId: opts.wafInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 bindCert 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}/wafInstanceIds/{wafInstanceId}/cert:bindCert', + '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) + } + ) + } + + /** + * 获取网站在一定时间内的bps信息。 + * @param {Object} opts - parameters + * @param {getChartReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer timeScope + * @param bps bps bps数据 + */ + + getBpsData (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 getBpsData" + ) + } + + opts = opts || {} + + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling getBpsData" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 getBpsData 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}/chart:getBpsData', + '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) + } + ) + } + + /** + * 获取网站在一定时间内的qps信息。 + * @param {Object} opts - parameters + * @param {getChartReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer timeScope + * @param qps qps qps数据 + */ + + getQpsData (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 getQpsData" + ) + } + + opts = opts || {} + + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling getQpsData" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 getQpsData 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}/chart:getQpsData', + '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 {getStatusCodeReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param statusCodeData statusCodeData 状态码TopN + */ + + getStatusCodeInfo (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 getStatusCodeInfo" + ) + } + + opts = opts || {} + + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling getStatusCodeInfo" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 getStatusCodeInfo 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}/chart:getStatusCodeInfo', + '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) + } + ) + } + + /** + * 获取网站在一定时间内主要的防护信息,新接口,无url响应时间分布。 + * @param {Object} opts - parameters + * @param {getChartReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer ip ip访问量 + * @param integer ipPre 之前ip访问量,当时间跨度大于7天时,该值无意义。 + * @param integer pv PV访问量 + * @param integer pvPre 之前PV访问量,当时间跨度大于7天时,该值无意义。 + * @param integer maxBps 流量峰值 + * @param integer maxBpsPre 之前流量峰值,当时间跨度大于7天时,该值无意义。 + * @param integer wafAnti Web防护攻击数 + * @param integer wafAntiPre 之前Web防护攻击数,当时间跨度大于7天时,该值无意义。 + * @param integer domainCount 防护网站数 + * @param integer aclAnti 自定义规则防护攻击数 + * @param integer aclAntiPre 之前自定义规则防护攻击数 + * @param integer ccAnti cc防护攻击数 + * @param integer ccAntiPre 之前cc防护攻击数 + * @param integer botAnti bot防护攻击数 + * @param integer botAntiPre 之前bot防护攻击数 + */ + + getMainAntiInfoNew (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 getMainAntiInfoNew" + ) + } + + opts = opts || {} + + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling getMainAntiInfoNew" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 getMainAntiInfoNew 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}/chart:getMainAntiInfoNew', + '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.wafInstanceId] - 实例id,代表要查询的WAF实例,为空时表示当前用户下的所有实例 optional + * @param {string} [opts.domain] - 域名,为空时表示当前实例下的所有域名 optional + * @param {string} [opts.remote_addr] - 来源ip,检索字段 optional + * @param {string} [opts.document_uri] - URI,检索字段 optional + * @param {string} [opts.url] - url,检索字段 optional + * @param {string} [opts.anti_geo] - 来源地域,检索字段 optional + * @param {string} [opts.request_method] - 请求方法,检索字段 optional + * @param {string} [opts.action] - 动作,检索字段,支持类型:""(为空时,默认查询全部动作类型),"-"(放行),"notice"(观察),"forbidden OR status"(拦截),"redirect"(浏览器跳转),"verify"(人机交互) optional + * @param {string} [opts.status] - 状态码,检索字段 optional + * @param {string} [opts.logId] - 日志Id,检索字段 optional + * @param {string} [opts.request_id] - 请求Id,检索字段 optional + * @param {integer} opts.start - 开始时间戳,单位秒,时间间隔要求大于5分钟,小于30天。 + * @param {integer} opts.end - 结束时间戳,单位秒,时间间隔要求大于5分钟,小于30天。 + * @param {integer} opts.pageSize - 每页显示的个数,默认是10。 + * @param {integer} opts.pageIndex - 页数,默认是1。 + * @param {string} [opts.logType] - 日志类型,检索字段,支持类型:""(为空时,默认查询全部日志类型),"access"(访问日志),"waf"(wafSDK),"acl"(自定义规则),"skip"(白名单),"deny"(黑名单),"cc"(CC攻击),"webcache"(网页防篡改),"css"(跨站脚本攻击),"sqli"(SQL注入攻击),""fileinc"(文件读取/包含攻击),"cmding"(命令/代码执行攻击),"sdd"(敏感文件探测),"malscan"(恶意扫描攻击),"bckack"(恶意/后门文件攻击),"xmli"(XML注入攻击),"dirt"(目录遍历攻击) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer pageSize 每页显示的个数。 + * @param integer pageIndex 页数。 + * @param integer total 总个数。 + * @param esLogEvent events + */ + + getEsLogDetail (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 getEsLogDetail" + ) + } + + opts = opts || {} + + if (opts.start === undefined || opts.start === null) { + throw new Error( + "Missing the required parameter 'opts.start' when calling getEsLogDetail" + ) + } + if (opts.end === undefined || opts.end === null) { + throw new Error( + "Missing the required parameter 'opts.end' when calling getEsLogDetail" + ) + } + if (opts.pageSize === undefined || opts.pageSize === null) { + throw new Error( + "Missing the required parameter 'opts.pageSize' when calling getEsLogDetail" + ) + } + if (opts.pageIndex === undefined || opts.pageIndex === null) { + throw new Error( + "Missing the required parameter 'opts.pageIndex' when calling getEsLogDetail" + ) + } + + let postBody = null + let queryParams = {} + if (opts.wafInstanceId !== undefined && opts.wafInstanceId !== null) { + queryParams['wafInstanceId'] = opts.wafInstanceId + } + if (opts.domain !== undefined && opts.domain !== null) { + queryParams['domain'] = opts.domain + } + if (opts.remote_addr !== undefined && opts.remote_addr !== null) { + queryParams['remote_addr'] = opts.remote_addr + } + if (opts.document_uri !== undefined && opts.document_uri !== null) { + queryParams['document_uri'] = opts.document_uri + } + if (opts.url !== undefined && opts.url !== null) { + queryParams['url'] = opts.url + } + if (opts.anti_geo !== undefined && opts.anti_geo !== null) { + queryParams['anti_geo'] = opts.anti_geo + } + if (opts.request_method !== undefined && opts.request_method !== null) { + queryParams['request_method'] = opts.request_method + } + if (opts.action !== undefined && opts.action !== null) { + queryParams['action'] = opts.action + } + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + if (opts.logId !== undefined && opts.logId !== null) { + queryParams['logId'] = opts.logId + } + if (opts.request_id !== undefined && opts.request_id !== null) { + queryParams['request_id'] = opts.request_id + } + if (opts.start !== undefined && opts.start !== null) { + queryParams['start'] = opts.start + } + if (opts.end !== undefined && opts.end !== null) { + queryParams['end'] = opts.end + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.pageIndex !== undefined && opts.pageIndex !== null) { + queryParams['pageIndex'] = opts.pageIndex + } + Object.assign(queryParams, super.buildArrayParam(opts.logType, 'logType')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 getEsLogDetail 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}/chart:getEsLog', + '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 {getAntiEventReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer pageSize 每页显示的个数。 + * @param integer pageIndex 页数。 + * @param integer total 总个数。 + * @param antiEvent events + */ + + getAntiEvent (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 getAntiEvent" + ) + } + + opts = opts || {} + + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling getAntiEvent" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 getAntiEvent 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}/chart:getAntiEvent', + '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) + } + ) + } + + /** + * 获取网站lb配置 + * @param {Object} opts - parameters + * @param {string} opts.wafInstanceId - 实例Id + * @param {commonReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string wafInstanceId 实例id + * @param lbConfig config 网站lb配置 + */ + + getDomainLbConfig (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 getDomainLbConfig" + ) + } + + opts = opts || {} + + if (opts.wafInstanceId === undefined || opts.wafInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.wafInstanceId' when calling getDomainLbConfig" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling getDomainLbConfig" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + wafInstanceId: opts.wafInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 getDomainLbConfig 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}/wafInstanceIds/{wafInstanceId}/domain:getDomainLbConfig', + '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.wafInstanceId - 实例Id + * @param {addDomain} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + addDomain (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 addDomain" + ) + } + + opts = opts || {} + + if (opts.wafInstanceId === undefined || opts.wafInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.wafInstanceId' when calling addDomain" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling addDomain" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + wafInstanceId: opts.wafInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 addDomain 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}/wafInstanceIds/{wafInstanceId}/domain:add', + '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.wafInstanceId - 实例Id + * @param {addDomain} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateDomain (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 updateDomain" + ) + } + + opts = opts || {} + + if (opts.wafInstanceId === undefined || opts.wafInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.wafInstanceId' when calling updateDomain" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling updateDomain" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + wafInstanceId: opts.wafInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 updateDomain 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}/wafInstanceIds/{wafInstanceId}/domain:update', + '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.wafInstanceId - 实例Id + * @param {commonReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteDomain (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 deleteDomain" + ) + } + + opts = opts || {} + + if (opts.wafInstanceId === undefined || opts.wafInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.wafInstanceId' when calling deleteDomain" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling deleteDomain" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + wafInstanceId: opts.wafInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 deleteDomain 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}/wafInstanceIds/{wafInstanceId}/domain:delete', + '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.wafInstanceId - 实例Id + * @param {listDomains} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string wafInstanceId 实例id + * @param string list + * @param integer pageIndex 页码 + * @param integer pageSize 页大小 + * @param integer totalCount 该实例下总共的域名数量 + * @param integer maxLimit 最大支持的数目 + */ + + listDomains (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 listDomains" + ) + } + + opts = opts || {} + + if (opts.wafInstanceId === undefined || opts.wafInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.wafInstanceId' when calling listDomains" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling listDomains" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + wafInstanceId: opts.wafInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 listDomains 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}/wafInstanceIds/{wafInstanceId}/domain:list', + '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.wafInstanceId - 实例Id + * @param {commonReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string domain 域名 + * @param integer disableWaf waf状态 1表示关闭waf + * @param integer enableJs js验证全局开关 0表示关闭 + * @param aclConf aclConf 网站waf防护配置 + * @param spiderConf antispiderConf 网站防爬虫防护配置 + * @param ccConf ccConf 网站cc防护配置 + * @param denyConf denyConf 网站黑名单防护配置 + * @param intSemConf intSemConf 网站智能语义引擎防护配置 + * @param ipbanConf ipbanConf 网站恶意ip防护配置 + * @param ipbanUsrConf ipbanUsrConf 网站恶意ip自定义防护配置 + * @param ratelimitConf ratelimitConf 网站限速规则防护配置 + * @param enableConf threatinfoConf 网站威胁情报防护配置 + * @param userDefPageConf userDefPageConf 网站自定义页面配置 + * @param wafConf wafConf 网站waf防护配置 + * @param webUserdefConf webUserdefConf 网站web自定义规则防护配置 + * @param enableConf webcacheConf 网站防篡改防护配置 + * @param skipConf skipConf 网站白名单防护配置 + * @param filterHeaderConf filterHeaderConf 网站请求头管理防护配置 + * @param filterSenseConf filterSenseConf 网站敏感信息防护配置 + * @param statusConf statusConf 状态码修改配置 + * @param uriRewriteConf uriRewriteConf 网站uri重写规则配置 + * @param enableConf proxycacheConf proxy缓存配置 + * @param riskConf riskConf risk配置 + * @param botConf botConf bot配置 + */ + + getDomainAntiConfig (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 getDomainAntiConfig" + ) + } + + opts = opts || {} + + if (opts.wafInstanceId === undefined || opts.wafInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.wafInstanceId' when calling getDomainAntiConfig" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling getDomainAntiConfig" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + wafInstanceId: opts.wafInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 getDomainAntiConfig 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}/wafInstanceIds/{wafInstanceId}/domain:getAntiConfig', + '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) + } + ) + } + + /** + * cname解析到回源 + * @param {Object} opts - parameters + * @param {string} opts.wafInstanceId - 实例Id + * @param {activeFuncReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + enableCname2RsExternal (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 enableCname2RsExternal" + ) + } + + opts = opts || {} + + if (opts.wafInstanceId === undefined || opts.wafInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.wafInstanceId' when calling enableCname2RsExternal" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling enableCname2RsExternal" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + wafInstanceId: opts.wafInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 enableCname2RsExternal 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}/wafInstanceIds/{wafInstanceId}/domain:enableCname2RsExternal', + '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.wafInstanceId - 实例Id + * @param {listDomains} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string wafInstanceId 实例id + * @param domainMainConfig list + * @param integer pageIndex 页码 + * @param integer pageSize 页大小 + * @param integer maxLimit 最大支持的数目 + * @param integer totalCount 当前实例域名总数 + * @param integer tldLimit 最大支持一级域名的数目 + * @param integer tldNum 一级域名个数 + * @param integer count 本次查询域名个数 + * @param string invalidRegion + * @param integer invalidIpv6 Ipv6是否故障,1:故障 0:健康 + */ + + listMainCfg (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 listMainCfg" + ) + } + + opts = opts || {} + + if (opts.wafInstanceId === undefined || opts.wafInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.wafInstanceId' when calling listMainCfg" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling listMainCfg" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + wafInstanceId: opts.wafInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 listMainCfg 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}/wafInstanceIds/{wafInstanceId}/domain:listMainCfg', + '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.wafInstanceId - 实例Id + * @param {disableRulesReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + disableRules (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 disableRules" + ) + } + + opts = opts || {} + + if (opts.wafInstanceId === undefined || opts.wafInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.wafInstanceId' when calling disableRules" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling disableRules" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + wafInstanceId: opts.wafInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 disableRules 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}/wafInstanceIds/{wafInstanceId}/domain:disableRules', + '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) + } + ) + } + + /** + * 激活waf + * @param {Object} opts - parameters + * @param {string} opts.wafInstanceId - 实例Id + * @param {enableReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + enableWaf (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 enableWaf" + ) + } + + opts = opts || {} + + if (opts.wafInstanceId === undefined || opts.wafInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.wafInstanceId' when calling enableWaf" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling enableWaf" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + wafInstanceId: opts.wafInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 enableWaf 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}/wafInstanceIds/{wafInstanceId}/waf:enable', + '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) + } + ) + } + + /** + * 设置waf防护模式 + * @param {Object} opts - parameters + * @param {string} opts.wafInstanceId - 实例Id + * @param {antiModeWafReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + antiModeWaf (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 antiModeWaf" + ) + } + + opts = opts || {} + + if (opts.wafInstanceId === undefined || opts.wafInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.wafInstanceId' when calling antiModeWaf" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling antiModeWaf" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + wafInstanceId: opts.wafInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 antiModeWaf 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}/wafInstanceIds/{wafInstanceId}/waf:antiMode', + '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) + } + ) + } + + /** + * 设置waf策略等级 + * @param {Object} opts - parameters + * @param {string} opts.wafInstanceId - 实例Id + * @param {antiLevelWafReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + antiLevelWaf (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 antiLevelWaf" + ) + } + + opts = opts || {} + + if (opts.wafInstanceId === undefined || opts.wafInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.wafInstanceId' when calling antiLevelWaf" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling antiLevelWaf" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + wafInstanceId: opts.wafInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 antiLevelWaf 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}/wafInstanceIds/{wafInstanceId}/waf:antiLevel', + '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) + } + ) + } + + /** + * 激活waf自定义规则 + * @param {Object} opts - parameters + * @param {string} opts.wafInstanceId - 实例Id + * @param {setWafUserDefineReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + enableWafUserDefine (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 enableWafUserDefine" + ) + } + + opts = opts || {} + + if (opts.wafInstanceId === undefined || opts.wafInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.wafInstanceId' when calling enableWafUserDefine" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling enableWafUserDefine" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + wafInstanceId: opts.wafInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 enableWafUserDefine 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}/wafInstanceIds/{wafInstanceId}/waf:setWafUserDefine', + '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) + } + ) + } + + /** + * 设置waf自定义规则 + * @param {Object} opts - parameters + * @param {string} opts.wafInstanceId - 实例Id + * @param {setWafRuleReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + setWafRule (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 setWafRule" + ) + } + + opts = opts || {} + + if (opts.wafInstanceId === undefined || opts.wafInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.wafInstanceId' when calling setWafRule" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling setWafRule" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + wafInstanceId: opts.wafInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 setWafRule 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}/wafInstanceIds/{wafInstanceId}/waf:setRule', + '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) + } + ) + } + + /** + * 删除waf自定义规则 + * @param {Object} opts - parameters + * @param {string} opts.wafInstanceId - 实例Id + * @param {delRulesReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + delWafRule (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 delWafRule" + ) + } + + opts = opts || {} + + if (opts.wafInstanceId === undefined || opts.wafInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.wafInstanceId' when calling delWafRule" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling delWafRule" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + wafInstanceId: opts.wafInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 delWafRule 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}/wafInstanceIds/{wafInstanceId}/waf:delRule', + '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) + } + ) + } + + /** + * 获取网站的waf自定义规则 + * @param {Object} opts - parameters + * @param {string} opts.wafInstanceId - 实例Id + * @param {listWafRulesReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer pageIndex 页码 + * @param integer pageSize 页大小 + * @param integer totalCount 配置总数 + * @param listWafRuleCfg list + */ + + listWafRules (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 listWafRules" + ) + } + + opts = opts || {} + + if (opts.wafInstanceId === undefined || opts.wafInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.wafInstanceId' when calling listWafRules" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling listWafRules" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + wafInstanceId: opts.wafInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 listWafRules 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}/wafInstanceIds/{wafInstanceId}/waf:listRules', + '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) + } + ) + } + + /** + * 设置网站黑白名单ip配置 + * @param {Object} opts - parameters + * @param {string} opts.wafInstanceId - 实例Id + * @param {setIpReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + addIps (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 addIps" + ) + } + + opts = opts || {} + + if (opts.wafInstanceId === undefined || opts.wafInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.wafInstanceId' when calling addIps" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling addIps" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + wafInstanceId: opts.wafInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 addIps 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}/wafInstanceIds/{wafInstanceId}/userdefine:addIps', + '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) + } + ) + } + + /** + * 更新网站黑白名单ip配置 + * @param {Object} opts - parameters + * @param {string} opts.wafInstanceId - 实例Id + * @param {setIpReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + updateIps (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 updateIps" + ) + } + + opts = opts || {} + + if (opts.wafInstanceId === undefined || opts.wafInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.wafInstanceId' when calling updateIps" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling updateIps" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + wafInstanceId: opts.wafInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 updateIps 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}/wafInstanceIds/{wafInstanceId}/userdefine:updateIps', + '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) + } + ) + } + + /** + * 获取网站黑白名单ip配置 + * @param {Object} opts - parameters + * @param {string} opts.wafInstanceId - 实例Id + * @param {listDenySkipRulesReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string wafInstanceId 实例id + * @param string domain 域名 + * @param string iswhite 0表示黑名单 1表示白名单 + * @param integer pageIndex 页码,[1-100] + * @param integer pageSize 页大小,[1-100] + * @param integer count 总数 + * @param ipListCfg data + */ + + listIps (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 listIps" + ) + } + + opts = opts || {} + + if (opts.wafInstanceId === undefined || opts.wafInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.wafInstanceId' when calling listIps" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling listIps" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + wafInstanceId: opts.wafInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 listIps 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}/wafInstanceIds/{wafInstanceId}/userdefine:listIps', + '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) + } + ) + } + + /** + * 删除网站黑白名单ip配置 + * @param {Object} opts - parameters + * @param {string} opts.wafInstanceId - 实例Id + * @param {delRulesReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + delIps (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 delIps" + ) + } + + opts = opts || {} + + if (opts.wafInstanceId === undefined || opts.wafInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.wafInstanceId' when calling delIps" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling delIps" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + wafInstanceId: opts.wafInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 delIps 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}/wafInstanceIds/{wafInstanceId}/userdefine:delIps', + '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) + } + ) + } + + /** + * 设置网站waf自定义防护条件 + * @param {Object} opts - parameters + * @param {string} opts.wafInstanceId - 实例Id + * @param {setWafConditionReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + setWafCondition (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 setWafCondition" + ) + } + + opts = opts || {} + + if (opts.wafInstanceId === undefined || opts.wafInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.wafInstanceId' when calling setWafCondition" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling setWafCondition" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + wafInstanceId: opts.wafInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 setWafCondition 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}/wafInstanceIds/{wafInstanceId}/waf:setCondition', + '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) + } + ) + } + + /** + * 删除网站waf自定义防护条件 + * @param {Object} opts - parameters + * @param {string} opts.wafInstanceId - 实例Id + * @param {delRulesReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + delWafCondition (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 delWafCondition" + ) + } + + opts = opts || {} + + if (opts.wafInstanceId === undefined || opts.wafInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.wafInstanceId' when calling delWafCondition" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling delWafCondition" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + wafInstanceId: opts.wafInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 delWafCondition 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}/wafInstanceIds/{wafInstanceId}/waf:delCondition', + '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) + } + ) + } + + /** + * 获取网站waf自定义防护条件 + * @param {Object} opts - parameters + * @param {string} opts.wafInstanceId - 实例Id + * @param {listWafConditionsReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer pageIndex 页码 + * @param integer pageSize 页大小 + * @param integer totalCount 配置总数 + * @param listWafConditionCfg list + */ + + listWafConditions (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 listWafConditions" + ) + } + + opts = opts || {} + + if (opts.wafInstanceId === undefined || opts.wafInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.wafInstanceId' when calling listWafConditions" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling listWafConditions" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + wafInstanceId: opts.wafInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 listWafConditions 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}/wafInstanceIds/{wafInstanceId}/waf:listConditions', + '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) + } + ) + } + + /** + * 获取网站waf自定义防护过滤器 + * @param {Object} opts - parameters + * @param {string} opts.wafInstanceId - 实例Id + * @param {listWafFilterReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer pageIndex 页码 + * @param integer pageSize 页大小 + * @param integer totalCount 配置总数 + * @param listWafFilterCfg list 网站waf自定义防护过滤器设置 + */ + + listWafFilter (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 listWafFilter" + ) + } + + opts = opts || {} + + if (opts.wafInstanceId === undefined || opts.wafInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.wafInstanceId' when calling listWafFilter" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling listWafFilter" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + wafInstanceId: opts.wafInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 listWafFilter 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}/wafInstanceIds/{wafInstanceId}/waf:listFilter', + '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.wafInstanceId - 实例Id + * @param {setWebcacheUrlReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + addWebcacheUrl (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 addWebcacheUrl" + ) + } + + opts = opts || {} + + if (opts.wafInstanceId === undefined || opts.wafInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.wafInstanceId' when calling addWebcacheUrl" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling addWebcacheUrl" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + wafInstanceId: opts.wafInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 addWebcacheUrl 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}/wafInstanceIds/{wafInstanceId}/webcache:addWebcacheUrl', + '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.wafInstanceId - 实例Id + * @param {commonNameReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + refreshUrlCache (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 refreshUrlCache" + ) + } + + opts = opts || {} + + if (opts.wafInstanceId === undefined || opts.wafInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.wafInstanceId' when calling refreshUrlCache" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling refreshUrlCache" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + wafInstanceId: opts.wafInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 refreshUrlCache 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}/wafInstanceIds/{wafInstanceId}/webcache:refreshUrlCache', + '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) + } + ) + } + + /** + * 获取网站已知类型bot规则 + * @param {Object} opts - parameters + * @param {string} opts.wafInstanceId - 实例Id + * @param {listBotStdRuleReq} opts.req - 请求 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer pageIndex 页码 + * @param integer pageSize 页大小 + * @param integer totalCount 配置总数 + * @param stdBotRules list + */ + + listBotStdRules (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 listBotStdRules" + ) + } + + opts = opts || {} + + if (opts.wafInstanceId === undefined || opts.wafInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.wafInstanceId' when calling listBotStdRules" + ) + } + if (opts.req === undefined || opts.req === null) { + throw new Error( + "Missing the required parameter 'opts.req' when calling listBotStdRules" + ) + } + + let postBody = {} + if (opts.req !== undefined && opts.req !== null) { + postBody['req'] = opts.req + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + wafInstanceId: opts.wafInstanceId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 listBotStdRules 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}/wafInstanceIds/{wafInstanceId}/bot:listStdRule', + '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) + } + ) + } + + /** + * 获取实例ID及相关信息列表 + * @param {Object} opts - parameters + * @param {string} [opts.idc] - 所属地区, 模糊匹配 optional + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 分页大小 optional + * @param {string} [opts.sourceIds] - 资源id 多个时,以逗号,分隔。 optional + * @param {filter} [opts.filters] - wafInstanceId - 实例id optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param integer total 总个数。 + * @param instanceIdCfg instanceIdCfg + */ + + getWafInstance (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 getWafInstance" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.idc !== undefined && opts.idc !== null) { + queryParams['idc'] = opts.idc + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + queryParams['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.sourceIds !== undefined && opts.sourceIds !== null) { + queryParams['sourceIds'] = opts.sourceIds + } + Object.assign(queryParams, super.buildFilterParam(opts.filters, 'filters')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 waf/1.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 getWafInstance 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}/user:getWafInstance', + '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 = WAF diff --git a/packages/libs/lib-jdcloud/src/repo/xdata/v1/xdata.js b/packages/libs/lib-jdcloud/src/repo/xdata/v1/xdata.js new file mode 100644 index 000000000..505412189 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/xdata/v1/xdata.js @@ -0,0 +1,2317 @@ +/* + * 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. + * + * table + * API related to XDATA-DW table + * + * 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 = 'xdata' +Service._services[serviceId] = true + +/** + * xdata service. + * @version 1.1.0 + */ + +JDCloud.XDATA = class XDATA extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'xdata.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询用户实例的所有数据库信息 + * @param {Object} opts - parameters + * @param {string} opts.instanceName - 实例名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status + * @param string message + * @param dwDatabaseInfo data + */ + + listDatabaseInfo (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 listDatabaseInfo" + ) + } + + opts = opts || {} + + if (opts.instanceName === undefined || opts.instanceName === null) { + throw new Error( + "Missing the required parameter 'opts.instanceName' when calling listDatabaseInfo" + ) + } + + let postBody = null + let queryParams = {} + if (opts.instanceName !== undefined && opts.instanceName !== null) { + queryParams['instanceName'] = opts.instanceName + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 xdata/1.1.0' + } + + 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 listDatabaseInfo 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 = this.makeRequest( + '/regions/{regionId}/dwDatabase', + '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.databaseName - 数据库名 + * @param {string} opts.instanceName - 实例名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status + * @param string message + * @param dwDatabase data + */ + + getDatabaseInfo (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 getDatabaseInfo" + ) + } + + opts = opts || {} + + if (opts.databaseName === undefined || opts.databaseName === null) { + throw new Error( + "Missing the required parameter 'opts.databaseName' when calling getDatabaseInfo" + ) + } + if (opts.instanceName === undefined || opts.instanceName === null) { + throw new Error( + "Missing the required parameter 'opts.instanceName' when calling getDatabaseInfo" + ) + } + + let postBody = null + let queryParams = {} + if (opts.instanceName !== undefined && opts.instanceName !== null) { + queryParams['instanceName'] = opts.instanceName + } + + let pathParams = { + regionId: regionId, + databaseName: opts.databaseName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 xdata/1.1.0' + } + + 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 getDatabaseInfo 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 = this.makeRequest( + '/regions/{regionId}/dwDatabase/{databaseName}', + '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.databaseName - 数据库名 + * @param {string} opts.instanceName - 实例名称 + * @param {string} [opts.description] - 数据库描述信息 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status + * @param string message + */ + + createDatabase (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 createDatabase" + ) + } + + opts = opts || {} + + if (opts.databaseName === undefined || opts.databaseName === null) { + throw new Error( + "Missing the required parameter 'opts.databaseName' when calling createDatabase" + ) + } + if (opts.instanceName === undefined || opts.instanceName === null) { + throw new Error( + "Missing the required parameter 'opts.instanceName' when calling createDatabase" + ) + } + + let postBody = {} + if (opts.instanceName !== undefined && opts.instanceName !== null) { + postBody['instanceName'] = opts.instanceName + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + databaseName: opts.databaseName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 xdata/1.1.0' + } + + 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 createDatabase 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 = this.makeRequest( + '/regions/{regionId}/dwDatabase/{databaseName}', + '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.databaseName - 数据库名 + * @param {string} opts.instanceName - 实例名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status + * @param string message + */ + + deleteDatabase (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 deleteDatabase" + ) + } + + opts = opts || {} + + if (opts.databaseName === undefined || opts.databaseName === null) { + throw new Error( + "Missing the required parameter 'opts.databaseName' when calling deleteDatabase" + ) + } + if (opts.instanceName === undefined || opts.instanceName === null) { + throw new Error( + "Missing the required parameter 'opts.instanceName' when calling deleteDatabase" + ) + } + + let postBody = null + let queryParams = {} + if (opts.instanceName !== undefined && opts.instanceName !== null) { + queryParams['instanceName'] = opts.instanceName + } + + let pathParams = { + regionId: regionId, + databaseName: opts.databaseName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 xdata/1.1.0' + } + + 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 deleteDatabase 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 = this.makeRequest( + '/regions/{regionId}/dwDatabase/{databaseName}', + '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} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status + * @param string message + * @param dwInstance data + */ + + listInstanceInfo (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 listInstanceInfo" + ) + } + + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 xdata/1.1.0' + } + + 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 listInstanceInfo 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 = this.makeRequest( + '/regions/{regionId}/dwInstance', + '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) + } + ) + } + + /** + * 执行用户编写的Spark SQL脚本 + * @param {Object} opts - parameters + * @param {string} [opts.databaseName] - 数据库名称 optional + * @param {string} opts.sql - sql脚本 + * @param {string} opts.userName - 用户名称 + * @param {string} [opts.queueName] - 队列名称 optional + * @param {string} [opts.source] - 资源名称 optional + * @param {string} [opts.callBackURL] - 回调地址名称 optional + * @param {string} opts.instanceName - 实例名称 + * @param {string} [opts.instanceOwnerName] - 实例拥有者名称 optional + * @param {string} [opts.isExplain] - 是否需要解释 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status + * @param string message + * @param integer data + */ + + executeRasQuery (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 executeRasQuery" + ) + } + + opts = opts || {} + + if (opts.sql === undefined || opts.sql === null) { + throw new Error( + "Missing the required parameter 'opts.sql' when calling executeRasQuery" + ) + } + if (opts.userName === undefined || opts.userName === null) { + throw new Error( + "Missing the required parameter 'opts.userName' when calling executeRasQuery" + ) + } + if (opts.instanceName === undefined || opts.instanceName === null) { + throw new Error( + "Missing the required parameter 'opts.instanceName' when calling executeRasQuery" + ) + } + + let postBody = {} + if (opts.databaseName !== undefined && opts.databaseName !== null) { + postBody['databaseName'] = opts.databaseName + } + if (opts.sql !== undefined && opts.sql !== null) { + postBody['sql'] = opts.sql + } + if (opts.userName !== undefined && opts.userName !== null) { + postBody['userName'] = opts.userName + } + if (opts.queueName !== undefined && opts.queueName !== null) { + postBody['queueName'] = opts.queueName + } + if (opts.source !== undefined && opts.source !== null) { + postBody['source'] = opts.source + } + if (opts.callBackURL !== undefined && opts.callBackURL !== null) { + postBody['callBackURL'] = opts.callBackURL + } + if (opts.instanceName !== undefined && opts.instanceName !== null) { + postBody['instanceName'] = opts.instanceName + } + if ( + opts.instanceOwnerName !== undefined && + opts.instanceOwnerName !== null + ) { + postBody['instanceOwnerName'] = opts.instanceOwnerName + } + if (opts.isExplain !== undefined && opts.isExplain !== null) { + postBody['isExplain'] = opts.isExplain + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 xdata/1.1.0' + } + + 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 executeRasQuery 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 = this.makeRequest( + '/regions/{regionId}/dwQuery:executeRasQuery', + '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) + } + ) + } + + /** + * 执行用户编写的PySpark脚本 + * @param {Object} opts - parameters + * @param {string} opts.script - PySpark脚本 + * @param {string} opts.userName - 用户名称 + * @param {string} opts.instanceName - 实例名称 + * @param {string} [opts.instanceOwnerName] - 实例拥有者名称 optional + * @param {string} [opts.scriptType] - 脚本类型名称 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status + * @param string message + * @param integer data + */ + + executePySparkQuery (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 executePySparkQuery" + ) + } + + opts = opts || {} + + if (opts.script === undefined || opts.script === null) { + throw new Error( + "Missing the required parameter 'opts.script' when calling executePySparkQuery" + ) + } + if (opts.userName === undefined || opts.userName === null) { + throw new Error( + "Missing the required parameter 'opts.userName' when calling executePySparkQuery" + ) + } + if (opts.instanceName === undefined || opts.instanceName === null) { + throw new Error( + "Missing the required parameter 'opts.instanceName' when calling executePySparkQuery" + ) + } + + let postBody = {} + if (opts.script !== undefined && opts.script !== null) { + postBody['script'] = opts.script + } + if (opts.userName !== undefined && opts.userName !== null) { + postBody['userName'] = opts.userName + } + if (opts.instanceName !== undefined && opts.instanceName !== null) { + postBody['instanceName'] = opts.instanceName + } + if ( + opts.instanceOwnerName !== undefined && + opts.instanceOwnerName !== null + ) { + postBody['instanceOwnerName'] = opts.instanceOwnerName + } + if (opts.scriptType !== undefined && opts.scriptType !== null) { + postBody['scriptType'] = opts.scriptType + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 xdata/1.1.0' + } + + 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 executePySparkQuery 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 = this.makeRequest( + '/regions/{regionId}/dwQuery:executePySparkQuery', + '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) + } + ) + } + + /** + * 获取用户Spark SQL脚本的查询状态 + * @param {Object} opts - parameters + * @param {string} opts.userName - 用户名称 + * @param {string} opts.queryId - 查询id名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status + * @param string message + * @param string data + */ + + getRasQueryState (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 getRasQueryState" + ) + } + + opts = opts || {} + + if (opts.userName === undefined || opts.userName === null) { + throw new Error( + "Missing the required parameter 'opts.userName' when calling getRasQueryState" + ) + } + if (opts.queryId === undefined || opts.queryId === null) { + throw new Error( + "Missing the required parameter 'opts.queryId' when calling getRasQueryState" + ) + } + + let postBody = null + let queryParams = {} + if (opts.userName !== undefined && opts.userName !== null) { + queryParams['userName'] = opts.userName + } + if (opts.queryId !== undefined && opts.queryId !== null) { + queryParams['queryId'] = opts.queryId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 xdata/1.1.0' + } + + 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 getRasQueryState 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 = this.makeRequest( + '/regions/{regionId}/dwQuery:getRasQueryState', + '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) + } + ) + } + + /** + * 获取用户PySpark脚本的执行状态 + * @param {Object} opts - parameters + * @param {string} opts.userName - 用户名称 + * @param {string} opts.queryId - 查询id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status + * @param string message + * @param string data + */ + + getPySparkExecuteState (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 getPySparkExecuteState" + ) + } + + opts = opts || {} + + if (opts.userName === undefined || opts.userName === null) { + throw new Error( + "Missing the required parameter 'opts.userName' when calling getPySparkExecuteState" + ) + } + if (opts.queryId === undefined || opts.queryId === null) { + throw new Error( + "Missing the required parameter 'opts.queryId' when calling getPySparkExecuteState" + ) + } + + let postBody = null + let queryParams = {} + if (opts.userName !== undefined && opts.userName !== null) { + queryParams['userName'] = opts.userName + } + if (opts.queryId !== undefined && opts.queryId !== null) { + queryParams['queryId'] = opts.queryId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 xdata/1.1.0' + } + + 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 getPySparkExecuteState 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 = this.makeRequest( + '/regions/{regionId}/dwQuery:getPySparkExecuteState', + '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) + } + ) + } + + /** + * 获取用户Spark SQL脚本的查询日志 + * @param {Object} opts - parameters + * @param {string} opts.userName - 用户名称 + * @param {string} opts.queryId - 查询id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status + * @param string message + */ + + getRasQueryLog (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 getRasQueryLog" + ) + } + + opts = opts || {} + + if (opts.userName === undefined || opts.userName === null) { + throw new Error( + "Missing the required parameter 'opts.userName' when calling getRasQueryLog" + ) + } + if (opts.queryId === undefined || opts.queryId === null) { + throw new Error( + "Missing the required parameter 'opts.queryId' when calling getRasQueryLog" + ) + } + + let postBody = null + let queryParams = {} + if (opts.userName !== undefined && opts.userName !== null) { + queryParams['userName'] = opts.userName + } + if (opts.queryId !== undefined && opts.queryId !== null) { + queryParams['queryId'] = opts.queryId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 xdata/1.1.0' + } + + 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 getRasQueryLog 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 = this.makeRequest( + '/regions/{regionId}/dwQuery:getRasQueryLog', + '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) + } + ) + } + + /** + * 获取用户Spark SQL脚本的查询结果 + * @param {Object} opts - parameters + * @param {string} opts.userName - 用户名称 + * @param {string} opts.queryId - 查询id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status + * @param string message + */ + + getRasQueryResult (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 getRasQueryResult" + ) + } + + opts = opts || {} + + if (opts.userName === undefined || opts.userName === null) { + throw new Error( + "Missing the required parameter 'opts.userName' when calling getRasQueryResult" + ) + } + if (opts.queryId === undefined || opts.queryId === null) { + throw new Error( + "Missing the required parameter 'opts.queryId' when calling getRasQueryResult" + ) + } + + let postBody = null + let queryParams = {} + if (opts.userName !== undefined && opts.userName !== null) { + queryParams['userName'] = opts.userName + } + if (opts.queryId !== undefined && opts.queryId !== null) { + queryParams['queryId'] = opts.queryId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 xdata/1.1.0' + } + + 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 getRasQueryResult 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 = this.makeRequest( + '/regions/{regionId}/dwQuery:getRasQueryResult', + '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) + } + ) + } + + /** + * 获取用户PySpark脚本的执行结果 + * @param {Object} opts - parameters + * @param {string} opts.userName - 用户名称 + * @param {string} opts.queryId - 查询id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status + * @param string message + */ + + getPySparkExecuteResult (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 getPySparkExecuteResult" + ) + } + + opts = opts || {} + + if (opts.userName === undefined || opts.userName === null) { + throw new Error( + "Missing the required parameter 'opts.userName' when calling getPySparkExecuteResult" + ) + } + if (opts.queryId === undefined || opts.queryId === null) { + throw new Error( + "Missing the required parameter 'opts.queryId' when calling getPySparkExecuteResult" + ) + } + + let postBody = null + let queryParams = {} + if (opts.userName !== undefined && opts.userName !== null) { + queryParams['userName'] = opts.userName + } + if (opts.queryId !== undefined && opts.queryId !== null) { + queryParams['queryId'] = opts.queryId + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 xdata/1.1.0' + } + + 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 getPySparkExecuteResult 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 = this.makeRequest( + '/regions/{regionId}/dwQuery:getPySparkExecuteResult', + '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) + } + ) + } + + /** + * 终止用户Spark SQL脚本查询 + * @param {Object} opts - parameters + * @param {string} opts.userName - 用户名称 + * @param {string} opts.queryId - 查询id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status + * @param string message + */ + + cancelRasQuery (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 cancelRasQuery" + ) + } + + opts = opts || {} + + if (opts.userName === undefined || opts.userName === null) { + throw new Error( + "Missing the required parameter 'opts.userName' when calling cancelRasQuery" + ) + } + if (opts.queryId === undefined || opts.queryId === null) { + throw new Error( + "Missing the required parameter 'opts.queryId' when calling cancelRasQuery" + ) + } + + let postBody = {} + if (opts.userName !== undefined && opts.userName !== null) { + postBody['userName'] = opts.userName + } + if (opts.queryId !== undefined && opts.queryId !== null) { + postBody['queryId'] = opts.queryId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 xdata/1.1.0' + } + + 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 cancelRasQuery 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 = this.makeRequest( + '/regions/{regionId}/dwQuery:cancelRasQuery', + '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) + } + ) + } + + /** + * 终止用户PySpark脚本任务 + * @param {Object} opts - parameters + * @param {string} opts.userName - 用户名称 + * @param {string} opts.queryId - 查询id + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status + * @param string message + */ + + cancelPySparkJob (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 cancelPySparkJob" + ) + } + + opts = opts || {} + + if (opts.userName === undefined || opts.userName === null) { + throw new Error( + "Missing the required parameter 'opts.userName' when calling cancelPySparkJob" + ) + } + if (opts.queryId === undefined || opts.queryId === null) { + throw new Error( + "Missing the required parameter 'opts.queryId' when calling cancelPySparkJob" + ) + } + + let postBody = {} + if (opts.userName !== undefined && opts.userName !== null) { + postBody['userName'] = opts.userName + } + if (opts.queryId !== undefined && opts.queryId !== null) { + postBody['queryId'] = opts.queryId + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 xdata/1.1.0' + } + + 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 cancelPySparkJob 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 = this.makeRequest( + '/regions/{regionId}/dwQuery:cancelPySparkQuery', + '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.instanceName - 实例名称 + * @param {string} opts.databaseName - 数据库名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status + * @param string message + * @param dwTable data + */ + + listTableInfo (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 listTableInfo" + ) + } + + opts = opts || {} + + if (opts.instanceName === undefined || opts.instanceName === null) { + throw new Error( + "Missing the required parameter 'opts.instanceName' when calling listTableInfo" + ) + } + if (opts.databaseName === undefined || opts.databaseName === null) { + throw new Error( + "Missing the required parameter 'opts.databaseName' when calling listTableInfo" + ) + } + + let postBody = null + let queryParams = {} + if (opts.instanceName !== undefined && opts.instanceName !== null) { + queryParams['instanceName'] = opts.instanceName + } + if (opts.databaseName !== undefined && opts.databaseName !== null) { + queryParams['databaseName'] = opts.databaseName + } + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 xdata/1.1.0' + } + + 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 listTableInfo 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 = this.makeRequest( + '/regions/{regionId}/dwTable', + '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.instanceName - 实例名称 + * @param {dwTableDesc} opts.dbModelDBTable - 数据表描述信息 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status + * @param string message + */ + + createTable (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 createTable" + ) + } + + opts = opts || {} + + if (opts.instanceName === undefined || opts.instanceName === null) { + throw new Error( + "Missing the required parameter 'opts.instanceName' when calling createTable" + ) + } + if (opts.dbModelDBTable === undefined || opts.dbModelDBTable === null) { + throw new Error( + "Missing the required parameter 'opts.dbModelDBTable' when calling createTable" + ) + } + + let postBody = {} + if (opts.instanceName !== undefined && opts.instanceName !== null) { + postBody['instanceName'] = opts.instanceName + } + if (opts.dbModelDBTable !== undefined && opts.dbModelDBTable !== null) { + postBody['dbModelDBTable'] = opts.dbModelDBTable + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 xdata/1.1.0' + } + + 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 createTable 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 = this.makeRequest( + '/regions/{regionId}/dwTable', + '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.tableName - 数据表名 + * @param {string} opts.instanceName - 实例名称 + * @param {string} opts.databaseName - 数据库名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status + * @param string message + * @param dwTable data + */ + + getTableInfo (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 getTableInfo" + ) + } + + opts = opts || {} + + if (opts.tableName === undefined || opts.tableName === null) { + throw new Error( + "Missing the required parameter 'opts.tableName' when calling getTableInfo" + ) + } + if (opts.instanceName === undefined || opts.instanceName === null) { + throw new Error( + "Missing the required parameter 'opts.instanceName' when calling getTableInfo" + ) + } + if (opts.databaseName === undefined || opts.databaseName === null) { + throw new Error( + "Missing the required parameter 'opts.databaseName' when calling getTableInfo" + ) + } + + let postBody = null + let queryParams = {} + if (opts.instanceName !== undefined && opts.instanceName !== null) { + queryParams['instanceName'] = opts.instanceName + } + if (opts.databaseName !== undefined && opts.databaseName !== null) { + queryParams['databaseName'] = opts.databaseName + } + + let pathParams = { + regionId: regionId, + tableName: opts.tableName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 xdata/1.1.0' + } + + 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 getTableInfo 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 = this.makeRequest( + '/regions/{regionId}/dwTable/{tableName}', + '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.tableName - 数据表名 + * @param {string} opts.instanceName - 实例名称 + * @param {string} opts.databaseName - 数据库名称 + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param boolean status + * @param string message + * @param object data + */ + + deleteTable (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 deleteTable" + ) + } + + opts = opts || {} + + if (opts.tableName === undefined || opts.tableName === null) { + throw new Error( + "Missing the required parameter 'opts.tableName' when calling deleteTable" + ) + } + if (opts.instanceName === undefined || opts.instanceName === null) { + throw new Error( + "Missing the required parameter 'opts.instanceName' when calling deleteTable" + ) + } + if (opts.databaseName === undefined || opts.databaseName === null) { + throw new Error( + "Missing the required parameter 'opts.databaseName' when calling deleteTable" + ) + } + + let postBody = null + let queryParams = {} + if (opts.instanceName !== undefined && opts.instanceName !== null) { + queryParams['instanceName'] = opts.instanceName + } + if (opts.databaseName !== undefined && opts.databaseName !== null) { + queryParams['databaseName'] = opts.databaseName + } + + let pathParams = { + regionId: regionId, + tableName: opts.tableName + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 xdata/1.1.0' + } + + 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 deleteTable 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 = this.makeRequest( + '/regions/{regionId}/dwTable/{tableName}', + '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) + } + ) + } +} +module.exports = JDCloud.XDATA diff --git a/packages/libs/lib-jdcloud/src/repo/ydsms/v1/ydsms.js b/packages/libs/lib-jdcloud/src/repo/ydsms/v1/ydsms.js new file mode 100644 index 000000000..2f4609c50 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/ydsms/v1/ydsms.js @@ -0,0 +1,4801 @@ +/* + * 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. + * + * 云鼎短信服务-用户相关接口 + * 云鼎短信服务-用户相关接口 + * + * 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 = 'ydsms' +Service._services[serviceId] = true + +/** + * ydsms service. + * @version 1.0.8 + */ + +class YDSMS extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'ydsms.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询应用列表 + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 分页大小 optional + * @param {string} [opts.status] - 状态,0 停用 1 启用 optional + * @param {string} [opts.appName] - 应用名称 optional + * @param {string} callback - callback + @return {Object} result + * @param smsAppVO smsApps + * @param integer totalCount + */ + + listSmsAppsUsingGET (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 + } + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + if (opts.appName !== undefined && opts.appName !== null) { + queryParams['appName'] = opts.appName + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 listSmsAppsUsingGET 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( + '/smsApps', + '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 {} opts.appDesc - 应用描述 + * @param {} [opts.appId] - 云鼎应用id optional + * @param {} opts.appName - 应用名称 + * @param {} [opts.accessKeyId] - accessKeyId optional + * @param {} [opts.accessKeySecret] - accessKeySecret optional + * @param {string} callback - callback + @return {Object} result + * @param string appId 应用id + */ + + createSmsAppUsingPOST (opts, callback) { + opts = opts || {} + + if (opts.appDesc === undefined || opts.appDesc === null) { + throw new Error( + "Missing the required parameter 'opts.appDesc' when calling createSmsAppUsingPOST" + ) + } + if (opts.appName === undefined || opts.appName === null) { + throw new Error( + "Missing the required parameter 'opts.appName' when calling createSmsAppUsingPOST" + ) + } + + let postBody = {} + if (opts.appDesc !== undefined && opts.appDesc !== null) { + postBody['appDesc'] = opts.appDesc + } + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.appName !== undefined && opts.appName !== null) { + postBody['appName'] = opts.appName + } + if (opts.accessKeyId !== undefined && opts.accessKeyId !== null) { + postBody['accessKeyId'] = opts.accessKeyId + } + if (opts.accessKeySecret !== undefined && opts.accessKeySecret !== null) { + postBody['accessKeySecret'] = opts.accessKeySecret + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 createSmsAppUsingPOST 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( + '/smsApps', + '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.appId - 应用id + * @param {string} callback - callback + @return {Object} result + * @param smsAppVO smsAppVO + */ + + getSmsAppByIdUsingGET (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling getSmsAppByIdUsingGET" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 getSmsAppByIdUsingGET 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( + '/smsApps/{appId}', + '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.appId - appId + * @param {} [opts.appDesc] - 应用描述 optional + * @param {} [opts.appName] - 应用名称 optional + * @param {string} callback - callback + @return {Object} result + * @param string appId 应用id + */ + + modifySmsAppUsingPOST (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling modifySmsAppUsingPOST" + ) + } + + let postBody = {} + if (opts.appDesc !== undefined && opts.appDesc !== null) { + postBody['appDesc'] = opts.appDesc + } + if (opts.appName !== undefined && opts.appName !== null) { + postBody['appName'] = opts.appName + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 modifySmsAppUsingPOST 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( + '/smsApps/{appId}', + '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) + } + ) + } + + /** + * 查询应用secretKey + * @param {Object} opts - parameters + * @param {string} opts.appId - 应用id + * @param {string} callback - callback + @return {Object} result + * @param string secretKey 密钥 + */ + + querySecretKeyUsingGET (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling querySecretKeyUsingGET" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 querySecretKeyUsingGET 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( + '/smsApps/{appId}:querySecretKey', + '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.appId - 应用id + * @param {integer} [opts.status] - 应用状态,0 停用 1 启用 optional + * @param {string} callback - callback + @return {Object} result + * @param string appId 应用id + */ + + modifyStatusUsingGET (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling modifyStatusUsingGET" + ) + } + + let postBody = null + let queryParams = {} + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 modifyStatusUsingGET 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( + '/smsApps/{appId}:modifyStatus', + '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.appId - 应用id,传all查询所有应用的数据总和 + * @param {integer} [opts.packageType] - 套餐包类型,1普通短信 2官方短信,默认为1 optional + * @param {string} [opts.templateId] - 模板id optional + * @param {string} opts.endTime - 结束时间,pattern ="yyyy-MM-dd HH:mm:ss",timezone="GMT+8" + * @param {string} opts.startTime - 开始时间,pattern ="yyyy-MM-dd HH:mm:ss",timezone="GMT+8" + * @param {string} callback - callback + @return {Object} result + * @param string pin pin + * @param string appId 应用id + * @param sendOverviewVO sendOverviewVOList + */ + + listSmsSendOverviewUsingGET (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling listSmsSendOverviewUsingGET" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling listSmsSendOverviewUsingGET" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling listSmsSendOverviewUsingGET" + ) + } + + let postBody = null + let queryParams = {} + if (opts.packageType !== undefined && opts.packageType !== null) { + queryParams['packageType'] = opts.packageType + } + if (opts.templateId !== undefined && opts.templateId !== null) { + queryParams['templateId'] = opts.templateId + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 listSmsSendOverviewUsingGET 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( + '/smsApps/{appId}:overview', + '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.appId - 应用id + * @param {integer} [opts.sendStatus] - 发送状态,0 全部状态 1 发送成功 2 发送失败 3 已发送未回执, 默认为0 optional + * @param {string} [opts.sendNumber] - 手机号码 optional + * @param {string} [opts.templateId] - 模板id optional + * @param {string} [opts.sign_id] - 签名id optional + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 分页大小 optional + * @param {string} opts.endTime - 结束时间,pattern ="yyyy-MM-dd HH:mm:ss",timezone="GMT+8" + * @param {string} opts.startTime - 开始时间,pattern ="yyyy-MM-dd HH:mm:ss",timezone="GMT+8" + * @param {string} callback - callback + @return {Object} result + * @param sendRecord sendRecords + * @param integer totalCount + */ + + querySendRecordUsingGET (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling querySendRecordUsingGET" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling querySendRecordUsingGET" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling querySendRecordUsingGET" + ) + } + + let postBody = null + let queryParams = {} + if (opts.sendStatus !== undefined && opts.sendStatus !== null) { + queryParams['sendStatus'] = opts.sendStatus + } + if (opts.sendNumber !== undefined && opts.sendNumber !== null) { + queryParams['sendNumber'] = opts.sendNumber + } + if (opts.templateId !== undefined && opts.templateId !== null) { + queryParams['templateId'] = opts.templateId + } + if (opts.sign_id !== undefined && opts.sign_id !== null) { + queryParams['sign_id'] = opts.sign_id + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + queryParams['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 querySendRecordUsingGET 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( + '/smsApps/{appId}:querySendRecord', + '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.appId - 应用id + * @param {string} [opts.sendNumber] - 手机号码 optional + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 分页大小 optional + * @param {string} opts.endTime - 结束时间,pattern ="yyyy-MM-dd HH:mm:ss",timezone="GMT+8" + * @param {string} opts.startTime - 开始时间,pattern ="yyyy-MM-dd HH:mm:ss",timezone="GMT+8" + * @param {string} callback - callback + @return {Object} result + * @param replyRecord replyRecords + * @param integer totalCount + */ + + queryReplyRecordUsingGET (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling queryReplyRecordUsingGET" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling queryReplyRecordUsingGET" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling queryReplyRecordUsingGET" + ) + } + + let postBody = null + let queryParams = {} + if (opts.sendNumber !== undefined && opts.sendNumber !== null) { + queryParams['sendNumber'] = opts.sendNumber + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + queryParams['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 queryReplyRecordUsingGET 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( + '/smsApps/{appId}:queryReplyRecord', + '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.appId - 应用id + * @param {string} opts.endTime - 结束时间,pattern ="yyyy-MM-dd HH:mm:ss",timezone="GMT+8" + * @param {string} opts.startTime - 开始时间,pattern ="yyyy-MM-dd HH:mm:ss",timezone="GMT+8" + * @param {string} callback - callback + @return {Object} result + * @param string pin pin + * @param string appId 应用id + * @param receiptRecord receiptRecords + */ + + queryReceiptRecordUsingGET (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling queryReceiptRecordUsingGET" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling queryReceiptRecordUsingGET" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling queryReceiptRecordUsingGET" + ) + } + + let postBody = null + let queryParams = {} + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 queryReceiptRecordUsingGET 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( + '/smsApps/{appId}:queryReceiptRecord', + '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.appId] - 应用id optional + * @param {integer} [opts.type] - 通用设置类型,0发送频率设置 1发送超量提醒 2短信发送状态回调地址 optional + * @param {string} callback - callback + @return {Object} result + * @param generalSettings appGeneralSettings + */ + + listSmsAppGeneralSettingsUsingGET (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.appId !== undefined && opts.appId !== null) { + queryParams['appId'] = opts.appId + } + if (opts.type !== undefined && opts.type !== null) { + queryParams['type'] = opts.type + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 listSmsAppGeneralSettingsUsingGET 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( + '/smsAppGeneralSettings', + '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.id] - id optional + * @param {string} [opts.settingValue] - 设置的值 optional + * @param {integer} [opts.status] - 是否启用,当前设置是否生效,0未生效 1生效 optional + * @param {string} callback - callback + @return {Object} result + * @param boolean success 是否修改成功 + */ + + modifyAppGeneralSettingById (opts, callback) { + opts = opts || {} + + if (opts.id === undefined || opts.id === null) { + throw new Error( + "Missing the required parameter 'opts.id' when calling modifyAppGeneralSettingById" + ) + } + + let postBody = null + let queryParams = {} + if (opts.settingValue !== undefined && opts.settingValue !== null) { + queryParams['settingValue'] = opts.settingValue + } + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + + let pathParams = { + regionId: 'jdcloud', + id: opts.id + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 modifyAppGeneralSettingById 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( + '/smsAppGeneralSettings/{id}:modify', + '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} callback - callback + @return {Object} result + * @param certificateType certificateTypes + */ + + listSmsCertificateTypesUsingGET (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 listSmsCertificateTypesUsingGET 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( + '/smsCertificateTypes', + '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.appId - 应用id + * @param {string} opts.endTime - 结束时间 + * @param {string} opts.startTime - 开始时间 + * @param {string} callback - callback + @return {Object} result + */ + + listSmsSendOverviewUsingGET (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling listSmsSendOverviewUsingGET" + ) + } + if (opts.endTime === undefined || opts.endTime === null) { + throw new Error( + "Missing the required parameter 'opts.endTime' when calling listSmsSendOverviewUsingGET" + ) + } + if (opts.startTime === undefined || opts.startTime === null) { + throw new Error( + "Missing the required parameter 'opts.startTime' when calling listSmsSendOverviewUsingGET" + ) + } + + let postBody = null + let queryParams = {} + if (opts.endTime !== undefined && opts.endTime !== null) { + queryParams['endTime'] = opts.endTime + } + if (opts.startTime !== undefined && opts.startTime !== null) { + queryParams['startTime'] = opts.startTime + } + + let pathParams = { + regionId: 'jdcloud', + appId: opts.appId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 listSmsSendOverviewUsingGET 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( + '/apps/{appId}:overview', + '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.packageType] - 套餐包类型:1通道短信,2官方短信 optional + * @param {integer} [opts.pageNumber] - pageNumber optional + * @param {integer} [opts.pageSize] - pageSize optional + * @param {string} callback - callback + @return {Object} result + * @param smsPackageVO smsPackages + * @param integer totalCount + */ + + listSmsPackagesUsingGET (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + if (opts.packageType !== undefined && opts.packageType !== null) { + queryParams['packageType'] = opts.packageType + } + 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: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 listSmsPackagesUsingGET 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( + '/smsPackages', + '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 {} opts.packageCount - 套餐包数量 + * @param {} opts.packageType - 套餐包类型,1通道短信,2官方短信 + * @param {} opts.specification - 套餐包规格 + * @param {string} callback - callback + @return {Object} result + * @param string buyId 购物车id,预付费需登陆控制台https://buy.jdcloud.com/confirm?buyId=xxx 确认订单 + */ + + createSmsPackageUsingPOST (opts, callback) { + opts = opts || {} + + if (opts.packageCount === undefined || opts.packageCount === null) { + throw new Error( + "Missing the required parameter 'opts.packageCount' when calling createSmsPackageUsingPOST" + ) + } + if (opts.packageType === undefined || opts.packageType === null) { + throw new Error( + "Missing the required parameter 'opts.packageType' when calling createSmsPackageUsingPOST" + ) + } + if (opts.specification === undefined || opts.specification === null) { + throw new Error( + "Missing the required parameter 'opts.specification' when calling createSmsPackageUsingPOST" + ) + } + + let postBody = {} + if (opts.packageCount !== undefined && opts.packageCount !== null) { + postBody['packageCount'] = opts.packageCount + } + if (opts.packageType !== undefined && opts.packageType !== null) { + postBody['packageType'] = opts.packageType + } + if (opts.specification !== undefined && opts.specification !== null) { + postBody['specification'] = opts.specification + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 createSmsPackageUsingPOST 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( + '/smsPackages', + '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.packageId - 套餐包id + * @param {string} callback - callback + @return {Object} result + * @param smsPackageVO smsPackageVO + */ + + getSmsPackageByIdUsingGET (opts, callback) { + opts = opts || {} + + if (opts.packageId === undefined || opts.packageId === null) { + throw new Error( + "Missing the required parameter 'opts.packageId' when calling getSmsPackageByIdUsingGET" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + packageId: opts.packageId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 getSmsPackageByIdUsingGET 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( + '/smsPackages/{packageId}', + '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.packageType - 套餐包类型,1通道短信 2官方短信 + * @param {string} callback - callback + @return {Object} result + * @param specificationVO specificationVOS + */ + + getSmsPackageSpecificationsUsingGET (opts, callback) { + opts = opts || {} + + if (opts.packageType === undefined || opts.packageType === null) { + throw new Error( + "Missing the required parameter 'opts.packageType' when calling getSmsPackageSpecificationsUsingGET" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + packageType: opts.packageType + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 getSmsPackageSpecificationsUsingGET 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( + '/smsPackages/{packageType}:querySpecifications', + '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 {} opts.appId - 应用id + * @param {} [opts.params] - 短信模板变量对应的数据值 optional + * @param {} opts.phoneList - 群发的国内电话号码,群发时一次最多不要超过100个手机号 + * @param {} opts.signId - 签名id + * @param {} opts.templateId - 模板id + * @param {string} callback - callback + @return {Object} result + * @param mtResVO mtResVO + */ + + sendMessagesUsingPOST (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling sendMessagesUsingPOST" + ) + } + if (opts.phoneList === undefined || opts.phoneList === null) { + throw new Error( + "Missing the required parameter 'opts.phoneList' when calling sendMessagesUsingPOST" + ) + } + if (opts.signId === undefined || opts.signId === null) { + throw new Error( + "Missing the required parameter 'opts.signId' when calling sendMessagesUsingPOST" + ) + } + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling sendMessagesUsingPOST" + ) + } + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.params !== undefined && opts.params !== null) { + postBody['params'] = opts.params + } + if (opts.phoneList !== undefined && opts.phoneList !== null) { + postBody['phoneList'] = opts.phoneList + } + if (opts.signId !== undefined && opts.signId !== null) { + postBody['signId'] = opts.signId + } + if (opts.templateId !== undefined && opts.templateId !== null) { + postBody['templateId'] = opts.templateId + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 sendMessagesUsingPOST 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( + '/smsSendMessages', + '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 {} opts.appId - 应用id + * @param {} opts.signId - 签名id + * @param {} opts.templateId - 模板id + * @param {} opts.venderId - 商家id + * @param {} opts.orderId - 订单编号 + * @param {} [opts.params] - 短信模板变量对应的数据值 optional + * @param {string} callback - callback + @return {Object} result + * @param mtResVO mtResVO + */ + + sendMessagesByOrderIdUsingPOST (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling sendMessagesByOrderIdUsingPOST" + ) + } + if (opts.signId === undefined || opts.signId === null) { + throw new Error( + "Missing the required parameter 'opts.signId' when calling sendMessagesByOrderIdUsingPOST" + ) + } + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling sendMessagesByOrderIdUsingPOST" + ) + } + if (opts.venderId === undefined || opts.venderId === null) { + throw new Error( + "Missing the required parameter 'opts.venderId' when calling sendMessagesByOrderIdUsingPOST" + ) + } + if (opts.orderId === undefined || opts.orderId === null) { + throw new Error( + "Missing the required parameter 'opts.orderId' when calling sendMessagesByOrderIdUsingPOST" + ) + } + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.signId !== undefined && opts.signId !== null) { + postBody['signId'] = opts.signId + } + if (opts.templateId !== undefined && opts.templateId !== null) { + postBody['templateId'] = opts.templateId + } + if (opts.venderId !== undefined && opts.venderId !== null) { + postBody['venderId'] = opts.venderId + } + if (opts.orderId !== undefined && opts.orderId !== null) { + postBody['orderId'] = opts.orderId + } + if (opts.params !== undefined && opts.params !== null) { + postBody['params'] = opts.params + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 sendMessagesByOrderIdUsingPOST 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( + '/sendMessagesByOrderId', + '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) + } + ) + } + + /** + * 根据pin发送短信 + * @param {Object} opts - parameters + * @param {} opts.appId - 应用id + * @param {} opts.signId - 签名id + * @param {} opts.templateId - 模板id + * @param {} opts.pin - 用户pin + * @param {} [opts.params] - 短信模板变量对应的数据值 optional + * @param {string} callback - callback + @return {Object} result + * @param mtResVO mtResVO + */ + + sendMessagesByPinUsingPOST (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling sendMessagesByPinUsingPOST" + ) + } + if (opts.signId === undefined || opts.signId === null) { + throw new Error( + "Missing the required parameter 'opts.signId' when calling sendMessagesByPinUsingPOST" + ) + } + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling sendMessagesByPinUsingPOST" + ) + } + if (opts.pin === undefined || opts.pin === null) { + throw new Error( + "Missing the required parameter 'opts.pin' when calling sendMessagesByPinUsingPOST" + ) + } + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.signId !== undefined && opts.signId !== null) { + postBody['signId'] = opts.signId + } + if (opts.templateId !== undefined && opts.templateId !== null) { + postBody['templateId'] = opts.templateId + } + if (opts.pin !== undefined && opts.pin !== null) { + postBody['pin'] = opts.pin + } + if (opts.params !== undefined && opts.params !== null) { + postBody['params'] = opts.params + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 sendMessagesByPinUsingPOST 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( + '/sendMessagesByPin', + '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) + } + ) + } + + /** + * 根据加密pin发送短信 + * @param {Object} opts - parameters + * @param {} opts.appId - 应用id + * @param {} opts.signId - 签名id + * @param {} opts.templateId - 模板id + * @param {} opts.encPins - 加密pin集合,不能超过100个 + * @param {} [opts.params] - 短信模板变量对应的数据值 optional + * @param {string} callback - callback + @return {Object} result + * @param mtResVO mtResVO + */ + + sendMessagesByEncPinUsingPOST (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling sendMessagesByEncPinUsingPOST" + ) + } + if (opts.signId === undefined || opts.signId === null) { + throw new Error( + "Missing the required parameter 'opts.signId' when calling sendMessagesByEncPinUsingPOST" + ) + } + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling sendMessagesByEncPinUsingPOST" + ) + } + if (opts.encPins === undefined || opts.encPins === null) { + throw new Error( + "Missing the required parameter 'opts.encPins' when calling sendMessagesByEncPinUsingPOST" + ) + } + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.signId !== undefined && opts.signId !== null) { + postBody['signId'] = opts.signId + } + if (opts.templateId !== undefined && opts.templateId !== null) { + postBody['templateId'] = opts.templateId + } + if (opts.encPins !== undefined && opts.encPins !== null) { + postBody['encPins'] = opts.encPins + } + if (opts.params !== undefined && opts.params !== null) { + postBody['params'] = opts.params + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 sendMessagesByEncPinUsingPOST 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( + '/sendMessagesByEncPin', + '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.appId - 应用id + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 分页大小 optional + * @param {string} [opts.status] - 状态,1申请中 2拒绝 3通过 optional + * @param {string} callback - callback + @return {Object} result + * @param smsSignVO smsSigns + * @param integer totalCount + */ + + listSmsSignsUsingGET (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling listSmsSignsUsingGET" + ) + } + + let postBody = null + let queryParams = {} + if (opts.appId !== undefined && opts.appId !== null) { + queryParams['appId'] = opts.appId + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + queryParams['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 listSmsSignsUsingGET 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( + '/smsSigns', + '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 {} opts.appId - 应用id + * @param {} [opts.applyExplanation] - 申请说明 optional + * @param {} [opts.signAttorneyUrl] - 授权委托下载地址,若短信签名用途为他用,涉及第三方权益需上传,上传至 oss optional + * @param {} opts.signCertificateUrl - 证明材料下载地址,上传至 oss + * @param {} opts.signContent - 若签名内容侵犯到第三方权益必须获得第三方真实授权,长度为 2~12 个字符无须添加【】、()、[] 符号,签名发送会自带【】符号,避免重复 + * @param {} [opts.signOtherCertificateUrl] - 其他证明材料下载地址 上传至 oss optional + * @param {} opts.signPurpose - 签名用途,0自用 1他用 + * @param {} opts.signTypeId - 签名类型id,调用listSmsSignTypesUsingGET 接口获取 + * @param {string} callback - callback + @return {Object} result + * @param string signId 签名id + */ + + createSmsSignUsingPOST (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling createSmsSignUsingPOST" + ) + } + if ( + opts.signCertificateUrl === undefined || + opts.signCertificateUrl === null + ) { + throw new Error( + "Missing the required parameter 'opts.signCertificateUrl' when calling createSmsSignUsingPOST" + ) + } + if (opts.signContent === undefined || opts.signContent === null) { + throw new Error( + "Missing the required parameter 'opts.signContent' when calling createSmsSignUsingPOST" + ) + } + if (opts.signPurpose === undefined || opts.signPurpose === null) { + throw new Error( + "Missing the required parameter 'opts.signPurpose' when calling createSmsSignUsingPOST" + ) + } + if (opts.signTypeId === undefined || opts.signTypeId === null) { + throw new Error( + "Missing the required parameter 'opts.signTypeId' when calling createSmsSignUsingPOST" + ) + } + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.applyExplanation !== undefined && opts.applyExplanation !== null) { + postBody['applyExplanation'] = opts.applyExplanation + } + if (opts.signAttorneyUrl !== undefined && opts.signAttorneyUrl !== null) { + postBody['signAttorneyUrl'] = opts.signAttorneyUrl + } + if ( + opts.signCertificateUrl !== undefined && + opts.signCertificateUrl !== null + ) { + postBody['signCertificateUrl'] = opts.signCertificateUrl + } + if (opts.signContent !== undefined && opts.signContent !== null) { + postBody['signContent'] = opts.signContent + } + if ( + opts.signOtherCertificateUrl !== undefined && + opts.signOtherCertificateUrl !== null + ) { + postBody['signOtherCertificateUrl'] = opts.signOtherCertificateUrl + } + if (opts.signPurpose !== undefined && opts.signPurpose !== null) { + postBody['signPurpose'] = opts.signPurpose + } + if (opts.signTypeId !== undefined && opts.signTypeId !== null) { + postBody['signTypeId'] = opts.signTypeId + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 createSmsSignUsingPOST 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( + '/smsSigns', + '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.signId - 签名id + * @param {string} callback - callback + @return {Object} result + * @param smsSignVO smsSignVO + */ + + getSmsSignByIdUsingGET (opts, callback) { + opts = opts || {} + + if (opts.signId === undefined || opts.signId === null) { + throw new Error( + "Missing the required parameter 'opts.signId' when calling getSmsSignByIdUsingGET" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + signId: opts.signId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 getSmsSignByIdUsingGET 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( + '/smsSigns/{signId}', + '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.signId - 签名id + * @param {} opts.appId - 应用id + * @param {} [opts.applyExplanation] - 申请说明 optional + * @param {} [opts.signAttorneyUrl] - 授权委托下载地址,若短信签名用途为他用,涉及第三方权益需上传,上传至 oss optional + * @param {} opts.signCertificateUrl - 证明材料下载地址,上传至 oss + * @param {} opts.signContent - 若签名内容侵犯到第三方权益必须获得第三方真实授权,长度为 2~12 个字符无须添加【】、()、[] 符号,签名发送会自带【】符号,避免重复 + * @param {} [opts.signOtherCertificateUrl] - 其他证明材料下载地址 上传至 oss optional + * @param {} opts.signPurpose - 签名用途,0自用 1他用 + * @param {} opts.signTypeId - 签名类型id,调用listSmsSignTypesUsingGET 接口获取 + * @param {string} callback - callback + @return {Object} result + * @param string signId 签名id + */ + + modifySmsSignUsingPOST (opts, callback) { + opts = opts || {} + + if (opts.signId === undefined || opts.signId === null) { + throw new Error( + "Missing the required parameter 'opts.signId' when calling modifySmsSignUsingPOST" + ) + } + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling modifySmsSignUsingPOST" + ) + } + if ( + opts.signCertificateUrl === undefined || + opts.signCertificateUrl === null + ) { + throw new Error( + "Missing the required parameter 'opts.signCertificateUrl' when calling modifySmsSignUsingPOST" + ) + } + if (opts.signContent === undefined || opts.signContent === null) { + throw new Error( + "Missing the required parameter 'opts.signContent' when calling modifySmsSignUsingPOST" + ) + } + if (opts.signPurpose === undefined || opts.signPurpose === null) { + throw new Error( + "Missing the required parameter 'opts.signPurpose' when calling modifySmsSignUsingPOST" + ) + } + if (opts.signTypeId === undefined || opts.signTypeId === null) { + throw new Error( + "Missing the required parameter 'opts.signTypeId' when calling modifySmsSignUsingPOST" + ) + } + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.applyExplanation !== undefined && opts.applyExplanation !== null) { + postBody['applyExplanation'] = opts.applyExplanation + } + if (opts.signAttorneyUrl !== undefined && opts.signAttorneyUrl !== null) { + postBody['signAttorneyUrl'] = opts.signAttorneyUrl + } + if ( + opts.signCertificateUrl !== undefined && + opts.signCertificateUrl !== null + ) { + postBody['signCertificateUrl'] = opts.signCertificateUrl + } + if (opts.signContent !== undefined && opts.signContent !== null) { + postBody['signContent'] = opts.signContent + } + if ( + opts.signOtherCertificateUrl !== undefined && + opts.signOtherCertificateUrl !== null + ) { + postBody['signOtherCertificateUrl'] = opts.signOtherCertificateUrl + } + if (opts.signPurpose !== undefined && opts.signPurpose !== null) { + postBody['signPurpose'] = opts.signPurpose + } + if (opts.signTypeId !== undefined && opts.signTypeId !== null) { + postBody['signTypeId'] = opts.signTypeId + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + signId: opts.signId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 modifySmsSignUsingPOST 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( + '/smsSigns/{signId}', + '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} callback - callback + @return {Object} result + * @param signType signTypes + */ + + listSmsSignTypesUsingGET (opts, callback) { + opts = opts || {} + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 listSmsSignTypesUsingGET 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( + '/smsSignTypes', + '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.appId - 应用id + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 分页大小 optional + * @param {integer} [opts.status] - 状态,1申请中 2拒绝 3通过 optional + * @param {string} callback - callback + @return {Object} result + * @param smsTaskVO smsTasks + * @param integer totalCount + */ + + listSmsTasksUsingGET (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling listSmsTasksUsingGET" + ) + } + + let postBody = null + let queryParams = {} + if (opts.appId !== undefined && opts.appId !== null) { + queryParams['appId'] = opts.appId + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + queryParams['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 listSmsTasksUsingGET 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( + '/smsTasks', + '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 {} opts.appId - 应用id + * @param {} [opts.sendNumberUrl] - 短信发送号码集合文件 optional + * @param {} [opts.sendTime] - 短信发送时间,不传表示立即发送 optional + * @param {} opts.signId - 短信签名id + * @param {} opts.taskName - 任务名称 + * @param {} opts.templateId - 短信模板id + * @param {} [opts.taskType] - 任务类型,1:通道短信 2:营销短信 optional + * @param {string} callback - callback + @return {Object} result + * @param string taskId 任务id + */ + + createSmsTaskUsingPOST (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling createSmsTaskUsingPOST" + ) + } + if (opts.signId === undefined || opts.signId === null) { + throw new Error( + "Missing the required parameter 'opts.signId' when calling createSmsTaskUsingPOST" + ) + } + if (opts.taskName === undefined || opts.taskName === null) { + throw new Error( + "Missing the required parameter 'opts.taskName' when calling createSmsTaskUsingPOST" + ) + } + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling createSmsTaskUsingPOST" + ) + } + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.sendNumberUrl !== undefined && opts.sendNumberUrl !== null) { + postBody['sendNumberUrl'] = opts.sendNumberUrl + } + if (opts.sendTime !== undefined && opts.sendTime !== null) { + postBody['sendTime'] = opts.sendTime + } + if (opts.signId !== undefined && opts.signId !== null) { + postBody['signId'] = opts.signId + } + if (opts.taskName !== undefined && opts.taskName !== null) { + postBody['taskName'] = opts.taskName + } + if (opts.templateId !== undefined && opts.templateId !== null) { + postBody['templateId'] = opts.templateId + } + if (opts.taskType !== undefined && opts.taskType !== null) { + postBody['taskType'] = opts.taskType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 createSmsTaskUsingPOST 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( + '/smsTasks', + '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.taskId - 任务id + * @param {string} callback - callback + @return {Object} result + * @param smsTaskVO smsTaskVO + */ + + getSmsTaskIdUsingGET (opts, callback) { + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling getSmsTaskIdUsingGET" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 getSmsTaskIdUsingGET 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( + '/smsTasks/{taskId}', + '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.taskId - 任务id + * @param {} opts.appId - 应用id + * @param {} [opts.sendNumberUrl] - 短信发送号码集合文件 optional + * @param {} [opts.sendTime] - 短信发送时间,不传表示立即发送 optional + * @param {} opts.signId - 短信签名id + * @param {} opts.taskName - 任务名称 + * @param {} opts.templateId - 短信模板id + * @param {string} callback - callback + @return {Object} result + * @param string taskId 任务id + */ + + modifySmsTaskUsingPOST (opts, callback) { + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling modifySmsTaskUsingPOST" + ) + } + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling modifySmsTaskUsingPOST" + ) + } + if (opts.signId === undefined || opts.signId === null) { + throw new Error( + "Missing the required parameter 'opts.signId' when calling modifySmsTaskUsingPOST" + ) + } + if (opts.taskName === undefined || opts.taskName === null) { + throw new Error( + "Missing the required parameter 'opts.taskName' when calling modifySmsTaskUsingPOST" + ) + } + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling modifySmsTaskUsingPOST" + ) + } + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.sendNumberUrl !== undefined && opts.sendNumberUrl !== null) { + postBody['sendNumberUrl'] = opts.sendNumberUrl + } + if (opts.sendTime !== undefined && opts.sendTime !== null) { + postBody['sendTime'] = opts.sendTime + } + if (opts.signId !== undefined && opts.signId !== null) { + postBody['signId'] = opts.signId + } + if (opts.taskName !== undefined && opts.taskName !== null) { + postBody['taskName'] = opts.taskName + } + if (opts.templateId !== undefined && opts.templateId !== null) { + postBody['templateId'] = opts.templateId + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 modifySmsTaskUsingPOST 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( + '/smsTasks/{taskId}', + '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.taskId - 任务id + * @param {string} callback - callback + @return {Object} result + * @param boolean success 任务删除是否成功 + */ + + taskDeleteUsingDelete (opts, callback) { + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling taskDeleteUsingDelete" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 taskDeleteUsingDelete 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( + '/smsTasks/{taskId}', + '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.taskId - 任务id + * @param {string} callback - callback + @return {Object} result + * @param boolean success 任务启动是否成功 + */ + + taskStartUsingGET (opts, callback) { + opts = opts || {} + + if (opts.taskId === undefined || opts.taskId === null) { + throw new Error( + "Missing the required parameter 'opts.taskId' when calling taskStartUsingGET" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + taskId: opts.taskId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 taskStartUsingGET 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( + '/smsTasks/{taskId}:start', + '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.signId - 签名id + * @param {string} opts.templateId - 模板id + * @param {string} callback - callback + @return {Object} result + * @param string content 短信内容预览 + * @param integer chargeCount 计费条数 + */ + + getSmsTaskContentUsingGET (opts, callback) { + opts = opts || {} + + if (opts.signId === undefined || opts.signId === null) { + throw new Error( + "Missing the required parameter 'opts.signId' when calling getSmsTaskContentUsingGET" + ) + } + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling getSmsTaskContentUsingGET" + ) + } + + let postBody = null + let queryParams = {} + if (opts.signId !== undefined && opts.signId !== null) { + queryParams['signId'] = opts.signId + } + if (opts.templateId !== undefined && opts.templateId !== null) { + queryParams['templateId'] = opts.templateId + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 getSmsTaskContentUsingGET 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( + '/smsTasks:getSmsTaskContent', + '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.appId - 应用id + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 分页大小 optional + * @param {string} [opts.status] - 状态,1申请中 2拒绝 3通过 optional + * @param {string} [opts.templateTypes] - 要查询的模板类型,多个以 , 隔开(0 验证码短信,1 通知短信,2 推广短信) optional + * @param {string} callback - callback + @return {Object} result + * @param smsTemplateVO smsTemplates + * @param integer totalCount + */ + + listSmsTemplatesUsingGET (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling listSmsTemplatesUsingGET" + ) + } + + let postBody = null + let queryParams = {} + if (opts.appId !== undefined && opts.appId !== null) { + queryParams['appId'] = opts.appId + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + queryParams['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.status !== undefined && opts.status !== null) { + queryParams['status'] = opts.status + } + if (opts.templateTypes !== undefined && opts.templateTypes !== null) { + queryParams['templateTypes'] = opts.templateTypes + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 listSmsTemplatesUsingGET 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( + '/smsTemplates', + '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 {} opts.appId - 应用id + * @param {} [opts.applyExplanation] - 申请说明 optional + * @param {} opts.templateContent - 模板内容 + * @param {} opts.templateName - 模板名称 + * @param {} opts.templateType - 模板类型:0 验证码短信,1 通知短信,2 推广短信 + * @param {string} callback - callback + @return {Object} result + * @param string templateId 模板id + */ + + createSmsTemplateUsingPOST (opts, callback) { + opts = opts || {} + + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling createSmsTemplateUsingPOST" + ) + } + if (opts.templateContent === undefined || opts.templateContent === null) { + throw new Error( + "Missing the required parameter 'opts.templateContent' when calling createSmsTemplateUsingPOST" + ) + } + if (opts.templateName === undefined || opts.templateName === null) { + throw new Error( + "Missing the required parameter 'opts.templateName' when calling createSmsTemplateUsingPOST" + ) + } + if (opts.templateType === undefined || opts.templateType === null) { + throw new Error( + "Missing the required parameter 'opts.templateType' when calling createSmsTemplateUsingPOST" + ) + } + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.applyExplanation !== undefined && opts.applyExplanation !== null) { + postBody['applyExplanation'] = opts.applyExplanation + } + if (opts.templateContent !== undefined && opts.templateContent !== null) { + postBody['templateContent'] = opts.templateContent + } + if (opts.templateName !== undefined && opts.templateName !== null) { + postBody['templateName'] = opts.templateName + } + if (opts.templateType !== undefined && opts.templateType !== null) { + postBody['templateType'] = opts.templateType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 createSmsTemplateUsingPOST 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( + '/smsTemplates', + '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.templateId - 模板id + * @param {string} callback - callback + @return {Object} result + * @param smsTemplateVO smsTemplateVO + */ + + getSmsTemplateByIdUsingGET (opts, callback) { + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling getSmsTemplateByIdUsingGET" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 getSmsTemplateByIdUsingGET 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( + '/smsTemplates/{templateId}', + '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.templateId - 模板id + * @param {} opts.appId - 应用id + * @param {} [opts.applyExplanation] - 申请说明 optional + * @param {} opts.templateContent - 模板内容 + * @param {} opts.templateName - 模板名称 + * @param {} opts.templateType - 模板类型:0 验证码短信,1 通知短信,2 推广短信 + * @param {string} callback - callback + @return {Object} result + * @param string templateId 模板id + */ + + modifySmsTemplateUsingPOST (opts, callback) { + opts = opts || {} + + if (opts.templateId === undefined || opts.templateId === null) { + throw new Error( + "Missing the required parameter 'opts.templateId' when calling modifySmsTemplateUsingPOST" + ) + } + if (opts.appId === undefined || opts.appId === null) { + throw new Error( + "Missing the required parameter 'opts.appId' when calling modifySmsTemplateUsingPOST" + ) + } + if (opts.templateContent === undefined || opts.templateContent === null) { + throw new Error( + "Missing the required parameter 'opts.templateContent' when calling modifySmsTemplateUsingPOST" + ) + } + if (opts.templateName === undefined || opts.templateName === null) { + throw new Error( + "Missing the required parameter 'opts.templateName' when calling modifySmsTemplateUsingPOST" + ) + } + if (opts.templateType === undefined || opts.templateType === null) { + throw new Error( + "Missing the required parameter 'opts.templateType' when calling modifySmsTemplateUsingPOST" + ) + } + + let postBody = {} + if (opts.appId !== undefined && opts.appId !== null) { + postBody['appId'] = opts.appId + } + if (opts.applyExplanation !== undefined && opts.applyExplanation !== null) { + postBody['applyExplanation'] = opts.applyExplanation + } + if (opts.templateContent !== undefined && opts.templateContent !== null) { + postBody['templateContent'] = opts.templateContent + } + if (opts.templateName !== undefined && opts.templateName !== null) { + postBody['templateName'] = opts.templateName + } + if (opts.templateType !== undefined && opts.templateType !== null) { + postBody['templateType'] = opts.templateType + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + templateId: opts.templateId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 modifySmsTemplateUsingPOST 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( + '/smsTemplates/{templateId}', + '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} callback - callback + @return {Object} result + * @param boolean success 是否开通成功 + */ + + openServiceUsingPOST (opts, callback) { + opts = opts || {} + + let postBody = {} + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 openServiceUsingPOST 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( + '/smsUsers', + '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.packageType - 通道类型,1通道短信,2官方短信 + * @param {string} callback - callback + @return {Object} result + * @param integer packageType 套餐包类型 1通道短信,2官方短信 + * @param integer remaining 剩余可调用次数 + * @param integer totalCount 总量 + * @param string remainingRate 剩余百分比 + */ + + queryRemainingUsingGET (opts, callback) { + opts = opts || {} + + if (opts.packageType === undefined || opts.packageType === null) { + throw new Error( + "Missing the required parameter 'opts.packageType' when calling queryRemainingUsingGET" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + packageType: opts.packageType + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 queryRemainingUsingGET 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( + '/smsUsers/{packageType}:queryRemaining', + '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.packageType - 通道类型,1通道短信,2官方短信 + * @param {string} callback - callback + @return {Object} result + * @param integer packageType 套餐包类型 1通道短信,2官方短信 + * @param integer amount 发送量 + */ + + queryAmountUsingGET (opts, callback) { + opts = opts || {} + + if (opts.packageType === undefined || opts.packageType === null) { + throw new Error( + "Missing the required parameter 'opts.packageType' when calling queryAmountUsingGET" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud', + packageType: opts.packageType + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 ydsms/1.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 queryAmountUsingGET 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( + '/smsUsers/{packageType}:queryAmount', + '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 = YDSMS diff --git a/packages/libs/lib-jdcloud/src/repo/yunding/v2/yunding.js b/packages/libs/lib-jdcloud/src/repo/yunding/v2/yunding.js new file mode 100644 index 000000000..cf0e54e81 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/yunding/v2/yunding.js @@ -0,0 +1,4456 @@ +/* + * 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 diff --git a/packages/libs/lib-jdcloud/src/repo/yundingdatapush/v1/yundingdatapush.js b/packages/libs/lib-jdcloud/src/repo/yundingdatapush/v1/yundingdatapush.js new file mode 100644 index 000000000..cdab33b92 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/yundingdatapush/v1/yundingdatapush.js @@ -0,0 +1,495 @@ +/* + * 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-datapush + * 云鼎数据推送OPENAPI接口 + * + * 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 = 'yundingdatapush' +Service._services[serviceId] = true + +/** + * yundingdatapush service. + * @version 1.0.3 + */ + +JDCloud.YUNDINGDATAPUSH = class YUNDINGDATAPUSH extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'yundingdatapush.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * 查询已经开通的用户 + * @param {Object} opts - parameters + * @param {string} opts.appkey - appkey + * @param {integer} [opts.pageNumber] - 页码 optional + * @param {integer} [opts.pageSize] - 页大小 optional + * @param {string} [opts.ydRdsInstanceId] - 云鼎数据库实例ID optional + * @param {string} [opts.rdsInstanceName] - 数据库实例名称 optional + * @param {string} [opts.venderId] - 商家ID optional + * @param {string} [opts.venderName] - 商家店铺名称 optional + * @param {string} callback - callback + @return {Object} result + * @param venderShow venders + */ + + describeDatapushVenders (opts, callback) { + opts = opts || {} + + if (opts.appkey === undefined || opts.appkey === null) { + throw new Error( + "Missing the required parameter 'opts.appkey' when calling describeDatapushVenders" + ) + } + + let postBody = null + let queryParams = {} + if (opts.appkey !== undefined && opts.appkey !== null) { + queryParams['appkey'] = opts.appkey + } + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + queryParams['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + queryParams['pageSize'] = opts.pageSize + } + if (opts.ydRdsInstanceId !== undefined && opts.ydRdsInstanceId !== null) { + queryParams['ydRdsInstanceId'] = opts.ydRdsInstanceId + } + if (opts.rdsInstanceName !== undefined && opts.rdsInstanceName !== null) { + queryParams['rdsInstanceName'] = opts.rdsInstanceName + } + if (opts.venderId !== undefined && opts.venderId !== null) { + queryParams['venderId'] = opts.venderId + } + if (opts.venderName !== undefined && opts.venderName !== null) { + queryParams['venderName'] = opts.venderName + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 yundingdatapush/1.0.3' + } + + 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 describeDatapushVenders 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 = this.makeRequest( + '/datapushVenders', + '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 {vender} opts.datapushVender - 添加数据推送用户对象 + + * @param {string} callback - callback + @return {Object} result + * @param boolean success 操作是否成功 + */ + + addDatapushVender (opts, callback) { + opts = opts || {} + + if (opts.datapushVender === undefined || opts.datapushVender === null) { + throw new Error( + "Missing the required parameter 'opts.datapushVender' when calling addDatapushVender" + ) + } + + let postBody = {} + if (opts.datapushVender !== undefined && opts.datapushVender !== null) { + postBody['datapushVender'] = opts.datapushVender + } + + let queryParams = {} + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 yundingdatapush/1.0.3' + } + + 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 addDatapushVender 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 = this.makeRequest( + '/datapushVenders', + '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.appkey - appkey + * @param {string} opts.ydRdsInstanceId - 云鼎数据库实例ID + * @param {string} opts.venderId - 商家ID + * @param {string} callback - callback + @return {Object} result + * @param boolean success 操作是否成功 + */ + + deleteDatapushVender (opts, callback) { + opts = opts || {} + + if (opts.appkey === undefined || opts.appkey === null) { + throw new Error( + "Missing the required parameter 'opts.appkey' when calling deleteDatapushVender" + ) + } + if (opts.ydRdsInstanceId === undefined || opts.ydRdsInstanceId === null) { + throw new Error( + "Missing the required parameter 'opts.ydRdsInstanceId' when calling deleteDatapushVender" + ) + } + if (opts.venderId === undefined || opts.venderId === null) { + throw new Error( + "Missing the required parameter 'opts.venderId' when calling deleteDatapushVender" + ) + } + + let postBody = null + let queryParams = {} + if (opts.appkey !== undefined && opts.appkey !== null) { + queryParams['appkey'] = opts.appkey + } + if (opts.ydRdsInstanceId !== undefined && opts.ydRdsInstanceId !== null) { + queryParams['ydRdsInstanceId'] = opts.ydRdsInstanceId + } + if (opts.venderId !== undefined && opts.venderId !== null) { + queryParams['venderId'] = opts.venderId + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 yundingdatapush/1.0.3' + } + + 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 deleteDatapushVender 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 = this.makeRequest( + '/datapushVenders', + '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} callback - callback + @return {Object} result + * @param rdsInstance rdsInstances + */ + + describeRdsInstances (opts, callback) { + opts = opts || {} + + if (opts.appkey === undefined || opts.appkey === null) { + throw new Error( + "Missing the required parameter 'opts.appkey' when calling describeRdsInstances" + ) + } + + let postBody = null + let queryParams = {} + if (opts.appkey !== undefined && opts.appkey !== null) { + queryParams['appkey'] = opts.appkey + } + + let pathParams = { + regionId: 'jdcloud' + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 yundingdatapush/1.0.3' + } + + 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 = this.makeRequest( + '/describeRdsInstances', + '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 = JDCloud.YUNDINGDATAPUSH diff --git a/packages/libs/lib-jdcloud/src/repo/zfs/v1/zfs.js b/packages/libs/lib-jdcloud/src/repo/zfs/v1/zfs.js new file mode 100644 index 000000000..f79616c4b --- /dev/null +++ b/packages/libs/lib-jdcloud/src/repo/zfs/v1/zfs.js @@ -0,0 +1,1267 @@ +/* + * 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. + * + * Mount-Target + * 挂载目标相关接口。 + * + * 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 = 'zfs' +Service._services[serviceId] = true + +/** + * zfs service. + * @version 1.0.9 + */ + +class ZFS extends Service { + constructor (options = {}) { + options._defaultEndpoint = {} + options._defaultEndpoint.protocol = + options._defaultEndpoint.protocol || 'https' + options._defaultEndpoint.host = + options._defaultEndpoint.host || 'cfs.jdcloud-api.com' + options.basePath = '/v1' // 默认要设为空"" + super(serviceId, options) + } + + /** + * - 查询文件系统列表。 +- filters多个过滤条件之间是逻辑与(AND),每个条件内部的多个取值是逻辑或(OR) + + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞) optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {filter} [opts.filters] - fileSystemId - 文件系统ID,精确匹配,支持多个 +name - 文件系统名称,模糊匹配,支持单个 +status - 文件系统状态,精确匹配,支持多个 FileSystem Status/creating、available、in-use + optional + * @param {tagFilter} [opts.tags] - Tag筛选条件 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param fileSystem fileSystems + * @param integer totalCount 查询的文件系统数目 + */ + + describeFileSystems (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 describeFileSystems" + ) + } + + 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')) + Object.assign(queryParams, super.buildTagFilterParam(opts.tags, 'tags')) + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 zfs/1.0.9' + } + + 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 describeFileSystems 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}/fileSystems', + '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) + } + ) + } + + /** + * - 创建一个新的文件系统,为这个文件系统分配一个Id + + * @param {Object} opts - parameters + * @param {string} opts.name - 文件系统名称 + * @param {string} opts.description - 文件系统描述 + * @param {string} opts.clientToken - 幂等性参数(只支持数字、大小写字母,且不能超过64字符) + * @param {string} [opts.fileSystemType] - 文件系统类型(通用型:gp1,容量型:std1),默认为通用型 optional + * @param {string} [opts.serviceCode] - 文件系统的serviceCode,默认为zfs optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string fileSystemId 文件系统 ID + */ + + createFileSystem (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 createFileSystem" + ) + } + + opts = opts || {} + + if (opts.name === undefined || opts.name === null) { + throw new Error( + "Missing the required parameter 'opts.name' when calling createFileSystem" + ) + } + if (opts.description === undefined || opts.description === null) { + throw new Error( + "Missing the required parameter 'opts.description' when calling createFileSystem" + ) + } + if (opts.clientToken === undefined || opts.clientToken === null) { + throw new Error( + "Missing the required parameter 'opts.clientToken' when calling createFileSystem" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + if (opts.fileSystemType !== undefined && opts.fileSystemType !== null) { + postBody['fileSystemType'] = opts.fileSystemType + } + if (opts.serviceCode !== undefined && opts.serviceCode !== null) { + postBody['serviceCode'] = opts.serviceCode + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 zfs/1.0.9' + } + + 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 createFileSystem 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}/fileSystems', + '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.fileSystemId - 文件系统ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param fileSystem fileSystem + */ + + describeFileSystem (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 describeFileSystem" + ) + } + + opts = opts || {} + + if (opts.fileSystemId === undefined || opts.fileSystemId === null) { + throw new Error( + "Missing the required parameter 'opts.fileSystemId' when calling describeFileSystem" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + fileSystemId: opts.fileSystemId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 zfs/1.0.9' + } + + 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 describeFileSystem 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}/fileSystems/{fileSystemId}', + '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) + } + ) + } + + /** + * 修改文件系统属性(name 和 description 必须要指定一个) + * @param {Object} opts - parameters + * @param {string} opts.fileSystemId - 文件系统ID + * @param {string} [opts.name] - 文件系统名称(参数规则:不可为空,只支持中文、数字、大小写字母、英文下划线“_”及中划线“-”,且不能超过32字符) optional + * @param {string} [opts.description] - 文件系统描述(参数规则:不能超过256字符) optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + modifyFileSystemAttribute (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 modifyFileSystemAttribute" + ) + } + + opts = opts || {} + + if (opts.fileSystemId === undefined || opts.fileSystemId === null) { + throw new Error( + "Missing the required parameter 'opts.fileSystemId' when calling modifyFileSystemAttribute" + ) + } + + let postBody = {} + if (opts.name !== undefined && opts.name !== null) { + postBody['name'] = opts.name + } + if (opts.description !== undefined && opts.description !== null) { + postBody['description'] = opts.description + } + + let queryParams = {} + + let pathParams = { + regionId: regionId, + fileSystemId: opts.fileSystemId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 zfs/1.0.9' + } + + 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 modifyFileSystemAttribute 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}/fileSystems/{fileSystemId}', + 'PATCH', + 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) + } + ) + } + + /** + * - 删除一个文件系统,一旦删除,该文件系统将不存在,也无法访问已删除的文件系统里的任何内容。 + [MFA enabled] + * @param {Object} opts - parameters + * @param {string} opts.fileSystemId - 文件系统ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteFileSystem (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 deleteFileSystem" + ) + } + + opts = opts || {} + + if (opts.fileSystemId === undefined || opts.fileSystemId === null) { + throw new Error( + "Missing the required parameter 'opts.fileSystemId' when calling deleteFileSystem" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + fileSystemId: opts.fileSystemId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 zfs/1.0.9' + } + + 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 deleteFileSystem 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}/fileSystems/{fileSystemId}', + '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) + } + ) + } + + /** + * 查询挂载客户端IP + * @param {Object} opts - parameters + * @param {integer} [opts.pageNumber] - 页码, 默认为1, 取值范围:[1,∞) optional + * @param {integer} [opts.pageSize] - 分页大小,默认为10,取值范围:[10,100] optional + * @param {string} opts.fileSystemId - 文件系统ID + * @param {string} [opts.mountTargetId] - 挂载目标ID optional + * @param {array} [opts.clientIP] - 查询客户端IP数组 optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string clientsIPs + * @param integer totalCount 结果集数目 + */ + + describeMountedClients (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 describeMountedClients" + ) + } + + opts = opts || {} + + if (opts.fileSystemId === undefined || opts.fileSystemId === null) { + throw new Error( + "Missing the required parameter 'opts.fileSystemId' when calling describeMountedClients" + ) + } + + let postBody = {} + if (opts.pageNumber !== undefined && opts.pageNumber !== null) { + postBody['pageNumber'] = opts.pageNumber + } + if (opts.pageSize !== undefined && opts.pageSize !== null) { + postBody['pageSize'] = opts.pageSize + } + if (opts.fileSystemId !== undefined && opts.fileSystemId !== null) { + postBody['fileSystemId'] = opts.fileSystemId + } + if (opts.mountTargetId !== undefined && opts.mountTargetId !== null) { + postBody['mountTargetId'] = opts.mountTargetId + } + if (opts.clientIP !== undefined && opts.clientIP !== null) { + postBody['clientIP'] = opts.clientIP + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 zfs/1.0.9' + } + + 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 describeMountedClients 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}/describeMountedClients', + '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.pageNumber] - 页码, 默认为1, 取值范围:[1,∞) optional + * @param {integer} [opts.pageSize] - 分页大小,默认为20,取值范围:[10,100] optional + * @param {filter} [opts.filters] - fileSystemId - 文件系统ID,精确匹配,支持多个 +mountTargetId - 挂载目标ID,精确匹配,支持多个 + optional + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param mountTarget mountTargets + * @param integer totalCount 查询的挂载目标数目 + */ + + describeMountTargets (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 describeMountTargets" + ) + } + + 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 zfs/1.0.9' + } + + 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 describeMountTargets 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}/mountTargets', + '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) + } + ) + } + + /** + * - 为一个文件系统创建一个挂载目标。通过这个挂载目标,你可以挂载将一个文件系统挂载到主机实例上。 +- 创建一个挂载目标,为这个挂载目标分配一个Id + + * @param {Object} opts - parameters + * @param {string} opts.fileSystemId - 创建挂载目标的文件系统 + * @param {string} opts.subnetId - 子网id + * @param {string} opts.vpcId - vpcId + * @param {string} [opts.securityGroupId] - 安全组id optional + * @param {string} opts.clientToken - 幂等性参数(只支持数字、大小写字母,且不能超过64字符) + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param string mountTargetId 挂载目标 ID + */ + + createMountTarget (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 createMountTarget" + ) + } + + opts = opts || {} + + if (opts.fileSystemId === undefined || opts.fileSystemId === null) { + throw new Error( + "Missing the required parameter 'opts.fileSystemId' when calling createMountTarget" + ) + } + if (opts.subnetId === undefined || opts.subnetId === null) { + throw new Error( + "Missing the required parameter 'opts.subnetId' when calling createMountTarget" + ) + } + if (opts.vpcId === undefined || opts.vpcId === null) { + throw new Error( + "Missing the required parameter 'opts.vpcId' when calling createMountTarget" + ) + } + if (opts.clientToken === undefined || opts.clientToken === null) { + throw new Error( + "Missing the required parameter 'opts.clientToken' when calling createMountTarget" + ) + } + + let postBody = {} + if (opts.fileSystemId !== undefined && opts.fileSystemId !== null) { + postBody['fileSystemId'] = opts.fileSystemId + } + if (opts.subnetId !== undefined && opts.subnetId !== null) { + postBody['subnetId'] = opts.subnetId + } + if (opts.vpcId !== undefined && opts.vpcId !== null) { + postBody['vpcId'] = opts.vpcId + } + if (opts.securityGroupId !== undefined && opts.securityGroupId !== null) { + postBody['securityGroupId'] = opts.securityGroupId + } + if (opts.clientToken !== undefined && opts.clientToken !== null) { + postBody['clientToken'] = opts.clientToken + } + + let queryParams = {} + + let pathParams = { + regionId: regionId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 zfs/1.0.9' + } + + 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 createMountTarget 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}/mountTargets', + '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.mountTargetId - 挂载目标ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + * @param mountTarget mountTarget + */ + + describeMountTarget (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 describeMountTarget" + ) + } + + opts = opts || {} + + if (opts.mountTargetId === undefined || opts.mountTargetId === null) { + throw new Error( + "Missing the required parameter 'opts.mountTargetId' when calling describeMountTarget" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + mountTargetId: opts.mountTargetId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 zfs/1.0.9' + } + + 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 describeMountTarget 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}/mountTargets/{mountTargetId}', + '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.mountTargetId - 挂载目标ID + * @param {string} regionId - ID of the region + * @param {string} callback - callback + @return {Object} result + */ + + deleteMountTarget (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 deleteMountTarget" + ) + } + + opts = opts || {} + + if (opts.mountTargetId === undefined || opts.mountTargetId === null) { + throw new Error( + "Missing the required parameter 'opts.mountTargetId' when calling deleteMountTarget" + ) + } + + let postBody = null + let queryParams = {} + + let pathParams = { + regionId: regionId, + mountTargetId: opts.mountTargetId + } + + let headerParams = { + 'User-Agent': 'JdcloudSdkNode/1.0.0 zfs/1.0.9' + } + + 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 deleteMountTarget 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}/mountTargets/{mountTargetId}', + '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) + } + ) + } +} +module.exports = ZFS diff --git a/packages/libs/lib-jdcloud/src/services/.gitkeep b/packages/libs/lib-jdcloud/src/services/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/packages/libs/lib-jdcloud/src/services/ag.js b/packages/libs/lib-jdcloud/src/services/ag.js new file mode 100644 index 000000000..4e81eb977 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/ag.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Quota + * 关于高可用组配额的接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'ag' +Service._services[serviceId] = true + +/** + * ag service. + */ + +JDCloud.AG = class AG { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'ag' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.AG diff --git a/packages/libs/lib-jdcloud/src/services/all.js b/packages/libs/lib-jdcloud/src/services/all.js new file mode 100644 index 000000000..908ccaa7e --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/all.js @@ -0,0 +1,120 @@ +module.exports = { + RDTS: require('./rdts'), + VQD: require('./vqd'), + SMARTDBA: require('./smartdba'), + DMS: require('./dms'), + STREAMCOMPUTER: require('./streamcomputer'), + FLOWLOG: require('./flowlog'), + SSL: require('./ssl'), + OSS: require('./oss'), + REDIS: require('./redis'), + DOMAINSERVICE: require('./domainservice'), + BILLING: require('./billing'), + GCS: require('./gcs'), + QUOTA: require('./quota'), + BRI: require('./bri'), + EDCPS: require('./edcps'), + BASTION: require('./bastion'), + PORTAL: require('./portal'), + ORDER: require('./order'), + CLOUDDNSSERVICE: require('./clouddnsservice'), + AG: require('./ag'), + INSTANCEVOUCHER: require('./instancevoucher'), + CDN: require('./cdn'), + IV: require('./iv'), + STREAMBUS: require('./streambus'), + APIGATEWAY: require('./apigateway'), + MPS: require('./mps'), + STS: require('./sts'), + KAFKA: require('./kafka'), + DOMAIN: require('./domain'), + NATIVECONTAINER: require('./nativecontainer'), + PRIVATEZONE: require('./privatezone'), + STARSHIELD: require('./starshield'), + REFUND: require('./refund'), + EID: require('./eid'), + POD: require('./pod'), + JKE: require('./jke'), + DATASTAR: require('./datastar'), + USERPOOL: require('./userpool'), + KMS: require('./kms'), + ELITE: require('./elite'), + IAM: require('./iam'), + IOTHUB: require('./iothub'), + SMS: require('./sms'), + JCQ: require('./jcq'), + RESOURCETAG: require('./resourcetag'), + IAS: require('./ias'), + JDFUSION: require('./jdfusion'), + DETECTION: require('./detection'), + RENEWAL: require('./renewal'), + IOTLINK: require('./iotlink'), + YUNDING: require('./yunding'), + CP: require('./cp'), + CR: require('./cr'), + PIPELINE: require('./pipeline'), + CONTAINERREGISTRY: require('./containerregistry'), + PARTNER: require('./partner'), + LB: require('./lb'), + IOTCARD: require('./iotcard'), + CENSOR: require('./censor'), + INDUSTRYDATA: require('./industrydata'), + JDW: require('./jdw'), + ASSET: require('./asset'), + AUTOTASKPOLICY: require('./autotaskpolicy'), + RDS: require('./rds'), + KUBERNETES: require('./kubernetes'), + DH: require('./dh'), + TIDB: require('./tidb'), + IPANTI: require('./ipanti'), + ANTIPRO: require('./antipro'), + JMR: require('./jmr'), + DEPLOY: require('./deploy'), + COMPILE: require('./compile'), + SOP: require('./sop'), + CAPTCHA: require('./captcha'), + FUNCTION: require('./function'), + RESERVEDINSTANCE: require('./reservedinstance'), + RMS: require('./rms'), + LOGS: require('./logs'), + JDCCS: require('./jdccs'), + IOTEDGE: require('./iotedge'), + CPS: require('./cps'), + DBAUDIT: require('./dbaudit'), + HUFU: require('./hufu'), + ES: require('./es'), + HTTPDNS: require('./httpdns'), + DISK: require('./disk'), + DBS: require('./dbs'), + NC: require('./nc'), + YDSMS: require('./ydsms'), + CLICKHOUSE: require('./clickhouse'), + VM: require('./vm'), + FC: require('./fc'), + DCAP: require('./dcap'), + CLOUDAUTH: require('./cloudauth'), + IOTCORE: require('./iotcore'), + AMS: require('./ams'), + JDRO: require('./jdro'), + ZFS: require('./zfs'), + VOD: require('./vod'), + YUNDINGDATAPUSH: require('./yundingdatapush'), + OSSOPENAPI: require('./ossopenapi'), + BGW: require('./bgw'), + CLOUDSIGN: require('./cloudsign'), + BASEANTI: require('./baseanti'), + MONGODB: require('./mongodb'), + WAF: require('./waf'), + LIVE: require('./live'), + LAVM: require('./lavm'), + JDWORKSPACE: require('./jdworkspace'), + DTS: require('./dts'), + ASSISTANT: require('./assistant'), + VPC: require('./vpc'), + MONITOR: require('./monitor'), + XDATA: require('./xdata'), + OPENJRTC: require('./openjrtc'), + IOTCLOUDGATEWAY: require('./iotcloudgateway'), + INVOICE: require('./invoice'), + USER: require('./user') +} diff --git a/packages/libs/lib-jdcloud/src/services/ams.js b/packages/libs/lib-jdcloud/src/services/ams.js new file mode 100644 index 000000000..14c4ce813 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/ams.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 应用管理平台API (仅对授权用户使用) + * 应用管理平台API + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'ams' +Service._services[serviceId] = true + +/** + * ams service. + */ + +JDCloud.AMS = class AMS { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'ams' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.AMS diff --git a/packages/libs/lib-jdcloud/src/services/antipro.js b/packages/libs/lib-jdcloud/src/services/antipro.js new file mode 100644 index 000000000..8ab0e9dd9 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/antipro.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Operation Records APIs + * Anti DDoS Protection Package Operation Records APIs + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'antipro' +Service._services[serviceId] = true + +/** + * antipro service. + */ + +JDCloud.ANTIPRO = class ANTIPRO { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'antipro' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.ANTIPRO diff --git a/packages/libs/lib-jdcloud/src/services/apigateway.js b/packages/libs/lib-jdcloud/src/services/apigateway.js new file mode 100644 index 000000000..281f3745c --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/apigateway.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 自定义域名 + * api 自定义域名 service + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'apigateway' +Service._services[serviceId] = true + +/** + * apigateway service. + */ + +JDCloud.APIGATEWAY = class APIGATEWAY { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'apigateway' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.APIGATEWAY diff --git a/packages/libs/lib-jdcloud/src/services/asset.js b/packages/libs/lib-jdcloud/src/services/asset.js new file mode 100644 index 000000000..ac2447e49 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/asset.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * JDCLOUD asset API + * API JDCLOUD asset API + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'asset' +Service._services[serviceId] = true + +/** + * asset service. + */ + +JDCloud.ASSET = class ASSET { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'asset' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.ASSET diff --git a/packages/libs/lib-jdcloud/src/services/assistant.js b/packages/libs/lib-jdcloud/src/services/assistant.js new file mode 100644 index 000000000..0b7fecc4c --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/assistant.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * LogConfig + * 用户日志相关配置 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'assistant' +Service._services[serviceId] = true + +/** + * assistant service. + */ + +JDCloud.ASSISTANT = class ASSISTANT { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'assistant' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.ASSISTANT diff --git a/packages/libs/lib-jdcloud/src/services/autotaskpolicy.js b/packages/libs/lib-jdcloud/src/services/autotaskpolicy.js new file mode 100644 index 000000000..f68b656f3 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/autotaskpolicy.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 配额 + * 与配额相关的接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'autotaskpolicy' +Service._services[serviceId] = true + +/** + * autotaskpolicy service. + */ + +JDCloud.AUTOTASKPOLICY = class AUTOTASKPOLICY { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'autotaskpolicy' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.AUTOTASKPOLICY diff --git a/packages/libs/lib-jdcloud/src/services/baseanti.js b/packages/libs/lib-jdcloud/src/services/baseanti.js new file mode 100644 index 000000000..f098f1f65 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/baseanti.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * IP Resource APIs + * Anti DDoS Basic IP Resource APIs + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'baseanti' +Service._services[serviceId] = true + +/** + * baseanti service. + */ + +JDCloud.BASEANTI = class BASEANTI { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'baseanti' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.BASEANTI diff --git a/packages/libs/lib-jdcloud/src/services/bastion.js b/packages/libs/lib-jdcloud/src/services/bastion.js new file mode 100644 index 000000000..99487e1a9 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/bastion.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * statistics + * 堡垒机规格分布数量信息 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'bastion' +Service._services[serviceId] = true + +/** + * bastion service. + */ + +JDCloud.BASTION = class BASTION { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'bastion' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.BASTION diff --git a/packages/libs/lib-jdcloud/src/services/bgw.js b/packages/libs/lib-jdcloud/src/services/bgw.js new file mode 100644 index 000000000..aaa4b8ac1 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/bgw.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * instances + * 续费查询实例信息接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'bgw' +Service._services[serviceId] = true + +/** + * bgw service. + */ + +JDCloud.BGW = class BGW { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'bgw' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.BGW diff --git a/packages/libs/lib-jdcloud/src/services/billing.js b/packages/libs/lib-jdcloud/src/services/billing.js new file mode 100644 index 000000000..852589152 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/billing.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 停删规则 + * 停删规则 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'billing' +Service._services[serviceId] = true + +/** + * billing service. + */ + +JDCloud.BILLING = class BILLING { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'billing' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.BILLING diff --git a/packages/libs/lib-jdcloud/src/services/bri.js b/packages/libs/lib-jdcloud/src/services/bri.js new file mode 100644 index 000000000..ff7cb944f --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/bri.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 页面测试检测接口 + * 京东云信用评分-OpenAPI页面测试检测接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'bri' +Service._services[serviceId] = true + +/** + * bri service. + */ + +JDCloud.BRI = class BRI { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'bri' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.BRI diff --git a/packages/libs/lib-jdcloud/src/services/captcha.js b/packages/libs/lib-jdcloud/src/services/captcha.js new file mode 100644 index 000000000..3498adbf9 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/captcha.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 运营后台类接口 + * 京东云验证码-OpenAPI应用管理类接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'captcha' +Service._services[serviceId] = true + +/** + * captcha service. + */ + +JDCloud.CAPTCHA = class CAPTCHA { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'captcha' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.CAPTCHA diff --git a/packages/libs/lib-jdcloud/src/services/cdn.js b/packages/libs/lib-jdcloud/src/services/cdn.js new file mode 100644 index 000000000..9195cde25 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/cdn.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * SCDN相关接口 + * Openapi For JCLOUD cdn + * + * OpenAPI spec version: v1 + * Contact: pid-cdn@jd.com + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'cdn' +Service._services[serviceId] = true + +/** + * cdn service. + */ + +JDCloud.CDN = class CDN { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'cdn' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.CDN diff --git a/packages/libs/lib-jdcloud/src/services/censor.js b/packages/libs/lib-jdcloud/src/services/censor.js new file mode 100644 index 000000000..1662424e1 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/censor.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 站点检测类接口 + * 京东云内容安全-OpenAPI站点检测类接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'censor' +Service._services[serviceId] = true + +/** + * censor service. + */ + +JDCloud.CENSOR = class CENSOR { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'censor' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.CENSOR diff --git a/packages/libs/lib-jdcloud/src/services/clickhouse.js b/packages/libs/lib-jdcloud/src/services/clickhouse.js new file mode 100644 index 000000000..988fbfb5b --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/clickhouse.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 白名单 + * 白名单相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'clickhouse' +Service._services[serviceId] = true + +/** + * clickhouse service. + */ + +JDCloud.CLICKHOUSE = class CLICKHOUSE { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'clickhouse' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.CLICKHOUSE diff --git a/packages/libs/lib-jdcloud/src/services/cloudauth.js b/packages/libs/lib-jdcloud/src/services/cloudauth.js new file mode 100644 index 000000000..dfbdd2215 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/cloudauth.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 用户管理接口 + * 实名认证-用户管理接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'cloudauth' +Service._services[serviceId] = true + +/** + * cloudauth service. + */ + +JDCloud.CLOUDAUTH = class CLOUDAUTH { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'cloudauth' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.CLOUDAUTH diff --git a/packages/libs/lib-jdcloud/src/services/clouddnsservice.js b/packages/libs/lib-jdcloud/src/services/clouddnsservice.js new file mode 100644 index 000000000..554d496be --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/clouddnsservice.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 实例信息 + * 云解析OpenAPI实例信息接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'clouddnsservice' +Service._services[serviceId] = true + +/** + * clouddnsservice service. + */ + +JDCloud.CLOUDDNSSERVICE = class CLOUDDNSSERVICE { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'clouddnsservice' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.CLOUDDNSSERVICE diff --git a/packages/libs/lib-jdcloud/src/services/cloudsign.js b/packages/libs/lib-jdcloud/src/services/cloudsign.js new file mode 100644 index 000000000..aead37eb2 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/cloudsign.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * OLD合同模板管理接口 + * OLD合同模板管理接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'cloudsign' +Service._services[serviceId] = true + +/** + * cloudsign service. + */ + +JDCloud.CLOUDSIGN = class CLOUDSIGN { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'cloudsign' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.CLOUDSIGN diff --git a/packages/libs/lib-jdcloud/src/services/compile.js b/packages/libs/lib-jdcloud/src/services/compile.js new file mode 100644 index 000000000..4b26c519c --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/compile.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * code api + * API related to build + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'compile' +Service._services[serviceId] = true + +/** + * compile service. + */ + +JDCloud.COMPILE = class COMPILE { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'compile' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.COMPILE diff --git a/packages/libs/lib-jdcloud/src/services/containerregistry.js b/packages/libs/lib-jdcloud/src/services/containerregistry.js new file mode 100644 index 000000000..37ca0f7d7 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/containerregistry.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Repository + * 容器镜像仓库相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'containerregistry' +Service._services[serviceId] = true + +/** + * containerregistry service. + */ + +JDCloud.CONTAINERREGISTRY = class CONTAINERREGISTRY { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'containerregistry' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.CONTAINERREGISTRY diff --git a/packages/libs/lib-jdcloud/src/services/cp.js b/packages/libs/lib-jdcloud/src/services/cp.js new file mode 100644 index 000000000..8816bd6f6 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/cp.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Partner UserAuth Management + * Partner UserAuth Management API + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'cp' +Service._services[serviceId] = true + +/** + * cp service. + */ + +JDCloud.CP = class CP { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'cp' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.CP diff --git a/packages/libs/lib-jdcloud/src/services/cps.js b/packages/libs/lib-jdcloud/src/services/cps.js new file mode 100644 index 000000000..e5bb99dbe --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/cps.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Cloud-Physical-Server + * 云物理服务器私有网络操作相关的接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'cps' +Service._services[serviceId] = true + +/** + * cps service. + */ + +JDCloud.CPS = class CPS { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'cps' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.CPS diff --git a/packages/libs/lib-jdcloud/src/services/cr.js b/packages/libs/lib-jdcloud/src/services/cr.js new file mode 100644 index 000000000..abc56560d --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/cr.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Repository + * 容器镜像仓库相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'cr' +Service._services[serviceId] = true + +/** + * cr service. + */ + +JDCloud.CR = class CR { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'cr' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.CR diff --git a/packages/libs/lib-jdcloud/src/services/datastar.js b/packages/libs/lib-jdcloud/src/services/datastar.js new file mode 100644 index 000000000..9315801d2 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/datastar.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 大屏数据查询接口 + * 陕西苹果大屏数据查询接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'datastar' +Service._services[serviceId] = true + +/** + * datastar service. + */ + +JDCloud.DATASTAR = class DATASTAR { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'datastar' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.DATASTAR diff --git a/packages/libs/lib-jdcloud/src/services/dbaudit.js b/packages/libs/lib-jdcloud/src/services/dbaudit.js new file mode 100644 index 000000000..8d2f19b3a --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/dbaudit.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Rule Interface + * Rule Interface + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'dbaudit' +Service._services[serviceId] = true + +/** + * dbaudit service. + */ + +JDCloud.DBAUDIT = class DBAUDIT { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'dbaudit' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.DBAUDIT diff --git a/packages/libs/lib-jdcloud/src/services/dbs.js b/packages/libs/lib-jdcloud/src/services/dbs.js new file mode 100644 index 000000000..93bc7c010 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/dbs.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 数据库备份服务 + * 数据库备份服务接口 + * + * OpenAPI spec version: v2 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'dbs' +Service._services[serviceId] = true + +/** + * dbs service. + */ + +JDCloud.DBS = class DBS { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'dbs' + let version = config.version || JDCloud.config.version + let versionFlag = 'v2' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.DBS diff --git a/packages/libs/lib-jdcloud/src/services/dcap.js b/packages/libs/lib-jdcloud/src/services/dcap.js new file mode 100644 index 000000000..5d4903f91 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/dcap.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * UserPackage + * 敏感数据保护-用户套餐相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'dcap' +Service._services[serviceId] = true + +/** + * dcap service. + */ + +JDCloud.DCAP = class DCAP { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'dcap' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.DCAP diff --git a/packages/libs/lib-jdcloud/src/services/deploy.js b/packages/libs/lib-jdcloud/src/services/deploy.js new file mode 100644 index 000000000..1746d9513 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/deploy.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 依赖 + * 云部署依赖相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'deploy' +Service._services[serviceId] = true + +/** + * deploy service. + */ + +JDCloud.DEPLOY = class DEPLOY { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'deploy' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.DEPLOY diff --git a/packages/libs/lib-jdcloud/src/services/detection.js b/packages/libs/lib-jdcloud/src/services/detection.js new file mode 100644 index 000000000..cb74c39c4 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/detection.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Task related APIs + * 云拔测-任务相关接口 + * + * OpenAPI spec version: v3 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'detection' +Service._services[serviceId] = true + +/** + * detection service. + */ + +JDCloud.DETECTION = class DETECTION { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'detection' + let version = config.version || JDCloud.config.version + let versionFlag = 'v3' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.DETECTION diff --git a/packages/libs/lib-jdcloud/src/services/dh.js b/packages/libs/lib-jdcloud/src/services/dh.js new file mode 100644 index 000000000..b923041e6 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/dh.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Quota + * 与配额相关的接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'dh' +Service._services[serviceId] = true + +/** + * dh service. + */ + +JDCloud.DH = class DH { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'dh' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.DH diff --git a/packages/libs/lib-jdcloud/src/services/disk.js b/packages/libs/lib-jdcloud/src/services/disk.js new file mode 100644 index 000000000..98ba3ca61 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/disk.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 售罄相关接口 + * 查询售罄情况 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'disk' +Service._services[serviceId] = true + +/** + * disk service. + */ + +JDCloud.DISK = class DISK { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'disk' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.DISK diff --git a/packages/libs/lib-jdcloud/src/services/dms.js b/packages/libs/lib-jdcloud/src/services/dms.js new file mode 100644 index 000000000..b97a0cbf1 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/dms.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * DmsView + * 视图相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'dms' +Service._services[serviceId] = true + +/** + * dms service. + */ + +JDCloud.DMS = class DMS { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'dms' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.DMS diff --git a/packages/libs/lib-jdcloud/src/services/domain.js b/packages/libs/lib-jdcloud/src/services/domain.js new file mode 100644 index 000000000..a65e6d740 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/domain.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Domain-Template + * 域名模板相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'domain' +Service._services[serviceId] = true + +/** + * domain service. + */ + +JDCloud.DOMAIN = class DOMAIN { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'domain' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.DOMAIN diff --git a/packages/libs/lib-jdcloud/src/services/domainservice.js b/packages/libs/lib-jdcloud/src/services/domainservice.js new file mode 100644 index 000000000..2342c77a8 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/domainservice.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 实例信息 + * 云解析OpenAPI实例信息接口 + * + * OpenAPI spec version: v2 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'domainservice' +Service._services[serviceId] = true + +/** + * domainservice service. + */ + +JDCloud.DOMAINSERVICE = class DOMAINSERVICE { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'domainservice' + let version = config.version || JDCloud.config.version + let versionFlag = 'v2' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.DOMAINSERVICE diff --git a/packages/libs/lib-jdcloud/src/services/dts.js b/packages/libs/lib-jdcloud/src/services/dts.js new file mode 100644 index 000000000..a17726f57 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/dts.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 数据传输服务 + * 数据传输服务相关接口 + * + * OpenAPI spec version: v2 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'dts' +Service._services[serviceId] = true + +/** + * dts service. + */ + +JDCloud.DTS = class DTS { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'dts' + let version = config.version || JDCloud.config.version + let versionFlag = 'v2' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.DTS diff --git a/packages/libs/lib-jdcloud/src/services/edcps.js b/packages/libs/lib-jdcloud/src/services/edcps.js new file mode 100644 index 000000000..91f5f381f --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/edcps.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Distributed-Cloud-Physical-Server + * 分布式云物理服务器私有网络操作相关的接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'edcps' +Service._services[serviceId] = true + +/** + * edcps service. + */ + +JDCloud.EDCPS = class EDCPS { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'edcps' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.EDCPS diff --git a/packages/libs/lib-jdcloud/src/services/eid.js b/packages/libs/lib-jdcloud/src/services/eid.js new file mode 100644 index 000000000..f88a87a3a --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/eid.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 页面测试检测接口 + * 京东云信用评分-OpenAPI页面测试检测接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'eid' +Service._services[serviceId] = true + +/** + * eid service. + */ + +JDCloud.EID = class EID { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'eid' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.EID diff --git a/packages/libs/lib-jdcloud/src/services/elite.js b/packages/libs/lib-jdcloud/src/services/elite.js new file mode 100644 index 000000000..c06f61d6d --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/elite.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * elite云存服务相关接口 + * elite云存服务相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'elite' +Service._services[serviceId] = true + +/** + * elite service. + */ + +JDCloud.ELITE = class ELITE { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'elite' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.ELITE diff --git a/packages/libs/lib-jdcloud/src/services/es.js b/packages/libs/lib-jdcloud/src/services/es.js new file mode 100644 index 000000000..1eec00f99 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/es.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * ES Snapshot API + * es快照创建、查询,自动快照的设置、查询接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'es' +Service._services[serviceId] = true + +/** + * es service. + */ + +JDCloud.ES = class ES { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'es' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.ES diff --git a/packages/libs/lib-jdcloud/src/services/fc.js b/packages/libs/lib-jdcloud/src/services/fc.js new file mode 100644 index 000000000..6c7d446ea --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/fc.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Trigger + * Trigger 相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'fc' +Service._services[serviceId] = true + +/** + * fc service. + */ + +JDCloud.FC = class FC { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'fc' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.FC diff --git a/packages/libs/lib-jdcloud/src/services/flowlog.js b/packages/libs/lib-jdcloud/src/services/flowlog.js new file mode 100644 index 000000000..bfd8681c5 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/flowlog.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Quota + * 配额的相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'flowlog' +Service._services[serviceId] = true + +/** + * flowlog service. + */ + +JDCloud.FLOWLOG = class FLOWLOG { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'flowlog' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.FLOWLOG diff --git a/packages/libs/lib-jdcloud/src/services/function.js b/packages/libs/lib-jdcloud/src/services/function.js new file mode 100644 index 000000000..a0f33a654 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/function.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Function OpenAPI + * + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'function' +Service._services[serviceId] = true + +/** + * function service. + */ + +JDCloud.FUNCTION = class FUNCTION { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'function' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.FUNCTION diff --git a/packages/libs/lib-jdcloud/src/services/gcs.js b/packages/libs/lib-jdcloud/src/services/gcs.js new file mode 100644 index 000000000..8360f9161 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/gcs.js @@ -0,0 +1,56 @@ +/* + * 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. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'gcs' +Service._services[serviceId] = true + +/** + * gcs service. + */ + +JDCloud.GCS = class GCS { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'gcs' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.GCS diff --git a/packages/libs/lib-jdcloud/src/services/httpdns.js b/packages/libs/lib-jdcloud/src/services/httpdns.js new file mode 100644 index 000000000..4ea2b982b --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/httpdns.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 域名 + * httpdns OpenAPI域名接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'httpdns' +Service._services[serviceId] = true + +/** + * httpdns service. + */ + +JDCloud.HTTPDNS = class HTTPDNS { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'httpdns' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.HTTPDNS diff --git a/packages/libs/lib-jdcloud/src/services/hufu.js b/packages/libs/lib-jdcloud/src/services/hufu.js new file mode 100644 index 000000000..af68762bc --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/hufu.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * hufu-wx + * 虎符商业化相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'hufu' +Service._services[serviceId] = true + +/** + * hufu service. + */ + +JDCloud.HUFU = class HUFU { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'hufu' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.HUFU diff --git a/packages/libs/lib-jdcloud/src/services/iam.js b/packages/libs/lib-jdcloud/src/services/iam.js new file mode 100644 index 000000000..a6344768b --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/iam.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * User Management + * User Management API + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'iam' +Service._services[serviceId] = true + +/** + * iam service. + */ + +JDCloud.IAM = class IAM { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'iam' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.IAM diff --git a/packages/libs/lib-jdcloud/src/services/ias.js b/packages/libs/lib-jdcloud/src/services/ias.js new file mode 100644 index 000000000..4b5c6f1a8 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/ias.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * JDCLOUD IAS Services API + * 京东云联合登陆Api + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'ias' +Service._services[serviceId] = true + +/** + * ias service. + */ + +JDCloud.IAS = class IAS { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'ias' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.IAS diff --git a/packages/libs/lib-jdcloud/src/services/industrydata.js b/packages/libs/lib-jdcloud/src/services/industrydata.js new file mode 100644 index 000000000..b4a7708e4 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/industrydata.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 大屏数据查询接口 + * 陕西苹果大屏数据查询接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'industrydata' +Service._services[serviceId] = true + +/** + * industrydata service. + */ + +JDCloud.INDUSTRYDATA = class INDUSTRYDATA { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'industrydata' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.INDUSTRYDATA diff --git a/packages/libs/lib-jdcloud/src/services/instancevoucher.js b/packages/libs/lib-jdcloud/src/services/instancevoucher.js new file mode 100644 index 000000000..06470d78a --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/instancevoucher.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Instance-Voucher + * 实例抵扣券相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'instancevoucher' +Service._services[serviceId] = true + +/** + * instancevoucher service. + */ + +JDCloud.INSTANCEVOUCHER = class INSTANCEVOUCHER { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'instancevoucher' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.INSTANCEVOUCHER diff --git a/packages/libs/lib-jdcloud/src/services/invoice.js b/packages/libs/lib-jdcloud/src/services/invoice.js new file mode 100644 index 000000000..179a34806 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/invoice.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * JDCLOUD Invoice API + * 京东云发票 + * + * OpenAPI spec version: v2 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'invoice' +Service._services[serviceId] = true + +/** + * invoice service. + */ + +JDCloud.INVOICE = class INVOICE { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'invoice' + let version = config.version || JDCloud.config.version + let versionFlag = 'v2' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.INVOICE diff --git a/packages/libs/lib-jdcloud/src/services/iotcard.js b/packages/libs/lib-jdcloud/src/services/iotcard.js new file mode 100644 index 000000000..6b8aee035 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/iotcard.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * iot-card-Related-API + * 物联网卡服务相关API + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'iotcard' +Service._services[serviceId] = true + +/** + * iotcard service. + */ + +JDCloud.IOTCARD = class IOTCARD { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'iotcard' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.IOTCARD diff --git a/packages/libs/lib-jdcloud/src/services/iotcloudgateway.js b/packages/libs/lib-jdcloud/src/services/iotcloudgateway.js new file mode 100644 index 000000000..93eebe697 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/iotcloudgateway.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * iotcloudgateway开通接口 + * 用户开通iotcloudgateway服务相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'iotcloudgateway' +Service._services[serviceId] = true + +/** + * iotcloudgateway service. + */ + +JDCloud.IOTCLOUDGATEWAY = class IOTCLOUDGATEWAY { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'iotcloudgateway' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.IOTCLOUDGATEWAY diff --git a/packages/libs/lib-jdcloud/src/services/iotcore.js b/packages/libs/lib-jdcloud/src/services/iotcore.js new file mode 100644 index 000000000..4b48b1062 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/iotcore.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * IoTHubInstance + * IoT Hub共享模式和独享模式共用接口 + * + * OpenAPI spec version: v2 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'iotcore' +Service._services[serviceId] = true + +/** + * iotcore service. + */ + +JDCloud.IOTCORE = class IOTCORE { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'iotcore' + let version = config.version || JDCloud.config.version + let versionFlag = 'v2' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.IOTCORE diff --git a/packages/libs/lib-jdcloud/src/services/iotedge.js b/packages/libs/lib-jdcloud/src/services/iotedge.js new file mode 100644 index 000000000..ecbc4e2c2 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/iotedge.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * EdgeSubDeviceManager + * iotcore-Edge子设备管理 + * + * OpenAPI spec version: v2 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'iotedge' +Service._services[serviceId] = true + +/** + * iotedge service. + */ + +JDCloud.IOTEDGE = class IOTEDGE { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'iotedge' + let version = config.version || JDCloud.config.version + let versionFlag = 'v2' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.IOTEDGE diff --git a/packages/libs/lib-jdcloud/src/services/iothub.js b/packages/libs/lib-jdcloud/src/services/iothub.js new file mode 100644 index 000000000..4a0d28c9e --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/iothub.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * IoTHubInstance + * IoT Hub共享模式和独享模式共用接口 + * + * OpenAPI spec version: v2 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'iothub' +Service._services[serviceId] = true + +/** + * iothub service. + */ + +JDCloud.IOTHUB = class IOTHUB { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'iothub' + let version = config.version || JDCloud.config.version + let versionFlag = 'v2' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.IOTHUB diff --git a/packages/libs/lib-jdcloud/src/services/iotlink.js b/packages/libs/lib-jdcloud/src/services/iotlink.js new file mode 100644 index 000000000..f15ac31ec --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/iotlink.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Iotlink-Related-API + * 物联网卡服务相关API + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'iotlink' +Service._services[serviceId] = true + +/** + * iotlink service. + */ + +JDCloud.IOTLINK = class IOTLINK { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'iotlink' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.IOTLINK diff --git a/packages/libs/lib-jdcloud/src/services/ipanti.js b/packages/libs/lib-jdcloud/src/services/ipanti.js new file mode 100644 index 000000000..61658646a --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/ipanti.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Anti DDoS Pro Web Rule Configuration APIs + * Anti DDoS Pro Web Rule Configuration APIs + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'ipanti' +Service._services[serviceId] = true + +/** + * ipanti service. + */ + +JDCloud.IPANTI = class IPANTI { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'ipanti' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.IPANTI diff --git a/packages/libs/lib-jdcloud/src/services/iv.js b/packages/libs/lib-jdcloud/src/services/iv.js new file mode 100644 index 000000000..b34f4b728 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/iv.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Vi Template + * 视频审查模板管理相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'iv' +Service._services[serviceId] = true + +/** + * iv service. + */ + +JDCloud.IV = class IV { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'iv' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.IV diff --git a/packages/libs/lib-jdcloud/src/services/jcq.js b/packages/libs/lib-jdcloud/src/services/jcq.js new file mode 100644 index 000000000..d3c1e9908 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/jcq.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Topic + * Topic相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'jcq' +Service._services[serviceId] = true + +/** + * jcq service. + */ + +JDCloud.JCQ = class JCQ { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'jcq' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.JCQ diff --git a/packages/libs/lib-jdcloud/src/services/jdccs.js b/packages/libs/lib-jdcloud/src/services/jdccs.js new file mode 100644 index 000000000..eb1cfeed5 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/jdccs.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Ticket API + * 云托管服务的工单API + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'jdccs' +Service._services[serviceId] = true + +/** + * jdccs service. + */ + +JDCloud.JDCCS = class JDCCS { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'jdccs' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.JDCCS diff --git a/packages/libs/lib-jdcloud/src/services/jdfusion.js b/packages/libs/lib-jdcloud/src/services/jdfusion.js new file mode 100644 index 000000000..998d70916 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/jdfusion.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Vpc-VserverGroup + * 与服务器组相关的接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'jdfusion' +Service._services[serviceId] = true + +/** + * jdfusion service. + */ + +JDCloud.JDFUSION = class JDFUSION { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'jdfusion' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.JDFUSION diff --git a/packages/libs/lib-jdcloud/src/services/jdro.js b/packages/libs/lib-jdcloud/src/services/jdro.js new file mode 100644 index 000000000..a20e70f8c --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/jdro.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Template + * Interface of Template + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'jdro' +Service._services[serviceId] = true + +/** + * jdro service. + */ + +JDCloud.JDRO = class JDRO { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'jdro' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.JDRO diff --git a/packages/libs/lib-jdcloud/src/services/jdw.js b/packages/libs/lib-jdcloud/src/services/jdw.js new file mode 100644 index 000000000..6f721a90c --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/jdw.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 实例管理 + * 实例管理相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'jdw' +Service._services[serviceId] = true + +/** + * jdw service. + */ + +JDCloud.JDW = class JDW { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'jdw' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.JDW diff --git a/packages/libs/lib-jdcloud/src/services/jdworkspace.js b/packages/libs/lib-jdcloud/src/services/jdworkspace.js new file mode 100644 index 000000000..5d521d475 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/jdworkspace.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * JDCLOUD 态势感知续费管理 API + * 态势感知续费管理相关信息接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'jdworkspace' +Service._services[serviceId] = true + +/** + * jdworkspace service. + */ + +JDCloud.JDWORKSPACE = class JDWORKSPACE { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'jdworkspace' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.JDWORKSPACE diff --git a/packages/libs/lib-jdcloud/src/services/jke.js b/packages/libs/lib-jdcloud/src/services/jke.js new file mode 100644 index 000000000..9e9bb91dc --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/jke.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 配额 + * k8s 集群配额相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'jke' +Service._services[serviceId] = true + +/** + * jke service. + */ + +JDCloud.JKE = class JKE { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'jke' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.JKE diff --git a/packages/libs/lib-jdcloud/src/services/jmr.js b/packages/libs/lib-jdcloud/src/services/jmr.js new file mode 100644 index 000000000..ecc0ff984 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/jmr.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 集群管理 + * JMR集群管理相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'jmr' +Service._services[serviceId] = true + +/** + * jmr service. + */ + +JDCloud.JMR = class JMR { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'jmr' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.JMR diff --git a/packages/libs/lib-jdcloud/src/services/kafka.js b/packages/libs/lib-jdcloud/src/services/kafka.js new file mode 100644 index 000000000..c4a146f00 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/kafka.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * kafka topic 相关接口 + * kafka topic 相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'kafka' +Service._services[serviceId] = true + +/** + * kafka service. + */ + +JDCloud.KAFKA = class KAFKA { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'kafka' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.KAFKA diff --git a/packages/libs/lib-jdcloud/src/services/kms.js b/packages/libs/lib-jdcloud/src/services/kms.js new file mode 100644 index 000000000..a3d8bd496 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/kms.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Statistics Service + * 基于硬件保护密钥的安全数据托管服务 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'kms' +Service._services[serviceId] = true + +/** + * kms service. + */ + +JDCloud.KMS = class KMS { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'kms' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.KMS diff --git a/packages/libs/lib-jdcloud/src/services/kubernetes.js b/packages/libs/lib-jdcloud/src/services/kubernetes.js new file mode 100644 index 000000000..18b4e8568 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/kubernetes.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * ServerlessCluster + * Serverless集群相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'kubernetes' +Service._services[serviceId] = true + +/** + * kubernetes service. + */ + +JDCloud.KUBERNETES = class KUBERNETES { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'kubernetes' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.KUBERNETES diff --git a/packages/libs/lib-jdcloud/src/services/lavm.js b/packages/libs/lib-jdcloud/src/services/lavm.js new file mode 100644 index 000000000..078f44f0d --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/lavm.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * quota + * 轻量应用云主机配额模型的相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'lavm' +Service._services[serviceId] = true + +/** + * lavm service. + */ + +JDCloud.LAVM = class LAVM { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'lavm' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.LAVM diff --git a/packages/libs/lib-jdcloud/src/services/lb.js b/packages/libs/lib-jdcloud/src/services/lb.js new file mode 100644 index 000000000..2f2cd9506 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/lb.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Forwarding-Rules-Group + * 转发规则组相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'lb' +Service._services[serviceId] = true + +/** + * lb service. + */ + +JDCloud.LB = class LB { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'lb' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.LB diff --git a/packages/libs/lib-jdcloud/src/services/live.js b/packages/libs/lib-jdcloud/src/services/live.js new file mode 100644 index 000000000..eadf04b9a --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/live.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Live-Video + * 直播管理API + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'live' +Service._services[serviceId] = true + +/** + * live service. + */ + +JDCloud.LIVE = class LIVE { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'live' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.LIVE diff --git a/packages/libs/lib-jdcloud/src/services/logs.js b/packages/libs/lib-jdcloud/src/services/logs.js new file mode 100644 index 000000000..e58985a32 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/logs.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * WebConf APIs + * 日志服务webconf相关的管理控制接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'logs' +Service._services[serviceId] = true + +/** + * logs service. + */ + +JDCloud.LOGS = class LOGS { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'logs' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.LOGS diff --git a/packages/libs/lib-jdcloud/src/services/mongodb.js b/packages/libs/lib-jdcloud/src/services/mongodb.js new file mode 100644 index 000000000..fdc81d932 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/mongodb.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 安全管理 + * API related to MONGODB security + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'mongodb' +Service._services[serviceId] = true + +/** + * mongodb service. + */ + +JDCloud.MONGODB = class MONGODB { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'mongodb' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.MONGODB diff --git a/packages/libs/lib-jdcloud/src/services/monitor.js b/packages/libs/lib-jdcloud/src/services/monitor.js new file mode 100644 index 000000000..0aed9ee8d --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/monitor.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * maintainAuxiliaryTags APIs + * 一组资源增加删除标签 + * + * OpenAPI spec version: v2 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'monitor' +Service._services[serviceId] = true + +/** + * monitor service. + */ + +JDCloud.MONITOR = class MONITOR { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'monitor' + let version = config.version || JDCloud.config.version + let versionFlag = 'v2' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.MONITOR diff --git a/packages/libs/lib-jdcloud/src/services/monitorcm.js b/packages/libs/lib-jdcloud/src/services/monitorcm.js new file mode 100644 index 000000000..378aa25e5 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/monitorcm.js @@ -0,0 +1,55 @@ +/* + * 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. + * + * 监控项相关接口 + * 监控项相关接口,提供自定义监控数据上报功能 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'monitorcm' +Service._services[serviceId] = true + +/** + * monitorcm service. + */ + +JDCloud.MONITORCM = class MONITORCM { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'monitorcm' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + if (!this.service) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.MONITORCM diff --git a/packages/libs/lib-jdcloud/src/services/mps.js b/packages/libs/lib-jdcloud/src/services/mps.js new file mode 100644 index 000000000..1c4e866cf --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/mps.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 媒体处理相关接口 + * 多媒体处理服务API,包括截图、转码、媒体处理消息通知等操作。本文档详细说明了媒体处理API及用法,适合开发人员阅读。 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'mps' +Service._services[serviceId] = true + +/** + * mps service. + */ + +JDCloud.MPS = class MPS { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'mps' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.MPS diff --git a/packages/libs/lib-jdcloud/src/services/nativecontainer.js b/packages/libs/lib-jdcloud/src/services/nativecontainer.js new file mode 100644 index 000000000..3b54d920d --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/nativecontainer.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 用户设置 + * 查询用户设置接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'nativecontainer' +Service._services[serviceId] = true + +/** + * nativecontainer service. + */ + +JDCloud.NATIVECONTAINER = class NATIVECONTAINER { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'nativecontainer' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.NATIVECONTAINER diff --git a/packages/libs/lib-jdcloud/src/services/nc.js b/packages/libs/lib-jdcloud/src/services/nc.js new file mode 100644 index 000000000..78ff85d34 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/nc.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 镜像仓库认证信息 + * 关于镜像仓库认证信息的相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'nc' +Service._services[serviceId] = true + +/** + * nc service. + */ + +JDCloud.NC = class NC { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'nc' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.NC diff --git a/packages/libs/lib-jdcloud/src/services/openjrtc.js b/packages/libs/lib-jdcloud/src/services/openjrtc.js new file mode 100644 index 000000000..69f5d392c --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/openjrtc.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * UserRoom + * 用户房间号管理 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'openjrtc' +Service._services[serviceId] = true + +/** + * openjrtc service. + */ + +JDCloud.OPENJRTC = class OPENJRTC { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'openjrtc' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.OPENJRTC diff --git a/packages/libs/lib-jdcloud/src/services/order.js b/packages/libs/lib-jdcloud/src/services/order.js new file mode 100644 index 000000000..fdaa7efa7 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/order.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 相关接口 + * API related to order + * + * OpenAPI spec version: v2 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'order' +Service._services[serviceId] = true + +/** + * order service. + */ + +JDCloud.ORDER = class ORDER { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'order' + let version = config.version || JDCloud.config.version + let versionFlag = 'v2' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.ORDER diff --git a/packages/libs/lib-jdcloud/src/services/oss.js b/packages/libs/lib-jdcloud/src/services/oss.js new file mode 100644 index 000000000..fd2509774 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/oss.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * OSS相关接口 + * OSS相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'oss' +Service._services[serviceId] = true + +/** + * oss service. + */ + +JDCloud.OSS = class OSS { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'oss' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.OSS diff --git a/packages/libs/lib-jdcloud/src/services/ossopenapi.js b/packages/libs/lib-jdcloud/src/services/ossopenapi.js new file mode 100644 index 000000000..4efd24adc --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/ossopenapi.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * vpc policy openapi v1 + * vpc policy openapi v1 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'ossopenapi' +Service._services[serviceId] = true + +/** + * ossopenapi service. + */ + +JDCloud.OSSOPENAPI = class OSSOPENAPI { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'ossopenapi' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.OSSOPENAPI diff --git a/packages/libs/lib-jdcloud/src/services/partner.js b/packages/libs/lib-jdcloud/src/services/partner.js new file mode 100644 index 000000000..331d87c21 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/partner.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 合作信息管理 + * 合作信息管理 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'partner' +Service._services[serviceId] = true + +/** + * partner service. + */ + +JDCloud.PARTNER = class PARTNER { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'partner' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.PARTNER diff --git a/packages/libs/lib-jdcloud/src/services/pipeline.js b/packages/libs/lib-jdcloud/src/services/pipeline.js new file mode 100644 index 000000000..a1b181428 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/pipeline.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * tools + * API OF tools Create|Update|Read|Delete|Execute + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'pipeline' +Service._services[serviceId] = true + +/** + * pipeline service. + */ + +JDCloud.PIPELINE = class PIPELINE { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'pipeline' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.PIPELINE diff --git a/packages/libs/lib-jdcloud/src/services/pod.js b/packages/libs/lib-jdcloud/src/services/pod.js new file mode 100644 index 000000000..c01291a89 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/pod.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 用户设置 + * 查询用户设置接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'pod' +Service._services[serviceId] = true + +/** + * pod service. + */ + +JDCloud.POD = class POD { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'pod' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.POD diff --git a/packages/libs/lib-jdcloud/src/services/portal.js b/packages/libs/lib-jdcloud/src/services/portal.js new file mode 100644 index 000000000..b75a8b97e --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/portal.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * search + * 搜索相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'portal' +Service._services[serviceId] = true + +/** + * portal service. + */ + +JDCloud.PORTAL = class PORTAL { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'portal' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.PORTAL diff --git a/packages/libs/lib-jdcloud/src/services/privatezone.js b/packages/libs/lib-jdcloud/src/services/privatezone.js new file mode 100644 index 000000000..4abcddc0a --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/privatezone.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 私有域名zone + * 私有域名zone API + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'privatezone' +Service._services[serviceId] = true + +/** + * privatezone service. + */ + +JDCloud.PRIVATEZONE = class PRIVATEZONE { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'privatezone' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.PRIVATEZONE diff --git a/packages/libs/lib-jdcloud/src/services/quota.js b/packages/libs/lib-jdcloud/src/services/quota.js new file mode 100644 index 000000000..23a222951 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/quota.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * JDCLOUD remote quota API + * API JDCLOUD remote quota API + * + * OpenAPI spec version: v2 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'quota' +Service._services[serviceId] = true + +/** + * quota service. + */ + +JDCloud.QUOTA = class QUOTA { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'quota' + let version = config.version || JDCloud.config.version + let versionFlag = 'v2' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.QUOTA diff --git a/packages/libs/lib-jdcloud/src/services/rds.js b/packages/libs/lib-jdcloud/src/services/rds.js new file mode 100644 index 000000000..ec54db4fa --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/rds.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 白名单 + * 白名单相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'rds' +Service._services[serviceId] = true + +/** + * rds service. + */ + +JDCloud.RDS = class RDS { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'rds' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.RDS diff --git a/packages/libs/lib-jdcloud/src/services/rdts.js b/packages/libs/lib-jdcloud/src/services/rdts.js new file mode 100644 index 000000000..e2181ea48 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/rdts.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * operation + * 查询异步请求结果 + * + * OpenAPI spec version: v2 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'rdts' +Service._services[serviceId] = true + +/** + * rdts service. + */ + +JDCloud.RDTS = class RDTS { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'rdts' + let version = config.version || JDCloud.config.version + let versionFlag = 'v2' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.RDTS diff --git a/packages/libs/lib-jdcloud/src/services/redis.js b/packages/libs/lib-jdcloud/src/services/redis.js new file mode 100644 index 000000000..d269bcaad --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/redis.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Redis SpecConfig API + * 缓存Redis实例规格配置接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'redis' +Service._services[serviceId] = true + +/** + * redis service. + */ + +JDCloud.REDIS = class REDIS { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'redis' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.REDIS diff --git a/packages/libs/lib-jdcloud/src/services/refund.js b/packages/libs/lib-jdcloud/src/services/refund.js new file mode 100644 index 000000000..e4c65ef33 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/refund.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 退款策略中心 + * 退款策略中心接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'refund' +Service._services[serviceId] = true + +/** + * refund service. + */ + +JDCloud.REFUND = class REFUND { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'refund' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.REFUND diff --git a/packages/libs/lib-jdcloud/src/services/renewal.js b/packages/libs/lib-jdcloud/src/services/renewal.js new file mode 100644 index 000000000..e96bc1882 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/renewal.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Renew Management APIs + * 续费管理相关接口 + * + * OpenAPI spec version: v2 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'renewal' +Service._services[serviceId] = true + +/** + * renewal service. + */ + +JDCloud.RENEWAL = class RENEWAL { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'renewal' + let version = config.version || JDCloud.config.version + let versionFlag = 'v2' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.RENEWAL diff --git a/packages/libs/lib-jdcloud/src/services/reservedinstance.js b/packages/libs/lib-jdcloud/src/services/reservedinstance.js new file mode 100644 index 000000000..90e9cf56b --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/reservedinstance.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * sysConfig APIs + * 系统参数配置 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'reservedinstance' +Service._services[serviceId] = true + +/** + * reservedinstance service. + */ + +JDCloud.RESERVEDINSTANCE = class RESERVEDINSTANCE { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'reservedinstance' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.RESERVEDINSTANCE diff --git a/packages/libs/lib-jdcloud/src/services/resourcetag.js b/packages/libs/lib-jdcloud/src/services/resourcetag.js new file mode 100644 index 000000000..5012d7c0e --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/resourcetag.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Resource-Tag-APIs + * 资源标签接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'resourcetag' +Service._services[serviceId] = true + +/** + * resourcetag service. + */ + +JDCloud.RESOURCETAG = class RESOURCETAG { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'resourcetag' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.RESOURCETAG diff --git a/packages/libs/lib-jdcloud/src/services/rms.js b/packages/libs/lib-jdcloud/src/services/rms.js new file mode 100644 index 000000000..93dae3e3a --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/rms.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Message-Content-APIs + * 富媒体模板内容创建、查询相关接口 + * + * OpenAPI spec version: v2 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'rms' +Service._services[serviceId] = true + +/** + * rms service. + */ + +JDCloud.RMS = class RMS { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'rms' + let version = config.version || JDCloud.config.version + let versionFlag = 'v2' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.RMS diff --git a/packages/libs/lib-jdcloud/src/services/smartdba.js b/packages/libs/lib-jdcloud/src/services/smartdba.js new file mode 100644 index 000000000..024b4ca93 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/smartdba.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Table-Check + * 表诊断相关接口 + * + * OpenAPI spec version: v2 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'smartdba' +Service._services[serviceId] = true + +/** + * smartdba service. + */ + +JDCloud.SMARTDBA = class SMARTDBA { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'smartdba' + let version = config.version || JDCloud.config.version + let versionFlag = 'v2' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.SMARTDBA diff --git a/packages/libs/lib-jdcloud/src/services/sms.js b/packages/libs/lib-jdcloud/src/services/sms.js new file mode 100644 index 000000000..723f03b65 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/sms.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Send-Message-Related-APIs + * 模版相关API + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'sms' +Service._services[serviceId] = true + +/** + * sms service. + */ + +JDCloud.SMS = class SMS { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'sms' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.SMS diff --git a/packages/libs/lib-jdcloud/src/services/sop.js b/packages/libs/lib-jdcloud/src/services/sop.js new file mode 100644 index 000000000..712d24a05 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/sop.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 敏感操作配置 + * 操作敏感操作配置接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'sop' +Service._services[serviceId] = true + +/** + * sop service. + */ + +JDCloud.SOP = class SOP { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'sop' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.SOP diff --git a/packages/libs/lib-jdcloud/src/services/ssl.js b/packages/libs/lib-jdcloud/src/services/ssl.js new file mode 100644 index 000000000..a7a1ea3c7 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/ssl.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * SSL Certificate Manager + * SSL数字证书信息管理接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'ssl' +Service._services[serviceId] = true + +/** + * ssl service. + */ + +JDCloud.SSL = class SSL { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'ssl' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.SSL diff --git a/packages/libs/lib-jdcloud/src/services/starshield.js b/packages/libs/lib-jdcloud/src/services/starshield.js new file mode 100644 index 000000000..609bcfbfd --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/starshield.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Zone-Settings + * A Zone setting changes how the Zone works in relation to caching, security, or other features of JDC StarShield + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'starshield' +Service._services[serviceId] = true + +/** + * starshield service. + */ + +JDCloud.STARSHIELD = class STARSHIELD { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'starshield' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.STARSHIELD diff --git a/packages/libs/lib-jdcloud/src/services/streambus.js b/packages/libs/lib-jdcloud/src/services/streambus.js new file mode 100644 index 000000000..4c5332fca --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/streambus.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * ConsumerGroup相关 API + * 流数据总线ConsumerGroup相关信息接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'streambus' +Service._services[serviceId] = true + +/** + * streambus service. + */ + +JDCloud.STREAMBUS = class STREAMBUS { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'streambus' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.STREAMBUS diff --git a/packages/libs/lib-jdcloud/src/services/streamcomputer.js b/packages/libs/lib-jdcloud/src/services/streamcomputer.js new file mode 100644 index 000000000..b39a9016e --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/streamcomputer.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * storage相关 API + * 流计算storage相关信息接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'streamcomputer' +Service._services[serviceId] = true + +/** + * streamcomputer service. + */ + +JDCloud.STREAMCOMPUTER = class STREAMCOMPUTER { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'streamcomputer' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.STREAMCOMPUTER diff --git a/packages/libs/lib-jdcloud/src/services/sts.js b/packages/libs/lib-jdcloud/src/services/sts.js new file mode 100644 index 000000000..c189c3f5e --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/sts.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Security Token Service + * Security Token Service API + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'sts' +Service._services[serviceId] = true + +/** + * sts service. + */ + +JDCloud.STS = class STS { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'sts' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.STS diff --git a/packages/libs/lib-jdcloud/src/services/tidb.js b/packages/libs/lib-jdcloud/src/services/tidb.js new file mode 100644 index 000000000..80d5c2e2a --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/tidb.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * White-List + * 白名单相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'tidb' +Service._services[serviceId] = true + +/** + * tidb service. + */ + +JDCloud.TIDB = class TIDB { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'tidb' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.TIDB diff --git a/packages/libs/lib-jdcloud/src/services/user.js b/packages/libs/lib-jdcloud/src/services/user.js new file mode 100644 index 000000000..56670e62e --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/user.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 账号报备管理 + * 账号报备管理接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'user' +Service._services[serviceId] = true + +/** + * user service. + */ + +JDCloud.USER = class USER { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'user' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.USER diff --git a/packages/libs/lib-jdcloud/src/services/userpool.js b/packages/libs/lib-jdcloud/src/services/userpool.js new file mode 100644 index 000000000..eb9c23635 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/userpool.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 用户管理 + * 用户管理接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'userpool' +Service._services[serviceId] = true + +/** + * userpool service. + */ + +JDCloud.USERPOOL = class USERPOOL { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'userpool' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.USERPOOL diff --git a/packages/libs/lib-jdcloud/src/services/vm.js b/packages/libs/lib-jdcloud/src/services/vm.js new file mode 100644 index 000000000..88269c3fe --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/vm.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Task + * 与任务相关的接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'vm' +Service._services[serviceId] = true + +/** + * vm service. + */ + +JDCloud.VM = class VM { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'vm' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.VM diff --git a/packages/libs/lib-jdcloud/src/services/vod.js b/packages/libs/lib-jdcloud/src/services/vod.js new file mode 100644 index 000000000..92e623580 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/vod.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Watermark + * 水印管理相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'vod' +Service._services[serviceId] = true + +/** + * vod service. + */ + +JDCloud.VOD = class VOD { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'vod' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.VOD diff --git a/packages/libs/lib-jdcloud/src/services/vpc.js b/packages/libs/lib-jdcloud/src/services/vpc.js new file mode 100644 index 000000000..5aea281ce --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/vpc.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Vpc-Policy + * vpc支持oss权限访问控制相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'vpc' +Service._services[serviceId] = true + +/** + * vpc service. + */ + +JDCloud.VPC = class VPC { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'vpc' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.VPC diff --git a/packages/libs/lib-jdcloud/src/services/vqd.js b/packages/libs/lib-jdcloud/src/services/vqd.js new file mode 100644 index 000000000..9b87a538c --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/vqd.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Vqd Template + * 视频质检模板管理相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'vqd' +Service._services[serviceId] = true + +/** + * vqd service. + */ + +JDCloud.VQD = class VQD { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'vqd' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.VQD diff --git a/packages/libs/lib-jdcloud/src/services/waf.js b/packages/libs/lib-jdcloud/src/services/waf.js new file mode 100644 index 000000000..25e27a950 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/waf.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Warning + * Warning API + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'waf' +Service._services[serviceId] = true + +/** + * waf service. + */ + +JDCloud.WAF = class WAF { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'waf' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.WAF diff --git a/packages/libs/lib-jdcloud/src/services/xdata.js b/packages/libs/lib-jdcloud/src/services/xdata.js new file mode 100644 index 000000000..17bf53a9f --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/xdata.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * table + * API related to XDATA-DW table + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'xdata' +Service._services[serviceId] = true + +/** + * xdata service. + */ + +JDCloud.XDATA = class XDATA { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'xdata' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.XDATA diff --git a/packages/libs/lib-jdcloud/src/services/ydsms.js b/packages/libs/lib-jdcloud/src/services/ydsms.js new file mode 100644 index 000000000..f84606cc5 --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/ydsms.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * 云鼎短信服务-用户相关接口 + * 云鼎短信服务-用户相关接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'ydsms' +Service._services[serviceId] = true + +/** + * ydsms service. + */ + +JDCloud.YDSMS = class YDSMS { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'ydsms' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.YDSMS diff --git a/packages/libs/lib-jdcloud/src/services/yunding.js b/packages/libs/lib-jdcloud/src/services/yunding.js new file mode 100644 index 000000000..98602a7bb --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/yunding.js @@ -0,0 +1,56 @@ +/* + * 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. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'yunding' +Service._services[serviceId] = true + +/** + * yunding service. + */ + +JDCloud.YUNDING = class YUNDING { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'yunding' + let version = config.version || JDCloud.config.version + let versionFlag = 'v2' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.YUNDING diff --git a/packages/libs/lib-jdcloud/src/services/yundingdatapush.js b/packages/libs/lib-jdcloud/src/services/yundingdatapush.js new file mode 100644 index 000000000..e5d30ec1a --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/yundingdatapush.js @@ -0,0 +1,56 @@ +/* + * 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-datapush + * 云鼎数据推送OPENAPI接口 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'yundingdatapush' +Service._services[serviceId] = true + +/** + * yundingdatapush service. + */ + +JDCloud.YUNDINGDATAPUSH = class YUNDINGDATAPUSH { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'yundingdatapush' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.YUNDINGDATAPUSH diff --git a/packages/libs/lib-jdcloud/src/services/zfs.js b/packages/libs/lib-jdcloud/src/services/zfs.js new file mode 100644 index 000000000..a8e8259bc --- /dev/null +++ b/packages/libs/lib-jdcloud/src/services/zfs.js @@ -0,0 +1,56 @@ +/* + * 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. + * + * Mount-Target + * 挂载目标相关接口。 + * + * OpenAPI spec version: v1 + * Contact: + * + * NOTE: This class is auto generated by the jdcloud code generator program. + */ + +const JDCloud = require('../lib/core') +var Service = JDCloud.Service +var serviceId = 'zfs' +Service._services[serviceId] = true + +/** + * zfs service. + */ + +JDCloud.ZFS = class ZFS { + constructor (config = {}) { + this.init(config) + return new this.service(config) + } + init (config) { + let serviceName = 'zfs' + let version = config.version || JDCloud.config.version + let versionFlag = 'v1' + if (version && version[serviceName]) { + versionFlag = version[serviceName] + } + try { + this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`) + } catch (e) { + throw new Error( + `The version '${versionFlag}' of API ${serviceName} is undefined!` + ) + } + } +} + +module.exports = JDCloud.ZFS diff --git a/packages/libs/lib-jdcloud/test/callStyle.spec.js b/packages/libs/lib-jdcloud/test/callStyle.spec.js new file mode 100644 index 000000000..42166b6df --- /dev/null +++ b/packages/libs/lib-jdcloud/test/callStyle.spec.js @@ -0,0 +1,28 @@ +var NC = require('../src/services/nc') +var config = require('config') +var global = config.get('global') +var expec = require('chai').expect +describe('JDCloud.CallStyle', function () { + var nc = new NC({ + credentials: { + accessKeyId: global.accessKeyId, + secretAccessKey: global.secretAccessKey + } + }) + it('use Promise style', function () { + return nc.describeContainers( + { + }, + 'cn-north-1' + ) + }) + it('use callback style', function (done) { + nc.describeContainers({}, 'cn-north-1', function (err, data) { + if (err) { + done(err) + } else { + done() + } + }) + }) +}) diff --git a/packages/libs/lib-jdcloud/test/config.spec.js b/packages/libs/lib-jdcloud/test/config.spec.js new file mode 100644 index 000000000..6f281f025 --- /dev/null +++ b/packages/libs/lib-jdcloud/test/config.spec.js @@ -0,0 +1,85 @@ +var JDCloud = require('../src/lib/jc') +var config = require('config') +var global = config.get('global') +var expect = require('chai').expect + +describe('JDCloud.Config', function () { + describe('constructor', function () { + it('should be able to bass in a Config object as parameter', function () { + var config = new JDCloud.Config({ + apiVersions: '1', + vm: { + apiVersions: '2' + } + }) + var copyConfig = new JDCloud.Config(config) + expect(copyConfig).not.to.equal(config) + expect(config.apiVersions).to.equal('1') + expect(copyConfig.apiVersions).to.equal('1') + }) + it('should be able to pass credential values directly', function () { + var config = new JDCloud.Config({ + accessKeyId: 'akid', + secretAccessKey: 'secret' + }) + expect(config.credentials.accessKeyId).to.equal('akid') + expect(config.credentials.secretAccessKey).to.equal('secret') + }) + + it('should use right config value', function () { + var NC = require('../src/services/nc') + var nc = new NC() + expect(nc.config.endpoint.host).to.not.be.empty + + var config = new JDCloud.Config({ + endpoint: { + host: 'globalHost.com' + } + }) + JDCloud.config.update(config) + var ncUseGlobal = new NC() + expect(ncUseGlobal.config.endpoint.host).to.equal('globalHost.com') + + config = new JDCloud.Config({ + endpoint: { + host: 'globalHost.com' + }, + nc: { + endpoint: { + host: 'globalNCHost.com' + } + } + }) + JDCloud.config.update(config) + var ncUseGlobalNCConfig = new NC() + expect(ncUseGlobalNCConfig.config.endpoint.host).to.equal( + 'globalNCHost.com' + ) + + var ncUseSelf = new NC({ + endpoint: { + host: 'ncSelfHost.com' + } + }) + expect(ncUseSelf.config.endpoint.host).to.equal('ncSelfHost.com') + }) + }) + describe('usage', function () { + it('should use default regionId', function () { + JDCloud.config = new JDCloud.Config() + var nc = new JDCloud.NC({ + regionId: 'cn-north-1', + credentials: { + accessKeyId: global.accessKeyId, + secretAccessKey: global.secretAccessKey + }, + logger: function (str, level = 'INFO') { + if (level === 'INFO') { + console.log(str) + } + } + }) + return nc.describeContainers() + }) + }) +}) diff --git a/packages/libs/lib-jdcloud/test/config/default.yml b/packages/libs/lib-jdcloud/test/config/default.yml new file mode 100644 index 000000000..85b461115 --- /dev/null +++ b/packages/libs/lib-jdcloud/test/config/default.yml @@ -0,0 +1,3 @@ +global: + accessKeyId : ak + secretAccessKey: sk diff --git a/packages/libs/lib-jdcloud/test/services/monitor.spec.js b/packages/libs/lib-jdcloud/test/services/monitor.spec.js new file mode 100644 index 000000000..2fedd3256 --- /dev/null +++ b/packages/libs/lib-jdcloud/test/services/monitor.spec.js @@ -0,0 +1,122 @@ +var MONITOR = require('../../src/services/monitor') +var config = require('config') +var global = config.get('global') +var expect = require('chai').expect + +describe('JDCloud.MONITOR', function () { + var monitor = new MONITOR({ + credentials: { + accessKeyId: global.accessKeyId, + secretAccessKey: global.secretAccessKey + }, + version: { + monitor: 'v1' + }, + regionId: 'cn-north-1' + }) + + it('describeMetrics', function () { + return monitor.describeMetrics({ + serviceCode: 'vm', + }) + .then(function (data) { + console.log(data) + }) + }) + + + it('describeMetricData', function () { + return monitor.describeMetricData({ + serviceCode: 'vm', + resourceId: 'i-p1jskbki8', + metric: 'cpu_util', + timeInterval: '1h' + }, 'cn-north-1') + .then(function (data) { + console.log(data) + }) + }) + + it('createAlarm', function () { + return monitor.createAlarm({ + createAlarmSpec: { + serviceCode: 'vm', + resourceIds: ['i-p1jskbki8'], + metric: 'cpu_util', + period: 2, + calculation: 'max', + operation: '==', + threshold: 100.0, + times: 1 + }, + clientToken: 'dsf4safd6hjsfssdf567jaf' + }, 'cn-north-1') + .then(function (data) { + console.log(data) + }) + }) + + it('updateAlarm', function () { + return monitor.updateAlarm({ + alarmId: '265945', + serviceCode: 'vm', + resourceIds: ['i-p1jskbki8'], + metric: 'cpu_util', + period: 2, + calculation: 'max', + operation: '==', + threshold: 99.0, + times: 1 + }, 'cn-north-1') + .then(function (data) { + console.log(data) + }) + }) + + it('disableAlarm', function () { + return monitor.disableAlarm({ + alarmId: '265945', + }, 'cn-north-1') + .then(function (data) { + console.log(data) + }) + }) + + it('enableAlarm', function () { + return monitor.enableAlarm({ + alarmId: '265945', + }, 'cn-north-1') + .then(function (data) { + console.log(data) + }) + }) + + it('describeAlarmsByID', function () { + return monitor.describeAlarmsByID({ + alarmId: '265945', + }, 'cn-north-1') + .then(function (data) { + console.log(data) + }) + }) + + it('describeAlarms', function () { + return monitor.describeAlarms({ + pageNumber: 1, + pageSize: 50 + }, 'cn-north-1') + .then(function (data) { + console.log(data) + }) + }) + + it('deleteAlarms', function () { + return monitor.deleteAlarms({ + ids: '265945', + }, 'cn-north-1') + .then(function (data) { + console.log(data) + }) + }) + +}) diff --git a/packages/libs/lib-jdcloud/test/services/nc.spec.js b/packages/libs/lib-jdcloud/test/services/nc.spec.js new file mode 100644 index 000000000..f8bdc3145 --- /dev/null +++ b/packages/libs/lib-jdcloud/test/services/nc.spec.js @@ -0,0 +1,33 @@ +var NC = require('../../src/services/nativecontainer') +var config = require('config') +var global = config.get('global') +describe('JDCloud.NC', function () { + var nc = new NATIVECONTAINER({ + credentials: { + accessKeyId: global.accessKeyId, + secretAccessKey: global.secretAccessKey + }, + endpoint: { + host: 'nativecontainer.internal.cn-north-1.jdcloud-api.com', //指定非默认Endpoint + protocol: 'http' //设置使用HTTP而不是HTTPS,vpc专用域名不支持HTTPS + }, + 'x-extra-header': { //指定额外header + "x-jdcloud-security-token" : "xxx", //要调用开启了MFA操作保护的接口需要传递 + "x-jdcloud-content-sha256" : "xxx", //body过大,希望用此value替代对body进行哈希的过程 + "MyOwn" : "xxx" + }, + version: { + nativecontainer: 'v1' + } + }) + // var nc = new NC(); + describe('describeContainers', function () { + it('should be able to get nc list', function () { + return nc.describeContainers({ + filters: [ + {name: 'containerId', values: ['c-rxjwzysxu', 'c-73woiy7iz']} + ], + }, 'cn-north-1') + }) + }) +}) diff --git a/packages/libs/lib-jdcloud/test/services/oss.spec.js b/packages/libs/lib-jdcloud/test/services/oss.spec.js new file mode 100644 index 000000000..90ca24417 --- /dev/null +++ b/packages/libs/lib-jdcloud/test/services/oss.spec.js @@ -0,0 +1,61 @@ +var OSS = require('../../src/services/oss') +var config = require('config') +var global = config.get('global') +var expect = require('chai').expect + +describe('JDCloud.OSS', function () { + + var oss = new OSS({ + credentials: { + accessKeyId: global.accessKeyId, + secretAccessKey: global.secretAccessKey + }, + version: { + oss: 'v1' + }, + basePath : '/v1', //默认要设为空"" + }) + + describe('listBucket', function () { + it('should be able to get bucket list', function () { + return oss.listBuckets({ + },'cn-east-1') + .then(function (data) { + console.log(data) + }) + }) + }) + + describe('putBucket', function () { + it('should be able to put bucket', function () { + return oss.putBucket({ + bucketname : "apitest" + },'cn-east-1') + .then(function (data) { + console.log(data) + }) + }) + }) + + describe('headBucket', function () { + it('should be able to get head', function () { + return oss.headBucket({ + bucketname : "apitest" + },'cn-east-1') + .then(function (data) { + console.log(data) + }) + }) + }) + + describe('deleteBucket', function () { + it('should be able to get head', function () { + return oss.deleteBucket({ + bucketname : "apitest" + },'cn-east-1') + .then(function (data) { + console.log(data) + }) + }) + }) +}) diff --git a/packages/libs/lib-jdcloud/test/services/vm.spec.js b/packages/libs/lib-jdcloud/test/services/vm.spec.js new file mode 100644 index 000000000..a24ba70a4 --- /dev/null +++ b/packages/libs/lib-jdcloud/test/services/vm.spec.js @@ -0,0 +1,70 @@ +var VM = require('../../src/services/vm') +var config = require('config') +var global = config.get('global') +var expect = require('chai').expect + +describe('JDCloud.VM', function () { + var vm = new VM({ + credentials: { + accessKeyId: global.accessKeyId, + secretAccessKey: global.secretAccessKey + }, + regionId: 'cn-north-1', + version: { + vm: 'v1' + } + }) + it('describeInstances', function () { + console.log("========DescribeInstances======="); + return vm.describeInstances({ + filters: [{ name: "name" , values:[ "i-6za0ovr24v", + "i-rj5ve7jegu", + "i-rj5ve7jegu1", + "i-rj5ve7jegu2", + "i-rj5ve7jegu3", + "i-rj5ve7jegu4", + "i-rj5ve7jegdu"] ,operator: "eq"}] + }, 'cn-north-1') + .then(function (data) { + console.log(data) + }) + }) + describe('should create and delete a instance', function () { + var instanceId = null + it('createInstances', function () { + return vm + .createInstances({ + instanceSpec: { + instanceType: 'g.s1.micro', + az: 'cn-north-1a', + imageId: '9d44a0f-88c1-451a-8971-f1f769073b6c', + name: 'node-sdk-test', + elasticIp: { bandwidthMbps: 2, provider: 'BGP' }, + primaryNetworkInterface: { + networkInterface: { + subnetId: 'subnet-3dm3k30gh', + az: 'cn-north-1a' + } + }, + systemDisk: { diskCategory: 'local' }, + description: 'sdk' + }, + maxCount: 1 + }, 'cn-north-1') + .then(function (data) { + + // instanceIds = data.data.instanceIds + // return expec(instanceIds[0]).to.not.be.empty + }) + }) + it('deleteInstance', function () { + if (instanceId) { + return vm.deleteInstance({ + instanceId: instanceId + }) + } else { + this.skip() + } + }) + }) +}) diff --git a/packages/libs/lib-jdcloud/tsconfig.json b/packages/libs/lib-jdcloud/tsconfig.json new file mode 100644 index 000000000..d72a2eea7 --- /dev/null +++ b/packages/libs/lib-jdcloud/tsconfig.json @@ -0,0 +1,41 @@ +{ + "compileOnSave": true, + "compilerOptions": { + "target": "ESNext", + "module": "ESNext", + "moduleResolution": "node", + "esModuleInterop": true, + "experimentalDecorators": true, + "emitDecoratorMetadata": true, + "noImplicitThis": true, + "noUnusedLocals": true, + "stripInternal": true, + "importHelpers": true, + "skipLibCheck": true, + "pretty": true, + "declaration": true, + "forceConsistentCasingInFileNames": true, + "typeRoots": [ "./typings", "./node_modules/@types"], + "outDir": "dist", + "rootDir": "src", + "composite": false, + "useDefineForClassFields": true, + "strict": false, + "sourceMap": true, + "resolveJsonModule": true, + "isolatedModules": false, + "lib": ["ESNext", "DOM"], + }, + "include": [ + "src/**/*.ts", + "src/**/*.d.ts", + "src/**/*.js", + "src/**/*.json" + ], + "exclude": [ + "*.ts", + "dist", + "node_modules", + "test" + ], +} diff --git a/packages/plugins/plugin-cert/src/plugin/cert-plugin/index.ts b/packages/plugins/plugin-cert/src/plugin/cert-plugin/index.ts index e34a729d9..96630690c 100644 --- a/packages/plugins/plugin-cert/src/plugin/cert-plugin/index.ts +++ b/packages/plugins/plugin-cert/src/plugin/cert-plugin/index.ts @@ -66,7 +66,7 @@ export class CertApplyPlugin extends CertApplyBasePlugin { ], }, required: true, - helper: `DNS直接验证:域名是在阿里云、腾讯云、华为云、Cloudflare、NameSilo、西数、dns.la注册的,选它; + helper: `DNS直接验证:域名是在阿里云/腾讯云/华为云/Cloudflare/NameSilo/西数/火山/dns.la/京东云注册的,选它; CNAME代理验证:支持任何注册商注册的域名,但第一次需要手动添加CNAME记录; HTTP文件验证:不支持泛域名,需要配置网站文件上传`, }) diff --git a/packages/ui/certd-server/package.json b/packages/ui/certd-server/package.json index dc4055e8b..031b54428 100644 --- a/packages/ui/certd-server/package.json +++ b/packages/ui/certd-server/package.json @@ -50,6 +50,7 @@ "@certd/plugin-lib": "^1.31.10", "@certd/plugin-plus": "^1.31.10", "@certd/plus-core": "^1.31.10", + "@certd/jdcloud": "^1.31.10", "@corsinvest/cv4pve-api-javascript": "^8.3.0", "@huaweicloud/huaweicloud-sdk-cdn": "^3.1.120", "@huaweicloud/huaweicloud-sdk-core": "^3.1.120", @@ -80,6 +81,7 @@ "glob": "^11.0.0", "https-proxy-agent": "^7.0.5", "iconv-lite": "^0.6.3", + "jdcloud-sdk-js": "^1.2.202", "js-yaml": "^4.1.0", "jsonwebtoken": "^9.0.0", "jszip": "^3.10.1", diff --git a/packages/ui/certd-server/src/plugins/plugin-jdcloud/access.ts b/packages/ui/certd-server/src/plugins/plugin-jdcloud/access.ts new file mode 100644 index 000000000..ab8231086 --- /dev/null +++ b/packages/ui/certd-server/src/plugins/plugin-jdcloud/access.ts @@ -0,0 +1,36 @@ +import {AccessInput, BaseAccess, IsAccess} from '@certd/pipeline'; + +/** + * 这个注解将注册一个授权配置 + * 在certd的后台管理系统中,用户可以选择添加此类型的授权 + */ +@IsAccess({ + name: 'jdcloud', + title: '京东云', + desc: '', + icon: 'svg:icon-jdcloud', +}) +export class JDCloudAccess extends BaseAccess { + + @AccessInput({ + title: 'AccessKeyID', + component: { + placeholder: 'AccessKeyID', + }, + helper:"[获取密钥](https://uc.jdcloud.com/account/accesskey)", + required: true, + }) + accessKeyId = ''; + @AccessInput({ + title: 'SecretAccessKey', + component: { + placeholder: 'SecretAccessKey', + }, + required: true, + encrypt: true, + }) + secretAccessKey = ''; + +} + +new JDCloudAccess(); diff --git a/packages/ui/certd-server/src/plugins/plugin-jdcloud/dns-provider.ts b/packages/ui/certd-server/src/plugins/plugin-jdcloud/dns-provider.ts new file mode 100644 index 000000000..96a492b2d --- /dev/null +++ b/packages/ui/certd-server/src/plugins/plugin-jdcloud/dns-provider.ts @@ -0,0 +1,97 @@ +import { AbstractDnsProvider, CreateRecordOptions, IsDnsProvider, RemoveRecordOptions } from "@certd/plugin-cert"; +import { Autowire } from "@certd/pipeline"; +import { JDCloudAccess } from "./access.js"; + +@IsDnsProvider({ + name: "jdcloud", + title: "京东云", + desc: "京东云DNS解析提供商", + accessType: "jdcloud", + icon: "svg:icon-jdcloud" +}) +export class JDCloudDnsProvider extends AbstractDnsProvider { + @Autowire() + access!: JDCloudAccess; + + + async onInstance() { + } + + + + async createRecord(options: CreateRecordOptions): Promise { + const { fullRecord, hostRecord, value, type, domain } = options; + this.logger.info("添加域名解析:", fullRecord, value, domain); + + const service = await this.getJDDomainService(); + + const domainRes = await service.describeDomains({ + domainName: domain, + pageNumber: 1, + pageSize: 10 + }) + if (!domainRes.result?.dataList?.length) { + throw new Error(`域名${domain}在此京东云账号中不存在`) + } + + const domainId = domainRes.result.dataList[0].id + this.logger.info("域名ID:", domainId) + /** + * hostRecord String True 主机记录 + * hostValue String True 解析记录的值 + * jcloudRes Boolean False 是否是京东云资源 + * mxPriority Integer False 优先级,只存在于MX, SRV解析记录类型 + * port Integer False 端口,只存在于SRV解析记录类型 + * ttl Integer True 解析记录的生存时间,单位:秒 + * type String True 解析的类型,请参考解析记录类型详解 + * weight Integer False 解析记录的权重,目前支持权重的有:A/AAAA/CNAME/JNAME,A/AAAA权重范围:0-100、CNAME/JNAME权重范围:1-100。 + * viewValue Integer True 解析线路的ID,请调用describeViewTree接口获取基础解 + */ + try{ + const res = await service.createResourceRecord({ + domainId: domainId, + req:{ + hostRecord: hostRecord, + hostValue: value, + type: type, + ttl: 100, + } + }) + return { + recordId: res.result.dataList[0].id, + domainId: domainId + }; + }catch (e) { + this.logger.error(e) + throw e + } + + + + } + + async removeRecord(options: RemoveRecordOptions): Promise { + const record = options.recordRes; + + const service = await this.getJDDomainService(); + await service.deleteResourceRecord({ + domainId: record.domainId, + resourceRecordId: record.recordId + }) + } + + private async getJDDomainService() { + const {JDDomainService} = await import("@certd/jdcloud") + const service = new JDDomainService({ + credentials: { + accessKeyId: this.access.accessKeyId, + secretAccessKey: this.access.secretAccessKey + }, + regionId: "cn-north-1" //地域信息,某个api调用可以单独传参regionId,如果不传则会使用此配置中的regionId + }); + return service; + } + +} + +new JDCloudDnsProvider(); diff --git a/packages/ui/certd-server/src/plugins/plugin-jdcloud/index.ts b/packages/ui/certd-server/src/plugins/plugin-jdcloud/index.ts new file mode 100644 index 000000000..35fce2541 --- /dev/null +++ b/packages/ui/certd-server/src/plugins/plugin-jdcloud/index.ts @@ -0,0 +1,2 @@ +export * from './access.js'; +export * from './dns-provider.js'; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2dc0d3bc6..524a73b45 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -46,7 +46,7 @@ importers: packages/core/acme-client: dependencies: '@certd/basic': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../basic '@peculiar/x509': specifier: ^1.11.0 @@ -204,10 +204,10 @@ importers: packages/core/pipeline: dependencies: '@certd/basic': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../basic '@certd/plus-core': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../pro/plus-core dayjs: specifier: ^1.11.7 @@ -339,10 +339,80 @@ importers: specifier: ^5.4.2 version: 5.8.2 + packages/libs/lib-jdcloud: + dependencies: + babel-register: + specifier: ^6.26.0 + version: 6.26.0 + buffer: + specifier: ^5.0.8 + version: 5.7.1 + create-hash: + specifier: ^1.1.3 + version: 1.2.0 + create-hmac: + specifier: ^1.1.6 + version: 1.1.7 + debug: + specifier: ^3.1.0 + version: 3.2.7 + node-fetch: + specifier: ^2.1.2 + version: 2.7.0(encoding@0.1.13) + querystring: + specifier: ^0.2.0 + version: 0.2.1 + rollup: + specifier: ^3.7.4 + version: 3.29.5 + url: + specifier: ^0.11.0 + version: 0.11.4 + uuid: + specifier: ^3.1.0 + version: 3.4.0 + devDependencies: + '@rollup/plugin-typescript': + specifier: ^11.0.0 + version: 11.1.6(rollup@3.29.5)(tslib@2.8.1)(typescript@5.8.2) + '@typescript-eslint/eslint-plugin': + specifier: ^8.26.1 + version: 8.26.1(@typescript-eslint/parser@8.26.1(eslint@8.57.0)(typescript@5.8.2))(eslint@8.57.0)(typescript@5.8.2) + '@typescript-eslint/parser': + specifier: ^8.26.1 + version: 8.26.1(eslint@8.57.0)(typescript@5.8.2) + babel-cli: + specifier: ^6.26.0 + version: 6.26.0 + babel-preset-env: + specifier: ^1.6.1 + version: 1.7.0 + chai: + specifier: ^4.1.2 + version: 4.5.0 + config: + specifier: ^1.30.0 + version: 1.31.0 + cross-env: + specifier: ^5.1.4 + version: 5.2.1 + js-yaml: + specifier: ^3.11.0 + version: 3.14.1 + mocha: + specifier: ^5.0.0 + version: 5.2.0 + prettier: + specifier: ^2.8.8 + version: 2.8.8 + tslib: + specifier: ^2.8.1 + version: 2.8.1 + packages/libs/lib-k8s: dependencies: '@certd/basic': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../core/basic '@kubernetes/client-node': specifier: 0.21.0 @@ -382,16 +452,16 @@ importers: packages/libs/lib-server: dependencies: '@certd/acme-client': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../core/acme-client '@certd/basic': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../core/basic '@certd/pipeline': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../core/pipeline '@certd/plus-core': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../pro/plus-core '@midwayjs/cache': specifier: ~3.14.0 @@ -534,16 +604,16 @@ importers: packages/plugins/plugin-cert: dependencies: '@certd/acme-client': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../core/acme-client '@certd/basic': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../core/basic '@certd/pipeline': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../core/pipeline '@certd/plugin-lib': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../plugin-lib '@google-cloud/publicca': specifier: ^1.3.0 @@ -610,10 +680,10 @@ importers: specifier: ^1.7.10 version: 1.8.0 '@certd/basic': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../core/basic '@certd/pipeline': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../core/pipeline '@kubernetes/client-node': specifier: 0.21.0 @@ -701,19 +771,19 @@ importers: packages/pro/commercial-core: dependencies: '@certd/basic': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../core/basic '@certd/lib-server': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../libs/lib-server '@certd/pipeline': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../core/pipeline '@certd/plugin-plus': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../plugin-plus '@certd/plus-core': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../plus-core '@midwayjs/core': specifier: ~3.20.3 @@ -798,22 +868,22 @@ importers: specifier: ^1.0.2 version: 1.0.2 '@certd/basic': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../core/basic '@certd/lib-k8s': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../libs/lib-k8s '@certd/pipeline': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../core/pipeline '@certd/plugin-cert': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../plugins/plugin-cert '@certd/plugin-lib': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../plugins/plugin-lib '@certd/plus-core': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../plus-core ali-oss: specifier: ^6.21.0 @@ -910,7 +980,7 @@ importers: packages/pro/plus-core: dependencies: '@certd/basic': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../core/basic dayjs: specifier: ^1.11.7 @@ -1185,10 +1255,10 @@ importers: version: 0.1.3(zod@3.24.2) devDependencies: '@certd/lib-iframe': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../libs/lib-iframe '@certd/pipeline': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../core/pipeline '@rollup/plugin-commonjs': specifier: ^25.0.7 @@ -1368,40 +1438,43 @@ importers: specifier: ^3.705.0 version: 3.758.0(aws-crt@1.25.3) '@certd/acme-client': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../core/acme-client '@certd/basic': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../core/basic '@certd/commercial-core': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../pro/commercial-core + '@certd/jdcloud': + specifier: ^1.31.10 + version: link:../../libs/lib-jdcloud '@certd/lib-huawei': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../libs/lib-huawei '@certd/lib-k8s': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../libs/lib-k8s '@certd/lib-server': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../libs/lib-server '@certd/midway-flyway-js': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../libs/midway-flyway-js '@certd/pipeline': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../core/pipeline '@certd/plugin-cert': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../plugins/plugin-cert '@certd/plugin-lib': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../plugins/plugin-lib '@certd/plugin-plus': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../pro/plugin-plus '@certd/plus-core': - specifier: ^1.31.8 + specifier: ^1.31.10 version: link:../../pro/plus-core '@corsinvest/cv4pve-api-javascript': specifier: ^8.3.0 @@ -1493,6 +1566,9 @@ importers: iconv-lite: specifier: ^0.6.3 version: 0.6.3 + jdcloud-sdk-js: + specifier: ^1.2.202 + version: 1.2.202(encoding@0.1.13) js-yaml: specifier: ^4.1.0 version: 4.1.0 @@ -5137,6 +5213,10 @@ packages: resolution: {integrity: sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==} engines: {node: '>=8'} + ansi-regex@2.1.1: + resolution: {integrity: sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==} + engines: {node: '>=0.10.0'} + ansi-regex@5.0.1: resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} engines: {node: '>=8'} @@ -5145,6 +5225,10 @@ packages: resolution: {integrity: sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==} engines: {node: '>=12'} + ansi-styles@2.2.1: + resolution: {integrity: sha512-kmCevFghRiWM7HB5zTPULl4r9bVFSWjz62MhqizDGUrq2NWuNMQyuv4tHHoKJHs69M/MF64lEcHdYIocrdWQYA==} + engines: {node: '>=0.10.0'} + ansi-styles@3.2.1: resolution: {integrity: sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==} engines: {node: '>=4'} @@ -5174,6 +5258,9 @@ packages: any-promise@1.3.0: resolution: {integrity: sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==} + anymatch@1.3.2: + resolution: {integrity: sha512-0XNayC8lTHQ2OI8aljNCN3sSx6hsr/1+rlcDAotXJR7C1oZZHCNsfpbKwMjRA3Uqb5tF1Rae2oloTr4xpq+WjA==} + anymatch@3.1.3: resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==} engines: {node: '>= 8'} @@ -5201,6 +5288,22 @@ packages: resolution: {integrity: sha512-y+CcFFwelSXpLZk/7fMB2mUbGtX9lKycf1MWJ7CaTIERyitVlyQx6C+sxcROU2BAJ24OiZyK+8wj2i8AlBoS3A==} engines: {node: '>=10'} + arr-diff@2.0.0: + resolution: {integrity: sha512-dtXTVMkh6VkEEA7OhXnN1Ecb8aAGFdZ1LFxtOCoqj4qkyOJMt7+qs6Ahdy6p/NQCPYsRSXXivhSB/J5E9jmYKA==} + engines: {node: '>=0.10.0'} + + arr-diff@4.0.0: + resolution: {integrity: sha512-YVIQ82gZPGBebQV/a8dar4AitzCQs0jjXwMPZllpXMaGjXPYVUawSxQrRsjhjupyVxEvbHgUmIhKVlND+j02kA==} + engines: {node: '>=0.10.0'} + + arr-flatten@1.1.0: + resolution: {integrity: sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==} + engines: {node: '>=0.10.0'} + + arr-union@3.1.0: + resolution: {integrity: sha512-sKpyeERZ02v1FeCZT8lrfJq5u6goHCtpTAzPwJYe7c8SPFOboNjNg1vz2L4VTn9T4PQxEx13TbXLmYUcS6Ug7Q==} + engines: {node: '>=0.10.0'} + array-back@1.0.4: resolution: {integrity: sha512-1WxbZvrmyhkNoeYcizokbmh5oiOCIfyvGtcqbK3Ls1v1fKcquzxnQSceOx6tzq7jmai2kFLWIpGND2cLhH6TPw==} engines: {node: '>=0.12.0'} @@ -5251,6 +5354,14 @@ packages: resolution: {integrity: sha512-1OvF9IbWwaeiM9VhzYXVQacMibxpXOMYVNIvMtKRyX9SImBXpKcFr8XvFDeEslCyuH/t6KRt7HEO94AlP8Iatw==} engines: {node: '>=12'} + array-unique@0.2.1: + resolution: {integrity: sha512-G2n5bG5fSUCpnsXz4+8FUkYsGPkNfLn9YvS66U5qbTIXI2Ynnlo4Bi42bWv+omKUCqz+ejzfClwne0alJWJPhg==} + engines: {node: '>=0.10.0'} + + array-unique@0.3.2: + resolution: {integrity: sha512-SleRWjh9JUud2wH1hPs9rZBZ33H6T9HOiL0uwGnGx9FpE6wKGyfWugmbkEOIs6qWrZhg0LWeLziLrEwQJhs5mQ==} + engines: {node: '>=0.10.0'} + array.prototype.findlastindex@1.2.5: resolution: {integrity: sha512-zfETvRFA8o7EiNn++N5f/kaCw221hrpGsDmcpndVupkPzEc1Wuf3VgC0qby1BbHs7f5DVYjgtEU2LLh5bqeGfQ==} engines: {node: '>= 0.4'} @@ -5292,6 +5403,10 @@ packages: resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==} engines: {node: '>=12'} + assign-symbols@1.0.0: + resolution: {integrity: sha512-Q+JC7Whu8HhmTdBph/Tq59IoRtoy6KAm5zzPv00WdujX82lbAL8K7WVjne7vdCsAmbF4AYaDOPyO3k0kl8qIrw==} + engines: {node: '>=0.10.0'} + ast-kit@1.4.2: resolution: {integrity: sha512-lvGehj1XsrIoQrD5CfPduIzQbcpuX2EPjlk/vDMDQF9U9HLRB6WwMTdighj5n52hdhh8xg9VgPTU7Q25MuJ/rw==} engines: {node: '>=16.14.0'} @@ -5304,6 +5419,9 @@ packages: resolution: {integrity: sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==} engines: {node: '>=8'} + async-each@1.0.6: + resolution: {integrity: sha512-c646jH1avxr+aVpndVMeAfYw7wAa6idufrlN3LPA4PmKS0QEGp6PIC9nwz0WQkkvBGAMEki3pFdtxaF39J9vvg==} + async-function@1.0.0: resolution: {integrity: sha512-hsU18Ae8CDTR6Kgu9DYf0EbCr/a5iGL0rytQDobUcdpYOKokk8LEjVphnXkDkgpi0wYVsqrXuP0bZxJaTqdgoA==} engines: {node: '>= 0.4'} @@ -5323,6 +5441,11 @@ packages: asynckit@0.4.0: resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} + atob@2.1.2: + resolution: {integrity: sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==} + engines: {node: '>= 4.5.0'} + hasBin: true + atomically@1.7.0: resolution: {integrity: sha512-Xcz9l0z7y9yQ9rdDaxlmaI4uJHf/T8g9hOEzJcsEqX2SjCj4J20uK7+ldkDHMbpJDK76wF7xEIgxc/vSlsfw5w==} engines: {node: '>=10.12.0'} @@ -5358,6 +5481,61 @@ packages: axios@1.8.2: resolution: {integrity: sha512-ls4GYBm5aig9vWx8AWDSGLpnpDQRtWAfrjU+EuytuODrFBkqesN2RkOQCBzrA1RQNHw1SmRMSDDDSwzNAYQ6Rg==} + babel-cli@6.26.0: + resolution: {integrity: sha512-wau+BDtQfuSBGQ9PzzFL3REvR9Sxnd4LKwtcHAiPjhugA7K/80vpHXafj+O5bAqJOuSefjOx5ZJnNSR2J1Qw6Q==} + hasBin: true + + babel-code-frame@6.26.0: + resolution: {integrity: sha512-XqYMR2dfdGMW+hd0IUZ2PwK+fGeFkOxZJ0wY+JaQAHzt1Zx8LcvpiZD2NiGkEG8qx0CfkAOr5xt76d1e8vG90g==} + + babel-core@6.26.3: + resolution: {integrity: sha512-6jyFLuDmeidKmUEb3NM+/yawG0M2bDZ9Z1qbZP59cyHLz8kYGKYwpJP0UwUKKUiTRNvxfLesJnTedqczP7cTDA==} + + babel-generator@6.26.1: + resolution: {integrity: sha512-HyfwY6ApZj7BYTcJURpM5tznulaBvyio7/0d4zFOeMPUmfxkCjHocCuoLa2SAGzBI8AREcH3eP3758F672DppA==} + + babel-helper-builder-binary-assignment-operator-visitor@6.24.1: + resolution: {integrity: sha512-gCtfYORSG1fUMX4kKraymq607FWgMWg+j42IFPc18kFQEsmtaibP4UrqsXt8FlEJle25HUd4tsoDR7H2wDhe9Q==} + + babel-helper-call-delegate@6.24.1: + resolution: {integrity: sha512-RL8n2NiEj+kKztlrVJM9JT1cXzzAdvWFh76xh/H1I4nKwunzE4INBXn8ieCZ+wh4zWszZk7NBS1s/8HR5jDkzQ==} + + babel-helper-define-map@6.26.0: + resolution: {integrity: sha512-bHkmjcC9lM1kmZcVpA5t2om2nzT/xiZpo6TJq7UlZ3wqKfzia4veeXbIhKvJXAMzhhEBd3cR1IElL5AenWEUpA==} + + babel-helper-explode-assignable-expression@6.24.1: + resolution: {integrity: sha512-qe5csbhbvq6ccry9G7tkXbzNtcDiH4r51rrPUbwwoTzZ18AqxWYRZT6AOmxrpxKnQBW0pYlBI/8vh73Z//78nQ==} + + babel-helper-function-name@6.24.1: + resolution: {integrity: sha512-Oo6+e2iX+o9eVvJ9Y5eKL5iryeRdsIkwRYheCuhYdVHsdEQysbc2z2QkqCLIYnNxkT5Ss3ggrHdXiDI7Dhrn4Q==} + + babel-helper-get-function-arity@6.24.1: + resolution: {integrity: sha512-WfgKFX6swFB1jS2vo+DwivRN4NB8XUdM3ij0Y1gnC21y1tdBoe6xjVnd7NSI6alv+gZXCtJqvrTeMW3fR/c0ng==} + + babel-helper-hoist-variables@6.24.1: + resolution: {integrity: sha512-zAYl3tqerLItvG5cKYw7f1SpvIxS9zi7ohyGHaI9cgDUjAT6YcY9jIEH5CstetP5wHIVSceXwNS7Z5BpJg+rOw==} + + babel-helper-optimise-call-expression@6.24.1: + resolution: {integrity: sha512-Op9IhEaxhbRT8MDXx2iNuMgciu2V8lDvYCNQbDGjdBNCjaMvyLf4wl4A3b8IgndCyQF8TwfgsQ8T3VD8aX1/pA==} + + babel-helper-regex@6.26.0: + resolution: {integrity: sha512-VlPiWmqmGJp0x0oK27Out1D+71nVVCTSdlbhIVoaBAj2lUgrNjBCRR9+llO4lTSb2O4r7PJg+RobRkhBrf6ofg==} + + babel-helper-remap-async-to-generator@6.24.1: + resolution: {integrity: sha512-RYqaPD0mQyQIFRu7Ho5wE2yvA/5jxqCIj/Lv4BXNq23mHYu/vxikOy2JueLiBxQknwapwrJeNCesvY0ZcfnlHg==} + + babel-helper-replace-supers@6.24.1: + resolution: {integrity: sha512-sLI+u7sXJh6+ToqDr57Bv973kCepItDhMou0xCP2YPVmR1jkHSCY+p1no8xErbV1Siz5QE8qKT1WIwybSWlqjw==} + + babel-helpers@6.24.1: + resolution: {integrity: sha512-n7pFrqQm44TCYvrCDb0MqabAF+JUBq+ijBvNMUxpkLjJaAu32faIexewMumrH5KLLJ1HDyT0PTEqRyAe/GwwuQ==} + + babel-messages@6.23.0: + resolution: {integrity: sha512-Bl3ZiA+LjqaMtNYopA9TYE9HP1tQ+E5dLxE0XrAzcIJeK2UqF0/EaqXwBn9esd4UmTfEab+P+UYQ1GnioFIb/w==} + + babel-plugin-check-es2015-constants@6.22.0: + resolution: {integrity: sha512-B1M5KBP29248dViEo1owyY32lk1ZSH2DaNNrXLGt8lyjjHm7pBqAdQ7VKUPR6EEDO323+OvT3MQXbCin8ooWdA==} + babel-plugin-polyfill-corejs2@0.4.12: resolution: {integrity: sha512-CPWT6BwvhrTO2d8QVorhTCQw9Y43zOu7G9HigcfxvepOU6b8o3tcWad6oVgZIsZCTt42FFv97aA7ZJsbM4+8og==} peerDependencies: @@ -5373,6 +5551,118 @@ packages: peerDependencies: '@babel/core': ^7.4.0 || ^8.0.0-0 <8.0.0 + babel-plugin-syntax-async-functions@6.13.0: + resolution: {integrity: sha512-4Zp4unmHgw30A1eWI5EpACji2qMocisdXhAftfhXoSV9j0Tvj6nRFE3tOmRY912E0FMRm/L5xWE7MGVT2FoLnw==} + + babel-plugin-syntax-exponentiation-operator@6.13.0: + resolution: {integrity: sha512-Z/flU+T9ta0aIEKl1tGEmN/pZiI1uXmCiGFRegKacQfEJzp7iNsKloZmyJlQr+75FCJtiFfGIK03SiCvCt9cPQ==} + + babel-plugin-syntax-trailing-function-commas@6.22.0: + resolution: {integrity: sha512-Gx9CH3Q/3GKbhs07Bszw5fPTlU+ygrOGfAhEt7W2JICwufpC4SuO0mG0+4NykPBSYPMJhqvVlDBU17qB1D+hMQ==} + + babel-plugin-transform-async-to-generator@6.24.1: + resolution: {integrity: sha512-7BgYJujNCg0Ti3x0c/DL3tStvnKS6ktIYOmo9wginv/dfZOrbSZ+qG4IRRHMBOzZ5Awb1skTiAsQXg/+IWkZYw==} + + babel-plugin-transform-es2015-arrow-functions@6.22.0: + resolution: {integrity: sha512-PCqwwzODXW7JMrzu+yZIaYbPQSKjDTAsNNlK2l5Gg9g4rz2VzLnZsStvp/3c46GfXpwkyufb3NCyG9+50FF1Vg==} + + babel-plugin-transform-es2015-block-scoped-functions@6.22.0: + resolution: {integrity: sha512-2+ujAT2UMBzYFm7tidUsYh+ZoIutxJ3pN9IYrF1/H6dCKtECfhmB8UkHVpyxDwkj0CYbQG35ykoz925TUnBc3A==} + + babel-plugin-transform-es2015-block-scoping@6.26.0: + resolution: {integrity: sha512-YiN6sFAQ5lML8JjCmr7uerS5Yc/EMbgg9G8ZNmk2E3nYX4ckHR01wrkeeMijEf5WHNK5TW0Sl0Uu3pv3EdOJWw==} + + babel-plugin-transform-es2015-classes@6.24.1: + resolution: {integrity: sha512-5Dy7ZbRinGrNtmWpquZKZ3EGY8sDgIVB4CU8Om8q8tnMLrD/m94cKglVcHps0BCTdZ0TJeeAWOq2TK9MIY6cag==} + + babel-plugin-transform-es2015-computed-properties@6.24.1: + resolution: {integrity: sha512-C/uAv4ktFP/Hmh01gMTvYvICrKze0XVX9f2PdIXuriCSvUmV9j+u+BB9f5fJK3+878yMK6dkdcq+Ymr9mrcLzw==} + + babel-plugin-transform-es2015-destructuring@6.23.0: + resolution: {integrity: sha512-aNv/GDAW0j/f4Uy1OEPZn1mqD+Nfy9viFGBfQ5bZyT35YqOiqx7/tXdyfZkJ1sC21NyEsBdfDY6PYmLHF4r5iA==} + + babel-plugin-transform-es2015-duplicate-keys@6.24.1: + resolution: {integrity: sha512-ossocTuPOssfxO2h+Z3/Ea1Vo1wWx31Uqy9vIiJusOP4TbF7tPs9U0sJ9pX9OJPf4lXRGj5+6Gkl/HHKiAP5ug==} + + babel-plugin-transform-es2015-for-of@6.23.0: + resolution: {integrity: sha512-DLuRwoygCoXx+YfxHLkVx5/NpeSbVwfoTeBykpJK7JhYWlL/O8hgAK/reforUnZDlxasOrVPPJVI/guE3dCwkw==} + + babel-plugin-transform-es2015-function-name@6.24.1: + resolution: {integrity: sha512-iFp5KIcorf11iBqu/y/a7DK3MN5di3pNCzto61FqCNnUX4qeBwcV1SLqe10oXNnCaxBUImX3SckX2/o1nsrTcg==} + + babel-plugin-transform-es2015-literals@6.22.0: + resolution: {integrity: sha512-tjFl0cwMPpDYyoqYA9li1/7mGFit39XiNX5DKC/uCNjBctMxyL1/PT/l4rSlbvBG1pOKI88STRdUsWXB3/Q9hQ==} + + babel-plugin-transform-es2015-modules-amd@6.24.1: + resolution: {integrity: sha512-LnIIdGWIKdw7zwckqx+eGjcS8/cl8D74A3BpJbGjKTFFNJSMrjN4bIh22HY1AlkUbeLG6X6OZj56BDvWD+OeFA==} + + babel-plugin-transform-es2015-modules-commonjs@6.26.2: + resolution: {integrity: sha512-CV9ROOHEdrjcwhIaJNBGMBCodN+1cfkwtM1SbUHmvyy35KGT7fohbpOxkE2uLz1o6odKK2Ck/tz47z+VqQfi9Q==} + + babel-plugin-transform-es2015-modules-systemjs@6.24.1: + resolution: {integrity: sha512-ONFIPsq8y4bls5PPsAWYXH/21Hqv64TBxdje0FvU3MhIV6QM2j5YS7KvAzg/nTIVLot2D2fmFQrFWCbgHlFEjg==} + + babel-plugin-transform-es2015-modules-umd@6.24.1: + resolution: {integrity: sha512-LpVbiT9CLsuAIp3IG0tfbVo81QIhn6pE8xBJ7XSeCtFlMltuar5VuBV6y6Q45tpui9QWcy5i0vLQfCfrnF7Kiw==} + + babel-plugin-transform-es2015-object-super@6.24.1: + resolution: {integrity: sha512-8G5hpZMecb53vpD3mjs64NhI1au24TAmokQ4B+TBFBjN9cVoGoOvotdrMMRmHvVZUEvqGUPWL514woru1ChZMA==} + + babel-plugin-transform-es2015-parameters@6.24.1: + resolution: {integrity: sha512-8HxlW+BB5HqniD+nLkQ4xSAVq3bR/pcYW9IigY+2y0dI+Y7INFeTbfAQr+63T3E4UDsZGjyb+l9txUnABWxlOQ==} + + babel-plugin-transform-es2015-shorthand-properties@6.24.1: + resolution: {integrity: sha512-mDdocSfUVm1/7Jw/FIRNw9vPrBQNePy6wZJlR8HAUBLybNp1w/6lr6zZ2pjMShee65t/ybR5pT8ulkLzD1xwiw==} + + babel-plugin-transform-es2015-spread@6.22.0: + resolution: {integrity: sha512-3Ghhi26r4l3d0Js933E5+IhHwk0A1yiutj9gwvzmFbVV0sPMYk2lekhOufHBswX7NCoSeF4Xrl3sCIuSIa+zOg==} + + babel-plugin-transform-es2015-sticky-regex@6.24.1: + resolution: {integrity: sha512-CYP359ADryTo3pCsH0oxRo/0yn6UsEZLqYohHmvLQdfS9xkf+MbCzE3/Kolw9OYIY4ZMilH25z/5CbQbwDD+lQ==} + + babel-plugin-transform-es2015-template-literals@6.22.0: + resolution: {integrity: sha512-x8b9W0ngnKzDMHimVtTfn5ryimars1ByTqsfBDwAqLibmuuQY6pgBQi5z1ErIsUOWBdw1bW9FSz5RZUojM4apg==} + + babel-plugin-transform-es2015-typeof-symbol@6.23.0: + resolution: {integrity: sha512-fz6J2Sf4gYN6gWgRZaoFXmq93X+Li/8vf+fb0sGDVtdeWvxC9y5/bTD7bvfWMEq6zetGEHpWjtzRGSugt5kNqw==} + + babel-plugin-transform-es2015-unicode-regex@6.24.1: + resolution: {integrity: sha512-v61Dbbihf5XxnYjtBN04B/JBvsScY37R1cZT5r9permN1cp+b70DY3Ib3fIkgn1DI9U3tGgBJZVD8p/mE/4JbQ==} + + babel-plugin-transform-exponentiation-operator@6.24.1: + resolution: {integrity: sha512-LzXDmbMkklvNhprr20//RStKVcT8Cu+SQtX18eMHLhjHf2yFzwtQ0S2f0jQ+89rokoNdmwoSqYzAhq86FxlLSQ==} + + babel-plugin-transform-regenerator@6.26.0: + resolution: {integrity: sha512-LS+dBkUGlNR15/5WHKe/8Neawx663qttS6AGqoOUhICc9d1KciBvtrQSuc0PI+CxQ2Q/S1aKuJ+u64GtLdcEZg==} + + babel-plugin-transform-strict-mode@6.24.1: + resolution: {integrity: sha512-j3KtSpjyLSJxNoCDrhwiJad8kw0gJ9REGj8/CqL0HeRyLnvUNYV9zcqluL6QJSXh3nfsLEmSLvwRfGzrgR96Pw==} + + babel-polyfill@6.26.0: + resolution: {integrity: sha512-F2rZGQnAdaHWQ8YAoeRbukc7HS9QgdgeyJ0rQDd485v9opwuPvjpPFcOOT/WmkKTdgy9ESgSPXDcTNpzrGr6iQ==} + + babel-preset-env@1.7.0: + resolution: {integrity: sha512-9OR2afuKDneX2/q2EurSftUYM0xGu4O2D9adAhVfADDhrYDaxXV0rBbevVYoY9n6nyX1PmQW/0jtpJvUNr9CHg==} + + babel-register@6.26.0: + resolution: {integrity: sha512-veliHlHX06wjaeY8xNITbveXSiI+ASFnOqvne/LaIJIqOWi2Ogmj91KOugEz/hoh/fwMhXNBJPCv8Xaz5CyM4A==} + + babel-runtime@6.26.0: + resolution: {integrity: sha512-ITKNuq2wKlW1fJg9sSW52eepoYgZBggvOAHC0u/CYu/qxQ9EVzThCgR69BnSXLHjy2f7SY5zaQ4yt7H9ZVxY2g==} + + babel-template@6.26.0: + resolution: {integrity: sha512-PCOcLFW7/eazGUKIoqH97sO9A2UYMahsn/yRQ7uOk37iutwjq7ODtcTNF+iFDSHNfkctqsLRjLP7URnOx0T1fg==} + + babel-traverse@6.26.0: + resolution: {integrity: sha512-iSxeXx7apsjCHe9c7n8VtRXGzI2Bk1rBSOJgCCjfyXb6v1aCqE1KSEpq/8SXuVN8Ka/Rh1WDTF0MDzkvTA4MIA==} + + babel-types@6.26.0: + resolution: {integrity: sha512-zhe3V/26rCWsEZK8kZN+HaQj5yQ1CilTObixFzKW1UWjqG7618Twz6YEsCnjfg5gBcJh02DrpCkS9h98ZqDY+g==} + + babylon@6.18.0: + resolution: {integrity: sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ==} + hasBin: true + baidu-aip-sdk@4.16.16: resolution: {integrity: sha512-dXjeQrd/eJIXDzBXNKArZZyFxf2boUI+XKEqb7yLUwnNiHJT3xDmHz30Oobe1LxOFFsvdH5pm72+pzi6MbXgmw==} @@ -5389,6 +5679,10 @@ packages: resolution: {integrity: sha512-ir1UPr3dkwexU7FdV8qBBbNDRUhMmIekYMFZfi+C/sLNnRESKPl23nB9b2pltqfOQNnGzsDdId90AEtG5tCx4A==} engines: {node: '>=6.0.0'} + base@0.11.2: + resolution: {integrity: sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==} + engines: {node: '>=0.10.0'} + basic-ftp@5.0.5: resolution: {integrity: sha512-4Bcg1P8xhUuqcii/S0Z9wiHIrQVPMermM1any+MX5GeGD7faD3/msQUDGLol9wOcz4/jbg/WJnGqoJF6LiBdtg==} engines: {node: '>=10.0.0'} @@ -5421,6 +5715,10 @@ packages: resolution: {integrity: sha512-cMtq4W5ZsEwcutJrVId+a/tjt8GSbS+h0oNkdl6+6rBuEv8Ot33Bevj5KPm40t309zuhVic8NjpuL42QCiJWWA==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + binary-extensions@1.13.1: + resolution: {integrity: sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==} + engines: {node: '>=0.10.0'} + binary-extensions@2.3.0: resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==} engines: {node: '>=8'} @@ -5459,6 +5757,14 @@ packages: brace-expansion@2.0.1: resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==} + braces@1.8.5: + resolution: {integrity: sha512-xU7bpz2ytJl1bH9cgIurjpg/n8Gohy9GTw81heDYLJQ4RU60dlyJsa+atVF2pI0yMMvKxI9HkKwjePCj5XI1hw==} + engines: {node: '>=0.10.0'} + + braces@2.3.2: + resolution: {integrity: sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==} + engines: {node: '>=0.10.0'} + braces@3.0.3: resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} engines: {node: '>=8'} @@ -5476,6 +5782,10 @@ packages: peerDependencies: browserslist: '*' + browserslist@3.2.8: + resolution: {integrity: sha512-WHVocJYavUwVgVViC0ORikPHQquXwVh939TaelZ4WDqpWgTX/FsGhl/+P4qBUAGcRvtOgDgC+xftNWWp2RUTAQ==} + hasBin: true + browserslist@4.24.4: resolution: {integrity: sha512-KDi1Ny1gSePi1vm0q4oxSF8b4DR44GF4BbmS2YdhPLOEqd8pDviZOGH/GsmRwoWJ2+5Lr085X7naowMwKHDG1A==} engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} @@ -5547,6 +5857,10 @@ packages: resolution: {integrity: sha512-B+L5iIa9mgcjLbliir2th36yEwPftrzteHYujzsx3dFP/31GCHcIeS8f5MGd80odLOjaOvSpU3EEAmRQptkxLQ==} engines: {node: ^16.14.0 || >=18.0.0} + cache-base@1.0.1: + resolution: {integrity: sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==} + engines: {node: '>=0.10.0'} + cache-content-type@1.0.1: resolution: {integrity: sha512-IKufZ1o4Ut42YUrZSo8+qnMTrFuKkvyoLXUywKz9GJ5BrhOFGhLdkx9sG4KAnVvbY6kEcSFjLQul+DVmBm2bgA==} engines: {node: '>= 6.0.0'} @@ -5653,6 +5967,10 @@ packages: resolution: {integrity: sha512-mCuXncKXk5iCLhfhwTc0izo0gtEmpz5CtG2y8GiOINBlMVS6v8TMRc5TaLWKS6692m9+dVVfzgeVxR5UxWHTYw==} engines: {node: '>=12'} + chalk@1.1.3: + resolution: {integrity: sha512-U3lRVLMSlsCfjqYPbLyVv11M9CPW4I728d6TCKMAOJueEeB9/8o+eSsMnxPJD+Q+K909sdESg7C+tIkoH6on1A==} + engines: {node: '>=0.10.0'} + chalk@2.4.2: resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} engines: {node: '>=4'} @@ -5680,6 +5998,9 @@ packages: china-division@2.7.0: resolution: {integrity: sha512-4uUPAT+1WfqDh5jytq7omdCmHNk3j+k76zEG/2IqaGcYB90c2SwcixttcypdsZ3T/9tN1TTpBDoeZn+Yw/qBEA==} + chokidar@1.7.0: + resolution: {integrity: sha512-mk8fAWcRUOxY7btlLtitj3A45jOwSAxH4tOFOoEGbVsl6cL6pPMWUy7dwZ/canfj3QEdP6FHSnf/l1c6/WkzVg==} + chokidar@3.6.0: resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==} engines: {node: '>= 8.10.0'} @@ -5710,12 +6031,20 @@ packages: resolution: {integrity: sha512-cYY9mypksY8NRqgDB1XD1RiJL338v/551niynFTGkZOO2LHuB2OmOYxDIe/ttN9AHwrqdum1360G3ald0W9kCg==} engines: {node: '>=8'} + cipher-base@1.0.6: + resolution: {integrity: sha512-3Ek9H3X6pj5TgenXYtNWdaBon1tgYCaebd+XPg0keyjEbEfkD4KkmAxkQ/i1vYvxdcT5nscLBfq9VJRmCBcFSw==} + engines: {node: '>= 0.10'} + citty@0.1.6: resolution: {integrity: sha512-tskPPKEs8D2KPafUypv2gxwJP8h/OaJmC82QQGGDQcHvXX43xF2VDACcJVmZ0EuSxkpO9Kc4MlrA3q0+FG58AQ==} class-transformer@0.5.1: resolution: {integrity: sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw==} + class-utils@0.3.6: + resolution: {integrity: sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==} + engines: {node: '>=0.10.0'} + class-variance-authority@0.7.1: resolution: {integrity: sha512-Ka+9Trutv7G8M6WT6SeiRWz792K5qEqIGEGzXKhAE6xOWAY6pPH8U+9IY3oCMv6kqTmLsv7Xh/2w2RigkePMsg==} @@ -5799,6 +6128,10 @@ packages: resolution: {integrity: sha512-RKZhRwJtJEP5FWul+gkSMEnaK6H3AGPTTWOiRimCcs+rc/OmQE3Yhy1Q7A7KsdkG3ZXVdZq68Y6ONSdvkeEcKA==} engines: {node: '>=0.10.0'} + collection-visit@1.0.0: + resolution: {integrity: sha512-lNkKvzEeMBBjUGHZ+q6z9pSJla0KWAQPvtzhEV9+iGyQYG+pBpl7xKDhxoNSOZH2hhv0v5k0y2yAM4o4SjoSkw==} + engines: {node: '>=0.10.0'} + color-convert@1.9.3: resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==} @@ -5856,6 +6189,9 @@ packages: commander@2.11.0: resolution: {integrity: sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==} + commander@2.15.1: + resolution: {integrity: sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==} + commander@2.20.3: resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==} @@ -5930,6 +6266,10 @@ packages: config-master@3.1.0: resolution: {integrity: sha512-n7LBL1zBzYdTpF1mx5DNcZnZn05CWIdsdvtPL4MosvqbBUK3Rq6VWEtGUuF3Y0s9/CIhMejezqlSkP6TnCJ/9g==} + config@1.31.0: + resolution: {integrity: sha512-Ep/l9Rd1J9IPueztJfpbOqVzuKHQh4ZODMNt9xqTYdBBNRXbV4oTu34kCkkfdRVcDq0ohtpaeXGgb+c0LQxFRA==} + engines: {node: '>= 4.0.0'} + configstore@5.0.1: resolution: {integrity: sha512-aMKprgk5YhBNyH25hj8wGt2+D52Sw1DRRIzqBwLp2Ya9mFmY8KPvvtvmna8SxVR9JMZ4kzMD68N22vlaRpkeFA==} engines: {node: '>=8'} @@ -5987,6 +6327,9 @@ packages: engines: {node: '>=16'} hasBin: true + convert-source-map@1.9.0: + resolution: {integrity: sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==} + convert-source-map@2.0.0: resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} @@ -6004,6 +6347,10 @@ packages: resolution: {integrity: sha512-yCEafptTtb4bk7GLEQoM8KVJpxAfdBJYaXyzQEgQQQgYrZiDp8SJmGKlYza6CYjEDNstAdNdKA3UuoULlEbS6w==} engines: {node: '>=12.13'} + copy-descriptor@0.1.1: + resolution: {integrity: sha512-XgZ0pFcakEUlbwQEVNg3+QAis1FyTL3Qel9FYy8pSkQqoG3PNoT0bOCQtOXcOkur21r2Eq2kI+IE+gsmAEVlYw==} + engines: {node: '>=0.10.0'} + copy-to@2.0.1: resolution: {integrity: sha512-3DdaFaU/Zf1AnpLiFDeNCD4TOWe3Zl2RZaTzUvWiIk5ERzcCodOE20Vqq4fzCbNoHURFHT4/us/Lfq+S2zyY4w==} @@ -6075,6 +6422,12 @@ packages: buffer: optional: true + create-hash@1.2.0: + resolution: {integrity: sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==} + + create-hmac@1.1.7: + resolution: {integrity: sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==} + create-require@1.1.1: resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==} @@ -6085,11 +6438,20 @@ packages: cropperjs@1.6.2: resolution: {integrity: sha512-nhymn9GdnV3CqiEHJVai54TULFAE3VshJTXSqSJKa8yXAKyBKDWdhHarnlIPrshJ0WMFTGuFvG02YjLXfPiuOA==} + cross-env@5.2.1: + resolution: {integrity: sha512-1yHhtcfAd1r4nwQgknowuUNfIT9E8dOMMspC36g45dN+iD1blloi7xp8X/xAIDnjHWyt1uQ8PHk2fkNaym7soQ==} + engines: {node: '>=4.0'} + hasBin: true + cross-env@7.0.3: resolution: {integrity: sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==} engines: {node: '>=10.14', npm: '>=6', yarn: '>=1'} hasBin: true + cross-spawn@6.0.6: + resolution: {integrity: sha512-VqCUuhcd1iB+dsv8gxPttb5iZh/D0iubSP21g36KXdEuf6I5JiioesUVjpCdHV9MZRUfVFlvwtIUyPfxo5trtw==} + engines: {node: '>=4.8'} + cross-spawn@7.0.6: resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==} engines: {node: '>= 8'} @@ -6274,6 +6636,10 @@ packages: resolution: {integrity: sha512-VfxadyCECXgQlkoEAjeghAr5gY3Hf+IKjKb+X8tGVDtveCjN+USwprd2q3QXBR9T1+x2DG0XZF5/w+7HAtSaXA==} engines: {node: '>=10'} + decode-uri-component@0.2.2: + resolution: {integrity: sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==} + engines: {node: '>=0.10'} + decompress-response@3.3.0: resolution: {integrity: sha512-BzRPQuY1ip+qDonAOz42gRm/pg9F768C+npV/4JOsxRC2sq+Rlk+Q4ZCAsOhnIaMrgarILY+RMUIvMmmX1qAEA==} engines: {node: '>=4'} @@ -6345,6 +6711,18 @@ packages: resolution: {integrity: sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==} engines: {node: '>= 0.4'} + define-property@0.2.5: + resolution: {integrity: sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==} + engines: {node: '>=0.10.0'} + + define-property@1.0.0: + resolution: {integrity: sha512-cZTYKFWspt9jZsMscWo8sc/5lbPC9Q0N5nBLgb+Yd915iL3udB1uFgS3B8YCx66UVHq018DAVFoee7x+gxggeA==} + engines: {node: '>=0.10.0'} + + define-property@2.0.2: + resolution: {integrity: sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==} + engines: {node: '>=0.10.0'} + defu@6.1.4: resolution: {integrity: sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==} @@ -6382,6 +6760,10 @@ packages: resolution: {integrity: sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==} engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16} + detect-indent@4.0.0: + resolution: {integrity: sha512-BDKtmHlOzwI7iRuEkhzsnPoi5ypEhWAJB5RvHWe1kMr06js3uK5B3734i3ui5Yd+wOJV1cpE4JnivPD283GU/A==} + engines: {node: '>=0.10.0'} + detect-indent@7.0.1: resolution: {integrity: sha512-Mc7QhQ8s+cLrnUfU/Ji94vG/r8M26m8f++vyres4ZoojaRDpZ1eSIh/EpzLNwlWuvzSZ3UbDFspjFvTDXe6e/g==} engines: {node: '>=12.20'} @@ -6407,6 +6789,10 @@ packages: resolution: {integrity: sha512-MKPHZDMB0o6yHyDryUOScqZibp914ksXwAMYMTHj6KO8UeKsRYNJD3oNCKjTqZon+V488P7N/HzXF8t7ZR95ww==} engines: {node: '>=0.3.1'} + diff@3.5.0: + resolution: {integrity: sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==} + engines: {node: '>=0.3.1'} + diff@4.0.2: resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==} engines: {node: '>=0.3.1'} @@ -6903,6 +7289,18 @@ packages: resolution: {integrity: sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==} engines: {node: '>=16.17'} + expand-brackets@0.1.5: + resolution: {integrity: sha512-hxx03P2dJxss6ceIeri9cmYOT4SRs3Zk3afZwWpOsRqLqprhTR8u++SlC+sFGsQr7WGFPdMF7Gjc1njDLDK6UA==} + engines: {node: '>=0.10.0'} + + expand-brackets@2.1.4: + resolution: {integrity: sha512-w/ozOKR9Obk3qoWeY/WDi6MFta9AoMR+zud60mdnbniMcBxRuFJyDt2LdX/14A1UABeqk+Uk+LDfUpvoGKppZA==} + engines: {node: '>=0.10.0'} + + expand-range@1.8.2: + resolution: {integrity: sha512-AFASGfIlnIbkKPQwX1yHaDjFvh/1gyKJODme52V6IORh69uEYgZp0o9C+qsIGNVEiuuhQU0CSSl++Rlegg1qvA==} + engines: {node: '>=0.10.0'} + expand-template@2.0.3: resolution: {integrity: sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==} engines: {node: '>=6'} @@ -6924,6 +7322,10 @@ packages: resolution: {integrity: sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==} engines: {node: '>=0.10.0'} + extend-shallow@3.0.2: + resolution: {integrity: sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==} + engines: {node: '>=0.10.0'} + extend@3.0.2: resolution: {integrity: sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==} @@ -6931,6 +7333,14 @@ packages: resolution: {integrity: sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==} engines: {node: '>=4'} + extglob@0.3.2: + resolution: {integrity: sha512-1FOj1LOwn42TMrruOHGt18HemVnbwAmAak7krWk+wa93KXxGbK+2jpezm+ytJYDaBX0/SPLZFHKM7m+tKobWGg==} + engines: {node: '>=0.10.0'} + + extglob@2.0.4: + resolution: {integrity: sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==} + engines: {node: '>=0.10.0'} + extsprintf@1.3.0: resolution: {integrity: sha512-11Ndz7Nv+mvAC1j0ktTa7fAb0vLyGGX+rMHNBYQviQDGU0Hw7lhctJANqbPhu9nV9/izT/IntTgZ7Im/9LJs9g==} engines: {'0': node >=0.6.0} @@ -7023,10 +7433,22 @@ packages: filelist@1.0.4: resolution: {integrity: sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==} + filename-regex@2.0.1: + resolution: {integrity: sha512-BTCqyBaWBTsauvnHiE8i562+EdJj+oUpkqWp2R1iCoR8f6oo8STRu3of7WJJ0TqWtxN50a5YFpzYK4Jj9esYfQ==} + engines: {node: '>=0.10.0'} + filesize@10.1.6: resolution: {integrity: sha512-sJslQKU2uM33qH5nqewAwVB2QgR6w1aMNsYUp3aN5rMRyXEwJGmZvaWzeJFNTOXWlHQyBFCWrdj3fV/fsTOX8w==} engines: {node: '>= 10.4.0'} + fill-range@2.2.4: + resolution: {integrity: sha512-cnrcCbj01+j2gTG921VZPnHbjmdAf8oQV/iGeV2kZxGSyfYjjTyY79ErsK1WJWMpw6DaApEX72binqJE+/d+5Q==} + engines: {node: '>=0.10.0'} + + fill-range@4.0.0: + resolution: {integrity: sha512-VcpLTWqWDiTerugjj8e3+esbg+skS3M9e54UuR3iCeIDMXCLTsAH8hTSzDQU/X6/6t3eYkOKoZSef2PlU6U1XQ==} + engines: {node: '>=0.10.0'} + fill-range@7.1.1: resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==} engines: {node: '>=8'} @@ -7087,6 +7509,14 @@ packages: resolution: {integrity: sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg==} engines: {node: '>= 0.4'} + for-in@1.0.2: + resolution: {integrity: sha512-7EwmXrOjyL+ChxMhmG5lnW9MPt1aIeZEwKhQzoBUdTV0N3zuwWDZYVJatDvZ2OyzPUvdIAZDsCetk3coyMfcnQ==} + engines: {node: '>=0.10.0'} + + for-own@0.1.5: + resolution: {integrity: sha512-SKmowqGTJoPzLO1T0BBJpkfp3EMacCMOuH40hOUbrbzElVktk4DioXVM99QkLCyKoiuOmyjgcWMpVz2xjE7LZw==} + engines: {node: '>=0.10.0'} + foreground-child@3.3.1: resolution: {integrity: sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==} engines: {node: '>=14'} @@ -7127,6 +7557,10 @@ packages: fraction.js@4.3.7: resolution: {integrity: sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew==} + fragment-cache@0.2.1: + resolution: {integrity: sha512-GMBAbW9antB8iZRHLoGw0b3HANt57diZYFO/HL1JGIC1MjKrdmhxvrJbupnVvpys0zsz7yBApXdQyfepKly2kA==} + engines: {node: '>=0.10.0'} + fresh@0.5.2: resolution: {integrity: sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==} engines: {node: '>= 0.6'} @@ -7164,6 +7598,12 @@ packages: fs.realpath@1.0.0: resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} + fsevents@1.2.13: + resolution: {integrity: sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==} + engines: {node: '>= 4.0'} + os: [darwin] + deprecated: Upgrade to fsevents v2 to mitigate potential security issues + fsevents@2.3.3: resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} @@ -7240,6 +7680,10 @@ packages: resolution: {integrity: sha512-w9UMqWwJxHNOvoNzSJ2oPF5wvYcvP7jUvYzhp67yEhTi17ZDBBC1z9pTdGuzjD+EFIqLSYRweZjqfiPzQ06Ebg==} engines: {node: '>= 0.4'} + get-value@2.0.6: + resolution: {integrity: sha512-Ln0UQDlxH1BapMu3GPtf7CuYNwRZf2gwCuPqbyG6pB8WfmFpzqcy4xtAaAMUhnNqjMKTiCPZG2oMT3YSx8U2NA==} + engines: {node: '>=0.10.0'} + getpass@0.1.7: resolution: {integrity: sha512-0fzj9JxOLfJ+XGLhR8ze3unN0KZCgZwiSSDz168VERjK8Wl8kVSdcu2kspd4s4wtAa1y/qrVRiAA0WclVsu0ng==} @@ -7266,6 +7710,13 @@ packages: github-from-package@0.0.0: resolution: {integrity: sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==} + glob-base@0.3.0: + resolution: {integrity: sha512-ab1S1g1EbO7YzauaJLkgLp7DZVAqj9M/dvKlTt8DkXA2tiOIcSMrlVI2J1RZyB5iJVccEscjGn+kpOG9788MHA==} + engines: {node: '>=0.10.0'} + + glob-parent@2.0.0: + resolution: {integrity: sha512-JDYOvfxio/t42HKdxkAYaCiBN7oYiuxykOxKxdaUW5Qn0zaYN3gRQWolrwdnf0shM9/EP0ebuuTmyoXNr1cC5w==} + glob-parent@5.1.2: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} engines: {node: '>= 6'} @@ -7320,6 +7771,10 @@ packages: resolution: {integrity: sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==} engines: {node: '>=8'} + globals@9.18.0: + resolution: {integrity: sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ==} + engines: {node: '>=0.10.0'} + globalthis@1.0.4: resolution: {integrity: sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==} engines: {node: '>= 0.4'} @@ -7368,6 +7823,10 @@ packages: resolution: {integrity: sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==} engines: {node: '>=4.x'} + growl@1.10.5: + resolution: {integrity: sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==} + engines: {node: '>=4.x'} + gtoken@7.1.0: resolution: {integrity: sha512-pCcEwRi+TKpMlxAQObHDQ56KawURgyAf6jtIY046fJ5tIv3zDe/LEIubckAO8fj6JnAxLdmWkUfNyulQ2iKdEw==} engines: {node: '>=14.0.0'} @@ -7390,6 +7849,10 @@ packages: resolution: {integrity: sha512-VIZB+ibDhx7ObhAe7OVtoEbuP4h/MuOTHJ+J8h/eBXotJYl0fBgR72xDFCKgIh22OJZIOVNxBMWuhAr10r8HdA==} engines: {node: '>=6'} + has-ansi@2.0.0: + resolution: {integrity: sha512-C8vBJ8DwUCx19vhm7urhTuUsr4/IyP6l4VzNQDv+ryHQObW3TTTp9yB68WpYgRe2bbaGuZ/se74IqFeVnMnLZg==} + engines: {node: '>=0.10.0'} + has-bigints@1.1.0: resolution: {integrity: sha512-R3pbpkcIqv2Pm3dUwgjclDRVmWpTJW2DcMzcIhEXEx1oh/CEMObMm3KLmRJOdvhM7o4uQBnwr8pzRK2sJWIqfg==} engines: {node: '>= 0.4'} @@ -7424,10 +7887,30 @@ packages: has-unicode@2.0.1: resolution: {integrity: sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ==} + has-value@0.3.1: + resolution: {integrity: sha512-gpG936j8/MzaeID5Yif+577c17TxaDmhuyVgSwtnL/q8UUTySg8Mecb+8Cf1otgLoD7DDH75axp86ER7LFsf3Q==} + engines: {node: '>=0.10.0'} + + has-value@1.0.0: + resolution: {integrity: sha512-IBXk4GTsLYdQ7Rvt+GRBrFSVEkmuOUy4re0Xjd9kJSUQpnTrWR4/y9RpfexN9vkAPMFuQoeWKwqzPozRTlasGw==} + engines: {node: '>=0.10.0'} + + has-values@0.1.4: + resolution: {integrity: sha512-J8S0cEdWuQbqD9//tlZxiMuMNmxB8PlEwvYwuxsTmR1G5RXUePEX/SJn7aD0GMLieuZYSwNH0cQuJGwnYunXRQ==} + engines: {node: '>=0.10.0'} + + has-values@1.0.0: + resolution: {integrity: sha512-ODYZC64uqzmtfGMEAX/FvZiRyWLpAC3vYnNunURUnkGVTS+mI0smVsWaPydRBsE3g+ok7h960jChO8mFcWlHaQ==} + engines: {node: '>=0.10.0'} + has-yarn@2.1.0: resolution: {integrity: sha512-UqBRqi4ju7T+TqGNdqAO0PaSVGsDGJUBQvk9eUWNGRY1CFGDzYhLWoM7JQEemnlvVcv/YEmc2wNW8BC24EnUsw==} engines: {node: '>=8'} + hash-base@3.1.0: + resolution: {integrity: sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA==} + engines: {node: '>=4'} + hasown@2.0.2: resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==} engines: {node: '>= 0.4'} @@ -7457,6 +7940,10 @@ packages: resolution: {integrity: sha512-Xwwo44whKBVCYoliBQwaPvtd/2tYFkRQtXDWj1nackaV2JPXx3L0+Jvd8/qCJ2p+ML0/XVkJ2q+Mr+UVdpJK5w==} engines: {node: '>=12.0.0'} + home-or-tmp@2.0.0: + resolution: {integrity: sha512-ycURW7oUxE2sNiPVw1HVEFsW+ecOpJ5zaj7eC0RlwhibhRBod20muUN8qu/gzx956YrLolVvs1MTXwKgC2rVEg==} + engines: {node: '>=0.10.0'} + hookable@5.5.3: resolution: {integrity: sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ==} @@ -7664,6 +8151,9 @@ packages: resolution: {integrity: sha512-6xwYfHbajpoF0xLW+iwLkhwgvLoZDfjYfoFNu8ftMoXINzwuymNLd9u/KmwtdT2GbR+/Cz66otEGEVVUHX9QLQ==} engines: {node: '>=10.13.0'} + invariant@2.2.4: + resolution: {integrity: sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==} + ip-address@9.0.5: resolution: {integrity: sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g==} engines: {node: '>= 12'} @@ -7672,6 +8162,10 @@ packages: resolution: {integrity: sha512-1ANGLZ+Nkv1ptFb2pa8oG8Lem4krflKuX/gINiHJHjJUKaJHk/SXk5x6K3J+39/p0h1RQ2saROclJJ+QLvETCQ==} engines: {node: '>=8'} + is-accessor-descriptor@1.0.1: + resolution: {integrity: sha512-YBUanLI8Yoihw923YeFUS5fs0fF2f5TSFTNiYAAzhhDscDa3lEqYuz1pDOEP5KvX94I9ey3vsqjJcLVFVU+3QA==} + engines: {node: '>= 0.10'} + is-arguments@1.2.0: resolution: {integrity: sha512-7bVbi0huj/wrIAOzb8U1aszg9kdi3KN/CyU19CTI7tAoZYEZoL9yCDXpbXN+uPsuWnP02cyug1gleqq+TU+YCA==} engines: {node: '>= 0.4'} @@ -7691,6 +8185,10 @@ packages: resolution: {integrity: sha512-n4ZT37wG78iz03xPRKJrHTdZbe3IicyucEtdRsV5yglwc3GyUfbAfpSeD0FJ41NbUNSt5wbhqfp1fS+BgnvDFQ==} engines: {node: '>= 0.4'} + is-binary-path@1.0.1: + resolution: {integrity: sha512-9fRVlXc0uCxEDj1nQzaWONSpbTfx0FmJfzHF7pwlI8DkWGoHBBea4Pg5Ky0ojwwxQmnSifgbKkI06Qv0Ljgj+Q==} + engines: {node: '>=0.10.0'} + is-binary-path@2.1.0: resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==} engines: {node: '>=8'} @@ -7699,6 +8197,9 @@ packages: resolution: {integrity: sha512-wa56o2/ElJMYqjCjGkXri7it5FbebW5usLw/nPmCMs5DeZ7eziSYZhSmPRn0txqeW4LnAmQQU7FgqLpsEFKM4A==} engines: {node: '>= 0.4'} + is-buffer@1.1.6: + resolution: {integrity: sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==} + is-buffer@2.0.5: resolution: {integrity: sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ==} engines: {node: '>=4'} @@ -7722,6 +8223,10 @@ packages: resolution: {integrity: sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==} engines: {node: '>= 0.4'} + is-data-descriptor@1.0.1: + resolution: {integrity: sha512-bc4NlCDiCr28U4aEsQ3Qs2491gVq4V8G7MQyws968ImqjKuYtTJXrl7Vq7jsN7Ly/C3xj5KWFrY7sHNeDkAzXw==} + engines: {node: '>= 0.4'} + is-data-view@1.0.2: resolution: {integrity: sha512-RKtWF8pGmS87i2D6gqQu/l7EYRlVdfzemCJN/P3UOs//x1QE7mfhvzHIApBTRf7axvT6DMGwSwBXYCT0nfB9xw==} engines: {node: '>= 0.4'} @@ -7730,15 +8235,39 @@ packages: resolution: {integrity: sha512-PwwhEakHVKTdRNVOw+/Gyh0+MzlCl4R6qKvkhuvLtPMggI1WAHt9sOwZxQLSGpUaDnrdyDsomoRgNnCfKNSXXg==} engines: {node: '>= 0.4'} + is-descriptor@0.1.7: + resolution: {integrity: sha512-C3grZTvObeN1xud4cRWl366OMXZTj0+HGyk4hvfpx4ZHt1Pb60ANSXqCK7pdOTeUQpRzECBSTphqvD7U+l22Eg==} + engines: {node: '>= 0.4'} + + is-descriptor@1.0.3: + resolution: {integrity: sha512-JCNNGbwWZEVaSPtS45mdtrneRWJFp07LLmykxeFV5F6oBvNF8vHSfJuJgoT472pSfk+Mf8VnlrspaFBHWM8JAw==} + engines: {node: '>= 0.4'} + is-docker@2.2.1: resolution: {integrity: sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==} engines: {node: '>=8'} hasBin: true + is-dotfile@1.0.3: + resolution: {integrity: sha512-9YclgOGtN/f8zx0Pr4FQYMdibBiTaH3sn52vjYip4ZSf6C4/6RfTEZ+MR4GvKhCxdPh21Bg42/WL55f6KSnKpg==} + engines: {node: '>=0.10.0'} + + is-equal-shallow@0.1.3: + resolution: {integrity: sha512-0EygVC5qPvIyb+gSz7zdD5/AAoS6Qrx1e//6N4yv4oNm30kqvdmG66oZFWVlQHUWe5OjP08FuTw2IdT0EOTcYA==} + engines: {node: '>=0.10.0'} + is-extendable@0.1.1: resolution: {integrity: sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==} engines: {node: '>=0.10.0'} + is-extendable@1.0.1: + resolution: {integrity: sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==} + engines: {node: '>=0.10.0'} + + is-extglob@1.0.0: + resolution: {integrity: sha512-7Q+VbVafe6x2T+Tu6NcOf6sRklazEPmBoB3IWk3WdGZM2iGUwU/Oe3Wtq5lSEkDTTlpp8yx+5t4pzO/i9Ty1ww==} + engines: {node: '>=0.10.0'} + is-extglob@2.1.1: resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} engines: {node: '>=0.10.0'} @@ -7747,6 +8276,10 @@ packages: resolution: {integrity: sha512-1pC6N8qWJbWoPtEjgcL2xyhQOP491EQjeUo3qTKcmV8YSDDJrOepfG8pcC7h/QgnQHYSv0mJ3Z/ZWxmatVrysg==} engines: {node: '>= 0.4'} + is-finite@1.1.0: + resolution: {integrity: sha512-cdyMtqX/BOqqNBBiKlIVkytNHm49MtMlYyn1zxzvJKWmFMlGzm+ry5BBfYyeY9YmNKbRSo/o7OX9w9ale0wg3w==} + engines: {node: '>=0.10.0'} + is-fullwidth-code-point@3.0.0: resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} engines: {node: '>=8'} @@ -7755,6 +8288,10 @@ packages: resolution: {integrity: sha512-nPUB5km40q9e8UfN/Zc24eLlzdSf9OfKByBw9CIdw4H1giPMeA0OIJvbchsCu4npfI2QcMVBsGEBHKZ7wLTWmQ==} engines: {node: '>= 0.4'} + is-glob@2.0.1: + resolution: {integrity: sha512-a1dBeB19NXsf/E0+FHqkagizel/LQw2DjSQpvQrj3zT+jYPpaUCryPnrQajXKFLCMuf4I6FhRpaGtw4lPrG6Eg==} + engines: {node: '>=0.10.0'} + is-glob@4.0.3: resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} engines: {node: '>=0.10.0'} @@ -7788,6 +8325,18 @@ packages: resolution: {integrity: sha512-lZhclumE1G6VYD8VHe35wFaIif+CTy5SJIi5+3y4psDgWu4wPDoBhF8NxUOinEc7pHgiTsT6MaBb92rKhhD+Xw==} engines: {node: '>= 0.4'} + is-number@2.1.0: + resolution: {integrity: sha512-QUzH43Gfb9+5yckcrSA0VBDwEtDUchrk4F6tfJZQuNzDJbEDB9cZNzSfXGQ1jqmdDY/kl41lUOWM9syA8z8jlg==} + engines: {node: '>=0.10.0'} + + is-number@3.0.0: + resolution: {integrity: sha512-4cboCqIpliH+mAvFNegjZQ4kgKc3ZUhQVr3HvWbSh5q3WH2v82ct+T2Y1hdU5Gdtorx/cLifQjqCbL7bpznLTg==} + engines: {node: '>=0.10.0'} + + is-number@4.0.0: + resolution: {integrity: sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==} + engines: {node: '>=0.10.0'} + is-number@7.0.0: resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} engines: {node: '>=0.12.0'} @@ -7828,6 +8377,14 @@ packages: resolution: {integrity: sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==} engines: {node: '>=0.10.0'} + is-posix-bracket@0.1.1: + resolution: {integrity: sha512-Yu68oeXJ7LeWNmZ3Zov/xg/oDBnBK2RNxwYY1ilNJX+tKKZqgPK+qOn/Gs9jEu66KDY9Netf5XLKNGzas/vPfQ==} + engines: {node: '>=0.10.0'} + + is-primitive@2.0.0: + resolution: {integrity: sha512-N3w1tFaRfk3UrPfqeRyD+GYDASU3W5VinKhlORy8EWVf/sIdDL9GAcew85XmktCfH+ngG7SRXEVDoO18WMdB/Q==} + engines: {node: '>=0.10.0'} + is-reference@1.2.1: resolution: {integrity: sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==} @@ -7906,6 +8463,10 @@ packages: resolution: {integrity: sha512-ZhMwEosbFJkA0YhFnNDgTM4ZxDRsS6HqTo7qsZM08fehyRYIYa0yHu5R6mgo1n/8MgaPBXiPimPD77baVFYg+A==} engines: {node: '>=12.13'} + is-windows@1.0.2: + resolution: {integrity: sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==} + engines: {node: '>=0.10.0'} + is-wsl@2.2.0: resolution: {integrity: sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==} engines: {node: '>=8'} @@ -7929,6 +8490,10 @@ packages: resolution: {integrity: sha512-LpB/54B+/2J5hqQ7imZHfdU31OlgQqx7ZicVlkm9kzg9/w8GKLEcFfJl/t7DCEDueOyBAD6zCCwTO6Fzs0NoEQ==} engines: {node: '>=16'} + isobject@2.1.0: + resolution: {integrity: sha512-+OUdGJlgjOBZDfxnDjYYG6zp487z0JGNQq3cYQYg5f5hKR+syHMsaztzGeml/4kGG55CSpKSpWTY+jYGgsHLgA==} + engines: {node: '>=0.10.0'} + isobject@3.0.1: resolution: {integrity: sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==} engines: {node: '>=0.10.0'} @@ -7973,6 +8538,10 @@ packages: javascript-natural-sort@0.7.1: resolution: {integrity: sha512-nO6jcEfZWQXDhOiBtG2KvKyEptz7RVbpGP4vTD2hLBdmNQSsCiicO2Ioinv6UI4y9ukqnBpy+XZ9H6uLNgJTlw==} + jdcloud-sdk-js@1.2.202: + resolution: {integrity: sha512-uKGFPmkuwjfMm1hhctC3ssW3pruohTjv92ISyuQ21PaAI9cFRZfjAp+iwj7p486w8eBQR/F+7IZ04avcAZRjrg==} + engines: {node: '>= 8.6.0', npm: '>= 5.6.0'} + jest-diff@29.7.0: resolution: {integrity: sha512-LMIgiIrhigmPrs03JHpxUh2yISK3vLFPkAodPeo0+BuF7wA2FoQbkEg1u8gBYBThncu7e1oEDUfIXVuTqLRUjw==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} @@ -8034,6 +8603,9 @@ packages: js-sdsl@4.3.0: resolution: {integrity: sha512-mifzlm2+5nZ+lEcLJMoBK0/IH/bDg8XnJfd/Wq6IP+xoCjLZsTOnV2QpxlVbX9bMnkl5PdEjNtBJ9Cj1NjifhQ==} + js-tokens@3.0.2: + resolution: {integrity: sha512-RjTcuD4xjtthQkaWH7dFlH85L+QaVtSoOyGdZ3g6HFhS9dFNDfLyqgm2NFe2X6cQpeFmt0452FJjFG5UameExg==} + js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} @@ -8078,6 +8650,14 @@ packages: jsencrypt@3.3.2: resolution: {integrity: sha512-arQR1R1ESGdAxY7ZheWr12wCaF2yF47v5qpB76TtV64H1pyGudk9Hvw8Y9tb/FiTIaaTRUyaSnm5T/Y53Ghm/A==} + jsesc@0.5.0: + resolution: {integrity: sha512-uZz5UnB7u4T9LvwmFqXii7pZSouaRPorGs5who1Ip7VO0wxanFvBL7GkM6dTHlgX+jhBApRetaWpnDabOeTcnA==} + hasBin: true + + jsesc@1.3.0: + resolution: {integrity: sha512-Mke0DA0QjUWuJlhsE0ZPPhYiJkRap642SmI/4ztCFaUs6V2AiH1sfecc+57NgaryfAA2VR3v6O+CSjC1jZJKOA==} + hasBin: true + jsesc@3.0.2: resolution: {integrity: sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g==} engines: {node: '>=6'} @@ -8131,6 +8711,10 @@ packages: json-stringify-safe@5.0.1: resolution: {integrity: sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==} + json5@0.5.1: + resolution: {integrity: sha512-4xrs1aW+6N5DalkqSVA8fxh458CXvR99WU8WLKmq4v8eWAL86Xo3BVqyd3SkA9wEVjCMqyvvRRkshAdOnBp5rw==} + hasBin: true + json5@1.0.2: resolution: {integrity: sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==} hasBin: true @@ -8211,6 +8795,14 @@ packages: keyv@5.3.1: resolution: {integrity: sha512-13hQT2q2VIwOoaJdJa7nY3J8UVbYtMTJFHnwm9LI+SaQRfUiM6Em9KZeOVTCKbMnGcRIL3NSUFpAdjZCq24nLQ==} + kind-of@3.2.2: + resolution: {integrity: sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==} + engines: {node: '>=0.10.0'} + + kind-of@4.0.0: + resolution: {integrity: sha512-24XsCxmEbRwEDbz/qz3stgin8TTzZ1ESR56OMCN0ujYg+vRutNSiOj9bHH9u85DKgXguraugV5sFuvbD4FW/hw==} + engines: {node: '>=0.10.0'} + kind-of@6.0.3: resolution: {integrity: sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==} engines: {node: '>=0.10.0'} @@ -8519,6 +9111,10 @@ packages: resolution: {integrity: sha512-cKTUFc/rbKUd/9meOvgrpJ2WrNzymt6jfRDdwg5UCnVzv9dTpEj9JS5m3wtziXVCjluIXyL8pcaukYqezIzZQA==} engines: {node: ^16.14.0 || >=18.0.0} + map-cache@0.2.2: + resolution: {integrity: sha512-8y/eV9QQZCiyn1SprXSrCmqJN0yNRATe+PO8ztwqrvrbdRLA3eYJF0yaR0YayLWkMbsQSKWS9N2gPcGEc4UsZg==} + engines: {node: '>=0.10.0'} + map-obj@1.0.1: resolution: {integrity: sha512-7N/q3lyZ+LVCp7PzuxrJr4KMbBE2hW7BT7YNia330OFxIf4d3r5zVpicP2650l7CPN6RM9zOJRl3NGpqSiw3Eg==} engines: {node: '>=0.10.0'} @@ -8527,6 +9123,10 @@ packages: resolution: {integrity: sha512-hdN1wVrZbb29eBGiGjJbeP8JbKjq1urkHJ/LIP/NY48MZ1QVXUsQBV1G1zvYFHn1XE06cwjBsOI2K3Ulnj1YXQ==} engines: {node: '>=8'} + map-visit@1.0.0: + resolution: {integrity: sha512-4y7uGv8bd2WdM9vpQsiQNo41Ln1NvhvDRuVt0k2JZQ+ezN2uaQes7lZeZ+QQUHOLQAtDaBJ+7wCbi+ab/KFs+w==} + engines: {node: '>=0.10.0'} + mark.js@8.11.1: resolution: {integrity: sha512-1I+1qpDt4idfgLQG+BNWmrqku+7/2bi5nLf4YwF8y8zXvmfiTBY3PV3ZibfrjBueCByROpuBjLLFCajqkgYoLQ==} @@ -8549,9 +9149,15 @@ packages: resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==} engines: {node: '>= 0.4'} + math-random@1.0.4: + resolution: {integrity: sha512-rUxjysqif/BZQH2yhd5Aaq7vXMSx9NdEsQcyA07uEzIvxgI7zIr33gGsh+RU0/XjmQpCW7RsVof1vlkvQVCK5A==} + mathml-tag-names@2.1.3: resolution: {integrity: sha512-APMBEanjybaPzUrfqU0IMU5I0AswKMH7k8OTLs0vvV4KZpExkTkY87nR/zpbuTPj+gARop7aGUbl11pnDfW6xg==} + md5.js@1.3.5: + resolution: {integrity: sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==} + mdast-util-to-hast@13.2.0: resolution: {integrity: sha512-QGYKEuUsYT9ykKBCMOEDLsU5JRObWQusAolFMeko/tYPufNkRffBAQjIE+99jbA87xv6FgmjLtwjh9wBWajwAA==} @@ -8620,6 +9226,14 @@ packages: micromark-util-types@2.0.2: resolution: {integrity: sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==} + micromatch@2.3.11: + resolution: {integrity: sha512-LnU2XFEk9xxSJ6rfgAry/ty5qwUTyHYOBU0g4R6tIw5ljwgGIBmiKhRWLw5NpMOnrgUNcDJ4WMp8rl3sYVHLNA==} + engines: {node: '>=0.10.0'} + + micromatch@3.1.10: + resolution: {integrity: sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==} + engines: {node: '>=0.10.0'} + micromatch@4.0.8: resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==} engines: {node: '>=8.6'} @@ -8681,6 +9295,9 @@ packages: resolution: {integrity: sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==} engines: {node: 20 || >=22} + minimatch@3.0.4: + resolution: {integrity: sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==} + minimatch@3.1.2: resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} @@ -8752,6 +9369,10 @@ packages: mitt@3.0.1: resolution: {integrity: sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==} + mixin-deep@1.3.2: + resolution: {integrity: sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==} + engines: {node: '>=0.10.0'} + mkdirp-classic@0.5.3: resolution: {integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==} @@ -8793,6 +9414,11 @@ packages: engines: {node: '>= 4.0.0'} hasBin: true + mocha@5.2.0: + resolution: {integrity: sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==} + engines: {node: '>= 4.0.0'} + hasBin: true + mockdate@3.0.5: resolution: {integrity: sha512-iniQP4rj1FhBdBYS/+eQv7j1tadJ9lJtdzgOpvsOHng/GbcDh2Fhdeq+ZRldrPYdXvCyfFUmFeEwEGXZB5I/AQ==} @@ -8885,6 +9511,10 @@ packages: engines: {node: ^18 || >=20} hasBin: true + nanomatch@1.2.13: + resolution: {integrity: sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==} + engines: {node: '>=0.10.0'} + nanopop@2.4.2: resolution: {integrity: sha512-NzOgmMQ+elxxHeIha+OG/Pv3Oc3p4RU2aBhwWwAqDpXrdTbtRylbRLQztLy8dMMwfl6pclznBdfUhccEn9ZIzw==} @@ -8924,6 +9554,9 @@ packages: next-tick@1.1.0: resolution: {integrity: sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==} + nice-try@1.0.5: + resolution: {integrity: sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==} + no-case@3.0.4: resolution: {integrity: sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==} @@ -8997,6 +9630,10 @@ packages: resolution: {integrity: sha512-V6gygoYb/5EmNI+MEGrWkC+e6+Rr7mTmfHrxDbLzxQogBkgzo76rkok0Am6thgSF7Mv2nLOajAJj5vDJZEFn7g==} engines: {node: ^16.14.0 || >=18.0.0} + normalize-path@2.1.1: + resolution: {integrity: sha512-3pKJwH184Xo/lnH6oyP1q2pMd7HcypqqmRs91/6/i2CGtWwIKGCkOOMTm/zXbgTEWHw1uNpNi/igc3ePOYHb6w==} + engines: {node: '>=0.10.0'} + normalize-path@3.0.0: resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} engines: {node: '>=0.10.0'} @@ -9066,6 +9703,10 @@ packages: resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==} engines: {node: '>=0.10.0'} + object-copy@0.1.0: + resolution: {integrity: sha512-79LYn6VAb63zgtmAteVOWo9Vdj71ZVBy3Pbse+VqxDpEP83XuujMrGqHIwAXJ5I/aM0zU7dIyIAhifVTPrNItQ==} + engines: {node: '>=0.10.0'} + object-get@2.1.1: resolution: {integrity: sha512-7n4IpLMzGGcLEMiQKsNR7vCe+N5E9LORFrtNUVy4sO3dj9a3HedZCxEL2T7QuLhcHN1NBuBsMOKaOsAYI9IIvg==} @@ -9093,6 +9734,10 @@ packages: resolution: {integrity: sha512-6FuKFQ39cOID+BMZ3QaphcC8Y4cw6LXBLyIgPU+OhIYwviJamPAn+4mITapnSBQrejB+NNp+FMskhD8Cq+Ys3w==} engines: {node: '>=8.0.0'} + object-visit@1.0.1: + resolution: {integrity: sha512-GBaMwwAVK9qbQN3Scdo0OyvgPW7l3lnaVMj84uTOZlswkX0KpF6fyDBJhtTthf7pymztoN36/KEr1DyhF96zEA==} + engines: {node: '>=0.10.0'} + object.assign@4.1.7: resolution: {integrity: sha512-nK28WOo+QIjBkDduTINE4JkF/UJJKyf2EJxvJKfblDpyg0Q+pkOHNTL0Qwy6NP6FhE/EnzV73BxxqcJaXY9anw==} engines: {node: '>= 0.4'} @@ -9105,6 +9750,14 @@ packages: resolution: {integrity: sha512-+Lhy3TQTuzXI5hevh8sBGqbmurHbbIjAi0Z4S63nthVLmLxfbj4T54a4CfZrXIrt9iP4mVAPYMo/v99taj3wjQ==} engines: {node: '>= 0.4'} + object.omit@2.0.1: + resolution: {integrity: sha512-UiAM5mhmIuKLsOvrL+B0U2d1hXHF3bFYWIuH1LMpuV2EJEHG1Ntz06PgLEHjm6VFd87NpH8rastvPoyv6UW2fA==} + engines: {node: '>=0.10.0'} + + object.pick@1.3.0: + resolution: {integrity: sha512-tqa/UMy/CCoYmj+H5qc07qvSL9dqcs/WZENZ1JbtWBlATP+iVOe778gE6MSijnyCnORzDuX6hU+LA4SZ09YjFQ==} + engines: {node: '>=0.10.0'} + object.values@1.2.1: resolution: {integrity: sha512-gXah6aZrcUxjWg2zR2MwouP2eHlCBzdV4pygudehaKXSGW4v2AsRQUK+lwwXhii6KFZcunEnmSUoYp5CXibxtA==} engines: {node: '>= 0.4'} @@ -9159,6 +9812,10 @@ packages: resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==} engines: {node: '>= 0.8.0'} + os-homedir@1.0.2: + resolution: {integrity: sha512-B5JU3cabzk8c67mRRd3ECmROafjYMXbuzlwtqdM8IbS8ktlTix8aFGb2bAGKrSRIlnfKwovGUUr72JUPyOb6kQ==} + engines: {node: '>=0.10.0'} + os-name@1.0.3: resolution: {integrity: sha512-f5estLO2KN8vgtTRaILIgEGBoBrMnZ3JQ7W9TMZCnOIGwHe8TRGSpcagnWDo+Dfhd/z08k9Xe75hvciJJ8Qaew==} engines: {node: '>=0.10.0'} @@ -9173,6 +9830,9 @@ packages: engines: {node: '>=0.10.0'} hasBin: true + output-file-sync@1.1.2: + resolution: {integrity: sha512-uQLlclru4xpCi+tfs80l3QF24KL81X57ELNMy7W/dox+JTtxUf1bLyQ8968fFCmSqqbokjW0kn+WBIlO+rSkNg==} + own-keys@1.0.1: resolution: {integrity: sha512-qFOyK5PjiWZd+QQIh+1jhdb9LpxTF0qs7Pm8o5QHYZ0M3vKqSqzsZaEB6oWlxZ+q2sJBMI/Ktgd2N5ZwQoRHfg==} engines: {node: '>= 0.4'} @@ -9282,6 +9942,10 @@ packages: resolution: {integrity: sha512-01TvEktc68vwbJOtWZluyWeVGWjP+bZwXtPDMQVbBKzbJ/vZBif0L69KH1+cHv1SZ6e0FKLvjyHe8mqsIqYOmw==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + parse-glob@3.0.4: + resolution: {integrity: sha512-FC5TeK0AwXzq3tUBFtH74naWkPQCEWs4K+xMxWZBlKDWu0bVHXGZa+KKqxKidd7xwhdZ19ZNuF2uO1M/r196HA==} + engines: {node: '>=0.10.0'} + parse-json@5.2.0: resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} engines: {node: '>=8'} @@ -9312,6 +9976,10 @@ packages: pascal-case@3.1.2: resolution: {integrity: sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==} + pascalcase@0.1.1: + resolution: {integrity: sha512-XHXfu/yOQRy9vYOtUDVMN60OEJjW013GoObG1o+xwQTpB9eYJX/BjXMsdW13ZDPruFhYYn0AG22w0xgQMwl3Nw==} + engines: {node: '>=0.10.0'} + path-browserify@1.0.1: resolution: {integrity: sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==} @@ -9331,6 +9999,10 @@ packages: resolution: {integrity: sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==} engines: {node: '>=0.10.0'} + path-key@2.0.1: + resolution: {integrity: sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw==} + engines: {node: '>=4'} + path-key@3.1.1: resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} engines: {node: '>=8'} @@ -9510,6 +10182,10 @@ packages: resolution: {integrity: sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw==} engines: {node: '>=10.13.0'} + posix-character-classes@0.1.1: + resolution: {integrity: sha512-xTgYBc3fuo7Yt7JbiuFxSYGToMoz8fLoE6TC9Wx1P/u+LfeThMOAqmuyECnlBaaJb+u1m9hHiXUEtwW4OzfUJg==} + engines: {node: '>=0.10.0'} + possible-typed-array-names@1.1.0: resolution: {integrity: sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==} engines: {node: '>= 0.4'} @@ -9941,6 +10617,10 @@ packages: resolution: {integrity: sha512-ravE6m9Atw9Z/jjttRUZ+clIXogdghyZAuWJ3qEzjT+jI/dL1ifAqhZeC5VHzQp1MSt1+jxKkFNemj/iO7tVUA==} engines: {node: '>=4'} + preserve@0.2.0: + resolution: {integrity: sha512-s/46sYeylUfHNjI+sA/78FAHlmIuKqI9wNnzEOGehAlUUYeObv5C2mOinXBjyUyWmJ2SfcS2/ydApH4hTF4WXQ==} + engines: {node: '>=0.10.0'} + prettier-linter-helpers@1.0.0: resolution: {integrity: sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==} engines: {node: '>=6.0.0'} @@ -9970,6 +10650,10 @@ packages: resolution: {integrity: sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q==} engines: {node: '>=6'} + private@0.1.8: + resolution: {integrity: sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==} + engines: {node: '>= 0.6'} + proc-log@4.2.0: resolution: {integrity: sha512-g8+OnU/L2v+wyiVK+D5fA34J7EH8jZ8DDlvwhRCMxmMj7UCBvxiO1mGeN+36JXIKF4zevU4kRBd8lVgG9vLelA==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} @@ -10052,6 +10736,9 @@ packages: resolution: {integrity: sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==} engines: {node: '>=6'} + punycode@1.4.1: + resolution: {integrity: sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ==} + punycode@2.3.1: resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} engines: {node: '>=6'} @@ -10136,6 +10823,10 @@ packages: ramda@0.27.2: resolution: {integrity: sha512-SbiLPU40JuJniHexQSAgad32hfwd+DRUdwF2PlVuI5RZD0/vahUco7R8vD86J/tcEKKF9vZrUVwgtmGCqlCKyA==} + randomatic@3.1.1: + resolution: {integrity: sha512-TuDE5KxZ0J461RVjrJZCJc+J+zCkTb1MbH9AQUq68sMhOMcy9jLcb3BrZKgp9q9Ncltdg4QVqWrH02W2EFFVYw==} + engines: {node: '>= 0.10.0'} + randombytes@2.1.0: resolution: {integrity: sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==} @@ -10213,6 +10904,10 @@ packages: resolution: {integrity: sha512-9nX56alTf5bwXQ3ZDipHJhusu9NTQJ/CVPtb/XHAJCXihZeitfJvIRS4GqQ/mfIoOE3IelHMrpayVrosdHBuLw==} engines: {node: '>=8'} + readdirp@2.2.1: + resolution: {integrity: sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==} + engines: {node: '>=0.10'} + readdirp@3.6.0: resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==} engines: {node: '>=8.10.0'} @@ -10270,12 +10965,29 @@ packages: regenerate@1.4.2: resolution: {integrity: sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A==} + regenerator-runtime@0.10.5: + resolution: {integrity: sha512-02YopEIhAgiBHWeoTiA8aitHDt8z6w+rQqNuIftlM+ZtvSl/brTouaU7DW6GO/cHtvxJvS4Hwv2ibKdxIRi24w==} + + regenerator-runtime@0.11.1: + resolution: {integrity: sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==} + regenerator-runtime@0.14.1: resolution: {integrity: sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==} + regenerator-transform@0.10.1: + resolution: {integrity: sha512-PJepbvDbuK1xgIgnau7Y90cwaAmO/LCLMI2mPvaXq2heGMR3aWW5/BQvYrhJ8jgmQjXewXvBjzfqKcVOmhjZ6Q==} + regenerator-transform@0.15.2: resolution: {integrity: sha512-hfMp2BoF0qOk3uc5V20ALGDS2ddjQaLrdl7xrGXvAIow7qeWRM2VA2HuCHkUKk9slq3VwEwLNK3DFBqDfPGYtg==} + regex-cache@0.4.4: + resolution: {integrity: sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==} + engines: {node: '>=0.10.0'} + + regex-not@1.0.2: + resolution: {integrity: sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==} + engines: {node: '>=0.10.0'} + regex-recursion@6.0.2: resolution: {integrity: sha512-0YCaSCq2VRIebiaUviZNs0cBz1kg5kVS2UKUfNIx8YVs1cN3AV7NTctO5FOKBA+UT2BPJIWZauYHPqJODG50cg==} @@ -10297,6 +11009,9 @@ packages: resolution: {integrity: sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==} engines: {node: '>=8'} + regexpu-core@2.0.0: + resolution: {integrity: sha512-tJ9+S4oKjxY8IZ9jmjnp/mtytu1u3iyIQAfmI51IKWH6bFf7XR1ybtaO6j7INhZKXOTYADk7V5qxaqLkmNxiZQ==} + regexpu-core@6.2.0: resolution: {integrity: sha512-H66BPQMrv+V16t8xtmq+UC0CBpiTBA60V8ibS1QVReIp8T1z8hwFxqcGzm9K6lgsN7sB5edVH8a+ze6Fqm4weA==} engines: {node: '>=4'} @@ -10309,9 +11024,16 @@ packages: resolution: {integrity: sha512-8acYXXTI0AkQv6RAOjE3vOaIXZkT9wo4LOFbBKYQEEnnMNBpKqdUrI6S4NT0KPIo/WVvJ5tE/X5LF/TQUf0ekw==} engines: {node: '>=8'} + regjsgen@0.2.0: + resolution: {integrity: sha512-x+Y3yA24uF68m5GA+tBjbGYo64xXVJpbToBaWCoSNSc1hdk6dfctaRWrNFTVJZIIhL5GxW8zwjoixbnifnK59g==} + regjsgen@0.8.0: resolution: {integrity: sha512-RvwtGe3d7LvWiDQXeQw8p5asZUmfU1G/l6WbUXeHta7Y2PEIvBTwH6E2EfmYUK8pxcxEdEmaomqyp0vZZ7C+3Q==} + regjsparser@0.1.5: + resolution: {integrity: sha512-jlQ9gYLfk2p3V5Ag5fYhA7fv7OHzd1KUH0PRP46xc3TgwjwgROIW572AfYg/X9kaNq/LJnu6oJcFRXlIrGoTRw==} + hasBin: true + regjsparser@0.12.0: resolution: {integrity: sha512-cnE+y8bz4NhMjISKbgeVJtqNbtf5QpjZP+Bslo+UqkIt9QPnX9q095eiRRASJG1/tz6dlNr6Z5NsBiWYokp6EQ==} hasBin: true @@ -10323,6 +11045,21 @@ packages: resolution: {integrity: sha512-G08Dxvm4iDN3MLM0EsP62EDV9IuhXPR6blNz6Utcp7zyV3tr4HVNINt6MpaRWbxoOHT3Q7YN2P+jaHX8vUbgog==} engines: {node: '>= 0.10'} + remove-trailing-separator@1.1.0: + resolution: {integrity: sha512-/hS+Y0u3aOfIETiaiirUFwDBDzmXPvO+jAfKTitUngIPzdKc6Z0LoFjM/CK5PL4C+eKwHohlHAb6H0VFfmmUsw==} + + repeat-element@1.1.4: + resolution: {integrity: sha512-LFiNfRcSu7KK3evMyYOuCzv3L10TW7yC1G2/+StMjK8Y6Vqd2MG7r/Qjw4ghtuCOjFvlnms/iMmLqpvW/ES/WQ==} + engines: {node: '>=0.10.0'} + + repeat-string@1.6.1: + resolution: {integrity: sha512-PV0dzCYDNfRi1jCDbJzpW7jNNDRuCOG/jI5ctQcGKt/clZD+YcPS3yIlWuTJMmESC8aevCFmWJy5wjAFgNqN6w==} + engines: {node: '>=0.10'} + + repeating@2.0.1: + resolution: {integrity: sha512-ZqtSMuVybkISo2OWvqvm7iHSWngvdaW3IpsT9/uP8v4gMi591LY6h35wdOfvQdWCKFWZWm2Y1Opp4kV7vQKT6A==} + engines: {node: '>=0.10.0'} + request@2.88.2: resolution: {integrity: sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==} engines: {node: '>= 6'} @@ -10361,6 +11098,10 @@ packages: resolution: {integrity: sha512-i1xevIst/Qa+nA9olDxLWnLk8YZbi8R/7JPbCMcgyWaFR6bKWaexgJgEB5oc2PKMjYdrHynyz0NY+if+H98t1w==} engines: {node: '>= 0.8'} + resolve-url@0.2.1: + resolution: {integrity: sha512-ZuF55hVUQaaczgOIwqWzkEcEidmlD/xl44x1UZnhOXcYuFN2S6+rcxpG+C1N3So0wvNI3DmJICUFfu2SxhBmvg==} + deprecated: https://github.com/lydell/resolve-url#deprecated + resolve@1.22.10: resolution: {integrity: sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==} engines: {node: '>= 0.4'} @@ -10373,6 +11114,10 @@ packages: resolution: {integrity: sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==} engines: {node: '>=8'} + ret@0.1.15: + resolution: {integrity: sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==} + engines: {node: '>=0.12'} + retry-request@7.0.2: resolution: {integrity: sha512-dUOvLMJ0/JJYEn8NrpOaGNE7X3vpI5XlZS/u0ANjqtcZVKnIxP7IgCFwrKTxENw29emmwug53awKtaMm4i9g5w==} engines: {node: '>=14'} @@ -10400,6 +11145,9 @@ packages: resolution: {integrity: sha512-l0OE8wL34P4nJH/H2ffoaniAokM2qSmrtXHmlpvYr5AVVX8msAyW0l8NVJFDxlSK4u3Uh/f41cQheDVdnYijwQ==} hasBin: true + ripemd160@2.0.2: + resolution: {integrity: sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==} + rollup-plugin-visualizer@5.14.0: resolution: {integrity: sha512-VlDXneTDaKsHIw8yzJAFWtrzguoJ/LnQ+lMpoVfYJ3jJF4Ihe5oYLAqLklIK/35lgUY+1yEzCkHyZ1j4A5w5fA==} engines: {node: '>=18'} @@ -10452,6 +11200,9 @@ packages: resolution: {integrity: sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw==} engines: {node: '>= 0.4'} + safe-regex@1.1.0: + resolution: {integrity: sha512-aJXcif4xnaNUzvUuC5gcb46oTS7zvg4jpMTnuqtrEPlR3vFr4pxtdTwaF1Qs3Enjn9HK+ZlwQui+a7z0SywIzg==} + safe-regex@2.1.1: resolution: {integrity: sha512-rx+x8AMzKb5Q5lQ95Zoi6ZbJqwCLkqi3XuJXp5P3rT8OEc6sZCJG5AE5dU3lsgRr/F4Bs31jSlVN+j5KrsGu9A==} @@ -10518,6 +11269,10 @@ packages: resolution: {integrity: sha512-RJRdvCo6IAnPdsvP/7m6bsQqNnn1FCBX5ZNtFL98MmFF/4xAIJTIg1YbHW5DC2W5SKZanrC6i4HsJqlajw/dZw==} engines: {node: '>= 0.4'} + set-value@2.0.1: + resolution: {integrity: sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==} + engines: {node: '>=0.10.0'} + setimmediate@1.0.5: resolution: {integrity: sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==} @@ -10538,10 +11293,18 @@ packages: shallow-equal@1.2.1: resolution: {integrity: sha512-S4vJDjHHMBaiZuT9NPb616CSmLf618jawtv3sufLl6ivK8WocjAo58cXwbRV1cgqxH0Qbv+iUt6m05eqEa2IRA==} + shebang-command@1.2.0: + resolution: {integrity: sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==} + engines: {node: '>=0.10.0'} + shebang-command@2.0.0: resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} engines: {node: '>=8'} + shebang-regex@1.0.0: + resolution: {integrity: sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ==} + engines: {node: '>=0.10.0'} + shebang-regex@3.0.0: resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} engines: {node: '>=8'} @@ -10614,6 +11377,10 @@ packages: sisteransi@1.0.5: resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} + slash@1.0.0: + resolution: {integrity: sha512-3TYDR7xWt4dIqV2JauJr+EJeW356RXijHeUlO+8djJ+uBXPn8/2dpzBc8yQhh583sVvc9CvFAeQVgijsH+PNNg==} + engines: {node: '>=0.10.0'} + slash@3.0.0: resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} engines: {node: '>=8'} @@ -10655,6 +11422,18 @@ packages: resolution: {integrity: sha512-Sj51kE1zC7zh6TDlNNz0/Jn1n5HiHdoQErxO8jLtnyrkJW/M5PrI7x05uDgY3BO7OUQYKCvmeMurW6BPUdwEOw==} engines: {node: '>=18'} + snapdragon-node@2.1.1: + resolution: {integrity: sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==} + engines: {node: '>=0.10.0'} + + snapdragon-util@3.0.1: + resolution: {integrity: sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==} + engines: {node: '>=0.10.0'} + + snapdragon@0.8.2: + resolution: {integrity: sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==} + engines: {node: '>=0.10.0'} + socks-proxy-agent@8.0.5: resolution: {integrity: sha512-HehCEsotFqbPW9sJ8WVYB6UbmIMv7kUUORIF2Nncq4VQvBfNBLibW9YZR5dlYCSUhwcD628pRllm7n+E+YTzJw==} engines: {node: '>= 14'} @@ -10686,9 +11465,24 @@ packages: resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==} engines: {node: '>=0.10.0'} + source-map-resolve@0.5.3: + resolution: {integrity: sha512-Htz+RnsXWk5+P2slx5Jh3Q66vhQj1Cllm0zvnaY98+NFx+Dv2CF/f5O/t8x+KaNdrdIAsruNzoh/KpialbqAnw==} + deprecated: See https://github.com/lydell/source-map-resolve#deprecated + + source-map-support@0.4.18: + resolution: {integrity: sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA==} + source-map-support@0.5.21: resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} + source-map-url@0.4.1: + resolution: {integrity: sha512-cPiFOTLUKvJFIg4SKVScy4ilPPW6rFgMgfuZJPNoDuMs3nC1HbMUycBoJw77xFIp6z1UJQJOfx6C9GMH80DiTw==} + deprecated: See https://github.com/lydell/source-map-url#deprecated + + source-map@0.5.7: + resolution: {integrity: sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==} + engines: {node: '>=0.10.0'} + source-map@0.6.1: resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} engines: {node: '>=0.10.0'} @@ -10719,6 +11513,10 @@ packages: resolution: {integrity: sha512-1POYv7uv2gXoyGFpBCmpDVSNV74IfsWlDW216UPjbWufNf+bSU6GdbDsxdcxtfwb4xlI3yxzOTKClUosxARYrQ==} engines: {node: '>=0.10.0'} + split-string@3.1.0: + resolution: {integrity: sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==} + engines: {node: '>=0.10.0'} + split2@3.2.2: resolution: {integrity: sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg==} @@ -10775,6 +11573,10 @@ packages: stackback@0.0.2: resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==} + static-extend@0.1.2: + resolution: {integrity: sha512-72E9+uLc27Mt718pMHt9VMNiAL4LMsmDbBva8mxWUCkT07fSzEGMYUCk0XWY6lp0j6RBAG4cJ3mWuZv2OE3s0g==} + engines: {node: '>=0.10.0'} + statuses@1.5.0: resolution: {integrity: sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==} engines: {node: '>= 0.6'} @@ -10855,6 +11657,10 @@ packages: stringify-entities@4.0.4: resolution: {integrity: sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg==} + strip-ansi@3.0.1: + resolution: {integrity: sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==} + engines: {node: '>=0.10.0'} + strip-ansi@6.0.1: resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} engines: {node: '>=8'} @@ -10957,10 +11763,18 @@ packages: resolution: {integrity: sha512-EMCG6G8gDu5qEqRQ3JjjPs6+FYT1a7Hv5ApHvtSghmOFJYtsU5S+pSb6Y2EUeCEY3CmEL3mmQ8YWlPOzQomabA==} engines: {node: '>=6.4.0'} + supports-color@2.0.0: + resolution: {integrity: sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==} + engines: {node: '>=0.8.0'} + supports-color@4.4.0: resolution: {integrity: sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==} engines: {node: '>=4'} + supports-color@5.4.0: + resolution: {integrity: sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==} + engines: {node: '>=4'} + supports-color@5.5.0: resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==} engines: {node: '>=4'} @@ -11153,14 +11967,30 @@ packages: to-arraybuffer@1.0.1: resolution: {integrity: sha512-okFlQcoGTi4LQBG/PgSYblw9VOyptsz2KJZqc6qtgGdes8VktzUQkj4BI2blit072iS8VODNcMA+tvnS9dnuMA==} + to-fast-properties@1.0.3: + resolution: {integrity: sha512-lxrWP8ejsq+7E3nNjwYmUBMAgjMTZoTI+sdBOpvNyijeDLa29LUn9QaoXAHv4+Z578hbmHHJKZknzxVtvo77og==} + engines: {node: '>=0.10.0'} + + to-object-path@0.3.0: + resolution: {integrity: sha512-9mWHdnGRuh3onocaHzukyvCZhzvr6tiflAy/JRFXcJX0TjgfWA9pk9t8CMbzmBE4Jfw58pXbkngtBtqYxzNEyg==} + engines: {node: '>=0.10.0'} + to-readable-stream@1.0.0: resolution: {integrity: sha512-Iq25XBt6zD5npPhlLVXGFN3/gyR2/qODcKNNyTMd4vbm39HUaOiAM4PMq0eMVC/Tkxz+Zjdsc55g9yyz+Yq00Q==} engines: {node: '>=6'} + to-regex-range@2.1.1: + resolution: {integrity: sha512-ZZWNfCjUokXXDGXFpZehJIkZqq91BcULFq/Pi7M5i4JnxXdhMKAK682z8bCW3o8Hj1wuuzoKcW3DfVzaP6VuNg==} + engines: {node: '>=0.10.0'} + to-regex-range@5.0.1: resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} engines: {node: '>=8.0'} + to-regex@3.0.2: + resolution: {integrity: sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==} + engines: {node: '>=0.10.0'} + toidentifier@1.0.1: resolution: {integrity: sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==} engines: {node: '>=0.6'} @@ -11191,6 +12021,10 @@ packages: resolution: {integrity: sha512-jRKj0n0jXWo6kh62nA5TEh3+4igKDXLvzBJcPpiizP7oOolUrYIxmVBG9TOtHYFHoddUk6YvAkGeGoSVTXfQXQ==} engines: {node: '>=12'} + trim-right@1.0.1: + resolution: {integrity: sha512-WZGXGstmCWgeevgTL54hrCuw1dyMQIzWy7ZfqRJfSmJZBwklI15egmQytFP6bPidmw3M8d5yEowl1niq4vmqZw==} + engines: {node: '>=0.10.0'} + ts-api-utils@1.4.3: resolution: {integrity: sha512-i3eMG77UTMD0hZhgRS562pv83RC6ukSAC2GMNWc+9dieh/+jDM5u5YG+NHX6VNDRHQcHwmsTHctP9LhbC3WxVw==} engines: {node: '>=16'} @@ -11511,6 +12345,10 @@ packages: resolution: {integrity: sha512-oVUL7PSlyVV3QRhsdcyYEMaDX8HJyS/CnUonEJTYA3//bWO+o/4gG8F7auGWWWkrrxBQBYOO8DKe+C53ktpRXw==} engines: {node: '>=18.12.0'} + union-value@1.0.1: + resolution: {integrity: sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==} + engines: {node: '>=0.10.0'} + unique-filename@3.0.0: resolution: {integrity: sha512-afXhuC55wkAmZ0P18QsVE6kp8JaxrEokN2HGIoIVv2ijHQd419H0+6EigAFcIzXeMIkcIkNBpB3L/DXB3cTS/g==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} @@ -11569,6 +12407,10 @@ packages: resolution: {integrity: sha512-m1ekpSwuOT5hxkJeZGRxO7gXbXT3gF26NjQ7GdVHoLoF8/nopLcd/QfPigpCy7i51oFHiRJg/CyHhj4vs2+KGw==} engines: {node: '>=18.12.0'} + unset-value@1.0.0: + resolution: {integrity: sha512-PcA2tsuGSF9cnySLHTLSh2qrQiJ70mn+r+Glzxv2TWZblxsxCC52BDlZoPCsz7STd9pN7EZetkWZBAvk4cgZdQ==} + engines: {node: '>=0.10.0'} + untildify@4.0.0: resolution: {integrity: sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==} engines: {node: '>=8'} @@ -11594,6 +12436,10 @@ packages: uri-js@4.4.1: resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} + urix@0.1.0: + resolution: {integrity: sha512-Am1ousAhSLBeB9cG/7k7r2R0zj50uDRlZHPGbazid5s9rlF1F/QKYObEKSIunSjIOkJZqwRRLpvewjEkM7pSqg==} + deprecated: Please see https://github.com/lydell/urix#deprecated + url-join@4.0.1: resolution: {integrity: sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA==} @@ -11601,6 +12447,10 @@ packages: resolution: {integrity: sha512-NjFKA0DidqPa5ciFcSrXnAltTtzz84ogy+NebPvfEgAck0+TNg4UJ4IN+fB7zRZfbgUf0syOo9MDxFkDSMuFaQ==} engines: {node: '>=4'} + url@0.11.4: + resolution: {integrity: sha512-oCwdVC7mTuWiPyjLUz/COz5TLk6wgp0RCsN+wHZ2Ekneac9w8uuV0njcbbie2ME+Vs+d6duwmYuR3HgQXs1fOg==} + engines: {node: '>= 0.4'} + urlencode@1.1.0: resolution: {integrity: sha512-OOAOh9owHXr/rCN1tteSnYwIvsrGHamSz0hafMhmQa7RcS4+Ets6/2iVClVGjt9jkDW84UqoMw/Gmpc7QolX6A==} @@ -11617,6 +12467,15 @@ packages: resolution: {integrity: sha512-6vxaBISIV2yUloDy0QkZIbQsint5omDs6GsoqFNRmyUzkpJ4IeU/hMT3Ck5+2htEIRlHDACBIy2MHfxSyhLzPQ==} engines: {node: '>= 18.19.0'} + use@3.1.1: + resolution: {integrity: sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==} + engines: {node: '>=0.10.0'} + + user-home@1.1.1: + resolution: {integrity: sha512-aggiKfEEubv3UwRNqTzLInZpAOmKzwdHqEBmW/hBA/mt99eg+b4VrX6i+IRLxU8+WJYfa33rGwRseg4eElUgsQ==} + engines: {node: '>=0.10.0'} + hasBin: true + util-deprecate@1.0.2: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} @@ -11659,6 +12518,10 @@ packages: resolution: {integrity: sha512-kiGUalWN+rgBJ/1OHZsBtU4rXZOfj/7rKQxULKlIzwzQSvMJUUNgPwJEEh7gU6xEVxC0ahoOBvN2YI8GH6FNgA==} engines: {node: '>=10.12.0'} + v8flags@2.1.1: + resolution: {integrity: sha512-SKfhk/LlaXzvtowJabLZwD4K6SGRYeoxA7KJeISlUMAB/NT4CBkZjMq3WceX2Ckm4llwqYVo8TICgsDYCBU2tA==} + engines: {node: '>= 0.10.0'} + validate-npm-package-license@3.0.4: resolution: {integrity: sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==} @@ -17166,10 +18029,14 @@ snapshots: dependencies: type-fest: 0.21.3 + ansi-regex@2.1.1: {} + ansi-regex@5.0.1: {} ansi-regex@6.1.0: {} + ansi-styles@2.2.1: {} + ansi-styles@3.2.1: dependencies: color-convert: 1.9.3 @@ -17212,6 +18079,12 @@ snapshots: any-promise@1.3.0: {} + anymatch@1.3.2: + dependencies: + micromatch: 2.3.11 + normalize-path: 2.1.1 + optional: true + anymatch@3.1.3: dependencies: normalize-path: 3.0.0 @@ -17235,6 +18108,20 @@ snapshots: dependencies: tslib: 2.8.1 + arr-diff@2.0.0: + dependencies: + arr-flatten: 1.1.0 + optional: true + + arr-diff@4.0.0: + optional: true + + arr-flatten@1.1.0: + optional: true + + arr-union@3.1.0: + optional: true + array-back@1.0.4: dependencies: typical: 2.6.1 @@ -17275,6 +18162,12 @@ snapshots: array-union@3.0.1: {} + array-unique@0.2.1: + optional: true + + array-unique@0.3.2: + optional: true + array.prototype.findlastindex@1.2.5: dependencies: call-bind: 1.0.8 @@ -17328,6 +18221,9 @@ snapshots: assertion-error@2.0.1: {} + assign-symbols@1.0.0: + optional: true + ast-kit@1.4.2: dependencies: '@babel/parser': 7.26.9 @@ -17340,6 +18236,9 @@ snapshots: astral-regex@2.0.0: {} + async-each@1.0.6: + optional: true + async-function@1.0.0: {} async-limiter@1.0.1: {} @@ -17352,6 +18251,9 @@ snapshots: asynckit@0.4.0: {} + atob@2.1.2: + optional: true + atomically@1.7.0: {} autoprefixer@10.4.21(postcss@8.5.3): @@ -17407,6 +18309,169 @@ snapshots: transitivePeerDependencies: - debug + babel-cli@6.26.0: + dependencies: + babel-core: 6.26.3 + babel-polyfill: 6.26.0 + babel-register: 6.26.0 + babel-runtime: 6.26.0 + commander: 2.20.3 + convert-source-map: 1.9.0 + fs-readdir-recursive: 1.1.0 + glob: 7.2.3 + lodash: 4.17.21 + output-file-sync: 1.1.2 + path-is-absolute: 1.0.1 + slash: 1.0.0 + source-map: 0.5.7 + v8flags: 2.1.1 + optionalDependencies: + chokidar: 1.7.0 + transitivePeerDependencies: + - supports-color + + babel-code-frame@6.26.0: + dependencies: + chalk: 1.1.3 + esutils: 2.0.3 + js-tokens: 3.0.2 + + babel-core@6.26.3: + dependencies: + babel-code-frame: 6.26.0 + babel-generator: 6.26.1 + babel-helpers: 6.24.1 + babel-messages: 6.23.0 + babel-register: 6.26.0 + babel-runtime: 6.26.0 + babel-template: 6.26.0 + babel-traverse: 6.26.0 + babel-types: 6.26.0 + babylon: 6.18.0 + convert-source-map: 1.9.0 + debug: 2.6.9 + json5: 0.5.1 + lodash: 4.17.21 + minimatch: 3.1.2 + path-is-absolute: 1.0.1 + private: 0.1.8 + slash: 1.0.0 + source-map: 0.5.7 + transitivePeerDependencies: + - supports-color + + babel-generator@6.26.1: + dependencies: + babel-messages: 6.23.0 + babel-runtime: 6.26.0 + babel-types: 6.26.0 + detect-indent: 4.0.0 + jsesc: 1.3.0 + lodash: 4.17.21 + source-map: 0.5.7 + trim-right: 1.0.1 + + babel-helper-builder-binary-assignment-operator-visitor@6.24.1: + dependencies: + babel-helper-explode-assignable-expression: 6.24.1 + babel-runtime: 6.26.0 + babel-types: 6.26.0 + transitivePeerDependencies: + - supports-color + + babel-helper-call-delegate@6.24.1: + dependencies: + babel-helper-hoist-variables: 6.24.1 + babel-runtime: 6.26.0 + babel-traverse: 6.26.0 + babel-types: 6.26.0 + transitivePeerDependencies: + - supports-color + + babel-helper-define-map@6.26.0: + dependencies: + babel-helper-function-name: 6.24.1 + babel-runtime: 6.26.0 + babel-types: 6.26.0 + lodash: 4.17.21 + transitivePeerDependencies: + - supports-color + + babel-helper-explode-assignable-expression@6.24.1: + dependencies: + babel-runtime: 6.26.0 + babel-traverse: 6.26.0 + babel-types: 6.26.0 + transitivePeerDependencies: + - supports-color + + babel-helper-function-name@6.24.1: + dependencies: + babel-helper-get-function-arity: 6.24.1 + babel-runtime: 6.26.0 + babel-template: 6.26.0 + babel-traverse: 6.26.0 + babel-types: 6.26.0 + transitivePeerDependencies: + - supports-color + + babel-helper-get-function-arity@6.24.1: + dependencies: + babel-runtime: 6.26.0 + babel-types: 6.26.0 + + babel-helper-hoist-variables@6.24.1: + dependencies: + babel-runtime: 6.26.0 + babel-types: 6.26.0 + + babel-helper-optimise-call-expression@6.24.1: + dependencies: + babel-runtime: 6.26.0 + babel-types: 6.26.0 + + babel-helper-regex@6.26.0: + dependencies: + babel-runtime: 6.26.0 + babel-types: 6.26.0 + lodash: 4.17.21 + + babel-helper-remap-async-to-generator@6.24.1: + dependencies: + babel-helper-function-name: 6.24.1 + babel-runtime: 6.26.0 + babel-template: 6.26.0 + babel-traverse: 6.26.0 + babel-types: 6.26.0 + transitivePeerDependencies: + - supports-color + + babel-helper-replace-supers@6.24.1: + dependencies: + babel-helper-optimise-call-expression: 6.24.1 + babel-messages: 6.23.0 + babel-runtime: 6.26.0 + babel-template: 6.26.0 + babel-traverse: 6.26.0 + babel-types: 6.26.0 + transitivePeerDependencies: + - supports-color + + babel-helpers@6.24.1: + dependencies: + babel-runtime: 6.26.0 + babel-template: 6.26.0 + transitivePeerDependencies: + - supports-color + + babel-messages@6.23.0: + dependencies: + babel-runtime: 6.26.0 + + babel-plugin-check-es2015-constants@6.22.0: + dependencies: + babel-runtime: 6.26.0 + babel-plugin-polyfill-corejs2@0.4.12(@babel/core@7.26.9): dependencies: '@babel/compat-data': 7.26.8 @@ -17431,6 +18496,272 @@ snapshots: transitivePeerDependencies: - supports-color + babel-plugin-syntax-async-functions@6.13.0: {} + + babel-plugin-syntax-exponentiation-operator@6.13.0: {} + + babel-plugin-syntax-trailing-function-commas@6.22.0: {} + + babel-plugin-transform-async-to-generator@6.24.1: + dependencies: + babel-helper-remap-async-to-generator: 6.24.1 + babel-plugin-syntax-async-functions: 6.13.0 + babel-runtime: 6.26.0 + transitivePeerDependencies: + - supports-color + + babel-plugin-transform-es2015-arrow-functions@6.22.0: + dependencies: + babel-runtime: 6.26.0 + + babel-plugin-transform-es2015-block-scoped-functions@6.22.0: + dependencies: + babel-runtime: 6.26.0 + + babel-plugin-transform-es2015-block-scoping@6.26.0: + dependencies: + babel-runtime: 6.26.0 + babel-template: 6.26.0 + babel-traverse: 6.26.0 + babel-types: 6.26.0 + lodash: 4.17.21 + transitivePeerDependencies: + - supports-color + + babel-plugin-transform-es2015-classes@6.24.1: + dependencies: + babel-helper-define-map: 6.26.0 + babel-helper-function-name: 6.24.1 + babel-helper-optimise-call-expression: 6.24.1 + babel-helper-replace-supers: 6.24.1 + babel-messages: 6.23.0 + babel-runtime: 6.26.0 + babel-template: 6.26.0 + babel-traverse: 6.26.0 + babel-types: 6.26.0 + transitivePeerDependencies: + - supports-color + + babel-plugin-transform-es2015-computed-properties@6.24.1: + dependencies: + babel-runtime: 6.26.0 + babel-template: 6.26.0 + transitivePeerDependencies: + - supports-color + + babel-plugin-transform-es2015-destructuring@6.23.0: + dependencies: + babel-runtime: 6.26.0 + + babel-plugin-transform-es2015-duplicate-keys@6.24.1: + dependencies: + babel-runtime: 6.26.0 + babel-types: 6.26.0 + + babel-plugin-transform-es2015-for-of@6.23.0: + dependencies: + babel-runtime: 6.26.0 + + babel-plugin-transform-es2015-function-name@6.24.1: + dependencies: + babel-helper-function-name: 6.24.1 + babel-runtime: 6.26.0 + babel-types: 6.26.0 + transitivePeerDependencies: + - supports-color + + babel-plugin-transform-es2015-literals@6.22.0: + dependencies: + babel-runtime: 6.26.0 + + babel-plugin-transform-es2015-modules-amd@6.24.1: + dependencies: + babel-plugin-transform-es2015-modules-commonjs: 6.26.2 + babel-runtime: 6.26.0 + babel-template: 6.26.0 + transitivePeerDependencies: + - supports-color + + babel-plugin-transform-es2015-modules-commonjs@6.26.2: + dependencies: + babel-plugin-transform-strict-mode: 6.24.1 + babel-runtime: 6.26.0 + babel-template: 6.26.0 + babel-types: 6.26.0 + transitivePeerDependencies: + - supports-color + + babel-plugin-transform-es2015-modules-systemjs@6.24.1: + dependencies: + babel-helper-hoist-variables: 6.24.1 + babel-runtime: 6.26.0 + babel-template: 6.26.0 + transitivePeerDependencies: + - supports-color + + babel-plugin-transform-es2015-modules-umd@6.24.1: + dependencies: + babel-plugin-transform-es2015-modules-amd: 6.24.1 + babel-runtime: 6.26.0 + babel-template: 6.26.0 + transitivePeerDependencies: + - supports-color + + babel-plugin-transform-es2015-object-super@6.24.1: + dependencies: + babel-helper-replace-supers: 6.24.1 + babel-runtime: 6.26.0 + transitivePeerDependencies: + - supports-color + + babel-plugin-transform-es2015-parameters@6.24.1: + dependencies: + babel-helper-call-delegate: 6.24.1 + babel-helper-get-function-arity: 6.24.1 + babel-runtime: 6.26.0 + babel-template: 6.26.0 + babel-traverse: 6.26.0 + babel-types: 6.26.0 + transitivePeerDependencies: + - supports-color + + babel-plugin-transform-es2015-shorthand-properties@6.24.1: + dependencies: + babel-runtime: 6.26.0 + babel-types: 6.26.0 + + babel-plugin-transform-es2015-spread@6.22.0: + dependencies: + babel-runtime: 6.26.0 + + babel-plugin-transform-es2015-sticky-regex@6.24.1: + dependencies: + babel-helper-regex: 6.26.0 + babel-runtime: 6.26.0 + babel-types: 6.26.0 + + babel-plugin-transform-es2015-template-literals@6.22.0: + dependencies: + babel-runtime: 6.26.0 + + babel-plugin-transform-es2015-typeof-symbol@6.23.0: + dependencies: + babel-runtime: 6.26.0 + + babel-plugin-transform-es2015-unicode-regex@6.24.1: + dependencies: + babel-helper-regex: 6.26.0 + babel-runtime: 6.26.0 + regexpu-core: 2.0.0 + + babel-plugin-transform-exponentiation-operator@6.24.1: + dependencies: + babel-helper-builder-binary-assignment-operator-visitor: 6.24.1 + babel-plugin-syntax-exponentiation-operator: 6.13.0 + babel-runtime: 6.26.0 + transitivePeerDependencies: + - supports-color + + babel-plugin-transform-regenerator@6.26.0: + dependencies: + regenerator-transform: 0.10.1 + + babel-plugin-transform-strict-mode@6.24.1: + dependencies: + babel-runtime: 6.26.0 + babel-types: 6.26.0 + + babel-polyfill@6.26.0: + dependencies: + babel-runtime: 6.26.0 + core-js: 2.6.12 + regenerator-runtime: 0.10.5 + + babel-preset-env@1.7.0: + dependencies: + babel-plugin-check-es2015-constants: 6.22.0 + babel-plugin-syntax-trailing-function-commas: 6.22.0 + babel-plugin-transform-async-to-generator: 6.24.1 + babel-plugin-transform-es2015-arrow-functions: 6.22.0 + babel-plugin-transform-es2015-block-scoped-functions: 6.22.0 + babel-plugin-transform-es2015-block-scoping: 6.26.0 + babel-plugin-transform-es2015-classes: 6.24.1 + babel-plugin-transform-es2015-computed-properties: 6.24.1 + babel-plugin-transform-es2015-destructuring: 6.23.0 + babel-plugin-transform-es2015-duplicate-keys: 6.24.1 + babel-plugin-transform-es2015-for-of: 6.23.0 + babel-plugin-transform-es2015-function-name: 6.24.1 + babel-plugin-transform-es2015-literals: 6.22.0 + babel-plugin-transform-es2015-modules-amd: 6.24.1 + babel-plugin-transform-es2015-modules-commonjs: 6.26.2 + babel-plugin-transform-es2015-modules-systemjs: 6.24.1 + babel-plugin-transform-es2015-modules-umd: 6.24.1 + babel-plugin-transform-es2015-object-super: 6.24.1 + babel-plugin-transform-es2015-parameters: 6.24.1 + babel-plugin-transform-es2015-shorthand-properties: 6.24.1 + babel-plugin-transform-es2015-spread: 6.22.0 + babel-plugin-transform-es2015-sticky-regex: 6.24.1 + babel-plugin-transform-es2015-template-literals: 6.22.0 + babel-plugin-transform-es2015-typeof-symbol: 6.23.0 + babel-plugin-transform-es2015-unicode-regex: 6.24.1 + babel-plugin-transform-exponentiation-operator: 6.24.1 + babel-plugin-transform-regenerator: 6.26.0 + browserslist: 3.2.8 + invariant: 2.2.4 + semver: 5.7.2 + transitivePeerDependencies: + - supports-color + + babel-register@6.26.0: + dependencies: + babel-core: 6.26.3 + babel-runtime: 6.26.0 + core-js: 2.6.12 + home-or-tmp: 2.0.0 + lodash: 4.17.21 + mkdirp: 0.5.6 + source-map-support: 0.4.18 + transitivePeerDependencies: + - supports-color + + babel-runtime@6.26.0: + dependencies: + core-js: 2.6.12 + regenerator-runtime: 0.11.1 + + babel-template@6.26.0: + dependencies: + babel-runtime: 6.26.0 + babel-traverse: 6.26.0 + babel-types: 6.26.0 + babylon: 6.18.0 + lodash: 4.17.21 + transitivePeerDependencies: + - supports-color + + babel-traverse@6.26.0: + dependencies: + babel-code-frame: 6.26.0 + babel-messages: 6.23.0 + babel-runtime: 6.26.0 + babel-types: 6.26.0 + babylon: 6.18.0 + debug: 2.6.9 + globals: 9.18.0 + invariant: 2.2.4 + lodash: 4.17.21 + transitivePeerDependencies: + - supports-color + + babel-types@6.26.0: + dependencies: + babel-runtime: 6.26.0 + esutils: 2.0.3 + lodash: 4.17.21 + to-fast-properties: 1.0.3 + + babylon@6.18.0: {} + baidu-aip-sdk@4.16.16: dependencies: debug: 2.6.9 @@ -17451,6 +18782,17 @@ snapshots: base64url@3.0.1: {} + base@0.11.2: + dependencies: + cache-base: 1.0.1 + class-utils: 0.3.6 + component-emitter: 1.3.1 + define-property: 1.0.0 + isobject: 3.0.1 + mixin-deep: 1.3.2 + pascalcase: 0.1.1 + optional: true + basic-ftp@5.0.5: {} bcrypt-pbkdf@1.0.2: @@ -17496,6 +18838,9 @@ snapshots: read-cmd-shim: 4.0.0 write-file-atomic: 5.0.1 + binary-extensions@1.13.1: + optional: true + binary-extensions@2.3.0: {} bindings@1.5.0: @@ -17542,6 +18887,29 @@ snapshots: dependencies: balanced-match: 1.0.2 + braces@1.8.5: + dependencies: + expand-range: 1.8.2 + preserve: 0.2.0 + repeat-element: 1.1.4 + optional: true + + braces@2.3.2: + dependencies: + arr-flatten: 1.1.0 + array-unique: 0.3.2 + extend-shallow: 2.0.1 + fill-range: 4.0.0 + isobject: 3.0.1 + repeat-element: 1.1.4 + snapdragon: 0.8.2 + snapdragon-node: 2.1.1 + split-string: 3.1.0 + to-regex: 3.0.2 + transitivePeerDependencies: + - supports-color + optional: true + braces@3.0.3: dependencies: fill-range: 7.1.1 @@ -17556,6 +18924,11 @@ snapshots: browserslist: 4.24.4 meow: 13.2.0 + browserslist@3.2.8: + dependencies: + caniuse-lite: 1.0.30001703 + electron-to-chromium: 1.5.113 + browserslist@4.24.4: dependencies: caniuse-lite: 1.0.30001703 @@ -17636,6 +19009,19 @@ snapshots: tar: 6.2.1 unique-filename: 3.0.0 + cache-base@1.0.1: + dependencies: + collection-visit: 1.0.0 + component-emitter: 1.3.1 + get-value: 2.0.6 + has-value: 1.0.0 + isobject: 3.0.1 + set-value: 2.0.1 + to-object-path: 0.3.0 + union-value: 1.0.1 + unset-value: 1.0.0 + optional: true + cache-content-type@1.0.1: dependencies: mime-types: 2.1.35 @@ -17775,6 +19161,14 @@ snapshots: loupe: 3.1.3 pathval: 2.0.0 + chalk@1.1.3: + dependencies: + ansi-styles: 2.2.1 + escape-string-regexp: 1.0.5 + has-ansi: 2.0.0 + strip-ansi: 3.0.1 + supports-color: 2.0.0 + chalk@2.4.2: dependencies: ansi-styles: 3.2.1 @@ -17800,6 +19194,22 @@ snapshots: china-division@2.7.0: {} + chokidar@1.7.0: + dependencies: + anymatch: 1.3.2 + async-each: 1.0.6 + glob-parent: 2.0.0 + inherits: 2.0.4 + is-binary-path: 1.0.1 + is-glob: 2.0.1 + path-is-absolute: 1.0.1 + readdirp: 2.2.1 + optionalDependencies: + fsevents: 1.2.13 + transitivePeerDependencies: + - supports-color + optional: true + chokidar@3.6.0: dependencies: anymatch: 3.1.3 @@ -17828,12 +19238,25 @@ snapshots: ci-info@4.2.0: {} + cipher-base@1.0.6: + dependencies: + inherits: 2.0.4 + safe-buffer: 5.2.1 + citty@0.1.6: dependencies: consola: 3.4.0 class-transformer@0.5.1: {} + class-utils@0.3.6: + dependencies: + arr-union: 3.1.0 + define-property: 0.2.5 + isobject: 3.0.1 + static-extend: 0.1.2 + optional: true + class-variance-authority@0.7.1: dependencies: clsx: 2.1.1 @@ -17919,6 +19342,12 @@ snapshots: stream-connect: 1.0.2 stream-via: 1.0.4 + collection-visit@1.0.0: + dependencies: + map-visit: 1.0.0 + object-visit: 1.0.1 + optional: true + color-convert@1.9.3: dependencies: color-name: 1.1.3 @@ -17977,6 +19406,8 @@ snapshots: commander@2.11.0: optional: true + commander@2.15.1: {} + commander@2.20.3: {} commander@4.1.1: {} @@ -18051,6 +19482,10 @@ snapshots: dependencies: walk-back: 2.0.1 + config@1.31.0: + dependencies: + json5: 1.0.2 + configstore@5.0.1: dependencies: dot-prop: 5.3.0 @@ -18120,6 +19555,8 @@ snapshots: git-semver-tags: 7.0.1 meow: 12.1.1 + convert-source-map@1.9.0: {} + convert-source-map@2.0.0: {} cookiejar@2.1.4: {} @@ -18137,6 +19574,9 @@ snapshots: dependencies: is-what: 4.1.16 + copy-descriptor@0.1.1: + optional: true + copy-to@2.0.1: {} copyfiles@2.4.1: @@ -18204,6 +19644,23 @@ snapshots: optionalDependencies: buffer: 6.0.3 + create-hash@1.2.0: + dependencies: + cipher-base: 1.0.6 + inherits: 2.0.4 + md5.js: 1.3.5 + ripemd160: 2.0.2 + sha.js: 2.4.11 + + create-hmac@1.1.7: + dependencies: + cipher-base: 1.0.6 + create-hash: 1.2.0 + inherits: 2.0.4 + ripemd160: 2.0.2 + safe-buffer: 5.2.1 + sha.js: 2.4.11 + create-require@1.1.1: {} cron-parser@4.9.0: @@ -18212,10 +19669,22 @@ snapshots: cropperjs@1.6.2: {} + cross-env@5.2.1: + dependencies: + cross-spawn: 6.0.6 + cross-env@7.0.3: dependencies: cross-spawn: 7.0.6 + cross-spawn@6.0.6: + dependencies: + nice-try: 1.0.5 + path-key: 2.0.1 + semver: 5.7.2 + shebang-command: 1.2.0 + which: 1.3.1 + cross-spawn@7.0.6: dependencies: path-key: 3.1.1 @@ -18384,6 +19853,12 @@ snapshots: supports-color: 4.4.0 optional: true + debug@3.1.0(supports-color@5.4.0): + dependencies: + ms: 2.0.0 + optionalDependencies: + supports-color: 5.4.0 + debug@3.2.7: dependencies: ms: 2.1.3 @@ -18405,6 +19880,9 @@ snapshots: decamelize@5.0.1: {} + decode-uri-component@0.2.2: + optional: true + decompress-response@3.3.0: dependencies: mimic-response: 1.0.1 @@ -18466,6 +19944,22 @@ snapshots: has-property-descriptors: 1.0.2 object-keys: 1.1.1 + define-property@0.2.5: + dependencies: + is-descriptor: 0.1.7 + optional: true + + define-property@1.0.0: + dependencies: + is-descriptor: 1.0.3 + optional: true + + define-property@2.0.2: + dependencies: + is-descriptor: 1.0.3 + isobject: 3.0.1 + optional: true + defu@6.1.4: {} delayed-stream@1.0.0: {} @@ -18509,6 +20003,10 @@ snapshots: destroy@1.2.0: {} + detect-indent@4.0.0: + dependencies: + repeating: 2.0.1 + detect-indent@7.0.1: {} detect-libc@2.0.3: {} @@ -18529,6 +20027,8 @@ snapshots: diff@3.3.1: optional: true + diff@3.5.0: {} + diff@4.0.2: {} diff@5.2.0: {} @@ -19042,13 +20542,13 @@ snapshots: resolve: 1.22.10 semver: 6.3.1 - eslint-plugin-prettier@3.4.1(eslint-config-prettier@8.10.0(eslint@7.32.0))(eslint@7.32.0)(prettier@2.8.8): + eslint-plugin-prettier@3.4.1(eslint-config-prettier@8.10.0(eslint@8.57.0))(eslint@7.32.0)(prettier@2.8.8): dependencies: eslint: 7.32.0 prettier: 2.8.8 prettier-linter-helpers: 1.0.0 optionalDependencies: - eslint-config-prettier: 8.10.0(eslint@7.32.0) + eslint-config-prettier: 8.10.0(eslint@8.57.0) eslint-plugin-prettier@4.2.1(eslint-config-prettier@8.10.0(eslint@8.57.0))(eslint@8.57.0)(prettier@2.8.8): dependencies: @@ -19275,6 +20775,29 @@ snapshots: signal-exit: 4.1.0 strip-final-newline: 3.0.0 + expand-brackets@0.1.5: + dependencies: + is-posix-bracket: 0.1.1 + optional: true + + expand-brackets@2.1.4: + dependencies: + debug: 2.6.9 + define-property: 0.2.5 + extend-shallow: 2.0.1 + posix-character-classes: 0.1.1 + regex-not: 1.0.2 + snapdragon: 0.8.2 + to-regex: 3.0.2 + transitivePeerDependencies: + - supports-color + optional: true + + expand-range@1.8.2: + dependencies: + fill-range: 2.2.4 + optional: true + expand-template@2.0.3: {} expect@29.7.0: @@ -19297,6 +20820,12 @@ snapshots: dependencies: is-extendable: 0.1.1 + extend-shallow@3.0.2: + dependencies: + assign-symbols: 1.0.0 + is-extendable: 1.0.1 + optional: true + extend@3.0.2: {} external-editor@3.1.0: @@ -19305,6 +20834,25 @@ snapshots: iconv-lite: 0.4.24 tmp: 0.0.33 + extglob@0.3.2: + dependencies: + is-extglob: 1.0.0 + optional: true + + extglob@2.0.4: + dependencies: + array-unique: 0.3.2 + define-property: 1.0.0 + expand-brackets: 2.1.4 + extend-shallow: 2.0.1 + fragment-cache: 0.2.1 + regex-not: 1.0.2 + snapdragon: 0.8.2 + to-regex: 3.0.2 + transitivePeerDependencies: + - supports-color + optional: true + extsprintf@1.3.0: {} fast-content-type-parse@2.0.1: {} @@ -19389,8 +20937,28 @@ snapshots: dependencies: minimatch: 5.1.6 + filename-regex@2.0.1: + optional: true + filesize@10.1.6: {} + fill-range@2.2.4: + dependencies: + is-number: 2.1.0 + isobject: 2.1.0 + randomatic: 3.1.1 + repeat-element: 1.1.4 + repeat-string: 1.6.1 + optional: true + + fill-range@4.0.0: + dependencies: + extend-shallow: 2.0.1 + is-number: 3.0.0 + repeat-string: 1.6.1 + to-regex-range: 2.1.1 + optional: true + fill-range@7.1.1: dependencies: to-regex-range: 5.0.1 @@ -19442,6 +21010,14 @@ snapshots: dependencies: is-callable: 1.2.7 + for-in@1.0.2: + optional: true + + for-own@0.1.5: + dependencies: + for-in: 1.0.2 + optional: true + foreground-child@3.3.1: dependencies: cross-spawn: 7.0.6 @@ -19499,6 +21075,11 @@ snapshots: fraction.js@4.3.7: {} + fragment-cache@0.2.1: + dependencies: + map-cache: 0.2.2 + optional: true + fresh@0.5.2: {} fs-constants@1.0.0: {} @@ -19535,6 +21116,12 @@ snapshots: fs.realpath@1.0.0: {} + fsevents@1.2.13: + dependencies: + bindings: 1.5.0 + nan: 2.22.2 + optional: true + fsevents@2.3.3: optional: true @@ -19624,6 +21211,9 @@ snapshots: es-errors: 1.3.0 get-intrinsic: 1.3.0 + get-value@2.0.6: + optional: true + getpass@0.1.7: dependencies: assert-plus: 1.0.0 @@ -19659,6 +21249,17 @@ snapshots: github-from-package@0.0.0: {} + glob-base@0.3.0: + dependencies: + glob-parent: 2.0.0 + is-glob: 2.0.1 + optional: true + + glob-parent@2.0.0: + dependencies: + is-glob: 2.0.1 + optional: true + glob-parent@5.1.2: dependencies: is-glob: 4.0.3 @@ -19693,7 +21294,6 @@ snapshots: minimatch: 3.1.2 once: 1.4.0 path-is-absolute: 1.0.1 - optional: true glob@7.2.3: dependencies: @@ -19736,6 +21336,8 @@ snapshots: dependencies: type-fest: 0.20.2 + globals@9.18.0: {} + globalthis@1.0.4: dependencies: define-properties: 1.2.1 @@ -19822,6 +21424,8 @@ snapshots: growl@1.10.3: optional: true + growl@1.10.5: {} + gtoken@7.1.0(encoding@0.1.13): dependencies: gaxios: 6.7.1(encoding@0.1.13) @@ -19848,6 +21452,10 @@ snapshots: hard-rejection@2.1.0: {} + has-ansi@2.0.0: + dependencies: + ansi-regex: 2.1.1 + has-bigints@1.1.0: {} has-flag@2.0.0: @@ -19873,8 +21481,37 @@ snapshots: has-unicode@2.0.1: {} + has-value@0.3.1: + dependencies: + get-value: 2.0.6 + has-values: 0.1.4 + isobject: 2.1.0 + optional: true + + has-value@1.0.0: + dependencies: + get-value: 2.0.6 + has-values: 1.0.0 + isobject: 3.0.1 + optional: true + + has-values@0.1.4: + optional: true + + has-values@1.0.0: + dependencies: + is-number: 3.0.0 + kind-of: 4.0.0 + optional: true + has-yarn@2.1.0: {} + hash-base@3.1.0: + dependencies: + inherits: 2.0.4 + readable-stream: 3.6.2 + safe-buffer: 5.2.1 + hasown@2.0.2: dependencies: function-bind: 1.1.2 @@ -19897,8 +21534,7 @@ snapshots: dependencies: '@types/hast': 3.0.4 - he@1.1.1: - optional: true + he@1.1.1: {} he@1.2.0: {} @@ -19911,6 +21547,11 @@ snapshots: highlight.js@11.11.1: {} + home-or-tmp@2.0.0: + dependencies: + os-homedir: 1.0.2 + os-tmpdir: 1.0.2 + hookable@5.5.3: {} hosted-git-info@2.8.9: {} @@ -20121,6 +21762,10 @@ snapshots: interpret@3.1.1: {} + invariant@2.2.4: + dependencies: + loose-envify: 1.4.0 + ip-address@9.0.5: dependencies: jsbn: 1.1.0 @@ -20128,6 +21773,11 @@ snapshots: irregular-plurals@3.5.0: {} + is-accessor-descriptor@1.0.1: + dependencies: + hasown: 2.0.2 + optional: true + is-arguments@1.2.0: dependencies: call-bound: 1.0.4 @@ -20153,6 +21803,11 @@ snapshots: dependencies: has-bigints: 1.1.0 + is-binary-path@1.0.1: + dependencies: + binary-extensions: 1.13.1 + optional: true + is-binary-path@2.1.0: dependencies: binary-extensions: 2.3.0 @@ -20162,6 +21817,9 @@ snapshots: call-bound: 1.0.4 has-tostringtag: 1.0.2 + is-buffer@1.1.6: + optional: true + is-buffer@2.0.5: {} is-callable@1.2.7: {} @@ -20180,6 +21838,11 @@ snapshots: dependencies: hasown: 2.0.2 + is-data-descriptor@1.0.1: + dependencies: + hasown: 2.0.2 + optional: true + is-data-view@1.0.2: dependencies: call-bound: 1.0.4 @@ -20191,16 +21854,46 @@ snapshots: call-bound: 1.0.4 has-tostringtag: 1.0.2 + is-descriptor@0.1.7: + dependencies: + is-accessor-descriptor: 1.0.1 + is-data-descriptor: 1.0.1 + optional: true + + is-descriptor@1.0.3: + dependencies: + is-accessor-descriptor: 1.0.1 + is-data-descriptor: 1.0.1 + optional: true + is-docker@2.2.1: {} + is-dotfile@1.0.3: + optional: true + + is-equal-shallow@0.1.3: + dependencies: + is-primitive: 2.0.0 + optional: true + is-extendable@0.1.1: {} + is-extendable@1.0.1: + dependencies: + is-plain-object: 2.0.4 + optional: true + + is-extglob@1.0.0: + optional: true + is-extglob@2.1.1: {} is-finalizationregistry@1.1.1: dependencies: call-bound: 1.0.4 + is-finite@1.1.0: {} + is-fullwidth-code-point@3.0.0: {} is-generator-function@1.1.0: @@ -20210,6 +21903,11 @@ snapshots: has-tostringtag: 1.0.2 safe-regex-test: 1.1.0 + is-glob@2.0.1: + dependencies: + is-extglob: 1.0.0 + optional: true + is-glob@4.0.3: dependencies: is-extglob: 2.1.1 @@ -20239,6 +21937,19 @@ snapshots: call-bound: 1.0.4 has-tostringtag: 1.0.2 + is-number@2.1.0: + dependencies: + kind-of: 3.2.2 + optional: true + + is-number@3.0.0: + dependencies: + kind-of: 3.2.2 + optional: true + + is-number@4.0.0: + optional: true + is-number@7.0.0: {} is-obj@2.0.0: {} @@ -20261,6 +21972,12 @@ snapshots: is-plain-object@5.0.0: {} + is-posix-bracket@0.1.1: + optional: true + + is-primitive@2.0.0: + optional: true + is-reference@1.2.1: dependencies: '@types/estree': 1.0.6 @@ -20334,6 +22051,9 @@ snapshots: is-what@4.1.16: {} + is-windows@1.0.2: + optional: true + is-wsl@2.2.0: dependencies: is-docker: 2.2.1 @@ -20350,6 +22070,11 @@ snapshots: isexe@3.1.1: {} + isobject@2.1.0: + dependencies: + isarray: 1.0.0 + optional: true + isobject@3.0.1: {} isomorphic-ws@4.0.1(ws@6.2.3): @@ -20398,6 +22123,21 @@ snapshots: javascript-natural-sort@0.7.1: {} + jdcloud-sdk-js@1.2.202(encoding@0.1.13): + dependencies: + babel-register: 6.26.0 + buffer: 5.7.1 + create-hash: 1.2.0 + create-hmac: 1.1.7 + debug: 3.2.7 + node-fetch: 2.7.0(encoding@0.1.13) + querystring: 0.2.1 + url: 0.11.4 + uuid: 3.4.0 + transitivePeerDependencies: + - encoding + - supports-color + jest-diff@29.7.0: dependencies: chalk: 4.1.2 @@ -20472,6 +22212,8 @@ snapshots: js-sdsl@4.3.0: {} + js-tokens@3.0.2: {} + js-tokens@4.0.0: {} js-tokens@9.0.1: {} @@ -20546,6 +22288,10 @@ snapshots: jsencrypt@3.3.2: {} + jsesc@0.5.0: {} + + jsesc@1.3.0: {} + jsesc@3.0.2: {} jsesc@3.1.0: {} @@ -20580,6 +22326,8 @@ snapshots: json-stringify-safe@5.0.1: {} + json5@0.5.1: {} + json5@1.0.2: dependencies: minimist: 1.2.8 @@ -20687,6 +22435,16 @@ snapshots: dependencies: '@keyv/serialize': 1.0.3 + kind-of@3.2.2: + dependencies: + is-buffer: 1.1.6 + optional: true + + kind-of@4.0.0: + dependencies: + is-buffer: 1.1.6 + optional: true + kind-of@6.0.3: {} kitx@1.3.0: {} @@ -21029,10 +22787,18 @@ snapshots: transitivePeerDependencies: - supports-color + map-cache@0.2.2: + optional: true + map-obj@1.0.1: {} map-obj@4.3.0: {} + map-visit@1.0.0: + dependencies: + object-visit: 1.0.1 + optional: true + mark.js@8.11.1: {} markdown-it-anchor@8.6.7(@types/markdown-it@14.1.2)(markdown-it@14.1.0): @@ -21053,8 +22819,17 @@ snapshots: math-intrinsics@1.1.0: {} + math-random@1.0.4: + optional: true + mathml-tag-names@2.1.3: {} + md5.js@1.3.5: + dependencies: + hash-base: 3.1.0 + inherits: 2.0.4 + safe-buffer: 5.2.1 + mdast-util-to-hast@13.2.0: dependencies: '@types/hast': 3.0.4 @@ -21140,6 +22915,42 @@ snapshots: micromark-util-types@2.0.2: {} + micromatch@2.3.11: + dependencies: + arr-diff: 2.0.0 + array-unique: 0.2.1 + braces: 1.8.5 + expand-brackets: 0.1.5 + extglob: 0.3.2 + filename-regex: 2.0.1 + is-extglob: 1.0.0 + is-glob: 2.0.1 + kind-of: 3.2.2 + normalize-path: 2.1.1 + object.omit: 2.0.1 + parse-glob: 3.0.4 + regex-cache: 0.4.4 + optional: true + + micromatch@3.1.10: + dependencies: + arr-diff: 4.0.0 + array-unique: 0.3.2 + braces: 2.3.2 + define-property: 2.0.2 + extend-shallow: 3.0.2 + extglob: 2.0.4 + fragment-cache: 0.2.1 + kind-of: 6.0.3 + nanomatch: 1.2.13 + object.pick: 1.3.0 + regex-not: 1.0.2 + snapdragon: 0.8.2 + to-regex: 3.0.2 + transitivePeerDependencies: + - supports-color + optional: true + micromatch@4.0.8: dependencies: braces: 3.0.3 @@ -21180,6 +22991,10 @@ snapshots: dependencies: brace-expansion: 2.0.1 + minimatch@3.0.4: + dependencies: + brace-expansion: 1.1.11 + minimatch@3.1.2: dependencies: brace-expansion: 1.1.11 @@ -21202,8 +23017,7 @@ snapshots: is-plain-obj: 1.1.0 kind-of: 6.0.3 - minimist@0.0.8: - optional: true + minimist@0.0.8: {} minimist@1.2.8: {} @@ -21253,6 +23067,12 @@ snapshots: mitt@3.0.1: {} + mixin-deep@1.3.2: + dependencies: + for-in: 1.0.2 + is-extendable: 1.0.1 + optional: true + mkdirp-classic@0.5.3: {} mkdirp2@1.0.5: {} @@ -21260,7 +23080,6 @@ snapshots: mkdirp@0.5.1: dependencies: minimist: 0.0.8 - optional: true mkdirp@0.5.6: dependencies: @@ -21316,6 +23135,20 @@ snapshots: supports-color: 4.4.0 optional: true + mocha@5.2.0: + dependencies: + browser-stdout: 1.3.1 + commander: 2.15.1 + debug: 3.1.0(supports-color@5.4.0) + diff: 3.5.0 + escape-string-regexp: 1.0.5 + glob: 7.1.2 + growl: 1.10.5 + he: 1.1.1 + minimatch: 3.0.4 + mkdirp: 0.5.1 + supports-color: 5.4.0 + mockdate@3.0.5: {} moment-timezone@0.5.47: @@ -21386,7 +23219,7 @@ snapshots: eslint: 7.32.0 eslint-config-prettier: 8.10.0(eslint@7.32.0) eslint-plugin-node: 11.1.0(eslint@7.32.0) - eslint-plugin-prettier: 3.4.1(eslint-config-prettier@8.10.0(eslint@7.32.0))(eslint@7.32.0)(prettier@2.8.8) + eslint-plugin-prettier: 3.4.1(eslint-config-prettier@8.10.0(eslint@8.57.0))(eslint@7.32.0)(prettier@2.8.8) execa: 5.1.1 inquirer: 7.3.3 json5: 2.2.3 @@ -21436,6 +23269,23 @@ snapshots: nanoid@5.1.3: {} + nanomatch@1.2.13: + dependencies: + arr-diff: 4.0.0 + array-unique: 0.3.2 + define-property: 2.0.2 + extend-shallow: 3.0.2 + fragment-cache: 0.2.1 + is-windows: 1.0.2 + kind-of: 6.0.3 + object.pick: 1.3.0 + regex-not: 1.0.2 + snapdragon: 0.8.2 + to-regex: 3.0.2 + transitivePeerDependencies: + - supports-color + optional: true + nanopop@2.4.2: {} napi-build-utils@2.0.0: {} @@ -21464,6 +23314,8 @@ snapshots: next-tick@1.1.0: {} + nice-try@1.0.5: {} + no-case@3.0.4: dependencies: lower-case: 2.0.2 @@ -21554,6 +23406,11 @@ snapshots: semver: 7.7.1 validate-npm-package-license: 3.0.4 + normalize-path@2.1.1: + dependencies: + remove-trailing-separator: 1.1.0 + optional: true + normalize-path@3.0.0: {} normalize-range@0.1.2: {} @@ -21634,6 +23491,13 @@ snapshots: object-assign@4.1.1: {} + object-copy@0.1.0: + dependencies: + copy-descriptor: 0.1.1 + define-property: 0.2.5 + kind-of: 3.2.2 + optional: true + object-get@2.1.1: {} object-hash@2.2.0: {} @@ -21651,6 +23515,11 @@ snapshots: object-to-spawn-args@2.0.1: {} + object-visit@1.0.1: + dependencies: + isobject: 3.0.1 + optional: true + object.assign@4.1.7: dependencies: call-bind: 1.0.8 @@ -21673,6 +23542,17 @@ snapshots: define-properties: 1.2.1 es-abstract: 1.23.9 + object.omit@2.0.1: + dependencies: + for-own: 0.1.5 + is-extendable: 0.1.1 + optional: true + + object.pick@1.3.0: + dependencies: + isobject: 3.0.1 + optional: true + object.values@1.2.1: dependencies: call-bind: 1.0.8 @@ -21750,6 +23630,8 @@ snapshots: type-check: 0.4.0 word-wrap: 1.2.5 + os-homedir@1.0.2: {} + os-name@1.0.3: dependencies: osx-release: 1.1.0 @@ -21761,6 +23643,12 @@ snapshots: dependencies: minimist: 1.2.8 + output-file-sync@1.1.2: + dependencies: + graceful-fs: 4.2.11 + mkdirp: 0.5.6 + object-assign: 4.1.1 + own-keys@1.0.1: dependencies: get-intrinsic: 1.3.0 @@ -21883,6 +23771,14 @@ snapshots: just-diff: 6.0.2 just-diff-apply: 5.5.0 + parse-glob@3.0.4: + dependencies: + glob-base: 0.3.0 + is-dotfile: 1.0.3 + is-extglob: 1.0.0 + is-glob: 2.0.1 + optional: true + parse-json@5.2.0: dependencies: '@babel/code-frame': 7.26.2 @@ -21922,6 +23818,9 @@ snapshots: no-case: 3.0.4 tslib: 2.8.1 + pascalcase@0.1.1: + optional: true + path-browserify@1.0.1: {} path-exists@3.0.0: {} @@ -21932,6 +23831,8 @@ snapshots: path-is-absolute@1.0.1: {} + path-key@2.0.1: {} + path-key@3.1.1: {} path-key@4.0.0: {} @@ -22079,6 +23980,9 @@ snapshots: pngjs@5.0.0: {} + posix-character-classes@0.1.1: + optional: true + possible-typed-array-names@1.1.0: {} postcss-antd-fixes@0.2.0(postcss@8.5.3): @@ -22547,6 +24451,9 @@ snapshots: prepend-http@2.0.0: {} + preserve@0.2.0: + optional: true + prettier-linter-helpers@1.0.0: dependencies: fast-diff: 1.3.0 @@ -22574,6 +24481,8 @@ snapshots: prismjs@1.29.0: {} + private@0.1.8: {} + proc-log@4.2.0: {} process-nextick-args@2.0.1: {} @@ -22658,6 +24567,8 @@ snapshots: punycode.js@2.3.1: {} + punycode@1.4.1: {} + punycode@2.3.1: {} pupa@2.1.1: @@ -22760,6 +24671,13 @@ snapshots: ramda@0.27.2: {} + randomatic@3.1.1: + dependencies: + is-number: 4.0.0 + kind-of: 6.0.3 + math-random: 1.0.4 + optional: true + randombytes@2.1.0: dependencies: safe-buffer: 5.2.1 @@ -22888,6 +24806,15 @@ snapshots: dependencies: readable-stream: 4.7.0 + readdirp@2.2.1: + dependencies: + graceful-fs: 4.2.11 + micromatch: 3.1.10 + readable-stream: 2.3.8 + transitivePeerDependencies: + - supports-color + optional: true + readdirp@3.6.0: dependencies: picomatch: 2.3.1 @@ -22943,12 +24870,33 @@ snapshots: regenerate@1.4.2: {} + regenerator-runtime@0.10.5: {} + + regenerator-runtime@0.11.1: {} + regenerator-runtime@0.14.1: {} + regenerator-transform@0.10.1: + dependencies: + babel-runtime: 6.26.0 + babel-types: 6.26.0 + private: 0.1.8 + regenerator-transform@0.15.2: dependencies: '@babel/runtime': 7.26.9 + regex-cache@0.4.4: + dependencies: + is-equal-shallow: 0.1.3 + optional: true + + regex-not@1.0.2: + dependencies: + extend-shallow: 3.0.2 + safe-regex: 1.1.0 + optional: true + regex-recursion@6.0.2: dependencies: regex-utilities: 2.3.0 @@ -22972,6 +24920,12 @@ snapshots: regexpp@3.2.0: {} + regexpu-core@2.0.0: + dependencies: + regenerate: 1.4.2 + regjsgen: 0.2.0 + regjsparser: 0.1.5 + regexpu-core@6.2.0: dependencies: regenerate: 1.4.2 @@ -22989,8 +24943,14 @@ snapshots: dependencies: rc: 1.2.8 + regjsgen@0.2.0: {} + regjsgen@0.8.0: {} + regjsparser@0.1.5: + dependencies: + jsesc: 0.5.0 + regjsparser@0.12.0: dependencies: jsesc: 3.0.2 @@ -22999,6 +24959,19 @@ snapshots: relateurl@0.2.7: {} + remove-trailing-separator@1.1.0: + optional: true + + repeat-element@1.1.4: + optional: true + + repeat-string@1.6.1: + optional: true + + repeating@2.0.1: + dependencies: + is-finite: 1.1.0 + request@2.88.2: dependencies: aws-sign2: 0.7.0 @@ -23047,6 +25020,9 @@ snapshots: http-errors: 1.6.3 path-is-absolute: 1.0.1 + resolve-url@0.2.1: + optional: true + resolve@1.22.10: dependencies: is-core-module: 2.16.1 @@ -23062,6 +25038,9 @@ snapshots: onetime: 5.1.2 signal-exit: 3.0.7 + ret@0.1.15: + optional: true + retry-request@7.0.2(encoding@0.1.13): dependencies: '@types/request': 2.48.12 @@ -23087,6 +25066,11 @@ snapshots: dependencies: glob: 10.4.5 + ripemd160@2.0.2: + dependencies: + hash-base: 3.1.0 + inherits: 2.0.4 + rollup-plugin-visualizer@5.14.0(rollup@3.29.5): dependencies: open: 8.4.2 @@ -23167,6 +25151,11 @@ snapshots: es-errors: 1.3.0 is-regex: 1.2.1 + safe-regex@1.1.0: + dependencies: + ret: 0.1.15 + optional: true + safe-regex@2.1.1: dependencies: regexp-tree: 0.1.27 @@ -23231,6 +25220,14 @@ snapshots: es-errors: 1.3.0 es-object-atoms: 1.1.1 + set-value@2.0.1: + dependencies: + extend-shallow: 2.0.1 + is-extendable: 0.1.1 + is-plain-object: 2.0.4 + split-string: 3.1.0 + optional: true + setimmediate@1.0.5: {} setprototypeof@1.1.0: {} @@ -23248,10 +25245,16 @@ snapshots: shallow-equal@1.2.1: {} + shebang-command@1.2.0: + dependencies: + shebang-regex: 1.0.0 + shebang-command@2.0.0: dependencies: shebang-regex: 3.0.0 + shebang-regex@1.0.0: {} + shebang-regex@3.0.0: {} shelljs@0.8.5: @@ -23360,6 +25363,8 @@ snapshots: sisteransi@1.0.5: {} + slash@1.0.0: {} + slash@3.0.0: {} slash@5.1.0: {} @@ -23400,6 +25405,32 @@ snapshots: snake-case: 3.0.4 type-fest: 4.37.0 + snapdragon-node@2.1.1: + dependencies: + define-property: 1.0.0 + isobject: 3.0.1 + snapdragon-util: 3.0.1 + optional: true + + snapdragon-util@3.0.1: + dependencies: + kind-of: 3.2.2 + optional: true + + snapdragon@0.8.2: + dependencies: + base: 0.11.2 + debug: 2.6.9 + define-property: 0.2.5 + extend-shallow: 2.0.1 + map-cache: 0.2.2 + source-map: 0.5.7 + source-map-resolve: 0.5.3 + use: 3.1.1 + transitivePeerDependencies: + - supports-color + optional: true + socks-proxy-agent@8.0.5: dependencies: agent-base: 7.1.3 @@ -23428,11 +25459,29 @@ snapshots: source-map-js@1.2.1: {} + source-map-resolve@0.5.3: + dependencies: + atob: 2.1.2 + decode-uri-component: 0.2.2 + resolve-url: 0.2.1 + source-map-url: 0.4.1 + urix: 0.1.0 + optional: true + + source-map-support@0.4.18: + dependencies: + source-map: 0.5.7 + source-map-support@0.5.21: dependencies: buffer-from: 1.1.2 source-map: 0.6.1 + source-map-url@0.4.1: + optional: true + + source-map@0.5.7: {} + source-map@0.6.1: {} source-map@0.7.4: {} @@ -23457,6 +25506,11 @@ snapshots: speakingurl@14.0.1: {} + split-string@3.1.0: + dependencies: + extend-shallow: 3.0.2 + optional: true + split2@3.2.2: dependencies: readable-stream: 3.6.2 @@ -23513,6 +25567,12 @@ snapshots: stackback@0.0.2: {} + static-extend@0.1.2: + dependencies: + define-property: 0.2.5 + object-copy: 0.1.0 + optional: true + statuses@1.5.0: {} statuses@2.0.1: {} @@ -23609,6 +25669,10 @@ snapshots: character-entities-html4: 2.1.0 character-entities-legacy: 3.0.0 + strip-ansi@3.0.1: + dependencies: + ansi-regex: 2.1.1 + strip-ansi@6.0.1: dependencies: ansi-regex: 5.0.1 @@ -23771,11 +25835,17 @@ snapshots: transitivePeerDependencies: - supports-color + supports-color@2.0.0: {} + supports-color@4.4.0: dependencies: has-flag: 2.0.0 optional: true + supports-color@5.4.0: + dependencies: + has-flag: 3.0.0 + supports-color@5.5.0: dependencies: has-flag: 3.0.0 @@ -24021,12 +26091,33 @@ snapshots: to-arraybuffer@1.0.1: {} + to-fast-properties@1.0.3: {} + + to-object-path@0.3.0: + dependencies: + kind-of: 3.2.2 + optional: true + to-readable-stream@1.0.0: {} + to-regex-range@2.1.1: + dependencies: + is-number: 3.0.0 + repeat-string: 1.6.1 + optional: true + to-regex-range@5.0.1: dependencies: is-number: 7.0.0 + to-regex@3.0.2: + dependencies: + define-property: 2.0.2 + extend-shallow: 3.0.2 + regex-not: 1.0.2 + safe-regex: 1.1.0 + optional: true + toidentifier@1.0.1: {} token-types@4.2.1: @@ -24049,6 +26140,8 @@ snapshots: trim-newlines@4.1.1: {} + trim-right@1.0.1: {} + ts-api-utils@1.4.3(typescript@5.8.2): dependencies: typescript: 5.8.2 @@ -24343,6 +26436,14 @@ snapshots: unplugin: 2.2.0 unplugin-utils: 0.2.4 + union-value@1.0.1: + dependencies: + arr-union: 3.1.0 + get-value: 2.0.6 + is-extendable: 0.1.1 + set-value: 2.0.1 + optional: true + unique-filename@3.0.0: dependencies: unique-slug: 4.0.0 @@ -24409,6 +26510,12 @@ snapshots: acorn: 8.14.1 webpack-virtual-modules: 0.6.2 + unset-value@1.0.0: + dependencies: + has-value: 0.3.1 + isobject: 3.0.1 + optional: true + untildify@4.0.0: {} untyped@2.0.0: @@ -24448,12 +26555,20 @@ snapshots: dependencies: punycode: 2.3.1 + urix@0.1.0: + optional: true + url-join@4.0.1: {} url-parse-lax@3.0.0: dependencies: prepend-http: 2.0.0 + url@0.11.4: + dependencies: + punycode: 1.4.1 + qs: 6.14.0 + urlencode@1.1.0: dependencies: iconv-lite: 0.4.24 @@ -24483,6 +26598,11 @@ snapshots: undici: 7.4.0 ylru: 2.0.0 + use@3.1.1: + optional: true + + user-home@1.1.1: {} + util-deprecate@1.0.2: {} utility@1.18.0: @@ -24519,6 +26639,10 @@ snapshots: '@types/istanbul-lib-coverage': 2.0.6 convert-source-map: 2.0.0 + v8flags@2.1.1: + dependencies: + user-home: 1.1.1 + validate-npm-package-license@3.0.4: dependencies: spdx-correct: 3.2.0