华为云会议室管理典型场景_Python
引导式阅读
Python
华为云会议室管理典型场景_Python
作者
C***
上架时间
2023-11-16 06:28:05

华为云会议室管理典型场景_Python

0. 版本说明

本示例基于华为云SDK V3.0版本开发。

1. 介绍

华为云会议室管理介绍

华为云会议的Pyton SDK(huaweicloudsdkmeeting)开放了会议室管理接口,用于与第三方的业务系统集成。可以实现云会议室的分配、回收、查询等操作。开放的接口支持如下功能:

功能 方法名
分配云会议室 associate_vmr
回收云会议室 disassociate_vmr
删除云会议室 delete_corpVmr
管理员查询企业云会议室 search_corp_vmr
用户查询云会议及个人会议ID search_member_vmr
修改云会议室级个人会议ID信息 update_member_vmr

2.开发前准备

  • 申请华为云账号
  • 申请华为云会议测试资源
  • 获取华为云会议的管理员帐号和密码

具体操作步骤,请参考:开发前准备

3.问题求助通道:

4.安装SDK:

在使用华为云会议服务端SDK前,您需要安装“huaweicloudsdkcore”和“huaweicloudsdkmeeting”。

pip install huaweicloudsdkcore pip install huaweicloudsdkmeeting

5. 开始使用

接口调用概览

图1 华为云会议室管理典型场景的接口调用时序图

步骤1:创建SDK client

描述

根据华为云会议管理员帐号和密码创建SDK client。 说明:

  • 华为云会议不是使用IMA的AK、SK方式鉴权,需要单独申请华为云会议的管理员帐号。
  • 中国站的endpoint是api.meeting.huaweicloud.com;国际站的endpoint是api-intl.meeting.huaweicloud.com
示例代码
# coding: utf-8 from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkmeeting.v1 import * from huaweicloudsdkmeeting.v1.meeting_credentials import MeetingCredentials import os def create_client(): try: # 认证用的账号和密码直接写到代码中有很大的安全风险,建议在配置文件或者环境变量中密文存放,使用时解密,确保安全; # 本示例以账号和密码保存在环境变量中来实现身份验证为例,运行本示例前请先在本地环境中设置环境变量YOUR_MANAGER_ACCOUNT和YOUR_PASSWORD。 username = os.environ["YOUR_MANAGER_ACCOUNT"] password = os.environ["YOUR_PASSWORD"] credentials = MeetingCredentials(username, password) client = MeetingClient.new_builder() \ .with_credentials(credentials) \ .with_endpoint("api.meeting.huaweicloud.com") \ .build() return client except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)

步骤2:管理员查询企业的云会议室

描述

管理员帐号,使用步骤1生成的client中的search_corp_vmr方法可以查询企业的所有云会议室资源。

示例代码
# coding: utf-8 from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkmeeting.v1 import * from create_client import create_client def search_corp_vmr(client=None): try: request = SearchCorpVmrRequest() response = client.search_corp_vmr(request) vmr_list = [] for vmr in response.data: vmr_tmp = { "vmr_id": vmr.id, "account_id": "", "status": vmr.status } if vmr.status == 0: vmr_tmp["account_id"] = vmr.member.id vmr_list.append(vmr_tmp) return vmr_list except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) if __name__ == "__main__": client = create_client() vmr_list = search_corp_vmr(client) print(vmr_list)

步骤3:用户查询云会议室和个人会议ID

描述

普通用户帐号,使用步骤1生成的client中的search_member_vmr方法可以查询该用户的云会议室及个人会议ID。

示例代码
# coding: utf-8 from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkmeeting.v1 import * from create_client import create_client def search_member_vmr(client=None): try: request = SearchMemberVmrRequest(special_vmr=True) response = client.search_member_vmr(request) vmr_id_list = [] for vmr in response.data: vmr_id_list.append(vmr.id) return vmr_id_list except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) if __name__ == "__main__": client = create_client() vmr_id_list = search_member_vmr(client) print(vmr_id_list)

步骤4:分配云会议室

描述

用户帐号上绑定云会议室ID后才能创建云会议的会议。

示例代码
# coding: utf-8 from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkmeeting.v1 import * from create_client import create_client from search_corp_vmr import search_corp_vmr from dept_user.show_my_info import show_my_info def associate_vmr(client=None, vmr_id=None, account=None): try: body = [vmr["vmr_id"]] request = AssociateVmrRequest(account=account, body=body) response = client.associate_vmr(request) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) if __name__ == "__main__": client = create_client() vmr_list = search_corp_vmr(client) my_info = show_my_info(client) for vmr in vmr_list: if vmr["status"] == 2: associate_vmr(client, vmr["vmr_id"], my_info.user_account) break

步骤4:回收云会议室

描述

云会议室资源需要绑定到其他帐号上前,需要从原来的帐号上回收云会议室资源。

示例代码
# coding: utf-8 from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkmeeting.v1 import * from create_client import create_client from search_corp_vmr import search_corp_vmr def disassociate_vmr(client=None, vmr=None): try: body = [vmr["vmr_id"]] request = DisassociateVmrRequest(account=vmr["account_id"], body=body) response = client.disassociate_vmr(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) if __name__ == "__main__": client = create_client() vmr_list = search_corp_vmr(client) for vmr in vmr_list: if vmr["status"] == 0: disassociate_vmr(client, vmr)

6.参考文件

7.修订记录

发布日期 文档版本 修订说明
2021-07-31 1.0 文档首次发布