|
31 | 31 | from azure.core.credentials import TokenCredential |
32 | 32 | from azure.core.paging import ItemPaged |
33 | 33 | from azure.core import PipelineClient |
| 34 | +from azure.core.pipeline.transport import HttpRequest, HttpResponse # pylint: disable=no-legacy-azure-core-http-response-import |
34 | 35 | from azure.core.pipeline.policies import ( |
35 | 36 | HTTPPolicy, |
36 | 37 | ContentDecodePolicy, |
@@ -205,7 +206,11 @@ def __init__( |
205 | 206 | ] |
206 | 207 |
|
207 | 208 | transport = kwargs.pop("transport", None) |
208 | | - self.pipeline_client = PipelineClient(base_url=url_connection, transport=transport, policies=policies) |
| 209 | + self.pipeline_client: PipelineClient[HttpRequest, HttpResponse] = PipelineClient( |
| 210 | + base_url=url_connection, |
| 211 | + transport=transport, |
| 212 | + policies=policies |
| 213 | + ) |
209 | 214 |
|
210 | 215 | # Query compatibility mode. |
211 | 216 | # Allows to specify compatibility mode used by client when making query requests. Should be removed when |
@@ -404,7 +409,7 @@ def QueryDatabases( |
404 | 409 | if options is None: |
405 | 410 | options = {} |
406 | 411 |
|
407 | | - def fetch_fn(options: Mapping[str, Any]) -> Tuple[ItemPaged[Dict[str, Any]], Dict[str, Any]]: |
| 412 | + def fetch_fn(options: Mapping[str, Any]) -> Tuple[List[Dict[str, Any]], Dict[str, Any]]: |
408 | 413 | return ( |
409 | 414 | self.__QueryFeed( |
410 | 415 | "/dbs", "dbs", "", lambda r: r["Databases"], |
@@ -466,7 +471,7 @@ def QueryContainers( |
466 | 471 | path = base.GetPathFromLink(database_link, "colls") |
467 | 472 | database_id = base.GetResourceIdOrFullNameFromLink(database_link) |
468 | 473 |
|
469 | | - def fetch_fn(options: Mapping[str, Any]) -> Tuple[ItemPaged[Dict[str, Any]], Dict[str, Any]]: |
| 474 | + def fetch_fn(options: Mapping[str, Any]) -> Tuple[List[Dict[str, Any]], Dict[str, Any]]: |
470 | 475 | return ( |
471 | 476 | self.__QueryFeed( |
472 | 477 | path, "colls", database_id, lambda r: r["DocumentCollections"], |
@@ -699,7 +704,7 @@ def QueryUsers( |
699 | 704 | path = base.GetPathFromLink(database_link, "users") |
700 | 705 | database_id = base.GetResourceIdOrFullNameFromLink(database_link) |
701 | 706 |
|
702 | | - def fetch_fn(options: Mapping[str, Any]) -> Tuple[ItemPaged[Dict[str, Any]], Dict[str, Any]]: |
| 707 | + def fetch_fn(options: Mapping[str, Any]) -> Tuple[List[Dict[str, Any]], Dict[str, Any]]: |
703 | 708 | return ( |
704 | 709 | self.__QueryFeed( |
705 | 710 | path, "users", database_id, lambda r: r["Users"], |
@@ -835,7 +840,7 @@ def ReadPermissions( |
835 | 840 | user_link: str, |
836 | 841 | options: Optional[Mapping[str, Any]] = None, |
837 | 842 | **kwargs: Any |
838 | | - ) -> Dict[str, Any]: |
| 843 | + ) -> ItemPaged[Dict[str, Any]]: |
839 | 844 | """Reads all permissions for a user. |
840 | 845 |
|
841 | 846 | :param str user_link: |
@@ -881,7 +886,7 @@ def QueryPermissions( |
881 | 886 | path = base.GetPathFromLink(user_link, "permissions") |
882 | 887 | user_id = base.GetResourceIdOrFullNameFromLink(user_link) |
883 | 888 |
|
884 | | - def fetch_fn(options: Mapping[str, Any]) -> Tuple[ItemPaged[Dict[str, Any]], Dict[str, Any]]: |
| 889 | + def fetch_fn(options: Mapping[str, Any]) -> Tuple[List[Dict[str, Any]], Dict[str, Any]]: |
885 | 890 | return ( |
886 | 891 | self.__QueryFeed( |
887 | 892 | path, "permissions", user_id, lambda r: r["Permissions"], lambda _, b: b, query, options, **kwargs |
@@ -1069,7 +1074,7 @@ def QueryItems( |
1069 | 1074 | path = base.GetPathFromLink(database_or_container_link, "docs") |
1070 | 1075 | collection_id = base.GetResourceIdOrFullNameFromLink(database_or_container_link) |
1071 | 1076 |
|
1072 | | - def fetch_fn(options: Mapping[str, Any]) -> Tuple[ItemPaged[Dict[str, Any]], Dict[str, Any]]: |
| 1077 | + def fetch_fn(options: Mapping[str, Any]) -> Tuple[List[Dict[str, Any]], Dict[str, Any]]: |
1073 | 1078 | return ( |
1074 | 1079 | self.__QueryFeed( |
1075 | 1080 | path, |
@@ -1163,7 +1168,7 @@ def _QueryChangeFeed( |
1163 | 1168 | path = base.GetPathFromLink(collection_link, resource_key) |
1164 | 1169 | collection_id = base.GetResourceIdOrFullNameFromLink(collection_link) |
1165 | 1170 |
|
1166 | | - def fetch_fn(options: Mapping[str, Any]) -> Tuple[ItemPaged[Dict[str, Any]], Dict[str, Any]]: |
| 1171 | + def fetch_fn(options: Mapping[str, Any]) -> Tuple[List[Dict[str, Any]], Dict[str, Any]]: |
1167 | 1172 | return ( |
1168 | 1173 | self.__QueryFeed( |
1169 | 1174 | path, |
@@ -1235,7 +1240,7 @@ def _QueryPartitionKeyRanges( |
1235 | 1240 | path = base.GetPathFromLink(collection_link, "pkranges") |
1236 | 1241 | collection_id = base.GetResourceIdOrFullNameFromLink(collection_link) |
1237 | 1242 |
|
1238 | | - def fetch_fn(options: Mapping[str, Any]) -> Tuple[ItemPaged[Dict[str, Any]], Dict[str, Any]]: |
| 1243 | + def fetch_fn(options: Mapping[str, Any]) -> Tuple[List[Dict[str, Any]], Dict[str, Any]]: |
1239 | 1244 | return ( |
1240 | 1245 | self.__QueryFeed( |
1241 | 1246 | path, "pkranges", collection_id, lambda r: r["PartitionKeyRanges"], |
@@ -1438,7 +1443,7 @@ def QueryTriggers( |
1438 | 1443 | path = base.GetPathFromLink(collection_link, "triggers") |
1439 | 1444 | collection_id = base.GetResourceIdOrFullNameFromLink(collection_link) |
1440 | 1445 |
|
1441 | | - def fetch_fn(options: Mapping[str, Any]) -> Tuple[ItemPaged[Dict[str, Any]], Dict[str, Any]]: |
| 1446 | + def fetch_fn(options: Mapping[str, Any]) -> Tuple[List[Dict[str, Any]], Dict[str, Any]]: |
1442 | 1447 | return ( |
1443 | 1448 | self.__QueryFeed( |
1444 | 1449 | path, "triggers", collection_id, lambda r: r["Triggers"], lambda _, b: b, query, options, **kwargs |
@@ -1597,7 +1602,7 @@ def QueryUserDefinedFunctions( |
1597 | 1602 | path = base.GetPathFromLink(collection_link, "udfs") |
1598 | 1603 | collection_id = base.GetResourceIdOrFullNameFromLink(collection_link) |
1599 | 1604 |
|
1600 | | - def fetch_fn(options: Mapping[str, Any]) -> Tuple[ItemPaged[Dict[str, Any]], Dict[str, Any]]: |
| 1605 | + def fetch_fn(options: Mapping[str, Any]) -> Tuple[List[Dict[str, Any]], Dict[str, Any]]: |
1601 | 1606 | return ( |
1602 | 1607 | self.__QueryFeed( |
1603 | 1608 | path, "udfs", collection_id, lambda r: r["UserDefinedFunctions"], |
@@ -1757,7 +1762,7 @@ def QueryStoredProcedures( |
1757 | 1762 | path = base.GetPathFromLink(collection_link, "sprocs") |
1758 | 1763 | collection_id = base.GetResourceIdOrFullNameFromLink(collection_link) |
1759 | 1764 |
|
1760 | | - def fetch_fn(options: Mapping[str, Any]) -> Tuple[ItemPaged[Dict[str, Any]], Dict[str, Any]]: |
| 1765 | + def fetch_fn(options: Mapping[str, Any]) -> Tuple[List[Dict[str, Any]], Dict[str, Any]]: |
1761 | 1766 | return ( |
1762 | 1767 | self.__QueryFeed( |
1763 | 1768 | path, "sprocs", collection_id, lambda r: r["StoredProcedures"], |
@@ -1915,7 +1920,7 @@ def QueryConflicts( |
1915 | 1920 | path = base.GetPathFromLink(collection_link, "conflicts") |
1916 | 1921 | collection_id = base.GetResourceIdOrFullNameFromLink(collection_link) |
1917 | 1922 |
|
1918 | | - def fetch_fn(options: Mapping[str, Any]) -> Tuple[ItemPaged[Dict[str, Any]], Dict[str, Any]]: |
| 1923 | + def fetch_fn(options: Mapping[str, Any]) -> Tuple[List[Dict[str, Any]], Dict[str, Any]]: |
1919 | 1924 | return ( |
1920 | 1925 | self.__QueryFeed( |
1921 | 1926 | path, "conflicts", collection_id, lambda r: r["Conflicts"], |
@@ -2528,7 +2533,7 @@ def QueryOffers( |
2528 | 2533 | if options is None: |
2529 | 2534 | options = {} |
2530 | 2535 |
|
2531 | | - def fetch_fn(options: Mapping[str, Any]) -> Tuple[ItemPaged[Dict[str, Any]], Dict[str, Any]]: |
| 2536 | + def fetch_fn(options: Mapping[str, Any]) -> Tuple[List[Dict[str, Any]], Dict[str, Any]]: |
2532 | 2537 | return ( |
2533 | 2538 | self.__QueryFeed( |
2534 | 2539 | "/offers", "offers", "", lambda r: r["Offers"], lambda _, b: b, query, options, **kwargs |
@@ -2779,7 +2784,7 @@ def __Get( |
2779 | 2784 | self, |
2780 | 2785 | path: str, |
2781 | 2786 | request_params: RequestObject, |
2782 | | - req_headers: Mapping[str, Any], |
| 2787 | + req_headers: Dict[str, Any], |
2783 | 2788 | **kwargs: Any |
2784 | 2789 | ) -> Tuple[Dict[str, Any], Dict[str, Any]]: |
2785 | 2790 | """Azure Cosmos 'GET' http request. |
@@ -2807,7 +2812,7 @@ def __Post( |
2807 | 2812 | path: str, |
2808 | 2813 | request_params: RequestObject, |
2809 | 2814 | body: Optional[Union[str, List[Dict[str, Any]], Dict[str, Any]]], |
2810 | | - req_headers: Mapping[str, Any], |
| 2815 | + req_headers: Dict[str, Any], |
2811 | 2816 | **kwargs: Any |
2812 | 2817 | ) -> Tuple[Dict[str, Any], Dict[str, Any]]: |
2813 | 2818 | """Azure Cosmos 'POST' http request. |
@@ -2836,7 +2841,7 @@ def __Put( |
2836 | 2841 | path: str, |
2837 | 2842 | request_params: RequestObject, |
2838 | 2843 | body: Dict[str, Any], |
2839 | | - req_headers: Mapping[str, Any], |
| 2844 | + req_headers: Dict[str, Any], |
2840 | 2845 | **kwargs: Any |
2841 | 2846 | ) -> Tuple[Dict[str, Any], Dict[str, Any]]: |
2842 | 2847 | """Azure Cosmos 'PUT' http request. |
@@ -2865,7 +2870,7 @@ def __Patch( |
2865 | 2870 | path: str, |
2866 | 2871 | request_params: RequestObject, |
2867 | 2872 | request_data: Dict[str, Any], |
2868 | | - req_headers: Mapping[str, Any], |
| 2873 | + req_headers: Dict[str, Any], |
2869 | 2874 | **kwargs: Any |
2870 | 2875 | ) -> Tuple[Dict[str, Any], Dict[str, Any]]: |
2871 | 2876 | """Azure Cosmos 'PATCH' http request. |
@@ -2893,7 +2898,7 @@ def __Delete( |
2893 | 2898 | self, |
2894 | 2899 | path: str, |
2895 | 2900 | request_params: RequestObject, |
2896 | | - req_headers: Mapping[str, Any], |
| 2901 | + req_headers: Dict[str, Any], |
2897 | 2902 | **kwargs: Any |
2898 | 2903 | ) -> Tuple[None, Dict[str, Any]]: |
2899 | 2904 | """Azure Cosmos 'DELETE' http request. |
@@ -2924,7 +2929,7 @@ def QueryFeed( |
2924 | 2929 | options: Mapping[str, Any], |
2925 | 2930 | partition_key_range_id: Optional[str] = None, |
2926 | 2931 | **kwargs: Any |
2927 | | - ) -> Tuple[ItemPaged[Dict[str, Any]], Dict[str, Any]]: |
| 2932 | + ) -> Tuple[List[Dict[str, Any]], Dict[str, Any]]: |
2928 | 2933 | """Query Feed for Document Collection resource. |
2929 | 2934 |
|
2930 | 2935 | :param str path: Path to the document collection. |
@@ -2963,7 +2968,7 @@ def __QueryFeed( # pylint: disable=too-many-locals, too-many-statements |
2963 | 2968 | response_hook: Optional[Callable[[Mapping[str, Any], Mapping[str, Any]], None]] = None, |
2964 | 2969 | is_query_plan: bool = False, |
2965 | 2970 | **kwargs: Any |
2966 | | - ) -> ItemPaged[Dict[str, Any]]: |
| 2971 | + ) -> List[Dict[str, Any]]: |
2967 | 2972 | """Query for more than one Azure Cosmos resources. |
2968 | 2973 |
|
2969 | 2974 | :param str path: |
@@ -3114,7 +3119,7 @@ def __GetBodiesFromQueryResult(result: Dict[str, Any]) -> List[Dict[str, Any]]: |
3114 | 3119 |
|
3115 | 3120 | return __GetBodiesFromQueryResult(result) |
3116 | 3121 |
|
3117 | | - def _GetQueryPlanThroughGateway(self, query: str, resource_link: str, **kwargs: Any) -> ItemPaged[Dict[str, Any]]: |
| 3122 | + def _GetQueryPlanThroughGateway(self, query: str, resource_link: str, **kwargs: Any) -> List[Dict[str, Any]]: |
3118 | 3123 | supported_query_features = (documents._QueryFeature.Aggregate + "," + |
3119 | 3124 | documents._QueryFeature.CompositeAggregate + "," + |
3120 | 3125 | documents._QueryFeature.Distinct + "," + |
|
0 commit comments