1010from enum import Enum
1111from collections import namedtuple
1212from azure .core import CaseInsensitiveEnumMeta
13- from ._generated .v2023_02_28_preview .models import DocumentModelDetails as ModelDetails , Error
13+ from ._generated .v2023_02_28_preview .models import (
14+ DocumentModelDetails as ModelDetails ,
15+ DocumentClassifierDetails as ClassifierDetails ,
16+ Error
17+ )
1418from ._generated .models import ClassifierDocumentTypeDetails
1519from ._helpers import (
1620 adjust_value_type ,
@@ -3700,7 +3704,8 @@ class OperationSummary:
37003704 created, and more.
37013705
37023706 Note that operation information only persists for 24 hours. If the operation was successful,
3703- the model can be accessed using the :func:`~get_document_model` or :func:`~list_document_models` APIs.
3707+ the model can be accessed using the :func:`~get_document_model`, :func:`~list_document_models`,
3708+ :func:`~get_document_classifier`, :func:`~list_document_classifiers` APIs.
37043709 To find out why an operation failed, use :func:`~get_operation` and provide the `operation_id`.
37053710
37063711 .. versionadded:: 2023-02-28-preview
@@ -3800,10 +3805,11 @@ class OperationDetails(OperationSummary):
38003805 error of the operation if it has completed.
38013806
38023807 Note that operation information only persists for 24 hours. If the operation was successful,
3803- the model can also be accessed using the :func:`~get_document_model` or :func:`~list_document_models` APIs.
3808+ the model can also be accessed using the :func:`~get_document_model`, :func:`~list_document_models`,
3809+ :func:`~get_document_classifier`, :func:`~list_document_classifiers` APIs.
38043810
38053811 .. versionadded:: 2023-02-28-preview
3806- The `documentClassifierBuild` kind.
3812+ The `documentClassifierBuild` kind and `DocumentClassifierDetails` result .
38073813 """
38083814 operation_id : str
38093815 """Operation ID."""
@@ -3824,10 +3830,9 @@ class OperationDetails(OperationSummary):
38243830 error : Optional [DocumentAnalysisError ]
38253831 """Encountered error, includes the error code, message, and details for why
38263832 the operation failed."""
3827- result : Optional [DocumentModelDetails ]
3828- """Operation result upon success. Returns a DocumentModelDetails which contains
3829- all information about the model including the doc types
3830- and fields it can analyze from documents."""
3833+ result : Optional [Union [DocumentModelDetails , DocumentClassifierDetails ]]
3834+ """Operation result upon success. Returns a DocumentModelDetails or DocumentClassifierDetails
3835+ which contains all the information about the model."""
38313836 api_version : Optional [str ]
38323837 """API version used to create this operation."""
38333838 tags : Optional [Dict [str , str ]]
@@ -3871,6 +3876,14 @@ def from_dict(cls, data: Dict) -> "OperationDetails":
38713876 :return: OperationDetails
38723877 :rtype: OperationDetails
38733878 """
3879+
3880+ kind = data .get ("kind" , None )
3881+ if kind == "documentClassifierBuild" :
3882+ result = \
3883+ DocumentClassifierDetails .from_dict (data .get ("result" )) if data .get ("result" ) else None # type: ignore
3884+ else :
3885+ result = \
3886+ DocumentModelDetails .from_dict (data .get ("result" )) if data .get ("result" ) else None # type: ignore
38743887 return cls (
38753888 operation_id = data .get ("operation_id" , None ),
38763889 status = data .get ("status" , None ),
@@ -3879,7 +3892,7 @@ def from_dict(cls, data: Dict) -> "OperationDetails":
38793892 last_updated_on = data .get ("last_updated_on" , None ),
38803893 kind = data .get ("kind" , None ),
38813894 resource_location = data .get ("resource_location" , None ),
3882- result = DocumentModelDetails . from_dict ( data . get ( " result" )) if data . get ( "result" ) else None , # type: ignore
3895+ result = result ,
38833896 error = DocumentAnalysisError .from_dict (data .get ("error" )) if data .get ("error" ) else None , # type: ignore
38843897 api_version = data .get ("api_version" , None ),
38853898 tags = data .get ("tags" , {}),
@@ -3888,6 +3901,12 @@ def from_dict(cls, data: Dict) -> "OperationDetails":
38883901 @classmethod
38893902 def _from_generated (cls , op , api_version ): # pylint: disable=arguments-differ
38903903 deserialize = _get_deserialize (api_version )
3904+ if op .kind == "documentClassifierBuild" :
3905+ result = DocumentClassifierDetails ._from_generated (deserialize (ClassifierDetails , op .result )) \
3906+ if op .result else None
3907+ else :
3908+ result = DocumentModelDetails ._from_generated (deserialize (ModelDetails , op .result )) \
3909+ if op .result else None
38913910 return cls (
38923911 operation_id = op .operation_id ,
38933912 status = op .status ,
@@ -3896,8 +3915,7 @@ def _from_generated(cls, op, api_version): # pylint: disable=arguments-differ
38963915 last_updated_on = op .last_updated_date_time ,
38973916 kind = op .kind ,
38983917 resource_location = op .resource_location ,
3899- result = DocumentModelDetails ._from_generated (deserialize (ModelDetails , op .result ))
3900- if op .result else None ,
3918+ result = result ,
39013919 error = DocumentAnalysisError ._from_generated (deserialize (Error , op .error ))
39023920 if op .error else None ,
39033921 api_version = op .api_version ,
0 commit comments