# 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 Cloudaudit module V20190319 class Client < TencentCloud::Common::AbstractClient def initialize(credential, region, profile = nil) api_version = '2019-03-19' api_endpoint = 'cloudaudit.tencentcloudapi.com' sdk_version = 'CLOUDAUDIT_' + File.read(File.expand_path('../VERSION', __dir__)).strip super(credential, region, api_version, api_endpoint, sdk_version, profile) end # 创建操作审计跟踪集 # @param request: Request instance for CreateAuditTrack. # @type request: :class:`Tencentcloud::cloudaudit::V20190319::CreateAuditTrackRequest` # @rtype: :class:`Tencentcloud::cloudaudit::V20190319::CreateAuditTrackResponse` def CreateAuditTrack(request) body = send_request('CreateAuditTrack', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = CreateAuditTrackResponse.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 # 创建操作审计跟踪集 # @param request: Request instance for CreateEventsAuditTrack. # @type request: :class:`Tencentcloud::cloudaudit::V20190319::CreateEventsAuditTrackRequest` # @rtype: :class:`Tencentcloud::cloudaudit::V20190319::CreateEventsAuditTrackResponse` def CreateEventsAuditTrack(request) body = send_request('CreateEventsAuditTrack', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = CreateEventsAuditTrackResponse.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 # 删除操作审计跟踪集 # @param request: Request instance for DeleteAuditTrack. # @type request: :class:`Tencentcloud::cloudaudit::V20190319::DeleteAuditTrackRequest` # @rtype: :class:`Tencentcloud::cloudaudit::V20190319::DeleteAuditTrackResponse` def DeleteAuditTrack(request) body = send_request('DeleteAuditTrack', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = DeleteAuditTrackResponse.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 # 查询跟踪集详情 # @param request: Request instance for DescribeAudit. # @type request: :class:`Tencentcloud::cloudaudit::V20190319::DescribeAuditRequest` # @rtype: :class:`Tencentcloud::cloudaudit::V20190319::DescribeAuditResponse` def DescribeAudit(request) body = send_request('DescribeAudit', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = DescribeAuditResponse.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 # 查询操作审计跟踪集详情 # @param request: Request instance for DescribeAuditTrack. # @type request: :class:`Tencentcloud::cloudaudit::V20190319::DescribeAuditTrackRequest` # @rtype: :class:`Tencentcloud::cloudaudit::V20190319::DescribeAuditTrackResponse` def DescribeAuditTrack(request) body = send_request('DescribeAuditTrack', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = DescribeAuditTrackResponse.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 # 查询操作审计跟踪集列表 # @param request: Request instance for DescribeAuditTracks. # @type request: :class:`Tencentcloud::cloudaudit::V20190319::DescribeAuditTracksRequest` # @rtype: :class:`Tencentcloud::cloudaudit::V20190319::DescribeAuditTracksResponse` def DescribeAuditTracks(request) body = send_request('DescribeAuditTracks', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = DescribeAuditTracksResponse.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 # 查询操作审计日志 # @param request: Request instance for DescribeEvents. # @type request: :class:`Tencentcloud::cloudaudit::V20190319::DescribeEventsRequest` # @rtype: :class:`Tencentcloud::cloudaudit::V20190319::DescribeEventsResponse` def DescribeEvents(request) body = send_request('DescribeEvents', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = DescribeEventsResponse.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 # 查询AttributeKey的有效取值范围 # @param request: Request instance for GetAttributeKey. # @type request: :class:`Tencentcloud::cloudaudit::V20190319::GetAttributeKeyRequest` # @rtype: :class:`Tencentcloud::cloudaudit::V20190319::GetAttributeKeyResponse` def GetAttributeKey(request) body = send_request('GetAttributeKey', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = GetAttributeKeyResponse.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 # 查询用户可创建跟踪集的数量 # @param request: Request instance for InquireAuditCredit. # @type request: :class:`Tencentcloud::cloudaudit::V20190319::InquireAuditCreditRequest` # @rtype: :class:`Tencentcloud::cloudaudit::V20190319::InquireAuditCreditResponse` def InquireAuditCredit(request) body = send_request('InquireAuditCredit', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = InquireAuditCreditResponse.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 # 查询跟踪集概要 # @param request: Request instance for ListAudits. # @type request: :class:`Tencentcloud::cloudaudit::V20190319::ListAuditsRequest` # @rtype: :class:`Tencentcloud::cloudaudit::V20190319::ListAuditsResponse` def ListAudits(request) body = send_request('ListAudits', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = ListAuditsResponse.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 # 查询云审计支持的cmq的可用区 # @param request: Request instance for ListCmqEnableRegion. # @type request: :class:`Tencentcloud::cloudaudit::V20190319::ListCmqEnableRegionRequest` # @rtype: :class:`Tencentcloud::cloudaudit::V20190319::ListCmqEnableRegionResponse` def ListCmqEnableRegion(request) body = send_request('ListCmqEnableRegion', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = ListCmqEnableRegionResponse.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 # 查询云审计支持的cos可用区 # @param request: Request instance for ListCosEnableRegion. # @type request: :class:`Tencentcloud::cloudaudit::V20190319::ListCosEnableRegionRequest` # @rtype: :class:`Tencentcloud::cloudaudit::V20190319::ListCosEnableRegionResponse` def ListCosEnableRegion(request) body = send_request('ListCosEnableRegion', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = ListCosEnableRegionResponse.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 # 根据地域获取KMS密钥别名 # @param request: Request instance for ListKeyAliasByRegion. # @type request: :class:`Tencentcloud::cloudaudit::V20190319::ListKeyAliasByRegionRequest` # @rtype: :class:`Tencentcloud::cloudaudit::V20190319::ListKeyAliasByRegionResponse` def ListKeyAliasByRegion(request) body = send_request('ListKeyAliasByRegion', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = ListKeyAliasByRegionResponse.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 # 用于对操作日志进行检索,便于用户进行查询相关的操作信息。 # @param request: Request instance for LookUpEvents. # @type request: :class:`Tencentcloud::cloudaudit::V20190319::LookUpEventsRequest` # @rtype: :class:`Tencentcloud::cloudaudit::V20190319::LookUpEventsResponse` def LookUpEvents(request) body = send_request('LookUpEvents', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = LookUpEventsResponse.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 # 修改操作审计跟踪集 # @param request: Request instance for ModifyAuditTrack. # @type request: :class:`Tencentcloud::cloudaudit::V20190319::ModifyAuditTrackRequest` # @rtype: :class:`Tencentcloud::cloudaudit::V20190319::ModifyAuditTrackResponse` def ModifyAuditTrack(request) body = send_request('ModifyAuditTrack', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = ModifyAuditTrackResponse.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 # 修改操作审计跟踪集 # @param request: Request instance for ModifyEventsAuditTrack. # @type request: :class:`Tencentcloud::cloudaudit::V20190319::ModifyEventsAuditTrackRequest` # @rtype: :class:`Tencentcloud::cloudaudit::V20190319::ModifyEventsAuditTrackResponse` def ModifyEventsAuditTrack(request) body = send_request('ModifyEventsAuditTrack', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = ModifyEventsAuditTrackResponse.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 # 开启跟踪集 # @param request: Request instance for StartLogging. # @type request: :class:`Tencentcloud::cloudaudit::V20190319::StartLoggingRequest` # @rtype: :class:`Tencentcloud::cloudaudit::V20190319::StartLoggingResponse` def StartLogging(request) body = send_request('StartLogging', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = StartLoggingResponse.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 # 关闭跟踪集 # @param request: Request instance for StopLogging. # @type request: :class:`Tencentcloud::cloudaudit::V20190319::StopLoggingRequest` # @rtype: :class:`Tencentcloud::cloudaudit::V20190319::StopLoggingResponse` def StopLogging(request) body = send_request('StopLogging', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = StopLoggingResponse.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 # 参数要求: # 1、如果IsCreateNewBucket的值存在的话,cosRegion和cosBucketName都是必填参数。 # 2、如果IsEnableCmqNotify的值是1的话,IsCreateNewQueue、CmqRegion和CmqQueueName都是必填参数。 # 3、如果IsEnableCmqNotify的值是0的话,IsCreateNewQueue、CmqRegion和CmqQueueName都不能传。 # 4、如果IsEnableKmsEncry的值是1的话,KmsRegion和KeyId属于必填项 # @param request: Request instance for UpdateAudit. # @type request: :class:`Tencentcloud::cloudaudit::V20190319::UpdateAuditRequest` # @rtype: :class:`Tencentcloud::cloudaudit::V20190319::UpdateAuditResponse` def UpdateAudit(request) body = send_request('UpdateAudit', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = UpdateAuditResponse.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