From 9ab2ca0da5954cfaeb38501a0a29fe38e1931b9e Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Sat, 1 Jun 2019 00:10:58 +0000 Subject: [PATCH 1/3] Generated from 0bc60ed42fd5aa7a857431b75a7d9ec7a7e6482d Adding optional support for subfolders in source parameter to Train API. --- .../formrecognizer/form_recognizer_client.py | 8 +++- .../formrecognizer/models/__init__.py | 3 ++ .../formrecognizer/models/train_request.py | 6 +++ .../models/train_request_py3.py | 8 +++- .../models/train_source_filter.py | 41 +++++++++++++++++++ .../models/train_source_filter_py3.py | 41 +++++++++++++++++++ 6 files changed, 104 insertions(+), 3 deletions(-) create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_source_filter.py create mode 100644 sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_source_filter_py3.py diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/form_recognizer_client.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/form_recognizer_client.py index 22db48af28ea..4d5b73245cd3 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/form_recognizer_client.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/form_recognizer_client.py @@ -73,7 +73,7 @@ def __init__( def train_custom_model( - self, source, custom_headers=None, raw=False, **operation_config): + self, source, source_filter=None, custom_headers=None, raw=False, **operation_config): """Train Model. Create and train a custom model. The train request must include a @@ -92,6 +92,10 @@ def train_custom_model( :param source: Get or set source path. :type source: str + :param source_filter: Get or set filter to further search the + source path for content. + :type source_filter: + ~azure.cognitiveservices.formrecognizer.models.TrainSourceFilter :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -103,7 +107,7 @@ def train_custom_model( :raises: :class:`ErrorResponseException` """ - train_request = models.TrainRequest(source=source) + train_request = models.TrainRequest(source=source, source_filter=source_filter) # Construct URL url = self.train_custom_model.metadata['url'] diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/__init__.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/__init__.py index dd715045ff1b..d409491013c6 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/__init__.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/__init__.py @@ -10,6 +10,7 @@ # -------------------------------------------------------------------------- try: + from .train_source_filter_py3 import TrainSourceFilter from .train_request_py3 import TrainRequest from .form_document_report_py3 import FormDocumentReport from .form_operation_error_py3 import FormOperationError @@ -38,6 +39,7 @@ from .computer_vision_error_py3 import ComputerVisionError, ComputerVisionErrorException from .image_url_py3 import ImageUrl except (SyntaxError, ImportError): + from .train_source_filter import TrainSourceFilter from .train_request import TrainRequest from .form_document_report import FormDocumentReport from .form_operation_error import FormOperationError @@ -72,6 +74,7 @@ ) __all__ = [ + 'TrainSourceFilter', 'TrainRequest', 'FormDocumentReport', 'FormOperationError', diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_request.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_request.py index b29c8b6e02eb..371f70939092 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_request.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_request.py @@ -19,6 +19,10 @@ class TrainRequest(Model): :param source: Required. Get or set source path. :type source: str + :param source_filter: Get or set filter to further search the + source path for content. + :type source_filter: + ~azure.cognitiveservices.formrecognizer.models.TrainSourceFilter """ _validation = { @@ -27,8 +31,10 @@ class TrainRequest(Model): _attribute_map = { 'source': {'key': 'source', 'type': 'str'}, + 'source_filter': {'key': 'sourceFilter', 'type': 'TrainSourceFilter'}, } def __init__(self, **kwargs): super(TrainRequest, self).__init__(**kwargs) self.source = kwargs.get('source', None) + self.source_filter = kwargs.get('source_filter', None) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_request_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_request_py3.py index e32bbf06cad1..3e08a8464e8e 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_request_py3.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_request_py3.py @@ -19,6 +19,10 @@ class TrainRequest(Model): :param source: Required. Get or set source path. :type source: str + :param source_filter: Get or set filter to further search the + source path for content. + :type source_filter: + ~azure.cognitiveservices.formrecognizer.models.TrainSourceFilter """ _validation = { @@ -27,8 +31,10 @@ class TrainRequest(Model): _attribute_map = { 'source': {'key': 'source', 'type': 'str'}, + 'source_filter': {'key': 'sourceFilter', 'type': 'TrainSourceFilter'}, } - def __init__(self, *, source: str, **kwargs) -> None: + def __init__(self, *, source: str, source_filter=None, **kwargs) -> None: super(TrainRequest, self).__init__(**kwargs) self.source = source + self.source_filter = source_filter diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_source_filter.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_source_filter.py new file mode 100644 index 000000000000..c99bc146b017 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_source_filter.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class TrainSourceFilter(Model): + """Filters to be applied when traversing a data source. + + :param prefix: A case-sensitive prefix string to filter content + under the source location. For e.g., when using a Azure Blob + Uri use the prefix to restrict subfolders for content. + :type prefix: str + :param include_sub_folders: A flag to indicate of sub folders within the + set of + prefix folders will also need to included when searching + for content to be preprocessed. + :type include_sub_folders: bool + """ + + _validation = { + 'prefix': {'max_length': 128, 'min_length': 0}, + } + + _attribute_map = { + 'prefix': {'key': 'prefix', 'type': 'str'}, + 'include_sub_folders': {'key': 'includeSubFolders', 'type': 'bool'}, + } + + def __init__(self, **kwargs): + super(TrainSourceFilter, self).__init__(**kwargs) + self.prefix = kwargs.get('prefix', None) + self.include_sub_folders = kwargs.get('include_sub_folders', None) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_source_filter_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_source_filter_py3.py new file mode 100644 index 000000000000..f155786f0658 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_source_filter_py3.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class TrainSourceFilter(Model): + """Filters to be applied when traversing a data source. + + :param prefix: A case-sensitive prefix string to filter content + under the source location. For e.g., when using a Azure Blob + Uri use the prefix to restrict subfolders for content. + :type prefix: str + :param include_sub_folders: A flag to indicate of sub folders within the + set of + prefix folders will also need to included when searching + for content to be preprocessed. + :type include_sub_folders: bool + """ + + _validation = { + 'prefix': {'max_length': 128, 'min_length': 0}, + } + + _attribute_map = { + 'prefix': {'key': 'prefix', 'type': 'str'}, + 'include_sub_folders': {'key': 'includeSubFolders', 'type': 'bool'}, + } + + def __init__(self, *, prefix: str=None, include_sub_folders: bool=None, **kwargs) -> None: + super(TrainSourceFilter, self).__init__(**kwargs) + self.prefix = prefix + self.include_sub_folders = include_sub_folders From ab0907c685c1626b9417faa25998c14aee5a47cb Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Wed, 5 Jun 2019 14:39:13 +0000 Subject: [PATCH 2/3] Generated from 32fa3cb8bf93a50a580b82444835251dde1b09e4 Minor fix to sawgger, removed merged swagger. --- .../formrecognizer/models/train_source_filter.py | 2 +- .../formrecognizer/models/train_source_filter_py3.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_source_filter.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_source_filter.py index c99bc146b017..2e6dc649cd47 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_source_filter.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_source_filter.py @@ -19,7 +19,7 @@ class TrainSourceFilter(Model): under the source location. For e.g., when using a Azure Blob Uri use the prefix to restrict subfolders for content. :type prefix: str - :param include_sub_folders: A flag to indicate of sub folders within the + :param include_sub_folders: A flag to indicate if sub folders within the set of prefix folders will also need to included when searching for content to be preprocessed. diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_source_filter_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_source_filter_py3.py index f155786f0658..7aa5a1cc8de0 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_source_filter_py3.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_source_filter_py3.py @@ -19,7 +19,7 @@ class TrainSourceFilter(Model): under the source location. For e.g., when using a Azure Blob Uri use the prefix to restrict subfolders for content. :type prefix: str - :param include_sub_folders: A flag to indicate of sub folders within the + :param include_sub_folders: A flag to indicate if sub folders within the set of prefix folders will also need to included when searching for content to be preprocessed. From 3862e397852a3cbde26c0c1f4ebe507b7173dafa Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Wed, 5 Jun 2019 17:30:11 +0000 Subject: [PATCH 3/3] Generated from e0c7d245283e52eeca9285dcb4d3f7bdcfb14331 Minor text fix. --- .../formrecognizer/models/train_source_filter.py | 2 +- .../formrecognizer/models/train_source_filter_py3.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_source_filter.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_source_filter.py index 2e6dc649cd47..5ed9aad65dca 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_source_filter.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_source_filter.py @@ -21,7 +21,7 @@ class TrainSourceFilter(Model): :type prefix: str :param include_sub_folders: A flag to indicate if sub folders within the set of - prefix folders will also need to included when searching + prefix folders will also need to be included when searching for content to be preprocessed. :type include_sub_folders: bool """ diff --git a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_source_filter_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_source_filter_py3.py index 7aa5a1cc8de0..f6469269d7df 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_source_filter_py3.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-formrecognizer/azure/cognitiveservices/formrecognizer/models/train_source_filter_py3.py @@ -21,7 +21,7 @@ class TrainSourceFilter(Model): :type prefix: str :param include_sub_folders: A flag to indicate if sub folders within the set of - prefix folders will also need to included when searching + prefix folders will also need to be included when searching for content to be preprocessed. :type include_sub_folders: bool """