|
41 | 41 | build_check_name_availability_check_local_request, |
42 | 42 | build_lro_create_or_replace_request, |
43 | 43 | build_lro_delete_request, |
| 44 | + build_lro_export_array_request, |
44 | 45 | build_lro_export_request, |
45 | 46 | build_lro_paging_post_paging_lro_request, |
46 | 47 | build_operations_list_request, |
@@ -1064,6 +1065,194 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- |
1064 | 1065 | ) |
1065 | 1066 | return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore |
1066 | 1067 |
|
| 1068 | + async def _export_array_initial( |
| 1069 | + self, body: Union[_models.ExportRequest, JSON, IO[bytes]], **kwargs: Any |
| 1070 | + ) -> AsyncIterator[bytes]: |
| 1071 | + error_map: MutableMapping = { |
| 1072 | + 401: ClientAuthenticationError, |
| 1073 | + 404: ResourceNotFoundError, |
| 1074 | + 409: ResourceExistsError, |
| 1075 | + 304: ResourceNotModifiedError, |
| 1076 | + } |
| 1077 | + error_map.update(kwargs.pop("error_map", {}) or {}) |
| 1078 | + |
| 1079 | + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) |
| 1080 | + _params = kwargs.pop("params", {}) or {} |
| 1081 | + |
| 1082 | + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) |
| 1083 | + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) |
| 1084 | + |
| 1085 | + content_type = content_type or "application/json" |
| 1086 | + _content = None |
| 1087 | + if isinstance(body, (IOBase, bytes)): |
| 1088 | + _content = body |
| 1089 | + else: |
| 1090 | + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore |
| 1091 | + |
| 1092 | + _request = build_lro_export_array_request( |
| 1093 | + subscription_id=self._config.subscription_id, |
| 1094 | + content_type=content_type, |
| 1095 | + api_version=self._config.api_version, |
| 1096 | + content=_content, |
| 1097 | + headers=_headers, |
| 1098 | + params=_params, |
| 1099 | + ) |
| 1100 | + path_format_arguments = { |
| 1101 | + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), |
| 1102 | + } |
| 1103 | + _request.url = self._client.format_url(_request.url, **path_format_arguments) |
| 1104 | + |
| 1105 | + _stream = True |
| 1106 | + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access |
| 1107 | + _request, stream=_stream, **kwargs |
| 1108 | + ) |
| 1109 | + |
| 1110 | + response = pipeline_response.http_response |
| 1111 | + |
| 1112 | + if response.status_code not in [200, 202]: |
| 1113 | + try: |
| 1114 | + await response.read() # Load the body in memory and close the socket |
| 1115 | + except (StreamConsumedError, StreamClosedError): |
| 1116 | + pass |
| 1117 | + map_error(status_code=response.status_code, response=response, error_map=error_map) |
| 1118 | + error = _failsafe_deserialize( |
| 1119 | + _models.ErrorResponse, |
| 1120 | + response, |
| 1121 | + ) |
| 1122 | + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) |
| 1123 | + |
| 1124 | + response_headers = {} |
| 1125 | + if response.status_code == 202: |
| 1126 | + response_headers["Azure-AsyncOperation"] = self._deserialize( |
| 1127 | + "str", response.headers.get("Azure-AsyncOperation") |
| 1128 | + ) |
| 1129 | + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) |
| 1130 | + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) |
| 1131 | + |
| 1132 | + deserialized = response.iter_bytes() |
| 1133 | + |
| 1134 | + if cls: |
| 1135 | + return cls(pipeline_response, deserialized, response_headers) # type: ignore |
| 1136 | + |
| 1137 | + return deserialized # type: ignore |
| 1138 | + |
| 1139 | + @overload |
| 1140 | + async def begin_export_array( |
| 1141 | + self, body: _models.ExportRequest, *, content_type: str = "application/json", **kwargs: Any |
| 1142 | + ) -> AsyncLROPoller[List[_models.ExportResult]]: |
| 1143 | + """export_array. |
| 1144 | +
|
| 1145 | + :param body: The request body. Required. |
| 1146 | + :type body: ~azure.resourcemanager.operationtemplates.models.ExportRequest |
| 1147 | + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. |
| 1148 | + Default value is "application/json". |
| 1149 | + :paramtype content_type: str |
| 1150 | + :return: An instance of AsyncLROPoller that returns list of ExportResult |
| 1151 | + :rtype: |
| 1152 | + ~azure.core.polling.AsyncLROPoller[list[~azure.resourcemanager.operationtemplates.models.ExportResult]] |
| 1153 | + :raises ~azure.core.exceptions.HttpResponseError: |
| 1154 | + """ |
| 1155 | + |
| 1156 | + @overload |
| 1157 | + async def begin_export_array( |
| 1158 | + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any |
| 1159 | + ) -> AsyncLROPoller[List[_models.ExportResult]]: |
| 1160 | + """export_array. |
| 1161 | +
|
| 1162 | + :param body: The request body. Required. |
| 1163 | + :type body: JSON |
| 1164 | + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. |
| 1165 | + Default value is "application/json". |
| 1166 | + :paramtype content_type: str |
| 1167 | + :return: An instance of AsyncLROPoller that returns list of ExportResult |
| 1168 | + :rtype: |
| 1169 | + ~azure.core.polling.AsyncLROPoller[list[~azure.resourcemanager.operationtemplates.models.ExportResult]] |
| 1170 | + :raises ~azure.core.exceptions.HttpResponseError: |
| 1171 | + """ |
| 1172 | + |
| 1173 | + @overload |
| 1174 | + async def begin_export_array( |
| 1175 | + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any |
| 1176 | + ) -> AsyncLROPoller[List[_models.ExportResult]]: |
| 1177 | + """export_array. |
| 1178 | +
|
| 1179 | + :param body: The request body. Required. |
| 1180 | + :type body: IO[bytes] |
| 1181 | + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. |
| 1182 | + Default value is "application/json". |
| 1183 | + :paramtype content_type: str |
| 1184 | + :return: An instance of AsyncLROPoller that returns list of ExportResult |
| 1185 | + :rtype: |
| 1186 | + ~azure.core.polling.AsyncLROPoller[list[~azure.resourcemanager.operationtemplates.models.ExportResult]] |
| 1187 | + :raises ~azure.core.exceptions.HttpResponseError: |
| 1188 | + """ |
| 1189 | + |
| 1190 | + @distributed_trace_async |
| 1191 | + async def begin_export_array( |
| 1192 | + self, body: Union[_models.ExportRequest, JSON, IO[bytes]], **kwargs: Any |
| 1193 | + ) -> AsyncLROPoller[List[_models.ExportResult]]: |
| 1194 | + """export_array. |
| 1195 | +
|
| 1196 | + :param body: The request body. Is one of the following types: ExportRequest, JSON, IO[bytes] |
| 1197 | + Required. |
| 1198 | + :type body: ~azure.resourcemanager.operationtemplates.models.ExportRequest or JSON or IO[bytes] |
| 1199 | + :return: An instance of AsyncLROPoller that returns list of ExportResult |
| 1200 | + :rtype: |
| 1201 | + ~azure.core.polling.AsyncLROPoller[list[~azure.resourcemanager.operationtemplates.models.ExportResult]] |
| 1202 | + :raises ~azure.core.exceptions.HttpResponseError: |
| 1203 | + """ |
| 1204 | + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) |
| 1205 | + _params = kwargs.pop("params", {}) or {} |
| 1206 | + |
| 1207 | + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) |
| 1208 | + cls: ClsType[List[_models.ExportResult]] = kwargs.pop("cls", None) |
| 1209 | + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) |
| 1210 | + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) |
| 1211 | + cont_token: Optional[str] = kwargs.pop("continuation_token", None) |
| 1212 | + if cont_token is None: |
| 1213 | + raw_result = await self._export_array_initial( |
| 1214 | + body=body, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs |
| 1215 | + ) |
| 1216 | + await raw_result.http_response.read() # type: ignore |
| 1217 | + kwargs.pop("error_map", None) |
| 1218 | + |
| 1219 | + def get_long_running_output(pipeline_response): |
| 1220 | + response_headers = {} |
| 1221 | + response = pipeline_response.http_response |
| 1222 | + response_headers["Azure-AsyncOperation"] = self._deserialize( |
| 1223 | + "str", response.headers.get("Azure-AsyncOperation") |
| 1224 | + ) |
| 1225 | + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) |
| 1226 | + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) |
| 1227 | + |
| 1228 | + deserialized = _deserialize(List[_models.ExportResult], response.json()) |
| 1229 | + if cls: |
| 1230 | + return cls(pipeline_response, deserialized, response_headers) # type: ignore |
| 1231 | + return deserialized |
| 1232 | + |
| 1233 | + path_format_arguments = { |
| 1234 | + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), |
| 1235 | + } |
| 1236 | + |
| 1237 | + if polling is True: |
| 1238 | + polling_method: AsyncPollingMethod = cast( |
| 1239 | + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) |
| 1240 | + ) |
| 1241 | + elif polling is False: |
| 1242 | + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) |
| 1243 | + else: |
| 1244 | + polling_method = polling |
| 1245 | + if cont_token: |
| 1246 | + return AsyncLROPoller[List[_models.ExportResult]].from_continuation_token( |
| 1247 | + polling_method=polling_method, |
| 1248 | + continuation_token=cont_token, |
| 1249 | + client=self._client, |
| 1250 | + deserialization_callback=get_long_running_output, |
| 1251 | + ) |
| 1252 | + return AsyncLROPoller[List[_models.ExportResult]]( |
| 1253 | + self._client, raw_result, get_long_running_output, polling_method # type: ignore |
| 1254 | + ) |
| 1255 | + |
1067 | 1256 |
|
1068 | 1257 | class LroPagingOperations: |
1069 | 1258 | """ |
|
0 commit comments