10
10
from enum import Enum
11
11
from collections import namedtuple
12
12
from 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
+ )
14
18
from ._generated .models import ClassifierDocumentTypeDetails
15
19
from ._helpers import (
16
20
adjust_value_type ,
@@ -3700,7 +3704,8 @@ class OperationSummary:
3700
3704
created, and more.
3701
3705
3702
3706
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.
3704
3709
To find out why an operation failed, use :func:`~get_operation` and provide the `operation_id`.
3705
3710
3706
3711
.. versionadded:: 2023-02-28-preview
@@ -3800,10 +3805,11 @@ class OperationDetails(OperationSummary):
3800
3805
error of the operation if it has completed.
3801
3806
3802
3807
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.
3804
3810
3805
3811
.. versionadded:: 2023-02-28-preview
3806
- The `documentClassifierBuild` kind.
3812
+ The `documentClassifierBuild` kind and `DocumentClassifierDetails` result .
3807
3813
"""
3808
3814
operation_id : str
3809
3815
"""Operation ID."""
@@ -3824,10 +3830,9 @@ class OperationDetails(OperationSummary):
3824
3830
error : Optional [DocumentAnalysisError ]
3825
3831
"""Encountered error, includes the error code, message, and details for why
3826
3832
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."""
3831
3836
api_version : Optional [str ]
3832
3837
"""API version used to create this operation."""
3833
3838
tags : Optional [Dict [str , str ]]
@@ -3871,6 +3876,14 @@ def from_dict(cls, data: Dict) -> "OperationDetails":
3871
3876
:return: OperationDetails
3872
3877
:rtype: OperationDetails
3873
3878
"""
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
3874
3887
return cls (
3875
3888
operation_id = data .get ("operation_id" , None ),
3876
3889
status = data .get ("status" , None ),
@@ -3879,7 +3892,7 @@ def from_dict(cls, data: Dict) -> "OperationDetails":
3879
3892
last_updated_on = data .get ("last_updated_on" , None ),
3880
3893
kind = data .get ("kind" , None ),
3881
3894
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 ,
3883
3896
error = DocumentAnalysisError .from_dict (data .get ("error" )) if data .get ("error" ) else None , # type: ignore
3884
3897
api_version = data .get ("api_version" , None ),
3885
3898
tags = data .get ("tags" , {}),
@@ -3888,6 +3901,12 @@ def from_dict(cls, data: Dict) -> "OperationDetails":
3888
3901
@classmethod
3889
3902
def _from_generated (cls , op , api_version ): # pylint: disable=arguments-differ
3890
3903
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
3891
3910
return cls (
3892
3911
operation_id = op .operation_id ,
3893
3912
status = op .status ,
@@ -3896,8 +3915,7 @@ def _from_generated(cls, op, api_version): # pylint: disable=arguments-differ
3896
3915
last_updated_on = op .last_updated_date_time ,
3897
3916
kind = op .kind ,
3898
3917
resource_location = op .resource_location ,
3899
- result = DocumentModelDetails ._from_generated (deserialize (ModelDetails , op .result ))
3900
- if op .result else None ,
3918
+ result = result ,
3901
3919
error = DocumentAnalysisError ._from_generated (deserialize (Error , op .error ))
3902
3920
if op .error else None ,
3903
3921
api_version = op .api_version ,
0 commit comments