Source code for azure.mgmt.compute.v2021_07_01.operations._operations

# pylint: disable=too-many-lines
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
from io import IOBase
import sys
from typing import Any, Callable, Dict, IO, Iterable, Iterator, List, Optional, TypeVar, Union, cast, overload
import urllib.parse

from azure.core.exceptions import (
    ClientAuthenticationError,
    HttpResponseError,
    ResourceExistsError,
    ResourceNotFoundError,
    ResourceNotModifiedError,
    StreamClosedError,
    StreamConsumedError,
    map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest, HttpResponse
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling

from .. import models as _models
from ..._serialization import Serializer

if sys.version_info >= (3, 9):
    from collections.abc import MutableMapping
else:
    from typing import MutableMapping  # type: ignore
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]

_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False


def build_operations_list_request(**kwargs: Any) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop("template_url", "/providers/Microsoft.Compute/operations")

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_availability_sets_create_or_update_request(  # pylint: disable=name-too-long
    resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "availabilitySetName": _SERIALIZER.url("availability_set_name", availability_set_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)


def build_availability_sets_update_request(
    resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "availabilitySetName": _SERIALIZER.url("availability_set_name", availability_set_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)


def build_availability_sets_delete_request(
    resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "availabilitySetName": _SERIALIZER.url("availability_set_name", availability_set_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs)


def build_availability_sets_get_request(
    resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "availabilitySetName": _SERIALIZER.url("availability_set_name", availability_set_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_availability_sets_list_by_subscription_request(  # pylint: disable=name-too-long
    subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets")
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
    if expand is not None:
        _params["$expand"] = _SERIALIZER.query("expand", expand, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_availability_sets_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_availability_sets_list_available_sizes_request(  # pylint: disable=name-too-long
    resource_group_name: str, availability_set_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "availabilitySetName": _SERIALIZER.url("availability_set_name", availability_set_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_proximity_placement_groups_create_or_update_request(  # pylint: disable=name-too-long
    resource_group_name: str, proximity_placement_group_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "proximityPlacementGroupName": _SERIALIZER.url(
            "proximity_placement_group_name", proximity_placement_group_name, "str"
        ),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)


def build_proximity_placement_groups_update_request(  # pylint: disable=name-too-long
    resource_group_name: str, proximity_placement_group_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "proximityPlacementGroupName": _SERIALIZER.url(
            "proximity_placement_group_name", proximity_placement_group_name, "str"
        ),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)


def build_proximity_placement_groups_delete_request(  # pylint: disable=name-too-long
    resource_group_name: str, proximity_placement_group_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "proximityPlacementGroupName": _SERIALIZER.url(
            "proximity_placement_group_name", proximity_placement_group_name, "str"
        ),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs)


def build_proximity_placement_groups_get_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    proximity_placement_group_name: str,
    subscription_id: str,
    *,
    include_colocation_status: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "proximityPlacementGroupName": _SERIALIZER.url(
            "proximity_placement_group_name", proximity_placement_group_name, "str"
        ),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if include_colocation_status is not None:
        _params["includeColocationStatus"] = _SERIALIZER.query(
            "include_colocation_status", include_colocation_status, "str"
        )
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_proximity_placement_groups_list_by_subscription_request(  # pylint: disable=name-too-long
    subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/proximityPlacementGroups"
    )
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_proximity_placement_groups_list_by_resource_group_request(  # pylint: disable=name-too-long
    resource_group_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_dedicated_host_groups_create_or_update_request(  # pylint: disable=name-too-long
    resource_group_name: str, host_group_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)


def build_dedicated_host_groups_update_request(  # pylint: disable=name-too-long
    resource_group_name: str, host_group_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)


def build_dedicated_host_groups_delete_request(  # pylint: disable=name-too-long
    resource_group_name: str, host_group_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs)


def build_dedicated_host_groups_get_request(
    resource_group_name: str,
    host_group_name: str,
    subscription_id: str,
    *,
    expand: Optional[Union[str, _models.InstanceViewTypes]] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if expand is not None:
        _params["$expand"] = _SERIALIZER.query("expand", expand, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_dedicated_host_groups_list_by_resource_group_request(  # pylint: disable=name-too-long
    resource_group_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_dedicated_host_groups_list_by_subscription_request(  # pylint: disable=name-too-long
    subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/hostGroups")
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_dedicated_hosts_create_or_update_request(  # pylint: disable=name-too-long
    resource_group_name: str, host_group_name: str, host_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"),
        "hostName": _SERIALIZER.url("host_name", host_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)


def build_dedicated_hosts_update_request(
    resource_group_name: str, host_group_name: str, host_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"),
        "hostName": _SERIALIZER.url("host_name", host_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)


def build_dedicated_hosts_delete_request(
    resource_group_name: str, host_group_name: str, host_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"),
        "hostName": _SERIALIZER.url("host_name", host_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs)


def build_dedicated_hosts_get_request(
    resource_group_name: str,
    host_group_name: str,
    host_name: str,
    subscription_id: str,
    *,
    expand: Optional[Union[str, _models.InstanceViewTypes]] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"),
        "hostName": _SERIALIZER.url("host_name", host_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if expand is not None:
        _params["$expand"] = _SERIALIZER.query("expand", expand, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_dedicated_hosts_list_by_host_group_request(  # pylint: disable=name-too-long
    resource_group_name: str, host_group_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "hostGroupName": _SERIALIZER.url("host_group_name", host_group_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_ssh_public_keys_list_by_subscription_request(  # pylint: disable=name-too-long
    subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/sshPublicKeys")
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_ssh_public_keys_list_by_resource_group_request(  # pylint: disable=name-too-long
    resource_group_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_ssh_public_keys_create_request(
    resource_group_name: str, ssh_public_key_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "sshPublicKeyName": _SERIALIZER.url("ssh_public_key_name", ssh_public_key_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)


def build_ssh_public_keys_update_request(
    resource_group_name: str, ssh_public_key_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "sshPublicKeyName": _SERIALIZER.url("ssh_public_key_name", ssh_public_key_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)


def build_ssh_public_keys_delete_request(
    resource_group_name: str, ssh_public_key_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "sshPublicKeyName": _SERIALIZER.url("ssh_public_key_name", ssh_public_key_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs)


def build_ssh_public_keys_get_request(
    resource_group_name: str, ssh_public_key_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "sshPublicKeyName": _SERIALIZER.url("ssh_public_key_name", ssh_public_key_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_ssh_public_keys_generate_key_pair_request(  # pylint: disable=name-too-long
    resource_group_name: str, ssh_public_key_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}/generateKeyPair",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "sshPublicKeyName": _SERIALIZER.url("ssh_public_key_name", ssh_public_key_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_extension_images_get_request(  # pylint: disable=name-too-long
    location: str, publisher_name: str, type: str, version: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "location": _SERIALIZER.url("location", location, "str"),
        "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"),
        "type": _SERIALIZER.url("type", type, "str"),
        "version": _SERIALIZER.url("version", version, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_extension_images_list_types_request(  # pylint: disable=name-too-long
    location: str, publisher_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "location": _SERIALIZER.url("location", location, "str"),
        "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_extension_images_list_versions_request(  # pylint: disable=name-too-long
    location: str,
    publisher_name: str,
    type: str,
    subscription_id: str,
    *,
    filter: Optional[str] = None,
    top: Optional[int] = None,
    orderby: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "location": _SERIALIZER.url("location", location, "str"),
        "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"),
        "type": _SERIALIZER.url("type", type, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if filter is not None:
        _params["$filter"] = _SERIALIZER.query("filter", filter, "str")
    if top is not None:
        _params["$top"] = _SERIALIZER.query("top", top, "int")
    if orderby is not None:
        _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_extensions_create_or_update_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_name: str, vm_extension_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "vmExtensionName": _SERIALIZER.url("vm_extension_name", vm_extension_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_extensions_update_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_name: str, vm_extension_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "vmExtensionName": _SERIALIZER.url("vm_extension_name", vm_extension_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_extensions_delete_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_name: str, vm_extension_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "vmExtensionName": _SERIALIZER.url("vm_extension_name", vm_extension_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs)


def build_virtual_machine_extensions_get_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    vm_name: str,
    vm_extension_name: str,
    subscription_id: str,
    *,
    expand: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "vmExtensionName": _SERIALIZER.url("vm_extension_name", vm_extension_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if expand is not None:
        _params["$expand"] = _SERIALIZER.query("expand", expand, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_extensions_list_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_name: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if expand is not None:
        _params["$expand"] = _SERIALIZER.query("expand", expand, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_images_get_request(
    location: str, publisher_name: str, offer: str, skus: str, version: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "location": _SERIALIZER.url("location", location, "str"),
        "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"),
        "offer": _SERIALIZER.url("offer", offer, "str"),
        "skus": _SERIALIZER.url("skus", skus, "str"),
        "version": _SERIALIZER.url("version", version, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_images_list_request(  # pylint: disable=name-too-long
    location: str,
    publisher_name: str,
    offer: str,
    skus: str,
    subscription_id: str,
    *,
    expand: Optional[str] = None,
    top: Optional[int] = None,
    orderby: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "location": _SERIALIZER.url("location", location, "str"),
        "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"),
        "offer": _SERIALIZER.url("offer", offer, "str"),
        "skus": _SERIALIZER.url("skus", skus, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if expand is not None:
        _params["$expand"] = _SERIALIZER.query("expand", expand, "str")
    if top is not None:
        _params["$top"] = _SERIALIZER.query("top", top, "int")
    if orderby is not None:
        _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_images_list_offers_request(  # pylint: disable=name-too-long
    location: str, publisher_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "location": _SERIALIZER.url("location", location, "str"),
        "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_images_list_publishers_request(  # pylint: disable=name-too-long
    location: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers"
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "location": _SERIALIZER.url("location", location, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_images_list_skus_request(  # pylint: disable=name-too-long
    location: str, publisher_name: str, offer: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "location": _SERIALIZER.url("location", location, "str"),
        "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"),
        "offer": _SERIALIZER.url("offer", offer, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_images_edge_zone_get_request(  # pylint: disable=name-too-long
    location: str,
    edge_zone: str,
    publisher_name: str,
    offer: str,
    skus: str,
    version: str,
    subscription_id: str,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "location": _SERIALIZER.url("location", location, "str"),
        "edgeZone": _SERIALIZER.url("edge_zone", edge_zone, "str"),
        "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"),
        "offer": _SERIALIZER.url("offer", offer, "str"),
        "skus": _SERIALIZER.url("skus", skus, "str"),
        "version": _SERIALIZER.url("version", version, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_images_edge_zone_list_request(  # pylint: disable=name-too-long
    location: str,
    edge_zone: str,
    publisher_name: str,
    offer: str,
    skus: str,
    subscription_id: str,
    *,
    expand: Optional[str] = None,
    top: Optional[int] = None,
    orderby: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "location": _SERIALIZER.url("location", location, "str"),
        "edgeZone": _SERIALIZER.url("edge_zone", edge_zone, "str"),
        "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"),
        "offer": _SERIALIZER.url("offer", offer, "str"),
        "skus": _SERIALIZER.url("skus", skus, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if expand is not None:
        _params["$expand"] = _SERIALIZER.query("expand", expand, "str")
    if top is not None:
        _params["$top"] = _SERIALIZER.query("top", top, "int")
    if orderby is not None:
        _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_images_edge_zone_list_offers_request(  # pylint: disable=name-too-long
    location: str, edge_zone: str, publisher_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "location": _SERIALIZER.url("location", location, "str"),
        "edgeZone": _SERIALIZER.url("edge_zone", edge_zone, "str"),
        "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_images_edge_zone_list_publishers_request(  # pylint: disable=name-too-long
    location: str, edge_zone: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "location": _SERIALIZER.url("location", location, "str"),
        "edgeZone": _SERIALIZER.url("edge_zone", edge_zone, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_images_edge_zone_list_skus_request(  # pylint: disable=name-too-long
    location: str, edge_zone: str, publisher_name: str, offer: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "location": _SERIALIZER.url("location", location, "str"),
        "edgeZone": _SERIALIZER.url("edge_zone", edge_zone, "str"),
        "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"),
        "offer": _SERIALIZER.url("offer", offer, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_usage_list_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages"
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "location": _SERIALIZER.url("location", location, "str", pattern=r"^[-\w\._]+$"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machines_list_by_location_request(  # pylint: disable=name-too-long
    location: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachines",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "location": _SERIALIZER.url("location", location, "str", pattern=r"^[-\w\._]+$"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machines_capture_request(
    resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machines_create_or_update_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machines_update_request(
    resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machines_delete_request(
    resource_group_name: str,
    vm_name: str,
    subscription_id: str,
    *,
    force_deletion: Optional[bool] = None,
    **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if force_deletion is not None:
        _params["forceDeletion"] = _SERIALIZER.query("force_deletion", force_deletion, "bool")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs)


def build_virtual_machines_get_request(
    resource_group_name: str,
    vm_name: str,
    subscription_id: str,
    *,
    expand: Optional[Union[str, _models.InstanceViewTypes]] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if expand is not None:
        _params["$expand"] = _SERIALIZER.query("expand", expand, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machines_instance_view_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/instanceView",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machines_convert_to_managed_disks_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/convertToManagedDisks",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="POST", url=_url, params=_params, **kwargs)


def build_virtual_machines_deallocate_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_name: str, subscription_id: str, *, hibernate: Optional[bool] = None, **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if hibernate is not None:
        _params["hibernate"] = _SERIALIZER.query("hibernate", hibernate, "bool")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="POST", url=_url, params=_params, **kwargs)


def build_virtual_machines_generalize_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="POST", url=_url, params=_params, **kwargs)


def build_virtual_machines_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machines_list_all_request(
    subscription_id: str, *, status_only: Optional[str] = None, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines")
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
    if status_only is not None:
        _params["statusOnly"] = _SERIALIZER.query("status_only", status_only, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machines_list_available_sizes_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machines_power_off_request(
    resource_group_name: str, vm_name: str, subscription_id: str, *, skip_shutdown: bool = False, **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if skip_shutdown is not None:
        _params["skipShutdown"] = _SERIALIZER.query("skip_shutdown", skip_shutdown, "bool")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="POST", url=_url, params=_params, **kwargs)


def build_virtual_machines_reapply_request(
    resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reapply",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machines_restart_request(
    resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="POST", url=_url, params=_params, **kwargs)


def build_virtual_machines_start_request(
    resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="POST", url=_url, params=_params, **kwargs)


def build_virtual_machines_redeploy_request(
    resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="POST", url=_url, params=_params, **kwargs)


def build_virtual_machines_reimage_request(
    resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reimage",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")

    return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machines_retrieve_boot_diagnostics_data_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    vm_name: str,
    subscription_id: str,
    *,
    sas_uri_expiration_time_in_minutes: Optional[int] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/retrieveBootDiagnosticsData",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if sas_uri_expiration_time_in_minutes is not None:
        _params["sasUriExpirationTimeInMinutes"] = _SERIALIZER.query(
            "sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, "int"
        )
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machines_perform_maintenance_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/performMaintenance",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="POST", url=_url, params=_params, **kwargs)


def build_virtual_machines_simulate_eviction_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/simulateEviction",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="POST", url=_url, params=_params, **kwargs)


def build_virtual_machines_assess_patches_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/assessPatches",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machines_install_patches_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/installPatches",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machines_run_command_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json, text/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommand",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_sets_list_by_location_request(  # pylint: disable=name-too-long
    location: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachineScaleSets",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "location": _SERIALIZER.url("location", location, "str", pattern=r"^[-\w\._]+$"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_sets_create_or_update_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_sets_update_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_sets_delete_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    vm_scale_set_name: str,
    subscription_id: str,
    *,
    force_deletion: Optional[bool] = None,
    **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if force_deletion is not None:
        _params["forceDeletion"] = _SERIALIZER.query("force_deletion", force_deletion, "bool")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs)


def build_virtual_machine_scale_sets_get_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    vm_scale_set_name: str,
    subscription_id: str,
    *,
    expand: Optional[Union[str, _models.ExpandTypesForGetVMScaleSets]] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
    if expand is not None:
        _params["$expand"] = _SERIALIZER.query("expand", expand, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_sets_deallocate_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/deallocate",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")

    return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_sets_delete_instances_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    vm_scale_set_name: str,
    subscription_id: str,
    *,
    force_deletion: Optional[bool] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/delete",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if force_deletion is not None:
        _params["forceDeletion"] = _SERIALIZER.query("force_deletion", force_deletion, "bool")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")

    return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_sets_get_instance_view_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_sets_list_request(  # pylint: disable=name-too-long
    resource_group_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_sets_list_all_request(  # pylint: disable=name-too-long
    subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets"
    )
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_sets_list_skus_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_sets_get_os_upgrade_history_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osUpgradeHistory",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_sets_power_off_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    vm_scale_set_name: str,
    subscription_id: str,
    *,
    skip_shutdown: bool = False,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/poweroff",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if skip_shutdown is not None:
        _params["skipShutdown"] = _SERIALIZER.query("skip_shutdown", skip_shutdown, "bool")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")

    return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_sets_restart_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/restart",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")

    return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_sets_start_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")

    return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_sets_redeploy_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/redeploy",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")

    return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_sets_perform_maintenance_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/performMaintenance",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")

    return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_sets_update_instances_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/manualupgrade",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")

    return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_sets_reimage_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimage",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")

    return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_sets_reimage_all_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimageall",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")

    return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_sets_force_recovery_service_fabric_platform_update_domain_walk_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    vm_scale_set_name: str,
    subscription_id: str,
    *,
    platform_update_domain: int,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/forceRecoveryServiceFabricPlatformUpdateDomainWalk",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
    _params["platformUpdateDomain"] = _SERIALIZER.query("platform_update_domain", platform_update_domain, "int")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_sets_convert_to_single_placement_group_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/convertToSinglePlacementGroup",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")

    return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_sets_set_orchestration_service_state_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/setOrchestrationServiceState",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")

    return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_sizes_list_request(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes"
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "location": _SERIALIZER.url("location", location, "str", pattern=r"^[-\w\._]+$"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_images_create_or_update_request(
    resource_group_name: str, image_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "imageName": _SERIALIZER.url("image_name", image_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)


def build_images_update_request(
    resource_group_name: str, image_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "imageName": _SERIALIZER.url("image_name", image_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)


def build_images_delete_request(
    resource_group_name: str, image_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "imageName": _SERIALIZER.url("image_name", image_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs)


def build_images_get_request(
    resource_group_name: str, image_name: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "imageName": _SERIALIZER.url("image_name", image_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if expand is not None:
        _params["$expand"] = _SERIALIZER.query("expand", expand, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_images_list_by_resource_group_request(  # pylint: disable=name-too-long
    resource_group_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_images_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/images")
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_restore_point_collections_create_or_update_request(  # pylint: disable=name-too-long
    resource_group_name: str, restore_point_collection_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "restorePointCollectionName": _SERIALIZER.url(
            "restore_point_collection_name", restore_point_collection_name, "str"
        ),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)


def build_restore_point_collections_update_request(  # pylint: disable=name-too-long
    resource_group_name: str, restore_point_collection_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "restorePointCollectionName": _SERIALIZER.url(
            "restore_point_collection_name", restore_point_collection_name, "str"
        ),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)


def build_restore_point_collections_delete_request(  # pylint: disable=name-too-long
    resource_group_name: str, restore_point_collection_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "restorePointCollectionName": _SERIALIZER.url(
            "restore_point_collection_name", restore_point_collection_name, "str"
        ),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)


def build_restore_point_collections_get_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    restore_point_collection_name: str,
    subscription_id: str,
    *,
    expand: Optional[Union[str, _models.RestorePointCollectionExpandOptions]] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "restorePointCollectionName": _SERIALIZER.url(
            "restore_point_collection_name", restore_point_collection_name, "str"
        ),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if expand is not None:
        _params["$expand"] = _SERIALIZER.query("expand", expand, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_restore_point_collections_list_request(  # pylint: disable=name-too-long
    resource_group_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_restore_point_collections_list_all_request(  # pylint: disable=name-too-long
    subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/restorePointCollections"
    )
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_restore_points_create_request(
    resource_group_name: str,
    restore_point_collection_name: str,
    restore_point_name: str,
    subscription_id: str,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "restorePointCollectionName": _SERIALIZER.url(
            "restore_point_collection_name", restore_point_collection_name, "str"
        ),
        "restorePointName": _SERIALIZER.url("restore_point_name", restore_point_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)


def build_restore_points_delete_request(
    resource_group_name: str,
    restore_point_collection_name: str,
    restore_point_name: str,
    subscription_id: str,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "restorePointCollectionName": _SERIALIZER.url(
            "restore_point_collection_name", restore_point_collection_name, "str"
        ),
        "restorePointName": _SERIALIZER.url("restore_point_name", restore_point_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)


def build_restore_points_get_request(
    resource_group_name: str,
    restore_point_collection_name: str,
    restore_point_name: str,
    subscription_id: str,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "restorePointCollectionName": _SERIALIZER.url(
            "restore_point_collection_name", restore_point_collection_name, "str"
        ),
        "restorePointName": _SERIALIZER.url("restore_point_name", restore_point_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_capacity_reservation_groups_create_or_update_request(  # pylint: disable=name-too-long
    resource_group_name: str, capacity_reservation_group_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "capacityReservationGroupName": _SERIALIZER.url(
            "capacity_reservation_group_name", capacity_reservation_group_name, "str"
        ),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)


def build_capacity_reservation_groups_update_request(  # pylint: disable=name-too-long
    resource_group_name: str, capacity_reservation_group_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "capacityReservationGroupName": _SERIALIZER.url(
            "capacity_reservation_group_name", capacity_reservation_group_name, "str"
        ),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)


def build_capacity_reservation_groups_delete_request(  # pylint: disable=name-too-long
    resource_group_name: str, capacity_reservation_group_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "capacityReservationGroupName": _SERIALIZER.url(
            "capacity_reservation_group_name", capacity_reservation_group_name, "str"
        ),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)


def build_capacity_reservation_groups_get_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    capacity_reservation_group_name: str,
    subscription_id: str,
    *,
    expand: Optional[Union[str, _models.CapacityReservationGroupInstanceViewTypes]] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "capacityReservationGroupName": _SERIALIZER.url(
            "capacity_reservation_group_name", capacity_reservation_group_name, "str"
        ),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if expand is not None:
        _params["$expand"] = _SERIALIZER.query("expand", expand, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_capacity_reservation_groups_list_by_resource_group_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    subscription_id: str,
    *,
    expand: Optional[Union[str, _models.ExpandTypesForGetCapacityReservationGroups]] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
    if expand is not None:
        _params["$expand"] = _SERIALIZER.query("expand", expand, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_capacity_reservation_groups_list_by_subscription_request(  # pylint: disable=name-too-long
    subscription_id: str,
    *,
    expand: Optional[Union[str, _models.ExpandTypesForGetCapacityReservationGroups]] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/capacityReservationGroups"
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
    if expand is not None:
        _params["$expand"] = _SERIALIZER.query("expand", expand, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_capacity_reservations_create_or_update_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    capacity_reservation_group_name: str,
    capacity_reservation_name: str,
    subscription_id: str,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "capacityReservationGroupName": _SERIALIZER.url(
            "capacity_reservation_group_name", capacity_reservation_group_name, "str"
        ),
        "capacityReservationName": _SERIALIZER.url("capacity_reservation_name", capacity_reservation_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)


def build_capacity_reservations_update_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    capacity_reservation_group_name: str,
    capacity_reservation_name: str,
    subscription_id: str,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "capacityReservationGroupName": _SERIALIZER.url(
            "capacity_reservation_group_name", capacity_reservation_group_name, "str"
        ),
        "capacityReservationName": _SERIALIZER.url("capacity_reservation_name", capacity_reservation_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)


def build_capacity_reservations_delete_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    capacity_reservation_group_name: str,
    capacity_reservation_name: str,
    subscription_id: str,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "capacityReservationGroupName": _SERIALIZER.url(
            "capacity_reservation_group_name", capacity_reservation_group_name, "str"
        ),
        "capacityReservationName": _SERIALIZER.url("capacity_reservation_name", capacity_reservation_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)


def build_capacity_reservations_get_request(
    resource_group_name: str,
    capacity_reservation_group_name: str,
    capacity_reservation_name: str,
    subscription_id: str,
    *,
    expand: Optional[Union[str, _models.CapacityReservationInstanceViewTypes]] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "capacityReservationGroupName": _SERIALIZER.url(
            "capacity_reservation_group_name", capacity_reservation_group_name, "str"
        ),
        "capacityReservationName": _SERIALIZER.url("capacity_reservation_name", capacity_reservation_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if expand is not None:
        _params["$expand"] = _SERIALIZER.query("expand", expand, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_capacity_reservations_list_by_capacity_reservation_group_request(  # pylint: disable=name-too-long
    resource_group_name: str, capacity_reservation_group_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "capacityReservationGroupName": _SERIALIZER.url(
            "capacity_reservation_group_name", capacity_reservation_group_name, "str"
        ),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_set_extensions_create_or_update_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "vmssExtensionName": _SERIALIZER.url("vmss_extension_name", vmss_extension_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_set_extensions_update_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "vmssExtensionName": _SERIALIZER.url("vmss_extension_name", vmss_extension_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_set_extensions_delete_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "vmssExtensionName": _SERIALIZER.url("vmss_extension_name", vmss_extension_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs)


def build_virtual_machine_scale_set_extensions_get_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    vm_scale_set_name: str,
    vmss_extension_name: str,
    subscription_id: str,
    *,
    expand: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "vmssExtensionName": _SERIALIZER.url("vmss_extension_name", vmss_extension_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if expand is not None:
        _params["$expand"] = _SERIALIZER.query("expand", expand, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_set_extensions_list_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_set_rolling_upgrades_cancel_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/cancel",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="POST", url=_url, params=_params, **kwargs)


def build_virtual_machine_scale_set_rolling_upgrades_start_os_upgrade_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osRollingUpgrade",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="POST", url=_url, params=_params, **kwargs)


def build_virtual_machine_scale_set_rolling_upgrades_start_extension_upgrade_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensionRollingUpgrade",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="POST", url=_url, params=_params, **kwargs)


def build_virtual_machine_scale_set_rolling_upgrades_get_latest_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_set_vm_extensions_create_or_update_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    vm_scale_set_name: str,
    instance_id: str,
    vm_extension_name: str,
    subscription_id: str,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"),
        "vmExtensionName": _SERIALIZER.url("vm_extension_name", vm_extension_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_set_vm_extensions_update_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    vm_scale_set_name: str,
    instance_id: str,
    vm_extension_name: str,
    subscription_id: str,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"),
        "vmExtensionName": _SERIALIZER.url("vm_extension_name", vm_extension_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_set_vm_extensions_delete_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    vm_scale_set_name: str,
    instance_id: str,
    vm_extension_name: str,
    subscription_id: str,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"),
        "vmExtensionName": _SERIALIZER.url("vm_extension_name", vm_extension_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_set_vm_extensions_get_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    vm_scale_set_name: str,
    instance_id: str,
    vm_extension_name: str,
    subscription_id: str,
    *,
    expand: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"),
        "vmExtensionName": _SERIALIZER.url("vm_extension_name", vm_extension_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if expand is not None:
        _params["$expand"] = _SERIALIZER.query("expand", expand, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_set_vm_extensions_list_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    vm_scale_set_name: str,
    instance_id: str,
    subscription_id: str,
    *,
    expand: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if expand is not None:
        _params["$expand"] = _SERIALIZER.query("expand", expand, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_set_vms_reimage_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimage",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")

    return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_set_vms_reimage_all_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimageall",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="POST", url=_url, params=_params, **kwargs)


def build_virtual_machine_scale_set_vms_deallocate_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="POST", url=_url, params=_params, **kwargs)


def build_virtual_machine_scale_set_vms_update_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_set_vms_delete_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    vm_scale_set_name: str,
    instance_id: str,
    subscription_id: str,
    *,
    force_deletion: Optional[bool] = None,
    **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if force_deletion is not None:
        _params["forceDeletion"] = _SERIALIZER.query("force_deletion", force_deletion, "bool")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs)


def build_virtual_machine_scale_set_vms_get_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    vm_scale_set_name: str,
    instance_id: str,
    subscription_id: str,
    *,
    expand: Optional[Union[str, _models.InstanceViewTypes]] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if expand is not None:
        _params["$expand"] = _SERIALIZER.query("expand", expand, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_set_vms_get_instance_view_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/instanceView",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_set_vms_list_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    virtual_machine_scale_set_name: str,
    subscription_id: str,
    *,
    filter: Optional[str] = None,
    select: Optional[str] = None,
    expand: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "virtualMachineScaleSetName": _SERIALIZER.url(
            "virtual_machine_scale_set_name", virtual_machine_scale_set_name, "str"
        ),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if filter is not None:
        _params["$filter"] = _SERIALIZER.query("filter", filter, "str")
    if select is not None:
        _params["$select"] = _SERIALIZER.query("select", select, "str")
    if expand is not None:
        _params["$expand"] = _SERIALIZER.query("expand", expand, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_set_vms_power_off_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    vm_scale_set_name: str,
    instance_id: str,
    subscription_id: str,
    *,
    skip_shutdown: bool = False,
    **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if skip_shutdown is not None:
        _params["skipShutdown"] = _SERIALIZER.query("skip_shutdown", skip_shutdown, "bool")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="POST", url=_url, params=_params, **kwargs)


def build_virtual_machine_scale_set_vms_restart_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="POST", url=_url, params=_params, **kwargs)


def build_virtual_machine_scale_set_vms_start_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="POST", url=_url, params=_params, **kwargs)


def build_virtual_machine_scale_set_vms_redeploy_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/redeploy",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="POST", url=_url, params=_params, **kwargs)


def build_virtual_machine_scale_set_vms_retrieve_boot_diagnostics_data_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    vm_scale_set_name: str,
    instance_id: str,
    subscription_id: str,
    *,
    sas_uri_expiration_time_in_minutes: Optional[int] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/retrieveBootDiagnosticsData",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if sas_uri_expiration_time_in_minutes is not None:
        _params["sasUriExpirationTimeInMinutes"] = _SERIALIZER.query(
            "sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, "int"
        )
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_set_vms_perform_maintenance_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/performMaintenance",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="POST", url=_url, params=_params, **kwargs)


def build_virtual_machine_scale_set_vms_simulate_eviction_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/simulateEviction",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    return HttpRequest(method="POST", url=_url, params=_params, **kwargs)


def build_virtual_machine_scale_set_vms_run_command_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_scale_set_name: str, instance_id: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json, text/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/runCommand",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)


def build_log_analytics_export_request_rate_by_interval_request(  # pylint: disable=name-too-long
    location: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getRequestRateByInterval",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "location": _SERIALIZER.url("location", location, "str", pattern=r"^[-\w\._]+$"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)


def build_log_analytics_export_throttled_requests_request(  # pylint: disable=name-too-long
    location: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getThrottledRequests",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "location": _SERIALIZER.url("location", location, "str", pattern=r"^[-\w\._]+$"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_run_commands_list_request(  # pylint: disable=name-too-long
    location: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json, text/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands"
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "location": _SERIALIZER.url("location", location, "str", pattern=r"^[-\w\._]+$"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_run_commands_get_request(  # pylint: disable=name-too-long
    location: str, command_id: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json, text/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands/{commandId}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "location": _SERIALIZER.url("location", location, "str", pattern=r"^[-\w\._]+$"),
        "commandId": _SERIALIZER.url("command_id", command_id, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_run_commands_create_or_update_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_name: str, run_command_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json, text/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_run_commands_update_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_name: str, run_command_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json, text/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_run_commands_delete_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_name: str, run_command_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json, text/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_run_commands_get_by_virtual_machine_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    vm_name: str,
    run_command_name: str,
    subscription_id: str,
    *,
    expand: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json, text/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if expand is not None:
        _params["$expand"] = _SERIALIZER.query("expand", expand, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_run_commands_list_by_virtual_machine_request(  # pylint: disable=name-too-long
    resource_group_name: str, vm_name: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json, text/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmName": _SERIALIZER.url("vm_name", vm_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if expand is not None:
        _params["$expand"] = _SERIALIZER.query("expand", expand, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_set_vm_run_commands_create_or_update_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    vm_scale_set_name: str,
    instance_id: str,
    run_command_name: str,
    subscription_id: str,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json, text/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"),
        "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_set_vm_run_commands_update_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    vm_scale_set_name: str,
    instance_id: str,
    run_command_name: str,
    subscription_id: str,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json, text/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"),
        "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_set_vm_run_commands_delete_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    vm_scale_set_name: str,
    instance_id: str,
    run_command_name: str,
    subscription_id: str,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json, text/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"),
        "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_set_vm_run_commands_get_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    vm_scale_set_name: str,
    instance_id: str,
    run_command_name: str,
    subscription_id: str,
    *,
    expand: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json, text/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"),
        "runCommandName": _SERIALIZER.url("run_command_name", run_command_name, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if expand is not None:
        _params["$expand"] = _SERIALIZER.query("expand", expand, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_virtual_machine_scale_set_vm_run_commands_list_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    vm_scale_set_name: str,
    instance_id: str,
    subscription_id: str,
    *,
    expand: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json, text/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "vmScaleSetName": _SERIALIZER.url("vm_scale_set_name", vm_scale_set_name, "str"),
        "instanceId": _SERIALIZER.url("instance_id", instance_id, "str"),
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if expand is not None:
        _params["$expand"] = _SERIALIZER.query("expand", expand, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_resource_skus_list_request(
    subscription_id: str,
    *,
    filter: Optional[str] = None,
    include_extended_locations: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/skus")
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
    if filter is not None:
        _params["$filter"] = _SERIALIZER.query("filter", filter, "str")
    if include_extended_locations is not None:
        _params["includeExtendedLocations"] = _SERIALIZER.query(
            "include_extended_locations", include_extended_locations, "str"
        )

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_galleries_create_or_update_request(
    resource_group_name: str, gallery_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)


def build_galleries_update_request(
    resource_group_name: str, gallery_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)


def build_galleries_get_request(
    resource_group_name: str,
    gallery_name: str,
    subscription_id: str,
    *,
    select: Optional[Union[str, _models.SelectPermissions]] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
    if select is not None:
        _params["$select"] = _SERIALIZER.query("select", select, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_galleries_delete_request(
    resource_group_name: str, gallery_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)


def build_galleries_list_by_resource_group_request(  # pylint: disable=name-too-long
    resource_group_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_galleries_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/galleries")
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_gallery_images_create_or_update_request(  # pylint: disable=name-too-long
    resource_group_name: str, gallery_name: str, gallery_image_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"),
        "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)


def build_gallery_images_update_request(
    resource_group_name: str, gallery_name: str, gallery_image_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"),
        "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)


def build_gallery_images_get_request(
    resource_group_name: str, gallery_name: str, gallery_image_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"),
        "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_gallery_images_delete_request(
    resource_group_name: str, gallery_name: str, gallery_image_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"),
        "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)


def build_gallery_images_list_by_gallery_request(  # pylint: disable=name-too-long
    resource_group_name: str, gallery_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_gallery_image_versions_create_or_update_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    gallery_name: str,
    gallery_image_name: str,
    gallery_image_version_name: str,
    subscription_id: str,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"),
        "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"),
        "galleryImageVersionName": _SERIALIZER.url("gallery_image_version_name", gallery_image_version_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)


def build_gallery_image_versions_update_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    gallery_name: str,
    gallery_image_name: str,
    gallery_image_version_name: str,
    subscription_id: str,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"),
        "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"),
        "galleryImageVersionName": _SERIALIZER.url("gallery_image_version_name", gallery_image_version_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)


def build_gallery_image_versions_get_request(
    resource_group_name: str,
    gallery_name: str,
    gallery_image_name: str,
    gallery_image_version_name: str,
    subscription_id: str,
    *,
    expand: Optional[Union[str, _models.ReplicationStatusTypes]] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"),
        "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"),
        "galleryImageVersionName": _SERIALIZER.url("gallery_image_version_name", gallery_image_version_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if expand is not None:
        _params["$expand"] = _SERIALIZER.query("expand", expand, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_gallery_image_versions_delete_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    gallery_name: str,
    gallery_image_name: str,
    gallery_image_version_name: str,
    subscription_id: str,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"),
        "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"),
        "galleryImageVersionName": _SERIALIZER.url("gallery_image_version_name", gallery_image_version_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)


def build_gallery_image_versions_list_by_gallery_image_request(  # pylint: disable=name-too-long
    resource_group_name: str, gallery_name: str, gallery_image_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"),
        "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_gallery_applications_create_or_update_request(  # pylint: disable=name-too-long
    resource_group_name: str, gallery_name: str, gallery_application_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"),
        "galleryApplicationName": _SERIALIZER.url("gallery_application_name", gallery_application_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)


def build_gallery_applications_update_request(  # pylint: disable=name-too-long
    resource_group_name: str, gallery_name: str, gallery_application_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"),
        "galleryApplicationName": _SERIALIZER.url("gallery_application_name", gallery_application_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)


def build_gallery_applications_get_request(
    resource_group_name: str, gallery_name: str, gallery_application_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"),
        "galleryApplicationName": _SERIALIZER.url("gallery_application_name", gallery_application_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_gallery_applications_delete_request(  # pylint: disable=name-too-long
    resource_group_name: str, gallery_name: str, gallery_application_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"),
        "galleryApplicationName": _SERIALIZER.url("gallery_application_name", gallery_application_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)


def build_gallery_applications_list_by_gallery_request(  # pylint: disable=name-too-long
    resource_group_name: str, gallery_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_gallery_application_versions_create_or_update_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    gallery_name: str,
    gallery_application_name: str,
    gallery_application_version_name: str,
    subscription_id: str,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"),
        "galleryApplicationName": _SERIALIZER.url("gallery_application_name", gallery_application_name, "str"),
        "galleryApplicationVersionName": _SERIALIZER.url(
            "gallery_application_version_name", gallery_application_version_name, "str"
        ),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)


def build_gallery_application_versions_update_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    gallery_name: str,
    gallery_application_name: str,
    gallery_application_version_name: str,
    subscription_id: str,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"),
        "galleryApplicationName": _SERIALIZER.url("gallery_application_name", gallery_application_name, "str"),
        "galleryApplicationVersionName": _SERIALIZER.url(
            "gallery_application_version_name", gallery_application_version_name, "str"
        ),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)


def build_gallery_application_versions_get_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    gallery_name: str,
    gallery_application_name: str,
    gallery_application_version_name: str,
    subscription_id: str,
    *,
    expand: Optional[Union[str, _models.ReplicationStatusTypes]] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"),
        "galleryApplicationName": _SERIALIZER.url("gallery_application_name", gallery_application_name, "str"),
        "galleryApplicationVersionName": _SERIALIZER.url(
            "gallery_application_version_name", gallery_application_version_name, "str"
        ),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if expand is not None:
        _params["$expand"] = _SERIALIZER.query("expand", expand, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_gallery_application_versions_delete_request(  # pylint: disable=name-too-long
    resource_group_name: str,
    gallery_name: str,
    gallery_application_name: str,
    gallery_application_version_name: str,
    subscription_id: str,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"),
        "galleryApplicationName": _SERIALIZER.url("gallery_application_name", gallery_application_name, "str"),
        "galleryApplicationVersionName": _SERIALIZER.url(
            "gallery_application_version_name", gallery_application_version_name, "str"
        ),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)


def build_gallery_application_versions_list_by_gallery_application_request(  # pylint: disable=name-too-long
    resource_group_name: str, gallery_name: str, gallery_application_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"),
        "galleryApplicationName": _SERIALIZER.url("gallery_application_name", gallery_application_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_gallery_sharing_profile_update_request(  # pylint: disable=name-too-long
    resource_group_name: str, gallery_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/share",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
        "galleryName": _SERIALIZER.url("gallery_name", gallery_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)


def build_shared_galleries_list_request(
    location: str,
    subscription_id: str,
    *,
    shared_to: Optional[Union[str, _models.SharedToValues]] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "location": _SERIALIZER.url("location", location, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
    if shared_to is not None:
        _params["sharedTo"] = _SERIALIZER.query("shared_to", shared_to, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_shared_galleries_get_request(
    location: str, gallery_unique_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "location": _SERIALIZER.url("location", location, "str"),
        "galleryUniqueName": _SERIALIZER.url("gallery_unique_name", gallery_unique_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_shared_gallery_images_list_request(
    location: str,
    gallery_unique_name: str,
    subscription_id: str,
    *,
    shared_to: Optional[Union[str, _models.SharedToValues]] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "location": _SERIALIZER.url("location", location, "str"),
        "galleryUniqueName": _SERIALIZER.url("gallery_unique_name", gallery_unique_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
    if shared_to is not None:
        _params["sharedTo"] = _SERIALIZER.query("shared_to", shared_to, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_shared_gallery_images_get_request(
    location: str, gallery_unique_name: str, gallery_image_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "location": _SERIALIZER.url("location", location, "str"),
        "galleryUniqueName": _SERIALIZER.url("gallery_unique_name", gallery_unique_name, "str"),
        "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_shared_gallery_image_versions_list_request(  # pylint: disable=name-too-long
    location: str,
    gallery_unique_name: str,
    gallery_image_name: str,
    subscription_id: str,
    *,
    shared_to: Optional[Union[str, _models.SharedToValues]] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}/versions",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "location": _SERIALIZER.url("location", location, "str"),
        "galleryUniqueName": _SERIALIZER.url("gallery_unique_name", gallery_unique_name, "str"),
        "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
    if shared_to is not None:
        _params["sharedTo"] = _SERIALIZER.query("shared_to", shared_to, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_shared_gallery_image_versions_get_request(  # pylint: disable=name-too-long
    location: str,
    gallery_unique_name: str,
    gallery_image_name: str,
    gallery_image_version_name: str,
    subscription_id: str,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}/versions/{galleryImageVersionName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "location": _SERIALIZER.url("location", location, "str"),
        "galleryUniqueName": _SERIALIZER.url("gallery_unique_name", gallery_unique_name, "str"),
        "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"),
        "galleryImageVersionName": _SERIALIZER.url("gallery_image_version_name", gallery_image_version_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_community_galleries_get_request(
    location: str, public_gallery_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "location": _SERIALIZER.url("location", location, "str"),
        "publicGalleryName": _SERIALIZER.url("public_gallery_name", public_gallery_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_community_gallery_images_get_request(  # pylint: disable=name-too-long
    location: str, public_gallery_name: str, gallery_image_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images/{galleryImageName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "location": _SERIALIZER.url("location", location, "str"),
        "publicGalleryName": _SERIALIZER.url("public_gallery_name", public_gallery_name, "str"),
        "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_community_gallery_image_versions_get_request(  # pylint: disable=name-too-long
    location: str,
    public_gallery_name: str,
    gallery_image_name: str,
    gallery_image_version_name: str,
    subscription_id: str,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop(
        "template_url",
        "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}",
    )  # pylint: disable=line-too-long
    path_format_arguments = {
        "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
        "location": _SERIALIZER.url("location", location, "str"),
        "publicGalleryName": _SERIALIZER.url("public_gallery_name", public_gallery_name, "str"),
        "galleryImageName": _SERIALIZER.url("gallery_image_name", gallery_image_name, "str"),
        "galleryImageVersionName": _SERIALIZER.url("gallery_image_version_name", gallery_image_version_name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


[docs] class Operations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`operations` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version")
[docs] @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.ComputeOperationValue"]: """Gets a list of compute operations. :return: An iterator like instance of either ComputeOperationValue or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.ComputeOperationValue] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.ComputeOperationListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_operations_list_request( api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("ComputeOperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] class AvailabilitySetsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`availability_sets` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload def create_or_update( self, resource_group_name: str, availability_set_name: str, parameters: _models.AvailabilitySet, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param availability_set_name: The name of the availability set. Required. :type availability_set_name: str :param parameters: Parameters supplied to the Create Availability Set operation. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.AvailabilitySet :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: AvailabilitySet or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.AvailabilitySet :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create_or_update( self, resource_group_name: str, availability_set_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param availability_set_name: The name of the availability set. Required. :type availability_set_name: str :param parameters: Parameters supplied to the Create Availability Set operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: AvailabilitySet or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.AvailabilitySet :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def create_or_update( self, resource_group_name: str, availability_set_name: str, parameters: Union[_models.AvailabilitySet, IO[bytes]], **kwargs: Any ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param availability_set_name: The name of the availability set. Required. :type availability_set_name: str :param parameters: Parameters supplied to the Create Availability Set operation. Is either a AvailabilitySet type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.AvailabilitySet or IO[bytes] :return: AvailabilitySet or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.AvailabilitySet :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "AvailabilitySet") _request = build_availability_sets_create_or_update_request( resource_group_name=resource_group_name, availability_set_name=availability_set_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("AvailabilitySet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
@overload def update( self, resource_group_name: str, availability_set_name: str, parameters: _models.AvailabilitySetUpdate, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param availability_set_name: The name of the availability set. Required. :type availability_set_name: str :param parameters: Parameters supplied to the Update Availability Set operation. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.AvailabilitySetUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: AvailabilitySet or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.AvailabilitySet :raises ~azure.core.exceptions.HttpResponseError: """ @overload def update( self, resource_group_name: str, availability_set_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param availability_set_name: The name of the availability set. Required. :type availability_set_name: str :param parameters: Parameters supplied to the Update Availability Set operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: AvailabilitySet or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.AvailabilitySet :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def update( self, resource_group_name: str, availability_set_name: str, parameters: Union[_models.AvailabilitySetUpdate, IO[bytes]], **kwargs: Any ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param availability_set_name: The name of the availability set. Required. :type availability_set_name: str :param parameters: Parameters supplied to the Update Availability Set operation. Is either a AvailabilitySetUpdate type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.AvailabilitySetUpdate or IO[bytes] :return: AvailabilitySet or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.AvailabilitySet :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "AvailabilitySetUpdate") _request = build_availability_sets_update_request( resource_group_name=resource_group_name, availability_set_name=availability_set_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("AvailabilitySet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, availability_set_name: str, **kwargs: Any ) -> None: """Delete an availability set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param availability_set_name: The name of the availability set. Required. :type availability_set_name: str :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) _request = build_availability_sets_delete_request( resource_group_name=resource_group_name, availability_set_name=availability_set_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) # type: ignore
[docs] @distributed_trace def get(self, resource_group_name: str, availability_set_name: str, **kwargs: Any) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param availability_set_name: The name of the availability set. Required. :type availability_set_name: str :return: AvailabilitySet or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.AvailabilitySet :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.AvailabilitySet] = kwargs.pop("cls", None) _request = build_availability_sets_get_request( resource_group_name=resource_group_name, availability_set_name=availability_set_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("AvailabilitySet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def list_by_subscription( self, *, expand: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.AvailabilitySet"]: """Lists all availability sets in a subscription. :keyword expand: The expand expression to apply to the operation. Allowed values are 'instanceView'. Default value is None. :paramtype expand: str :return: An iterator like instance of either AvailabilitySet or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.AvailabilitySet] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.AvailabilitySetListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_availability_sets_list_by_subscription_request( subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] @distributed_trace def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.AvailabilitySet"]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :return: An iterator like instance of either AvailabilitySet or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.AvailabilitySet] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.AvailabilitySetListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_availability_sets_list_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("AvailabilitySetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] @distributed_trace def list_available_sizes( self, resource_group_name: str, availability_set_name: str, **kwargs: Any ) -> Iterable["_models.VirtualMachineSize"]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param availability_set_name: The name of the availability set. Required. :type availability_set_name: str :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineSize] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_availability_sets_list_available_sizes_request( resource_group_name=resource_group_name, availability_set_name=availability_set_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("VirtualMachineSizeListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] class ProximityPlacementGroupsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`proximity_placement_groups` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload def create_or_update( self, resource_group_name: str, proximity_placement_group_name: str, parameters: _models.ProximityPlacementGroup, *, content_type: str = "application/json", **kwargs: Any ) -> _models.ProximityPlacementGroup: """Create or update a proximity placement group. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param proximity_placement_group_name: The name of the proximity placement group. Required. :type proximity_placement_group_name: str :param parameters: Parameters supplied to the Create Proximity Placement Group operation. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroup :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: ProximityPlacementGroup or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroup :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create_or_update( self, resource_group_name: str, proximity_placement_group_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.ProximityPlacementGroup: """Create or update a proximity placement group. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param proximity_placement_group_name: The name of the proximity placement group. Required. :type proximity_placement_group_name: str :param parameters: Parameters supplied to the Create Proximity Placement Group operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: ProximityPlacementGroup or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroup :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def create_or_update( self, resource_group_name: str, proximity_placement_group_name: str, parameters: Union[_models.ProximityPlacementGroup, IO[bytes]], **kwargs: Any ) -> _models.ProximityPlacementGroup: """Create or update a proximity placement group. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param proximity_placement_group_name: The name of the proximity placement group. Required. :type proximity_placement_group_name: str :param parameters: Parameters supplied to the Create Proximity Placement Group operation. Is either a ProximityPlacementGroup type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroup or IO[bytes] :return: ProximityPlacementGroup or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroup :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ProximityPlacementGroup") _request = build_proximity_placement_groups_create_or_update_request( resource_group_name=resource_group_name, proximity_placement_group_name=proximity_placement_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
@overload def update( self, resource_group_name: str, proximity_placement_group_name: str, parameters: _models.ProximityPlacementGroupUpdate, *, content_type: str = "application/json", **kwargs: Any ) -> _models.ProximityPlacementGroup: """Update a proximity placement group. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param proximity_placement_group_name: The name of the proximity placement group. Required. :type proximity_placement_group_name: str :param parameters: Parameters supplied to the Update Proximity Placement Group operation. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroupUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: ProximityPlacementGroup or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroup :raises ~azure.core.exceptions.HttpResponseError: """ @overload def update( self, resource_group_name: str, proximity_placement_group_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.ProximityPlacementGroup: """Update a proximity placement group. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param proximity_placement_group_name: The name of the proximity placement group. Required. :type proximity_placement_group_name: str :param parameters: Parameters supplied to the Update Proximity Placement Group operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: ProximityPlacementGroup or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroup :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def update( self, resource_group_name: str, proximity_placement_group_name: str, parameters: Union[_models.ProximityPlacementGroupUpdate, IO[bytes]], **kwargs: Any ) -> _models.ProximityPlacementGroup: """Update a proximity placement group. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param proximity_placement_group_name: The name of the proximity placement group. Required. :type proximity_placement_group_name: str :param parameters: Parameters supplied to the Update Proximity Placement Group operation. Is either a ProximityPlacementGroupUpdate type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroupUpdate or IO[bytes] :return: ProximityPlacementGroup or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroup :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ProximityPlacementGroupUpdate") _request = build_proximity_placement_groups_update_request( resource_group_name=resource_group_name, proximity_placement_group_name=proximity_placement_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, proximity_placement_group_name: str, **kwargs: Any ) -> None: """Delete a proximity placement group. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param proximity_placement_group_name: The name of the proximity placement group. Required. :type proximity_placement_group_name: str :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) _request = build_proximity_placement_groups_delete_request( resource_group_name=resource_group_name, proximity_placement_group_name=proximity_placement_group_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) # type: ignore
[docs] @distributed_trace def get( self, resource_group_name: str, proximity_placement_group_name: str, *, include_colocation_status: Optional[str] = None, **kwargs: Any ) -> _models.ProximityPlacementGroup: """Retrieves information about a proximity placement group . :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param proximity_placement_group_name: The name of the proximity placement group. Required. :type proximity_placement_group_name: str :keyword include_colocation_status: includeColocationStatus=true enables fetching the colocation status of all the resources in the proximity placement group. Default value is None. :paramtype include_colocation_status: str :return: ProximityPlacementGroup or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroup :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.ProximityPlacementGroup] = kwargs.pop("cls", None) _request = build_proximity_placement_groups_get_request( resource_group_name=resource_group_name, proximity_placement_group_name=proximity_placement_group_name, subscription_id=self._config.subscription_id, include_colocation_status=include_colocation_status, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("ProximityPlacementGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ProximityPlacementGroup"]: """Lists all proximity placement groups in a subscription. :return: An iterator like instance of either ProximityPlacementGroup or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroup] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_proximity_placement_groups_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("ProximityPlacementGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any ) -> Iterable["_models.ProximityPlacementGroup"]: """Lists all proximity placement groups in a resource group. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :return: An iterator like instance of either ProximityPlacementGroup or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroup] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.ProximityPlacementGroupListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_proximity_placement_groups_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("ProximityPlacementGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] class DedicatedHostGroupsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`dedicated_host_groups` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload def create_or_update( self, resource_group_name: str, host_group_name: str, parameters: _models.DedicatedHostGroup, *, content_type: str = "application/json", **kwargs: Any ) -> _models.DedicatedHostGroup: """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host Groups please see [Dedicated Host Documentation] (https://go.microsoft.com/fwlink/?linkid=2082596). :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str :param parameters: Parameters supplied to the Create Dedicated Host Group. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroup :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: DedicatedHostGroup or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroup :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create_or_update( self, resource_group_name: str, host_group_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.DedicatedHostGroup: """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host Groups please see [Dedicated Host Documentation] (https://go.microsoft.com/fwlink/?linkid=2082596). :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str :param parameters: Parameters supplied to the Create Dedicated Host Group. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: DedicatedHostGroup or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroup :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def create_or_update( self, resource_group_name: str, host_group_name: str, parameters: Union[_models.DedicatedHostGroup, IO[bytes]], **kwargs: Any ) -> _models.DedicatedHostGroup: """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host Groups please see [Dedicated Host Documentation] (https://go.microsoft.com/fwlink/?linkid=2082596). :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str :param parameters: Parameters supplied to the Create Dedicated Host Group. Is either a DedicatedHostGroup type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroup or IO[bytes] :return: DedicatedHostGroup or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroup :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DedicatedHostGroup") _request = build_dedicated_host_groups_create_or_update_request( resource_group_name=resource_group_name, host_group_name=host_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("DedicatedHostGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
@overload def update( self, resource_group_name: str, host_group_name: str, parameters: _models.DedicatedHostGroupUpdate, *, content_type: str = "application/json", **kwargs: Any ) -> _models.DedicatedHostGroup: """Update an dedicated host group. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroupUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: DedicatedHostGroup or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroup :raises ~azure.core.exceptions.HttpResponseError: """ @overload def update( self, resource_group_name: str, host_group_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.DedicatedHostGroup: """Update an dedicated host group. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: DedicatedHostGroup or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroup :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def update( self, resource_group_name: str, host_group_name: str, parameters: Union[_models.DedicatedHostGroupUpdate, IO[bytes]], **kwargs: Any ) -> _models.DedicatedHostGroup: """Update an dedicated host group. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str :param parameters: Parameters supplied to the Update Dedicated Host Group operation. Is either a DedicatedHostGroupUpdate type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroupUpdate or IO[bytes] :return: DedicatedHostGroup or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroup :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DedicatedHostGroupUpdate") _request = build_dedicated_host_groups_update_request( resource_group_name=resource_group_name, host_group_name=host_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("DedicatedHostGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, host_group_name: str, **kwargs: Any ) -> None: """Delete a dedicated host group. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) _request = build_dedicated_host_groups_delete_request( resource_group_name=resource_group_name, host_group_name=host_group_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) # type: ignore
[docs] @distributed_trace def get( self, resource_group_name: str, host_group_name: str, *, expand: Optional[Union[str, _models.InstanceViewTypes]] = None, **kwargs: Any ) -> _models.DedicatedHostGroup: """Retrieves information about a dedicated host group. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str :keyword expand: The expand expression to apply on the operation. 'InstanceView' will retrieve the list of instance views of the dedicated hosts under the dedicated host group. 'UserData' is not supported for dedicated host group. Known values are: "instanceView" and "userData". Default value is None. :paramtype expand: str or ~azure.mgmt.compute.v2021_07_01.models.InstanceViewTypes :return: DedicatedHostGroup or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroup :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.DedicatedHostGroup] = kwargs.pop("cls", None) _request = build_dedicated_host_groups_get_request( resource_group_name=resource_group_name, host_group_name=host_group_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("DedicatedHostGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.DedicatedHostGroup"]: """Lists all of the dedicated host groups in the specified resource group. Use the nextLink property in the response to get the next page of dedicated host groups. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :return: An iterator like instance of either DedicatedHostGroup or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroup] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_dedicated_host_groups_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("DedicatedHostGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] @distributed_trace def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.DedicatedHostGroup"]: """Lists all of the dedicated host groups in the subscription. Use the nextLink property in the response to get the next page of dedicated host groups. :return: An iterator like instance of either DedicatedHostGroup or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroup] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.DedicatedHostGroupListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_dedicated_host_groups_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("DedicatedHostGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] class DedicatedHostsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`dedicated_hosts` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") def _create_or_update_initial( self, resource_group_name: str, host_group_name: str, host_name: str, parameters: Union[_models.DedicatedHost, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DedicatedHost") _request = build_dedicated_hosts_create_or_update_request( resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_create_or_update( self, resource_group_name: str, host_group_name: str, host_name: str, parameters: _models.DedicatedHost, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.DedicatedHost]: """Create or update a dedicated host . :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str :param host_name: The name of the dedicated host . Required. :type host_name: str :param parameters: Parameters supplied to the Create Dedicated Host. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHost :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either DedicatedHost or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.DedicatedHost] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_create_or_update( self, resource_group_name: str, host_group_name: str, host_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.DedicatedHost]: """Create or update a dedicated host . :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str :param host_name: The name of the dedicated host . Required. :type host_name: str :param parameters: Parameters supplied to the Create Dedicated Host. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either DedicatedHost or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.DedicatedHost] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_create_or_update( self, resource_group_name: str, host_group_name: str, host_name: str, parameters: Union[_models.DedicatedHost, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.DedicatedHost]: """Create or update a dedicated host . :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str :param host_name: The name of the dedicated host . Required. :type host_name: str :param parameters: Parameters supplied to the Create Dedicated Host. Is either a DedicatedHost type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHost or IO[bytes] :return: An instance of LROPoller that returns either DedicatedHost or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.DedicatedHost] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DedicatedHost] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("DedicatedHost", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.DedicatedHost].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.DedicatedHost]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _update_initial( self, resource_group_name: str, host_group_name: str, host_name: str, parameters: Union[_models.DedicatedHostUpdate, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "DedicatedHostUpdate") _request = build_dedicated_hosts_update_request( resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_update( self, resource_group_name: str, host_group_name: str, host_name: str, parameters: _models.DedicatedHostUpdate, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.DedicatedHost]: """Update an dedicated host . :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str :param host_name: The name of the dedicated host . Required. :type host_name: str :param parameters: Parameters supplied to the Update Dedicated Host operation. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either DedicatedHost or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.DedicatedHost] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_update( self, resource_group_name: str, host_group_name: str, host_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.DedicatedHost]: """Update an dedicated host . :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str :param host_name: The name of the dedicated host . Required. :type host_name: str :param parameters: Parameters supplied to the Update Dedicated Host operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either DedicatedHost or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.DedicatedHost] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_update( self, resource_group_name: str, host_group_name: str, host_name: str, parameters: Union[_models.DedicatedHostUpdate, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.DedicatedHost]: """Update an dedicated host . :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str :param host_name: The name of the dedicated host . Required. :type host_name: str :param parameters: Parameters supplied to the Update Dedicated Host operation. Is either a DedicatedHostUpdate type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostUpdate or IO[bytes] :return: An instance of LROPoller that returns either DedicatedHost or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.DedicatedHost] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DedicatedHost] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("DedicatedHost", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.DedicatedHost].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.DedicatedHost]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _delete_initial( self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_dedicated_hosts_delete_request( resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_delete( self, resource_group_name: str, host_group_name: str, host_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete a dedicated host. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str :param host_name: The name of the dedicated host. Required. :type host_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
[docs] @distributed_trace def get( self, resource_group_name: str, host_group_name: str, host_name: str, *, expand: Optional[Union[str, _models.InstanceViewTypes]] = None, **kwargs: Any ) -> _models.DedicatedHost: """Retrieves information about a dedicated host. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str :param host_name: The name of the dedicated host. Required. :type host_name: str :keyword expand: The expand expression to apply on the operation. 'InstanceView' will retrieve the list of instance views of the dedicated host. 'UserData' is not supported for dedicated host. Known values are: "instanceView" and "userData". Default value is None. :paramtype expand: str or ~azure.mgmt.compute.v2021_07_01.models.InstanceViewTypes :return: DedicatedHost or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHost :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.DedicatedHost] = kwargs.pop("cls", None) _request = build_dedicated_hosts_get_request( resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("DedicatedHost", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def list_by_host_group( self, resource_group_name: str, host_group_name: str, **kwargs: Any ) -> Iterable["_models.DedicatedHost"]: """Lists all of the dedicated hosts in the specified dedicated host group. Use the nextLink property in the response to get the next page of dedicated hosts. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param host_group_name: The name of the dedicated host group. Required. :type host_group_name: str :return: An iterator like instance of either DedicatedHost or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.DedicatedHost] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.DedicatedHostListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_dedicated_hosts_list_by_host_group_request( resource_group_name=resource_group_name, host_group_name=host_group_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("DedicatedHostListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] class SshPublicKeysOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`ssh_public_keys` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version")
[docs] @distributed_trace def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.SshPublicKeyResource"]: """Lists all of the SSH public keys in the subscription. Use the nextLink property in the response to get the next page of SSH public keys. :return: An iterator like instance of either SshPublicKeyResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.SshPublicKeyResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.SshPublicKeysGroupListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_ssh_public_keys_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("SshPublicKeysGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any ) -> Iterable["_models.SshPublicKeyResource"]: """Lists all of the SSH public keys in the specified resource group. Use the nextLink property in the response to get the next page of SSH public keys. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :return: An iterator like instance of either SshPublicKeyResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.SshPublicKeyResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.SshPublicKeysGroupListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_ssh_public_keys_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("SshPublicKeysGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
@overload def create( self, resource_group_name: str, ssh_public_key_name: str, parameters: _models.SshPublicKeyResource, *, content_type: str = "application/json", **kwargs: Any ) -> _models.SshPublicKeyResource: """Creates a new SSH public key resource. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param ssh_public_key_name: The name of the SSH public key. Required. :type ssh_public_key_name: str :param parameters: Parameters supplied to create the SSH public key. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.SshPublicKeyResource :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: SshPublicKeyResource or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.SshPublicKeyResource :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create( self, resource_group_name: str, ssh_public_key_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.SshPublicKeyResource: """Creates a new SSH public key resource. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param ssh_public_key_name: The name of the SSH public key. Required. :type ssh_public_key_name: str :param parameters: Parameters supplied to create the SSH public key. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: SshPublicKeyResource or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.SshPublicKeyResource :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def create( self, resource_group_name: str, ssh_public_key_name: str, parameters: Union[_models.SshPublicKeyResource, IO[bytes]], **kwargs: Any ) -> _models.SshPublicKeyResource: """Creates a new SSH public key resource. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param ssh_public_key_name: The name of the SSH public key. Required. :type ssh_public_key_name: str :param parameters: Parameters supplied to create the SSH public key. Is either a SshPublicKeyResource type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.SshPublicKeyResource or IO[bytes] :return: SshPublicKeyResource or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.SshPublicKeyResource :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SshPublicKeyResource") _request = build_ssh_public_keys_create_request( resource_group_name=resource_group_name, ssh_public_key_name=ssh_public_key_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("SshPublicKeyResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
@overload def update( self, resource_group_name: str, ssh_public_key_name: str, parameters: _models.SshPublicKeyUpdateResource, *, content_type: str = "application/json", **kwargs: Any ) -> _models.SshPublicKeyResource: """Updates a new SSH public key resource. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param ssh_public_key_name: The name of the SSH public key. Required. :type ssh_public_key_name: str :param parameters: Parameters supplied to update the SSH public key. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.SshPublicKeyUpdateResource :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: SshPublicKeyResource or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.SshPublicKeyResource :raises ~azure.core.exceptions.HttpResponseError: """ @overload def update( self, resource_group_name: str, ssh_public_key_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.SshPublicKeyResource: """Updates a new SSH public key resource. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param ssh_public_key_name: The name of the SSH public key. Required. :type ssh_public_key_name: str :param parameters: Parameters supplied to update the SSH public key. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: SshPublicKeyResource or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.SshPublicKeyResource :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def update( self, resource_group_name: str, ssh_public_key_name: str, parameters: Union[_models.SshPublicKeyUpdateResource, IO[bytes]], **kwargs: Any ) -> _models.SshPublicKeyResource: """Updates a new SSH public key resource. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param ssh_public_key_name: The name of the SSH public key. Required. :type ssh_public_key_name: str :param parameters: Parameters supplied to update the SSH public key. Is either a SshPublicKeyUpdateResource type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.SshPublicKeyUpdateResource or IO[bytes] :return: SshPublicKeyResource or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.SshPublicKeyResource :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "SshPublicKeyUpdateResource") _request = build_ssh_public_keys_update_request( resource_group_name=resource_group_name, ssh_public_key_name=ssh_public_key_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("SshPublicKeyResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, ssh_public_key_name: str, **kwargs: Any ) -> None: """Delete an SSH public key. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param ssh_public_key_name: The name of the SSH public key. Required. :type ssh_public_key_name: str :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) _request = build_ssh_public_keys_delete_request( resource_group_name=resource_group_name, ssh_public_key_name=ssh_public_key_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) # type: ignore
[docs] @distributed_trace def get(self, resource_group_name: str, ssh_public_key_name: str, **kwargs: Any) -> _models.SshPublicKeyResource: """Retrieves information about an SSH public key. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param ssh_public_key_name: The name of the SSH public key. Required. :type ssh_public_key_name: str :return: SshPublicKeyResource or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.SshPublicKeyResource :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.SshPublicKeyResource] = kwargs.pop("cls", None) _request = build_ssh_public_keys_get_request( resource_group_name=resource_group_name, ssh_public_key_name=ssh_public_key_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("SshPublicKeyResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def generate_key_pair( self, resource_group_name: str, ssh_public_key_name: str, **kwargs: Any ) -> _models.SshPublicKeyGenerateKeyPairResult: """Generates and returns a public/private key pair and populates the SSH public key resource with the public key. The length of the key will be 3072 bits. This operation can only be performed once per SSH public key resource. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param ssh_public_key_name: The name of the SSH public key. Required. :type ssh_public_key_name: str :return: SshPublicKeyGenerateKeyPairResult or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.SshPublicKeyGenerateKeyPairResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.SshPublicKeyGenerateKeyPairResult] = kwargs.pop("cls", None) _request = build_ssh_public_keys_generate_key_pair_request( resource_group_name=resource_group_name, ssh_public_key_name=ssh_public_key_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("SshPublicKeyGenerateKeyPairResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] class VirtualMachineExtensionImagesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`virtual_machine_extension_images` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version")
[docs] @distributed_trace def get( self, location: str, publisher_name: str, type: str, version: str, **kwargs: Any ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. Required. :type location: str :param publisher_name: Required. :type publisher_name: str :param type: Required. :type type: str :param version: Required. :type version: str :return: VirtualMachineExtensionImage or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtensionImage :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineExtensionImage] = kwargs.pop("cls", None) _request = build_virtual_machine_extension_images_get_request( location=location, publisher_name=publisher_name, type=type, version=version, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("VirtualMachineExtensionImage", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def list_types( self, location: str, publisher_name: str, **kwargs: Any ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. Required. :type location: str :param publisher_name: Required. :type publisher_name: str :return: list of VirtualMachineExtensionImage or the result of cls(response) :rtype: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtensionImage] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) _request = build_virtual_machine_extension_images_list_types_request( location=location, publisher_name=publisher_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("[VirtualMachineExtensionImage]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def list_versions( self, location: str, publisher_name: str, type: str, *, filter: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. Required. :type location: str :param publisher_name: Required. :type publisher_name: str :param type: Required. :type type: str :keyword filter: The filter to apply on the operation. Default value is None. :paramtype filter: str :keyword top: Default value is None. :paramtype top: int :keyword orderby: Default value is None. :paramtype orderby: str :return: list of VirtualMachineExtensionImage or the result of cls(response) :rtype: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtensionImage] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[List[_models.VirtualMachineExtensionImage]] = kwargs.pop("cls", None) _request = build_virtual_machine_extension_images_list_versions_request( location=location, publisher_name=publisher_name, type=type, subscription_id=self._config.subscription_id, filter=filter, top=top, orderby=orderby, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("[VirtualMachineExtensionImage]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] class VirtualMachineExtensionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`virtual_machine_extensions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, extension_parameters: Union[_models.VirtualMachineExtension, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(extension_parameters, (IOBase, bytes)): _content = extension_parameters else: _json = self._serialize.body(extension_parameters, "VirtualMachineExtension") _request = build_virtual_machine_extensions_create_or_update_request( resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_create_or_update( self, resource_group_name: str, vm_name: str, vm_extension_name: str, extension_parameters: _models.VirtualMachineExtension, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine where the extension should be created or updated. Required. :type vm_name: str :param vm_extension_name: The name of the virtual machine extension. Required. :type vm_extension_name: str :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension operation. Required. :type extension_parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtension :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_create_or_update( self, resource_group_name: str, vm_name: str, vm_extension_name: str, extension_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine where the extension should be created or updated. Required. :type vm_name: str :param vm_extension_name: The name of the virtual machine extension. Required. :type vm_extension_name: str :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension operation. Required. :type extension_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_create_or_update( self, resource_group_name: str, vm_name: str, vm_extension_name: str, extension_parameters: Union[_models.VirtualMachineExtension, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine where the extension should be created or updated. Required. :type vm_name: str :param vm_extension_name: The name of the virtual machine extension. Required. :type vm_extension_name: str :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension operation. Is either a VirtualMachineExtension type or a IO[bytes] type. Required. :type extension_parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtension or IO[bytes] :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.VirtualMachineExtension] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, extension_parameters=extension_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("VirtualMachineExtension", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.VirtualMachineExtension].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.VirtualMachineExtension]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, extension_parameters: Union[_models.VirtualMachineExtensionUpdate, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(extension_parameters, (IOBase, bytes)): _content = extension_parameters else: _json = self._serialize.body(extension_parameters, "VirtualMachineExtensionUpdate") _request = build_virtual_machine_extensions_update_request( resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_update( self, resource_group_name: str, vm_name: str, vm_extension_name: str, extension_parameters: _models.VirtualMachineExtensionUpdate, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine where the extension should be updated. Required. :type vm_name: str :param vm_extension_name: The name of the virtual machine extension. Required. :type vm_extension_name: str :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension operation. Required. :type extension_parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtensionUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_update( self, resource_group_name: str, vm_name: str, vm_extension_name: str, extension_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine where the extension should be updated. Required. :type vm_name: str :param vm_extension_name: The name of the virtual machine extension. Required. :type vm_extension_name: str :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension operation. Required. :type extension_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_update( self, resource_group_name: str, vm_name: str, vm_extension_name: str, extension_parameters: Union[_models.VirtualMachineExtensionUpdate, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine where the extension should be updated. Required. :type vm_name: str :param vm_extension_name: The name of the virtual machine extension. Required. :type vm_extension_name: str :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension operation. Is either a VirtualMachineExtensionUpdate type or a IO[bytes] type. Required. :type extension_parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtensionUpdate or IO[bytes] :return: An instance of LROPoller that returns either VirtualMachineExtension or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.VirtualMachineExtension] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, extension_parameters=extension_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("VirtualMachineExtension", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.VirtualMachineExtension].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.VirtualMachineExtension]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _delete_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_virtual_machine_extensions_delete_request( resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_delete( self, resource_group_name: str, vm_name: str, vm_extension_name: str, **kwargs: Any ) -> LROPoller[None]: """The operation to delete the extension. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine where the extension should be deleted. Required. :type vm_name: str :param vm_extension_name: The name of the virtual machine extension. Required. :type vm_extension_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
[docs] @distributed_trace def get( self, resource_group_name: str, vm_name: str, vm_extension_name: str, *, expand: Optional[str] = None, **kwargs: Any ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine containing the extension. Required. :type vm_name: str :param vm_extension_name: The name of the virtual machine extension. Required. :type vm_extension_name: str :keyword expand: The expand expression to apply on the operation. Default value is None. :paramtype expand: str :return: VirtualMachineExtension or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtension :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineExtension] = kwargs.pop("cls", None) _request = build_virtual_machine_extensions_get_request( resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("VirtualMachineExtension", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def list( self, resource_group_name: str, vm_name: str, *, expand: Optional[str] = None, **kwargs: Any ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine containing the extension. Required. :type vm_name: str :keyword expand: The expand expression to apply on the operation. Default value is None. :paramtype expand: str :return: VirtualMachineExtensionsListResult or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtensionsListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineExtensionsListResult] = kwargs.pop("cls", None) _request = build_virtual_machine_extensions_list_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("VirtualMachineExtensionsListResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] class VirtualMachineImagesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`virtual_machine_images` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version")
[docs] @distributed_trace def get( self, location: str, publisher_name: str, offer: str, skus: str, version: str, **kwargs: Any ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. Required. :type location: str :param publisher_name: A valid image publisher. Required. :type publisher_name: str :param offer: A valid image publisher offer. Required. :type offer: str :param skus: A valid image SKU. Required. :type skus: str :param version: A valid image SKU version. Required. :type version: str :return: VirtualMachineImage or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImage :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineImage] = kwargs.pop("cls", None) _request = build_virtual_machine_images_get_request( location=location, publisher_name=publisher_name, offer=offer, skus=skus, version=version, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("VirtualMachineImage", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def list( self, location: str, publisher_name: str, offer: str, skus: str, *, expand: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. :param location: The name of a supported Azure region. Required. :type location: str :param publisher_name: A valid image publisher. Required. :type publisher_name: str :param offer: A valid image publisher offer. Required. :type offer: str :param skus: A valid image SKU. Required. :type skus: str :keyword expand: The expand expression to apply on the operation. Default value is None. :paramtype expand: str :keyword top: Default value is None. :paramtype top: int :keyword orderby: Default value is None. :paramtype orderby: str :return: list of VirtualMachineImageResource or the result of cls(response) :rtype: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImageResource] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) _request = build_virtual_machine_images_list_request( location=location, publisher_name=publisher_name, offer=offer, skus=skus, subscription_id=self._config.subscription_id, expand=expand, top=top, orderby=orderby, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def list_offers( self, location: str, publisher_name: str, **kwargs: Any ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. Required. :type location: str :param publisher_name: A valid image publisher. Required. :type publisher_name: str :return: list of VirtualMachineImageResource or the result of cls(response) :rtype: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImageResource] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) _request = build_virtual_machine_images_list_offers_request( location=location, publisher_name=publisher_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def list_publishers(self, location: str, **kwargs: Any) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. Required. :type location: str :return: list of VirtualMachineImageResource or the result of cls(response) :rtype: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImageResource] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) _request = build_virtual_machine_images_list_publishers_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def list_skus( self, location: str, publisher_name: str, offer: str, **kwargs: Any ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. Required. :type location: str :param publisher_name: A valid image publisher. Required. :type publisher_name: str :param offer: A valid image publisher offer. Required. :type offer: str :return: list of VirtualMachineImageResource or the result of cls(response) :rtype: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImageResource] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) _request = build_virtual_machine_images_list_skus_request( location=location, publisher_name=publisher_name, offer=offer, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] class VirtualMachineImagesEdgeZoneOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`virtual_machine_images_edge_zone` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version")
[docs] @distributed_trace def get( self, location: str, edge_zone: str, publisher_name: str, offer: str, skus: str, version: str, **kwargs: Any ) -> _models.VirtualMachineImage: """Gets a virtual machine image in an edge zone. :param location: The name of a supported Azure region. Required. :type location: str :param edge_zone: The name of the edge zone. Required. :type edge_zone: str :param publisher_name: A valid image publisher. Required. :type publisher_name: str :param offer: A valid image publisher offer. Required. :type offer: str :param skus: A valid image SKU. Required. :type skus: str :param version: A valid image SKU version. Required. :type version: str :return: VirtualMachineImage or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImage :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineImage] = kwargs.pop("cls", None) _request = build_virtual_machine_images_edge_zone_get_request( location=location, edge_zone=edge_zone, publisher_name=publisher_name, offer=offer, skus=skus, version=version, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("VirtualMachineImage", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def list( self, location: str, edge_zone: str, publisher_name: str, offer: str, skus: str, *, expand: Optional[str] = None, top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, edge zone, publisher, offer, and SKU. :param location: The name of a supported Azure region. Required. :type location: str :param edge_zone: The name of the edge zone. Required. :type edge_zone: str :param publisher_name: A valid image publisher. Required. :type publisher_name: str :param offer: A valid image publisher offer. Required. :type offer: str :param skus: A valid image SKU. Required. :type skus: str :keyword expand: The expand expression to apply on the operation. Default value is None. :paramtype expand: str :keyword top: An integer value specifying the number of images to return that matches supplied values. Default value is None. :paramtype top: int :keyword orderby: Specifies the order of the results returned. Formatted as an OData query. Default value is None. :paramtype orderby: str :return: list of VirtualMachineImageResource or the result of cls(response) :rtype: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImageResource] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) _request = build_virtual_machine_images_edge_zone_list_request( location=location, edge_zone=edge_zone, publisher_name=publisher_name, offer=offer, skus=skus, subscription_id=self._config.subscription_id, expand=expand, top=top, orderby=orderby, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def list_offers( self, location: str, edge_zone: str, publisher_name: str, **kwargs: Any ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location, edge zone and publisher. :param location: The name of a supported Azure region. Required. :type location: str :param edge_zone: The name of the edge zone. Required. :type edge_zone: str :param publisher_name: A valid image publisher. Required. :type publisher_name: str :return: list of VirtualMachineImageResource or the result of cls(response) :rtype: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImageResource] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) _request = build_virtual_machine_images_edge_zone_list_offers_request( location=location, edge_zone=edge_zone, publisher_name=publisher_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def list_publishers( self, location: str, edge_zone: str, **kwargs: Any ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location and edge zone. :param location: The name of a supported Azure region. Required. :type location: str :param edge_zone: The name of the edge zone. Required. :type edge_zone: str :return: list of VirtualMachineImageResource or the result of cls(response) :rtype: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImageResource] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) _request = build_virtual_machine_images_edge_zone_list_publishers_request( location=location, edge_zone=edge_zone, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def list_skus( self, location: str, edge_zone: str, publisher_name: str, offer: str, **kwargs: Any ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, edge zone, publisher, and offer. :param location: The name of a supported Azure region. Required. :type location: str :param edge_zone: The name of the edge zone. Required. :type edge_zone: str :param publisher_name: A valid image publisher. Required. :type publisher_name: str :param offer: A valid image publisher offer. Required. :type offer: str :return: list of VirtualMachineImageResource or the result of cls(response) :rtype: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImageResource] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[List[_models.VirtualMachineImageResource]] = kwargs.pop("cls", None) _request = build_virtual_machine_images_edge_zone_list_skus_request( location=location, edge_zone=edge_zone, publisher_name=publisher_name, offer=offer, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("[VirtualMachineImageResource]", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] class UsageOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`usage` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version")
[docs] @distributed_trace def list(self, location: str, **kwargs: Any) -> Iterable["_models.Usage"]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. :param location: The location for which resource usage is queried. Required. :type location: str :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.ListUsagesResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_usage_list_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("ListUsagesResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] class VirtualMachinesOperations: # pylint: disable=too-many-public-methods """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`virtual_machines` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version")
[docs] @distributed_trace def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.VirtualMachine"]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. Required. :type location: str :return: An iterator like instance of either VirtualMachine or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachine] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_virtual_machines_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("VirtualMachineListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
def _capture_initial( self, resource_group_name: str, vm_name: str, parameters: Union[_models.VirtualMachineCaptureParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "VirtualMachineCaptureParameters") _request = build_virtual_machines_capture_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_capture( self, resource_group_name: str, vm_name: str, parameters: _models.VirtualMachineCaptureParameters, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :param parameters: Parameters supplied to the Capture Virtual Machine operation. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineCaptureParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineCaptureResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineCaptureResult] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_capture( self, resource_group_name: str, vm_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :param parameters: Parameters supplied to the Capture Virtual Machine operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineCaptureResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineCaptureResult] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_capture( self, resource_group_name: str, vm_name: str, parameters: Union[_models.VirtualMachineCaptureParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :param parameters: Parameters supplied to the Capture Virtual Machine operation. Is either a VirtualMachineCaptureParameters type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineCaptureParameters or IO[bytes] :return: An instance of LROPoller that returns either VirtualMachineCaptureResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineCaptureResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.VirtualMachineCaptureResult] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._capture_initial( resource_group_name=resource_group_name, vm_name=vm_name, parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("VirtualMachineCaptureResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast( PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.VirtualMachineCaptureResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.VirtualMachineCaptureResult]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _create_or_update_initial( self, resource_group_name: str, vm_name: str, parameters: Union[_models.VirtualMachine, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "VirtualMachine") _request = build_virtual_machines_create_or_update_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_create_or_update( self, resource_group_name: str, vm_name: str, parameters: _models.VirtualMachine, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. Please note some properties can be set only during virtual machine creation. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :param parameters: Parameters supplied to the Create Virtual Machine operation. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachine :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachine or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachine] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_create_or_update( self, resource_group_name: str, vm_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. Please note some properties can be set only during virtual machine creation. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :param parameters: Parameters supplied to the Create Virtual Machine operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachine or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachine] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_create_or_update( self, resource_group_name: str, vm_name: str, parameters: Union[_models.VirtualMachine, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. Please note some properties can be set only during virtual machine creation. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :param parameters: Parameters supplied to the Create Virtual Machine operation. Is either a VirtualMachine type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachine or IO[bytes] :return: An instance of LROPoller that returns either VirtualMachine or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachine] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.VirtualMachine] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, vm_name=vm_name, parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("VirtualMachine", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.VirtualMachine].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.VirtualMachine]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _update_initial( self, resource_group_name: str, vm_name: str, parameters: Union[_models.VirtualMachineUpdate, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "VirtualMachineUpdate") _request = build_virtual_machines_update_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_update( self, resource_group_name: str, vm_name: str, parameters: _models.VirtualMachineUpdate, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :param parameters: Parameters supplied to the Update Virtual Machine operation. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachine or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachine] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_update( self, resource_group_name: str, vm_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :param parameters: Parameters supplied to the Update Virtual Machine operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachine or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachine] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_update( self, resource_group_name: str, vm_name: str, parameters: Union[_models.VirtualMachineUpdate, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :param parameters: Parameters supplied to the Update Virtual Machine operation. Is either a VirtualMachineUpdate type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineUpdate or IO[bytes] :return: An instance of LROPoller that returns either VirtualMachine or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachine] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.VirtualMachine] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, vm_name=vm_name, parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("VirtualMachine", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.VirtualMachine].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.VirtualMachine]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _delete_initial( self, resource_group_name: str, vm_name: str, *, force_deletion: Optional[bool] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_virtual_machines_delete_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, force_deletion=force_deletion, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_delete( self, resource_group_name: str, vm_name: str, *, force_deletion: Optional[bool] = None, **kwargs: Any ) -> LROPoller[None]: """The operation to delete a virtual machine. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :keyword force_deletion: Optional parameter to force delete virtual machines. Default value is None. :paramtype force_deletion: bool :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( resource_group_name=resource_group_name, vm_name=vm_name, force_deletion=force_deletion, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
[docs] @distributed_trace def get( self, resource_group_name: str, vm_name: str, *, expand: Optional[Union[str, _models.InstanceViewTypes]] = None, **kwargs: Any ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :keyword expand: The expand expression to apply on the operation. 'InstanceView' retrieves a snapshot of the runtime properties of the virtual machine that is managed by the platform and can change outside of control plane operations. 'UserData' retrieves the UserData property as part of the VM model view that was provided by the user during the VM Create/Update operation. Known values are: "instanceView" and "userData". Default value is None. :paramtype expand: str or ~azure.mgmt.compute.v2021_07_01.models.InstanceViewTypes :return: VirtualMachine or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachine :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachine] = kwargs.pop("cls", None) _request = build_virtual_machines_get_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("VirtualMachine", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def instance_view( self, resource_group_name: str, vm_name: str, **kwargs: Any ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :return: VirtualMachineInstanceView or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineInstanceView :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineInstanceView] = kwargs.pop("cls", None) _request = build_virtual_machines_instance_view_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("VirtualMachineInstanceView", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
def _convert_to_managed_disks_initial( self, resource_group_name: str, vm_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_virtual_machines_convert_to_managed_disks_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_convert_to_managed_disks(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> LROPoller[None]: """Converts virtual machine disks from blob-based to managed disks. Virtual machine must be stop-deallocated before invoking this operation. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._convert_to_managed_disks_initial( resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
def _deallocate_initial( self, resource_group_name: str, vm_name: str, *, hibernate: Optional[bool] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_virtual_machines_deallocate_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, hibernate=hibernate, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_deallocate( self, resource_group_name: str, vm_name: str, *, hibernate: Optional[bool] = None, **kwargs: Any ) -> LROPoller[None]: """Shuts down the virtual machine and releases the compute resources. You are not billed for the compute resources that this virtual machine uses. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :keyword hibernate: Optional parameter to hibernate a virtual machine. (Feature in Preview). Default value is None. :paramtype hibernate: bool :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._deallocate_initial( resource_group_name=resource_group_name, vm_name=vm_name, hibernate=hibernate, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
[docs] @distributed_trace def generalize( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, **kwargs: Any ) -> None: """Sets the OS state of the virtual machine to generalized. It is recommended to sysprep the virtual machine before performing this operation. :code:`<br>`For Windows, please refer to `Create a managed image of a generalized VM in Azure <https://docs.microsoft.com/azure/virtual-machines/windows/capture-image-resource>`_.\\ :code:`<br>`For Linux, please refer to `How to create an image of a virtual machine or VHD <https://docs.microsoft.com/azure/virtual-machines/linux/capture-image>`_. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) _request = build_virtual_machines_generalize_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) # type: ignore
[docs] @distributed_trace def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.VirtualMachine"]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :return: An iterator like instance of either VirtualMachine or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachine] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_virtual_machines_list_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("VirtualMachineListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] @distributed_trace def list_all(self, *, status_only: Optional[str] = None, **kwargs: Any) -> Iterable["_models.VirtualMachine"]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. :keyword status_only: statusOnly=true enables fetching run time status of all Virtual Machines in the subscription. Default value is None. :paramtype status_only: str :return: An iterator like instance of either VirtualMachine or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachine] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_virtual_machines_list_all_request( subscription_id=self._config.subscription_id, status_only=status_only, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("VirtualMachineListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] @distributed_trace def list_available_sizes( self, resource_group_name: str, vm_name: str, **kwargs: Any ) -> Iterable["_models.VirtualMachineSize"]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineSize] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_virtual_machines_list_available_sizes_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("VirtualMachineSizeListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
def _power_off_initial( self, resource_group_name: str, vm_name: str, *, skip_shutdown: bool = False, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_virtual_machines_power_off_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, skip_shutdown=skip_shutdown, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_power_off( self, resource_group_name: str, vm_name: str, *, skip_shutdown: bool = False, **kwargs: Any ) -> LROPoller[None]: """The operation to power off (stop) a virtual machine. The virtual machine can be restarted with the same provisioned resources. You are still charged for this virtual machine. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this flag is false if not specified. Default value is False. :paramtype skip_shutdown: bool :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._power_off_initial( resource_group_name=resource_group_name, vm_name=vm_name, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
def _reapply_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_virtual_machines_reapply_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_reapply(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> LROPoller[None]: """The operation to reapply a virtual machine's state. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._reapply_initial( resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
def _restart_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_virtual_machines_restart_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_restart(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> LROPoller[None]: """The operation to restart a virtual machine. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._restart_initial( resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
def _start_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_virtual_machines_start_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_start(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> LROPoller[None]: """The operation to start a virtual machine. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._start_initial( resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
def _redeploy_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_virtual_machines_redeploy_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_redeploy(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> LROPoller[None]: """Shuts down the virtual machine, moves it to a new node, and powers it back on. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._redeploy_initial( resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
def _reimage_initial( self, resource_group_name: str, vm_name: str, parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: if parameters is not None: _json = self._serialize.body(parameters, "VirtualMachineReimageParameters") else: _json = None _request = build_virtual_machines_reimage_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_reimage( self, resource_group_name: str, vm_name: str, parameters: Optional[_models.VirtualMachineReimageParameters] = None, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Default value is None. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineReimageParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_reimage( self, resource_group_name: str, vm_name: str, parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Default value is None. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_reimage( self, resource_group_name: str, vm_name: str, parameters: Optional[Union[_models.VirtualMachineReimageParameters, IO[bytes]]] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :param parameters: Parameters supplied to the Reimage Virtual Machine operation. Is either a VirtualMachineReimageParameters type or a IO[bytes] type. Default value is None. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineReimageParameters or IO[bytes] :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._reimage_initial( resource_group_name=resource_group_name, vm_name=vm_name, parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
[docs] @distributed_trace def retrieve_boot_diagnostics_data( self, resource_group_name: str, vm_name: str, *, sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any ) -> _models.RetrieveBootDiagnosticsDataResult: """The operation to retrieve SAS URIs for a virtual machine's boot diagnostic logs. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :keyword sas_uri_expiration_time_in_minutes: Expiration duration in minutes for the SAS URIs with a value between 1 to 1440 minutes. :code:`<br>`\\ :code:`<br>`NOTE: If not specified, SAS URIs will be generated with a default expiration duration of 120 minutes. Default value is None. :paramtype sas_uri_expiration_time_in_minutes: int :return: RetrieveBootDiagnosticsDataResult or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.RetrieveBootDiagnosticsDataResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.RetrieveBootDiagnosticsDataResult] = kwargs.pop("cls", None) _request = build_virtual_machines_retrieve_boot_diagnostics_data_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RetrieveBootDiagnosticsDataResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
def _perform_maintenance_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_virtual_machines_perform_maintenance_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_perform_maintenance(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> LROPoller[None]: """The operation to perform maintenance on a virtual machine. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._perform_maintenance_initial( resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
[docs] @distributed_trace def simulate_eviction( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, **kwargs: Any ) -> None: """The operation to simulate the eviction of spot virtual machine. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) _request = build_virtual_machines_simulate_eviction_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) # type: ignore
def _assess_patches_initial(self, resource_group_name: str, vm_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_virtual_machines_assess_patches_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_assess_patches( self, resource_group_name: str, vm_name: str, **kwargs: Any ) -> LROPoller[_models.VirtualMachineAssessPatchesResult]: """Assess patches on the VM. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :return: An instance of LROPoller that returns either VirtualMachineAssessPatchesResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineAssessPatchesResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineAssessPatchesResult] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._assess_patches_initial( resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("VirtualMachineAssessPatchesResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast( PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.VirtualMachineAssessPatchesResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.VirtualMachineAssessPatchesResult]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _install_patches_initial( self, resource_group_name: str, vm_name: str, install_patches_input: Union[_models.VirtualMachineInstallPatchesParameters, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(install_patches_input, (IOBase, bytes)): _content = install_patches_input else: _json = self._serialize.body(install_patches_input, "VirtualMachineInstallPatchesParameters") _request = build_virtual_machines_install_patches_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_install_patches( self, resource_group_name: str, vm_name: str, install_patches_input: _models.VirtualMachineInstallPatchesParameters, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineInstallPatchesResult]: """Installs patches on the VM. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :param install_patches_input: Input for InstallPatches as directly received by the API. Required. :type install_patches_input: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineInstallPatchesParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineInstallPatchesResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineInstallPatchesResult] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_install_patches( self, resource_group_name: str, vm_name: str, install_patches_input: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineInstallPatchesResult]: """Installs patches on the VM. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :param install_patches_input: Input for InstallPatches as directly received by the API. Required. :type install_patches_input: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineInstallPatchesResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineInstallPatchesResult] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_install_patches( self, resource_group_name: str, vm_name: str, install_patches_input: Union[_models.VirtualMachineInstallPatchesParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VirtualMachineInstallPatchesResult]: """Installs patches on the VM. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :param install_patches_input: Input for InstallPatches as directly received by the API. Is either a VirtualMachineInstallPatchesParameters type or a IO[bytes] type. Required. :type install_patches_input: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineInstallPatchesParameters or IO[bytes] :return: An instance of LROPoller that returns either VirtualMachineInstallPatchesResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineInstallPatchesResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.VirtualMachineInstallPatchesResult] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._install_patches_initial( resource_group_name=resource_group_name, vm_name=vm_name, install_patches_input=install_patches_input, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("VirtualMachineInstallPatchesResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast( PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.VirtualMachineInstallPatchesResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.VirtualMachineInstallPatchesResult]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _run_command_initial( self, resource_group_name: str, vm_name: str, parameters: Union[_models.RunCommandInput, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RunCommandInput") _request = build_virtual_machines_run_command_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_run_command( self, resource_group_name: str, vm_name: str, parameters: _models.RunCommandInput, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :param parameters: Parameters supplied to the Run command operation. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.RunCommandInput :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either RunCommandResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.RunCommandResult] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_run_command( self, resource_group_name: str, vm_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :param parameters: Parameters supplied to the Run command operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Known values are: 'application/json', 'text/json'. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either RunCommandResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.RunCommandResult] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_run_command( self, resource_group_name: str, vm_name: str, parameters: Union[_models.RunCommandInput, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine. Required. :type vm_name: str :param parameters: Parameters supplied to the Run command operation. Is either a RunCommandInput type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.RunCommandInput or IO[bytes] :return: An instance of LROPoller that returns either RunCommandResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.RunCommandResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._run_command_initial( resource_group_name=resource_group_name, vm_name=vm_name, parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("RunCommandResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast( PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.RunCommandResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.RunCommandResult]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
[docs] class VirtualMachineScaleSetsOperations: # pylint: disable=too-many-public-methods """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`virtual_machine_scale_sets` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version")
[docs] @distributed_trace def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.VirtualMachineScaleSet"]: """Gets all the VM scale sets under the specified subscription for the specified location. :param location: The location for which VM scale sets under the subscription are queried. Required. :type location: str :return: An iterator like instance of either VirtualMachineScaleSet or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSet] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineScaleSetListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_virtual_machine_scale_sets_list_by_location_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("VirtualMachineScaleSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, parameters: Union[_models.VirtualMachineScaleSet, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "VirtualMachineScaleSet") _request = build_virtual_machine_scale_sets_create_or_update_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, parameters: _models.VirtualMachineScaleSet, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set to create or update. Required. :type vm_scale_set_name: str :param parameters: The scale set object. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSet :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSet] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set to create or update. Required. :type vm_scale_set_name: str :param parameters: The scale set object. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSet] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, parameters: Union[_models.VirtualMachineScaleSet, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set to create or update. Required. :type vm_scale_set_name: str :param parameters: The scale set object. Is either a VirtualMachineScaleSet type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSet or IO[bytes] :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSet] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.VirtualMachineScaleSet] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("VirtualMachineScaleSet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.VirtualMachineScaleSet].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.VirtualMachineScaleSet]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, parameters: Union[_models.VirtualMachineScaleSetUpdate, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "VirtualMachineScaleSetUpdate") _request = build_virtual_machine_scale_sets_update_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_update( self, resource_group_name: str, vm_scale_set_name: str, parameters: _models.VirtualMachineScaleSetUpdate, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set to create or update. Required. :type vm_scale_set_name: str :param parameters: The scale set object. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSet] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_update( self, resource_group_name: str, vm_scale_set_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set to create or update. Required. :type vm_scale_set_name: str :param parameters: The scale set object. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSet] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_update( self, resource_group_name: str, vm_scale_set_name: str, parameters: Union[_models.VirtualMachineScaleSetUpdate, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set to create or update. Required. :type vm_scale_set_name: str :param parameters: The scale set object. Is either a VirtualMachineScaleSetUpdate type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetUpdate or IO[bytes] :return: An instance of LROPoller that returns either VirtualMachineScaleSet or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSet] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.VirtualMachineScaleSet] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("VirtualMachineScaleSet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.VirtualMachineScaleSet].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.VirtualMachineScaleSet]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _delete_initial( self, resource_group_name: str, vm_scale_set_name: str, *, force_deletion: Optional[bool] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_virtual_machine_scale_sets_delete_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, force_deletion=force_deletion, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_delete( self, resource_group_name: str, vm_scale_set_name: str, *, force_deletion: Optional[bool] = None, **kwargs: Any ) -> LROPoller[None]: """Deletes a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :keyword force_deletion: Optional parameter to force delete a VM scale set. (Feature in Preview). Default value is None. :paramtype force_deletion: bool :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, force_deletion=force_deletion, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
[docs] @distributed_trace def get( self, resource_group_name: str, vm_scale_set_name: str, *, expand: Optional[Union[str, _models.ExpandTypesForGetVMScaleSets]] = None, **kwargs: Any ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :keyword expand: The expand expression to apply on the operation. 'UserData' retrieves the UserData property of the VM scale set that was provided by the user during the VM scale set Create/Update operation. "userData" Default value is None. :paramtype expand: str or ~azure.mgmt.compute.v2021_07_01.models.ExpandTypesForGetVMScaleSets :return: VirtualMachineScaleSet or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSet :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineScaleSet] = kwargs.pop("cls", None) _request = build_virtual_machine_scale_sets_get_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("VirtualMachineScaleSet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
def _deallocate_initial( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(vm_instance_i_ds, (IOBase, bytes)): _content = vm_instance_i_ds else: if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") else: _json = None _request = build_virtual_machine_scale_sets_deallocate_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_deallocate( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and releases the compute resources. You are not billed for the compute resources that this virtual machine scale set deallocates. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default value is None. :type vm_instance_i_ds: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMInstanceIDs :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_deallocate( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and releases the compute resources. You are not billed for the compute resources that this virtual machine scale set deallocates. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default value is None. :type vm_instance_i_ds: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_deallocate( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any ) -> LROPoller[None]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and releases the compute resources. You are not billed for the compute resources that this virtual machine scale set deallocates. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. :type vm_instance_i_ds: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._deallocate_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
def _delete_instances_initial( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], *, force_deletion: Optional[bool] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(vm_instance_i_ds, (IOBase, bytes)): _content = vm_instance_i_ds else: _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceRequiredIDs") _request = build_virtual_machine_scale_sets_delete_instances_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, force_deletion=force_deletion, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_delete_instances( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, *, force_deletion: Optional[bool] = None, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Deletes virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Required. :type vm_instance_i_ds: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs :keyword force_deletion: Optional parameter to force delete virtual machines from the VM scale set. (Feature in Preview). Default value is None. :paramtype force_deletion: bool :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_delete_instances( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: IO[bytes], *, force_deletion: Optional[bool] = None, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Deletes virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Required. :type vm_instance_i_ds: IO[bytes] :keyword force_deletion: Optional parameter to force delete virtual machines from the VM scale set. (Feature in Preview). Default value is None. :paramtype force_deletion: bool :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_delete_instances( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], *, force_deletion: Optional[bool] = None, **kwargs: Any ) -> LROPoller[None]: """Deletes virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is either a VirtualMachineScaleSetVMInstanceRequiredIDs type or a IO[bytes] type. Required. :type vm_instance_i_ds: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs or IO[bytes] :keyword force_deletion: Optional parameter to force delete virtual machines from the VM scale set. (Feature in Preview). Default value is None. :paramtype force_deletion: bool :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_instances_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, force_deletion=force_deletion, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
[docs] @distributed_trace def get_instance_view( self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :return: VirtualMachineScaleSetInstanceView or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetInstanceView :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineScaleSetInstanceView] = kwargs.pop("cls", None) _request = build_virtual_machine_scale_sets_get_instance_view_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("VirtualMachineScaleSetInstanceView", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.VirtualMachineScaleSet"]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :return: An iterator like instance of either VirtualMachineScaleSet or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSet] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineScaleSetListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_virtual_machine_scale_sets_list_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("VirtualMachineScaleSetListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] @distributed_trace def list_all(self, **kwargs: Any) -> Iterable["_models.VirtualMachineScaleSet"]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. :return: An iterator like instance of either VirtualMachineScaleSet or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSet] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_virtual_machine_scale_sets_list_all_request( subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("VirtualMachineScaleSetListWithLinkResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] @distributed_trace def list_skus( self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any ) -> Iterable["_models.VirtualMachineScaleSetSku"]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :return: An iterator like instance of either VirtualMachineScaleSetSku or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetSku] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineScaleSetListSkusResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_virtual_machine_scale_sets_list_skus_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("VirtualMachineScaleSetListSkusResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] @distributed_trace def get_os_upgrade_history( self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any ) -> Iterable["_models.UpgradeOperationHistoricalStatusInfo"]: """Gets list of OS upgrades on a VM scale set instance. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :return: An iterator like instance of either UpgradeOperationHistoricalStatusInfo or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.UpgradeOperationHistoricalStatusInfo] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_virtual_machine_scale_sets_get_os_upgrade_history_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("VirtualMachineScaleSetListOSUpgradeHistory", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
def _power_off_initial( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, *, skip_shutdown: bool = False, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(vm_instance_i_ds, (IOBase, bytes)): _content = vm_instance_i_ds else: if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") else: _json = None _request = build_virtual_machine_scale_sets_power_off_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, skip_shutdown=skip_shutdown, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_power_off( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, *, skip_shutdown: bool = False, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still attached and you are getting charged for the resources. Instead, use deallocate to release resources and avoid charges. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default value is None. :type vm_instance_i_ds: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMInstanceIDs :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this flag is false if not specified. Default value is False. :paramtype skip_shutdown: bool :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_power_off( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Optional[IO[bytes]] = None, *, skip_shutdown: bool = False, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still attached and you are getting charged for the resources. Instead, use deallocate to release resources and avoid charges. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default value is None. :type vm_instance_i_ds: IO[bytes] :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this flag is false if not specified. Default value is False. :paramtype skip_shutdown: bool :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_power_off( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, *, skip_shutdown: bool = False, **kwargs: Any ) -> LROPoller[None]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still attached and you are getting charged for the resources. Instead, use deallocate to release resources and avoid charges. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. :type vm_instance_i_ds: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this flag is false if not specified. Default value is False. :paramtype skip_shutdown: bool :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._power_off_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, skip_shutdown=skip_shutdown, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
def _restart_initial( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(vm_instance_i_ds, (IOBase, bytes)): _content = vm_instance_i_ds else: if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") else: _json = None _request = build_virtual_machine_scale_sets_restart_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_restart( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Restarts one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default value is None. :type vm_instance_i_ds: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMInstanceIDs :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_restart( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Restarts one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default value is None. :type vm_instance_i_ds: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_restart( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any ) -> LROPoller[None]: """Restarts one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. :type vm_instance_i_ds: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._restart_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
def _start_initial( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(vm_instance_i_ds, (IOBase, bytes)): _content = vm_instance_i_ds else: if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") else: _json = None _request = build_virtual_machine_scale_sets_start_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_start( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Starts one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default value is None. :type vm_instance_i_ds: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMInstanceIDs :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_start( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Starts one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default value is None. :type vm_instance_i_ds: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_start( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any ) -> LROPoller[None]: """Starts one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. :type vm_instance_i_ds: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._start_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
def _redeploy_initial( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(vm_instance_i_ds, (IOBase, bytes)): _content = vm_instance_i_ds else: if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") else: _json = None _request = build_virtual_machine_scale_sets_redeploy_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_redeploy( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, and powers them back on. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default value is None. :type vm_instance_i_ds: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMInstanceIDs :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_redeploy( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, and powers them back on. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default value is None. :type vm_instance_i_ds: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_redeploy( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any ) -> LROPoller[None]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, and powers them back on. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. :type vm_instance_i_ds: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._redeploy_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
def _perform_maintenance_initial( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(vm_instance_i_ds, (IOBase, bytes)): _content = vm_instance_i_ds else: if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") else: _json = None _request = build_virtual_machine_scale_sets_perform_maintenance_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_perform_maintenance( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances which are not eligible for perform maintenance will be failed. Please refer to best practices for more details: https://docs.microsoft.com/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default value is None. :type vm_instance_i_ds: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMInstanceIDs :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_perform_maintenance( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances which are not eligible for perform maintenance will be failed. Please refer to best practices for more details: https://docs.microsoft.com/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default value is None. :type vm_instance_i_ds: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_perform_maintenance( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any ) -> LROPoller[None]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances which are not eligible for perform maintenance will be failed. Please refer to best practices for more details: https://docs.microsoft.com/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. :type vm_instance_i_ds: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._perform_maintenance_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
def _update_instances_initial( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(vm_instance_i_ds, (IOBase, bytes)): _content = vm_instance_i_ds else: _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceRequiredIDs") _request = build_virtual_machine_scale_sets_update_instances_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_update_instances( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Required. :type vm_instance_i_ds: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_update_instances( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Required. :type vm_instance_i_ds: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_update_instances( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Union[_models.VirtualMachineScaleSetVMInstanceRequiredIDs, IO[bytes]], **kwargs: Any ) -> LROPoller[None]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is either a VirtualMachineScaleSetVMInstanceRequiredIDs type or a IO[bytes] type. Required. :type vm_instance_i_ds: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMInstanceRequiredIDs or IO[bytes] :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_instances_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
def _reimage_initial( self, resource_group_name: str, vm_scale_set_name: str, vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, IO[bytes]]] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(vm_scale_set_reimage_input, (IOBase, bytes)): _content = vm_scale_set_reimage_input else: if vm_scale_set_reimage_input is not None: _json = self._serialize.body(vm_scale_set_reimage_input, "VirtualMachineScaleSetReimageParameters") else: _json = None _request = build_virtual_machine_scale_sets_reimage_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_reimage( self, resource_group_name: str, vm_scale_set_name: str, vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual machine is reset to initial state. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Default value is None. :type vm_scale_set_reimage_input: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetReimageParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_reimage( self, resource_group_name: str, vm_scale_set_name: str, vm_scale_set_reimage_input: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual machine is reset to initial state. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Default value is None. :type vm_scale_set_reimage_input: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_reimage( self, resource_group_name: str, vm_scale_set_name: str, vm_scale_set_reimage_input: Optional[Union[_models.VirtualMachineScaleSetReimageParameters, IO[bytes]]] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which don't have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual machine is reset to initial state. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param vm_scale_set_reimage_input: Parameters for Reimaging VM ScaleSet. Is either a VirtualMachineScaleSetReimageParameters type or a IO[bytes] type. Default value is None. :type vm_scale_set_reimage_input: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetReimageParameters or IO[bytes] :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._reimage_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_scale_set_reimage_input=vm_scale_set_reimage_input, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
def _reimage_all_initial( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(vm_instance_i_ds, (IOBase, bytes)): _content = vm_instance_i_ds else: if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, "VirtualMachineScaleSetVMInstanceIDs") else: _json = None _request = build_virtual_machine_scale_sets_reimage_all_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_reimage_all( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This operation is only supported for managed disks. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default value is None. :type vm_instance_i_ds: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMInstanceIDs :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_reimage_all( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This operation is only supported for managed disks. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Default value is None. :type vm_instance_i_ds: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_reimage_all( self, resource_group_name: str, vm_scale_set_name: str, vm_instance_i_ds: Optional[Union[_models.VirtualMachineScaleSetVMInstanceIDs, IO[bytes]]] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This operation is only supported for managed disks. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param vm_instance_i_ds: A list of virtual machine instance IDs from the VM scale set. Is either a VirtualMachineScaleSetVMInstanceIDs type or a IO[bytes] type. Default value is None. :type vm_instance_i_ds: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMInstanceIDs or IO[bytes] :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._reimage_all_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
[docs] @distributed_trace def force_recovery_service_fabric_platform_update_domain_walk( # pylint: disable=name-too-long self, resource_group_name: str, vm_scale_set_name: str, *, platform_update_domain: int, **kwargs: Any ) -> _models.RecoveryWalkResponse: """Manual platform update domain walk to update virtual machines in a service fabric virtual machine scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :keyword platform_update_domain: The platform update domain for which a manual recovery walk is requested. Required. :paramtype platform_update_domain: int :return: RecoveryWalkResponse or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.RecoveryWalkResponse :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.RecoveryWalkResponse] = kwargs.pop("cls", None) _request = build_virtual_machine_scale_sets_force_recovery_service_fabric_platform_update_domain_walk_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, platform_update_domain=platform_update_domain, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RecoveryWalkResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
@overload def convert_to_single_placement_group( self, resource_group_name: str, vm_scale_set_name: str, parameters: _models.VMScaleSetConvertToSinglePlacementGroupInput, *, content_type: str = "application/json", **kwargs: Any ) -> None: """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the virtual machine scale set to create or update. Required. :type vm_scale_set_name: str :param parameters: The input object for ConvertToSinglePlacementGroup API. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.VMScaleSetConvertToSinglePlacementGroupInput :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @overload def convert_to_single_placement_group( self, resource_group_name: str, vm_scale_set_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> None: """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the virtual machine scale set to create or update. Required. :type vm_scale_set_name: str :param parameters: The input object for ConvertToSinglePlacementGroup API. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def convert_to_single_placement_group( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, parameters: Union[_models.VMScaleSetConvertToSinglePlacementGroupInput, IO[bytes]], **kwargs: Any ) -> None: """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the virtual machine scale set to create or update. Required. :type vm_scale_set_name: str :param parameters: The input object for ConvertToSinglePlacementGroup API. Is either a VMScaleSetConvertToSinglePlacementGroupInput type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.VMScaleSetConvertToSinglePlacementGroupInput or IO[bytes] :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "VMScaleSetConvertToSinglePlacementGroupInput") _request = build_virtual_machine_scale_sets_convert_to_single_placement_group_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) # type: ignore
def _set_orchestration_service_state_initial( self, resource_group_name: str, vm_scale_set_name: str, parameters: Union[_models.OrchestrationServiceStateInput, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "OrchestrationServiceStateInput") _request = build_virtual_machine_scale_sets_set_orchestration_service_state_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_set_orchestration_service_state( self, resource_group_name: str, vm_scale_set_name: str, parameters: _models.OrchestrationServiceStateInput, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Changes ServiceState property for a given service. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the virtual machine scale set to create or update. Required. :type vm_scale_set_name: str :param parameters: The input object for SetOrchestrationServiceState API. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.OrchestrationServiceStateInput :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_set_orchestration_service_state( self, resource_group_name: str, vm_scale_set_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Changes ServiceState property for a given service. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the virtual machine scale set to create or update. Required. :type vm_scale_set_name: str :param parameters: The input object for SetOrchestrationServiceState API. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_set_orchestration_service_state( self, resource_group_name: str, vm_scale_set_name: str, parameters: Union[_models.OrchestrationServiceStateInput, IO[bytes]], **kwargs: Any ) -> LROPoller[None]: """Changes ServiceState property for a given service. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the virtual machine scale set to create or update. Required. :type vm_scale_set_name: str :param parameters: The input object for SetOrchestrationServiceState API. Is either a OrchestrationServiceStateInput type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.OrchestrationServiceStateInput or IO[bytes] :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._set_orchestration_service_state_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
[docs] class VirtualMachineSizesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`virtual_machine_sizes` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version")
[docs] @distributed_trace def list(self, location: str, **kwargs: Any) -> Iterable["_models.VirtualMachineSize"]: """This API is deprecated. Use `Resources Skus <https://docs.microsoft.com/rest/api/compute/resourceskus/list>`_. :param location: The location upon which virtual-machine-sizes is queried. Required. :type location: str :return: An iterator like instance of either VirtualMachineSize or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineSize] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineSizeListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_virtual_machine_sizes_list_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("VirtualMachineSizeListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] class ImagesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`images` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") def _create_or_update_initial( self, resource_group_name: str, image_name: str, parameters: Union[_models.Image, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Image") _request = build_images_create_or_update_request( resource_group_name=resource_group_name, image_name=image_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_create_or_update( self, resource_group_name: str, image_name: str, parameters: _models.Image, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param image_name: The name of the image. Required. :type image_name: str :param parameters: Parameters supplied to the Create Image operation. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.Image :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either Image or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_create_or_update( self, resource_group_name: str, image_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param image_name: The name of the image. Required. :type image_name: str :param parameters: Parameters supplied to the Create Image operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either Image or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_create_or_update( self, resource_group_name: str, image_name: str, parameters: Union[_models.Image, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param image_name: The name of the image. Required. :type image_name: str :param parameters: Parameters supplied to the Create Image operation. Is either a Image type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.Image or IO[bytes] :return: An instance of LROPoller that returns either Image or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Image] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, image_name=image_name, parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("Image", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.Image].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.Image]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _update_initial( self, resource_group_name: str, image_name: str, parameters: Union[_models.ImageUpdate, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ImageUpdate") _request = build_images_update_request( resource_group_name=resource_group_name, image_name=image_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_update( self, resource_group_name: str, image_name: str, parameters: _models.ImageUpdate, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param image_name: The name of the image. Required. :type image_name: str :param parameters: Parameters supplied to the Update Image operation. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.ImageUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either Image or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_update( self, resource_group_name: str, image_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param image_name: The name of the image. Required. :type image_name: str :param parameters: Parameters supplied to the Update Image operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either Image or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_update( self, resource_group_name: str, image_name: str, parameters: Union[_models.ImageUpdate, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param image_name: The name of the image. Required. :type image_name: str :param parameters: Parameters supplied to the Update Image operation. Is either a ImageUpdate type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.ImageUpdate or IO[bytes] :return: An instance of LROPoller that returns either Image or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Image] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, image_name=image_name, parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("Image", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.Image].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.Image]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _delete_initial(self, resource_group_name: str, image_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_images_delete_request( resource_group_name=resource_group_name, image_name=image_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_delete(self, resource_group_name: str, image_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes an Image. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param image_name: The name of the image. Required. :type image_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( resource_group_name=resource_group_name, image_name=image_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
[docs] @distributed_trace def get( self, resource_group_name: str, image_name: str, *, expand: Optional[str] = None, **kwargs: Any ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param image_name: The name of the image. Required. :type image_name: str :keyword expand: The expand expression to apply on the operation. Default value is None. :paramtype expand: str :return: Image or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.Image :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.Image] = kwargs.pop("cls", None) _request = build_images_get_request( resource_group_name=resource_group_name, image_name=image_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("Image", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Image"]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :return: An iterator like instance of either Image or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_images_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("ImageListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Image"]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. :return: An iterator like instance of either Image or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.Image] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.ImageListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_images_list_request( subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("ImageListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] class RestorePointCollectionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`restore_point_collections` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload def create_or_update( self, resource_group_name: str, restore_point_collection_name: str, parameters: _models.RestorePointCollection, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RestorePointCollection: """The operation to create or update the restore point collection. Please refer to https://aka.ms/RestorePoints for more details. When updating a restore point collection, only tags may be modified. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param restore_point_collection_name: The name of the restore point collection. Required. :type restore_point_collection_name: str :param parameters: Parameters supplied to the Create or Update restore point collection operation. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollection :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: RestorePointCollection or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollection :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create_or_update( self, resource_group_name: str, restore_point_collection_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.RestorePointCollection: """The operation to create or update the restore point collection. Please refer to https://aka.ms/RestorePoints for more details. When updating a restore point collection, only tags may be modified. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param restore_point_collection_name: The name of the restore point collection. Required. :type restore_point_collection_name: str :param parameters: Parameters supplied to the Create or Update restore point collection operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: RestorePointCollection or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollection :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def create_or_update( self, resource_group_name: str, restore_point_collection_name: str, parameters: Union[_models.RestorePointCollection, IO[bytes]], **kwargs: Any ) -> _models.RestorePointCollection: """The operation to create or update the restore point collection. Please refer to https://aka.ms/RestorePoints for more details. When updating a restore point collection, only tags may be modified. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param restore_point_collection_name: The name of the restore point collection. Required. :type restore_point_collection_name: str :param parameters: Parameters supplied to the Create or Update restore point collection operation. Is either a RestorePointCollection type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollection or IO[bytes] :return: RestorePointCollection or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollection :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RestorePointCollection] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RestorePointCollection") _request = build_restore_point_collections_create_or_update_request( resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RestorePointCollection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
@overload def update( self, resource_group_name: str, restore_point_collection_name: str, parameters: _models.RestorePointCollectionUpdate, *, content_type: str = "application/json", **kwargs: Any ) -> _models.RestorePointCollection: """The operation to update the restore point collection. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param restore_point_collection_name: The name of the restore point collection. Required. :type restore_point_collection_name: str :param parameters: Parameters supplied to the Update restore point collection operation. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollectionUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: RestorePointCollection or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollection :raises ~azure.core.exceptions.HttpResponseError: """ @overload def update( self, resource_group_name: str, restore_point_collection_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.RestorePointCollection: """The operation to update the restore point collection. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param restore_point_collection_name: The name of the restore point collection. Required. :type restore_point_collection_name: str :param parameters: Parameters supplied to the Update restore point collection operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: RestorePointCollection or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollection :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def update( self, resource_group_name: str, restore_point_collection_name: str, parameters: Union[_models.RestorePointCollectionUpdate, IO[bytes]], **kwargs: Any ) -> _models.RestorePointCollection: """The operation to update the restore point collection. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param restore_point_collection_name: The name of the restore point collection. Required. :type restore_point_collection_name: str :param parameters: Parameters supplied to the Update restore point collection operation. Is either a RestorePointCollectionUpdate type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollectionUpdate or IO[bytes] :return: RestorePointCollection or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollection :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RestorePointCollection] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RestorePointCollectionUpdate") _request = build_restore_point_collections_update_request( resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RestorePointCollection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
def _delete_initial( self, resource_group_name: str, restore_point_collection_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_restore_point_collections_delete_request( resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_delete( self, resource_group_name: str, restore_point_collection_name: str, **kwargs: Any ) -> LROPoller[None]: """The operation to delete the restore point collection. This operation will also delete all the contained restore points. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param restore_point_collection_name: The name of the Restore Point Collection. Required. :type restore_point_collection_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
[docs] @distributed_trace def get( self, resource_group_name: str, restore_point_collection_name: str, *, expand: Optional[Union[str, _models.RestorePointCollectionExpandOptions]] = None, **kwargs: Any ) -> _models.RestorePointCollection: """The operation to get the restore point collection. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param restore_point_collection_name: The name of the restore point collection. Required. :type restore_point_collection_name: str :keyword expand: The expand expression to apply on the operation. If expand=restorePoints, server will return all contained restore points in the restorePointCollection. "restorePoints" Default value is None. :paramtype expand: str or ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollectionExpandOptions :return: RestorePointCollection or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollection :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.RestorePointCollection] = kwargs.pop("cls", None) _request = build_restore_point_collections_get_request( resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RestorePointCollection", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.RestorePointCollection"]: """Gets the list of restore point collections in a resource group. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :return: An iterator like instance of either RestorePointCollection or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.RestorePointCollection] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.RestorePointCollectionListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_restore_point_collections_list_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("RestorePointCollectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] @distributed_trace def list_all(self, **kwargs: Any) -> Iterable["_models.RestorePointCollection"]: """Gets the list of restore point collections in the subscription. Use nextLink property in the response to get the next page of restore point collections. Do this till nextLink is not null to fetch all the restore point collections. :return: An iterator like instance of either RestorePointCollection or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.RestorePointCollection] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.RestorePointCollectionListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_restore_point_collections_list_all_request( subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("RestorePointCollectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] class RestorePointsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`restore_points` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") def _create_initial( self, resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, parameters: Union[_models.RestorePoint, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RestorePoint") _request = build_restore_points_create_request( resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, restore_point_name=restore_point_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [201]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_create( self, resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, parameters: _models.RestorePoint, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.RestorePoint]: """The operation to create the restore point. Updating properties of an existing restore point is not allowed. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param restore_point_collection_name: The name of the restore point collection. Required. :type restore_point_collection_name: str :param restore_point_name: The name of the restore point. Required. :type restore_point_name: str :param parameters: Parameters supplied to the Create restore point operation. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.RestorePoint :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either RestorePoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.RestorePoint] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_create( self, resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.RestorePoint]: """The operation to create the restore point. Updating properties of an existing restore point is not allowed. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param restore_point_collection_name: The name of the restore point collection. Required. :type restore_point_collection_name: str :param restore_point_name: The name of the restore point. Required. :type restore_point_name: str :param parameters: Parameters supplied to the Create restore point operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either RestorePoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.RestorePoint] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_create( self, resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, parameters: Union[_models.RestorePoint, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.RestorePoint]: """The operation to create the restore point. Updating properties of an existing restore point is not allowed. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param restore_point_collection_name: The name of the restore point collection. Required. :type restore_point_collection_name: str :param restore_point_name: The name of the restore point. Required. :type restore_point_name: str :param parameters: Parameters supplied to the Create restore point operation. Is either a RestorePoint type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.RestorePoint or IO[bytes] :return: An instance of LROPoller that returns either RestorePoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.RestorePoint] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RestorePoint] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_initial( resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, restore_point_name=restore_point_name, parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("RestorePoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.RestorePoint].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.RestorePoint]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _delete_initial( self, resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_restore_points_delete_request( resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, restore_point_name=restore_point_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_delete( self, resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, **kwargs: Any ) -> LROPoller[None]: """The operation to delete the restore point. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param restore_point_collection_name: The name of the Restore Point Collection. Required. :type restore_point_collection_name: str :param restore_point_name: The name of the restore point. Required. :type restore_point_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, restore_point_name=restore_point_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
[docs] @distributed_trace def get( self, resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, **kwargs: Any ) -> _models.RestorePoint: """The operation to get the restore point. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param restore_point_collection_name: The name of the restore point collection. Required. :type restore_point_collection_name: str :param restore_point_name: The name of the restore point. Required. :type restore_point_name: str :return: RestorePoint or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.RestorePoint :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.RestorePoint] = kwargs.pop("cls", None) _request = build_restore_points_get_request( resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, restore_point_name=restore_point_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RestorePoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] class CapacityReservationGroupsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`capacity_reservation_groups` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload def create_or_update( self, resource_group_name: str, capacity_reservation_group_name: str, parameters: _models.CapacityReservationGroup, *, content_type: str = "application/json", **kwargs: Any ) -> _models.CapacityReservationGroup: """The operation to create or update a capacity reservation group. When updating a capacity reservation group, only tags may be modified. Please refer to https://aka.ms/CapacityReservation for more details. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param capacity_reservation_group_name: The name of the capacity reservation group. Required. :type capacity_reservation_group_name: str :param parameters: Parameters supplied to the Create capacity reservation Group. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationGroup :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: CapacityReservationGroup or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationGroup :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create_or_update( self, resource_group_name: str, capacity_reservation_group_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CapacityReservationGroup: """The operation to create or update a capacity reservation group. When updating a capacity reservation group, only tags may be modified. Please refer to https://aka.ms/CapacityReservation for more details. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param capacity_reservation_group_name: The name of the capacity reservation group. Required. :type capacity_reservation_group_name: str :param parameters: Parameters supplied to the Create capacity reservation Group. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: CapacityReservationGroup or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationGroup :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def create_or_update( self, resource_group_name: str, capacity_reservation_group_name: str, parameters: Union[_models.CapacityReservationGroup, IO[bytes]], **kwargs: Any ) -> _models.CapacityReservationGroup: """The operation to create or update a capacity reservation group. When updating a capacity reservation group, only tags may be modified. Please refer to https://aka.ms/CapacityReservation for more details. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param capacity_reservation_group_name: The name of the capacity reservation group. Required. :type capacity_reservation_group_name: str :param parameters: Parameters supplied to the Create capacity reservation Group. Is either a CapacityReservationGroup type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationGroup or IO[bytes] :return: CapacityReservationGroup or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationGroup :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CapacityReservationGroup] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CapacityReservationGroup") _request = build_capacity_reservation_groups_create_or_update_request( resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("CapacityReservationGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
@overload def update( self, resource_group_name: str, capacity_reservation_group_name: str, parameters: _models.CapacityReservationGroupUpdate, *, content_type: str = "application/json", **kwargs: Any ) -> _models.CapacityReservationGroup: """The operation to update a capacity reservation group. When updating a capacity reservation group, only tags may be modified. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param capacity_reservation_group_name: The name of the capacity reservation group. Required. :type capacity_reservation_group_name: str :param parameters: Parameters supplied to the Update capacity reservation Group operation. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationGroupUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: CapacityReservationGroup or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationGroup :raises ~azure.core.exceptions.HttpResponseError: """ @overload def update( self, resource_group_name: str, capacity_reservation_group_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CapacityReservationGroup: """The operation to update a capacity reservation group. When updating a capacity reservation group, only tags may be modified. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param capacity_reservation_group_name: The name of the capacity reservation group. Required. :type capacity_reservation_group_name: str :param parameters: Parameters supplied to the Update capacity reservation Group operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: CapacityReservationGroup or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationGroup :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def update( self, resource_group_name: str, capacity_reservation_group_name: str, parameters: Union[_models.CapacityReservationGroupUpdate, IO[bytes]], **kwargs: Any ) -> _models.CapacityReservationGroup: """The operation to update a capacity reservation group. When updating a capacity reservation group, only tags may be modified. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param capacity_reservation_group_name: The name of the capacity reservation group. Required. :type capacity_reservation_group_name: str :param parameters: Parameters supplied to the Update capacity reservation Group operation. Is either a CapacityReservationGroupUpdate type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationGroupUpdate or IO[bytes] :return: CapacityReservationGroup or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationGroup :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CapacityReservationGroup] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CapacityReservationGroupUpdate") _request = build_capacity_reservation_groups_update_request( resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("CapacityReservationGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, capacity_reservation_group_name: str, **kwargs: Any ) -> None: """The operation to delete a capacity reservation group. This operation is allowed only if all the associated resources are disassociated from the reservation group and all capacity reservations under the reservation group have also been deleted. Please refer to https://aka.ms/CapacityReservation for more details. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param capacity_reservation_group_name: The name of the capacity reservation group. Required. :type capacity_reservation_group_name: str :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) _request = build_capacity_reservation_groups_delete_request( resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) # type: ignore
[docs] @distributed_trace def get( self, resource_group_name: str, capacity_reservation_group_name: str, *, expand: Optional[Union[str, _models.CapacityReservationGroupInstanceViewTypes]] = None, **kwargs: Any ) -> _models.CapacityReservationGroup: """The operation that retrieves information about a capacity reservation group. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param capacity_reservation_group_name: The name of the capacity reservation group. Required. :type capacity_reservation_group_name: str :keyword expand: The expand expression to apply on the operation. 'InstanceView' will retrieve the list of instance views of the capacity reservations under the capacity reservation group which is a snapshot of the runtime properties of a capacity reservation that is managed by the platform and can change outside of control plane operations. "instanceView" Default value is None. :paramtype expand: str or ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationGroupInstanceViewTypes :return: CapacityReservationGroup or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationGroup :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.CapacityReservationGroup] = kwargs.pop("cls", None) _request = build_capacity_reservation_groups_get_request( resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("CapacityReservationGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def list_by_resource_group( self, resource_group_name: str, *, expand: Optional[Union[str, _models.ExpandTypesForGetCapacityReservationGroups]] = None, **kwargs: Any ) -> Iterable["_models.CapacityReservationGroup"]: """Lists all of the capacity reservation groups in the specified resource group. Use the nextLink property in the response to get the next page of capacity reservation groups. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :keyword expand: The expand expression to apply on the operation. Based on the expand param(s) specified we return Virtual Machine or ScaleSet VM Instance or both resource Ids which are associated to capacity reservation group in the response. Known values are: "virtualMachineScaleSetVMs/$ref" and "virtualMachines/$ref". Default value is None. :paramtype expand: str or ~azure.mgmt.compute.v2021_07_01.models.ExpandTypesForGetCapacityReservationGroups :return: An iterator like instance of either CapacityReservationGroup or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.CapacityReservationGroup] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.CapacityReservationGroupListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_capacity_reservation_groups_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("CapacityReservationGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] @distributed_trace def list_by_subscription( self, *, expand: Optional[Union[str, _models.ExpandTypesForGetCapacityReservationGroups]] = None, **kwargs: Any ) -> Iterable["_models.CapacityReservationGroup"]: """Lists all of the capacity reservation groups in the subscription. Use the nextLink property in the response to get the next page of capacity reservation groups. :keyword expand: The expand expression to apply on the operation. Based on the expand param(s) specified we return Virtual Machine or ScaleSet VM Instance or both resource Ids which are associated to capacity reservation group in the response. Known values are: "virtualMachineScaleSetVMs/$ref" and "virtualMachines/$ref". Default value is None. :paramtype expand: str or ~azure.mgmt.compute.v2021_07_01.models.ExpandTypesForGetCapacityReservationGroups :return: An iterator like instance of either CapacityReservationGroup or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.CapacityReservationGroup] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.CapacityReservationGroupListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_capacity_reservation_groups_list_by_subscription_request( subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("CapacityReservationGroupListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] class CapacityReservationsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`capacity_reservations` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") def _create_or_update_initial( self, resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, parameters: Union[_models.CapacityReservation, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CapacityReservation") _request = build_capacity_reservations_create_or_update_request( resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_create_or_update( self, resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, parameters: _models.CapacityReservation, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.CapacityReservation]: """The operation to create or update a capacity reservation. Please note some properties can be set only during capacity reservation creation. Please refer to https://aka.ms/CapacityReservation for more details. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param capacity_reservation_group_name: The name of the capacity reservation group. Required. :type capacity_reservation_group_name: str :param capacity_reservation_name: The name of the capacity reservation. Required. :type capacity_reservation_name: str :param parameters: Parameters supplied to the Create capacity reservation. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.CapacityReservation :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either CapacityReservation or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.CapacityReservation] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_create_or_update( self, resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.CapacityReservation]: """The operation to create or update a capacity reservation. Please note some properties can be set only during capacity reservation creation. Please refer to https://aka.ms/CapacityReservation for more details. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param capacity_reservation_group_name: The name of the capacity reservation group. Required. :type capacity_reservation_group_name: str :param capacity_reservation_name: The name of the capacity reservation. Required. :type capacity_reservation_name: str :param parameters: Parameters supplied to the Create capacity reservation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either CapacityReservation or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.CapacityReservation] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_create_or_update( self, resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, parameters: Union[_models.CapacityReservation, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.CapacityReservation]: """The operation to create or update a capacity reservation. Please note some properties can be set only during capacity reservation creation. Please refer to https://aka.ms/CapacityReservation for more details. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param capacity_reservation_group_name: The name of the capacity reservation group. Required. :type capacity_reservation_group_name: str :param capacity_reservation_name: The name of the capacity reservation. Required. :type capacity_reservation_name: str :param parameters: Parameters supplied to the Create capacity reservation. Is either a CapacityReservation type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.CapacityReservation or IO[bytes] :return: An instance of LROPoller that returns either CapacityReservation or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.CapacityReservation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CapacityReservation] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("CapacityReservation", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.CapacityReservation].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.CapacityReservation]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _update_initial( self, resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, parameters: Union[_models.CapacityReservationUpdate, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CapacityReservationUpdate") _request = build_capacity_reservations_update_request( resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_update( self, resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, parameters: _models.CapacityReservationUpdate, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.CapacityReservation]: """The operation to update a capacity reservation. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param capacity_reservation_group_name: The name of the capacity reservation group. Required. :type capacity_reservation_group_name: str :param capacity_reservation_name: The name of the capacity reservation. Required. :type capacity_reservation_name: str :param parameters: Parameters supplied to the Update capacity reservation operation. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either CapacityReservation or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.CapacityReservation] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_update( self, resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.CapacityReservation]: """The operation to update a capacity reservation. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param capacity_reservation_group_name: The name of the capacity reservation group. Required. :type capacity_reservation_group_name: str :param capacity_reservation_name: The name of the capacity reservation. Required. :type capacity_reservation_name: str :param parameters: Parameters supplied to the Update capacity reservation operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either CapacityReservation or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.CapacityReservation] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_update( self, resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, parameters: Union[_models.CapacityReservationUpdate, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.CapacityReservation]: """The operation to update a capacity reservation. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param capacity_reservation_group_name: The name of the capacity reservation group. Required. :type capacity_reservation_group_name: str :param capacity_reservation_name: The name of the capacity reservation. Required. :type capacity_reservation_name: str :param parameters: Parameters supplied to the Update capacity reservation operation. Is either a CapacityReservationUpdate type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationUpdate or IO[bytes] :return: An instance of LROPoller that returns either CapacityReservation or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.CapacityReservation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CapacityReservation] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("CapacityReservation", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.CapacityReservation].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.CapacityReservation]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _delete_initial( self, resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_capacity_reservations_delete_request( resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_delete( self, resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, **kwargs: Any ) -> LROPoller[None]: """The operation to delete a capacity reservation. This operation is allowed only when all the associated resources are disassociated from the capacity reservation. Please refer to https://aka.ms/CapacityReservation for more details. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param capacity_reservation_group_name: The name of the capacity reservation group. Required. :type capacity_reservation_group_name: str :param capacity_reservation_name: The name of the capacity reservation. Required. :type capacity_reservation_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
[docs] @distributed_trace def get( self, resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, *, expand: Optional[Union[str, _models.CapacityReservationInstanceViewTypes]] = None, **kwargs: Any ) -> _models.CapacityReservation: """The operation that retrieves information about the capacity reservation. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param capacity_reservation_group_name: The name of the capacity reservation group. Required. :type capacity_reservation_group_name: str :param capacity_reservation_name: The name of the capacity reservation. Required. :type capacity_reservation_name: str :keyword expand: The expand expression to apply on the operation. 'InstanceView' retrieves a snapshot of the runtime properties of the capacity reservation that is managed by the platform and can change outside of control plane operations. "instanceView" Default value is None. :paramtype expand: str or ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationInstanceViewTypes :return: CapacityReservation or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.CapacityReservation :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.CapacityReservation] = kwargs.pop("cls", None) _request = build_capacity_reservations_get_request( resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("CapacityReservation", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def list_by_capacity_reservation_group( self, resource_group_name: str, capacity_reservation_group_name: str, **kwargs: Any ) -> Iterable["_models.CapacityReservation"]: """Lists all of the capacity reservations in the specified capacity reservation group. Use the nextLink property in the response to get the next page of capacity reservations. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param capacity_reservation_group_name: The name of the capacity reservation group. Required. :type capacity_reservation_group_name: str :return: An iterator like instance of either CapacityReservation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.CapacityReservation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.CapacityReservationListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_capacity_reservations_list_by_capacity_reservation_group_request( resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("CapacityReservationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] class VirtualMachineScaleSetExtensionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, extension_parameters: Union[_models.VirtualMachineScaleSetExtension, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(extension_parameters, (IOBase, bytes)): _content = extension_parameters else: _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetExtension") _request = build_virtual_machine_scale_set_extensions_create_or_update_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, extension_parameters: _models.VirtualMachineScaleSetExtension, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set where the extension should be create or updated. Required. :type vm_scale_set_name: str :param vmss_extension_name: The name of the VM scale set extension. Required. :type vmss_extension_name: str :param extension_parameters: Parameters supplied to the Create VM scale set Extension operation. Required. :type extension_parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtension :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, extension_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set where the extension should be create or updated. Required. :type vm_scale_set_name: str :param vmss_extension_name: The name of the VM scale set extension. Required. :type vmss_extension_name: str :param extension_parameters: Parameters supplied to the Create VM scale set Extension operation. Required. :type extension_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtension] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, extension_parameters: Union[_models.VirtualMachineScaleSetExtension, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set where the extension should be create or updated. Required. :type vm_scale_set_name: str :param vmss_extension_name: The name of the VM scale set extension. Required. :type vmss_extension_name: str :param extension_parameters: Parameters supplied to the Create VM scale set Extension operation. Is either a VirtualMachineScaleSetExtension type or a IO[bytes] type. Required. :type extension_parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtension or IO[bytes] :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtension] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, extension_parameters=extension_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.VirtualMachineScaleSetExtension].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.VirtualMachineScaleSetExtension]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, extension_parameters: Union[_models.VirtualMachineScaleSetExtensionUpdate, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(extension_parameters, (IOBase, bytes)): _content = extension_parameters else: _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetExtensionUpdate") _request = build_virtual_machine_scale_set_extensions_update_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_update( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to update an extension. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set where the extension should be updated. Required. :type vm_scale_set_name: str :param vmss_extension_name: The name of the VM scale set extension. Required. :type vmss_extension_name: str :param extension_parameters: Parameters supplied to the Update VM scale set Extension operation. Required. :type extension_parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtensionUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_update( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, extension_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to update an extension. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set where the extension should be updated. Required. :type vm_scale_set_name: str :param vmss_extension_name: The name of the VM scale set extension. Required. :type vmss_extension_name: str :param extension_parameters: Parameters supplied to the Update VM scale set Extension operation. Required. :type extension_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtension] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_update( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, extension_parameters: Union[_models.VirtualMachineScaleSetExtensionUpdate, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to update an extension. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set where the extension should be updated. Required. :type vm_scale_set_name: str :param vmss_extension_name: The name of the VM scale set extension. Required. :type vmss_extension_name: str :param extension_parameters: Parameters supplied to the Update VM scale set Extension operation. Is either a VirtualMachineScaleSetExtensionUpdate type or a IO[bytes] type. Required. :type extension_parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtensionUpdate or IO[bytes] :return: An instance of LROPoller that returns either VirtualMachineScaleSetExtension or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtension] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, extension_parameters=extension_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.VirtualMachineScaleSetExtension].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.VirtualMachineScaleSetExtension]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _delete_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_virtual_machine_scale_set_extensions_delete_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_delete( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any ) -> LROPoller[None]: """The operation to delete the extension. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set where the extension should be deleted. Required. :type vm_scale_set_name: str :param vmss_extension_name: The name of the VM scale set extension. Required. :type vmss_extension_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
[docs] @distributed_trace def get( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, *, expand: Optional[str] = None, **kwargs: Any ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set containing the extension. Required. :type vm_scale_set_name: str :param vmss_extension_name: The name of the VM scale set extension. Required. :type vmss_extension_name: str :keyword expand: The expand expression to apply on the operation. Default value is None. :paramtype expand: str :return: VirtualMachineScaleSetExtension or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtension :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineScaleSetExtension] = kwargs.pop("cls", None) _request = build_virtual_machine_scale_set_extensions_get_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("VirtualMachineScaleSetExtension", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def list( self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any ) -> Iterable["_models.VirtualMachineScaleSetExtension"]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set containing the extension. Required. :type vm_scale_set_name: str :return: An iterator like instance of either VirtualMachineScaleSetExtension or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtension] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineScaleSetExtensionListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_virtual_machine_scale_set_extensions_list_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("VirtualMachineScaleSetExtensionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] class VirtualMachineScaleSetRollingUpgradesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") def _cancel_initial(self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_virtual_machine_scale_set_rolling_upgrades_cancel_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_cancel(self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any) -> LROPoller[None]: """Cancels the current virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._cancel_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
def _start_os_upgrade_initial( self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_virtual_machine_scale_set_rolling_upgrades_start_os_upgrade_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_start_os_upgrade( self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any ) -> LROPoller[None]: """Starts a rolling upgrade to move all virtual machine scale set instances to the latest available Platform Image OS version. Instances which are already running the latest available OS version are not affected. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._start_os_upgrade_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
def _start_extension_upgrade_initial( self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_virtual_machine_scale_set_rolling_upgrades_start_extension_upgrade_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_start_extension_upgrade( self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any ) -> LROPoller[None]: """Starts a rolling upgrade to move all extensions for all virtual machine scale set instances to the latest available extension version. Instances which are already running the latest extension versions are not affected. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._start_extension_upgrade_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
[docs] @distributed_trace def get_latest( self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :return: RollingUpgradeStatusInfo or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.RollingUpgradeStatusInfo :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.RollingUpgradeStatusInfo] = kwargs.pop("cls", None) _request = build_virtual_machine_scale_set_rolling_upgrades_get_latest_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RollingUpgradeStatusInfo", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] class VirtualMachineScaleSetVMExtensionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`virtual_machine_scale_set_vm_extensions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, vm_extension_name: str, extension_parameters: Union[_models.VirtualMachineScaleSetVMExtension, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(extension_parameters, (IOBase, bytes)): _content = extension_parameters else: _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetVMExtension") _request = build_virtual_machine_scale_set_vm_extensions_create_or_update_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, vm_extension_name=vm_extension_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, vm_extension_name: str, extension_parameters: _models.VirtualMachineScaleSetVMExtension, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to create or update the VMSS VM extension. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :param vm_extension_name: The name of the virtual machine extension. Required. :type vm_extension_name: str :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension operation. Required. :type extension_parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMExtension :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineScaleSetVMExtension or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, vm_extension_name: str, extension_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to create or update the VMSS VM extension. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :param vm_extension_name: The name of the virtual machine extension. Required. :type vm_extension_name: str :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension operation. Required. :type extension_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineScaleSetVMExtension or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMExtension] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, vm_extension_name: str, extension_parameters: Union[_models.VirtualMachineScaleSetVMExtension, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to create or update the VMSS VM extension. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :param vm_extension_name: The name of the virtual machine extension. Required. :type vm_extension_name: str :param extension_parameters: Parameters supplied to the Create Virtual Machine Extension operation. Is either a VirtualMachineScaleSetVMExtension type or a IO[bytes] type. Required. :type extension_parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMExtension or IO[bytes] :return: An instance of LROPoller that returns either VirtualMachineScaleSetVMExtension or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMExtension] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.VirtualMachineScaleSetVMExtension] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, vm_extension_name=vm_extension_name, extension_parameters=extension_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("VirtualMachineScaleSetVMExtension", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.VirtualMachineScaleSetVMExtension].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.VirtualMachineScaleSetVMExtension]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, vm_extension_name: str, extension_parameters: Union[_models.VirtualMachineScaleSetVMExtensionUpdate, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(extension_parameters, (IOBase, bytes)): _content = extension_parameters else: _json = self._serialize.body(extension_parameters, "VirtualMachineScaleSetVMExtensionUpdate") _request = build_virtual_machine_scale_set_vm_extensions_update_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, vm_extension_name=vm_extension_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_update( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, vm_extension_name: str, extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to update the VMSS VM extension. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :param vm_extension_name: The name of the virtual machine extension. Required. :type vm_extension_name: str :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension operation. Required. :type extension_parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMExtensionUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineScaleSetVMExtension or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMExtension] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_update( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, vm_extension_name: str, extension_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to update the VMSS VM extension. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :param vm_extension_name: The name of the virtual machine extension. Required. :type vm_extension_name: str :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension operation. Required. :type extension_parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineScaleSetVMExtension or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMExtension] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_update( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, vm_extension_name: str, extension_parameters: Union[_models.VirtualMachineScaleSetVMExtensionUpdate, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to update the VMSS VM extension. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :param vm_extension_name: The name of the virtual machine extension. Required. :type vm_extension_name: str :param extension_parameters: Parameters supplied to the Update Virtual Machine Extension operation. Is either a VirtualMachineScaleSetVMExtensionUpdate type or a IO[bytes] type. Required. :type extension_parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMExtensionUpdate or IO[bytes] :return: An instance of LROPoller that returns either VirtualMachineScaleSetVMExtension or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMExtension] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.VirtualMachineScaleSetVMExtension] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, vm_extension_name=vm_extension_name, extension_parameters=extension_parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("VirtualMachineScaleSetVMExtension", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.VirtualMachineScaleSetVMExtension].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.VirtualMachineScaleSetVMExtension]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _delete_initial( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, vm_extension_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_virtual_machine_scale_set_vm_extensions_delete_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, vm_extension_name=vm_extension_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_delete( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, vm_extension_name: str, **kwargs: Any ) -> LROPoller[None]: """The operation to delete the VMSS VM extension. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :param vm_extension_name: The name of the virtual machine extension. Required. :type vm_extension_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
[docs] @distributed_trace def get( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, vm_extension_name: str, *, expand: Optional[str] = None, **kwargs: Any ) -> _models.VirtualMachineScaleSetVMExtension: """The operation to get the VMSS VM extension. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :param vm_extension_name: The name of the virtual machine extension. Required. :type vm_extension_name: str :keyword expand: The expand expression to apply on the operation. Default value is None. :paramtype expand: str :return: VirtualMachineScaleSetVMExtension or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMExtension :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineScaleSetVMExtension] = kwargs.pop("cls", None) _request = build_virtual_machine_scale_set_vm_extensions_get_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, vm_extension_name=vm_extension_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("VirtualMachineScaleSetVMExtension", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def list( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, *, expand: Optional[str] = None, **kwargs: Any ) -> _models.VirtualMachineScaleSetVMExtensionsListResult: """The operation to get all extensions of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :keyword expand: The expand expression to apply on the operation. Default value is None. :paramtype expand: str :return: VirtualMachineScaleSetVMExtensionsListResult or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMExtensionsListResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineScaleSetVMExtensionsListResult] = kwargs.pop("cls", None) _request = build_virtual_machine_scale_set_vm_extensions_list_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize( "VirtualMachineScaleSetVMExtensionsListResult", pipeline_response.http_response ) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] class VirtualMachineScaleSetVMsOperations: # pylint: disable=too-many-public-methods """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") def _reimage_initial( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, vm_scale_set_vm_reimage_input: Optional[ Union[_models.VirtualMachineScaleSetVMReimageParameters, IO[bytes]] ] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(vm_scale_set_vm_reimage_input, (IOBase, bytes)): _content = vm_scale_set_vm_reimage_input else: if vm_scale_set_vm_reimage_input is not None: _json = self._serialize.body(vm_scale_set_vm_reimage_input, "VirtualMachineScaleSetVMReimageParameters") else: _json = None _request = build_virtual_machine_scale_set_vms_reimage_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_reimage( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. Default value is None. :type vm_scale_set_vm_reimage_input: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMReimageParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_reimage( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, vm_scale_set_vm_reimage_input: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. Default value is None. :type vm_scale_set_vm_reimage_input: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_reimage( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, vm_scale_set_vm_reimage_input: Optional[ Union[_models.VirtualMachineScaleSetVMReimageParameters, IO[bytes]] ] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :param vm_scale_set_vm_reimage_input: Parameters for the Reimaging Virtual machine in ScaleSet. Is either a VirtualMachineScaleSetVMReimageParameters type or a IO[bytes] type. Default value is None. :type vm_scale_set_vm_reimage_input: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMReimageParameters or IO[bytes] :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._reimage_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, vm_scale_set_vm_reimage_input=vm_scale_set_vm_reimage_input, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
def _reimage_all_initial( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_virtual_machine_scale_set_vms_reimage_all_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_reimage_all( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any ) -> LROPoller[None]: """Allows you to re-image all the disks ( including data disks ) in the a VM scale set instance. This operation is only supported for managed disks. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._reimage_all_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
def _deallocate_initial( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_virtual_machine_scale_set_vms_deallocate_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_deallocate( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any ) -> LROPoller[None]: """Deallocates a specific virtual machine in a VM scale set. Shuts down the virtual machine and releases the compute resources it uses. You are not billed for the compute resources of this virtual machine once it is deallocated. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._deallocate_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, parameters: Union[_models.VirtualMachineScaleSetVM, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "VirtualMachineScaleSetVM") _request = build_virtual_machine_scale_set_vms_update_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_update( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, parameters: _models.VirtualMachineScaleSetVM, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set where the extension should be create or updated. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :param parameters: Parameters supplied to the Update Virtual Machine Scale Sets VM operation. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVM :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineScaleSetVM or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVM] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_update( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set where the extension should be create or updated. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :param parameters: Parameters supplied to the Update Virtual Machine Scale Sets VM operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineScaleSetVM or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVM] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_update( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, parameters: Union[_models.VirtualMachineScaleSetVM, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set where the extension should be create or updated. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :param parameters: Parameters supplied to the Update Virtual Machine Scale Sets VM operation. Is either a VirtualMachineScaleSetVM type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVM or IO[bytes] :return: An instance of LROPoller that returns either VirtualMachineScaleSetVM or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVM] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.VirtualMachineScaleSetVM] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("VirtualMachineScaleSetVM", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.VirtualMachineScaleSetVM].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.VirtualMachineScaleSetVM]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _delete_initial( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, *, force_deletion: Optional[bool] = None, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_virtual_machine_scale_set_vms_delete_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, subscription_id=self._config.subscription_id, force_deletion=force_deletion, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_delete( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, *, force_deletion: Optional[bool] = None, **kwargs: Any ) -> LROPoller[None]: """Deletes a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :keyword force_deletion: Optional parameter to force delete a virtual machine from a VM scale set. (Feature in Preview). Default value is None. :paramtype force_deletion: bool :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, force_deletion=force_deletion, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
[docs] @distributed_trace def get( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, *, expand: Optional[Union[str, _models.InstanceViewTypes]] = None, **kwargs: Any ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :keyword expand: The expand expression to apply on the operation. 'InstanceView' will retrieve the instance view of the virtual machine. 'UserData' will retrieve the UserData of the virtual machine. Known values are: "instanceView" and "userData". Default value is None. :paramtype expand: str or ~azure.mgmt.compute.v2021_07_01.models.InstanceViewTypes :return: VirtualMachineScaleSetVM or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVM :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineScaleSetVM] = kwargs.pop("cls", None) _request = build_virtual_machine_scale_set_vms_get_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("VirtualMachineScaleSetVM", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def get_instance_view( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :return: VirtualMachineScaleSetVMInstanceView or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMInstanceView :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineScaleSetVMInstanceView] = kwargs.pop("cls", None) _request = build_virtual_machine_scale_set_vms_get_instance_view_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("VirtualMachineScaleSetVMInstanceView", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def list( self, resource_group_name: str, virtual_machine_scale_set_name: str, *, filter: Optional[str] = None, select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.VirtualMachineScaleSetVM"]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param virtual_machine_scale_set_name: The name of the VM scale set. Required. :type virtual_machine_scale_set_name: str :keyword filter: The filter to apply to the operation. Allowed values are 'startswith(instanceView/statuses/code, 'PowerState') eq true', 'properties/latestModelApplied eq true', 'properties/latestModelApplied eq false'. Default value is None. :paramtype filter: str :keyword select: The list parameters. Allowed values are 'instanceView', 'instanceView/statuses'. Default value is None. :paramtype select: str :keyword expand: The expand expression to apply to the operation. Allowed values are 'instanceView'. Default value is None. :paramtype expand: str :return: An iterator like instance of either VirtualMachineScaleSetVM or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVM] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineScaleSetVMListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_virtual_machine_scale_set_vms_list_request( resource_group_name=resource_group_name, virtual_machine_scale_set_name=virtual_machine_scale_set_name, subscription_id=self._config.subscription_id, filter=filter, select=select, expand=expand, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("VirtualMachineScaleSetVMListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
def _power_off_initial( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, *, skip_shutdown: bool = False, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_virtual_machine_scale_set_vms_power_off_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, subscription_id=self._config.subscription_id, skip_shutdown=skip_shutdown, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_power_off( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, *, skip_shutdown: bool = False, **kwargs: Any ) -> LROPoller[None]: """Power off (stop) a virtual machine in a VM scale set. Note that resources are still attached and you are getting charged for the resources. Instead, use deallocate to release resources and avoid charges. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :keyword skip_shutdown: The parameter to request non-graceful VM shutdown. True value for this flag indicates non-graceful shutdown whereas false indicates otherwise. Default value for this flag is false if not specified. Default value is False. :paramtype skip_shutdown: bool :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._power_off_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
def _restart_initial( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_virtual_machine_scale_set_vms_restart_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_restart( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any ) -> LROPoller[None]: """Restarts a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._restart_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
def _start_initial( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_virtual_machine_scale_set_vms_start_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_start( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any ) -> LROPoller[None]: """Starts a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._start_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
def _redeploy_initial( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_virtual_machine_scale_set_vms_redeploy_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_redeploy( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any ) -> LROPoller[None]: """Shuts down the virtual machine in the virtual machine scale set, moves it to a new node, and powers it back on. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._redeploy_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
[docs] @distributed_trace def retrieve_boot_diagnostics_data( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, *, sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any ) -> _models.RetrieveBootDiagnosticsDataResult: """The operation to retrieve SAS URIs of boot diagnostic logs for a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :keyword sas_uri_expiration_time_in_minutes: Expiration duration in minutes for the SAS URIs with a value between 1 to 1440 minutes. :code:`<br>`\\ :code:`<br>`NOTE: If not specified, SAS URIs will be generated with a default expiration duration of 120 minutes. Default value is None. :paramtype sas_uri_expiration_time_in_minutes: int :return: RetrieveBootDiagnosticsDataResult or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.RetrieveBootDiagnosticsDataResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.RetrieveBootDiagnosticsDataResult] = kwargs.pop("cls", None) _request = build_virtual_machine_scale_set_vms_retrieve_boot_diagnostics_data_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, subscription_id=self._config.subscription_id, sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RetrieveBootDiagnosticsDataResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
def _perform_maintenance_initial( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_virtual_machine_scale_set_vms_perform_maintenance_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_perform_maintenance( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any ) -> LROPoller[None]: """Performs maintenance on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._perform_maintenance_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
[docs] @distributed_trace def simulate_eviction( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, **kwargs: Any ) -> None: """The operation to simulate the eviction of spot virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :return: None or the result of cls(response) :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) _request = build_virtual_machine_scale_set_vms_simulate_eviction_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) # type: ignore
def _run_command_initial( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, parameters: Union[_models.RunCommandInput, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RunCommandInput") _request = build_virtual_machine_scale_set_vms_run_command_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_run_command( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, parameters: _models.RunCommandInput, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.RunCommandResult]: """Run command on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :param parameters: Parameters supplied to the Run command operation. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.RunCommandInput :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either RunCommandResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.RunCommandResult] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_run_command( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.RunCommandResult]: """Run command on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :param parameters: Parameters supplied to the Run command operation. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Known values are: 'application/json', 'text/json'. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either RunCommandResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.RunCommandResult] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_run_command( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, parameters: Union[_models.RunCommandInput, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.RunCommandResult]: """Run command on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :param parameters: Parameters supplied to the Run command operation. Is either a RunCommandInput type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.RunCommandInput or IO[bytes] :return: An instance of LROPoller that returns either RunCommandResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.RunCommandResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RunCommandResult] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._run_command_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("RunCommandResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast( PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.RunCommandResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.RunCommandResult]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
[docs] class LogAnalyticsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`log_analytics` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") def _export_request_rate_by_interval_initial( self, location: str, parameters: Union[_models.RequestRateByIntervalInput, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "RequestRateByIntervalInput") _request = build_log_analytics_export_request_rate_by_interval_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_export_request_rate_by_interval( self, location: str, parameters: _models.RequestRateByIntervalInput, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. :param location: The location upon which virtual-machine-sizes is queried. Required. :type location: str :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.RequestRateByIntervalInput :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.LogAnalyticsOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_export_request_rate_by_interval( self, location: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. :param location: The location upon which virtual-machine-sizes is queried. Required. :type location: str :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.LogAnalyticsOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_export_request_rate_by_interval( self, location: str, parameters: Union[_models.RequestRateByIntervalInput, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. :param location: The location upon which virtual-machine-sizes is queried. Required. :type location: str :param parameters: Parameters supplied to the LogAnalytics getRequestRateByInterval Api. Is either a RequestRateByIntervalInput type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.RequestRateByIntervalInput or IO[bytes] :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.LogAnalyticsOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.LogAnalyticsOperationResult] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._export_request_rate_by_interval_initial( location=location, parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("LogAnalyticsOperationResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast( PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.LogAnalyticsOperationResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.LogAnalyticsOperationResult]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _export_throttled_requests_initial( self, location: str, parameters: Union[_models.ThrottledRequestsInput, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "ThrottledRequestsInput") _request = build_log_analytics_export_throttled_requests_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_export_throttled_requests( self, location: str, parameters: _models.ThrottledRequestsInput, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. :param location: The location upon which virtual-machine-sizes is queried. Required. :type location: str :param parameters: Parameters supplied to the LogAnalytics getThrottledRequests Api. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.ThrottledRequestsInput :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.LogAnalyticsOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_export_throttled_requests( self, location: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. :param location: The location upon which virtual-machine-sizes is queried. Required. :type location: str :param parameters: Parameters supplied to the LogAnalytics getThrottledRequests Api. Required. :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.LogAnalyticsOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_export_throttled_requests( self, location: str, parameters: Union[_models.ThrottledRequestsInput, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. :param location: The location upon which virtual-machine-sizes is queried. Required. :type location: str :param parameters: Parameters supplied to the LogAnalytics getThrottledRequests Api. Is either a ThrottledRequestsInput type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.ThrottledRequestsInput or IO[bytes] :return: An instance of LROPoller that returns either LogAnalyticsOperationResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.LogAnalyticsOperationResult] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.LogAnalyticsOperationResult] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._export_throttled_requests_initial( location=location, parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("LogAnalyticsOperationResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast( PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.LogAnalyticsOperationResult].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.LogAnalyticsOperationResult]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
[docs] class VirtualMachineRunCommandsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`virtual_machine_run_commands` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version")
[docs] @distributed_trace def list(self, location: str, **kwargs: Any) -> Iterable["_models.RunCommandDocumentBase"]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. Required. :type location: str :return: An iterator like instance of either RunCommandDocumentBase or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.RunCommandDocumentBase] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.RunCommandListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_virtual_machine_run_commands_list_request( location=location, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("RunCommandListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] @distributed_trace def get(self, location: str, command_id: str, **kwargs: Any) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. Required. :type location: str :param command_id: The command id. Required. :type command_id: str :return: RunCommandDocument or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.RunCommandDocument :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.RunCommandDocument] = kwargs.pop("cls", None) _request = build_virtual_machine_run_commands_get_request( location=location, command_id=command_id, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("RunCommandDocument", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
def _create_or_update_initial( self, resource_group_name: str, vm_name: str, run_command_name: str, run_command: Union[_models.VirtualMachineRunCommand, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(run_command, (IOBase, bytes)): _content = run_command else: _json = self._serialize.body(run_command, "VirtualMachineRunCommand") _request = build_virtual_machine_run_commands_create_or_update_request( resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_create_or_update( self, resource_group_name: str, vm_name: str, run_command_name: str, run_command: _models.VirtualMachineRunCommand, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the run command. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine where the run command should be created or updated. Required. :type vm_name: str :param run_command_name: The name of the virtual machine run command. Required. :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. Required. :type run_command: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_create_or_update( self, resource_group_name: str, vm_name: str, run_command_name: str, run_command: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the run command. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine where the run command should be created or updated. Required. :type vm_name: str :param run_command_name: The name of the virtual machine run command. Required. :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. Required. :type run_command: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Known values are: 'application/json', 'text/json'. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_create_or_update( self, resource_group_name: str, vm_name: str, run_command_name: str, run_command: Union[_models.VirtualMachineRunCommand, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the run command. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine where the run command should be created or updated. Required. :type vm_name: str :param run_command_name: The name of the virtual machine run command. Required. :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. Is either a VirtualMachineRunCommand type or a IO[bytes] type. Required. :type run_command: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand or IO[bytes] :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, run_command=run_command, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("VirtualMachineRunCommand", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.VirtualMachineRunCommand].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.VirtualMachineRunCommand]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _update_initial( self, resource_group_name: str, vm_name: str, run_command_name: str, run_command: Union[_models.VirtualMachineRunCommandUpdate, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(run_command, (IOBase, bytes)): _content = run_command else: _json = self._serialize.body(run_command, "VirtualMachineRunCommandUpdate") _request = build_virtual_machine_run_commands_update_request( resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_update( self, resource_group_name: str, vm_name: str, run_command_name: str, run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to update the run command. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine where the run command should be updated. Required. :type vm_name: str :param run_command_name: The name of the virtual machine run command. Required. :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. Required. :type run_command: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommandUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_update( self, resource_group_name: str, vm_name: str, run_command_name: str, run_command: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to update the run command. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine where the run command should be updated. Required. :type vm_name: str :param run_command_name: The name of the virtual machine run command. Required. :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. Required. :type run_command: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Known values are: 'application/json', 'text/json'. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_update( self, resource_group_name: str, vm_name: str, run_command_name: str, run_command: Union[_models.VirtualMachineRunCommandUpdate, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to update the run command. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine where the run command should be updated. Required. :type vm_name: str :param run_command_name: The name of the virtual machine run command. Required. :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. Is either a VirtualMachineRunCommandUpdate type or a IO[bytes] type. Required. :type run_command: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommandUpdate or IO[bytes] :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, run_command=run_command, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("VirtualMachineRunCommand", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.VirtualMachineRunCommand].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.VirtualMachineRunCommand]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _delete_initial( self, resource_group_name: str, vm_name: str, run_command_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_virtual_machine_run_commands_delete_request( resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_delete( self, resource_group_name: str, vm_name: str, run_command_name: str, **kwargs: Any ) -> LROPoller[None]: """The operation to delete the run command. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine where the run command should be deleted. Required. :type vm_name: str :param run_command_name: The name of the virtual machine run command. Required. :type run_command_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
[docs] @distributed_trace def get_by_virtual_machine( self, resource_group_name: str, vm_name: str, run_command_name: str, *, expand: Optional[str] = None, **kwargs: Any ) -> _models.VirtualMachineRunCommand: """The operation to get the run command. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine containing the run command. Required. :type vm_name: str :param run_command_name: The name of the virtual machine run command. Required. :type run_command_name: str :keyword expand: The expand expression to apply on the operation. Default value is None. :paramtype expand: str :return: VirtualMachineRunCommand or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) _request = build_virtual_machine_run_commands_get_by_virtual_machine_request( resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("VirtualMachineRunCommand", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def list_by_virtual_machine( self, resource_group_name: str, vm_name: str, *, expand: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.VirtualMachineRunCommand"]: """The operation to get all run commands of a Virtual Machine. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_name: The name of the virtual machine containing the run command. Required. :type vm_name: str :keyword expand: The expand expression to apply on the operation. Default value is None. :paramtype expand: str :return: An iterator like instance of either VirtualMachineRunCommand or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineRunCommandsListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_virtual_machine_run_commands_list_by_virtual_machine_request( resource_group_name=resource_group_name, vm_name=vm_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("VirtualMachineRunCommandsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] class VirtualMachineScaleSetVMRunCommandsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`virtual_machine_scale_set_vm_run_commands` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, run_command_name: str, run_command: Union[_models.VirtualMachineRunCommand, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(run_command, (IOBase, bytes)): _content = run_command else: _json = self._serialize.body(run_command, "VirtualMachineRunCommand") _request = build_virtual_machine_scale_set_vm_run_commands_create_or_update_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, run_command_name=run_command_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, run_command_name: str, run_command: _models.VirtualMachineRunCommand, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the VMSS VM run command. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :param run_command_name: The name of the virtual machine run command. Required. :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. Required. :type run_command: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, run_command_name: str, run_command: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the VMSS VM run command. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :param run_command_name: The name of the virtual machine run command. Required. :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. Required. :type run_command: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Known values are: 'application/json', 'text/json'. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, run_command_name: str, run_command: Union[_models.VirtualMachineRunCommand, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the VMSS VM run command. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :param run_command_name: The name of the virtual machine run command. Required. :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. Is either a VirtualMachineRunCommand type or a IO[bytes] type. Required. :type run_command: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand or IO[bytes] :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, run_command_name=run_command_name, run_command=run_command, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("VirtualMachineRunCommand", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.VirtualMachineRunCommand].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.VirtualMachineRunCommand]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, run_command_name: str, run_command: Union[_models.VirtualMachineRunCommandUpdate, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(run_command, (IOBase, bytes)): _content = run_command else: _json = self._serialize.body(run_command, "VirtualMachineRunCommandUpdate") _request = build_virtual_machine_scale_set_vm_run_commands_update_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, run_command_name=run_command_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_update( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, run_command_name: str, run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to update the VMSS VM run command. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :param run_command_name: The name of the virtual machine run command. Required. :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. Required. :type run_command: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommandUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_update( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, run_command_name: str, run_command: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to update the VMSS VM run command. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :param run_command_name: The name of the virtual machine run command. Required. :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. Required. :type run_command: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Known values are: 'application/json', 'text/json'. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_update( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, run_command_name: str, run_command: Union[_models.VirtualMachineRunCommandUpdate, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to update the VMSS VM run command. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :param run_command_name: The name of the virtual machine run command. Required. :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. Is either a VirtualMachineRunCommandUpdate type or a IO[bytes] type. Required. :type run_command: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommandUpdate or IO[bytes] :return: An instance of LROPoller that returns either VirtualMachineRunCommand or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, run_command_name=run_command_name, run_command=run_command, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("VirtualMachineRunCommand", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.VirtualMachineRunCommand].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.VirtualMachineRunCommand]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _delete_initial( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, run_command_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_virtual_machine_scale_set_vm_run_commands_delete_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, run_command_name=run_command_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_delete( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, run_command_name: str, **kwargs: Any ) -> LROPoller[None]: """The operation to delete the VMSS VM run command. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :param run_command_name: The name of the virtual machine run command. Required. :type run_command_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, run_command_name=run_command_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
[docs] @distributed_trace def get( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, run_command_name: str, *, expand: Optional[str] = None, **kwargs: Any ) -> _models.VirtualMachineRunCommand: """The operation to get the VMSS VM run command. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :param run_command_name: The name of the virtual machine run command. Required. :type run_command_name: str :keyword expand: The expand expression to apply on the operation. Default value is None. :paramtype expand: str :return: VirtualMachineRunCommand or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineRunCommand] = kwargs.pop("cls", None) _request = build_virtual_machine_scale_set_vm_run_commands_get_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, run_command_name=run_command_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("VirtualMachineRunCommand", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def list( self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, *, expand: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.VirtualMachineRunCommand"]: """The operation to get all run commands of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param vm_scale_set_name: The name of the VM scale set. Required. :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. Required. :type instance_id: str :keyword expand: The expand expression to apply on the operation. Default value is None. :paramtype expand: str :return: An iterator like instance of either VirtualMachineRunCommand or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.VirtualMachineRunCommandsListResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_virtual_machine_scale_set_vm_run_commands_list_request( resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("VirtualMachineRunCommandsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] class ResourceSkusOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`resource_skus` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version")
[docs] @distributed_trace def list( self, *, filter: Optional[str] = None, include_extended_locations: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.ResourceSku"]: """Gets the list of Microsoft.Compute SKUs available for your Subscription. :keyword filter: The filter to apply on the operation. Only **location** filter is supported currently. Default value is None. :paramtype filter: str :keyword include_extended_locations: To Include Extended Locations information or not in the response. Default value is None. :paramtype include_extended_locations: str :return: An iterator like instance of either ResourceSku or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.ResourceSku] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.ResourceSkusResult] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_resource_skus_list_request( subscription_id=self._config.subscription_id, filter=filter, include_extended_locations=include_extended_locations, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("ResourceSkusResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] class GalleriesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`galleries` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery: Union[_models.Gallery, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(gallery, (IOBase, bytes)): _content = gallery else: _json = self._serialize.body(gallery, "Gallery") _request = build_galleries_create_or_update_request( resource_group_name=resource_group_name, gallery_name=gallery_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_create_or_update( self, resource_group_name: str, gallery_name: str, gallery: _models.Gallery, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.Gallery]: """Create or update a Shared Image Gallery. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Image Gallery. The allowed characters are alphabets and numbers with dots and periods allowed in the middle. The maximum length is 80 characters. Required. :type gallery_name: str :param gallery: Parameters supplied to the create or update Shared Image Gallery operation. Required. :type gallery: ~azure.mgmt.compute.v2021_07_01.models.Gallery :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either Gallery or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.Gallery] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_create_or_update( self, resource_group_name: str, gallery_name: str, gallery: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.Gallery]: """Create or update a Shared Image Gallery. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Image Gallery. The allowed characters are alphabets and numbers with dots and periods allowed in the middle. The maximum length is 80 characters. Required. :type gallery_name: str :param gallery: Parameters supplied to the create or update Shared Image Gallery operation. Required. :type gallery: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either Gallery or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.Gallery] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_create_or_update( self, resource_group_name: str, gallery_name: str, gallery: Union[_models.Gallery, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Gallery]: """Create or update a Shared Image Gallery. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Image Gallery. The allowed characters are alphabets and numbers with dots and periods allowed in the middle. The maximum length is 80 characters. Required. :type gallery_name: str :param gallery: Parameters supplied to the create or update Shared Image Gallery operation. Is either a Gallery type or a IO[bytes] type. Required. :type gallery: ~azure.mgmt.compute.v2021_07_01.models.Gallery or IO[bytes] :return: An instance of LROPoller that returns either Gallery or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.Gallery] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Gallery] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery=gallery, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("Gallery", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.Gallery].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.Gallery]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _update_initial( self, resource_group_name: str, gallery_name: str, gallery: Union[_models.GalleryUpdate, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(gallery, (IOBase, bytes)): _content = gallery else: _json = self._serialize.body(gallery, "GalleryUpdate") _request = build_galleries_update_request( resource_group_name=resource_group_name, gallery_name=gallery_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_update( self, resource_group_name: str, gallery_name: str, gallery: _models.GalleryUpdate, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.Gallery]: """Update a Shared Image Gallery. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Image Gallery. The allowed characters are alphabets and numbers with dots and periods allowed in the middle. The maximum length is 80 characters. Required. :type gallery_name: str :param gallery: Parameters supplied to the update Shared Image Gallery operation. Required. :type gallery: ~azure.mgmt.compute.v2021_07_01.models.GalleryUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either Gallery or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.Gallery] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_update( self, resource_group_name: str, gallery_name: str, gallery: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.Gallery]: """Update a Shared Image Gallery. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Image Gallery. The allowed characters are alphabets and numbers with dots and periods allowed in the middle. The maximum length is 80 characters. Required. :type gallery_name: str :param gallery: Parameters supplied to the update Shared Image Gallery operation. Required. :type gallery: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either Gallery or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.Gallery] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_update( self, resource_group_name: str, gallery_name: str, gallery: Union[_models.GalleryUpdate, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Gallery]: """Update a Shared Image Gallery. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Image Gallery. The allowed characters are alphabets and numbers with dots and periods allowed in the middle. The maximum length is 80 characters. Required. :type gallery_name: str :param gallery: Parameters supplied to the update Shared Image Gallery operation. Is either a GalleryUpdate type or a IO[bytes] type. Required. :type gallery: ~azure.mgmt.compute.v2021_07_01.models.GalleryUpdate or IO[bytes] :return: An instance of LROPoller that returns either Gallery or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.Gallery] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Gallery] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery=gallery, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("Gallery", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.Gallery].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.Gallery]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
[docs] @distributed_trace def get( self, resource_group_name: str, gallery_name: str, *, select: Optional[Union[str, _models.SelectPermissions]] = None, **kwargs: Any ) -> _models.Gallery: """Retrieves information about a Shared Image Gallery. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str :keyword select: The select expression to apply on the operation. "Permissions" Default value is None. :paramtype select: str or ~azure.mgmt.compute.v2021_07_01.models.SelectPermissions :return: Gallery or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.Gallery :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.Gallery] = kwargs.pop("cls", None) _request = build_galleries_get_request( resource_group_name=resource_group_name, gallery_name=gallery_name, subscription_id=self._config.subscription_id, select=select, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("Gallery", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
def _delete_initial(self, resource_group_name: str, gallery_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_galleries_delete_request( resource_group_name=resource_group_name, gallery_name=gallery_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_delete(self, resource_group_name: str, gallery_name: str, **kwargs: Any) -> LROPoller[None]: """Delete a Shared Image Gallery. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Image Gallery to be deleted. Required. :type gallery_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( resource_group_name=resource_group_name, gallery_name=gallery_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
[docs] @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Gallery"]: """List galleries under a resource group. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :return: An iterator like instance of either Gallery or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.Gallery] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.GalleryList] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_galleries_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("GalleryList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Gallery"]: """List galleries under a subscription. :return: An iterator like instance of either Gallery or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.Gallery] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.GalleryList] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_galleries_list_request( subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("GalleryList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] class GalleryImagesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`gallery_images` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, gallery_image: Union[_models.GalleryImage, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(gallery_image, (IOBase, bytes)): _content = gallery_image else: _json = self._serialize.body(gallery_image, "GalleryImage") _request = build_gallery_images_create_or_update_request( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_create_or_update( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, gallery_image: _models.GalleryImage, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.GalleryImage]: """Create or update a gallery image definition. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Image Gallery in which the Image Definition is to be created. Required. :type gallery_name: str :param gallery_image_name: The name of the gallery image definition to be created or updated. The allowed characters are alphabets and numbers with dots, dashes, and periods allowed in the middle. The maximum length is 80 characters. Required. :type gallery_image_name: str :param gallery_image: Parameters supplied to the create or update gallery image operation. Required. :type gallery_image: ~azure.mgmt.compute.v2021_07_01.models.GalleryImage :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either GalleryImage or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryImage] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_create_or_update( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, gallery_image: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.GalleryImage]: """Create or update a gallery image definition. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Image Gallery in which the Image Definition is to be created. Required. :type gallery_name: str :param gallery_image_name: The name of the gallery image definition to be created or updated. The allowed characters are alphabets and numbers with dots, dashes, and periods allowed in the middle. The maximum length is 80 characters. Required. :type gallery_image_name: str :param gallery_image: Parameters supplied to the create or update gallery image operation. Required. :type gallery_image: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either GalleryImage or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryImage] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_create_or_update( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, gallery_image: Union[_models.GalleryImage, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.GalleryImage]: """Create or update a gallery image definition. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Image Gallery in which the Image Definition is to be created. Required. :type gallery_name: str :param gallery_image_name: The name of the gallery image definition to be created or updated. The allowed characters are alphabets and numbers with dots, dashes, and periods allowed in the middle. The maximum length is 80 characters. Required. :type gallery_image_name: str :param gallery_image: Parameters supplied to the create or update gallery image operation. Is either a GalleryImage type or a IO[bytes] type. Required. :type gallery_image: ~azure.mgmt.compute.v2021_07_01.models.GalleryImage or IO[bytes] :return: An instance of LROPoller that returns either GalleryImage or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryImage] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.GalleryImage] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, gallery_image=gallery_image, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("GalleryImage", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.GalleryImage].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.GalleryImage]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _update_initial( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, gallery_image: Union[_models.GalleryImageUpdate, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(gallery_image, (IOBase, bytes)): _content = gallery_image else: _json = self._serialize.body(gallery_image, "GalleryImageUpdate") _request = build_gallery_images_update_request( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_update( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, gallery_image: _models.GalleryImageUpdate, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.GalleryImage]: """Update a gallery image definition. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Image Gallery in which the Image Definition is to be updated. Required. :type gallery_name: str :param gallery_image_name: The name of the gallery image definition to be updated. The allowed characters are alphabets and numbers with dots, dashes, and periods allowed in the middle. The maximum length is 80 characters. Required. :type gallery_image_name: str :param gallery_image: Parameters supplied to the update gallery image operation. Required. :type gallery_image: ~azure.mgmt.compute.v2021_07_01.models.GalleryImageUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either GalleryImage or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryImage] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_update( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, gallery_image: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.GalleryImage]: """Update a gallery image definition. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Image Gallery in which the Image Definition is to be updated. Required. :type gallery_name: str :param gallery_image_name: The name of the gallery image definition to be updated. The allowed characters are alphabets and numbers with dots, dashes, and periods allowed in the middle. The maximum length is 80 characters. Required. :type gallery_image_name: str :param gallery_image: Parameters supplied to the update gallery image operation. Required. :type gallery_image: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either GalleryImage or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryImage] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_update( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, gallery_image: Union[_models.GalleryImageUpdate, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.GalleryImage]: """Update a gallery image definition. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Image Gallery in which the Image Definition is to be updated. Required. :type gallery_name: str :param gallery_image_name: The name of the gallery image definition to be updated. The allowed characters are alphabets and numbers with dots, dashes, and periods allowed in the middle. The maximum length is 80 characters. Required. :type gallery_image_name: str :param gallery_image: Parameters supplied to the update gallery image operation. Is either a GalleryImageUpdate type or a IO[bytes] type. Required. :type gallery_image: ~azure.mgmt.compute.v2021_07_01.models.GalleryImageUpdate or IO[bytes] :return: An instance of LROPoller that returns either GalleryImage or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryImage] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.GalleryImage] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, gallery_image=gallery_image, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("GalleryImage", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.GalleryImage].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.GalleryImage]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
[docs] @distributed_trace def get( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any ) -> _models.GalleryImage: """Retrieves information about a gallery image definition. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Image Gallery from which the Image Definitions are to be retrieved. Required. :type gallery_name: str :param gallery_image_name: The name of the gallery image definition to be retrieved. Required. :type gallery_image_name: str :return: GalleryImage or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.GalleryImage :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.GalleryImage] = kwargs.pop("cls", None) _request = build_gallery_images_get_request( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("GalleryImage", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
def _delete_initial( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_gallery_images_delete_request( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_delete( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete a gallery image. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Image Gallery in which the Image Definition is to be deleted. Required. :type gallery_name: str :param gallery_image_name: The name of the gallery image definition to be deleted. Required. :type gallery_image_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
[docs] class GalleryImageVersionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`gallery_image_versions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, gallery_image_version: Union[_models.GalleryImageVersion, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(gallery_image_version, (IOBase, bytes)): _content = gallery_image_version else: _json = self._serialize.body(gallery_image_version, "GalleryImageVersion") _request = build_gallery_image_versions_create_or_update_request( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, gallery_image_version_name=gallery_image_version_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_create_or_update( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, gallery_image_version: _models.GalleryImageVersion, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.GalleryImageVersion]: """Create or update a gallery image version. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Image Gallery in which the Image Definition resides. Required. :type gallery_name: str :param gallery_image_name: The name of the gallery image definition in which the Image Version is to be created. Required. :type gallery_image_name: str :param gallery_image_version_name: The name of the gallery image version to be created. Needs to follow semantic version name pattern: The allowed characters are digit and period. Digits must be within the range of a 32-bit integer. Format: :code:`<MajorVersion>`.\\ :code:`<MinorVersion>`.\\ :code:`<Patch>`. Required. :type gallery_image_version_name: str :param gallery_image_version: Parameters supplied to the create or update gallery image version operation. Required. :type gallery_image_version: ~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersion :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either GalleryImageVersion or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersion] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_create_or_update( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, gallery_image_version: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.GalleryImageVersion]: """Create or update a gallery image version. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Image Gallery in which the Image Definition resides. Required. :type gallery_name: str :param gallery_image_name: The name of the gallery image definition in which the Image Version is to be created. Required. :type gallery_image_name: str :param gallery_image_version_name: The name of the gallery image version to be created. Needs to follow semantic version name pattern: The allowed characters are digit and period. Digits must be within the range of a 32-bit integer. Format: :code:`<MajorVersion>`.\\ :code:`<MinorVersion>`.\\ :code:`<Patch>`. Required. :type gallery_image_version_name: str :param gallery_image_version: Parameters supplied to the create or update gallery image version operation. Required. :type gallery_image_version: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either GalleryImageVersion or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersion] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_create_or_update( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, gallery_image_version: Union[_models.GalleryImageVersion, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.GalleryImageVersion]: """Create or update a gallery image version. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Image Gallery in which the Image Definition resides. Required. :type gallery_name: str :param gallery_image_name: The name of the gallery image definition in which the Image Version is to be created. Required. :type gallery_image_name: str :param gallery_image_version_name: The name of the gallery image version to be created. Needs to follow semantic version name pattern: The allowed characters are digit and period. Digits must be within the range of a 32-bit integer. Format: :code:`<MajorVersion>`.\\ :code:`<MinorVersion>`.\\ :code:`<Patch>`. Required. :type gallery_image_version_name: str :param gallery_image_version: Parameters supplied to the create or update gallery image version operation. Is either a GalleryImageVersion type or a IO[bytes] type. Required. :type gallery_image_version: ~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersion or IO[bytes] :return: An instance of LROPoller that returns either GalleryImageVersion or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersion] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.GalleryImageVersion] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, gallery_image_version_name=gallery_image_version_name, gallery_image_version=gallery_image_version, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("GalleryImageVersion", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.GalleryImageVersion].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.GalleryImageVersion]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _update_initial( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, gallery_image_version: Union[_models.GalleryImageVersionUpdate, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(gallery_image_version, (IOBase, bytes)): _content = gallery_image_version else: _json = self._serialize.body(gallery_image_version, "GalleryImageVersionUpdate") _request = build_gallery_image_versions_update_request( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, gallery_image_version_name=gallery_image_version_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_update( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, gallery_image_version: _models.GalleryImageVersionUpdate, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.GalleryImageVersion]: """Update a gallery image version. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Image Gallery in which the Image Definition resides. Required. :type gallery_name: str :param gallery_image_name: The name of the gallery image definition in which the Image Version is to be updated. Required. :type gallery_image_name: str :param gallery_image_version_name: The name of the gallery image version to be updated. Needs to follow semantic version name pattern: The allowed characters are digit and period. Digits must be within the range of a 32-bit integer. Format: :code:`<MajorVersion>`.\\ :code:`<MinorVersion>`.\\ :code:`<Patch>`. Required. :type gallery_image_version_name: str :param gallery_image_version: Parameters supplied to the update gallery image version operation. Required. :type gallery_image_version: ~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersionUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either GalleryImageVersion or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersion] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_update( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, gallery_image_version: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.GalleryImageVersion]: """Update a gallery image version. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Image Gallery in which the Image Definition resides. Required. :type gallery_name: str :param gallery_image_name: The name of the gallery image definition in which the Image Version is to be updated. Required. :type gallery_image_name: str :param gallery_image_version_name: The name of the gallery image version to be updated. Needs to follow semantic version name pattern: The allowed characters are digit and period. Digits must be within the range of a 32-bit integer. Format: :code:`<MajorVersion>`.\\ :code:`<MinorVersion>`.\\ :code:`<Patch>`. Required. :type gallery_image_version_name: str :param gallery_image_version: Parameters supplied to the update gallery image version operation. Required. :type gallery_image_version: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either GalleryImageVersion or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersion] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_update( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, gallery_image_version: Union[_models.GalleryImageVersionUpdate, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.GalleryImageVersion]: """Update a gallery image version. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Image Gallery in which the Image Definition resides. Required. :type gallery_name: str :param gallery_image_name: The name of the gallery image definition in which the Image Version is to be updated. Required. :type gallery_image_name: str :param gallery_image_version_name: The name of the gallery image version to be updated. Needs to follow semantic version name pattern: The allowed characters are digit and period. Digits must be within the range of a 32-bit integer. Format: :code:`<MajorVersion>`.\\ :code:`<MinorVersion>`.\\ :code:`<Patch>`. Required. :type gallery_image_version_name: str :param gallery_image_version: Parameters supplied to the update gallery image version operation. Is either a GalleryImageVersionUpdate type or a IO[bytes] type. Required. :type gallery_image_version: ~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersionUpdate or IO[bytes] :return: An instance of LROPoller that returns either GalleryImageVersion or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersion] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.GalleryImageVersion] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, gallery_image_version_name=gallery_image_version_name, gallery_image_version=gallery_image_version, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("GalleryImageVersion", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.GalleryImageVersion].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.GalleryImageVersion]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
[docs] @distributed_trace def get( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, *, expand: Optional[Union[str, _models.ReplicationStatusTypes]] = None, **kwargs: Any ) -> _models.GalleryImageVersion: """Retrieves information about a gallery image version. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Image Gallery in which the Image Definition resides. Required. :type gallery_name: str :param gallery_image_name: The name of the gallery image definition in which the Image Version resides. Required. :type gallery_image_name: str :param gallery_image_version_name: The name of the gallery image version to be retrieved. Required. :type gallery_image_version_name: str :keyword expand: The expand expression to apply on the operation. "ReplicationStatus" Default value is None. :paramtype expand: str or ~azure.mgmt.compute.v2021_07_01.models.ReplicationStatusTypes :return: GalleryImageVersion or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.GalleryImageVersion] = kwargs.pop("cls", None) _request = build_gallery_image_versions_get_request( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, gallery_image_version_name=gallery_image_version_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("GalleryImageVersion", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
def _delete_initial( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_gallery_image_versions_delete_request( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, gallery_image_version_name=gallery_image_version_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_delete( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete a gallery image version. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Image Gallery in which the Image Definition resides. Required. :type gallery_name: str :param gallery_image_name: The name of the gallery image definition in which the Image Version resides. Required. :type gallery_image_name: str :param gallery_image_version_name: The name of the gallery image version to be deleted. Required. :type gallery_image_version_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, gallery_image_version_name=gallery_image_version_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
[docs] class GalleryApplicationsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`gallery_applications` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, gallery_application: Union[_models.GalleryApplication, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(gallery_application, (IOBase, bytes)): _content = gallery_application else: _json = self._serialize.body(gallery_application, "GalleryApplication") _request = build_gallery_applications_create_or_update_request( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_create_or_update( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, gallery_application: _models.GalleryApplication, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.GalleryApplication]: """Create or update a gallery Application Definition. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Application Gallery in which the Application Definition is to be created. Required. :type gallery_name: str :param gallery_application_name: The name of the gallery Application Definition to be created or updated. The allowed characters are alphabets and numbers with dots, dashes, and periods allowed in the middle. The maximum length is 80 characters. Required. :type gallery_application_name: str :param gallery_application: Parameters supplied to the create or update gallery Application operation. Required. :type gallery_application: ~azure.mgmt.compute.v2021_07_01.models.GalleryApplication :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either GalleryApplication or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplication] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_create_or_update( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, gallery_application: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.GalleryApplication]: """Create or update a gallery Application Definition. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Application Gallery in which the Application Definition is to be created. Required. :type gallery_name: str :param gallery_application_name: The name of the gallery Application Definition to be created or updated. The allowed characters are alphabets and numbers with dots, dashes, and periods allowed in the middle. The maximum length is 80 characters. Required. :type gallery_application_name: str :param gallery_application: Parameters supplied to the create or update gallery Application operation. Required. :type gallery_application: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either GalleryApplication or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplication] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_create_or_update( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, gallery_application: Union[_models.GalleryApplication, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.GalleryApplication]: """Create or update a gallery Application Definition. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Application Gallery in which the Application Definition is to be created. Required. :type gallery_name: str :param gallery_application_name: The name of the gallery Application Definition to be created or updated. The allowed characters are alphabets and numbers with dots, dashes, and periods allowed in the middle. The maximum length is 80 characters. Required. :type gallery_application_name: str :param gallery_application: Parameters supplied to the create or update gallery Application operation. Is either a GalleryApplication type or a IO[bytes] type. Required. :type gallery_application: ~azure.mgmt.compute.v2021_07_01.models.GalleryApplication or IO[bytes] :return: An instance of LROPoller that returns either GalleryApplication or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplication] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.GalleryApplication] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, gallery_application=gallery_application, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("GalleryApplication", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.GalleryApplication].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.GalleryApplication]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _update_initial( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, gallery_application: Union[_models.GalleryApplicationUpdate, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(gallery_application, (IOBase, bytes)): _content = gallery_application else: _json = self._serialize.body(gallery_application, "GalleryApplicationUpdate") _request = build_gallery_applications_update_request( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_update( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, gallery_application: _models.GalleryApplicationUpdate, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.GalleryApplication]: """Update a gallery Application Definition. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Application Gallery in which the Application Definition is to be updated. Required. :type gallery_name: str :param gallery_application_name: The name of the gallery Application Definition to be updated. The allowed characters are alphabets and numbers with dots, dashes, and periods allowed in the middle. The maximum length is 80 characters. Required. :type gallery_application_name: str :param gallery_application: Parameters supplied to the update gallery Application operation. Required. :type gallery_application: ~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either GalleryApplication or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplication] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_update( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, gallery_application: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.GalleryApplication]: """Update a gallery Application Definition. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Application Gallery in which the Application Definition is to be updated. Required. :type gallery_name: str :param gallery_application_name: The name of the gallery Application Definition to be updated. The allowed characters are alphabets and numbers with dots, dashes, and periods allowed in the middle. The maximum length is 80 characters. Required. :type gallery_application_name: str :param gallery_application: Parameters supplied to the update gallery Application operation. Required. :type gallery_application: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either GalleryApplication or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplication] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_update( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, gallery_application: Union[_models.GalleryApplicationUpdate, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.GalleryApplication]: """Update a gallery Application Definition. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Application Gallery in which the Application Definition is to be updated. Required. :type gallery_name: str :param gallery_application_name: The name of the gallery Application Definition to be updated. The allowed characters are alphabets and numbers with dots, dashes, and periods allowed in the middle. The maximum length is 80 characters. Required. :type gallery_application_name: str :param gallery_application: Parameters supplied to the update gallery Application operation. Is either a GalleryApplicationUpdate type or a IO[bytes] type. Required. :type gallery_application: ~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationUpdate or IO[bytes] :return: An instance of LROPoller that returns either GalleryApplication or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplication] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.GalleryApplication] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, gallery_application=gallery_application, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("GalleryApplication", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.GalleryApplication].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.GalleryApplication]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
[docs] @distributed_trace def get( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, **kwargs: Any ) -> _models.GalleryApplication: """Retrieves information about a gallery Application Definition. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Application Gallery from which the Application Definitions are to be retrieved. Required. :type gallery_name: str :param gallery_application_name: The name of the gallery Application Definition to be retrieved. Required. :type gallery_application_name: str :return: GalleryApplication or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.GalleryApplication :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.GalleryApplication] = kwargs.pop("cls", None) _request = build_gallery_applications_get_request( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("GalleryApplication", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
def _delete_initial( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_gallery_applications_delete_request( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_delete( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete a gallery Application. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Application Gallery in which the Application Definition is to be deleted. Required. :type gallery_name: str :param gallery_application_name: The name of the gallery Application Definition to be deleted. Required. :type gallery_application_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
[docs] class GalleryApplicationVersionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`gallery_application_versions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, gallery_application_version: Union[_models.GalleryApplicationVersion, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(gallery_application_version, (IOBase, bytes)): _content = gallery_application_version else: _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersion") _request = build_gallery_application_versions_create_or_update_request( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, gallery_application_version_name=gallery_application_version_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_create_or_update( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, gallery_application_version: _models.GalleryApplicationVersion, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.GalleryApplicationVersion]: """Create or update a gallery Application Version. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Application Gallery in which the Application Definition resides. Required. :type gallery_name: str :param gallery_application_name: The name of the gallery Application Definition in which the Application Version is to be created. Required. :type gallery_application_name: str :param gallery_application_version_name: The name of the gallery Application Version to be created. Needs to follow semantic version name pattern: The allowed characters are digit and period. Digits must be within the range of a 32-bit integer. Format: :code:`<MajorVersion>`.\\ :code:`<MinorVersion>`.\\ :code:`<Patch>`. Required. :type gallery_application_version_name: str :param gallery_application_version: Parameters supplied to the create or update gallery Application Version operation. Required. :type gallery_application_version: ~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersion :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either GalleryApplicationVersion or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersion] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_create_or_update( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, gallery_application_version: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.GalleryApplicationVersion]: """Create or update a gallery Application Version. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Application Gallery in which the Application Definition resides. Required. :type gallery_name: str :param gallery_application_name: The name of the gallery Application Definition in which the Application Version is to be created. Required. :type gallery_application_name: str :param gallery_application_version_name: The name of the gallery Application Version to be created. Needs to follow semantic version name pattern: The allowed characters are digit and period. Digits must be within the range of a 32-bit integer. Format: :code:`<MajorVersion>`.\\ :code:`<MinorVersion>`.\\ :code:`<Patch>`. Required. :type gallery_application_version_name: str :param gallery_application_version: Parameters supplied to the create or update gallery Application Version operation. Required. :type gallery_application_version: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either GalleryApplicationVersion or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersion] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_create_or_update( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, gallery_application_version: Union[_models.GalleryApplicationVersion, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.GalleryApplicationVersion]: """Create or update a gallery Application Version. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Application Gallery in which the Application Definition resides. Required. :type gallery_name: str :param gallery_application_name: The name of the gallery Application Definition in which the Application Version is to be created. Required. :type gallery_application_name: str :param gallery_application_version_name: The name of the gallery Application Version to be created. Needs to follow semantic version name pattern: The allowed characters are digit and period. Digits must be within the range of a 32-bit integer. Format: :code:`<MajorVersion>`.\\ :code:`<MinorVersion>`.\\ :code:`<Patch>`. Required. :type gallery_application_version_name: str :param gallery_application_version: Parameters supplied to the create or update gallery Application Version operation. Is either a GalleryApplicationVersion type or a IO[bytes] type. Required. :type gallery_application_version: ~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersion or IO[bytes] :return: An instance of LROPoller that returns either GalleryApplicationVersion or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersion] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.GalleryApplicationVersion] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, gallery_application_version_name=gallery_application_version_name, gallery_application_version=gallery_application_version, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("GalleryApplicationVersion", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.GalleryApplicationVersion].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.GalleryApplicationVersion]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
def _update_initial( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, gallery_application_version: Union[_models.GalleryApplicationVersionUpdate, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(gallery_application_version, (IOBase, bytes)): _content = gallery_application_version else: _json = self._serialize.body(gallery_application_version, "GalleryApplicationVersionUpdate") _request = build_gallery_application_versions_update_request( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, gallery_application_version_name=gallery_application_version_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_update( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, gallery_application_version: _models.GalleryApplicationVersionUpdate, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.GalleryApplicationVersion]: """Update a gallery Application Version. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Application Gallery in which the Application Definition resides. Required. :type gallery_name: str :param gallery_application_name: The name of the gallery Application Definition in which the Application Version is to be updated. Required. :type gallery_application_name: str :param gallery_application_version_name: The name of the gallery Application Version to be updated. Needs to follow semantic version name pattern: The allowed characters are digit and period. Digits must be within the range of a 32-bit integer. Format: :code:`<MajorVersion>`.\\ :code:`<MinorVersion>`.\\ :code:`<Patch>`. Required. :type gallery_application_version_name: str :param gallery_application_version: Parameters supplied to the update gallery Application Version operation. Required. :type gallery_application_version: ~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersionUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either GalleryApplicationVersion or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersion] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_update( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, gallery_application_version: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.GalleryApplicationVersion]: """Update a gallery Application Version. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Application Gallery in which the Application Definition resides. Required. :type gallery_name: str :param gallery_application_name: The name of the gallery Application Definition in which the Application Version is to be updated. Required. :type gallery_application_name: str :param gallery_application_version_name: The name of the gallery Application Version to be updated. Needs to follow semantic version name pattern: The allowed characters are digit and period. Digits must be within the range of a 32-bit integer. Format: :code:`<MajorVersion>`.\\ :code:`<MinorVersion>`.\\ :code:`<Patch>`. Required. :type gallery_application_version_name: str :param gallery_application_version: Parameters supplied to the update gallery Application Version operation. Required. :type gallery_application_version: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either GalleryApplicationVersion or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersion] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_update( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, gallery_application_version: Union[_models.GalleryApplicationVersionUpdate, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.GalleryApplicationVersion]: """Update a gallery Application Version. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Application Gallery in which the Application Definition resides. Required. :type gallery_name: str :param gallery_application_name: The name of the gallery Application Definition in which the Application Version is to be updated. Required. :type gallery_application_name: str :param gallery_application_version_name: The name of the gallery Application Version to be updated. Needs to follow semantic version name pattern: The allowed characters are digit and period. Digits must be within the range of a 32-bit integer. Format: :code:`<MajorVersion>`.\\ :code:`<MinorVersion>`.\\ :code:`<Patch>`. Required. :type gallery_application_version_name: str :param gallery_application_version: Parameters supplied to the update gallery Application Version operation. Is either a GalleryApplicationVersionUpdate type or a IO[bytes] type. Required. :type gallery_application_version: ~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersionUpdate or IO[bytes] :return: An instance of LROPoller that returns either GalleryApplicationVersion or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersion] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.GalleryApplicationVersion] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, gallery_application_version_name=gallery_application_version_name, gallery_application_version=gallery_application_version, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("GalleryApplicationVersion", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.GalleryApplicationVersion].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.GalleryApplicationVersion]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
[docs] @distributed_trace def get( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, *, expand: Optional[Union[str, _models.ReplicationStatusTypes]] = None, **kwargs: Any ) -> _models.GalleryApplicationVersion: """Retrieves information about a gallery Application Version. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Application Gallery in which the Application Definition resides. Required. :type gallery_name: str :param gallery_application_name: The name of the gallery Application Definition in which the Application Version resides. Required. :type gallery_application_name: str :param gallery_application_version_name: The name of the gallery Application Version to be retrieved. Required. :type gallery_application_version_name: str :keyword expand: The expand expression to apply on the operation. "ReplicationStatus" Default value is None. :paramtype expand: str or ~azure.mgmt.compute.v2021_07_01.models.ReplicationStatusTypes :return: GalleryApplicationVersion or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.GalleryApplicationVersion] = kwargs.pop("cls", None) _request = build_gallery_application_versions_get_request( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, gallery_application_version_name=gallery_application_version_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("GalleryApplicationVersion", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
def _delete_initial( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_gallery_application_versions_delete_request( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, gallery_application_version_name=gallery_application_version_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] @distributed_trace def begin_delete( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete a gallery Application Version. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Application Gallery in which the Application Definition resides. Required. :type gallery_name: str :param gallery_application_name: The name of the gallery Application Definition in which the Application Version resides. Required. :type gallery_application_name: str :param gallery_application_version_name: The name of the gallery Application Version to be deleted. Required. :type gallery_application_version_name: str :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, gallery_application_version_name=gallery_application_version_name, api_version=api_version, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
[docs] class GallerySharingProfileOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`gallery_sharing_profile` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") def _update_initial( self, resource_group_name: str, gallery_name: str, sharing_update: Union[_models.SharingUpdate, IO[bytes]], **kwargs: Any ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None if isinstance(sharing_update, (IOBase, bytes)): _content = sharing_update else: _json = self._serialize.body(sharing_update, "SharingUpdate") _request = build_gallery_sharing_profile_update_request( resource_group_name=resource_group_name, gallery_name=gallery_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _decompress = kwargs.pop("decompress", True) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload def begin_update( self, resource_group_name: str, gallery_name: str, sharing_update: _models.SharingUpdate, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.SharingUpdate]: """Update sharing profile of a gallery. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str :param sharing_update: Parameters supplied to the update gallery sharing profile. Required. :type sharing_update: ~azure.mgmt.compute.v2021_07_01.models.SharingUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either SharingUpdate or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.SharingUpdate] :raises ~azure.core.exceptions.HttpResponseError: """ @overload def begin_update( self, resource_group_name: str, gallery_name: str, sharing_update: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.SharingUpdate]: """Update sharing profile of a gallery. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str :param sharing_update: Parameters supplied to the update gallery sharing profile. Required. :type sharing_update: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns either SharingUpdate or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.SharingUpdate] :raises ~azure.core.exceptions.HttpResponseError: """
[docs] @distributed_trace def begin_update( self, resource_group_name: str, gallery_name: str, sharing_update: Union[_models.SharingUpdate, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.SharingUpdate]: """Update sharing profile of a gallery. :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str :param gallery_name: The name of the Shared Image Gallery. Required. :type gallery_name: str :param sharing_update: Parameters supplied to the update gallery sharing profile. Is either a SharingUpdate type or a IO[bytes] type. Required. :type sharing_update: ~azure.mgmt.compute.v2021_07_01.models.SharingUpdate or IO[bytes] :return: An instance of LROPoller that returns either SharingUpdate or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.SharingUpdate] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SharingUpdate] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_initial( resource_group_name=resource_group_name, gallery_name=gallery_name, sharing_update=sharing_update, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): deserialized = self._deserialize("SharingUpdate", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.SharingUpdate].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.SharingUpdate]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
[docs] class SharedGalleriesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`shared_galleries` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version")
[docs] @distributed_trace def list( self, location: str, *, shared_to: Optional[Union[str, _models.SharedToValues]] = None, **kwargs: Any ) -> Iterable["_models.SharedGallery"]: """List shared galleries by subscription id or tenant id. :param location: Resource location. Required. :type location: str :keyword shared_to: The query parameter to decide what shared galleries to fetch when doing listing operations. "tenant" Default value is None. :paramtype shared_to: str or ~azure.mgmt.compute.v2021_07_01.models.SharedToValues :return: An iterator like instance of either SharedGallery or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.SharedGallery] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.SharedGalleryList] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_shared_galleries_list_request( location=location, subscription_id=self._config.subscription_id, shared_to=shared_to, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("SharedGalleryList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] @distributed_trace def get(self, location: str, gallery_unique_name: str, **kwargs: Any) -> _models.SharedGallery: """Get a shared gallery by subscription id or tenant id. :param location: Resource location. Required. :type location: str :param gallery_unique_name: The unique name of the Shared Gallery. Required. :type gallery_unique_name: str :return: SharedGallery or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.SharedGallery :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.SharedGallery] = kwargs.pop("cls", None) _request = build_shared_galleries_get_request( location=location, gallery_unique_name=gallery_unique_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("SharedGallery", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] class SharedGalleryImagesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`shared_gallery_images` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version")
[docs] @distributed_trace def list( self, location: str, gallery_unique_name: str, *, shared_to: Optional[Union[str, _models.SharedToValues]] = None, **kwargs: Any ) -> Iterable["_models.SharedGalleryImage"]: """List shared gallery images by subscription id or tenant id. :param location: Resource location. Required. :type location: str :param gallery_unique_name: The unique name of the Shared Gallery. Required. :type gallery_unique_name: str :keyword shared_to: The query parameter to decide what shared galleries to fetch when doing listing operations. "tenant" Default value is None. :paramtype shared_to: str or ~azure.mgmt.compute.v2021_07_01.models.SharedToValues :return: An iterator like instance of either SharedGalleryImage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.SharedGalleryImage] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.SharedGalleryImageList] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_shared_gallery_images_list_request( location=location, gallery_unique_name=gallery_unique_name, subscription_id=self._config.subscription_id, shared_to=shared_to, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("SharedGalleryImageList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] @distributed_trace def get( self, location: str, gallery_unique_name: str, gallery_image_name: str, **kwargs: Any ) -> _models.SharedGalleryImage: """Get a shared gallery image by subscription id or tenant id. :param location: Resource location. Required. :type location: str :param gallery_unique_name: The unique name of the Shared Gallery. Required. :type gallery_unique_name: str :param gallery_image_name: The name of the Shared Gallery Image Definition from which the Image Versions are to be listed. Required. :type gallery_image_name: str :return: SharedGalleryImage or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.SharedGalleryImage :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.SharedGalleryImage] = kwargs.pop("cls", None) _request = build_shared_gallery_images_get_request( location=location, gallery_unique_name=gallery_unique_name, gallery_image_name=gallery_image_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("SharedGalleryImage", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] class SharedGalleryImageVersionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`shared_gallery_image_versions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version")
[docs] @distributed_trace def list( self, location: str, gallery_unique_name: str, gallery_image_name: str, *, shared_to: Optional[Union[str, _models.SharedToValues]] = None, **kwargs: Any ) -> Iterable["_models.SharedGalleryImageVersion"]: """List shared gallery image versions by subscription id or tenant id. :param location: Resource location. Required. :type location: str :param gallery_unique_name: The unique name of the Shared Gallery. Required. :type gallery_unique_name: str :param gallery_image_name: The name of the Shared Gallery Image Definition from which the Image Versions are to be listed. Required. :type gallery_image_name: str :keyword shared_to: The query parameter to decide what shared galleries to fetch when doing listing operations. "tenant" Default value is None. :paramtype shared_to: str or ~azure.mgmt.compute.v2021_07_01.models.SharedToValues :return: An iterator like instance of either SharedGalleryImageVersion or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.SharedGalleryImageVersion] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.SharedGalleryImageVersionList] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): if not next_link: _request = build_shared_gallery_image_versions_list_request( location=location, gallery_unique_name=gallery_unique_name, gallery_image_name=gallery_image_name, subscription_id=self._config.subscription_id, shared_to=shared_to, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version _parsed_next_link = urllib.parse.urlparse(next_link) _next_request_params = case_insensitive_dict( { key: [urllib.parse.quote(v) for v in value] for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() } ) _next_request_params["api-version"] = self._api_version _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request def extract_data(pipeline_response): deserialized = self._deserialize("SharedGalleryImageVersionList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data)
[docs] @distributed_trace def get( self, location: str, gallery_unique_name: str, gallery_image_name: str, gallery_image_version_name: str, **kwargs: Any ) -> _models.SharedGalleryImageVersion: """Get a shared gallery image version by subscription id or tenant id. :param location: Resource location. Required. :type location: str :param gallery_unique_name: The unique name of the Shared Gallery. Required. :type gallery_unique_name: str :param gallery_image_name: The name of the Shared Gallery Image Definition from which the Image Versions are to be listed. Required. :type gallery_image_name: str :param gallery_image_version_name: The name of the gallery image version to be created. Needs to follow semantic version name pattern: The allowed characters are digit and period. Digits must be within the range of a 32-bit integer. Format: :code:`<MajorVersion>`.\\ :code:`<MinorVersion>`.\\ :code:`<Patch>`. Required. :type gallery_image_version_name: str :return: SharedGalleryImageVersion or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.SharedGalleryImageVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.SharedGalleryImageVersion] = kwargs.pop("cls", None) _request = build_shared_gallery_image_versions_get_request( location=location, gallery_unique_name=gallery_unique_name, gallery_image_name=gallery_image_name, gallery_image_version_name=gallery_image_version_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("SharedGalleryImageVersion", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] class CommunityGalleriesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`community_galleries` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version")
[docs] @distributed_trace def get(self, location: str, public_gallery_name: str, **kwargs: Any) -> _models.CommunityGallery: """Get a community gallery by gallery public name. :param location: Resource location. Required. :type location: str :param public_gallery_name: The public name of the community gallery. Required. :type public_gallery_name: str :return: CommunityGallery or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.CommunityGallery :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.CommunityGallery] = kwargs.pop("cls", None) _request = build_community_galleries_get_request( location=location, public_gallery_name=public_gallery_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("CommunityGallery", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] class CommunityGalleryImagesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`community_gallery_images` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version")
[docs] @distributed_trace def get( self, location: str, public_gallery_name: str, gallery_image_name: str, **kwargs: Any ) -> _models.CommunityGalleryImage: """Get a community gallery image. :param location: Resource location. Required. :type location: str :param public_gallery_name: The public name of the community gallery. Required. :type public_gallery_name: str :param gallery_image_name: The name of the community gallery image definition. Required. :type gallery_image_name: str :return: CommunityGalleryImage or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.CommunityGalleryImage :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.CommunityGalleryImage] = kwargs.pop("cls", None) _request = build_community_gallery_images_get_request( location=location, public_gallery_name=public_gallery_name, gallery_image_name=gallery_image_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("CommunityGalleryImage", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
[docs] class CommunityGalleryImageVersionsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s :attr:`community_gallery_image_versions` attribute. """ models = _models def __init__(self, *args, **kwargs): input_args = list(args) self._client = input_args.pop(0) if input_args else kwargs.pop("client") self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version")
[docs] @distributed_trace def get( self, location: str, public_gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, **kwargs: Any ) -> _models.CommunityGalleryImageVersion: """Get a community gallery image version. :param location: Resource location. Required. :type location: str :param public_gallery_name: The public name of the community gallery. Required. :type public_gallery_name: str :param gallery_image_name: The name of the community gallery image definition. Required. :type gallery_image_name: str :param gallery_image_version_name: The name of the community gallery image version. Needs to follow semantic version name pattern: The allowed characters are digit and period. Digits must be within the range of a 32-bit integer. Format: :code:`<MajorVersion>`.\\ :code:`<MinorVersion>`.\\ :code:`<Patch>`. Required. :type gallery_image_version_name: str :return: CommunityGalleryImageVersion or the result of cls(response) :rtype: ~azure.mgmt.compute.v2021_07_01.models.CommunityGalleryImageVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.CommunityGalleryImageVersion] = kwargs.pop("cls", None) _request = build_community_gallery_image_versions_get_request( location=location, public_gallery_name=public_gallery_name, gallery_image_name=gallery_image_name, gallery_image_version_name=gallery_image_version_name, subscription_id=self._config.subscription_id, api_version=api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize("CommunityGalleryImageVersion", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore