Skip to content

Commit b4f87b9

Browse files
SDK regenerated by CI server [ci skip]
1 parent 80d2444 commit b4f87b9

File tree

9 files changed

+239
-7
lines changed

9 files changed

+239
-7
lines changed
11.8 KB
Binary file not shown.

asposewordscloud/api_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ def __init__(self, configuration=None, header_name=None, header_value=None,
8383

8484
self.pool = None
8585
self.rest_client = rest.RESTClientObject(configuration)
86-
self.default_headers = {'x-aspose-client': 'python sdk', 'x-aspose-version': '22.3'}
86+
self.default_headers = {'x-aspose-client': 'python sdk', 'x-aspose-version': '22.4'}
8787
if header_name is not None:
8888
self.default_headers[header_name] = header_value
8989
self.cookie = cookie
9090
# Set default User-Agent.
91-
self.user_agent = 'python sdk 22.3'
91+
self.user_agent = 'python sdk 22.4'
9292

9393
def __del__(self):
9494
if not self.pool is None:

asposewordscloud/apis/words_api.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,6 +1500,86 @@ def copy_style_online_with_http_info(self, request, **kwargs): # noqa: E501
15001500
_request_timeout=params.get('_request_timeout'),
15011501
collection_formats=http_params['collection_formats']))
15021502

1503+
def copy_styles_from_template(self, request, **kwargs): # noqa: E501
1504+
"""Copies styles from the origin document to the target document. # noqa: E501
1505+
1506+
This method makes a synchronous HTTP request by default. To make an
1507+
asynchronous HTTP request, please pass is_async=True
1508+
1509+
:param is_async bool
1510+
:param name str : The filename of the target document. (required)
1511+
:param template_name str : The filename of the origin document. (required)
1512+
:param folder str : Original document folder.
1513+
:param storage str : Original document storage.
1514+
:param load_encoding str : Encoding that will be used to load an HTML (or TXT) document if the encoding is not specified in HTML.
1515+
:param password str : Password of protected Word document. Use the parameter to pass a password via SDK. SDK encrypts it automatically. We don't recommend to use the parameter to pass a plain password for direct call of API.
1516+
:param encrypted_password str : Password of protected Word document. Use the parameter to pass an encrypted password for direct calls of API. See SDK code for encyption details.
1517+
:param dest_file_name str : Result path of the document after the operation. If this parameter is omitted then result of the operation will be saved as the source document.
1518+
:param revision_author str : Initials of the author to use for revisions.If you set this parameter and then make some changes to the document programmatically, save the document and later open the document in MS Word you will see these changes as revisions.
1519+
:param revision_date_time str : The date and time to use for revisions.
1520+
:return: WordsResponse
1521+
If the method is called asynchronously,
1522+
returns the request thread.
1523+
"""
1524+
try:
1525+
if kwargs.get('is_async'):
1526+
return self.copy_styles_from_template_with_http_info(request, **kwargs) # noqa: E501
1527+
data = self.copy_styles_from_template_with_http_info(request, **kwargs) # noqa: E501
1528+
return data
1529+
except ApiException as e:
1530+
if e.status == 401:
1531+
self.api_client.request_token()
1532+
if kwargs.get('is_async'):
1533+
return self.copy_styles_from_template_with_http_info(request, **kwargs) # noqa: E501
1534+
data = self.copy_styles_from_template_with_http_info(request, **kwargs) # noqa: E501
1535+
return data
1536+
1537+
def copy_styles_from_template_with_http_info(self, request, **kwargs): # noqa: E501
1538+
"""Copies styles from the origin document to the target document. # noqa: E501
1539+
1540+
This method makes a synchronous HTTP request by default. To make an
1541+
asynchronous HTTP request, please pass is_async=True
1542+
1543+
:param is_async bool
1544+
:param request CopyStylesFromTemplateRequest object with parameters
1545+
:return: WordsResponse
1546+
If the method is called asynchronously,
1547+
returns the request thread.
1548+
"""
1549+
1550+
params = locals()
1551+
params['is_async'] = ''
1552+
params['_preload_content'] = True
1553+
params['_request_timeout'] = self.timeout
1554+
for key, val in six.iteritems(params['kwargs']):
1555+
if key not in params:
1556+
raise TypeError(
1557+
"Got an unexpected keyword argument '%s'"
1558+
" to method copy_styles_from_template" % key
1559+
)
1560+
params[key] = val
1561+
del params['kwargs']
1562+
http_params = request.create_http_request(self.api_client)
1563+
1564+
# Authentication setting
1565+
auth_settings = ['JWT'] # noqa: E501
1566+
1567+
self.api_client.handle_password(http_params, self)
1568+
1569+
return request.deserialize_response(self.api_client, self.api_client.call_api(
1570+
http_params['path'],
1571+
http_params['method'],
1572+
http_params['query_params'],
1573+
http_params['header_params'],
1574+
body=http_params['body'],
1575+
post_params=http_params['form_params'],
1576+
response_type=http_params['response_type'], # noqa: E501
1577+
auth_settings=auth_settings,
1578+
is_async=params.get('is_async'),
1579+
_preload_content=params.get('_preload_content', True),
1580+
_request_timeout=params.get('_request_timeout'),
1581+
collection_formats=http_params['collection_formats']))
1582+
15031583
def create_document(self, request, **kwargs): # noqa: E501
15041584
"""Supported extensions: ".doc", ".docx", ".docm", ".dot", ".dotm", ".dotx", ".flatopc", ".fopc", ".flatopc_macro", ".fopc_macro", ".flatopc_template", ".fopc_template", ".flatopc_template_macro", ".fopc_template_macro", ".wordml", ".wml", ".rtf". # noqa: E501
15051585

asposewordscloud/configuration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,6 @@ def to_debug_report(self):
262262
return "Python SDK Debug Report:\n"\
263263
"OS: {env}\n"\
264264
"Python Version: {pyversion}\n"\
265-
"Version of the API: 22.3\n"\
266-
"SDK Package Version: 22.3".\
265+
"Version of the API: 22.4\n"\
266+
"SDK Package Version: 22.4".\
267267
format(env=sys.platform, pyversion=sys.version)

asposewordscloud/models/pdf_save_options_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ def compliance(self, compliance):
817817
:param compliance: The compliance of this PdfSaveOptionsData. # noqa: E501
818818
:type: str
819819
"""
820-
allowed_values = ["Pdf17", "Pdf20", "PdfA1a", "PdfA1b", "PdfA2a", "PdfA2u", "PdfUa1"] # noqa: E501
820+
allowed_values = ["Pdf17", "Pdf20", "PdfA1a", "PdfA1b", "PdfA2a", "PdfA2u", "PdfA4", "PdfUa1"] # noqa: E501
821821
if not compliance.isdigit():
822822
if compliance not in allowed_values:
823823
raise ValueError(

asposewordscloud/models/requests/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from asposewordscloud.models.requests.copy_folder_request import CopyFolderRequest
1919
from asposewordscloud.models.requests.copy_style_request import CopyStyleRequest
2020
from asposewordscloud.models.requests.copy_style_online_request import CopyStyleOnlineRequest
21+
from asposewordscloud.models.requests.copy_styles_from_template_request import CopyStylesFromTemplateRequest
2122
from asposewordscloud.models.requests.create_document_request import CreateDocumentRequest
2223
from asposewordscloud.models.requests.create_folder_request import CreateFolderRequest
2324
from asposewordscloud.models.requests.create_or_update_document_property_request import CreateOrUpdateDocumentPropertyRequest
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# coding: utf-8
2+
# -----------------------------------------------------------------------------------
3+
# <copyright company="Aspose" file="copy_styles_from_template_request.py">
4+
# Copyright (c) 2022 Aspose.Words for Cloud
5+
# </copyright>
6+
# <summary>
7+
# Permission is hereby granted, free of charge, to any person obtaining a copy
8+
# of this software and associated documentation files (the "Software"), to deal
9+
# in the Software without restriction, including without limitation the rights
10+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
# copies of the Software, and to permit persons to whom the Software is
12+
# furnished to do so, subject to the following conditions:
13+
#
14+
# The above copyright notice and this permission notice shall be included in all
15+
# copies or substantial portions of the Software.
16+
#
17+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
# SOFTWARE.
24+
# </summary>
25+
# -----------------------------------------------------------------------------------
26+
import json
27+
28+
from six.moves.urllib.parse import quote
29+
from asposewordscloud import *
30+
from asposewordscloud.models import *
31+
from asposewordscloud.models.requests import *
32+
from asposewordscloud.models.responses import *
33+
34+
class CopyStylesFromTemplateRequest(BaseRequestObject):
35+
"""
36+
Request model for copy_styles_from_template operation.
37+
Initializes a new instance.
38+
:param name The filename of the target document.
39+
:param template_name The filename of the origin document.
40+
:param folder Original document folder.
41+
:param storage Original document storage.
42+
:param load_encoding Encoding that will be used to load an HTML (or TXT) document if the encoding is not specified in HTML.
43+
:param password Password of protected Word document. Use the parameter to pass a password via SDK. SDK encrypts it automatically. We don't recommend to use the parameter to pass a plain password for direct call of API.
44+
:param encrypted_password Password of protected Word document. Use the parameter to pass an encrypted password for direct calls of API. See SDK code for encyption details.
45+
:param dest_file_name Result path of the document after the operation. If this parameter is omitted then result of the operation will be saved as the source document.
46+
:param revision_author Initials of the author to use for revisions.If you set this parameter and then make some changes to the document programmatically, save the document and later open the document in MS Word you will see these changes as revisions.
47+
:param revision_date_time The date and time to use for revisions.
48+
"""
49+
50+
def __init__(self, name, template_name, folder=None, storage=None, load_encoding=None, password=None, encrypted_password=None, dest_file_name=None, revision_author=None, revision_date_time=None):
51+
self.name = name
52+
self.template_name = template_name
53+
self.folder = folder
54+
self.storage = storage
55+
self.load_encoding = load_encoding
56+
self.password = password
57+
self.encrypted_password = encrypted_password
58+
self.dest_file_name = dest_file_name
59+
self.revision_author = revision_author
60+
self.revision_date_time = revision_date_time
61+
62+
def create_http_request(self, api_client):
63+
# verify the required parameter 'name' is set
64+
if self.name is None:
65+
raise ValueError("Missing the required parameter `name` when calling `copy_styles_from_template`") # noqa: E501
66+
# verify the required parameter 'template_name' is set
67+
if self.template_name is None:
68+
raise ValueError("Missing the required parameter `template_name` when calling `copy_styles_from_template`") # noqa: E501
69+
70+
path = '/v4.0/words/{name}/styles/copy_from'
71+
path_params = {}
72+
if self.name is not None:
73+
path_params['name'] = self.name # noqa: E501
74+
else:
75+
path_params['name'] = '' # noqa: E501
76+
77+
# path parameters
78+
collection_formats = {}
79+
if path_params:
80+
path_params = api_client.sanitize_for_serialization(path_params)
81+
path_params = api_client.parameters_to_tuples(path_params, collection_formats)
82+
for k, v in path_params:
83+
# specified safe chars, encode everything
84+
path = path.replace(
85+
'{%s}' % k,
86+
quote(str(v), safe=api_client.configuration.safe_chars_for_path_param)
87+
)
88+
89+
# remove optional path parameters
90+
path = path.replace('//', '/')
91+
92+
query_params = []
93+
if self.template_name is not None:
94+
query_params.append(('templateName', self.template_name)) # noqa: E501
95+
if self.folder is not None:
96+
query_params.append(('folder', self.folder)) # noqa: E501
97+
if self.storage is not None:
98+
query_params.append(('storage', self.storage)) # noqa: E501
99+
if self.load_encoding is not None:
100+
query_params.append(('loadEncoding', self.load_encoding)) # noqa: E501
101+
if self.password is not None:
102+
query_params.append(('password', self.password)) # noqa: E501
103+
if self.encrypted_password is not None:
104+
query_params.append(('encryptedPassword', self.encrypted_password)) # noqa: E501
105+
if self.dest_file_name is not None:
106+
query_params.append(('destFileName', self.dest_file_name)) # noqa: E501
107+
if self.revision_author is not None:
108+
query_params.append(('revisionAuthor', self.revision_author)) # noqa: E501
109+
if self.revision_date_time is not None:
110+
query_params.append(('revisionDateTime', self.revision_date_time)) # noqa: E501
111+
112+
header_params = {}
113+
114+
form_params = []
115+
116+
body_params = None
117+
return {
118+
"method": "PUT",
119+
"path": path,
120+
"query_params": query_params,
121+
"header_params": header_params,
122+
"form_params": form_params,
123+
"body": body_params,
124+
"collection_formats": collection_formats,
125+
"response_type": 'WordsResponse' # noqa: E501
126+
}
127+
128+
def get_response_type(self):
129+
return 'WordsResponse' # noqa: E501
130+
131+
def deserialize_response(self, api_client, response):
132+
return api_client.deserialize(response.data, response.getheaders(), WordsResponse)

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E501
77
8-
OpenAPI spec version: 22.3
8+
OpenAPI spec version: 22.4
99
1010
Generated by: https://github.com/swagger-api/swagger-codegen.git
1111
"""
@@ -14,7 +14,7 @@
1414
from setuptools import setup, find_packages # noqa: H301
1515

1616
NAME = "aspose-words-cloud"
17-
VERSION = "22.3.0"
17+
VERSION = "22.4.0"
1818
# To install the library, run the following
1919
#
2020
# python setup.py install

test/api/styles/test_styles.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,3 +249,22 @@ def test_apply_style_to_document_element_online(self):
249249
result = self.words_api.apply_style_to_document_element_online(request)
250250
self.assertIsNotNone(result, 'Error has occurred.')
251251

252+
253+
#
254+
# Test for copying styles from a template.
255+
#
256+
def test_copy_styles_from_template(self):
257+
remote_data_folder = self.remote_test_folder + '/DocumentElements/Styles'
258+
local_file = 'DocumentElements/Styles/GetStyles.docx'
259+
remote_file_name = 'TestCopyStylesFromTemplate.docx'
260+
template_folder = 'DocumentElements/Styles'
261+
template_name = 'StyleTemplate.docx'
262+
263+
self.upload_file(remote_data_folder + '/' + remote_file_name, open(os.path.join(self.local_test_folder, local_file), 'rb'))
264+
self.upload_file(remote_data_folder + '/' + template_name, open(os.path.join(self.local_test_folder, template_folder + '/' + template_name), 'rb'))
265+
266+
request = asposewordscloud.models.requests.CopyStylesFromTemplateRequest(name=remote_file_name, template_name=template_name, folder=remote_data_folder)
267+
268+
result = self.words_api.copy_styles_from_template(request)
269+
self.assertIsNotNone(result, 'Error has occurred.')
270+

0 commit comments

Comments
 (0)