diff --git a/crowdin_api/api_resources/glossaries/resource.py b/crowdin_api/api_resources/glossaries/resource.py index 133f64a..8a1b393 100644 --- a/crowdin_api/api_resources/glossaries/resource.py +++ b/crowdin_api/api_resources/glossaries/resource.py @@ -2,16 +2,17 @@ from crowdin_api.api_resources.abstract.resources import BaseResource from crowdin_api.api_resources.glossaries.enums import ( + TermGender, TermPartOfSpeech, TermStatus, TermType, - TermGender, ) from crowdin_api.api_resources.glossaries.types import ( GlossaryPatchRequest, - TermPatchRequest, - LanguagesDetails, GlossarySchemaRequest, + LanguagesDetails, + OrganizationConcordanceSearchRequest, + TermPatchRequest, ) from crowdin_api.sorting import Sorting @@ -231,6 +232,23 @@ def concordance_search_in_glossaries( request_data=data, ) + def organization_concordance_search(self, request_data: OrganizationConcordanceSearchRequest): + """ + Concordance search in organization glossaries. + + Link to documentation: + https://developer.crowdin.com/api/v2/#operation/api.glossaries.concordance.post + + Link to documentation for enterprise: + https://developer.crowdin.com/enterprise/api/v2/#operation/api.glossaries.concordance.post + """ + + return self.requester.request( + method="post", + path="glossaries/concordance", + request_data=request_data, + ) + # Terms def get_terms_path(self, glossaryId: int, termId: Optional[int] = None): if termId is not None: diff --git a/crowdin_api/api_resources/glossaries/tests/test_glossaries_resources.py b/crowdin_api/api_resources/glossaries/tests/test_glossaries_resources.py index 6a411cc..5b4095a 100644 --- a/crowdin_api/api_resources/glossaries/tests/test_glossaries_resources.py +++ b/crowdin_api/api_resources/glossaries/tests/test_glossaries_resources.py @@ -3,23 +3,23 @@ import pytest from crowdin_api.api_resources.enums import PatchOperation from crowdin_api.api_resources.glossaries.enums import ( + GlossaryExportFields, + GlossaryExportGender, + GlossaryExportPartOfSpeech, + GlossaryExportStatus, + GlossaryExportTermType, + GlossaryExportType, + GlossaryFormat, GlossaryPatchPath, ListConceptsOrderBy, + ListGlossariesCrowdinOrderBy, ListGlossariesEnterpriseOrderBy, ListTermsOrderBy, + TermGender, TermPartOfSpeech, TermPatchPath, TermStatus, TermType, - TermGender, - GlossaryFormat, - GlossaryExportFields, - GlossaryExportType, - GlossaryExportStatus, - GlossaryExportPartOfSpeech, - GlossaryExportTermType, - GlossaryExportGender, - ListGlossariesCrowdinOrderBy, ) from crowdin_api.api_resources.glossaries.resource import GlossariesResource from crowdin_api.requester import APIRequester @@ -354,6 +354,34 @@ def test_concordance_search_in_glossaries(self, m_request, base_absolut_url): request_data=data, ) + @pytest.mark.parametrize( + "data", + ( + { + "sourceLanguageId": "en", + "targetLanguageId": "de", + "expressions": ["Welcome!"], + }, + { + "sourceLanguageId": "en", + "targetLanguageId": "de", + "expressions": ["Welcome!"], + "userId": 12, + }, + ), + ) + @mock.patch("crowdin_api.requester.APIRequester.request") + def test_organization_concordance_search(self, m_request, data, base_absolut_url): + m_request.return_value = "response" + + resource = self.get_resource(base_absolut_url) + assert resource.organization_concordance_search(request_data=data) == "response" + m_request.assert_called_once_with( + method="post", + path="glossaries/concordance", + request_data=data, + ) + # Terms @pytest.mark.parametrize( "in_params, path", diff --git a/crowdin_api/api_resources/glossaries/types.py b/crowdin_api/api_resources/glossaries/types.py index de435ba..df5861e 100644 --- a/crowdin_api/api_resources/glossaries/types.py +++ b/crowdin_api/api_resources/glossaries/types.py @@ -1,16 +1,16 @@ -from typing import Any, Optional, Iterable +from typing import Any, Iterable, Optional from crowdin_api.api_resources.enums import PatchOperation from crowdin_api.api_resources.glossaries.enums import ( - GlossaryPatchPath, - TermPatchPath, - GlossaryFormat, GlossaryExportFields, - GlossaryExportType, - GlossaryExportStatus, + GlossaryExportGender, GlossaryExportPartOfSpeech, + GlossaryExportStatus, GlossaryExportTermType, - GlossaryExportGender, + GlossaryExportType, + GlossaryFormat, + GlossaryPatchPath, + TermPatchPath, ) from crowdin_api.typing import TypedDict @@ -40,6 +40,13 @@ class GlossarySchemaRequest(TypedDict): authorId: Optional[int] +class OrganizationConcordanceSearchRequest(TypedDict): + sourceLanguageId: str + targetLanguageId: str + expressions: Iterable[str] + userId: Optional[int] + + class TermPatchRequest(TypedDict): value: Any op: PatchOperation diff --git a/crowdin_api/api_resources/translation_memory/resource.py b/crowdin_api/api_resources/translation_memory/resource.py index 4a029f4..3880c0c 100644 --- a/crowdin_api/api_resources/translation_memory/resource.py +++ b/crowdin_api/api_resources/translation_memory/resource.py @@ -3,14 +3,15 @@ from crowdin_api.api_resources.abstract.resources import BaseResource from crowdin_api.api_resources.enums import ExportFormat from crowdin_api.api_resources.translation_memory.types import ( + OrganizationConcordanceSearchRequest, TranslationMemoryPatchRequest, TranslationMemorySegmentBatchOperationAdd, TranslationMemorySegmentBatchOperationRemove, TranslationMemorySegmentBatchOperationReplace, TranslationMemorySegmentRecord, TranslationMemorySegmentRecordOperationAdd, - TranslationMemorySegmentRecordOperationReplace, TranslationMemorySegmentRecordOperationRemove, + TranslationMemorySegmentRecordOperationReplace, ) from crowdin_api.sorting import Sorting @@ -320,6 +321,23 @@ def concordance_search_in_tms( request_data=data, ) + def organization_concordance_search(self, request_data: OrganizationConcordanceSearchRequest): + """ + Concordance search in organization TMs. + + Link to documentation: + https://developer.crowdin.com/api/v2/#operation/api.tms.concordance.post + + Link to documentation for enterprise: + https://developer.crowdin.com/enterprise/api/v2/#operation/api.tms.concordance.post + """ + + return self.requester.request( + method="post", + path="tms/concordance", + request_data=request_data, + ) + # Import def import_tm( self, diff --git a/crowdin_api/api_resources/translation_memory/tests/test_translation_memory_resources.py b/crowdin_api/api_resources/translation_memory/tests/test_translation_memory_resources.py index 1b9803e..eeb7992 100644 --- a/crowdin_api/api_resources/translation_memory/tests/test_translation_memory_resources.py +++ b/crowdin_api/api_resources/translation_memory/tests/test_translation_memory_resources.py @@ -11,9 +11,7 @@ TranslationMemorySegmentRecordOperation, TranslationMemorySegmentRecordOperationPath, ) -from crowdin_api.api_resources.translation_memory.resource import ( - TranslationMemoryResource, -) +from crowdin_api.api_resources.translation_memory.resource import TranslationMemoryResource from crowdin_api.requester import APIRequester from crowdin_api.sorting import Sorting, SortingOrder, SortingRule @@ -422,6 +420,38 @@ def test_concordance_search_in_tms(self, m_reqeust, base_absolut_url): request_data=data ) + @pytest.mark.parametrize( + "data", + ( + { + "sourceLanguageId": "en", + "targetLanguageId": "de", + "autoSubstitution": True, + "minRelevant": 60, + "expressions": ["Welcome!"], + }, + { + "sourceLanguageId": "en", + "targetLanguageId": "de", + "autoSubstitution": True, + "minRelevant": 60, + "expressions": ["Welcome!"], + "userId": 12, + }, + ), + ) + @mock.patch("crowdin_api.requester.APIRequester.request") + def test_organization_concordance_search(self, m_request, data, base_absolut_url): + m_request.return_value = "response" + + resource = self.get_resource(base_absolut_url) + assert resource.organization_concordance_search(request_data=data) == "response" + m_request.assert_called_once_with( + method="post", + path="tms/concordance", + request_data=data, + ) + # Import @pytest.mark.parametrize( "in_params, request_data", diff --git a/crowdin_api/api_resources/translation_memory/types.py b/crowdin_api/api_resources/translation_memory/types.py index 784dc83..44ac207 100644 --- a/crowdin_api/api_resources/translation_memory/types.py +++ b/crowdin_api/api_resources/translation_memory/types.py @@ -1,4 +1,4 @@ -from typing import Any, Iterable, Union +from typing import Any, Iterable, Optional, Union from crowdin_api.api_resources.enums import PatchOperation from crowdin_api.api_resources.translation_memory.enums import ( @@ -17,6 +17,15 @@ class TranslationMemoryPatchRequest(TypedDict): path: TranslationMemoryPatchPath +class OrganizationConcordanceSearchRequest(TypedDict): + sourceLanguageId: str + targetLanguageId: str + autoSubstitution: bool + minRelevant: int + expressions: Iterable[str] + userId: Optional[int] + + class TranslationMemorySegmentRecord(TypedDict): languageId: str text: str