# -*- coding: utf-8 -*-
# This file is auto-generated, don't edit it. Thanks.
import os
import sys
from typing import List
from alibabacloud_dingtalk.calendar_1_0.client import Client as dingtalkcalendar_1_0Client
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_dingtalk.calendar_1_0 import models as dingtalkcalendar__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() -> dingtalkcalendar_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 dingtalkcalendar_1_0Client(config)
@staticmethod
def main(
args: List[str],
) -> None:
client = Sample.create_client()
create_event_headers = dingtalkcalendar__1__0_models.CreateEventHeaders()
create_event_headers.x_acs_dingtalk_access_token = '<your access token>'
rich_text_description = dingtalkcalendar__1__0_models.CreateEventRequestRichTextDescription(
text='<div class="__aliyun_email_body_block"><div style="clear:both;"><span style="text-decoration:line-through;">Sample strikethrough text</span></div><div style="clear:both;"><span style="color:#ff0000;">Sample red text</span></div><div style="clear:both;"><span style="text-decoration:underline;">Sample underlined text</span></div><div style="clear:both;"><span style="font-weight:700;">Sample bold text</span></div><div style="clear:both;"><span style="font-weight:700;font-style:italic;">Sample bold italic text</span></div></div>'
)
ui_configs_0 = dingtalkcalendar__1__0_models.CreateEventRequestUiConfigs(
ui_name='updateEventButton',
ui_status='hide'
)
extra = {
'noChatNotification': 'true',
'noPushNotification': 'true'
}
online_meeting_info = dingtalkcalendar__1__0_models.CreateEventRequestOnlineMeetingInfo(
type='dingtalk'
)
reminders_0 = dingtalkcalendar__1__0_models.CreateEventRequestReminders(
method='dingtalk',
minutes=15
)
location = dingtalkcalendar__1__0_models.CreateEventRequestLocation(
display_name='dingtalk'
)
attendees_0 = dingtalkcalendar__1__0_models.CreateEventRequestAttendees(
id='iiiP35sJxxx',
is_optional=False
)
recurrence_range = dingtalkcalendar__1__0_models.CreateEventRequestRecurrenceRange(
type='endDate',
end_date='2021-12-31T10:15:30+08:00',
number_of_occurrences=5
)
recurrence_pattern = dingtalkcalendar__1__0_models.CreateEventRequestRecurrencePattern(
type='daily',
day_of_month=1,
days_of_week='monday',
index='last',
interval=1,
first_day_of_week='monday'
)
recurrence = dingtalkcalendar__1__0_models.CreateEventRequestRecurrence(
pattern=recurrence_pattern,
range=recurrence_range
)
end = dingtalkcalendar__1__0_models.CreateEventRequestEnd(
date='2020-09-21',
date_time='2021-09-20T10:15:30+08:00',
time_zone='Asia/Shanghai'
)
start = dingtalkcalendar__1__0_models.CreateEventRequestStart(
date='2021-09-20',
date_time='2021-09-20T10:15:30+08:00',
time_zone='Asia/Shanghai'
)
create_event_request = dingtalkcalendar__1__0_models.CreateEventRequest(
summary='test event',
description='something about this event',
start=start,
end=end,
is_all_day=False,
recurrence=recurrence,
attendees=[
attendees_0
],
location=location,
reminders=[
reminders_0
],
online_meeting_info=online_meeting_info,
extra=extra,
ui_configs=[
ui_configs_0
],
rich_text_description=rich_text_description
)
try:
client.create_event_with_options('iiiP35sJadba8aBSgjrwPRKgiEiF', 'primary', create_event_request, create_event_headers, util_models.RuntimeOptions())
except Exception as err:
if not UtilClient.empty(err.code) and not UtilClient.empty(err.message):
# err contains the code and message attributes, which help locate the issue
pass
@staticmethod
async def main_async(
args: List[str],
) -> None:
client = Sample.create_client()
create_event_headers = dingtalkcalendar__1__0_models.CreateEventHeaders()
create_event_headers.x_acs_dingtalk_access_token = '<your access token>'
rich_text_description = dingtalkcalendar__1__0_models.CreateEventRequestRichTextDescription(
text='<div class="__aliyun_email_body_block"><div style="clear:both;"><span style="text-decoration:line-through;">Sample strikethrough text</span></div><div style="clear:both;"><span style="color:#ff0000;">Sample red text</span></div><div style="clear:both;"><span style="text-decoration:underline;">Sample underlined text</span></div><div style="clear:both;"><span style="font-weight:700;">Sample bold text</span></div><div style="clear:both;"><span style="font-weight:700;font-style:italic;">Sample bold italic text</span></div></div>'
)
ui_configs_0 = dingtalkcalendar__1__0_models.CreateEventRequestUiConfigs(
ui_name='updateEventButton',
ui_status='hide'
)
extra = {
'key': 'noPushNotification'
}
online_meeting_info = dingtalkcalendar__1__0_models.CreateEventRequestOnlineMeetingInfo(
type='dingtalk'
)
reminders_0 = dingtalkcalendar__1__0_models.CreateEventRequestReminders(
method='dingtalk',
minutes=15
)
location = dingtalkcalendar__1__0_models.CreateEventRequestLocation(
display_name='dingtalk'
)
attendees_0 = dingtalkcalendar__1__0_models.CreateEventRequestAttendees(
id='iiiP35sJxxx',
is_optional=False
)
recurrence_range = dingtalkcalendar__1__0_models.CreateEventRequestRecurrenceRange(
type='endDate',
end_date='2021-12-31T10:15:30+08:00',
number_of_occurrences=5
)
recurrence_pattern = dingtalkcalendar__1__0_models.CreateEventRequestRecurrencePattern(
type='daily',
day_of_month=1,
days_of_week='monday',
index='last',
interval=1,
first_day_of_week='monday'
)
recurrence = dingtalkcalendar__1__0_models.CreateEventRequestRecurrence(
pattern=recurrence_pattern,
range=recurrence_range
)
end = dingtalkcalendar__1__0_models.CreateEventRequestEnd(
date='2020-09-21',
date_time='2021-09-20T10:15:30+08:00',
time_zone='Asia/Shanghai'
)
start = dingtalkcalendar__1__0_models.CreateEventRequestStart(
date='2021-09-20',
date_time='2021-09-20T10:15:30+08:00',
time_zone='Asia/Shanghai'
)
create_event_request = dingtalkcalendar__1__0_models.CreateEventRequest(
summary='test event',
description='something about this event',
start=start,
end=end,
is_all_day=False,
recurrence=recurrence,
attendees=[
attendees_0
],
location=location,
reminders=[
reminders_0
],
online_meeting_info=online_meeting_info,
extra=extra,
ui_configs=[
ui_configs_0
],
rich_text_description=rich_text_description
)
try:
await client.create_event_with_options_async('iiiP35sJadba8aBSgjrwPRKgiEiF', 'primary', create_event_request, create_event_headers, util_models.RuntimeOptions())
except Exception as err:
if not UtilClient.empty(err.code) and not UtilClient.empty(err.message):
# err contains the code and message attributes, which help locate the issue
pass
if __name__ == '__main__':
Sample.main(sys.argv[1:])