# 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 Organization module V20210331 class Client < TencentCloud::Common::AbstractClient def initialize(credential, region, profile = nil) api_version = '2021-03-31' api_endpoint = 'organization.tencentcloudapi.com' sdk_version = 'ORGANIZATION_' + File.read(File.expand_path('../VERSION', __dir__)).strip super(credential, region, api_version, api_endpoint, sdk_version, profile) end # 添加企业组织节点 # @param request: Request instance for AddOrganizationNode. # @type request: :class:`Tencentcloud::organization::V20210331::AddOrganizationNodeRequest` # @rtype: :class:`Tencentcloud::organization::V20210331::AddOrganizationNodeResponse` def AddOrganizationNode(request) body = send_request('AddOrganizationNode', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = AddOrganizationNodeResponse.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 BindOrganizationMemberAuthAccount. # @type request: :class:`Tencentcloud::organization::V20210331::BindOrganizationMemberAuthAccountRequest` # @rtype: :class:`Tencentcloud::organization::V20210331::BindOrganizationMemberAuthAccountResponse` def BindOrganizationMemberAuthAccount(request) body = send_request('BindOrganizationMemberAuthAccount', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = BindOrganizationMemberAuthAccountResponse.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 CancelOrganizationMemberAuthAccount. # @type request: :class:`Tencentcloud::organization::V20210331::CancelOrganizationMemberAuthAccountRequest` # @rtype: :class:`Tencentcloud::organization::V20210331::CancelOrganizationMemberAuthAccountResponse` def CancelOrganizationMemberAuthAccount(request) body = send_request('CancelOrganizationMemberAuthAccount', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = CancelOrganizationMemberAuthAccountResponse.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 CreateOrganizationMember. # @type request: :class:`Tencentcloud::organization::V20210331::CreateOrganizationMemberRequest` # @rtype: :class:`Tencentcloud::organization::V20210331::CreateOrganizationMemberResponse` def CreateOrganizationMember(request) body = send_request('CreateOrganizationMember', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = CreateOrganizationMemberResponse.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 CreateOrganizationMemberPolicy. # @type request: :class:`Tencentcloud::organization::V20210331::CreateOrganizationMemberPolicyRequest` # @rtype: :class:`Tencentcloud::organization::V20210331::CreateOrganizationMemberPolicyResponse` def CreateOrganizationMemberPolicy(request) body = send_request('CreateOrganizationMemberPolicy', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = CreateOrganizationMemberPolicyResponse.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 DeleteOrganizationMembers. # @type request: :class:`Tencentcloud::organization::V20210331::DeleteOrganizationMembersRequest` # @rtype: :class:`Tencentcloud::organization::V20210331::DeleteOrganizationMembersResponse` def DeleteOrganizationMembers(request) body = send_request('DeleteOrganizationMembers', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = DeleteOrganizationMembersResponse.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 DeleteOrganizationNodes. # @type request: :class:`Tencentcloud::organization::V20210331::DeleteOrganizationNodesRequest` # @rtype: :class:`Tencentcloud::organization::V20210331::DeleteOrganizationNodesResponse` def DeleteOrganizationNodes(request) body = send_request('DeleteOrganizationNodes', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = DeleteOrganizationNodesResponse.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 DescribeOrganization. # @type request: :class:`Tencentcloud::organization::V20210331::DescribeOrganizationRequest` # @rtype: :class:`Tencentcloud::organization::V20210331::DescribeOrganizationResponse` def DescribeOrganization(request) body = send_request('DescribeOrganization', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = DescribeOrganizationResponse.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 DescribeOrganizationAuthNode. # @type request: :class:`Tencentcloud::organization::V20210331::DescribeOrganizationAuthNodeRequest` # @rtype: :class:`Tencentcloud::organization::V20210331::DescribeOrganizationAuthNodeResponse` def DescribeOrganizationAuthNode(request) body = send_request('DescribeOrganizationAuthNode', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = DescribeOrganizationAuthNodeResponse.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 DescribeOrganizationMemberAuthAccounts. # @type request: :class:`Tencentcloud::organization::V20210331::DescribeOrganizationMemberAuthAccountsRequest` # @rtype: :class:`Tencentcloud::organization::V20210331::DescribeOrganizationMemberAuthAccountsResponse` def DescribeOrganizationMemberAuthAccounts(request) body = send_request('DescribeOrganizationMemberAuthAccounts', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = DescribeOrganizationMemberAuthAccountsResponse.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 DescribeOrganizationMemberAuthIdentities. # @type request: :class:`Tencentcloud::organization::V20210331::DescribeOrganizationMemberAuthIdentitiesRequest` # @rtype: :class:`Tencentcloud::organization::V20210331::DescribeOrganizationMemberAuthIdentitiesResponse` def DescribeOrganizationMemberAuthIdentities(request) body = send_request('DescribeOrganizationMemberAuthIdentities', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = DescribeOrganizationMemberAuthIdentitiesResponse.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 DescribeOrganizationMemberPolicies. # @type request: :class:`Tencentcloud::organization::V20210331::DescribeOrganizationMemberPoliciesRequest` # @rtype: :class:`Tencentcloud::organization::V20210331::DescribeOrganizationMemberPoliciesResponse` def DescribeOrganizationMemberPolicies(request) body = send_request('DescribeOrganizationMemberPolicies', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = DescribeOrganizationMemberPoliciesResponse.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 DescribeOrganizationMembers. # @type request: :class:`Tencentcloud::organization::V20210331::DescribeOrganizationMembersRequest` # @rtype: :class:`Tencentcloud::organization::V20210331::DescribeOrganizationMembersResponse` def DescribeOrganizationMembers(request) body = send_request('DescribeOrganizationMembers', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = DescribeOrganizationMembersResponse.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 DescribeOrganizationNodes. # @type request: :class:`Tencentcloud::organization::V20210331::DescribeOrganizationNodesRequest` # @rtype: :class:`Tencentcloud::organization::V20210331::DescribeOrganizationNodesResponse` def DescribeOrganizationNodes(request) body = send_request('DescribeOrganizationNodes', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = DescribeOrganizationNodesResponse.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 ListOrganizationIdentity. # @type request: :class:`Tencentcloud::organization::V20210331::ListOrganizationIdentityRequest` # @rtype: :class:`Tencentcloud::organization::V20210331::ListOrganizationIdentityResponse` def ListOrganizationIdentity(request) body = send_request('ListOrganizationIdentity', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = ListOrganizationIdentityResponse.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 MoveOrganizationNodeMembers. # @type request: :class:`Tencentcloud::organization::V20210331::MoveOrganizationNodeMembersRequest` # @rtype: :class:`Tencentcloud::organization::V20210331::MoveOrganizationNodeMembersResponse` def MoveOrganizationNodeMembers(request) body = send_request('MoveOrganizationNodeMembers', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = MoveOrganizationNodeMembersResponse.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 UpdateOrganizationNode. # @type request: :class:`Tencentcloud::organization::V20210331::UpdateOrganizationNodeRequest` # @rtype: :class:`Tencentcloud::organization::V20210331::UpdateOrganizationNodeResponse` def UpdateOrganizationNode(request) body = send_request('UpdateOrganizationNode', request.serialize) response = JSON.parse(body) if response['Response'].key?('Error') == false model = UpdateOrganizationNodeResponse.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