diff --git a/sample/api/docx.py b/sample/api/docx.py new file mode 100644 index 000000000..2999b2bdf --- /dev/null +++ b/sample/api/docx.py @@ -0,0 +1,172 @@ +# -*- coding: UTF-8 -*- +from larksuiteoapi import DOMAIN_FEISHU, Config, LEVEL_DEBUG +from larksuiteoapi.service.docx.v1 import Service as DocxService, model + +# 企业自建应用的配置 +# AppID、AppSecret: "开发者后台" -> "凭证与基础信息" -> 应用凭证(App ID、App Secret) +# VerificationToken、EncryptKey:"开发者后台" -> "事件订阅" -> 事件订阅(Verification Token、Encrypt Key)。 +# 更多介绍请看:Github->README.zh.md->如何构建应用配置(AppSettings) +app_settings = Config.new_internal_app_settings_from_env() + +# 当前访问的是飞书,使用默认存储、默认日志(Error级别) +# 更多介绍请看:Github->README.zh.md->如何构建整体配置(Config) +conf = Config(DOMAIN_FEISHU, app_settings, log_level=LEVEL_DEBUG) + +service = DocxService(conf) + + +def test_create_doc(): + # body + body = model.DocumentCreateReqBody() + body.folder_token = 'fldcniHf40Vcv1DoEc8SXeuA0Zd' + body.title = 'document-python' + req_call = service.documents.create(body, None, 'u-12kPy7i1Zf3Xg6YBJaoncNgk2cmBk1AFiww0lkC8G9SO') + resp = req_call.do() + print('request id = %s' % resp.get_request_id()) + print('http status code = %s' % resp.get_http_status_code()) + print('header = %s' % resp.get_header().items()) + if resp.code == 0: + print(resp.data) + else: + print(resp.msg) + print(resp.error) + + +def test_get_doc(): + req_call = service.documents.get(None, 'u-WKCn2nuMHEgeTQ9YyuFeMg') + req_call.set_document_id("doxcnEldNqtJ9Og88tf6dnVVNNf") + resp = req_call.do() + print('request id = %s' % resp.get_request_id()) + print('http status code = %s' % resp.get_http_status_code()) + print('header = %s' % resp.get_header().items()) + if resp.code == 0: + print(resp.data) + else: + print(resp.msg) + print(resp.error) + + +def test_get_raw_doc(): + req_call = service.documents.raw_content(None, 'u-12kPy7i1Zf3Xg6YBJaoncNgk2cmBk1AFiww0lkC8G9SO') + req_call.set_document_id("doxcnEldNqtJ9Og88tf6dnVVNNf") + resp = req_call.do() + print('request id = %s' % resp.get_request_id()) + print('http status code = %s' % resp.get_http_status_code()) + print('header = %s' % resp.get_header().items()) + if resp.code == 0: + print(resp.data) + else: + print(resp.msg) + print(resp.error) + + +def test_list_blocks(): + req_call = service.document_blocks.list(None, 'u-12kPy7i1Zf3Xg6YBJaoncNgk2cmBk1AFiww0lkC8G9SO') + req_call.set_document_id("doxcnEldNqtJ9Og88tf6dnVVNNf") + req_call.set_page_size(100) + resp = req_call.do() + print('request id = %s' % resp.get_request_id()) + print('http status code = %s' % resp.get_http_status_code()) + print('header = %s' % resp.get_header().items()) + if resp.code == 0: + print(resp.data) + else: + print(resp.msg) + print(resp.error) + + +def test_create_blocks(): + body = model.DocumentBlockChildrenCreateReqBody() + body.index = 0 + + block = model.Block() + block.block_type = 2 + + text = model.Text() + e = model.TextElement() + run = model.TextRun() + run.content = "66666" + style = model.TextElementStyle() + style.background_color = 14 + style.text_color = 5 + run.text_element_style = style + e.text_run = run + + es = [e] + text.elements = es + block.text = text + bs = [block] + body.children = bs + + req_call = service.document_block_childrens.create(body, None, 'u-12kPy7i1Zf3Xg6YBJaoncNgk2cmBk1AFiww0lkC8G9SO') + req_call.set_document_id("doxcnEldNqtJ9Og88tf6dnVVNNf") + req_call.set_block_id("doxcnKIaoQecc6GWwozvApH6rOf") + + resp = req_call.do() + print('request id = %s' % resp.get_request_id()) + print('http status code = %s' % resp.get_http_status_code()) + print('header = %s' % resp.get_header().items()) + if resp.code == 0: + print(resp.data) + else: + print(resp.msg) + print(resp.error) + + +def test_update_blocks(): + req = model.UpdateBlockRequest() + + text = model.Text() + e = model.TextElement() + run = model.TextRun() + run.content = "8888" + style = model.TextElementStyle() + style.background_color = 14 + style.text_color = 5 + run.text_element_style = style + e.text_run = run + + es = [e] + text.elements = es + r = model.UpdateTextElementsRequest() + r.elements = es + req.update_text_elements = r + + req_call = service.document_blocks.patch(req, None, 'u-03ETXnQCx2bGzlCpiLkBxA0k0Yr5k1C9XwG001a00csd') + req_call.set_document_id("doxcnEldNqtJ9Og88tf6dnVVNNf") + req_call.set_block_id("doxcnKIaoQecc6GWwozvApH6rOf") + + resp = req_call.do() + print('request id = %s' % resp.get_request_id()) + print('http status code = %s' % resp.get_http_status_code()) + print('header = %s' % resp.get_header().items()) + if resp.code == 0: + print(resp.data) + else: + print(resp.msg) + print(resp.error) + + +def test_list_sub_blocks(): + req_call = service.document_block_childrens.get(None, 'u-12kPy7i1Zf3Xg6YBJaoncNgk2cmBk1AFiww0lkC8G9SO',None) + req_call.set_document_id("doxcnEldNqtJ9Og88tf6dnVVNNf") + req_call.set_block_id("doxcnKIaoQecc6GWwozvApH6rOf") + req_call.set_page_size(100) + resp = req_call.do() + print('request id = %s' % resp.get_request_id()) + print('http status code = %s' % resp.get_http_status_code()) + print('header = %s' % resp.get_header().items()) + if resp.code == 0: + print(resp.data) + else: + print(resp.msg) + print(resp.error) + +if __name__ == '__main__': + # test_create_doc() + test_get_doc() + # test_get_raw_doc() + #test_list_blocks() + #test_create_blocks() + #test_list_sub_blocks() + #test_update_blocks() diff --git a/src/larksuiteoapi/service/docx/__init__.py b/src/larksuiteoapi/service/docx/__init__.py new file mode 100644 index 000000000..d40ceff6f --- /dev/null +++ b/src/larksuiteoapi/service/docx/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: UTF-8 -*- +# Code generated by lark suite oapi sdk gen + diff --git a/src/larksuiteoapi/service/docx/v1/__init__.py b/src/larksuiteoapi/service/docx/v1/__init__.py new file mode 100644 index 000000000..6ba7d5a4d --- /dev/null +++ b/src/larksuiteoapi/service/docx/v1/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: UTF-8 -*- +# Code generated by lark suite oapi sdk gen + +from .model import * +from .api import * diff --git a/src/larksuiteoapi/service/docx/v1/api.py b/src/larksuiteoapi/service/docx/v1/api.py new file mode 100644 index 000000000..fc9e016d0 --- /dev/null +++ b/src/larksuiteoapi/service/docx/v1/api.py @@ -0,0 +1,645 @@ +# -*- coding: UTF-8 -*- +# Code generated by lark suite oapi sdk gen + +from typing import * + +from ....api import Request as APIRequest, Response as APIResponse, set_timeout, set_tenant_key, set_user_access_token, set_path_params, \ + set_query_params, set_response_stream, set_is_response_stream, FormData, FormDataFile +from ....config import Config +from ....consts import ACCESS_TOKEN_TYPE_TENANT, ACCESS_TOKEN_TYPE_USER, ACCESS_TOKEN_TYPE_APP +from .model import * + + +class Service(object): + def __init__(self, conf): + # type: (Config) -> None + self.conf = conf + self.documents = DocumentService(self) + self.document_blocks = DocumentBlockService(self) + self.document_block_childrens = DocumentBlockChildrenService(self) + + + + +class DocumentService(object): + def __init__(self, service): + # type: (Service) -> None + self.service = service + + def create(self, body, tenant_key=None, user_access_token=None, timeout=None): + # type: (DocumentCreateReqBody, str, str, int) -> DocumentCreateReqCall + + request_opts = [] # type: List[Callable[[Any], Any]] + + if timeout is not None: + request_opts += [set_timeout(timeout)] + + if tenant_key is not None: + request_opts += [set_tenant_key(tenant_key)] + + if user_access_token is not None: + request_opts += [set_user_access_token(user_access_token)] + + return DocumentCreateReqCall(self, body, request_opts=request_opts) + + def get(self, tenant_key=None, user_access_token=None, timeout=None): + # type: (str, str, int) -> DocumentGetReqCall + + request_opts = [] # type: List[Callable[[Any], Any]] + + if timeout is not None: + request_opts += [set_timeout(timeout)] + + if tenant_key is not None: + request_opts += [set_tenant_key(tenant_key)] + + if user_access_token is not None: + request_opts += [set_user_access_token(user_access_token)] + + return DocumentGetReqCall(self, request_opts=request_opts) + + def raw_content(self, tenant_key=None, user_access_token=None, timeout=None): + # type: (str, str, int) -> DocumentRawContentReqCall + + request_opts = [] # type: List[Callable[[Any], Any]] + + if timeout is not None: + request_opts += [set_timeout(timeout)] + + if tenant_key is not None: + request_opts += [set_tenant_key(tenant_key)] + + if user_access_token is not None: + request_opts += [set_user_access_token(user_access_token)] + + return DocumentRawContentReqCall(self, request_opts=request_opts) + + +class DocumentBlockService(object): + def __init__(self, service): + # type: (Service) -> None + self.service = service + + def batch_update(self, body, tenant_key=None, user_access_token=None, timeout=None): + # type: (DocumentBlockBatchUpdateReqBody, str, str, int) -> DocumentBlockBatchUpdateReqCall + + request_opts = [] # type: List[Callable[[Any], Any]] + + if timeout is not None: + request_opts += [set_timeout(timeout)] + + if tenant_key is not None: + request_opts += [set_tenant_key(tenant_key)] + + if user_access_token is not None: + request_opts += [set_user_access_token(user_access_token)] + + return DocumentBlockBatchUpdateReqCall(self, body, request_opts=request_opts) + + def get(self, tenant_key=None, user_access_token=None, timeout=None): + # type: (str, str, int) -> DocumentBlockGetReqCall + + request_opts = [] # type: List[Callable[[Any], Any]] + + if timeout is not None: + request_opts += [set_timeout(timeout)] + + if tenant_key is not None: + request_opts += [set_tenant_key(tenant_key)] + + if user_access_token is not None: + request_opts += [set_user_access_token(user_access_token)] + + return DocumentBlockGetReqCall(self, request_opts=request_opts) + + def list(self, tenant_key=None, user_access_token=None, timeout=None): + # type: (str, str, int) -> DocumentBlockListReqCall + + request_opts = [] # type: List[Callable[[Any], Any]] + + if timeout is not None: + request_opts += [set_timeout(timeout)] + + if tenant_key is not None: + request_opts += [set_tenant_key(tenant_key)] + + if user_access_token is not None: + request_opts += [set_user_access_token(user_access_token)] + + return DocumentBlockListReqCall(self, request_opts=request_opts) + + def patch(self, body, tenant_key=None, user_access_token=None, timeout=None): + # type: (UpdateBlockRequest, str, str, int) -> DocumentBlockPatchReqCall + + request_opts = [] # type: List[Callable[[Any], Any]] + + if timeout is not None: + request_opts += [set_timeout(timeout)] + + if tenant_key is not None: + request_opts += [set_tenant_key(tenant_key)] + + if user_access_token is not None: + request_opts += [set_user_access_token(user_access_token)] + + return DocumentBlockPatchReqCall(self, body, request_opts=request_opts) + + +class DocumentBlockChildrenService(object): + def __init__(self, service): + # type: (Service) -> None + self.service = service + + def batch_delete(self, body, tenant_key=None, user_access_token=None, timeout=None): + # type: (DocumentBlockChildrenBatchDeleteReqBody, str, str, int) -> DocumentBlockChildrenBatchDeleteReqCall + + request_opts = [] # type: List[Callable[[Any], Any]] + + if timeout is not None: + request_opts += [set_timeout(timeout)] + + if tenant_key is not None: + request_opts += [set_tenant_key(tenant_key)] + + if user_access_token is not None: + request_opts += [set_user_access_token(user_access_token)] + + return DocumentBlockChildrenBatchDeleteReqCall(self, body, request_opts=request_opts) + + def create(self, body, tenant_key=None, user_access_token=None, timeout=None): + # type: (DocumentBlockChildrenCreateReqBody, str, str, int) -> DocumentBlockChildrenCreateReqCall + + request_opts = [] # type: List[Callable[[Any], Any]] + + if timeout is not None: + request_opts += [set_timeout(timeout)] + + if tenant_key is not None: + request_opts += [set_tenant_key(tenant_key)] + + if user_access_token is not None: + request_opts += [set_user_access_token(user_access_token)] + + return DocumentBlockChildrenCreateReqCall(self, body, request_opts=request_opts) + + def get(self, tenant_key=None, user_access_token=None, timeout=None): + # type: (str, str, int) -> DocumentBlockChildrenGetReqCall + + request_opts = [] # type: List[Callable[[Any], Any]] + + if timeout is not None: + request_opts += [set_timeout(timeout)] + + if tenant_key is not None: + request_opts += [set_tenant_key(tenant_key)] + + if user_access_token is not None: + request_opts += [set_user_access_token(user_access_token)] + + return DocumentBlockChildrenGetReqCall(self, request_opts=request_opts) + + + +class DocumentCreateReqCall(object): + def __init__(self, service, body, request_opts=None): + # type: (DocumentService, DocumentCreateReqBody, List[Any]) -> None + + self.service = service + self.body = body + + if request_opts: + self.request_opts = request_opts + else: + self.request_opts = [] # type: List[Any] + + def do(self): + # type: () -> APIResponse[Type[DocumentCreateResult]] + root_service = self.service.service + + conf = root_service.conf + req = APIRequest('/open-apis/docx/v1/documents', 'POST', [ACCESS_TOKEN_TYPE_TENANT, ACCESS_TOKEN_TYPE_USER], + self.body, output_class=DocumentCreateResult, request_opts=self.request_opts) + resp = req.do(conf) + return resp + + +class DocumentGetReqCall(object): + def __init__(self, service, request_opts=None): + # type: (DocumentService, List[Any]) -> None + + self.service = service + + self.path_params = {} # type: Dict[str, Any] + + if request_opts: + self.request_opts = request_opts + else: + self.request_opts = [] # type: List[Any] + + def set_document_id(self, document_id): + # type: (str) -> DocumentGetReqCall + self.path_params['document_id'] = document_id + return self + + def do(self): + # type: () -> APIResponse[Type[DocumentGetResult]] + root_service = self.service.service + + conf = root_service.conf + self.request_opts += [set_path_params(self.path_params)] + req = APIRequest('/open-apis/docx/v1/documents/:document_id', 'GET', [ACCESS_TOKEN_TYPE_TENANT, ACCESS_TOKEN_TYPE_USER], + None, output_class=DocumentGetResult, request_opts=self.request_opts) + resp = req.do(conf) + return resp + + +class DocumentRawContentReqCall(object): + def __init__(self, service, request_opts=None): + # type: (DocumentService, List[Any]) -> None + + self.service = service + + self.path_params = {} # type: Dict[str, Any] + self.query_params = {} # type: Dict[str, Any] + + if request_opts: + self.request_opts = request_opts + else: + self.request_opts = [] # type: List[Any] + + def set_document_id(self, document_id): + # type: (str) -> DocumentRawContentReqCall + self.path_params['document_id'] = document_id + return self + + def set_lang(self, lang): + # type: (int) -> DocumentRawContentReqCall + self.query_params['lang'] = lang + return self + + def do(self): + # type: () -> APIResponse[Type[DocumentRawContentResult]] + root_service = self.service.service + + conf = root_service.conf + self.request_opts += [set_path_params(self.path_params)] + self.request_opts += [set_query_params(self.query_params)] + req = APIRequest('/open-apis/docx/v1/documents/:document_id/raw_content', 'GET', [ACCESS_TOKEN_TYPE_TENANT, ACCESS_TOKEN_TYPE_USER], + None, output_class=DocumentRawContentResult, request_opts=self.request_opts) + resp = req.do(conf) + return resp + + +class DocumentBlockBatchUpdateReqCall(object): + def __init__(self, service, body, request_opts=None): + # type: (DocumentBlockService, DocumentBlockBatchUpdateReqBody, List[Any]) -> None + + self.service = service + self.body = body + self.path_params = {} # type: Dict[str, Any] + self.query_params = {} # type: Dict[str, Any] + + if request_opts: + self.request_opts = request_opts + else: + self.request_opts = [] # type: List[Any] + + def set_document_id(self, document_id): + # type: (str) -> DocumentBlockBatchUpdateReqCall + self.path_params['document_id'] = document_id + return self + + def set_document_revision_id(self, document_revision_id): + # type: (int) -> DocumentBlockBatchUpdateReqCall + self.query_params['document_revision_id'] = document_revision_id + return self + + def set_client_token(self, client_token): + # type: (str) -> DocumentBlockBatchUpdateReqCall + self.query_params['client_token'] = client_token + return self + + def set_user_id_type(self, user_id_type): + # type: (str) -> DocumentBlockBatchUpdateReqCall + self.query_params['user_id_type'] = user_id_type + return self + + def do(self): + # type: () -> APIResponse[Type[DocumentBlockBatchUpdateResult]] + root_service = self.service.service + + conf = root_service.conf + self.request_opts += [set_path_params(self.path_params)] + self.request_opts += [set_query_params(self.query_params)] + req = APIRequest('/open-apis/docx/v1/documents/:document_id/blocks/batch_update', 'PATCH', [ACCESS_TOKEN_TYPE_TENANT, ACCESS_TOKEN_TYPE_USER], + self.body, output_class=DocumentBlockBatchUpdateResult, request_opts=self.request_opts) + resp = req.do(conf) + return resp + + +class DocumentBlockGetReqCall(object): + def __init__(self, service, request_opts=None): + # type: (DocumentBlockService, List[Any]) -> None + + self.service = service + + self.path_params = {} # type: Dict[str, Any] + self.query_params = {} # type: Dict[str, Any] + + if request_opts: + self.request_opts = request_opts + else: + self.request_opts = [] # type: List[Any] + + def set_document_id(self, document_id): + # type: (str) -> DocumentBlockGetReqCall + self.path_params['document_id'] = document_id + return self + + def set_block_id(self, block_id): + # type: (str) -> DocumentBlockGetReqCall + self.path_params['block_id'] = block_id + return self + + def set_document_revision_id(self, document_revision_id): + # type: (int) -> DocumentBlockGetReqCall + self.query_params['document_revision_id'] = document_revision_id + return self + + def set_user_id_type(self, user_id_type): + # type: (str) -> DocumentBlockGetReqCall + self.query_params['user_id_type'] = user_id_type + return self + + def do(self): + # type: () -> APIResponse[Type[DocumentBlockGetResult]] + root_service = self.service.service + + conf = root_service.conf + self.request_opts += [set_path_params(self.path_params)] + self.request_opts += [set_query_params(self.query_params)] + req = APIRequest('/open-apis/docx/v1/documents/:document_id/blocks/:block_id', 'GET', [ACCESS_TOKEN_TYPE_TENANT, ACCESS_TOKEN_TYPE_USER], + None, output_class=DocumentBlockGetResult, request_opts=self.request_opts) + resp = req.do(conf) + return resp + + +class DocumentBlockListReqCall(object): + def __init__(self, service, request_opts=None): + # type: (DocumentBlockService, List[Any]) -> None + + self.service = service + + self.path_params = {} # type: Dict[str, Any] + self.query_params = {} # type: Dict[str, Any] + + if request_opts: + self.request_opts = request_opts + else: + self.request_opts = [] # type: List[Any] + + def set_document_id(self, document_id): + # type: (str) -> DocumentBlockListReqCall + self.path_params['document_id'] = document_id + return self + + def set_page_size(self, page_size): + # type: (int) -> DocumentBlockListReqCall + self.query_params['page_size'] = page_size + return self + + def set_page_token(self, page_token): + # type: (str) -> DocumentBlockListReqCall + self.query_params['page_token'] = page_token + return self + + def set_document_revision_id(self, document_revision_id): + # type: (int) -> DocumentBlockListReqCall + self.query_params['document_revision_id'] = document_revision_id + return self + + def set_user_id_type(self, user_id_type): + # type: (str) -> DocumentBlockListReqCall + self.query_params['user_id_type'] = user_id_type + return self + + def do(self): + # type: () -> APIResponse[Type[DocumentBlockListResult]] + root_service = self.service.service + + conf = root_service.conf + self.request_opts += [set_path_params(self.path_params)] + self.request_opts += [set_query_params(self.query_params)] + req = APIRequest('/open-apis/docx/v1/documents/:document_id/blocks', 'GET', [ACCESS_TOKEN_TYPE_TENANT, ACCESS_TOKEN_TYPE_USER], + None, output_class=DocumentBlockListResult, request_opts=self.request_opts) + resp = req.do(conf) + return resp + + +class DocumentBlockPatchReqCall(object): + def __init__(self, service, body, request_opts=None): + # type: (DocumentBlockService, UpdateBlockRequest, List[Any]) -> None + + self.service = service + self.body = body + self.path_params = {} # type: Dict[str, Any] + self.query_params = {} # type: Dict[str, Any] + + if request_opts: + self.request_opts = request_opts + else: + self.request_opts = [] # type: List[Any] + + def set_document_id(self, document_id): + # type: (str) -> DocumentBlockPatchReqCall + self.path_params['document_id'] = document_id + return self + + def set_block_id(self, block_id): + # type: (str) -> DocumentBlockPatchReqCall + self.path_params['block_id'] = block_id + return self + + def set_document_revision_id(self, document_revision_id): + # type: (int) -> DocumentBlockPatchReqCall + self.query_params['document_revision_id'] = document_revision_id + return self + + def set_client_token(self, client_token): + # type: (str) -> DocumentBlockPatchReqCall + self.query_params['client_token'] = client_token + return self + + def set_user_id_type(self, user_id_type): + # type: (str) -> DocumentBlockPatchReqCall + self.query_params['user_id_type'] = user_id_type + return self + + def do(self): + # type: () -> APIResponse[Type[DocumentBlockPatchResult]] + root_service = self.service.service + + conf = root_service.conf + self.request_opts += [set_path_params(self.path_params)] + self.request_opts += [set_query_params(self.query_params)] + req = APIRequest('/open-apis/docx/v1/documents/:document_id/blocks/:block_id', 'PATCH', [ACCESS_TOKEN_TYPE_TENANT, ACCESS_TOKEN_TYPE_USER], + self.body, output_class=DocumentBlockPatchResult, request_opts=self.request_opts) + resp = req.do(conf) + return resp + + +class DocumentBlockChildrenBatchDeleteReqCall(object): + def __init__(self, service, body, request_opts=None): + # type: (DocumentBlockChildrenService, DocumentBlockChildrenBatchDeleteReqBody, List[Any]) -> None + + self.service = service + self.body = body + self.path_params = {} # type: Dict[str, Any] + self.query_params = {} # type: Dict[str, Any] + + if request_opts: + self.request_opts = request_opts + else: + self.request_opts = [] # type: List[Any] + + def set_document_id(self, document_id): + # type: (str) -> DocumentBlockChildrenBatchDeleteReqCall + self.path_params['document_id'] = document_id + return self + + def set_block_id(self, block_id): + # type: (str) -> DocumentBlockChildrenBatchDeleteReqCall + self.path_params['block_id'] = block_id + return self + + def set_document_revision_id(self, document_revision_id): + # type: (int) -> DocumentBlockChildrenBatchDeleteReqCall + self.query_params['document_revision_id'] = document_revision_id + return self + + def set_client_token(self, client_token): + # type: (str) -> DocumentBlockChildrenBatchDeleteReqCall + self.query_params['client_token'] = client_token + return self + + def do(self): + # type: () -> APIResponse[Type[DocumentBlockChildrenBatchDeleteResult]] + root_service = self.service.service + + conf = root_service.conf + self.request_opts += [set_path_params(self.path_params)] + self.request_opts += [set_query_params(self.query_params)] + req = APIRequest('/open-apis/docx/v1/documents/:document_id/blocks/:block_id/children/batch_delete', 'DELETE', [ACCESS_TOKEN_TYPE_TENANT, ACCESS_TOKEN_TYPE_USER], + self.body, output_class=DocumentBlockChildrenBatchDeleteResult, request_opts=self.request_opts) + resp = req.do(conf) + return resp + + +class DocumentBlockChildrenCreateReqCall(object): + def __init__(self, service, body, request_opts=None): + # type: (DocumentBlockChildrenService, DocumentBlockChildrenCreateReqBody, List[Any]) -> None + + self.service = service + self.body = body + self.path_params = {} # type: Dict[str, Any] + self.query_params = {} # type: Dict[str, Any] + + if request_opts: + self.request_opts = request_opts + else: + self.request_opts = [] # type: List[Any] + + def set_document_id(self, document_id): + # type: (str) -> DocumentBlockChildrenCreateReqCall + self.path_params['document_id'] = document_id + return self + + def set_block_id(self, block_id): + # type: (str) -> DocumentBlockChildrenCreateReqCall + self.path_params['block_id'] = block_id + return self + + def set_document_revision_id(self, document_revision_id): + # type: (int) -> DocumentBlockChildrenCreateReqCall + self.query_params['document_revision_id'] = document_revision_id + return self + + def set_client_token(self, client_token): + # type: (str) -> DocumentBlockChildrenCreateReqCall + self.query_params['client_token'] = client_token + return self + + def set_user_id_type(self, user_id_type): + # type: (str) -> DocumentBlockChildrenCreateReqCall + self.query_params['user_id_type'] = user_id_type + return self + + def do(self): + # type: () -> APIResponse[Type[DocumentBlockChildrenCreateResult]] + root_service = self.service.service + + conf = root_service.conf + self.request_opts += [set_path_params(self.path_params)] + self.request_opts += [set_query_params(self.query_params)] + req = APIRequest('/open-apis/docx/v1/documents/:document_id/blocks/:block_id/children', 'POST', [ACCESS_TOKEN_TYPE_TENANT, ACCESS_TOKEN_TYPE_USER], + self.body, output_class=DocumentBlockChildrenCreateResult, request_opts=self.request_opts) + resp = req.do(conf) + return resp + + +class DocumentBlockChildrenGetReqCall(object): + def __init__(self, service, request_opts=None): + # type: (DocumentBlockChildrenService, List[Any]) -> None + + self.service = service + + self.path_params = {} # type: Dict[str, Any] + self.query_params = {} # type: Dict[str, Any] + + if request_opts: + self.request_opts = request_opts + else: + self.request_opts = [] # type: List[Any] + + def set_document_id(self, document_id): + # type: (str) -> DocumentBlockChildrenGetReqCall + self.path_params['document_id'] = document_id + return self + + def set_block_id(self, block_id): + # type: (str) -> DocumentBlockChildrenGetReqCall + self.path_params['block_id'] = block_id + return self + + def set_document_revision_id(self, document_revision_id): + # type: (int) -> DocumentBlockChildrenGetReqCall + self.query_params['document_revision_id'] = document_revision_id + return self + + def set_page_token(self, page_token): + # type: (str) -> DocumentBlockChildrenGetReqCall + self.query_params['page_token'] = page_token + return self + + def set_page_size(self, page_size): + # type: (int) -> DocumentBlockChildrenGetReqCall + self.query_params['page_size'] = page_size + return self + + def set_user_id_type(self, user_id_type): + # type: (str) -> DocumentBlockChildrenGetReqCall + self.query_params['user_id_type'] = user_id_type + return self + + def do(self): + # type: () -> APIResponse[Type[DocumentBlockChildrenGetResult]] + root_service = self.service.service + + conf = root_service.conf + self.request_opts += [set_path_params(self.path_params)] + self.request_opts += [set_query_params(self.query_params)] + req = APIRequest('/open-apis/docx/v1/documents/:document_id/blocks/:block_id/children', 'GET', [ACCESS_TOKEN_TYPE_TENANT, ACCESS_TOKEN_TYPE_USER], + None, output_class=DocumentBlockChildrenGetResult, request_opts=self.request_opts) + resp = req.do(conf) + return resp + diff --git a/src/larksuiteoapi/service/docx/v1/model.py b/src/larksuiteoapi/service/docx/v1/model.py new file mode 100644 index 000000000..046738ecb --- /dev/null +++ b/src/larksuiteoapi/service/docx/v1/model.py @@ -0,0 +1,504 @@ +# -*- coding: UTF-8 -*- +# Code generated by lark suite oapi sdk gen + +from typing import List, Dict, Any +from ....utils.dt import to_json_decorator +import attr + + + + +@to_json_decorator +@attr.s +class View(object): + view_type = attr.ib(type=int, default=None, metadata={'json': 'view_type'}) + + +@to_json_decorator +@attr.s +class UpdateTablePropertyRequest(object): + column_width = attr.ib(type=int, default=None, metadata={'json': 'column_width'}) + column_index = attr.ib(type=int, default=None, metadata={'json': 'column_index'}) + + +@to_json_decorator +@attr.s +class UpdateGridColumnWidthRatioRequest(object): + width_ratios = attr.ib(type=List[int], default=None, metadata={'json': 'width_ratios'}) + + +@to_json_decorator +@attr.s +class UnmergeTableCellsRequest(object): + row_index = attr.ib(type=int, default=None, metadata={'json': 'row_index'}) + column_index = attr.ib(type=int, default=None, metadata={'json': 'column_index'}) + + +@to_json_decorator +@attr.s +class UndefinedElement(object): + pass + + +@to_json_decorator +@attr.s +class Undefined(object): + pass + + +@to_json_decorator +@attr.s +class TextStyle(object): + align = attr.ib(type=int, default=None, metadata={'json': 'align'}) + done = attr.ib(type=bool, default=None, metadata={'json': 'done'}) + folded = attr.ib(type=bool, default=None, metadata={'json': 'folded'}) + language = attr.ib(type=int, default=None, metadata={'json': 'language'}) + wrap = attr.ib(type=bool, default=None, metadata={'json': 'wrap'}) + + +@to_json_decorator +@attr.s +class UpdateTextStyleRequest(object): + style = attr.ib(type=TextStyle, default=None, metadata={'json': 'style'}) + fields = attr.ib(type=List[int], default=None, metadata={'json': 'fields'}) + + +@to_json_decorator +@attr.s +class TableMergeInfo(object): + row_span = attr.ib(type=int, default=None, metadata={'json': 'row_span'}) + col_span = attr.ib(type=int, default=None, metadata={'json': 'col_span'}) + + +@to_json_decorator +@attr.s +class TableProperty(object): + row_size = attr.ib(type=int, default=None, metadata={'json': 'row_size'}) + column_size = attr.ib(type=int, default=None, metadata={'json': 'column_size'}) + column_width = attr.ib(type=List[int], default=None, metadata={'json': 'column_width'}) + merge_info = attr.ib(type=List[TableMergeInfo], default=None, metadata={'json': 'merge_info'}) + + +@to_json_decorator +@attr.s +class Table(object): + cells = attr.ib(type=List[str], default=None, metadata={'json': 'cells'}) + property = attr.ib(type=TableProperty, default=None, metadata={'json': 'property'}) + + +@to_json_decorator +@attr.s +class TableCell(object): + pass + + +@to_json_decorator +@attr.s +class Sheet(object): + token = attr.ib(type=str, default=None, metadata={'json': 'token'}) + row_size = attr.ib(type=int, default=None, metadata={'json': 'row_size'}) + column_size = attr.ib(type=int, default=None, metadata={'json': 'column_size'}) + + +@to_json_decorator +@attr.s +class ReplaceImageRequest(object): + token = attr.ib(type=str, default=None, metadata={'json': 'token'}) + + +@to_json_decorator +@attr.s +class ReplaceFileRequest(object): + token = attr.ib(type=str, default=None, metadata={'json': 'token'}) + + +@to_json_decorator +@attr.s +class Reminder(object): + __int_to_string_fields__ = attr.ib(type=List[str], default=["expire_time", "notify_time"]) + create_user_id = attr.ib(type=str, default=None, metadata={'json': 'create_user_id'}) + is_notify = attr.ib(type=bool, default=None, metadata={'json': 'is_notify'}) + is_whole_day = attr.ib(type=bool, default=None, metadata={'json': 'is_whole_day'}) + expire_time = attr.ib(type=int, default=None, metadata={'json': 'expire_time'}) + notify_time = attr.ib(type=int, default=None, metadata={'json': 'notify_time'}) + + +@to_json_decorator +@attr.s +class Mindnote(object): + token = attr.ib(type=str, default=None, metadata={'json': 'token'}) + + +@to_json_decorator +@attr.s +class MergeTableCellsRequest(object): + row_start_index = attr.ib(type=int, default=None, metadata={'json': 'row_start_index'}) + row_end_index = attr.ib(type=int, default=None, metadata={'json': 'row_end_index'}) + column_start_index = attr.ib(type=int, default=None, metadata={'json': 'column_start_index'}) + column_end_index = attr.ib(type=int, default=None, metadata={'json': 'column_end_index'}) + + +@to_json_decorator +@attr.s +class MentionUser(object): + user_id = attr.ib(type=str, default=None, metadata={'json': 'user_id'}) + + +@to_json_decorator +@attr.s +class MentionDoc(object): + token = attr.ib(type=str, default=None, metadata={'json': 'token'}) + obj_type = attr.ib(type=int, default=None, metadata={'json': 'obj_type'}) + url = attr.ib(type=str, default=None, metadata={'json': 'url'}) + title = attr.ib(type=str, default=None, metadata={'json': 'title'}) + + +@to_json_decorator +@attr.s +class Link(object): + url = attr.ib(type=str, default=None, metadata={'json': 'url'}) + + +@to_json_decorator +@attr.s +class TextElementStyle(object): + bold = attr.ib(type=bool, default=None, metadata={'json': 'bold'}) + italic = attr.ib(type=bool, default=None, metadata={'json': 'italic'}) + strikethrough = attr.ib(type=bool, default=None, metadata={'json': 'strikethrough'}) + underline = attr.ib(type=bool, default=None, metadata={'json': 'underline'}) + inline_code = attr.ib(type=bool, default=None, metadata={'json': 'inline_code'}) + background_color = attr.ib(type=int, default=None, metadata={'json': 'background_color'}) + text_color = attr.ib(type=int, default=None, metadata={'json': 'text_color'}) + link = attr.ib(type=Link, default=None, metadata={'json': 'link'}) + + +@to_json_decorator +@attr.s +class TextRun(object): + content = attr.ib(type=str, default=None, metadata={'json': 'content'}) + text_element_style = attr.ib(type=TextElementStyle, default=None, metadata={'json': 'text_element_style'}) + + +@to_json_decorator +@attr.s +class Isv(object): + component_id = attr.ib(type=str, default=None, metadata={'json': 'component_id'}) + component_type_id = attr.ib(type=str, default=None, metadata={'json': 'component_type_id'}) + + +@to_json_decorator +@attr.s +class InsertTableRowRequest(object): + row_index = attr.ib(type=int, default=None, metadata={'json': 'row_index'}) + + +@to_json_decorator +@attr.s +class InsertTableColumnRequest(object): + column_index = attr.ib(type=int, default=None, metadata={'json': 'column_index'}) + + +@to_json_decorator +@attr.s +class InsertGridColumnRequest(object): + column_index = attr.ib(type=int, default=None, metadata={'json': 'column_index'}) + + +@to_json_decorator +@attr.s +class InlineFile(object): + file_token = attr.ib(type=str, default=None, metadata={'json': 'file_token'}) + source_block_id = attr.ib(type=str, default=None, metadata={'json': 'source_block_id'}) + + +@to_json_decorator +@attr.s +class InlineBlock(object): + block_id = attr.ib(type=str, default=None, metadata={'json': 'block_id'}) + + +@to_json_decorator +@attr.s +class TextElement(object): + text_run = attr.ib(type=TextRun, default=None, metadata={'json': 'text_run'}) + mention_user = attr.ib(type=MentionUser, default=None, metadata={'json': 'mention_user'}) + mention_doc = attr.ib(type=MentionDoc, default=None, metadata={'json': 'mention_doc'}) + reminder = attr.ib(type=Reminder, default=None, metadata={'json': 'reminder'}) + file = attr.ib(type=InlineFile, default=None, metadata={'json': 'file'}) + undefined = attr.ib(type=UndefinedElement, default=None, metadata={'json': 'undefined'}) + inline_block = attr.ib(type=InlineBlock, default=None, metadata={'json': 'inline_block'}) + + +@to_json_decorator +@attr.s +class UpdateTextElementsRequest(object): + elements = attr.ib(type=List[TextElement], default=None, metadata={'json': 'elements'}) + + +@to_json_decorator +@attr.s +class Text(object): + style = attr.ib(type=TextStyle, default=None, metadata={'json': 'style'}) + elements = attr.ib(type=List[TextElement], default=None, metadata={'json': 'elements'}) + + +@to_json_decorator +@attr.s +class Image(object): + width = attr.ib(type=int, default=None, metadata={'json': 'width'}) + height = attr.ib(type=int, default=None, metadata={'json': 'height'}) + token = attr.ib(type=str, default=None, metadata={'json': 'token'}) + + +@to_json_decorator +@attr.s +class IframeComponent(object): + iframe_type = attr.ib(type=int, default=None, metadata={'json': 'iframe_type'}) + url = attr.ib(type=str, default=None, metadata={'json': 'url'}) + + +@to_json_decorator +@attr.s +class Iframe(object): + component = attr.ib(type=IframeComponent, default=None, metadata={'json': 'component'}) + + +@to_json_decorator +@attr.s +class GridColumn(object): + width_ratio = attr.ib(type=int, default=None, metadata={'json': 'width_ratio'}) + + +@to_json_decorator +@attr.s +class Grid(object): + column_size = attr.ib(type=int, default=None, metadata={'json': 'column_size'}) + + +@to_json_decorator +@attr.s +class File(object): + token = attr.ib(type=str, default=None, metadata={'json': 'token'}) + name = attr.ib(type=str, default=None, metadata={'json': 'name'}) + + +@to_json_decorator +@attr.s +class Divider(object): + pass + + +@to_json_decorator +@attr.s +class Diagram(object): + diagram_type = attr.ib(type=int, default=None, metadata={'json': 'diagram_type'}) + + +@to_json_decorator +@attr.s +class DeleteTableRowsRequest(object): + row_start_index = attr.ib(type=int, default=None, metadata={'json': 'row_start_index'}) + row_end_index = attr.ib(type=int, default=None, metadata={'json': 'row_end_index'}) + + +@to_json_decorator +@attr.s +class DeleteTableColumnsRequest(object): + column_start_index = attr.ib(type=int, default=None, metadata={'json': 'column_start_index'}) + column_end_index = attr.ib(type=int, default=None, metadata={'json': 'column_end_index'}) + + +@to_json_decorator +@attr.s +class DeleteGridColumnRequest(object): + column_index = attr.ib(type=int, default=None, metadata={'json': 'column_index'}) + + +@to_json_decorator +@attr.s +class UpdateBlockRequest(object): + update_text_elements = attr.ib(type=UpdateTextElementsRequest, default=None, metadata={'json': 'update_text_elements'}) + update_text_style = attr.ib(type=UpdateTextStyleRequest, default=None, metadata={'json': 'update_text_style'}) + update_table_property = attr.ib(type=UpdateTablePropertyRequest, default=None, metadata={'json': 'update_table_property'}) + insert_table_row = attr.ib(type=InsertTableRowRequest, default=None, metadata={'json': 'insert_table_row'}) + insert_table_column = attr.ib(type=InsertTableColumnRequest, default=None, metadata={'json': 'insert_table_column'}) + delete_table_rows = attr.ib(type=DeleteTableRowsRequest, default=None, metadata={'json': 'delete_table_rows'}) + delete_table_columns = attr.ib(type=DeleteTableColumnsRequest, default=None, metadata={'json': 'delete_table_columns'}) + merge_table_cells = attr.ib(type=MergeTableCellsRequest, default=None, metadata={'json': 'merge_table_cells'}) + unmerge_table_cells = attr.ib(type=UnmergeTableCellsRequest, default=None, metadata={'json': 'unmerge_table_cells'}) + insert_grid_column = attr.ib(type=InsertGridColumnRequest, default=None, metadata={'json': 'insert_grid_column'}) + delete_grid_column = attr.ib(type=DeleteGridColumnRequest, default=None, metadata={'json': 'delete_grid_column'}) + update_grid_column_width_ratio = attr.ib(type=UpdateGridColumnWidthRatioRequest, default=None, metadata={'json': 'update_grid_column_width_ratio'}) + replace_image = attr.ib(type=ReplaceImageRequest, default=None, metadata={'json': 'replace_image'}) + replace_file = attr.ib(type=ReplaceFileRequest, default=None, metadata={'json': 'replace_file'}) + block_id = attr.ib(type=str, default=None, metadata={'json': 'block_id'}) + + +@to_json_decorator +@attr.s +class ChatCard(object): + __int_to_string_fields__ = attr.ib(type=List[str], default=["chat_id"]) + chat_id = attr.ib(type=int, default=None, metadata={'json': 'chat_id'}) + align = attr.ib(type=int, default=None, metadata={'json': 'align'}) + + +@to_json_decorator +@attr.s +class Callout(object): + background_color = attr.ib(type=int, default=None, metadata={'json': 'background_color'}) + border_color = attr.ib(type=int, default=None, metadata={'json': 'border_color'}) + text_color = attr.ib(type=int, default=None, metadata={'json': 'text_color'}) + emoji_id = attr.ib(type=str, default=None, metadata={'json': 'emoji_id'}) + + +@to_json_decorator +@attr.s +class Bitable(object): + token = attr.ib(type=str, default=None, metadata={'json': 'token'}) + view_type = attr.ib(type=int, default=None, metadata={'json': 'view_type'}) + + +@to_json_decorator +@attr.s +class Block(object): + block_id = attr.ib(type=str, default=None, metadata={'json': 'block_id'}) + parent_id = attr.ib(type=str, default=None, metadata={'json': 'parent_id'}) + children = attr.ib(type=List[str], default=None, metadata={'json': 'children'}) + block_type = attr.ib(type=int, default=None, metadata={'json': 'block_type'}) + page = attr.ib(type=Text, default=None, metadata={'json': 'page'}) + text = attr.ib(type=Text, default=None, metadata={'json': 'text'}) + heading1 = attr.ib(type=Text, default=None, metadata={'json': 'heading1'}) + heading2 = attr.ib(type=Text, default=None, metadata={'json': 'heading2'}) + heading3 = attr.ib(type=Text, default=None, metadata={'json': 'heading3'}) + heading4 = attr.ib(type=Text, default=None, metadata={'json': 'heading4'}) + heading5 = attr.ib(type=Text, default=None, metadata={'json': 'heading5'}) + heading6 = attr.ib(type=Text, default=None, metadata={'json': 'heading6'}) + heading7 = attr.ib(type=Text, default=None, metadata={'json': 'heading7'}) + heading8 = attr.ib(type=Text, default=None, metadata={'json': 'heading8'}) + heading9 = attr.ib(type=Text, default=None, metadata={'json': 'heading9'}) + bullet = attr.ib(type=Text, default=None, metadata={'json': 'bullet'}) + ordered = attr.ib(type=Text, default=None, metadata={'json': 'ordered'}) + code = attr.ib(type=Text, default=None, metadata={'json': 'code'}) + quote = attr.ib(type=Text, default=None, metadata={'json': 'quote'}) + equation = attr.ib(type=Text, default=None, metadata={'json': 'equation'}) + todo = attr.ib(type=Text, default=None, metadata={'json': 'todo'}) + bitable = attr.ib(type=Bitable, default=None, metadata={'json': 'bitable'}) + callout = attr.ib(type=Callout, default=None, metadata={'json': 'callout'}) + chat_card = attr.ib(type=ChatCard, default=None, metadata={'json': 'chat_card'}) + diagram = attr.ib(type=Diagram, default=None, metadata={'json': 'diagram'}) + divider = attr.ib(type=Divider, default=None, metadata={'json': 'divider'}) + file = attr.ib(type=File, default=None, metadata={'json': 'file'}) + grid = attr.ib(type=Grid, default=None, metadata={'json': 'grid'}) + grid_column = attr.ib(type=GridColumn, default=None, metadata={'json': 'grid_column'}) + iframe = attr.ib(type=Iframe, default=None, metadata={'json': 'iframe'}) + image = attr.ib(type=Image, default=None, metadata={'json': 'image'}) + isv = attr.ib(type=Isv, default=None, metadata={'json': 'isv'}) + mindnote = attr.ib(type=Mindnote, default=None, metadata={'json': 'mindnote'}) + sheet = attr.ib(type=Sheet, default=None, metadata={'json': 'sheet'}) + table = attr.ib(type=Table, default=None, metadata={'json': 'table'}) + table_cell = attr.ib(type=TableCell, default=None, metadata={'json': 'table_cell'}) + view = attr.ib(type=View, default=None, metadata={'json': 'view'}) + undefined = attr.ib(type=Undefined, default=None, metadata={'json': 'undefined'}) + + +@to_json_decorator +@attr.s +class Document(object): + document_id = attr.ib(type=str, default=None, metadata={'json': 'document_id'}) + revision_id = attr.ib(type=int, default=None, metadata={'json': 'revision_id'}) + title = attr.ib(type=str, default=None, metadata={'json': 'title'}) + + + +@to_json_decorator +@attr.s +class DocumentCreateReqBody(object): + folder_token = attr.ib(type=str, default=None, metadata={'json': 'folder_token'}) + title = attr.ib(type=str, default=None, metadata={'json': 'title'}) + + +@attr.s +class DocumentCreateResult(object): + document = attr.ib(type=Document, default=None, metadata={'json': 'document'}) + + + +@attr.s +class DocumentGetResult(object): + document = attr.ib(type=Document, default=None, metadata={'json': 'document'}) + + + +@attr.s +class DocumentRawContentResult(object): + content = attr.ib(type=str, default=None, metadata={'json': 'content'}) + + +@to_json_decorator +@attr.s +class DocumentBlockBatchUpdateReqBody(object): + requests = attr.ib(type=List[UpdateBlockRequest], default=None, metadata={'json': 'requests'}) + + +@attr.s +class DocumentBlockBatchUpdateResult(object): + blocks = attr.ib(type=List[Block], default=None, metadata={'json': 'blocks'}) + document_revision_id = attr.ib(type=int, default=None, metadata={'json': 'document_revision_id'}) + client_token = attr.ib(type=str, default=None, metadata={'json': 'client_token'}) + + + +@attr.s +class DocumentBlockGetResult(object): + block = attr.ib(type=Block, default=None, metadata={'json': 'block'}) + + + +@attr.s +class DocumentBlockListResult(object): + items = attr.ib(type=List[Block], default=None, metadata={'json': 'items'}) + page_token = attr.ib(type=str, default=None, metadata={'json': 'page_token'}) + has_more = attr.ib(type=bool, default=None, metadata={'json': 'has_more'}) + + + +@attr.s +class DocumentBlockPatchResult(object): + block = attr.ib(type=Block, default=None, metadata={'json': 'block'}) + document_revision_id = attr.ib(type=int, default=None, metadata={'json': 'document_revision_id'}) + client_token = attr.ib(type=str, default=None, metadata={'json': 'client_token'}) + + +@to_json_decorator +@attr.s +class DocumentBlockChildrenBatchDeleteReqBody(object): + start_index = attr.ib(type=int, default=None, metadata={'json': 'start_index'}) + end_index = attr.ib(type=int, default=None, metadata={'json': 'end_index'}) + + +@attr.s +class DocumentBlockChildrenBatchDeleteResult(object): + document_revision_id = attr.ib(type=int, default=None, metadata={'json': 'document_revision_id'}) + client_token = attr.ib(type=str, default=None, metadata={'json': 'client_token'}) + + +@to_json_decorator +@attr.s +class DocumentBlockChildrenCreateReqBody(object): + children = attr.ib(type=List[Block], default=None, metadata={'json': 'children'}) + index = attr.ib(type=int, default=None, metadata={'json': 'index'}) + + +@attr.s +class DocumentBlockChildrenCreateResult(object): + children = attr.ib(type=List[Block], default=None, metadata={'json': 'children'}) + document_revision_id = attr.ib(type=int, default=None, metadata={'json': 'document_revision_id'}) + client_token = attr.ib(type=str, default=None, metadata={'json': 'client_token'}) + + + +@attr.s +class DocumentBlockChildrenGetResult(object): + items = attr.ib(type=List[Block], default=None, metadata={'json': 'items'}) + page_token = attr.ib(type=str, default=None, metadata={'json': 'page_token'}) + has_more = attr.ib(type=bool, default=None, metadata={'json': 'has_more'}) \ No newline at end of file