# frozen_string_literal: true # Copyright (c) 2017-2018 THL A29 Limited, a Tencent company. All Rights Reserved. # # 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. require 'json' module TencentCloud module Mongodb module V20180408 class Client < TencentCloud::Common::AbstractClient def initialize(credential, region, profile = nil) api_version = '2018-04-08' api_endpoint = 'mongodb.tencentcloudapi.com' sdk_version = 'MONGODB_' + File.read(File.expand_path('../VERSION', __dir__)).strip super(credential, region, api_version, api_endpoint, sdk_version, profile) end # 本接口(AssignProject)用于指定云数据库实例的所属项目。 # @param request: Request instance for AssignProject. # @type request: :class:`Tencentcloud::mongodb::V20180408::AssignProjectRequest` # @rtype: :class:`Tencentcloud::mongodb::V20180408::AssignProjectResponse` def AssignProject(request) body = send_request('AssignProject', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = AssignProjectResponse.new model.deserialize(response['Response']) model else code = response['Response']['Error']['Code'] message = response['Response']['Error']['Message'] reqid = response['Response']['RequestId'] raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid) end rescue TencentCloud::Common::TencentCloudSDKException => e raise e rescue StandardError => e raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect) end # 本接口(CreateDBInstance)用于创建包年包月的MongoDB云数据库实例。 # @param request: Request instance for CreateDBInstance. # @type request: :class:`Tencentcloud::mongodb::V20180408::CreateDBInstanceRequest` # @rtype: :class:`Tencentcloud::mongodb::V20180408::CreateDBInstanceResponse` def CreateDBInstance(request) body = send_request('CreateDBInstance', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = CreateDBInstanceResponse.new model.deserialize(response['Response']) model else code = response['Response']['Error']['Code'] message = response['Response']['Error']['Message'] reqid = response['Response']['RequestId'] raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid) end rescue TencentCloud::Common::TencentCloudSDKException => e raise e rescue StandardError => e raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect) end # 本接口(CreateDBInstanceHour)用于创建按量计费的MongoDB云数据库实例(包括主实例、灾备实例和只读实例),可通过传入实例规格、实例类型、MongoDB版本、购买时长和数量等信息创建云数据库实例。 # @param request: Request instance for CreateDBInstanceHour. # @type request: :class:`Tencentcloud::mongodb::V20180408::CreateDBInstanceHourRequest` # @rtype: :class:`Tencentcloud::mongodb::V20180408::CreateDBInstanceHourResponse` def CreateDBInstanceHour(request) body = send_request('CreateDBInstanceHour', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = CreateDBInstanceHourResponse.new model.deserialize(response['Response']) model else code = response['Response']['Error']['Code'] message = response['Response']['Error']['Message'] reqid = response['Response']['RequestId'] raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid) end rescue TencentCloud::Common::TencentCloudSDKException => e raise e rescue StandardError => e raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect) end # 本接口(DescribeClientConnections)用于查询实例客户端连接信息,包括连接IP和连接数量。目前只支持3.2版本的MongoDB实例。 # @param request: Request instance for DescribeClientConnections. # @type request: :class:`Tencentcloud::mongodb::V20180408::DescribeClientConnectionsRequest` # @rtype: :class:`Tencentcloud::mongodb::V20180408::DescribeClientConnectionsResponse` def DescribeClientConnections(request) body = send_request('DescribeClientConnections', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = DescribeClientConnectionsResponse.new model.deserialize(response['Response']) model else code = response['Response']['Error']['Code'] message = response['Response']['Error']['Message'] reqid = response['Response']['RequestId'] raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid) end rescue TencentCloud::Common::TencentCloudSDKException => e raise e rescue StandardError => e raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect) end # 本接口(DescribeDBInstances)用于查询云数据库实例列表,支持通过项目ID、实例ID、实例状态等过滤条件来筛选实例。支持查询主实例、灾备实例和只读实例信息列表。 # @param request: Request instance for DescribeDBInstances. # @type request: :class:`Tencentcloud::mongodb::V20180408::DescribeDBInstancesRequest` # @rtype: :class:`Tencentcloud::mongodb::V20180408::DescribeDBInstancesResponse` def DescribeDBInstances(request) body = send_request('DescribeDBInstances', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = DescribeDBInstancesResponse.new model.deserialize(response['Response']) model else code = response['Response']['Error']['Code'] message = response['Response']['Error']['Message'] reqid = response['Response']['RequestId'] raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid) end rescue TencentCloud::Common::TencentCloudSDKException => e raise e rescue StandardError => e raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect) end # 本接口(DescribeSlowLogs)用于获取云数据库实例的慢查询日志。 # @param request: Request instance for DescribeSlowLog. # @type request: :class:`Tencentcloud::mongodb::V20180408::DescribeSlowLogRequest` # @rtype: :class:`Tencentcloud::mongodb::V20180408::DescribeSlowLogResponse` def DescribeSlowLog(request) body = send_request('DescribeSlowLog', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = DescribeSlowLogResponse.new model.deserialize(response['Response']) model else code = response['Response']['Error']['Code'] message = response['Response']['Error']['Message'] reqid = response['Response']['RequestId'] raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid) end rescue TencentCloud::Common::TencentCloudSDKException => e raise e rescue StandardError => e raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect) end # 本接口(DescribeSpecInfo)用于查询实例的售卖规格。 # @param request: Request instance for DescribeSpecInfo. # @type request: :class:`Tencentcloud::mongodb::V20180408::DescribeSpecInfoRequest` # @rtype: :class:`Tencentcloud::mongodb::V20180408::DescribeSpecInfoResponse` def DescribeSpecInfo(request) body = send_request('DescribeSpecInfo', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = DescribeSpecInfoResponse.new model.deserialize(response['Response']) model else code = response['Response']['Error']['Code'] message = response['Response']['Error']['Message'] reqid = response['Response']['RequestId'] raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid) end rescue TencentCloud::Common::TencentCloudSDKException => e raise e rescue StandardError => e raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect) end # 本接口(RenameInstance)用于修改云数据库实例的名称。 # @param request: Request instance for RenameInstance. # @type request: :class:`Tencentcloud::mongodb::V20180408::RenameInstanceRequest` # @rtype: :class:`Tencentcloud::mongodb::V20180408::RenameInstanceResponse` def RenameInstance(request) body = send_request('RenameInstance', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = RenameInstanceResponse.new model.deserialize(response['Response']) model else code = response['Response']['Error']['Code'] message = response['Response']['Error']['Message'] reqid = response['Response']['RequestId'] raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid) end rescue TencentCloud::Common::TencentCloudSDKException => e raise e rescue StandardError => e raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect) end # 本接口(SetAutoRenew)用于设置包年包月云数据库实例的续费选项。 # @param request: Request instance for SetAutoRenew. # @type request: :class:`Tencentcloud::mongodb::V20180408::SetAutoRenewRequest` # @rtype: :class:`Tencentcloud::mongodb::V20180408::SetAutoRenewResponse` def SetAutoRenew(request) body = send_request('SetAutoRenew', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = SetAutoRenewResponse.new model.deserialize(response['Response']) model else code = response['Response']['Error']['Code'] message = response['Response']['Error']['Message'] reqid = response['Response']['RequestId'] raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid) end rescue TencentCloud::Common::TencentCloudSDKException => e raise e rescue StandardError => e raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect) end # 本接口(SetPassword)用于设置云数据库账户的密码。 # @param request: Request instance for SetPassword. # @type request: :class:`Tencentcloud::mongodb::V20180408::SetPasswordRequest` # @rtype: :class:`Tencentcloud::mongodb::V20180408::SetPasswordResponse` def SetPassword(request) body = send_request('SetPassword', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = SetPasswordResponse.new model.deserialize(response['Response']) model else code = response['Response']['Error']['Code'] message = response['Response']['Error']['Message'] reqid = response['Response']['RequestId'] raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid) end rescue TencentCloud::Common::TencentCloudSDKException => e raise e rescue StandardError => e raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect) end # 本接口(TerminateDBInstance)用于销毁按量计费的MongoDB云数据库实例 # @param request: Request instance for TerminateDBInstance. # @type request: :class:`Tencentcloud::mongodb::V20180408::TerminateDBInstanceRequest` # @rtype: :class:`Tencentcloud::mongodb::V20180408::TerminateDBInstanceResponse` def TerminateDBInstance(request) body = send_request('TerminateDBInstance', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = TerminateDBInstanceResponse.new model.deserialize(response['Response']) model else code = response['Response']['Error']['Code'] message = response['Response']['Error']['Message'] reqid = response['Response']['RequestId'] raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid) end rescue TencentCloud::Common::TencentCloudSDKException => e raise e rescue StandardError => e raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect) end # 本接口(UpgradeDBInstance)用于升级包年包月的MongoDB云数据库实例,可以扩容内存、存储以及Oplog # @param request: Request instance for UpgradeDBInstance. # @type request: :class:`Tencentcloud::mongodb::V20180408::UpgradeDBInstanceRequest` # @rtype: :class:`Tencentcloud::mongodb::V20180408::UpgradeDBInstanceResponse` def UpgradeDBInstance(request) body = send_request('UpgradeDBInstance', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = UpgradeDBInstanceResponse.new model.deserialize(response['Response']) model else code = response['Response']['Error']['Code'] message = response['Response']['Error']['Message'] reqid = response['Response']['RequestId'] raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid) end rescue TencentCloud::Common::TencentCloudSDKException => e raise e rescue StandardError => e raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect) end # 本接口(UpgradeDBInstanceHour)用于升级按量计费的MongoDB云数据库实例,可以扩容内存、存储以及oplog # @param request: Request instance for UpgradeDBInstanceHour. # @type request: :class:`Tencentcloud::mongodb::V20180408::UpgradeDBInstanceHourRequest` # @rtype: :class:`Tencentcloud::mongodb::V20180408::UpgradeDBInstanceHourResponse` def UpgradeDBInstanceHour(request) body = send_request('UpgradeDBInstanceHour', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = UpgradeDBInstanceHourResponse.new model.deserialize(response['Response']) model else code = response['Response']['Error']['Code'] message = response['Response']['Error']['Message'] reqid = response['Response']['RequestId'] raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid) end rescue TencentCloud::Common::TencentCloudSDKException => e raise e rescue StandardError => e raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect) end end end end end