Source code for azure.iot.deviceupdate.operations._devices_operations

# 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 typing import TYPE_CHECKING
import warnings

from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpRequest, HttpResponse

from .. import models as _models

if TYPE_CHECKING:
    # pylint: disable=unused-import,ungrouped-imports
    from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar

    T = TypeVar('T')
    ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]

[docs]class DevicesOperations(object): """DevicesOperations operations. You should not instantiate this class directly. Instead, you should create a Client instance that instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. :type models: ~azure.iot.deviceupdate.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. """ models = _models def __init__(self, client, config, serializer, deserializer): self._client = client self._serialize = serializer self._deserialize = deserializer self._config = config
[docs] def get_all_device_classes( self, **kwargs # type: Any ): # type: (...) -> Iterable["_models.PageableListOfDeviceClasses"] """Gets a list of all device classes (unique combinations of device manufacturer and model) for all devices connected to Device Update for IoT Hub. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PageableListOfDeviceClasses or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.iot.deviceupdate.models.PageableListOfDeviceClasses] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PageableListOfDeviceClasses"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) accept = "application/json" def prepare_request(next_link=None): # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') if not next_link: # Construct URL url = self.get_all_device_classes.metadata['url'] # type: ignore path_format_arguments = { 'accountEndpoint': self._serialize.url("self._config.account_endpoint", self._config.account_endpoint, 'str', skip_quote=True), 'instanceId': self._serialize.url("self._config.instance_id", self._config.instance_id, 'str', skip_quote=True), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] request = self._client.get(url, query_parameters, header_parameters) else: url = next_link query_parameters = {} # type: Dict[str, Any] path_format_arguments = { 'accountEndpoint': self._serialize.url("self._config.account_endpoint", self._config.account_endpoint, 'str', skip_quote=True), 'instanceId': self._serialize.url("self._config.instance_id", self._config.instance_id, 'str', skip_quote=True), } url = self._client.format_url(url, **path_format_arguments) request = self._client.get(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): deserialized = self._deserialize('PageableListOfDeviceClasses', pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = self._client._pipeline.run(request, stream=False, **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) return pipeline_response return ItemPaged( get_next, extract_data )
get_all_device_classes.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/deviceclasses'} # type: ignore
[docs] def get_device_class( self, device_class_id, # type: str **kwargs # type: Any ): # type: (...) -> "_models.DeviceClass" """Gets the properties of a device class. :param device_class_id: Device class identifier. :type device_class_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DeviceClass, or the result of cls(response) :rtype: ~azure.iot.deviceupdate.models.DeviceClass :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeviceClass"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) accept = "application/json" # Construct URL url = self.get_device_class.metadata['url'] # type: ignore path_format_arguments = { 'accountEndpoint': self._serialize.url("self._config.account_endpoint", self._config.account_endpoint, 'str', skip_quote=True), 'instanceId': self._serialize.url("self._config.instance_id", self._config.instance_id, 'str', skip_quote=True), 'deviceClassId': self._serialize.url("device_class_id", device_class_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **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) deserialized = self._deserialize('DeviceClass', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized
get_device_class.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/deviceclasses/{deviceClassId}'} # type: ignore
[docs] def get_device_class_device_ids( self, device_class_id, # type: str **kwargs # type: Any ): # type: (...) -> Iterable["_models.PageableListOfStrings"] """Gets a list of device identifiers in a device class. :param device_class_id: Device class identifier. :type device_class_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PageableListOfStrings or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.iot.deviceupdate.models.PageableListOfStrings] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PageableListOfStrings"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) accept = "application/json" def prepare_request(next_link=None): # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') if not next_link: # Construct URL url = self.get_device_class_device_ids.metadata['url'] # type: ignore path_format_arguments = { 'accountEndpoint': self._serialize.url("self._config.account_endpoint", self._config.account_endpoint, 'str', skip_quote=True), 'instanceId': self._serialize.url("self._config.instance_id", self._config.instance_id, 'str', skip_quote=True), 'deviceClassId': self._serialize.url("device_class_id", device_class_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] request = self._client.get(url, query_parameters, header_parameters) else: url = next_link query_parameters = {} # type: Dict[str, Any] path_format_arguments = { 'accountEndpoint': self._serialize.url("self._config.account_endpoint", self._config.account_endpoint, 'str', skip_quote=True), 'instanceId': self._serialize.url("self._config.instance_id", self._config.instance_id, 'str', skip_quote=True), 'deviceClassId': self._serialize.url("device_class_id", device_class_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) request = self._client.get(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): deserialized = self._deserialize('PageableListOfStrings', pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = self._client._pipeline.run(request, stream=False, **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) return pipeline_response return ItemPaged( get_next, extract_data )
get_device_class_device_ids.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/deviceclasses/{deviceClassId}/deviceids'} # type: ignore
[docs] def get_device_class_installable_updates( self, device_class_id, # type: str **kwargs # type: Any ): # type: (...) -> Iterable["_models.PageableListOfUpdateIds"] """Gets a list of installable updates for a device class. :param device_class_id: Device class identifier. :type device_class_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PageableListOfUpdateIds or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.iot.deviceupdate.models.PageableListOfUpdateIds] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PageableListOfUpdateIds"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) accept = "application/json" def prepare_request(next_link=None): # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') if not next_link: # Construct URL url = self.get_device_class_installable_updates.metadata['url'] # type: ignore path_format_arguments = { 'accountEndpoint': self._serialize.url("self._config.account_endpoint", self._config.account_endpoint, 'str', skip_quote=True), 'instanceId': self._serialize.url("self._config.instance_id", self._config.instance_id, 'str', skip_quote=True), 'deviceClassId': self._serialize.url("device_class_id", device_class_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] request = self._client.get(url, query_parameters, header_parameters) else: url = next_link query_parameters = {} # type: Dict[str, Any] path_format_arguments = { 'accountEndpoint': self._serialize.url("self._config.account_endpoint", self._config.account_endpoint, 'str', skip_quote=True), 'instanceId': self._serialize.url("self._config.instance_id", self._config.instance_id, 'str', skip_quote=True), 'deviceClassId': self._serialize.url("device_class_id", device_class_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) request = self._client.get(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): deserialized = self._deserialize('PageableListOfUpdateIds', pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = self._client._pipeline.run(request, stream=False, **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) return pipeline_response return ItemPaged( get_next, extract_data )
get_device_class_installable_updates.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/deviceclasses/{deviceClassId}/installableupdates'} # type: ignore
[docs] def get_all_devices( self, filter=None, # type: Optional[str] **kwargs # type: Any ): # type: (...) -> Iterable["_models.PageableListOfDevices"] """Gets a list of devices connected to Device Update for IoT Hub. :param filter: Restricts the set of devices returned. You can only filter on device GroupId. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PageableListOfDevices or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.iot.deviceupdate.models.PageableListOfDevices] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PageableListOfDevices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) accept = "application/json" def prepare_request(next_link=None): # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') if not next_link: # Construct URL url = self.get_all_devices.metadata['url'] # type: ignore path_format_arguments = { 'accountEndpoint': self._serialize.url("self._config.account_endpoint", self._config.account_endpoint, 'str', skip_quote=True), 'instanceId': self._serialize.url("self._config.instance_id", self._config.instance_id, 'str', skip_quote=True), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') request = self._client.get(url, query_parameters, header_parameters) else: url = next_link query_parameters = {} # type: Dict[str, Any] path_format_arguments = { 'accountEndpoint': self._serialize.url("self._config.account_endpoint", self._config.account_endpoint, 'str', skip_quote=True), 'instanceId': self._serialize.url("self._config.instance_id", self._config.instance_id, 'str', skip_quote=True), } url = self._client.format_url(url, **path_format_arguments) request = self._client.get(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): deserialized = self._deserialize('PageableListOfDevices', pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = self._client._pipeline.run(request, stream=False, **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) return pipeline_response return ItemPaged( get_next, extract_data )
get_all_devices.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/devices'} # type: ignore
[docs] def get_device( self, device_id, # type: str **kwargs # type: Any ): # type: (...) -> "_models.Device" """Gets the device properties and latest deployment status for a device connected to Device Update for IoT Hub. :param device_id: Device identifier in Azure IOT Hub. :type device_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Device, or the result of cls(response) :rtype: ~azure.iot.deviceupdate.models.Device :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.Device"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) accept = "application/json" # Construct URL url = self.get_device.metadata['url'] # type: ignore path_format_arguments = { 'accountEndpoint': self._serialize.url("self._config.account_endpoint", self._config.account_endpoint, 'str', skip_quote=True), 'instanceId': self._serialize.url("self._config.instance_id", self._config.instance_id, 'str', skip_quote=True), 'deviceId': self._serialize.url("device_id", device_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **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) deserialized = self._deserialize('Device', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized
get_device.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/devices/{deviceId}'} # type: ignore
[docs] def get_update_compliance( self, **kwargs # type: Any ): # type: (...) -> "_models.UpdateCompliance" """Gets the breakdown of how many devices are on their latest update, have new updates available, or are in progress receiving new updates. :keyword callable cls: A custom type or function that will be passed the direct response :return: UpdateCompliance, or the result of cls(response) :rtype: ~azure.iot.deviceupdate.models.UpdateCompliance :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.UpdateCompliance"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) accept = "application/json" # Construct URL url = self.get_update_compliance.metadata['url'] # type: ignore path_format_arguments = { 'accountEndpoint': self._serialize.url("self._config.account_endpoint", self._config.account_endpoint, 'str', skip_quote=True), 'instanceId': self._serialize.url("self._config.instance_id", self._config.instance_id, 'str', skip_quote=True), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **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) deserialized = self._deserialize('UpdateCompliance', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized
get_update_compliance.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/updatecompliance'} # type: ignore
[docs] def get_all_device_tags( self, **kwargs # type: Any ): # type: (...) -> Iterable["_models.PageableListOfDeviceTags"] """Gets a list of available group device tags for all devices connected to Device Update for IoT Hub. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PageableListOfDeviceTags or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.iot.deviceupdate.models.PageableListOfDeviceTags] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PageableListOfDeviceTags"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) accept = "application/json" def prepare_request(next_link=None): # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') if not next_link: # Construct URL url = self.get_all_device_tags.metadata['url'] # type: ignore path_format_arguments = { 'accountEndpoint': self._serialize.url("self._config.account_endpoint", self._config.account_endpoint, 'str', skip_quote=True), 'instanceId': self._serialize.url("self._config.instance_id", self._config.instance_id, 'str', skip_quote=True), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] request = self._client.get(url, query_parameters, header_parameters) else: url = next_link query_parameters = {} # type: Dict[str, Any] path_format_arguments = { 'accountEndpoint': self._serialize.url("self._config.account_endpoint", self._config.account_endpoint, 'str', skip_quote=True), 'instanceId': self._serialize.url("self._config.instance_id", self._config.instance_id, 'str', skip_quote=True), } url = self._client.format_url(url, **path_format_arguments) request = self._client.get(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): deserialized = self._deserialize('PageableListOfDeviceTags', pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = self._client._pipeline.run(request, stream=False, **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) return pipeline_response return ItemPaged( get_next, extract_data )
get_all_device_tags.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/devicetags'} # type: ignore
[docs] def get_device_tag( self, tag_name, # type: str **kwargs # type: Any ): # type: (...) -> "_models.DeviceTag" """Gets a count of how many devices have a device tag. :param tag_name: Tag name. :type tag_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DeviceTag, or the result of cls(response) :rtype: ~azure.iot.deviceupdate.models.DeviceTag :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DeviceTag"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) accept = "application/json" # Construct URL url = self.get_device_tag.metadata['url'] # type: ignore path_format_arguments = { 'accountEndpoint': self._serialize.url("self._config.account_endpoint", self._config.account_endpoint, 'str', skip_quote=True), 'instanceId': self._serialize.url("self._config.instance_id", self._config.instance_id, 'str', skip_quote=True), 'tagName': self._serialize.url("tag_name", tag_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **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) deserialized = self._deserialize('DeviceTag', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized
get_device_tag.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/devicetags/{tagName}'} # type: ignore
[docs] def get_all_groups( self, **kwargs # type: Any ): # type: (...) -> Iterable["_models.PageableListOfGroups"] """Gets a list of all device groups. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PageableListOfGroups or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.iot.deviceupdate.models.PageableListOfGroups] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PageableListOfGroups"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) accept = "application/json" def prepare_request(next_link=None): # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') if not next_link: # Construct URL url = self.get_all_groups.metadata['url'] # type: ignore path_format_arguments = { 'accountEndpoint': self._serialize.url("self._config.account_endpoint", self._config.account_endpoint, 'str', skip_quote=True), 'instanceId': self._serialize.url("self._config.instance_id", self._config.instance_id, 'str', skip_quote=True), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] request = self._client.get(url, query_parameters, header_parameters) else: url = next_link query_parameters = {} # type: Dict[str, Any] path_format_arguments = { 'accountEndpoint': self._serialize.url("self._config.account_endpoint", self._config.account_endpoint, 'str', skip_quote=True), 'instanceId': self._serialize.url("self._config.instance_id", self._config.instance_id, 'str', skip_quote=True), } url = self._client.format_url(url, **path_format_arguments) request = self._client.get(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): deserialized = self._deserialize('PageableListOfGroups', pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = self._client._pipeline.run(request, stream=False, **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) return pipeline_response return ItemPaged( get_next, extract_data )
get_all_groups.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/groups'} # type: ignore
[docs] def get_group( self, group_id, # type: str **kwargs # type: Any ): # type: (...) -> "_models.Group" """Gets the properties of a group. :param group_id: Group identifier. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Group, or the result of cls(response) :rtype: ~azure.iot.deviceupdate.models.Group :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.Group"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) accept = "application/json" # Construct URL url = self.get_group.metadata['url'] # type: ignore path_format_arguments = { 'accountEndpoint': self._serialize.url("self._config.account_endpoint", self._config.account_endpoint, 'str', skip_quote=True), 'instanceId': self._serialize.url("self._config.instance_id", self._config.instance_id, 'str', skip_quote=True), 'groupId': self._serialize.url("group_id", group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **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) deserialized = self._deserialize('Group', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized
get_group.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/groups/{groupId}'} # type: ignore
[docs] def create_or_update_group( self, group_id, # type: str group, # type: "_models.Group" **kwargs # type: Any ): # type: (...) -> "_models.Group" """Create or update a device group. :param group_id: Group identifier. :type group_id: str :param group: The group properties. :type group: ~azure.iot.deviceupdate.models.Group :keyword callable cls: A custom type or function that will be passed the direct response :return: Group, or the result of cls(response) :rtype: ~azure.iot.deviceupdate.models.Group :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.Group"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) content_type = kwargs.pop("content_type", "application/json") accept = "application/json" # Construct URL url = self.create_or_update_group.metadata['url'] # type: ignore path_format_arguments = { 'accountEndpoint': self._serialize.url("self._config.account_endpoint", self._config.account_endpoint, 'str', skip_quote=True), 'instanceId': self._serialize.url("self._config.instance_id", self._config.instance_id, 'str', skip_quote=True), 'groupId': self._serialize.url("group_id", group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(group, 'Group') body_content_kwargs['content'] = body_content request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **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) deserialized = self._deserialize('Group', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized
create_or_update_group.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/groups/{groupId}'} # type: ignore
[docs] def delete_group( self, group_id, # type: str **kwargs # type: Any ): # type: (...) -> None """Deletes a device group. :param group_id: Group identifier. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) # Construct URL url = self.delete_group.metadata['url'] # type: ignore path_format_arguments = { 'accountEndpoint': self._serialize.url("self._config.account_endpoint", self._config.account_endpoint, 'str', skip_quote=True), 'instanceId': self._serialize.url("self._config.instance_id", self._config.instance_id, 'str', skip_quote=True), 'groupId': self._serialize.url("group_id", group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] # Construct headers header_parameters = {} # type: Dict[str, Any] request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **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) if cls: return cls(pipeline_response, None, {})
delete_group.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/groups/{groupId}'} # type: ignore
[docs] def get_group_update_compliance( self, group_id, # type: str **kwargs # type: Any ): # type: (...) -> "_models.UpdateCompliance" """Get group update compliance information such as how many devices are on their latest update, how many need new updates, and how many are in progress on receiving a new update. :param group_id: Group identifier. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: UpdateCompliance, or the result of cls(response) :rtype: ~azure.iot.deviceupdate.models.UpdateCompliance :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.UpdateCompliance"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) accept = "application/json" # Construct URL url = self.get_group_update_compliance.metadata['url'] # type: ignore path_format_arguments = { 'accountEndpoint': self._serialize.url("self._config.account_endpoint", self._config.account_endpoint, 'str', skip_quote=True), 'instanceId': self._serialize.url("self._config.instance_id", self._config.instance_id, 'str', skip_quote=True), 'groupId': self._serialize.url("group_id", group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **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) deserialized = self._deserialize('UpdateCompliance', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized
get_group_update_compliance.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/groups/{groupId}/updateCompliance'} # type: ignore
[docs] def get_group_best_updates( self, group_id, # type: str filter=None, # type: Optional[str] **kwargs # type: Any ): # type: (...) -> Iterable["_models.PageableListOfUpdatableDevices"] """Get the best available updates for a group and a count of how many devices need each update. :param group_id: Group identifier. :type group_id: str :param filter: Restricts the set of bestUpdates returned. You can filter on update Provider, Name and Version property. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PageableListOfUpdatableDevices or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.iot.deviceupdate.models.PageableListOfUpdatableDevices] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PageableListOfUpdatableDevices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) accept = "application/json" def prepare_request(next_link=None): # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') if not next_link: # Construct URL url = self.get_group_best_updates.metadata['url'] # type: ignore path_format_arguments = { 'accountEndpoint': self._serialize.url("self._config.account_endpoint", self._config.account_endpoint, 'str', skip_quote=True), 'instanceId': self._serialize.url("self._config.instance_id", self._config.instance_id, 'str', skip_quote=True), 'groupId': self._serialize.url("group_id", group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') request = self._client.get(url, query_parameters, header_parameters) else: url = next_link query_parameters = {} # type: Dict[str, Any] path_format_arguments = { 'accountEndpoint': self._serialize.url("self._config.account_endpoint", self._config.account_endpoint, 'str', skip_quote=True), 'instanceId': self._serialize.url("self._config.instance_id", self._config.instance_id, 'str', skip_quote=True), 'groupId': self._serialize.url("group_id", group_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) request = self._client.get(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): deserialized = self._deserialize('PageableListOfUpdatableDevices', pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = self._client._pipeline.run(request, stream=False, **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) return pipeline_response return ItemPaged( get_next, extract_data )
get_group_best_updates.metadata = {'url': '/deviceupdate/{instanceId}/v2/management/groups/{groupId}/bestUpdates'} # type: ignore