Skip to content

RPS-7890. Update api-python-sdk to the latest version #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions builder/ApiSource.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,6 @@ def collectMethods(self, swaggerDict):
self.methods.append(m)

def patchMethods(self, descr, m, swaggerDict):
if descr['operationId'] == 'exportFileTranslations':
propDict = {
"type": "string",
"format": "binary",
"description": "The file contents to upload."
}
mp = MultipartProperty('file', propDict, swaggerDict)
mp.setRequired()
m.needMultipart = True
m.multipartParameters.insert(0, mp)
if descr['operationId'] in ('getAllSourceStringsByProject'):
m.method = 'post'
m.isJson = True
Expand Down
3 changes: 3 additions & 0 deletions changes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Aug 29, 2024 - 3.1.6
- updated according the latest changes in Smartling SDK

Dec 09, 2022 - 3.1.5
- fix of ApiResponse get attribute may cause stack overflow on requesting non-existng attribute

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
description="python library to work with Smartling translation services APIs",
license='Apache License v2.0',
keywords='translation localization internationalization',
url="https://api-reference.smartling.com/",
url="",
long_description="python SDK to work with Smartling API for computer assisted translation",
packages=['smartlingApiSdk','smartlingApiSdk/example','smartlingApiSdk/api'],
packages=['smartlingApiSdk','smartlingApiSdk/example','smartlingApiSdk/api','smartlingApiSdk/resources'],
include_package_data = True,
package_data = {
'': ['*.properties', '*.xml', '*.png', '*.csv'],
Expand Down
4 changes: 3 additions & 1 deletion smartlingApiSdk/api/AccountProjectsApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class AccountProjectsApi(ApiV2):
def __init__(self, userIdentifier, userSecret, projectId, proxySettings=None, permanentHeaders={}, env='prod'):
ApiV2.__init__(self, userIdentifier, userSecret, projectId, proxySettings, permanentHeaders=permanentHeaders, env=env)

def getProjectsByAccount(self, accountUid, projectNameFilter='', includeArchived='', offset=0, limit=0, **kwargs):
def getProjectsByAccount(self, accountUid, projectNameFilter='', includeArchived='', offset=0, limit=0, projectTypeCode='', projectTypeCodes=[], **kwargs):
"""
method : GET
api url : /accounts-api/v2/accounts/{accountUid}/projects
Expand All @@ -40,6 +40,8 @@ def getProjectsByAccount(self, accountUid, projectNameFilter='', includeArchived
'includeArchived':includeArchived,
'offset':offset,
'limit':limit,
'projectTypeCode':projectTypeCode,
'projectTypeCodes':projectTypeCodes,
}
kw.update(kwargs)
url = self.urlHelper.getUrl('/accounts-api/v2/accounts/{accountUid}/projects', accountUid=accountUid, **kwargs)
Expand Down
3 changes: 2 additions & 1 deletion smartlingApiSdk/api/ContextApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def downloadVisualContextFileContent(self, contextUid, **kwargs):
return response, status


def runAutomaticContextMatching(self, contextUid, contentFileUri='', stringHashcodes=[], translationJobUids=[], overrideContextOlderThanDays=0, **kwargs):
def runAutomaticContextMatching(self, contextUid, contentFileUri='', stringHashcodes=[], translationJobUids=[], overrideContextOlderThanDays=0, videoMatchingMode='', **kwargs):
"""
method : POST
api url : /context-api/v2/projects/{projectId}/contexts/{contextUid}/match/async
Expand All @@ -145,6 +145,7 @@ def runAutomaticContextMatching(self, contextUid, contentFileUri='', stringHashc
'stringHashcodes':stringHashcodes,
'translationJobUids':translationJobUids,
'overrideContextOlderThanDays':overrideContextOlderThanDays,
'videoMatchingMode':videoMatchingMode,
}
kw.update(kwargs)
url = self.urlHelper.getUrl('/context-api/v2/projects/{projectId}/contexts/{contextUid}/match/async', contextUid=contextUid, **kwargs)
Expand Down
4 changes: 2 additions & 2 deletions smartlingApiSdk/api/EstimatesApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def getJobFuzzyEstimateReports(self, translationJobUid, reportStatus='', content
return response, status


def generateJobFuzzyEstimateReports(self, translationJobUid, contentType='', tags=[], **kwargs):
def generateJobFuzzyEstimateReports(self, translationJobUid, contentType='ALL_CONTENT', tags=[], **kwargs):
"""
method : POST
api url : /estimates-api/v2/projects/{projectId}/jobs/{translationJobUid}/reports/fuzzy
Expand Down Expand Up @@ -94,7 +94,7 @@ def getJobCostEstimateReports(self, translationJobUid, reportStatus='', contentC
return response, status


def generateJobCostEstimateReports(self, translationJobUid, contentType='', tags=[], localeWorkflows=[], fuzzyProfileUid='', **kwargs):
def generateJobCostEstimateReports(self, translationJobUid, contentType='ALL_CONTENT', tags=[], localeWorkflows=[], fuzzyProfileUid='', **kwargs):
"""
method : POST
api url : /estimates-api/v2/projects/{projectId}/jobs/{translationJobUid}/reports/cost
Expand Down
4 changes: 1 addition & 3 deletions smartlingApiSdk/api/FilesApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class FilesApi(ApiV2):
def __init__(self, userIdentifier, userSecret, projectId, proxySettings=None, permanentHeaders={}, env='prod'):
ApiV2.__init__(self, userIdentifier, userSecret, projectId, proxySettings, permanentHeaders=permanentHeaders, env=env)

def uploadSourceFile(self, file, fileUri, fileType, authorize=False, localeIdsToAuthorize=[], callbackUrl='', directives={}, **kwargs):
def uploadSourceFile(self, file, fileUri, fileType, callbackUrl='', directives={}, **kwargs):
"""
method : POST
api url : /files-api/v2/projects/{projectId}/file
Expand All @@ -41,8 +41,6 @@ def uploadSourceFile(self, file, fileUri, fileType, authorize=False, localeIdsTo
'file':self.processFile(file),
'fileUri':fileUri,
'fileType':fileType,
'authorize':authorize,
'localeIdsToAuthorize':localeIdsToAuthorize,
'callbackUrl':callbackUrl,
}
self.addLibIdDirective(kw)
Expand Down
4 changes: 2 additions & 2 deletions smartlingApiSdk/api/JobsApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def findJobsByStrings(self, hashcodes=[], localeIds=[], **kwargs):
return response, status


def getStringsForTranslationJob(self, translationJobUid, targetLocaleId='', limit=0, offset=0, **kwargs):
def getStringsForTranslationJob(self, translationJobUid, targetLocaleId='', limit=1000, offset=0, **kwargs):
"""
method : GET
api url : /jobs-api/v3/projects/{projectId}/jobs/{translationJobUid}/strings
Expand Down Expand Up @@ -371,7 +371,7 @@ def removeFileFromJob(self, translationJobUid, fileUri='', **kwargs):
return response, status


def getJobFilesList(self, translationJobUid, limit=0, offset=0, **kwargs):
def getJobFilesList(self, translationJobUid, limit=1000, offset=0, **kwargs):
"""
method : GET
api url : /jobs-api/v3/projects/{projectId}/jobs/{translationJobUid}/files
Expand Down
21 changes: 21 additions & 0 deletions smartlingApiSdk/api/TagsApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,27 @@ class TagsApi(ApiV2):
def __init__(self, userIdentifier, userSecret, projectId, proxySettings=None, permanentHeaders={}, env='prod'):
ApiV2.__init__(self, userIdentifier, userSecret, projectId, proxySettings, permanentHeaders=permanentHeaders, env=env)

def getTagsListByAccount(self, accountUid, projectIds=[], tagMask='', limit=1500, offset=0, **kwargs):
"""
method : POST
api url : /tags-api/v2/accounts/{accountUid}/tags
as curl : curl -H "Authorization: Bearer $smartlingToken" https://api.smartling.com/tags-api/v2/accounts/$smartlingAccountUid/tags
Responses:
200 : OK
details : https://api-reference.smartling.com/#operation/getTagsListByAccount
"""
kw = {
'projectIds':projectIds,
'tagMask':tagMask,
'limit':limit,
'offset':offset,
}
kw.update(kwargs)
url = self.urlHelper.getUrl('/tags-api/v2/accounts/{accountUid}/tags', accountUid=accountUid, **kwargs)
response, status = self.commandJson('POST', url, kw)
return response, status


def getTagsListByProject(self, tagMask='', limit=100, offset=0, **kwargs):
"""
method : GET
Expand Down
3 changes: 1 addition & 2 deletions smartlingApiSdk/example/FilesExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ def checkUploadSourceFile(self):
file=self.FILE_PATH + self.FILE_NAME
fileUri=self.uri
fileType=self.FILE_TYPE
localeIdsToAuthorize=[self.MY_LOCALE]
res, status = self.files_api.uploadSourceFile(file=file, fileUri=fileUri, fileType=fileType, localeIdsToAuthorize=localeIdsToAuthorize)
res, status = self.files_api.uploadSourceFile(file=file, fileUri=fileUri, fileType=fileType)


assert_equal(res.data.wordCount, 6)
Expand Down
4 changes: 4 additions & 0 deletions smartlingApiSdk/example/TagsExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ def example():
t.checkRemoveTagsFromStrings()
t.checkAddTagToStrings()
t.checkRemoveAllTagsFromStrings()
# not covered by tests #
'''
getTagsListByAccount
'''
t.tearDown()

if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion smartlingApiSdk/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
* limitations under the License.
"""

version = "3.1.5"
version = "3.1.6"
2 changes: 2 additions & 0 deletions test/testApiChanges.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ def testAll(self):

if 'JobBatchesV2' == api_name:
api_name = 'Job Batches V2'
continue # api description is moved to yaml format whuch is not supported yet:
# "/job-batches-api/v2/projects/{projectId}/batches": { "$ref": "./spec/job_batches_v2/job_batches_endpoints.yaml#/x-paths/create_list_batches"

print ("Cheking:%s" % api_name)
apisrc = ApiBuilder(api_name).apisrc
Expand Down
3 changes: 1 addition & 2 deletions test/testFiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ def checkUploadSourceFile(self):
file=self.FILE_PATH + self.FILE_NAME
fileUri=self.uri
fileType=self.FILE_TYPE
localeIdsToAuthorize=[self.MY_LOCALE]
res, status = self.files_api.uploadSourceFile(file=file, fileUri=fileUri, fileType=fileType, localeIdsToAuthorize=localeIdsToAuthorize)
res, status = self.files_api.uploadSourceFile(file=file, fileUri=fileUri, fileType=fileType)


assert_equal(res.data.wordCount, 6)
Expand Down
1 change: 1 addition & 0 deletions test/testJobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@ def checkCancelJob(self):

assert_equal(True, status in [200,202])
assert_equal(True, res.code in [self.CODE_SUCCESS_TOKEN, self.ACCEPTED_TOKEN])
time.sleep(15) #wait for job to be cancelled
print('cancelJob', 'OK')


Expand Down
4 changes: 4 additions & 0 deletions test/testTags.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,7 @@ def test_all(self):
t.checkRemoveTagsFromStrings()
t.checkAddTagToStrings()
t.checkRemoveAllTagsFromStrings()
# not covered by tests #
'''
getTagsListByAccount
'''