# -*- coding: utf-8 -*-
# This file is auto-generated, don't edit it. Thanks.
import os
import sys
import json
from typing import List
from alibabacloud_dingtalk.im_1_0.client import Client as dingtalkim_1_0Client
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_dingtalk.im_1_0 import models as dingtalkim__1__0_models
from alibabacloud_tea_util import models as util_models
from alibabacloud_tea_util.client import Client as UtilClient
class Sample:
def __init__(self):
pass
@staticmethod
def create_client() -> dingtalkim_1_0Client:
"""
Initialize the account Client with a Token
@return: Client
@throws Exception
"""
config = open_api_models.Config()
config.protocol = 'https'
config.region_id = 'central'
return dingtalkim_1_0Client(config)
@staticmethod
def main(
args: List[str],
) -> None:
client = Sample.create_client()
update_group_headers = dingtalkim__1__0_models.UpdateGroupHeaders()
update_group_headers.x_acs_dingtalk_access_token = '<your access token>'
management_options = dingtalkim__1__0_models.UpdateGroupRequestManagementOptions(
mention_all_authority=0,
show_history_type=0,
validation_type=0,
searchable=0,
chat_banned_type=0,
management_type=0
)
update_group_request = dingtalkim__1__0_models.UpdateGroupRequest(
chatid='chatxxxx',
name='All-staff Chat.',
owner='04201724372xxxx',
owner_type='emp',
add_useridlist=[
'userid1'
],
del_useridlist=[
'userid1'
],
add_extidlist=[
'unionId'
],
del_extidlist=[
'unionId'
],
icon='@mediaId',
management_options=management_options
)
try:
client.update_group_with_options(update_group_request, update_group_headers, util_models.RuntimeOptions())
except Exception as err:
if not UtilClient.empty(err.code) and not UtilClient.empty(err.message):
# err contains code and message attributes, which help locate the issue during development
pass
@staticmethod
async def main_async(
args: List[str],
) -> None:
client = Sample.create_client()
update_group_headers = dingtalkim__1__0_models.UpdateGroupHeaders()
update_group_headers.x_acs_dingtalk_access_token = '<your access token>'
management_options = dingtalkim__1__0_models.UpdateGroupRequestManagementOptions(
mention_all_authority=0,
show_history_type=0,
validation_type=0,
searchable=0,
chat_banned_type=0,
management_type=0
)
update_group_request = dingtalkim__1__0_models.UpdateGroupRequest(
chatid='chatxxxx',
name='All-staff Chat.',
owner='04201724372xxxx',
owner_type='emp',
add_useridlist=[
'userid1'
],
del_useridlist=[
'userid1'
],
add_extidlist=[
'unionId'
],
del_extidlist=[
'unionId'
],
icon='@mediaId',
management_options=management_options
)
try:
await client.update_group_with_options_async(update_group_request, update_group_headers, util_models.RuntimeOptions())
except Exception as err:
if not UtilClient.empty(err.code) and not UtilClient.empty(err.message):
# err contains code and message attributes, which help locate the issue during development
pass
if __name__ == '__main__':
Sample.main(sys.argv[1:])