text: /*
   * 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
  