Skip to content

Commit b9fd183

Browse files
authored
[Deviceupdate] new api version 2021-06-01-preview (Azure#22354)
* update from private repo * regenerate code * update setup.pys * run live test * changelog * update changelog * update azure-core dependency * update test * Update shared_requirements.txt * regenerate code * rerun test * Update setup.py * review * update changelog * Update CHANGELOG.md * Update CHANGELOG.md * Update CHANGELOG.md
1 parent 3b61512 commit b9fd183

File tree

87 files changed

+10020
-11679
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+10020
-11679
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,50 @@
11
# Release History
22

3+
## 1.0.0b2 (2022-01-25)
4+
5+
### Features Added
6+
7+
- Added DeviceManagementOperations
8+
- Added DeviceUpdateOperations
9+
- Added operation `send_request` to send customized http request conveniently
10+
- Added `client.device_management`
11+
12+
### Breaking Changes
13+
14+
- Removed all models
15+
- Removed DeploymentsOperations
16+
- Removed UpdateOperations
17+
- Dropped support for Python2.7(https://github.com/Azure/azure-sdk-for-python#disclaimer)
18+
- Parameter `account_endpoint` of DeviceUpdateClient is renamed to `endpoint`
19+
- Renamed `client.updates` to `client.device_update`
20+
- Removed `client.devices`
21+
- Removed `client.deployments`
22+
- Renamed UpdatesOperations.get_update to DeviceUpdateOperations.get_update
23+
- Renamed UpdatesOperations.delete_update to DeviceUpdateOperations.begin_delete_update
24+
- Renamed UpdatesOperations.get_providers to DeviceUpdateOperations.list_providers
25+
- Renamed UpdatesOperations.get_names to DeviceUpdateOperations.list_names
26+
- Renamed UpdatesOperations.get_versions to DeviceUpdateOperations.list_versions
27+
- Renamed UpdatesOperations.get_file to DeviceUpdateOperations.get_file
28+
- Renamed UpdatesOperations.get_files to DeviceUpdateOperations.list_files
29+
- Renamed UpdatesOperations.get_operation to DeviceUpdateOperations.get_operation
30+
- Renamed UpdatesOperations.get_operations to DeviceUpdateOperations.list_operations
31+
- Renamed DevicesOperations.get_all_device_classes to DeviceManagementOperations.list_device_classes
32+
- Renamed DevicesOperations.get_device_class to DeviceManagementOperations.get_device_class
33+
- Renamed DevicesOperations.get_device_class_device_ids to DeviceManagementOperations.
34+
- Renamed DevicesOperations.list_devices to DeviceManagementOperations.list_devices
35+
- Renamed DevicesOperations.list_devices to DeviceManagementOperations.
36+
- Renamed DevicesOperations.get_all_device_tags to DeviceManagementOperations.list_device_tags
37+
- Renamed DevicesOperations.get_all_groups to DeviceManagementOperations.list_groups
38+
- Renamed DevicesOperations.get_group to DeviceManagementOperations.get_group
39+
- Renamed DevicesOperations.create_or_update_group to DeviceManagementOperations.create_or_update_group
40+
- Renamed DevicesOperations.delete_group to DeviceManagementOperations.delete_group
41+
- Renamed DevicesOperations.get_group_update_compliance to DeviceManagementOperations.get_group_update_compliance
42+
- Renamed DevicesOperations.get_group_best_updates to DeviceManagementOperations.list_best_updates_for_group
43+
- Renamed DeploymentsOperations.get_deployment_status to DeviceManagementOperations.get_deployment_status
44+
- Renamed DeploymentsOperations.create_or_update_deployment to DeviceManagementOperations.create_or_update_deployment
45+
- Renamed DeploymentsOperations.delete_deployment to DeviceManagementOperations.delete_deployment
46+
- Renamed DeploymentsOperations.get_deployment_devices to DeviceManagementOperations.list_deployment_devices
47+
48+
349
## 1.0.0b1 (2021-03-03)
450
* This is the initial release of Azure Device Update for IoT Hub library.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Copyright (c) Microsoft Corporation.
2+
3+
MIT License
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
recursive-include tests *.py
22
recursive-include samples *.py *.md
3+
include LICENSE
34
include *.md
45
include azure/__init__.py
56
include azure/iot/__init__.py

sdk/deviceupdate/azure-iot-deviceupdate/README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,33 @@ The library provides access to the Device Update for IoT Hub service that enable
44

55
[Source code](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/deviceupdate/azure-iot-deviceupdate) | [Package (PyPI)](https://aka.ms/azsdk/python/deviceupdate-pypi) | [Product documentation](https://docs.microsoft.com/azure/iot-hub-device-update/understand-device-update)
66

7+
## _Disclaimer_
8+
9+
_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_
10+
711
## Getting started
812

913
### Prerequisites
1014

1115
- Microsoft Azure Subscription: To call Microsoft Azure services, you need to create an [Azure subscription](https://azure.microsoft.com/free/)
1216
- Device Update for IoT Hub instance
1317
- Azure IoT Hub instance
14-
- Python 2.7, or 3.6 or later is required to use this package.
18+
- Python 3.6 or later is required to use this package.
1519

1620
### Install the package
1721

1822
Install the Device Update for IoT Hub client library for Python with [pip](https://pypi.org/project/pip/):
1923

2024
```bash
21-
pip install azure-iot-deviceupdate --pre
25+
pip install azure-iot-deviceupdate
2226
```
2327

2428
## Key concepts
2529

26-
Device Update for IoT Hub is a managed service that enables you to deploy over-the-air updates for your IoT devices. The client library has one main component named **AzureDeviceUpdateServiceDataPlane**. The component allows you to access all three main client services:
30+
Device Update for IoT Hub is a managed service that enables you to deploy over-the-air updates for your IoT devices. The client library has one main component named **DeviceUpdateClient**. The component allows you to access all three main client services:
2731

2832
- **UpdatesOperations**: update management (import, enumerate, delete, etc.)
29-
- **DevicesOperations**: device management (enumerate devices and retrieve device properties)
30-
- **DeploymentsOperations**: deployment management (start and monitor update deployments to a set of devices)
33+
- **ManagementOperations**: deployment management (manage devices and deployments)
3134

3235
You can learn more about Device Update for IoT Hub by visiting [Device Update for IoT Hub](https://github.com/azure/iot-hub-device-update).
3336

@@ -41,7 +44,7 @@ The Device Update for IoT Hub client will raise exceptions defined in [Azure Cor
4144

4245
## Next steps
4346

44-
Get started with our [Device Update for IoT Hub samples](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/deviceupdate/azure-iot-deviceupdate/samples)
47+
Get started with our [Samples](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/deviceupdate/azure-iot-deviceupdate/samples).
4548

4649
## Contributing
4750

sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/__init__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
__version__ = VERSION
1313
__all__ = ['DeviceUpdateClient']
1414

15-
try:
16-
from ._patch import patch_sdk # type: ignore
17-
patch_sdk()
18-
except ImportError:
19-
pass
15+
# `._patch.py` is used for handwritten extensions to the generated code
16+
# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
17+
from ._patch import patch_sdk
18+
patch_sdk()

sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/_configuration.py

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
from typing import TYPE_CHECKING
9+
from typing import Any, TYPE_CHECKING
1010

1111
from azure.core.configuration import Configuration
1212
from azure.core.pipeline import policies
@@ -15,8 +15,6 @@
1515

1616
if TYPE_CHECKING:
1717
# pylint: disable=unused-import,ungrouped-imports
18-
from typing import Any
19-
2018
from azure.core.credentials import TokenCredential
2119

2220

@@ -26,33 +24,37 @@ class DeviceUpdateClientConfiguration(Configuration):
2624
Note that all parameters used to create this instance are saved as instance
2725
attributes.
2826
29-
:param credential: Credential needed for the client to connect to Azure.
30-
:type credential: ~azure.core.credentials.TokenCredential
31-
:param account_endpoint: Account endpoint.
32-
:type account_endpoint: str
27+
:param endpoint: Account endpoint.
28+
:type endpoint: str
3329
:param instance_id: Account instance identifier.
3430
:type instance_id: str
31+
:param credential: Credential needed for the client to connect to Azure.
32+
:type credential: ~azure.core.credentials.TokenCredential
33+
:keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that overriding this default value may result in unsupported behavior.
34+
:paramtype api_version: str
3535
"""
3636

3737
def __init__(
3838
self,
39-
credential, # type: "TokenCredential"
40-
account_endpoint, # type: str
41-
instance_id, # type: str
42-
**kwargs # type: Any
43-
):
44-
# type: (...) -> None
45-
if credential is None:
46-
raise ValueError("Parameter 'credential' must not be None.")
47-
if account_endpoint is None:
48-
raise ValueError("Parameter 'account_endpoint' must not be None.")
39+
endpoint: str,
40+
instance_id: str,
41+
credential: "TokenCredential",
42+
**kwargs: Any
43+
) -> None:
44+
super(DeviceUpdateClientConfiguration, self).__init__(**kwargs)
45+
api_version = kwargs.pop('api_version', "2021-06-01-preview") # type: str
46+
47+
if endpoint is None:
48+
raise ValueError("Parameter 'endpoint' must not be None.")
4949
if instance_id is None:
5050
raise ValueError("Parameter 'instance_id' must not be None.")
51-
super(DeviceUpdateClientConfiguration, self).__init__(**kwargs)
51+
if credential is None:
52+
raise ValueError("Parameter 'credential' must not be None.")
5253

53-
self.credential = credential
54-
self.account_endpoint = account_endpoint
54+
self.endpoint = endpoint
5555
self.instance_id = instance_id
56+
self.credential = credential
57+
self.api_version = api_version
5658
self.credential_scopes = kwargs.pop('credential_scopes', ['https://api.adu.microsoft.com/.default'])
5759
kwargs.setdefault('sdk_moniker', 'iot-deviceupdate/{}'.format(VERSION))
5860
self._configure(**kwargs)

sdk/deviceupdate/azure-iot-deviceupdate/azure/iot/deviceupdate/_device_update_client.py

Lines changed: 57 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -6,84 +6,89 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
from typing import TYPE_CHECKING
9+
from copy import deepcopy
10+
from typing import Any, Optional, TYPE_CHECKING
1011

1112
from azure.core import PipelineClient
13+
from azure.core.rest import HttpRequest, HttpResponse
1214
from msrest import Deserializer, Serializer
1315

16+
from ._configuration import DeviceUpdateClientConfiguration
17+
from .operations import DeviceManagementOperations, DeviceUpdateOperations
18+
1419
if TYPE_CHECKING:
1520
# pylint: disable=unused-import,ungrouped-imports
16-
from typing import Any
21+
from typing import Dict
1722

1823
from azure.core.credentials import TokenCredential
19-
from azure.core.pipeline.transport import HttpRequest, HttpResponse
20-
21-
from ._configuration import DeviceUpdateClientConfiguration
22-
from .operations import UpdatesOperations
23-
from .operations import DevicesOperations
24-
from .operations import DeploymentsOperations
25-
from . import models
2624

27-
28-
class DeviceUpdateClient(object):
25+
class DeviceUpdateClient:
2926
"""Device Update for IoT Hub is an Azure service that enables customers to publish update for their IoT devices to the cloud, and then deploy that update to their devices (approve updates to groups of devices managed and provisioned in IoT Hub). It leverages the proven security and reliability of the Windows Update platform, optimized for IoT devices. It works globally and knows when and how to update devices, enabling customers to focus on their business goals and let Device Update for IoT Hub handle the updates.
3027
31-
:ivar updates: UpdatesOperations operations
32-
:vartype updates: azure.iot.deviceupdate.operations.UpdatesOperations
33-
:ivar devices: DevicesOperations operations
34-
:vartype devices: azure.iot.deviceupdate.operations.DevicesOperations
35-
:ivar deployments: DeploymentsOperations operations
36-
:vartype deployments: azure.iot.deviceupdate.operations.DeploymentsOperations
37-
:param credential: Credential needed for the client to connect to Azure.
38-
:type credential: ~azure.core.credentials.TokenCredential
39-
:param account_endpoint: Account endpoint.
40-
:type account_endpoint: str
28+
:ivar device_update: DeviceUpdateOperations operations
29+
:vartype device_update: azure.iot.deviceupdate.operations.DeviceUpdateOperations
30+
:ivar device_management: DeviceManagementOperations operations
31+
:vartype device_management: azure.iot.deviceupdate.operations.DeviceManagementOperations
32+
:param endpoint: Account endpoint.
33+
:type endpoint: str
4134
:param instance_id: Account instance identifier.
4235
:type instance_id: str
36+
:param credential: Credential needed for the client to connect to Azure.
37+
:type credential: ~azure.core.credentials.TokenCredential
38+
:keyword api_version: Api Version. The default value is "2021-06-01-preview". Note that
39+
overriding this default value may result in unsupported behavior.
40+
:paramtype api_version: str
41+
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
42+
Retry-After header is present.
4343
"""
4444

4545
def __init__(
4646
self,
47-
credential, # type: "TokenCredential"
48-
account_endpoint, # type: str
49-
instance_id, # type: str
50-
**kwargs # type: Any
51-
):
52-
# type: (...) -> None
53-
base_url = 'https://{accountEndpoint}'
54-
self._config = DeviceUpdateClientConfiguration(credential, account_endpoint, instance_id, **kwargs)
55-
self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs)
56-
57-
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
58-
self._serialize = Serializer(client_models)
47+
endpoint: str,
48+
instance_id: str,
49+
credential: "TokenCredential",
50+
**kwargs: Any
51+
) -> None:
52+
_endpoint = 'https://{endpoint}'
53+
self._config = DeviceUpdateClientConfiguration(endpoint=endpoint, instance_id=instance_id, credential=credential, **kwargs)
54+
self._client = PipelineClient(base_url=_endpoint, config=self._config, **kwargs)
55+
56+
self._serialize = Serializer()
57+
self._deserialize = Deserializer()
5958
self._serialize.client_side_validation = False
60-
self._deserialize = Deserializer(client_models)
59+
self.device_update = DeviceUpdateOperations(self._client, self._config, self._serialize, self._deserialize)
60+
self.device_management = DeviceManagementOperations(self._client, self._config, self._serialize, self._deserialize)
6161

62-
self.updates = UpdatesOperations(
63-
self._client, self._config, self._serialize, self._deserialize)
64-
self.devices = DevicesOperations(
65-
self._client, self._config, self._serialize, self._deserialize)
66-
self.deployments = DeploymentsOperations(
67-
self._client, self._config, self._serialize, self._deserialize)
6862

69-
def _send_request(self, http_request, **kwargs):
70-
# type: (HttpRequest, Any) -> HttpResponse
63+
def send_request(
64+
self,
65+
request, # type: HttpRequest
66+
**kwargs: Any
67+
) -> HttpResponse:
7168
"""Runs the network request through the client's chained policies.
7269
73-
:param http_request: The network request you want to make. Required.
74-
:type http_request: ~azure.core.pipeline.transport.HttpRequest
75-
:keyword bool stream: Whether the response payload will be streamed. Defaults to True.
70+
>>> from azure.core.rest import HttpRequest
71+
>>> request = HttpRequest("GET", "https://www.example.org/")
72+
<HttpRequest [GET], url: 'https://www.example.org/'>
73+
>>> response = client.send_request(request)
74+
<HttpResponse: 200 OK>
75+
76+
For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart
77+
78+
:param request: The network request you want to make. Required.
79+
:type request: ~azure.core.rest.HttpRequest
80+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
7681
:return: The response of your network call. Does not do error handling on your response.
77-
:rtype: ~azure.core.pipeline.transport.HttpResponse
82+
:rtype: ~azure.core.rest.HttpResponse
7883
"""
84+
85+
request_copy = deepcopy(request)
7986
path_format_arguments = {
80-
'accountEndpoint': self._serialize.url("self._config.account_endpoint", self._config.account_endpoint, 'str', skip_quote=True),
81-
'instanceId': self._serialize.url("self._config.instance_id", self._config.instance_id, 'str', skip_quote=True),
87+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
8288
}
83-
http_request.url = self._client.format_url(http_request.url, **path_format_arguments)
84-
stream = kwargs.pop("stream", True)
85-
pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs)
86-
return pipeline_response.http_response
89+
90+
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
91+
return self._client.send_request(request_copy, **kwargs)
8792

8893
def close(self):
8994
# type: () -> None
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
#
4+
# Copyright (c) Microsoft Corporation. All rights reserved.
5+
#
6+
# The MIT License (MIT)
7+
#
8+
# Permission is hereby granted, free of charge, to any person obtaining a copy
9+
# of this software and associated documentation files (the ""Software""), to
10+
# deal in the Software without restriction, including without limitation the
11+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12+
# sell copies of the Software, and to permit persons to whom the Software is
13+
# furnished to do so, subject to the following conditions:
14+
#
15+
# The above copyright notice and this permission notice shall be included in
16+
# all copies or substantial portions of the Software.
17+
#
18+
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24+
# IN THE SOFTWARE.
25+
#
26+
# --------------------------------------------------------------------------
27+
28+
# This file is used for handwritten extensions to the generated code. Example:
29+
# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
30+
def patch_sdk():
31+
pass

0 commit comments

Comments
 (0)