| Index: cms/translations/xtm/xtm_api.py | 
| diff --git a/cms/translations/xtm/xtm_api.py b/cms/translations/xtm/xtm_api.py | 
| index cd6a20ce05866c6f3997e872d6bbf192c009a027..1714db1509dcdfc6c69cea3f9ea4a91e8d6231e5 100644 | 
| --- a/cms/translations/xtm/xtm_api.py | 
| +++ b/cms/translations/xtm/xtm_api.py | 
| @@ -61,6 +61,7 @@ class XTMCloudAPI(object): | 
| UPLOAD = 'projects/{0}/files/upload' | 
| GET_TARGET_LANG = 'projects/{0}/metrics' | 
| ADD_TARGET_LANG = 'projects/{0}/target-languages' | 
| + GET_WORKFLOW_IDS = 'workflows' | 
| _MATCH_TYPE = { | 
| False: 'NO_MATCH', | 
| @@ -73,6 +74,7 @@ class XTMCloudAPI(object): | 
| DOWNLOAD = 200 | 
| GET_TARGET_LANGS = 200 | 
| ADD_TARGET_LANGS = 200 | 
| + GET_WORKFLOW_IDS = 200 | 
| def __init__(self, token): | 
| """Constructor. | 
| @@ -388,6 +390,42 @@ class XTMCloudAPI(object): | 
| raise XTMCloudException(response.status_code, response.content, | 
| 'adding target languages to project') | 
| + def get_workflows_by_name(self, name, exact=True): | 
| + """Get workflows with a specific name. | 
| + | 
| + Parameters | 
| + ---------- | 
| + name: str | 
| + The name of the workflow we're looking for. | 
| + exact: bool | 
| 
 
Vasily Kuznetsov
2018/10/16 14:52:54
Do we actually use this?
 
Tudor Avram
2018/10/18 16:29:23
No, we don't. We're only interested in exact match
 
 | 
| + Whether we're looking for exact matches only or if partial ones | 
| + are ok, too. Default True. | 
| + | 
| + Returns | 
| + ------- | 
| + iterable | 
| + Of workflow ids that match the name. | 
| + | 
| + """ | 
| + url = self.base_url + self._UrlPaths.GET_WORKFLOW_IDS | 
| + | 
| + response = self._execute(url, params={'name': name}) | 
| + | 
| + if response.status_code != self._SuccessCodes.GET_WORKFLOW_IDS: | 
| + raise XTMCloudException(response.status_code, response.content, | 
| + 'extracting workflow ids') | 
| + | 
| + if not exact: | 
| + return [item['id'] | 
| + for item in json.loads(response.content.encode('utf-8'))] | 
| + | 
| + valid_ids = [] | 
| + for item in json.loads(response.content.encode('utf-8')): | 
| + if name.lower().replace(' ', '') == \ | 
| + item['name'].lower().replace(' ', ''): | 
| + valid_ids.append(item['id']) | 
| + return valid_ids | 
| + | 
| def get_token(username, password, user_id): | 
| """Generate an API token from username and password. |