# -*- 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.doc_1_0.client import Client as dingtalkdoc_1_0Client
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_dingtalk.doc_1_0 import models as dingtalkdoc__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() -> dingtalkdoc_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 dingtalkdoc_1_0Client(config)
@staticmethod
def main(
args: List[str],
) -> None:
client = Sample.create_client()
create_float_image_headers = dingtalkdoc__1__0_models.CreateFloatImageHeaders()
create_float_image_headers.x_acs_dingtalk_access_token = '<your access token>'
coordinate = dingtalkdoc__1__0_models.CreateFloatImageRequestCoordinate(
width=300,
height=300,
offset_x=8,
offset_y=8
)
anchor = dingtalkdoc__1__0_models.CreateFloatImageRequestAnchor(
row=1,
col=1
)
create_float_image_request = dingtalkdoc__1__0_models.CreateFloatImageRequest(
operator_id='ppgAQuxxxxx',
src='/core/api/resources/img/xxx',
anchor=anchor,
coordinate=coordinate
)
try:
client.create_float_image_with_options('e54Lqxxxxx', 'Sheet1', create_float_image_request, create_float_image_headers, util_models.RuntimeOptions())
except Exception as err:
if not UtilClient.empty(err.code) and not UtilClient.empty(err.message):
# The err object contains the code and message attributes, which help diagnose the issue.
pass
@staticmethod
async def main_async(
args: List[str],
) -> None:
client = Sample.create_client()
create_float_image_headers = dingtalkdoc__1__0_models.CreateFloatImageHeaders()
create_float_image_headers.x_acs_dingtalk_access_token = '<your access token>'
coordinate = dingtalkdoc__1__0_models.CreateFloatImageRequestCoordinate(
width=300,
height=300,
offset_x=8,
offset_y=8
)
anchor = dingtalkdoc__1__0_models.CreateFloatImageRequestAnchor(
row=1,
col=1
)
create_float_image_request = dingtalkdoc__1__0_models.CreateFloatImageRequest(
operator_id='ppgAQuxxxxx',
src='/core/api/resources/img/xxx',
anchor=anchor,
coordinate=coordinate
)
try:
await client.create_float_image_with_options_async('e54Lqxxxxx', 'Sheet1', create_float_image_request, create_float_image_headers, util_models.RuntimeOptions())
except Exception as err:
if not UtilClient.empty(err.code) and not UtilClient.empty(err.message):
# The err object contains the code and message attributes, which help diagnose the issue.
pass
if __name__ == '__main__':
Sample.main(sys.argv[1:])