9
9
from urllib .parse import urlencode
10
10
from typing import Any , Mapping , Optional , Callable , TypeVar , cast
11
11
from typing_extensions import Protocol , runtime_checkable
12
- from azure .core .polling import PollingMethod
13
12
from azure .core .exceptions import HttpResponseError
14
13
from azure .core .polling import LROPoller
15
14
from azure .core .polling .base_polling import (
25
24
_SUCCEEDED = frozenset (["succeeded" , "partiallycompleted" , "partiallysucceeded" ])
26
25
27
26
28
- PollingReturnType = TypeVar ("PollingReturnType" )
27
+ PollingReturnType = TypeVar ("PollingReturnType" , covariant = True )
29
28
30
29
31
30
@runtime_checkable
@@ -35,34 +34,74 @@ class TextAnalysisLROPoller(Protocol[PollingReturnType]):
35
34
36
35
@property
37
36
def details (self ) -> Mapping [str , Any ]:
38
- .. .
37
+ """Long-running operation metadata .
39
38
40
- def polling_method (self ) -> PollingMethod [PollingReturnType ]: # pylint: disable=no-self-use
41
- ...
39
+ :return: A mapping of details about the long-running operation.
40
+ :rtype: Mapping[str, Any]
41
+ """
42
42
43
43
def continuation_token (self ) -> str : # pylint: disable=no-self-use
44
- ...
44
+ """Return a continuation token that allows to restart the poller later.
45
+
46
+ :returns: An opaque continuation token
47
+ :rtype: str
48
+ """
45
49
46
50
def status (self ) -> str : # pylint: disable=no-self-use
47
- ...
51
+ """Returns the current status string.
52
+
53
+ :returns: The current status string
54
+ :rtype: str
55
+ """
48
56
49
57
def result (self , timeout : Optional [int ] = None ) -> PollingReturnType : # pylint: disable=no-self-use, unused-argument
50
- ...
58
+ """Return the result of the long running operation, or
59
+ the result available after the specified timeout.
60
+
61
+ :returns: The deserialized resource of the long running operation,
62
+ if one is available.
63
+ :raises ~azure.core.exceptions.HttpResponseError: Server problem with the query.
64
+ """
51
65
52
66
def wait (self , timeout : Optional [float ] = None ) -> None : # pylint: disable=no-self-use, unused-argument
53
- ...
67
+ """Wait on the long running operation for a specified length
68
+ of time. You can check if this call as ended with timeout with the
69
+ "done()" method.
70
+
71
+ :param float timeout: Period of time to wait for the long running
72
+ operation to complete (in seconds).
73
+ :raises ~azure.core.exceptions.HttpResponseError: Server problem with the query.
74
+ """
54
75
55
76
def done (self ) -> bool : # pylint: disable=no-self-use
56
- ...
77
+ """Check status of the long running operation.
78
+
79
+ :returns: 'True' if the process has completed, else 'False'.
80
+ :rtype: bool
81
+ """
57
82
58
83
def add_done_callback (self , func : Callable ) -> None : # pylint: disable=no-self-use, unused-argument
59
- ...
84
+ """Add callback function to be run once the long running operation
85
+ has completed - regardless of the status of the operation.
86
+
87
+ :param callable func: Callback function that takes at least one
88
+ argument, a completed LongRunningOperation.
89
+ """
60
90
61
91
def remove_done_callback (self , func : Callable ) -> None : # pylint: disable=no-self-use, unused-argument
62
- ...
92
+ """Remove a callback from the long running operation.
93
+
94
+ :param callable func: The function to be removed from the callbacks.
95
+ :raises ValueError: if the long running operation has already completed.
96
+ """
63
97
64
98
def cancel (self ) -> None : # pylint: disable=no-self-use
65
- ...
99
+ """Cancel the operation currently being polled.
100
+
101
+ :return: None
102
+ :rtype: None
103
+ :raises ~azure.core.exceptions.HttpResponseError: When the operation has already reached a terminal state.
104
+ """
66
105
67
106
68
107
class TextAnalyticsOperationResourcePolling (OperationResourcePolling ):
0 commit comments