|
6 | 6 | # Code generated by Microsoft (R) AutoRest Code Generator.
|
7 | 7 | # Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
8 | 8 | # --------------------------------------------------------------------------
|
9 |
| -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar |
| 9 | +from io import IOBase |
| 10 | +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload |
10 | 11 | import urllib.parse
|
11 | 12 |
|
12 | 13 | from azure.core.async_paging import AsyncItemPaged, AsyncList
|
|
29 | 30 | from ... import models as _models
|
30 | 31 | from ..._vendor import _convert_request
|
31 | 32 | from ...operations._apply_updates_operations import (
|
| 33 | + build_create_or_update_or_cancel_request, |
32 | 34 | build_create_or_update_parent_request,
|
33 | 35 | build_create_or_update_request,
|
34 | 36 | build_get_parent_request,
|
@@ -229,6 +231,185 @@ async def get(
|
229 | 231 | "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}"
|
230 | 232 | }
|
231 | 233 |
|
| 234 | + @overload |
| 235 | + async def create_or_update_or_cancel( |
| 236 | + self, |
| 237 | + resource_group_name: str, |
| 238 | + provider_name: str, |
| 239 | + resource_type: str, |
| 240 | + resource_name: str, |
| 241 | + apply_update_name: str, |
| 242 | + apply_update: _models.ApplyUpdate, |
| 243 | + *, |
| 244 | + content_type: str = "application/json", |
| 245 | + **kwargs: Any |
| 246 | + ) -> _models.ApplyUpdate: |
| 247 | + """Apply Updates to resource. |
| 248 | +
|
| 249 | + Apply maintenance updates to resource. |
| 250 | +
|
| 251 | + :param resource_group_name: Resource group name. Required. |
| 252 | + :type resource_group_name: str |
| 253 | + :param provider_name: Resource provider name. Required. |
| 254 | + :type provider_name: str |
| 255 | + :param resource_type: Resource type. Required. |
| 256 | + :type resource_type: str |
| 257 | + :param resource_name: Resource identifier. Required. |
| 258 | + :type resource_name: str |
| 259 | + :param apply_update_name: ApplyUpdate name. Required. |
| 260 | + :type apply_update_name: str |
| 261 | + :param apply_update: The ApplyUpdate. Required. |
| 262 | + :type apply_update: ~azure.mgmt.maintenance.models.ApplyUpdate |
| 263 | + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. |
| 264 | + Default value is "application/json". |
| 265 | + :paramtype content_type: str |
| 266 | + :keyword callable cls: A custom type or function that will be passed the direct response |
| 267 | + :return: ApplyUpdate or the result of cls(response) |
| 268 | + :rtype: ~azure.mgmt.maintenance.models.ApplyUpdate |
| 269 | + :raises ~azure.core.exceptions.HttpResponseError: |
| 270 | + """ |
| 271 | + |
| 272 | + @overload |
| 273 | + async def create_or_update_or_cancel( |
| 274 | + self, |
| 275 | + resource_group_name: str, |
| 276 | + provider_name: str, |
| 277 | + resource_type: str, |
| 278 | + resource_name: str, |
| 279 | + apply_update_name: str, |
| 280 | + apply_update: IO, |
| 281 | + *, |
| 282 | + content_type: str = "application/json", |
| 283 | + **kwargs: Any |
| 284 | + ) -> _models.ApplyUpdate: |
| 285 | + """Apply Updates to resource. |
| 286 | +
|
| 287 | + Apply maintenance updates to resource. |
| 288 | +
|
| 289 | + :param resource_group_name: Resource group name. Required. |
| 290 | + :type resource_group_name: str |
| 291 | + :param provider_name: Resource provider name. Required. |
| 292 | + :type provider_name: str |
| 293 | + :param resource_type: Resource type. Required. |
| 294 | + :type resource_type: str |
| 295 | + :param resource_name: Resource identifier. Required. |
| 296 | + :type resource_name: str |
| 297 | + :param apply_update_name: ApplyUpdate name. Required. |
| 298 | + :type apply_update_name: str |
| 299 | + :param apply_update: The ApplyUpdate. Required. |
| 300 | + :type apply_update: IO |
| 301 | + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. |
| 302 | + Default value is "application/json". |
| 303 | + :paramtype content_type: str |
| 304 | + :keyword callable cls: A custom type or function that will be passed the direct response |
| 305 | + :return: ApplyUpdate or the result of cls(response) |
| 306 | + :rtype: ~azure.mgmt.maintenance.models.ApplyUpdate |
| 307 | + :raises ~azure.core.exceptions.HttpResponseError: |
| 308 | + """ |
| 309 | + |
| 310 | + @distributed_trace_async |
| 311 | + async def create_or_update_or_cancel( |
| 312 | + self, |
| 313 | + resource_group_name: str, |
| 314 | + provider_name: str, |
| 315 | + resource_type: str, |
| 316 | + resource_name: str, |
| 317 | + apply_update_name: str, |
| 318 | + apply_update: Union[_models.ApplyUpdate, IO], |
| 319 | + **kwargs: Any |
| 320 | + ) -> _models.ApplyUpdate: |
| 321 | + """Apply Updates to resource. |
| 322 | +
|
| 323 | + Apply maintenance updates to resource. |
| 324 | +
|
| 325 | + :param resource_group_name: Resource group name. Required. |
| 326 | + :type resource_group_name: str |
| 327 | + :param provider_name: Resource provider name. Required. |
| 328 | + :type provider_name: str |
| 329 | + :param resource_type: Resource type. Required. |
| 330 | + :type resource_type: str |
| 331 | + :param resource_name: Resource identifier. Required. |
| 332 | + :type resource_name: str |
| 333 | + :param apply_update_name: ApplyUpdate name. Required. |
| 334 | + :type apply_update_name: str |
| 335 | + :param apply_update: The ApplyUpdate. Is either a ApplyUpdate type or a IO type. Required. |
| 336 | + :type apply_update: ~azure.mgmt.maintenance.models.ApplyUpdate or IO |
| 337 | + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. |
| 338 | + Default value is None. |
| 339 | + :paramtype content_type: str |
| 340 | + :keyword callable cls: A custom type or function that will be passed the direct response |
| 341 | + :return: ApplyUpdate or the result of cls(response) |
| 342 | + :rtype: ~azure.mgmt.maintenance.models.ApplyUpdate |
| 343 | + :raises ~azure.core.exceptions.HttpResponseError: |
| 344 | + """ |
| 345 | + error_map = { |
| 346 | + 401: ClientAuthenticationError, |
| 347 | + 404: ResourceNotFoundError, |
| 348 | + 409: ResourceExistsError, |
| 349 | + 304: ResourceNotModifiedError, |
| 350 | + } |
| 351 | + error_map.update(kwargs.pop("error_map", {}) or {}) |
| 352 | + |
| 353 | + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) |
| 354 | + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) |
| 355 | + |
| 356 | + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) |
| 357 | + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) |
| 358 | + cls: ClsType[_models.ApplyUpdate] = kwargs.pop("cls", None) |
| 359 | + |
| 360 | + content_type = content_type or "application/json" |
| 361 | + _json = None |
| 362 | + _content = None |
| 363 | + if isinstance(apply_update, (IOBase, bytes)): |
| 364 | + _content = apply_update |
| 365 | + else: |
| 366 | + _json = self._serialize.body(apply_update, "ApplyUpdate") |
| 367 | + |
| 368 | + request = build_create_or_update_or_cancel_request( |
| 369 | + resource_group_name=resource_group_name, |
| 370 | + provider_name=provider_name, |
| 371 | + resource_type=resource_type, |
| 372 | + resource_name=resource_name, |
| 373 | + apply_update_name=apply_update_name, |
| 374 | + subscription_id=self._config.subscription_id, |
| 375 | + api_version=api_version, |
| 376 | + content_type=content_type, |
| 377 | + json=_json, |
| 378 | + content=_content, |
| 379 | + template_url=self.create_or_update_or_cancel.metadata["url"], |
| 380 | + headers=_headers, |
| 381 | + params=_params, |
| 382 | + ) |
| 383 | + request = _convert_request(request) |
| 384 | + request.url = self._client.format_url(request.url) |
| 385 | + |
| 386 | + _stream = False |
| 387 | + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access |
| 388 | + request, stream=_stream, **kwargs |
| 389 | + ) |
| 390 | + |
| 391 | + response = pipeline_response.http_response |
| 392 | + |
| 393 | + if response.status_code not in [200, 201]: |
| 394 | + map_error(status_code=response.status_code, response=response, error_map=error_map) |
| 395 | + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) |
| 396 | + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) |
| 397 | + |
| 398 | + if response.status_code == 200: |
| 399 | + deserialized = self._deserialize("ApplyUpdate", pipeline_response) |
| 400 | + |
| 401 | + if response.status_code == 201: |
| 402 | + deserialized = self._deserialize("ApplyUpdate", pipeline_response) |
| 403 | + |
| 404 | + if cls: |
| 405 | + return cls(pipeline_response, deserialized, {}) # type: ignore |
| 406 | + |
| 407 | + return deserialized # type: ignore |
| 408 | + |
| 409 | + create_or_update_or_cancel.metadata = { |
| 410 | + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}" |
| 411 | + } |
| 412 | + |
232 | 413 | @distributed_trace_async
|
233 | 414 | async def create_or_update_parent(
|
234 | 415 | self,
|
|
0 commit comments